From ddff7286d798599352c9b02e822e5a2f76c6bfcc Mon Sep 17 00:00:00 2001 From: picocodes Date: Thu, 8 Feb 2024 08:05:24 +0300 Subject: [PATCH] fix automation rule email data reset --- build/Emails/assets/js/email-editor.asset.php | 2 +- build/Emails/assets/js/email-editor.js | 30 +++++++++---------- .../class-type-automation-rule.php | 8 ++++- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/build/Emails/assets/js/email-editor.asset.php b/build/Emails/assets/js/email-editor.asset.php index 6ede699e..73ab8bc0 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-autop', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-commands', '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-plugins', 'wp-preferences', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '2209755333bd4256b0bb'); + array('lodash', 'react', 'wp-api-fetch', 'wp-autop', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-commands', '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-plugins', 'wp-preferences', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '0172c29bf3a267e78974'); diff --git a/build/Emails/assets/js/email-editor.js b/build/Emails/assets/js/email-editor.js index 6de992b0..109e0101 100644 --- a/build/Emails/assets/js/email-editor.js +++ b/build/Emails/assets/js/email-editor.js @@ -1,4 +1,4 @@ -(()=>{var e,t={409:(e,t,n)=>{"use strict";var a={};n.r(a),n.d(a,{BLOCK_INSPECTOR_IDENTIFIER:()=>D,CONTENT_TYPES:()=>R,CONTENT_TYPE_OPTIONS:()=>z,EMAIL_SETTINGS_IDENTIFIER:()=>V,HUGE_VIEWPORT:()=>F,JS_MISC_SETTINGS:()=>M,JS_SETTINGS:()=>N,NOPTIN_LICENSE_KEY:()=>L,STORE_NAME:()=>A,TEMPLATE_OPTIONS:()=>$});var r={};n.r(r),n.d(r,{closeModal:()=>Ie,disableComplementaryArea:()=>ke,enableComplementaryArea:()=>xe,openModal:()=>Pe,pinItem:()=>we,setDefaultComplementaryArea:()=>Ee,setFeatureDefaults:()=>Be,setFeatureValue:()=>Te,toggleFeature:()=>Se,unpinItem:()=>Ce});var o={};n.r(o),n.d(o,{getActiveComplementaryArea:()=>Ae,isComplementaryAreaLoading:()=>Ne,isFeatureActive:()=>Le,isItemPinned:()=>Me,isModalActive:()=>Re});var l={};n.r(l),n.d(l,{openGeneralSidebar:()=>De,registerSidebar:()=>Ue,setBlockCss:()=>Ge,setCurrentSidebar:()=>je,setIsInserterOpened:()=>He,setLicenseKeyDetails:()=>We,setPreviewDeviceType:()=>Oe,togglePinnedPluginItem:()=>Ve,updatePreferredStyleVariations:()=>Fe});var i={};n.r(i),n.d(i,{getBlockCSS:()=>Je,getCurrentSidebar:()=>Ye,getInsertionPoint:()=>Xe,getLicenseKeyDetails:()=>et,getPreviewDeviceType:()=>qe,getSidebars:()=>Ze,isInserterOpened:()=>Qe});var s={};n.r(s),n.d(s,{getLicenseKeyDetails:()=>nt});var c={};n.r(c),n.d(c,{LICENSE_DETAILS:()=>ct,getCurrentMergeTags:()=>el,hasLicense:()=>ut,isPremiumAutomatedEmail:()=>_t,onEmailTypeChange:()=>Q,useBlockCss:()=>Y,useBlockEditorSettings:()=>ot,useCampaignSubType:()=>K,useCampaignType:()=>W,useCampaignTypeInfo:()=>G,useColors:()=>yt,useContentType:()=>q,useCustomCss:()=>lt,useDebouncedInput:()=>ht,useEmailField:()=>U,useMergeTags:()=>Jo,useMetaField:()=>J,usePost:()=>j,usePostId:()=>H,usePostType:()=>O,usePremiumFeature:()=>pt,usePublicPostTypes:()=>bt,useSetStyleValue:()=>it,useTaxonomies:()=>ft,useTemplateOnly:()=>X});var u={};n.r(u),n.d(u,{constants:()=>a,hooks:()=>c,initializeEditor:()=>ms,store:()=>at}),window.wp.formatLibrary;const p=window.wp.hooks,m=window.wp.mediaUtils;(0,p.addFilter)("editor.MediaUpload","noptin/edit-email/components/media-upload",(()=>m.MediaUpload));const d=window.React;var g=n.n(d);const _=window.wp.compose;var h=n(184),b=n.n(h);const f=["core/html","noptin/missing","noptin/shortcode"],y=[...f,"noptin/social-link","noptin/spacer","noptin/social-links","noptin/separator","core/image","noptin/button"];(0,p.addFilter)("blocks.getSaveContent.extraProps","noptin/style/addSaveProps",(function(e,t,n){return y.includes(t.name)||(e.className=b()(e.className,n.anchor?n.anchor:null)),e}));const v=(0,_.createHigherOrderComponent)((e=>t=>{const n={...t.wrapperProps||{},className:b()(t.wrapperProps?.className,y.includes(t.name)?null:t.attributes?.anchor)};return[(0,d.createElement)(e,{key:"edit",...t,wrapperProps:n})]}),"withNoptinAnchorClass");(0,p.addFilter)("editor.BlockListBlock","noptin/style/addAnchorClass",v);const E=window.wp.url,x=window.wp.apiFetch;var k=n.n(x);const w={"/wp/v2/block-patterns/categories":[],"/wp/v2/block-patterns/patterns":[],"/wp/v2/wp_pattern_category":[],"/wp/v2/blocks":[]};k().use(((e,t)=>{const{parse:n=!0}=e;let a=e.path;if(!a&&e.url){const{rest_route:t}=(0,E.getQueryArgs)(e.url);"string"==typeof t&&(a=t)}if("string"!=typeof a)return t(e);a=a.split("?")[0],a=a.replace(/^\/?/,"/");const r=e.method||"GET",o=(0,E.normalizePath)(a);return"GET"===r&&w[o]?function(e,t){return Promise.resolve(t?e:new window.Response(JSON.stringify(e),{status:200,statusText:"OK",headers:{"Content-Type":"application/json"}}))}(w[o],!!n):t(e)}));const C=window.wp.components,S=window.wp.element,T=window.wp.editor,B=window.wp.blockEditor,P=window.wp.data,I=window.wp.coreData,A="noptin/edit-email",N=window.noptinEmailEditorSettings||{},M=window.noptinEmailSettingsMisc||{},L=M.license?.key||"",R=N.types||{},z=Object.keys(R).map((e=>({value:e,label:R[e].label}))),$=Object.keys(N.templates||{}).map((e=>({value:e,label:N.templates[e]}))),D=`${A}/block-inspector`,V=`${A}/email-settings`,F=1440,O=()=>(0,P.useSelect)((e=>e(T.store).getCurrentPostType()),[]),H=()=>(0,P.useSelect)((e=>e(T.store).getCurrentPostId()),[]),j=()=>(0,P.useSelect)((e=>{const{getEditedEntityRecord:t}=e(I.store),{getCurrentPostType:n,getCurrentPostId:a}=e(T.store);return t("postType",n(),a())}),[]),U=e=>(0,I.useEntityProp)("postType",O(),e),G=()=>{const[e]=U("noptin_campaign_type");return e||{}},W=()=>{const[e]=U("meta");return e?.campaign_type},K=()=>{const[e]=U("meta"),t=e?.campaign_type;return t?e?.[`${t}_type`]:void 0},q=()=>{const[e,t]=U("meta"),[n,...a]=J("email_type",e,t);return[n||"normal",...a]},Y=()=>{const[e,t]=U("meta"),[n,a]=J("block_css",e,t),r=n||{},o=(0,S.useCallback)(((e,t)=>{const n={...r,[e]:t};Object.keys(n).forEach((e=>{n[e]||delete n[e]})),a(n)}),[n,a]);return[r,o]},Z=N.templateDefaults||{},Q=e=>{const t="normal"===e.email_type?e.template:"visual"===e.email_type?"noptin-visual":"";return t?{...e,...N?.templateDefaults?.[t]||{}}:e},X=()=>{const[e]=U("meta"),t=(e||{}).campaign_data||{},n=t.template,a=t.email_type||"visual",r="normal"===a?n:"visual"===a?"noptin-visual":"",o=r&&Z[r]?Object.keys(Z[r]):[];return{template:n,emailType:a,templateSupports:e=>o.includes(e)}},J=(e,t,n)=>{const a=t||{},r=a.campaign_data||{};return[r[e],(0,S.useCallback)((t=>{n({...a,campaign_data:{...r,[e]:t}})}),[t,n])]},ee=window.wp.i18n;function te(e,t){const n=[];return e?(Object.keys(e).forEach((a=>{const r=e[a];if(r.hidden)return;if(r.conditions&&!r.conditions.every((e=>{let n=!1;return n=Array.isArray(e.value)?e.value.some((n=>n==t[e.key])):e.value==t[e.key],n===("is"===e.operator)})))return;let o=a;r.label?o=r.label:r.description&&(o=r.description),n.push({...r,smart_tag:a,label:o,example:r.example?r.example:"",description:r.description?r.description:"",placeholder:r.placeholder?r.placeholder:"",conditional_logic:!!r.conditional_logic&&r.conditional_logic,options:r.options?r.options:[]})})),n):n}const ne=window.wp.blocks,ae=(e,t)=>!0===e||(Array.isArray(e)?e.includes(t):"object"==typeof e&&!0===e[t]),re=window.wp.preferences,oe=window.matchMedia(`(min-width: ${F}px)`).matches,le=(0,P.combineReducers)({deviceType:function(e="Desktop",t){return"SET_PREVIEW_DEVICE_TYPE"===t.type?t.deviceType:e},blockInserterPanel:function(e=oe,t){return"SET_IS_INSERTER_OPENED"===t.type?t.value:e},sidebar:function(e={all:{},current:void 0},t){switch(t.type){case"SET_CURRENT_SIDEBAR":return{...e,current:t.value};case"REGISTER_SIDEBAR":return{...e,all:{...e.all,[t.name]:t.sidebar}}}return e},blockCSS:function(e={},t){return"SET_BLOCK_CSS"===t.type?{...e,[t.key]:t.css}:e}}),ie=({isActive:e})=>((0,S.useEffect)((()=>{let e=!1;return document.body.classList.contains("sticky-menu")&&(e=!0,document.body.classList.remove("sticky-menu")),()=>{e&&document.body.classList.add("sticky-menu")}}),[]),(0,S.useEffect)((()=>(e?document.body.classList.add("is-fullscreen-mode"):document.body.classList.remove("is-fullscreen-mode"),()=>{e&&document.body.classList.remove("is-fullscreen-mode")})),[e]),null);function se({children:e,className:t,ariaLabel:n,as:a="div",...r}){return(0,d.createElement)(a,{className:b()("interface-navigable-region",t),"aria-label":n,role:"region",tabIndex:"-1",...r},e)}const ce={hidden:{opacity:0},hover:{opacity:1,transition:{type:"tween",delay:.2,delayChildren:.2}},distractionFreeInactive:{opacity:1,transition:{delay:0}}},ue=(0,S.forwardRef)((function({isDistractionFree:e,footer:t,header:n,editorNotices:a,sidebar:r,secondarySidebar:o,notices:l,content:i,contentProps:s,actions:c,labels:u,className:p,enableRegionNavigation:m=!0,shortcuts:g},h){const f=(0,C.__unstableUseNavigateRegions)(g);!function(e){(0,S.useEffect)((()=>{const t=document&&document.querySelector(`html:not(.${e})`);if(t)return t.classList.toggle(e),()=>{t.classList.toggle(e)}}),[e])}("interface-interface-skeleton__html-container");const y={ +(()=>{var e,t={409:(e,t,n)=>{"use strict";var a={};n.r(a),n.d(a,{BLOCK_INSPECTOR_IDENTIFIER:()=>$,CONTENT_TYPES:()=>R,CONTENT_TYPE_OPTIONS:()=>z,EMAIL_SETTINGS_IDENTIFIER:()=>V,HUGE_VIEWPORT:()=>F,JS_MISC_SETTINGS:()=>M,JS_SETTINGS:()=>N,NOPTIN_LICENSE_KEY:()=>L,STORE_NAME:()=>A,TEMPLATE_OPTIONS:()=>D});var r={};n.r(r),n.d(r,{closeModal:()=>Ie,disableComplementaryArea:()=>ke,enableComplementaryArea:()=>xe,openModal:()=>Pe,pinItem:()=>we,setDefaultComplementaryArea:()=>Ee,setFeatureDefaults:()=>Be,setFeatureValue:()=>Te,toggleFeature:()=>Se,unpinItem:()=>Ce});var o={};n.r(o),n.d(o,{getActiveComplementaryArea:()=>Ae,isComplementaryAreaLoading:()=>Ne,isFeatureActive:()=>Le,isItemPinned:()=>Me,isModalActive:()=>Re});var l={};n.r(l),n.d(l,{openGeneralSidebar:()=>$e,registerSidebar:()=>Ue,setBlockCss:()=>Ge,setCurrentSidebar:()=>je,setIsInserterOpened:()=>Oe,setLicenseKeyDetails:()=>We,setPreviewDeviceType:()=>He,togglePinnedPluginItem:()=>Ve,updatePreferredStyleVariations:()=>Fe});var i={};n.r(i),n.d(i,{getBlockCSS:()=>Je,getCurrentSidebar:()=>Ye,getInsertionPoint:()=>Xe,getLicenseKeyDetails:()=>et,getPreviewDeviceType:()=>qe,getSidebars:()=>Ze,isInserterOpened:()=>Qe});var s={};n.r(s),n.d(s,{getLicenseKeyDetails:()=>nt});var c={};n.r(c),n.d(c,{LICENSE_DETAILS:()=>ct,getCurrentMergeTags:()=>Qo,hasLicense:()=>ut,isPremiumAutomatedEmail:()=>_t,onEmailTypeChange:()=>Q,useBlockCss:()=>Y,useBlockEditorSettings:()=>ot,useCampaignSubType:()=>K,useCampaignType:()=>W,useCampaignTypeInfo:()=>G,useColors:()=>yt,useContentType:()=>q,useCustomCss:()=>lt,useDebouncedInput:()=>ht,useEmailField:()=>U,useMergeTags:()=>Zo,useMetaField:()=>J,usePost:()=>j,usePostId:()=>O,usePostType:()=>H,usePremiumFeature:()=>pt,usePublicPostTypes:()=>bt,useSetStyleValue:()=>it,useTaxonomies:()=>ft,useTemplate:()=>X});var u={};n.r(u),n.d(u,{constants:()=>a,hooks:()=>c,initializeEditor:()=>us,store:()=>at}),window.wp.formatLibrary;const p=window.wp.hooks,m=window.wp.mediaUtils;(0,p.addFilter)("editor.MediaUpload","noptin/edit-email/components/media-upload",(()=>m.MediaUpload));const d=window.React;var g=n.n(d);const _=window.wp.compose;var h=n(184),b=n.n(h);const f=["core/html","noptin/missing","noptin/shortcode"],y=[...f,"noptin/social-link","noptin/spacer","noptin/social-links","noptin/separator","core/image","noptin/button"];(0,p.addFilter)("blocks.getSaveContent.extraProps","noptin/style/addSaveProps",(function(e,t,n){return y.includes(t.name)||(e.className=b()(e.className,n.anchor?n.anchor:null)),e}));const v=(0,_.createHigherOrderComponent)((e=>t=>{const n={...t.wrapperProps||{},className:b()(t.wrapperProps?.className,y.includes(t.name)?null:t.attributes?.anchor)};return[(0,d.createElement)(e,{key:"edit",...t,wrapperProps:n})]}),"withNoptinAnchorClass");(0,p.addFilter)("editor.BlockListBlock","noptin/style/addAnchorClass",v);const E=window.wp.url,x=window.wp.apiFetch;var k=n.n(x);const w={"/wp/v2/block-patterns/categories":[],"/wp/v2/block-patterns/patterns":[],"/wp/v2/wp_pattern_category":[],"/wp/v2/blocks":[]};k().use(((e,t)=>{const{parse:n=!0}=e;let a=e.path;if(!a&&e.url){const{rest_route:t}=(0,E.getQueryArgs)(e.url);"string"==typeof t&&(a=t)}if("string"!=typeof a)return t(e);a=a.split("?")[0],a=a.replace(/^\/?/,"/");const r=e.method||"GET",o=(0,E.normalizePath)(a);return"GET"===r&&w[o]?function(e,t){return Promise.resolve(t?e:new window.Response(JSON.stringify(e),{status:200,statusText:"OK",headers:{"Content-Type":"application/json"}}))}(w[o],!!n):t(e)}));const C=window.wp.components,S=window.wp.element,T=window.wp.editor,B=window.wp.blockEditor,P=window.wp.data,I=window.wp.coreData,A="noptin/edit-email",N=window.noptinEmailEditorSettings||{},M=window.noptinEmailSettingsMisc||{},L=M.license?.key||"",R=N.types||{},z=Object.keys(R).map((e=>({value:e,label:R[e].label}))),D=Object.keys(N.templates||{}).map((e=>({value:e,label:N.templates[e]}))),$=`${A}/block-inspector`,V=`${A}/email-settings`,F=1440,H=()=>(0,P.useSelect)((e=>e(T.store).getCurrentPostType()),[]),O=()=>(0,P.useSelect)((e=>e(T.store).getCurrentPostId()),[]),j=()=>(0,P.useSelect)((e=>{const{getEditedEntityRecord:t}=e(I.store),{getCurrentPostType:n,getCurrentPostId:a}=e(T.store);return t("postType",n(),a())}),[]),U=e=>(0,I.useEntityProp)("postType",H(),e),G=()=>{const[e]=U("noptin_campaign_type");return e||{}},W=()=>{const[e]=U("meta");return e?.campaign_type},K=()=>{const[e]=U("meta"),t=e?.campaign_type;return t?e?.[`${t}_type`]:void 0},q=()=>{const[e,t]=U("meta"),[n,...a]=J("email_type",e,t);return[n||"normal",...a]},Y=()=>{const[e,t]=U("meta"),[n,a]=J("block_css",e,t),r=n||{};return[r,(e,t)=>{const n={...r,[e]:t};Object.keys(n).forEach((e=>{n[e]||delete n[e]})),a(n)}]},Z=N.templateDefaults||{},Q=e=>{const t="normal"===e.email_type?e.template:"visual"===e.email_type?"noptin-visual":"";return t?{...e,...N?.templateDefaults?.[t]||{}}:e},X=()=>{const[e]=U("meta"),t=(e||{}).campaign_data||{},n=t.template,a=t.email_type||"visual",r="normal"===a?n:"visual"===a?"noptin-visual":"",o=r&&Z[r]?Object.keys(Z[r]):[];return{template:n,emailType:a,templateSupports:e=>o.includes(e)}},J=(e,t,n)=>{const a=t||{},r=a.campaign_data||{};return[r[e],t=>{n({...a,campaign_data:{...r,[e]:t}})}]},ee=window.wp.i18n;function te(e,t){const n=[];return e?(Object.keys(e).forEach((a=>{const r=e[a];if(r.hidden)return;if(r.conditions&&!r.conditions.every((e=>{let n=!1;return n=Array.isArray(e.value)?e.value.some((n=>n==t[e.key])):e.value==t[e.key],n===("is"===e.operator)})))return;let o=a;r.label?o=r.label:r.description&&(o=r.description),n.push({...r,smart_tag:a,label:o,example:r.example?r.example:"",description:r.description?r.description:"",placeholder:r.placeholder?r.placeholder:"",conditional_logic:!!r.conditional_logic&&r.conditional_logic,options:r.options?r.options:[]})})),n):n}const ne=window.wp.blocks,ae=(e,t)=>!0===e||(Array.isArray(e)?e.includes(t):"object"==typeof e&&!0===e[t]),re=window.wp.preferences,oe=window.matchMedia(`(min-width: ${F}px)`).matches,le=(0,P.combineReducers)({deviceType:function(e="Desktop",t){return"SET_PREVIEW_DEVICE_TYPE"===t.type?t.deviceType:e},blockInserterPanel:function(e=oe,t){return"SET_IS_INSERTER_OPENED"===t.type?t.value:e},sidebar:function(e={all:{},current:void 0},t){switch(t.type){case"SET_CURRENT_SIDEBAR":return{...e,current:t.value};case"REGISTER_SIDEBAR":return{...e,all:{...e.all,[t.name]:t.sidebar}}}return e},blockCSS:function(e={},t){return"SET_BLOCK_CSS"===t.type?{...e,[t.key]:t.css}:e}}),ie=({isActive:e})=>((0,S.useEffect)((()=>{let e=!1;return document.body.classList.contains("sticky-menu")&&(e=!0,document.body.classList.remove("sticky-menu")),()=>{e&&document.body.classList.add("sticky-menu")}}),[]),(0,S.useEffect)((()=>(e?document.body.classList.add("is-fullscreen-mode"):document.body.classList.remove("is-fullscreen-mode"),()=>{e&&document.body.classList.remove("is-fullscreen-mode")})),[e]),null);function se({children:e,className:t,ariaLabel:n,as:a="div",...r}){return(0,d.createElement)(a,{className:b()("interface-navigable-region",t),"aria-label":n,role:"region",tabIndex:"-1",...r},e)}const ce={hidden:{opacity:0},hover:{opacity:1,transition:{type:"tween",delay:.2,delayChildren:.2}},distractionFreeInactive:{opacity:1,transition:{delay:0}}},ue=(0,S.forwardRef)((function({isDistractionFree:e,footer:t,header:n,editorNotices:a,sidebar:r,secondarySidebar:o,notices:l,content:i,contentProps:s,actions:c,labels:u,className:p,enableRegionNavigation:m=!0,shortcuts:g},h){const f=(0,C.__unstableUseNavigateRegions)(g);!function(e){(0,S.useEffect)((()=>{const t=document&&document.querySelector(`html:not(.${e})`);if(t)return t.classList.toggle(e),()=>{t.classList.toggle(e)}}),[e])}("interface-interface-skeleton__html-container");const y={ /* translators: accessibility text for the top bar landmark region. */ header:(0,ee.__)("Header"), /* translators: accessibility text for the content landmark region. */ @@ -12,7 +12,7 @@ actions:(0,ee.__)("Publish"), /* translators: accessibility text for the footer landmark region. */ footer:(0,ee.__)("Footer"),...u};return(0,d.createElement)("div",{...m?f:{},ref:(0,_.useMergeRefs)([h,m?f.ref:void 0]),className:b()(p,"interface-interface-skeleton",f.className,!!t&&"has-footer")},(0,d.createElement)("div",{className:"interface-interface-skeleton__editor"},!!n&&(0,d.createElement)(se,{as:C.__unstableMotion.div,className:"interface-interface-skeleton__header","aria-label":y.header,initial:e?"hidden":"distractionFreeInactive",whileHover:e?"hover":"distractionFreeInactive",animate:e?"hidden":"distractionFreeInactive",variants:ce,transition:e?{type:"tween",delay:.8}:void 0},n),e&&(0,d.createElement)("div",{className:"interface-interface-skeleton__header"},a),(0,d.createElement)("div",{className:"interface-interface-skeleton__body"},!!o&&(0,d.createElement)(se,{className:"interface-interface-skeleton__secondary-sidebar",ariaLabel:y.secondarySidebar},o),!!l&&(0,d.createElement)("div",{className:"interface-interface-skeleton__notices"},l),(0,d.createElement)(se,{className:"interface-interface-skeleton__content",ariaLabel:y.body,...s},i),!!r&&(0,d.createElement)(se,{className:"interface-interface-skeleton__sidebar",ariaLabel:y.sidebar},r),!!c&&(0,d.createElement)(se,{className:"interface-interface-skeleton__actions",ariaLabel:y.actions},c))),!!t&&(0,d.createElement)(se,{className:"interface-interface-skeleton__footer",ariaLabel:y.footer},t))}));function pe({scope:e,...t}){return(0,d.createElement)(C.Fill,{name:`PinnedItems/${e}`,...t})}pe.Slot=function({scope:e,className:t,...n}){return(0,d.createElement)(C.Slot,{name:`PinnedItems/${e}`,...n},(e=>e?.length>0&&(0,d.createElement)("div",{className:b()(t,"interface-pinned-items")},e)))};const me=pe,de=window.wp.primitives,ge=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"}));function _e({as:e=C.DropdownMenu,className:t,label: /* translators: button label text should, if possible, be under 16 characters. */ -n=(0,ee.__)("Options"),popoverProps:a,toggleProps:r,children:o}){return(0,d.createElement)(e,{className:b()("interface-more-menu-dropdown",t),icon:ge,label:n,popoverProps:{placement:"bottom-end",...a,className:b()("interface-more-menu-dropdown__content",a?.className)},toggleProps:{tooltipPosition:"bottom",...r}},(e=>o(e)))}const he=()=>{};function be({name:e,as:t=C.Button,onClick:n,...a}){return(0,d.createElement)(C.Fill,{name:e},(({onClick:e})=>(0,d.createElement)(t,{onClick:n||e?(...t)=>{(n||he)(...t),(e||he)(...t)}:void 0,...a})))}be.Slot=function({name:e,as:t=C.ButtonGroup,fillProps:n={},bubblesVirtually:a,...r}){return(0,d.createElement)(C.Slot,{name:e,bubblesVirtually:a,fillProps:n},(e=>{if(!S.Children.toArray(e).length)return null;const n=[];S.Children.forEach(e,(({props:{__unstableExplicitMenuItem:e,__unstableTarget:t}})=>{t&&e&&n.push(t)}));const a=S.Children.map(e,(e=>!e.props.__unstableExplicitMenuItem&&n.includes(e.props.__unstableTarget)?null:e));return(0,d.createElement)(t,{...r},a)}))};const fe=be,ye=window.wp.deprecated;var ve=n.n(ye);const Ee=(e,t)=>({type:"SET_DEFAULT_COMPLEMENTARY_AREA",scope:e,area:t}),xe=(e,t)=>({registry:n,dispatch:a})=>{t&&(n.select(re.store).get(e,"isComplementaryAreaVisible")||n.dispatch(re.store).set(e,"isComplementaryAreaVisible",!0),a({type:"ENABLE_COMPLEMENTARY_AREA",scope:e,area:t}))},ke=e=>({registry:t})=>{t.select(re.store).get(e,"isComplementaryAreaVisible")&&t.dispatch(re.store).set(e,"isComplementaryAreaVisible",!1)},we=(e,t)=>({registry:n})=>{if(!t)return;const a=n.select(re.store).get(e,"pinnedItems");!0!==a?.[t]&&n.dispatch(re.store).set(e,"pinnedItems",{...a,[t]:!0})},Ce=(e,t)=>({registry:n})=>{if(!t)return;const a=n.select(re.store).get(e,"pinnedItems");n.dispatch(re.store).set(e,"pinnedItems",{...a,[t]:!1})};function Se(e,t){return function({registry:n}){ve()("dispatch( 'core/interface' ).toggleFeature",{since:"6.0",alternative:"dispatch( 'core/preferences' ).toggle"}),n.dispatch(re.store).toggle(e,t)}}function Te(e,t,n){return function({registry:a}){ve()("dispatch( 'core/interface' ).setFeatureValue",{since:"6.0",alternative:"dispatch( 'core/preferences' ).set"}),a.dispatch(re.store).set(e,t,!!n)}}function Be(e,t){return function({registry:n}){ve()("dispatch( 'core/interface' ).setFeatureDefaults",{since:"6.0",alternative:"dispatch( 'core/preferences' ).setDefaults"}),n.dispatch(re.store).setDefaults(e,t)}}function Pe(e){return{type:"OPEN_MODAL",name:e}}function Ie(){return{type:"CLOSE_MODAL"}}const Ae=(0,P.createRegistrySelector)((e=>(t,n)=>{const a=e(re.store).get(n,"isComplementaryAreaVisible");if(void 0!==a)return!1===a?null:t?.complementaryAreas?.[n]})),Ne=(0,P.createRegistrySelector)((e=>(t,n)=>{const a=e(re.store).get(n,"isComplementaryAreaVisible"),r=t?.complementaryAreas?.[n];return a&&void 0===r})),Me=(0,P.createRegistrySelector)((e=>(t,n,a)=>{var r;const o=e(re.store).get(n,"pinnedItems");return null===(r=o?.[a])||void 0===r||r})),Le=(0,P.createRegistrySelector)((e=>(t,n,a)=>(ve()("select( 'core/interface' ).isFeatureActive( scope, featureName )",{since:"6.0",alternative:"select( 'core/preferences' ).get( scope, featureName )"}),!!e(re.store).get(n,a))));function Re(e,t){return e.activeModal===t}const ze=(0,P.combineReducers)({complementaryAreas:function(e={},t){switch(t.type){case"SET_DEFAULT_COMPLEMENTARY_AREA":{const{scope:n,area:a}=t;return e[n]?e:{...e,[n]:a}}case"ENABLE_COMPLEMENTARY_AREA":{const{scope:n,area:a}=t;return{...e,[n]:a}}}return e},activeModal:function(e=null,t){switch(t.type){case"OPEN_MODAL":return t.name;case"CLOSE_MODAL":return null}return e}}),$e=(0,P.createReduxStore)("core/interface",{reducer:ze,actions:r,selectors:o});(0,P.register)($e);const De=e=>({registry:t})=>{t.dispatch($e).enableComplementaryArea(A,e)},Ve=e=>({registry:t})=>{const n=t.select($e).isItemPinned(A,e);t.dispatch($e)[n?"unpinItem":"pinItem"](A,e)},Fe=(e,t)=>({registry:n})=>{var a;if(!e)return;const r=null!==(a=n.select(re.store).get(A,"preferredStyleVariations"))&&void 0!==a?a:{};if(t)n.dispatch(re.store).set(A,"preferredStyleVariations",{...r,[e]:t});else{const t={...r};delete t[e],n.dispatch(re.store).set(A,"preferredStyleVariations",t)}};function Oe(e){return{type:"SET_PREVIEW_DEVICE_TYPE",deviceType:e}}function He(e){return{type:"SET_IS_INSERTER_OPENED",value:e}}function je(e){return{type:"SET_CURRENT_SIDEBAR",value:e}}function Ue(e,t){return{type:"REGISTER_SIDEBAR",name:e,sidebar:t}}function Ge(e,t){return{type:"SET_BLOCK_CSS",key:e,css:t}}function We(e,t){return{type:"SET_LICENSE_KEY_DETAILS",key:e,details:t}}const Ke={rootClientId:void 0,insertionIndex:void 0,filterValue:void 0};function qe(e){return e.deviceType}function Ye(e){return e.sidebar?.current}function Ze(e){return e.sidebar?.all||{}}function Qe(e){return!!e.blockInserterPanel}function Xe(e){return"boolean"==typeof e.blockInserterPanel?Ke:e.blockInserterPanel}function Je(e,t=void 0){return t?e.blockCSS[t]||"":e.blockCSS}const et=(e,t)=>e.licenseKeys[t]||{},tt=window.wp.dataControls;function*nt(e){const t=`noptin/v1/license-key-details?license_key=${e}`,n=yield(0,tt.apiFetch)({path:t});if(n)return We(e,n)}const at=(0,P.createReduxStore)(A,{reducer:le,actions:l,selectors:i,resolvers:s});function rt({onError:e=(e=>e),...t}){(0,m.uploadMedia)({onError:({message:t})=>e(t),wpAllowedMimeTypes:N?.wpAllowedMimeTypes,...t})}(0,P.register)(at);const ot=function(e){const{preferredStyleVariations:t}=(0,P.useSelect)((e=>({preferredStyleVariations:e(re.store).get(A,"preferredStyleVariations")})),[]),{updatePreferredStyleVariations:n}=(0,P.useDispatch)(at);return(0,S.useMemo)((()=>({...N?.settings,...e,allowRightClickOverrides:!0,mediaUpload:N?.user?.canUpload?rt:void 0,__experimentalFetchLinkSuggestions:(t,n)=>(0,I.__experimentalFetchLinkSuggestions)(t,n,e),__experimentalFetchRichUrlData:I.__experimentalFetchUrlData,__experimentalPreferredStyleVariations:{value:t,onChange:n}})),[e,t,n])},lt=function(){const[e]=U("meta"),t=e?.campaign_data||{},n=t.background_color,a=t.font_family,r=t.font_size,o=t.font_style,l=t.font_weight,i=t.line_height,s=t.color,c=t.link_color,u=t.button_color,p=t.button_background,m=t.custom_css,d=t.block_css;return(0,S.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: ${r||"14px"};\n\t\t\t\t\tfont-style: ${o||"normal"};\n\t\t\t\t\tfont-weight: ${l||"normal"};\n\t\t\t\t\tline-height: ${i||"1.5"};\n\t\t\t\t\tbox-sizing: border-box;\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: ${s||"#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\tword-wrap: break-word;\n \t\t\t\tword-break: break-all;\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.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.wp-block-image {\n\t\t\t\t\tmargin: 0 0 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: ${c||"#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: ${u||"#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: ${p||"#1a82e2"};\n\t\t\t\t\tcolor: ${u||"#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\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}\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\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${d?Object.values(d).join("\n"):""}\n\t\t\t\t${m||""}\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`),[s,c,u,p,n,a,r,o,l,i,m,d])},it=(e,t,n,a={})=>{const r="object"==typeof a;return[e?.style?.noptin?.[n]||a,t&&(0,S.useCallback)((o=>{t({style:{...e.style||{},noptin:{...e.style?.noptin||{},[n]:r?{...e.style?.noptin?.[n]||a||{},...o}:o}}})}),[e,t,n]),t&&(0,S.useCallback)((()=>{t({style:{...e.style||{},noptin:{...e.style?.noptin||{},[n]:a}}})}),[e,t,n])]},st=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zm-2.8 0H9.8V7c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3z"})),ct=M.license||{},ut=ct.is_usable&&ct.key,pt=({heading:e,helpText:t,needsAddonsPack:n,slug:a})=>{if((!n||ct.is_usable)&&ct.key&&ct.key)return[!0,null];const r=n&&ct.install_desc||(0,ee.__)("Activate your license key to unlock","newsletter-optin-box"),o=n&&ct.install_text||(0,ee.__)("View Pricing","newsletter-optin-box");let l=n&&ct.install_url||ct.upgrade_url||"https://noptin.com/pricing/";return ct.key||(l=(0,E.addQueryArgs)(l,{utm_source:a,utm_campaign:(M.data?.type||"noptin")+"-emails"})),[!1,(0,d.createElement)(C.Placeholder,{icon:st,label:e||(0,ee.__)("Premium Feature","newsletter-optin-box"),className:"noptin-premium-feature"},(0,d.createElement)(C.__experimentalVStack,{spacing:4},t&&(0,d.createElement)("div",null,t),(0,d.createElement)("div",null,r),(0,d.createElement)(C.__experimentalHStack,{justify:"start",wrap:!0},!ct.key&&(0,d.createElement)(C.Button,{href:ct.activate_url,variant:"secondary",target:"_blank",text:(0,ee.__)("Activate license","newsletter-optin-box"),style:{margin:0}}),(0,d.createElement)(C.Button,{href:l,variant:"primary",target:"_blank",text:o,style:{margin:0}}))))]},mt=/_published|_unpublished|_deleted$/,dt=["automation_rule_new_subscriber"],gt=["WordPress Users"],_t=(e,t=void 0)=>{if(!e)return!1;if(t&>.includes(t))return!0;const n=e.replace(/^automation_rule_/,"");return mt.test(n)?"post_published"!==n:dt.includes(n)};function ht(e,t,n=500){const[a,r]=(0,S.useState)(e),o=(0,S.useRef)(t);return(0,S.useEffect)((()=>{o.current=t}),[t]),(0,S.useEffect)((()=>{const t=setTimeout((()=>{a!==e&&o.current(a)}),n);return()=>clearTimeout(t)}),[a,n,e]),{value:a,onChange:r}}const bt=()=>{const e=(0,P.useSelect)((e=>e(I.store).getPostTypes({per_page:100})),[]);return(0,S.useMemo)((()=>{const t=["attachment"];return e?.filter((({viewable:e,slug:n})=>e&&!t.includes(n)))}),[e])},ft=e=>(0,P.useSelect)((t=>{const{getTaxonomies:n}=t(I.store);return n({type:e,per_page:-1,context:"view"})}),[e]),yt=()=>{const e=(0,P.useSelect)((e=>e(B.store).getSettings()),[]);return e.__experimentalFeatures?.color?.palette?.theme||[]},vt=["Arial, Helvetica, sans-serif","Verdana, Geneva, sans-serif","Times New Roman, Times, serif","Georgia, serif","Courier New, Courier, monospace","Tahoma, Geneva, sans-serif","Calibri, Arial, sans-serif","Trebuchet MS, sans-serif","Lucida Grande, sans-serif","Palatino, serif"],Et=({value:e,onChange:t})=>{const n=vt.map((n=>({title:(0,d.createElement)("span",{style:{fontFamily:n}},(0,d.createElement)(C.__experimentalTruncate,{limit:25,ellipsizeMode:"tail"},n)),onClick:()=>t(n),isActive:e===n,label:n})));return(0,d.createElement)(C.__experimentalInputControlSuffixWrapper,null,(0,d.createElement)(C.DropdownMenu,{icon:"admin-customizer",label:(0,ee.__)("Font family","newsletter-optin-box"),controls:n,noIcons:!0}))},xt=({value:e,onChange:t})=>(0,d.createElement)(C.__experimentalInputControl,{label:(0,ee.__)("Font family","newsletter-optin-box"),placeholder:"Arial, Helvetica, sans-serif",value:e,onChange:t,suffix:(0,d.createElement)(Et,{value:e,onChange:t})});function kt({breakpoint:e,operator:t=">=",children:n}){return(0,_.useViewportMatch)(e,t)?n:null}function wt({mobileOnly:e=!0}){return e?(0,d.createElement)(kt,{breakpoint:"small",operator:"<"},(0,d.createElement)(T.PostPublishButton,null)):(0,d.createElement)(T.PostPublishButton,null)}const Ct=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z"})),St=window.wp.keycodes;function Tt(){return Tt=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?Dt(qt,--Wt):0,Ut--,10===Kt&&(Ut=1,jt--),Kt}function Xt(){return Kt=Wt2||nn(Kt)>3?"":" "}function sn(e,t){for(;--t&&Xt()&&!(Kt<48||Kt>102||Kt>57&&Kt<65||Kt>70&&Kt<97););return tn(e,en()+(t<6&&32==Jt()&&32==Xt()))}function cn(e){for(;Xt();)switch(Kt){case e:return Wt;case 34:case 39:34!==e&&39!==e&&cn(Kt);break;case 40:41===e&&cn(e);break;case 92:Xt()}return Wt}function un(e,t){for(;Xt()&&e+Kt!==57&&(e+Kt!==84||47!==Jt()););return"/*"+tn(t,Wt-1)+"*"+Mt(47===e?e:Xt())}function pn(e){for(;!nn(Jt());)Xt();return tn(e,Wt)}var mn="-ms-",dn="-moz-",gn="-webkit-",hn="comm",bn="rule",fn="decl",yn="@keyframes";function vn(e,t){for(var n="",a=Ot(e),r=0;r0&&Ft(k)-p&&Ht(d>32?Sn(k+";",a,n,p-1):Sn(zt(k," ","")+";",a,n,p-2),s);break;case 59:k+=";";default:if(Ht(x=wn(k,t,n,c,u,r,i,y,v=[],E=[],p),o),123===f)if(0===u)kn(k,t,x,x,v,o,p,i,E);else switch(99===m&&110===Dt(k,3)?100:m){case 100:case 108:case 109:case 115:kn(e,x,x,a&&Ht(wn(e,x,x,0,0,r,i,y,r,v=[],p),E),r,E,p,i,a?v:E);break;default:kn(k,x,x,x,[""],E,0,i,E)}}c=u=d=0,_=b=1,y=k="",p=l;break;case 58:p=1+Ft(k),d=g;default:if(_<1)if(123==f)--_;else if(125==f&&0==_++&&125==Qt())continue;switch(k+=Mt(f),f*_){case 38:b=u>0?1:(k+="\f",-1);break;case 44:i[c++]=(Ft(k)-1)*b,b=1;break;case 64:45===Jt()&&(k+=on(Xt())),m=Jt(),u=p=Ft(y=k+=pn(en())),f++;break;case 45:45===g&&2==Ft(k)&&(_=0)}}return o}function wn(e,t,n,a,r,o,l,i,s,c,u){for(var p=r-1,m=0===r?o:[""],d=Ot(m),g=0,_=0,h=0;g0?m[b]+" "+f:zt(f,/&\f/g,m[b])))&&(s[h++]=y);return Yt(e,t,n,0===r?bn:i,s,c,u)}function Cn(e,t,n){return Yt(e,t,n,hn,Mt(Kt),Vt(e,2,-2),0)}function Sn(e,t,n,a){return Yt(e,t,n,fn,Vt(e,0,a),Vt(e,a+1,-1),a)}var Tn=function(e,t,n){for(var a=0,r=0;a=r,r=Jt(),38===a&&12===r&&(t[n]=1),!nn(r);)Xt();return tn(e,Wt)},Bn=new WeakMap,Pn=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,a=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||Bn.get(n))&&!a){Bn.set(e,!0);for(var r=[],o=function(e,t){return rn(function(e,t){var n=-1,a=44;do{switch(nn(a)){case 0:38===a&&12===Jt()&&(t[n]=1),e[n]+=Tn(Wt-1,t,n);break;case 2:e[n]+=on(a);break;case 4:if(44===a){e[++n]=58===Jt()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=Mt(a)}}while(a=Xt());return e}(an(e),t))}(t,r),l=n.props,i=0,s=0;i6)switch(Dt(e,t+1)){case 109:if(45!==Dt(e,t+4))break;case 102:return zt(e,/(.+:)(.+)-([^]+)/,"$1"+gn+"$2-$3$1"+dn+(108==Dt(e,t+3)?"$3":"$2-$3"))+e;case 115:return~$t(e,"stretch")?An(zt(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==Dt(e,t+1))break;case 6444:switch(Dt(e,Ft(e)-3-(~$t(e,"!important")&&10))){case 107:return zt(e,":",":"+gn)+e;case 101:return zt(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+gn+(45===Dt(e,14)?"inline-":"")+"box$3$1"+gn+"$2$3$1"+mn+"$2box$3")+e}break;case 5936:switch(Dt(e,t+11)){case 114:return gn+e+mn+zt(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return gn+e+mn+zt(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return gn+e+mn+zt(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return gn+e+mn+e+e}return e}var Nn=[function(e,t,n,a){if(e.length>-1&&!e.return)switch(e.type){case fn:e.return=An(e.value,e.length);break;case yn:return vn([Zt(e,{value:zt(e.value,"@","@"+gn)})],a);case bn:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return vn([Zt(e,{props:[zt(t,/:(read-\w+)/,":-moz-$1")]})],a);case"::placeholder":return vn([Zt(e,{props:[zt(t,/:(plac\w+)/,":"+gn+"input-$1")]}),Zt(e,{props:[zt(t,/:(plac\w+)/,":-moz-$1")]}),Zt(e,{props:[zt(t,/:(plac\w+)/,mn+"input-$1")]})],a)}return""}))}}],Mn=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var a,r,o=e.stylisPlugins||Nn,l={},i=[];a=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n=4;++a,r-=4)t=1540483477*(65535&(t=255&e.charCodeAt(a)|(255&e.charCodeAt(++a))<<8|(255&e.charCodeAt(++a))<<16|(255&e.charCodeAt(++a))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(r){case 3:n^=(255&e.charCodeAt(a+2))<<16;case 2:n^=(255&e.charCodeAt(a+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(a)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(r)+s;return{name:c,styles:r,next:Hn}},Gn=!!d.useInsertionEffect&&d.useInsertionEffect,Wn=Gn||function(e){return e()},Kn=(Gn||d.useLayoutEffect,d.createContext("undefined"!=typeof HTMLElement?Mn({key:"css"}):null));Kn.Provider;var qn=d.createContext({}),Yn=function(e,t,n){var a=e.key+"-"+t.name;!1===n&&void 0===e.registered[a]&&(e.registered[a]=t.styles)},Zn=It,Qn=function(e){return"theme"!==e},Xn=function(e){return"string"==typeof e&&e.charCodeAt(0)>96?Zn:Qn},Jn=function(e,t,n){var a;if(t){var r=t.shouldForwardProp;a=e.__emotion_forwardProp&&r?function(t){return e.__emotion_forwardProp(t)&&r(t)}:r}return"function"!=typeof a&&n&&(a=e.__emotion_forwardProp),a},ea=function(e){var t=e.cache,n=e.serialized,a=e.isStringTag;return Yn(t,n,a),Wn((function(){return function(e,t,n){Yn(e,t,n);var a=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var r=t;do{e.insert(t===r?"."+a:"",r,e.sheet,!0),r=r.next}while(void 0!==r)}}(t,n,a)})),null},ta=function e(t,n){var a,r,o=t.__emotion_real===t,l=o&&t.__emotion_base||t;void 0!==n&&(a=n.label,r=n.target);var i=Jn(t,n,o),s=i||Xn(l),c=!s("as");return function(){var u=arguments,p=o&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==a&&p.push("label:"+a+";"),null==u[0]||void 0===u[0].raw)p.push.apply(p,u);else{p.push(u[0][0]);for(var m=u.length,g=1;g{const a={...t};return"COMMIT"!==n.type&&"PRESS_UP"!==n.type&&"PRESS_DOWN"!==n.type||void 0!==a.value&&(a.value=a.value.toString().padStart(e,"0")),a}}const ra=ta.div` +n=(0,ee.__)("Options"),popoverProps:a,toggleProps:r,children:o}){return(0,d.createElement)(e,{className:b()("interface-more-menu-dropdown",t),icon:ge,label:n,popoverProps:{placement:"bottom-end",...a,className:b()("interface-more-menu-dropdown__content",a?.className)},toggleProps:{tooltipPosition:"bottom",...r}},(e=>o(e)))}const he=()=>{};function be({name:e,as:t=C.Button,onClick:n,...a}){return(0,d.createElement)(C.Fill,{name:e},(({onClick:e})=>(0,d.createElement)(t,{onClick:n||e?(...t)=>{(n||he)(...t),(e||he)(...t)}:void 0,...a})))}be.Slot=function({name:e,as:t=C.ButtonGroup,fillProps:n={},bubblesVirtually:a,...r}){return(0,d.createElement)(C.Slot,{name:e,bubblesVirtually:a,fillProps:n},(e=>{if(!S.Children.toArray(e).length)return null;const n=[];S.Children.forEach(e,(({props:{__unstableExplicitMenuItem:e,__unstableTarget:t}})=>{t&&e&&n.push(t)}));const a=S.Children.map(e,(e=>!e.props.__unstableExplicitMenuItem&&n.includes(e.props.__unstableTarget)?null:e));return(0,d.createElement)(t,{...r},a)}))};const fe=be,ye=window.wp.deprecated;var ve=n.n(ye);const Ee=(e,t)=>({type:"SET_DEFAULT_COMPLEMENTARY_AREA",scope:e,area:t}),xe=(e,t)=>({registry:n,dispatch:a})=>{t&&(n.select(re.store).get(e,"isComplementaryAreaVisible")||n.dispatch(re.store).set(e,"isComplementaryAreaVisible",!0),a({type:"ENABLE_COMPLEMENTARY_AREA",scope:e,area:t}))},ke=e=>({registry:t})=>{t.select(re.store).get(e,"isComplementaryAreaVisible")&&t.dispatch(re.store).set(e,"isComplementaryAreaVisible",!1)},we=(e,t)=>({registry:n})=>{if(!t)return;const a=n.select(re.store).get(e,"pinnedItems");!0!==a?.[t]&&n.dispatch(re.store).set(e,"pinnedItems",{...a,[t]:!0})},Ce=(e,t)=>({registry:n})=>{if(!t)return;const a=n.select(re.store).get(e,"pinnedItems");n.dispatch(re.store).set(e,"pinnedItems",{...a,[t]:!1})};function Se(e,t){return function({registry:n}){ve()("dispatch( 'core/interface' ).toggleFeature",{since:"6.0",alternative:"dispatch( 'core/preferences' ).toggle"}),n.dispatch(re.store).toggle(e,t)}}function Te(e,t,n){return function({registry:a}){ve()("dispatch( 'core/interface' ).setFeatureValue",{since:"6.0",alternative:"dispatch( 'core/preferences' ).set"}),a.dispatch(re.store).set(e,t,!!n)}}function Be(e,t){return function({registry:n}){ve()("dispatch( 'core/interface' ).setFeatureDefaults",{since:"6.0",alternative:"dispatch( 'core/preferences' ).setDefaults"}),n.dispatch(re.store).setDefaults(e,t)}}function Pe(e){return{type:"OPEN_MODAL",name:e}}function Ie(){return{type:"CLOSE_MODAL"}}const Ae=(0,P.createRegistrySelector)((e=>(t,n)=>{const a=e(re.store).get(n,"isComplementaryAreaVisible");if(void 0!==a)return!1===a?null:t?.complementaryAreas?.[n]})),Ne=(0,P.createRegistrySelector)((e=>(t,n)=>{const a=e(re.store).get(n,"isComplementaryAreaVisible"),r=t?.complementaryAreas?.[n];return a&&void 0===r})),Me=(0,P.createRegistrySelector)((e=>(t,n,a)=>{var r;const o=e(re.store).get(n,"pinnedItems");return null===(r=o?.[a])||void 0===r||r})),Le=(0,P.createRegistrySelector)((e=>(t,n,a)=>(ve()("select( 'core/interface' ).isFeatureActive( scope, featureName )",{since:"6.0",alternative:"select( 'core/preferences' ).get( scope, featureName )"}),!!e(re.store).get(n,a))));function Re(e,t){return e.activeModal===t}const ze=(0,P.combineReducers)({complementaryAreas:function(e={},t){switch(t.type){case"SET_DEFAULT_COMPLEMENTARY_AREA":{const{scope:n,area:a}=t;return e[n]?e:{...e,[n]:a}}case"ENABLE_COMPLEMENTARY_AREA":{const{scope:n,area:a}=t;return{...e,[n]:a}}}return e},activeModal:function(e=null,t){switch(t.type){case"OPEN_MODAL":return t.name;case"CLOSE_MODAL":return null}return e}}),De=(0,P.createReduxStore)("core/interface",{reducer:ze,actions:r,selectors:o});(0,P.register)(De);const $e=e=>({registry:t})=>{t.dispatch(De).enableComplementaryArea(A,e)},Ve=e=>({registry:t})=>{const n=t.select(De).isItemPinned(A,e);t.dispatch(De)[n?"unpinItem":"pinItem"](A,e)},Fe=(e,t)=>({registry:n})=>{var a;if(!e)return;const r=null!==(a=n.select(re.store).get(A,"preferredStyleVariations"))&&void 0!==a?a:{};if(t)n.dispatch(re.store).set(A,"preferredStyleVariations",{...r,[e]:t});else{const t={...r};delete t[e],n.dispatch(re.store).set(A,"preferredStyleVariations",t)}};function He(e){return{type:"SET_PREVIEW_DEVICE_TYPE",deviceType:e}}function Oe(e){return{type:"SET_IS_INSERTER_OPENED",value:e}}function je(e){return{type:"SET_CURRENT_SIDEBAR",value:e}}function Ue(e,t){return{type:"REGISTER_SIDEBAR",name:e,sidebar:t}}function Ge(e,t){return{type:"SET_BLOCK_CSS",key:e,css:t}}function We(e,t){return{type:"SET_LICENSE_KEY_DETAILS",key:e,details:t}}const Ke={rootClientId:void 0,insertionIndex:void 0,filterValue:void 0};function qe(e){return e.deviceType}function Ye(e){return e.sidebar?.current}function Ze(e){return e.sidebar?.all||{}}function Qe(e){return!!e.blockInserterPanel}function Xe(e){return"boolean"==typeof e.blockInserterPanel?Ke:e.blockInserterPanel}function Je(e,t=void 0){return t?e.blockCSS[t]||"":e.blockCSS}const et=(e,t)=>e.licenseKeys[t]||{},tt=window.wp.dataControls;function*nt(e){const t=`noptin/v1/license-key-details?license_key=${e}`,n=yield(0,tt.apiFetch)({path:t});if(n)return We(e,n)}const at=(0,P.createReduxStore)(A,{reducer:le,actions:l,selectors:i,resolvers:s});function rt({onError:e=(e=>e),...t}){(0,m.uploadMedia)({onError:({message:t})=>e(t),wpAllowedMimeTypes:N?.wpAllowedMimeTypes,...t})}(0,P.register)(at);const ot=function(e){const{preferredStyleVariations:t}=(0,P.useSelect)((e=>({preferredStyleVariations:e(re.store).get(A,"preferredStyleVariations")})),[]),{updatePreferredStyleVariations:n}=(0,P.useDispatch)(at);return(0,S.useMemo)((()=>({...N?.settings,...e,allowRightClickOverrides:!0,mediaUpload:N?.user?.canUpload?rt:void 0,__experimentalFetchLinkSuggestions:(t,n)=>(0,I.__experimentalFetchLinkSuggestions)(t,n,e),__experimentalFetchRichUrlData:I.__experimentalFetchUrlData,__experimentalPreferredStyleVariations:{value:t,onChange:n}})),[e,t,n])},lt=function(){const[e]=U("meta"),t=e?.campaign_data||{},n=t.background_color,a=t.font_family,r=t.font_size,o=t.font_style,l=t.font_weight,i=t.line_height,s=t.color,c=t.link_color,u=t.button_color,p=t.button_background,m=t.custom_css,d=t.block_css;return(0,S.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: ${r||"14px"};\n\t\t\t\t\tfont-style: ${o||"normal"};\n\t\t\t\t\tfont-weight: ${l||"normal"};\n\t\t\t\t\tline-height: ${i||"1.5"};\n\t\t\t\t\tbox-sizing: border-box;\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: ${s||"#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\tword-wrap: break-word;\n \t\t\t\tword-break: break-all;\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.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.wp-block-image {\n\t\t\t\t\tmargin: 0 0 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: ${c||"#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: ${u||"#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: ${p||"#1a82e2"};\n\t\t\t\t\tcolor: ${u||"#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\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}\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\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${d?Object.values(d).join("\n"):""}\n\t\t\t\t${m||""}\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`),[s,c,u,p,n,a,r,o,l,i,m,d])},it=(e,t,n,a={})=>{const r="object"==typeof a;return[e?.style?.noptin?.[n]||a,t&&(0,S.useCallback)((o=>{t({style:{...e.style||{},noptin:{...e.style?.noptin||{},[n]:r?{...e.style?.noptin?.[n]||a||{},...o}:o}}})}),[e,t,n]),t&&(0,S.useCallback)((()=>{t({style:{...e.style||{},noptin:{...e.style?.noptin||{},[n]:a}}})}),[e,t,n])]},st=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zm-2.8 0H9.8V7c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3z"})),ct=M.license||{},ut=ct.is_usable&&ct.key,pt=({heading:e,helpText:t,needsAddonsPack:n,slug:a})=>{if((!n||ct.is_usable)&&ct.key&&ct.key)return[!0,null];const r=n&&ct.install_desc||(0,ee.__)("Activate your license key to unlock","newsletter-optin-box"),o=n&&ct.install_text||(0,ee.__)("View Pricing","newsletter-optin-box");let l=n&&ct.install_url||ct.upgrade_url||"https://noptin.com/pricing/";return ct.key||(l=(0,E.addQueryArgs)(l,{utm_source:a,utm_campaign:(M.data?.type||"noptin")+"-emails"})),[!1,(0,d.createElement)(C.Placeholder,{icon:st,label:e||(0,ee.__)("Premium Feature","newsletter-optin-box"),className:"noptin-premium-feature"},(0,d.createElement)(C.__experimentalVStack,{spacing:4},t&&(0,d.createElement)("div",null,t),(0,d.createElement)("div",null,r),(0,d.createElement)(C.__experimentalHStack,{justify:"start",wrap:!0},!ct.key&&(0,d.createElement)(C.Button,{href:ct.activate_url,variant:"secondary",target:"_blank",text:(0,ee.__)("Activate license","newsletter-optin-box"),style:{margin:0}}),(0,d.createElement)(C.Button,{href:l,variant:"primary",target:"_blank",text:o,style:{margin:0}}))))]},mt=/_published|_unpublished|_deleted$/,dt=["automation_rule_new_subscriber"],gt=["WordPress Users"],_t=(e,t=void 0)=>{if(!e)return!1;if(t&>.includes(t))return!0;const n=e.replace(/^automation_rule_/,"");return mt.test(n)?"post_published"!==n:dt.includes(n)};function ht(e,t,n=500){const[a,r]=(0,S.useState)(e),o=(0,S.useRef)(t);return(0,S.useEffect)((()=>{o.current=t}),[t]),(0,S.useEffect)((()=>{const t=setTimeout((()=>{a!==e&&o.current(a)}),n);return()=>clearTimeout(t)}),[a,n,e]),{value:a,onChange:r}}const bt=()=>{const e=(0,P.useSelect)((e=>e(I.store).getPostTypes({per_page:100})),[]);return(0,S.useMemo)((()=>{const t=["attachment"];return e?.filter((({viewable:e,slug:n})=>e&&!t.includes(n)))}),[e])},ft=e=>(0,P.useSelect)((t=>{const{getTaxonomies:n}=t(I.store);return n({type:e,per_page:-1,context:"view"})}),[e]),yt=()=>{const e=(0,P.useSelect)((e=>e(B.store).getSettings()),[]);return e.__experimentalFeatures?.color?.palette?.theme||[]},vt=["Arial, Helvetica, sans-serif","Verdana, Geneva, sans-serif","Times New Roman, Times, serif","Georgia, serif","Courier New, Courier, monospace","Tahoma, Geneva, sans-serif","Calibri, Arial, sans-serif","Trebuchet MS, sans-serif","Lucida Grande, sans-serif","Palatino, serif"],Et=({value:e,onChange:t})=>{const n=vt.map((n=>({title:(0,d.createElement)("span",{style:{fontFamily:n}},(0,d.createElement)(C.__experimentalTruncate,{limit:25,ellipsizeMode:"tail"},n)),onClick:()=>t(n),isActive:e===n,label:n})));return(0,d.createElement)(C.__experimentalInputControlSuffixWrapper,null,(0,d.createElement)(C.DropdownMenu,{icon:"admin-customizer",label:(0,ee.__)("Font family","newsletter-optin-box"),controls:n,noIcons:!0}))},xt=({value:e,onChange:t})=>(0,d.createElement)(C.__experimentalInputControl,{label:(0,ee.__)("Font family","newsletter-optin-box"),placeholder:"Arial, Helvetica, sans-serif",value:e,onChange:t,suffix:(0,d.createElement)(Et,{value:e,onChange:t})});function kt({breakpoint:e,operator:t=">=",children:n}){return(0,_.useViewportMatch)(e,t)?n:null}function wt({mobileOnly:e=!0}){return e?(0,d.createElement)(kt,{breakpoint:"small",operator:"<"},(0,d.createElement)(T.PostPublishButton,null)):(0,d.createElement)(T.PostPublishButton,null)}const Ct=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z"})),St=window.wp.keycodes;function Tt(){return Tt=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?$t(qt,--Wt):0,Ut--,10===Kt&&(Ut=1,jt--),Kt}function Xt(){return Kt=Wt2||nn(Kt)>3?"":" "}function sn(e,t){for(;--t&&Xt()&&!(Kt<48||Kt>102||Kt>57&&Kt<65||Kt>70&&Kt<97););return tn(e,en()+(t<6&&32==Jt()&&32==Xt()))}function cn(e){for(;Xt();)switch(Kt){case e:return Wt;case 34:case 39:34!==e&&39!==e&&cn(Kt);break;case 40:41===e&&cn(e);break;case 92:Xt()}return Wt}function un(e,t){for(;Xt()&&e+Kt!==57&&(e+Kt!==84||47!==Jt()););return"/*"+tn(t,Wt-1)+"*"+Mt(47===e?e:Xt())}function pn(e){for(;!nn(Jt());)Xt();return tn(e,Wt)}var mn="-ms-",dn="-moz-",gn="-webkit-",hn="comm",bn="rule",fn="decl",yn="@keyframes";function vn(e,t){for(var n="",a=Ht(e),r=0;r0&&Ft(k)-p&&Ot(d>32?Sn(k+";",a,n,p-1):Sn(zt(k," ","")+";",a,n,p-2),s);break;case 59:k+=";";default:if(Ot(x=wn(k,t,n,c,u,r,i,y,v=[],E=[],p),o),123===f)if(0===u)kn(k,t,x,x,v,o,p,i,E);else switch(99===m&&110===$t(k,3)?100:m){case 100:case 108:case 109:case 115:kn(e,x,x,a&&Ot(wn(e,x,x,0,0,r,i,y,r,v=[],p),E),r,E,p,i,a?v:E);break;default:kn(k,x,x,x,[""],E,0,i,E)}}c=u=d=0,_=b=1,y=k="",p=l;break;case 58:p=1+Ft(k),d=g;default:if(_<1)if(123==f)--_;else if(125==f&&0==_++&&125==Qt())continue;switch(k+=Mt(f),f*_){case 38:b=u>0?1:(k+="\f",-1);break;case 44:i[c++]=(Ft(k)-1)*b,b=1;break;case 64:45===Jt()&&(k+=on(Xt())),m=Jt(),u=p=Ft(y=k+=pn(en())),f++;break;case 45:45===g&&2==Ft(k)&&(_=0)}}return o}function wn(e,t,n,a,r,o,l,i,s,c,u){for(var p=r-1,m=0===r?o:[""],d=Ht(m),g=0,_=0,h=0;g0?m[b]+" "+f:zt(f,/&\f/g,m[b])))&&(s[h++]=y);return Yt(e,t,n,0===r?bn:i,s,c,u)}function Cn(e,t,n){return Yt(e,t,n,hn,Mt(Kt),Vt(e,2,-2),0)}function Sn(e,t,n,a){return Yt(e,t,n,fn,Vt(e,0,a),Vt(e,a+1,-1),a)}var Tn=function(e,t,n){for(var a=0,r=0;a=r,r=Jt(),38===a&&12===r&&(t[n]=1),!nn(r);)Xt();return tn(e,Wt)},Bn=new WeakMap,Pn=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,a=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||Bn.get(n))&&!a){Bn.set(e,!0);for(var r=[],o=function(e,t){return rn(function(e,t){var n=-1,a=44;do{switch(nn(a)){case 0:38===a&&12===Jt()&&(t[n]=1),e[n]+=Tn(Wt-1,t,n);break;case 2:e[n]+=on(a);break;case 4:if(44===a){e[++n]=58===Jt()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=Mt(a)}}while(a=Xt());return e}(an(e),t))}(t,r),l=n.props,i=0,s=0;i6)switch($t(e,t+1)){case 109:if(45!==$t(e,t+4))break;case 102:return zt(e,/(.+:)(.+)-([^]+)/,"$1"+gn+"$2-$3$1"+dn+(108==$t(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Dt(e,"stretch")?An(zt(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==$t(e,t+1))break;case 6444:switch($t(e,Ft(e)-3-(~Dt(e,"!important")&&10))){case 107:return zt(e,":",":"+gn)+e;case 101:return zt(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+gn+(45===$t(e,14)?"inline-":"")+"box$3$1"+gn+"$2$3$1"+mn+"$2box$3")+e}break;case 5936:switch($t(e,t+11)){case 114:return gn+e+mn+zt(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return gn+e+mn+zt(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return gn+e+mn+zt(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return gn+e+mn+e+e}return e}var Nn=[function(e,t,n,a){if(e.length>-1&&!e.return)switch(e.type){case fn:e.return=An(e.value,e.length);break;case yn:return vn([Zt(e,{value:zt(e.value,"@","@"+gn)})],a);case bn:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return vn([Zt(e,{props:[zt(t,/:(read-\w+)/,":-moz-$1")]})],a);case"::placeholder":return vn([Zt(e,{props:[zt(t,/:(plac\w+)/,":"+gn+"input-$1")]}),Zt(e,{props:[zt(t,/:(plac\w+)/,":-moz-$1")]}),Zt(e,{props:[zt(t,/:(plac\w+)/,mn+"input-$1")]})],a)}return""}))}}],Mn=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var a,r,o=e.stylisPlugins||Nn,l={},i=[];a=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n=4;++a,r-=4)t=1540483477*(65535&(t=255&e.charCodeAt(a)|(255&e.charCodeAt(++a))<<8|(255&e.charCodeAt(++a))<<16|(255&e.charCodeAt(++a))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(r){case 3:n^=(255&e.charCodeAt(a+2))<<16;case 2:n^=(255&e.charCodeAt(a+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(a)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(r)+s;return{name:c,styles:r,next:On}},Gn=!!d.useInsertionEffect&&d.useInsertionEffect,Wn=Gn||function(e){return e()},Kn=(Gn||d.useLayoutEffect,d.createContext("undefined"!=typeof HTMLElement?Mn({key:"css"}):null));Kn.Provider;var qn=d.createContext({}),Yn=function(e,t,n){var a=e.key+"-"+t.name;!1===n&&void 0===e.registered[a]&&(e.registered[a]=t.styles)},Zn=It,Qn=function(e){return"theme"!==e},Xn=function(e){return"string"==typeof e&&e.charCodeAt(0)>96?Zn:Qn},Jn=function(e,t,n){var a;if(t){var r=t.shouldForwardProp;a=e.__emotion_forwardProp&&r?function(t){return e.__emotion_forwardProp(t)&&r(t)}:r}return"function"!=typeof a&&n&&(a=e.__emotion_forwardProp),a},ea=function(e){var t=e.cache,n=e.serialized,a=e.isStringTag;return Yn(t,n,a),Wn((function(){return function(e,t,n){Yn(e,t,n);var a=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var r=t;do{e.insert(t===r?"."+a:"",r,e.sheet,!0),r=r.next}while(void 0!==r)}}(t,n,a)})),null},ta=function e(t,n){var a,r,o=t.__emotion_real===t,l=o&&t.__emotion_base||t;void 0!==n&&(a=n.label,r=n.target);var i=Jn(t,n,o),s=i||Xn(l),c=!s("as");return function(){var u=arguments,p=o&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==a&&p.push("label:"+a+";"),null==u[0]||void 0===u[0].raw)p.push.apply(p,u);else{p.push(u[0][0]);for(var m=u.length,g=1;g{const a={...t};return"COMMIT"!==n.type&&"PRESS_UP"!==n.type&&"PRESS_DOWN"!==n.type||void 0!==a.value&&(a.value=a.value.toString().padStart(e,"0")),a}}const ra=ta.div` text-decoration: underline dotted; `,oa=()=>{const{timezone:e}=(0,na.getSettings)(),t=(new Date).getTimezoneOffset()/60*-1;if(Number(e.offset)===t)return null;const n=Number(e.offset)>=0?"+":"",a=""!==e.abbr&&isNaN(Number(e.abbr))?e.abbr:`UTC${n}${e.offset}`,r=e.string.replace("_"," "),o="UTC"===e.string?(0,ee.__)("Coordinated Universal Time"):`(${a}) ${r}`;return 0===r.trim().length?(0,d.createElement)(ra,{className:"components-datetime__timezone"},a):(0,d.createElement)(C.Tooltip,{placement:"top",text:o},(0,d.createElement)(ra,{className:"components-datetime__timezone"},a))},la=ta.span` border-top: 1px solid #757575; @@ -56,24 +56,24 @@ n=(0,ee.__)("Options"),popoverProps:a,toggleProps:r,children:o}){return(0,d.crea `,ua=ta.div` direction: ltr; display: flex; -`,pa=({value:e,onChange:t,...n})=>{const{baseControlProps:a,controlProps:r}=(0,C.useBaseControlProps)(n),o=e?e.split(":"):["07","00"],[l,i]=(0,d.useState)(o[0]),[s,c]=(0,d.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,d.useEffect)((()=>{e!==p&&t(p)}),[p]),(0,d.createElement)(C.BaseControl,{...a},(0,d.createElement)(C.__experimentalHStack,null,(0,d.createElement)(ua,null,(0,d.createElement)(sa,{value:u(l),onChange:i,min:0,max:23,step:1,...r,label:(0,ee.__)("Hours"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:aa(2)}),(0,d.createElement)(la,{"aria-hidden":"true"},":"),(0,d.createElement)(ca,{value:u(s),onChange:c,min:0,max:59,step:1,label:(0,ee.__)("Minutes"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:aa(2)})),(0,d.createElement)(oa,null)))},ma=[{label:(0,ee.__)("Only run if","newsletter-optin-box"),value:"allow"},{label:(0,ee.__)("Do not run if","newsletter-optin-box"),value:"prevent"}],da=[{label:(0,ee.__)("all","newsletter-optin-box"),value:"all"},{label:(0,ee.__)("any","newsletter-optin-box"),value:"any"}];function ga(e,t){return(0,S.useMemo)((()=>[{label:t,value:"",disabled:!0},...e]),[e,t])}function _a({type:e,action:t,ruleCount:n,setConditionalLogicAttribute:a}){const r=n>1;return(0,d.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0},(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("If","newsletter-optin-box"),hideLabelFromVision:!0,value:t||"allow",options:ma,onChange:e=>a("action",e),size:"default",__nextHasNoMarginBottom:!0}),r&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("all","newsletter-optin-box"),hideLabelFromVision:!0,value:e||"all",options:da,onChange:e=>a("type",e),size:"default",__nextHasNoMarginBottom:!0}),(0,d.createElement)(C.__experimentalText,null,(0,ee.__)("of the following rules are true:","newsletter-optin-box"))))}function ha({rule:e,comparisons:t,availableSmartTags:n,index:a,updateRule:r,removeRule:o}){const l=(0,S.useCallback)((e=>r(a,"value",e)),[a,r]),i=(0,S.useCallback)((e=>r(a,"condition",e)),[a,r]),s=(0,S.useCallback)((()=>o(a)),[a,o]),c=(0,S.useMemo)((()=>{const t=e.type;if(void 0!==n[t])return n[t];const a=t.replace("_",".",1);if(void 0!==n[a])return n[a];for(const[e,a]of Object.entries(n)){if(-1!==e.indexOf(".")&&e.split(".").slice(1).join(".")===t)return a;const n=e=>Array.isArray(e)?e:e.split(/[\s,]+/);if(a.deprecated&&n(a.deprecated).includes(t))return a}return null}),[e.type,n]),u=(0,S.useMemo)((()=>{if(!c)return e.type;const t=c.group||"General",n=c.label||e.type;return"General"===t?n:`${n} (${t})`}),[e.type,n]),p=ga((m=c?.options,(0,S.useMemo)((()=>m?Array.isArray(m)?m.map(((e,t)=>({label:e,value:t}))):Object.keys(m).map((e=>({label:m[e],value:e}))):[]),[m])),(0,ee.__)("Select a value","newsletter-optin-box"));var m;const g=p.length>1,_=c?.conditional_logic||"string",h=ga((0,S.useMemo)((()=>{const e=[];return Object.keys(t).forEach((n=>{let a=t[n].type;if(g){if("string"===_&&"is"!=n&&"is_not"!=n)return;if("is_empty"===n||"is_not_empty"===n||"is_between"===n)return}"any"!==a&&a!=_||e.push({label:t[n].name,value:n})})),e}),[_,t]),(0,ee.__)("Select a comparison","newsletter-optin-box")),b="is_empty"===e.condition||"is_not_empty"===e.condition;return(0,d.createElement)(C.__experimentalHStack,{wrap:!0,expanded:!0},(0,d.createElement)(C.__experimentalText,{variant:"muted"},u),(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("Comparison","newsletter-optin-box"),hideLabelFromVision:!0,value:e.condition?e.condition:"is",options:h,onChange:i,size:"default",__nextHasNoMarginBottom:!0}),!b&&(0,d.createElement)(d.Fragment,null,g&&(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("Value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",options:p,onChange:l,size:"default",__nextHasNoMarginBottom:!0}),!g&&(0,d.createElement)(C.TextControl,{type:"number"===_?"number":"text",label:(0,ee.__)("Value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",onChange:l,__nextHasNoMarginBottom:!0})),(0,d.createElement)(C.Button,{onClick:s,icon:"trash",variant:"tertiary",isDestructive:!0}))}function ba({rules:e,comparisons:t,availableSmartTags:n,setConditionalLogicAttribute:a,inModal:r,closeModal:o}){const l=(0,S.useMemo)((()=>Array.isArray(e)?e.filter((e=>e.type&&""!==e.type)):[]),[n]),i=(0,S.useMemo)((()=>{const e={};return n.forEach((t=>{t.conditional_logic&&(e[t.smart_tag]={...t,key:t.smart_tag,type:t.conditional_logic})})),e}),[n]),s=(0,S.useCallback)((e=>{const t=[...l];t.splice(e,1),a("rules",t)}),[l,a]),c=(0,S.useCallback)(((e,t,n)=>{const r=[...l];r[e][t]=n,a("rules",r)}),[l,a]),u=(0,S.useMemo)((()=>Object.values(i)),[i]),p=(0,S.useCallback)((e=>{const t=i[e],n=t?.options||[],r=t?.placeholder||"";let o=Array.isArray(n)&&n.length?Object.keys(n)[0]:r;t?.default&&(o=t.default);const s=[...l];s.push({type:e,condition:"is",value:o}),a("rules",s)}),[l]),m=0===l.length?(0,ee.__)("Add a conditional logic rule","newsletter-optin-box"):(0,ee.__)("Add another rule","newsletter-optin-box"),g=Ta({availableSmartTags:u,onMergeTagClick:p,raw:!0,icon:"plus",label:m,text:m,toggleProps:{variant:"primary"}});return(0,d.createElement)(C.__experimentalVStack,{className:"noptin-conditional-logic-rules"},l.map(((e,n)=>(0,d.createElement)(ha,{key:n,rule:e,index:n,updateRule:c,removeRule:s,comparisons:t,availableSmartTags:i}))),(0,d.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0},g,(0,d.createElement)(C.Button,{onClick:o,variant:"secondary"},(0,ee.__)("Return to editor","newsletter-optin-box"))))}function fa({onChange:e,value:t,comparisons:n,toggleText:a,availableSmartTags:r,className:o,inModal:l=!1}){const[i,s]=(0,S.useState)(!1);"object"!=typeof t&&(t={enabled:!1,action:"allow",rules:[{condition:"is",type:"date",value:""}],type:"all"});const c=(n,a)=>{e({...t,[n]:a})},u=(0,d.createElement)(C.__experimentalVStack,null,(0,d.createElement)(_a,{ruleCount:Array.isArray(t.rules)?t.rules.length:0,type:t.type,action:t.action,setConditionalLogicAttribute:c}),(0,d.createElement)(ba,{rules:t.rules,comparisons:n,availableSmartTags:r,setConditionalLogicAttribute:c,inModal:l,closeModal:()=>s(!1)}));return(0,d.createElement)(C.__experimentalVStack,{spacing:5,className:o},(0,d.createElement)(C.ToggleControl,{checked:!!t.enabled,onChange:e=>c("enabled",e),label:a||(0,ee.__)("Optionally enable/disable this trigger depending on specific conditions.","newsletter-optin-box"),__nextHasNoMarginBottom:!0}),t.enabled&&(0,d.createElement)(d.Fragment,null,l?(0,d.createElement)(d.Fragment,null,i&&(0,d.createElement)(C.Modal,{title:(0,ee.__)("Conditional Logic","newsletter-optin-box"),onRequestClose:()=>s(!1),size:"large"},u),(0,d.createElement)(C.Button,{variant:"secondary",className:"noptin-block-button",onClick:()=>s(!0)},(0,ee.__)("Edit Conditional Logic","newsletter-optin-box"))):(0,d.createElement)(d.Fragment,null,u)))}const ya={"==":(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),empty:e=>!e,"!empty":e=>e},va=(e,t,n)=>!!ya[t]&&ya[t](e,n),Ea=["number","search","email","password","tel","url","date"];function xa({setting:e,availableSmartTags:t,isPressEnterToChange:n,...a}){void 0===n&&(n=!0);const r=Ta({availableSmartTags:t,onMergeTagClick:(0,d.useCallback)((e=>{a.onChange&&a.onChange(a.value?`${a.value} ${e}`.trim():e)}),[a.value,a.onChange])});return"string"==typeof a.suffix||a.suffix instanceof String?a.suffix=(0,d.createElement)(C.__experimentalInputControlSuffixWrapper,null,a.suffix):a.suffix=r,e.disabled&&(a.readOnly=!0,a.onFocus=e=>e.target.select()),("string"==typeof a.prefix||a.prefix instanceof String)&&(a.prefix=(0,d.createElement)(C.__experimentalInputControlPrefixWrapper,null,a.prefix)),(0,d.createElement)(C.__experimentalInputControl,{...a,type:Ea.includes(e.type)?e.type:"text",placeholder:e.placeholder?e.placeholder:"",isPressEnterToChange:n,__next40pxDefaultSize:!0})}function ka({availableSmartTags:e,autoGrow:t=!1,label:n,id:a,...r}){const o=Ta({availableSmartTags:e,onMergeTagClick:(0,d.useCallback)((e=>{r.onChange&&r.onChange(r.value?`${r.value} ${e}`.trim():e)}),[r.value,r.onChange]),toggleProps:{size:"small"}}),l=(0,d.createElement)(C.__experimentalHStack,null,(0,d.createElement)("span",null,n),o),i=a||(0,_.useInstanceId)(ka,"noptin-textarea");return(0,d.useEffect)((()=>{if(t){const e=document.getElementById(i);e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}}),[r.value,t,i]),(0,d.createElement)(C.TextareaControl,{...r,id:i,label:l,__nextHasNoMarginBottom:!0})}function wa({options:e,...t}){const[n,a]=(0,d.useState)(e);return(0,d.createElement)(C.ComboboxControl,{...t,options:n,onFilterValueChange:t=>{a(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,d.createElement)("div",{...t,dangerouslySetInnerHTML:{__html:e.render}}):e.render:e.label,autocomplete:"off"})}function Ca({options:e,value:t,onChange:n,...a}){const r=Array.isArray(t)?t:[],o=(0,d.useMemo)((()=>e.map((e=>e.label))),[e]),l=(0,d.useCallback)((e=>o.includes(e)),[o]),i=(0,d.useMemo)((()=>r.map((t=>{const n=e.find((e=>e.value===t));return n?n.label:t}))),[t,e]),s=(0,d.useCallback)((t=>{const a=new Set;for(const n of t){const t=e.find((e=>e.label===n));t&&a.add(t.value)}n(Array.from(a))}),[n,e]),c=(0,d.useCallback)((t=>{const n=e.find((e=>e.label===t.item));return n&&n.render?(0,d.createElement)(S.RawHTML,null,n.render):(0,d.createElement)(d.Fragment,null,t.item)}),[e]);return(0,d.createElement)(C.FormTokenField,{value:i,suggestions:o,onChange:s,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalValidateInput:l,__experimentalRenderItem:c,...a})}const Sa=[{id:"key",label:(0,ee.__)("Key","noptin-addons-pack"),type:"text"},{id:"value",label:(0,ee.__)("Value","noptin-addons-pack"),type:"text"}];function Ta({availableSmartTags:e=[],onMergeTagClick:t=(e=>{}),raw:n=!1,icon:a="shortcode",label:r=(0,ee.__)("Insert merge tag","newsletter-optin-box"),...o}){const l=function(e){return(0,d.useMemo)((()=>{if(!Array.isArray(e))return{};const t={};return e.forEach((e=>{const n=e.group?e.group:(0,ee.__)("General","newsletter-optin-box");Array.isArray(t[n])||(t[n]=[]),t[n].push(e)})),t}),[e])}(e),i=Object.keys(l).length;let s=null;return i>0&&(s=(0,d.createElement)(C.DropdownMenu,{icon:a,label:r,...o},(({onClose:e})=>(0,d.createElement)(d.Fragment,null,Object.keys(l).map(((a,r)=>(0,d.createElement)(C.MenuGroup,{label:i>1?a:void 0,key:r},l[a].map((a=>(0,d.createElement)(C.MenuItem,{icon:a.icon||Ct,iconPosition:"left",onClick:()=>{if(t){const e=n?a.smart_tag:`[[${r=a,r.example?r.example:r.default?`${r.smart_tag} default="${r.default}"`:`${r.smart_tag}`}]]`;t(e)}var r;e()},key:a.smart_tag},(0,d.createElement)(S.RawHTML,null,a.label))))))))))),s}function Ba({value:e,onChange:t,...n}){const a="object"==typeof e?e:{},r=Array.isArray(a.items)&&a.items.length>1,o=(0,d.createElement)(d.Fragment,null,r&&(0,d.createElement)(C.__experimentalToggleGroupControl,{label:(0,ee.__)("Relation","noptin-addons-pack"),onChange:e=>{t({...a,relation:e})},__nextHasNoMarginBottom:!0},(0,d.createElement)(C.__experimentalToggleGroupControlOption,{value:"AND",label:"AND","aria-label":(0,ee.__)("All conditions must be met","noptin-addons-pack"),showTooltip:!0}),(0,d.createElement)(C.__experimentalToggleGroupControlOption,{value:"OR",label:"OR","aria-label":(0,ee.__)("At least one condition must be met","noptin-addons-pack"),showTooltip:!0})));return(0,d.createElement)(Pa,{...n,value:a.items,onChange:e=>{t({...a,items:e})},disabled:!!a.disabled,onDisable:e=>{t({...a,disabled:e})},prepend:o})}function Pa({availableSmartTags:e,value:t,onChange:n,button:a,fields:r,openModal:o,prepend:l,disable:i,disabled:s,onDisable:c,...u}){const[p,m]=(0,d.useState)(!1),g=Array.isArray(t)?t:[],{baseControlProps:_,controlProps:h}=(0,C.useBaseControlProps)(u),b={};if(!r)return console.warn("No fields provided to repeater control."),null;Object.keys(r).forEach((e=>{void 0!==r[e].default&&(b[e]=r[e].default)}));const f=!!o,y=(0,d.createElement)(C.__experimentalVStack,{...h},l,g.map(((t,a)=>(0,d.createElement)(C.Card,{key:a,variant:"secondary",size:"small",elevation:1},(0,d.createElement)(C.CardBody,null,(0,d.createElement)(Ia,{fields:r,value:t,availableSmartTags:e,onChange:e=>{const t=[...g];t[a]=e,n(t)},onDelete:()=>{const e=[...g];e.splice(a,1),n(e)}}))))),(0,d.createElement)(C.__experimentalHStack,null,(0,d.createElement)(C.Button,{onClick:()=>{const e=[...g];e.push(b),n(e)},variant:"primary"},a||(0,ee.__)("Add Item","newsletter-optin-box")),f&&(0,d.createElement)(C.Button,{onClick:()=>m(!1),variant:"secondary"},(0,ee.__)("Go Back","newsletter-optin-box")))),v=i&&s;return(0,d.createElement)(C.BaseControl,{..._},f&&(0,d.createElement)(d.Fragment,null,i&&(0,d.createElement)(C.ToggleControl,{label:i,checked:s,onChange:e=>{c&&c(e)}}),v&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.Button,{onClick:()=>m(!0),variant:"secondary"},o||(0,ee.__)("Set Items","newsletter-optin-box")),p&&(0,d.createElement)(C.Modal,{title:u.label||o||(0,ee.__)("Set Items","newsletter-optin-box"),onRequestClose:()=>m(!1),size:"medium"},y))),!f&&y)}function Ia({fields:e,availableSmartTags:t,value:n,onChange:a,onDelete:r}){return(0,d.createElement)(C.__experimentalVStack,null,Object.keys(e).map((r=>(0,d.createElement)($a,{key:r,settingKey:r,availableSmartTags:t,setting:e[r],saved:n,setAttributes:e=>{a({...n,...e})}}))),(0,d.createElement)("div",null,(0,d.createElement)(C.Button,{variant:"link",onClick:r,text:(0,ee.__)("Remove Item","newsletter-optin-box"),isDestructive:!0})))}function Aa({setting:e,availableSmartTags:t,value:n,onChange:a,...r}){const{baseControlProps:o,controlProps:l}=(0,C.useBaseControlProps)(r);Array.isArray(n)||(n=[]);const i=(0,d.useCallback)((({item:e,index:r})=>(0,d.createElement)(C.Flex,{className:"noptin-repeater-item",wrap:!0},Sa.map(((o,l)=>(0,d.createElement)(Na,{key:l,availableSmartTags:t,field:o,value:void 0===e[o.id]?"":e[o.id],onChange:e=>{const t=[...n];t[r][o.id]=e,a(t)}}))),(0,d.createElement)(C.FlexItem,null,(0,d.createElement)(C.Button,{icon:"trash",variant:"tertiary",className:"noptin-component__field",label:(0,ee.__)("Delete","noptin-addons-pack"),showTooltip:!0,onClick:()=>{const e=[...n];e.splice(r,1),a(e)},isDestructive:!0})))),[n,a]);return(0,d.createElement)(C.BaseControl,{...o},(0,d.createElement)("div",{...l},n.map(((e,t)=>(0,d.createElement)(i,{key:t,item:e,index:t}))),(0,d.createElement)(C.Button,{onClick:()=>{const e=[...n];e.push({}),a(e)},variant:"secondary"},e.add_field?e.add_field:(0,ee.__)("Add","newsletter-optin-box"))))}function Na({field:e,availableSmartTags:t,value:n,onChange:a}){const r=Ta({availableSmartTags:t,onMergeTagClick:(0,d.useCallback)((e=>{a&&a(n?`${n} ${e}`.trim():e)}),[n,a])});return(0,d.createElement)(C.FlexBlock,null,(0,d.createElement)(C.__experimentalInputControl,{label:e.label,type:e.type,value:n,placeholder:(0,ee.sprintf)((0,ee.__)("Enter %s","noptin-addons-pack"),e.label),className:"noptin-component__field noptin-condition-field",suffix:r,onChange:a,isPressEnterToChange:!0,__next40pxDefaultSize:!0}))}function Ma({setting:e,value:t,options:n,onChange:a,...r}){const{baseControlProps:o,controlProps:l}=(0,C.useBaseControlProps)(r);return Array.isArray(t)||(t=[]),(0,d.createElement)(C.BaseControl,{...o},(0,d.createElement)("div",{...l},n.map(((e,n)=>(0,d.createElement)(C.CheckboxControl,{key:n,label:e.label,checked:t.includes(e.value),onChange:n=>{a(n?[...t,e.value]:t.filter((t=>t!==e.value)))}})))))}function La({value:e,onChange:t,...n}){const{baseControlProps:a,controlProps:r}=(0,C.useBaseControlProps)({...n,__nextHasNoMarginBottom:!0}),o=r.id,l=(0,d.useRef)(null),{wp:i}=window;return(0,d.useEffect)((()=>{if(!l.current)return;const t=window.tinymce?.get(o),n=t?.getContent();t&&n!==e&&t.setContent(e||"")}),[e]),(0,d.useEffect)((()=>{if(l.current)return i.oldEditor.initialize(o,{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:!0,setup:function(n){e&&n.on("loadContent",(()=>n.setContent(e))),n.on("blur",(()=>(t(n.getContent()),!1)));const a=(0,_.debounce)((()=>{const e=n.getContent();e!==n._lastChange&&(n._lastChange=e,t(e))}),250);n.on("Paste Change input Undo Redo",a),n.on("remove",a.cancel),n.on("keydown",(e=>{St.isKeyboardEvent.primary(e,"z")&&e.stopPropagation();const{altKey:t}=e;t&&e.keyCode===St.F10&&e.stopPropagation()}))}},mediaButtons:!0,quicktags:!0}),()=>{i.oldEditor.remove(o)}}),[l.current]),(0,d.createElement)(C.BaseControl,{...a},(0,d.createElement)("textarea",{...r,className:"wp-editor-area",value:e||"",onChange:e=>t(e.target.value),name:o,rows:10,style:{width:"100%"},ref:l}))}const Ra=(e,t)=>{if(0===t.length||!e||"object"!=typeof e)return;const[n,...a]=t;return 0===a.length?e[n]:Ra(e[n],a)},za=(e,t,n)=>{if(0===t.length)return e;const[a,...r]=t;return 0===r.length?{...e,[a]:n}:{...e,[a]:za(e[a]||{},r,n)}};function $a({settingKey:e,setting:t,availableSmartTags:n,prop:a,saved:r,setAttributes:o}){const l=(a?`${a}.${e}`:e).split("."),i=t.sanitize?t.sanitize:e=>e,s=e=>{const[t,...n]=l;return 0===n.length?o(i({[t]:e})):o(i({[t]:za(r[t]||{},n,e)}))};if(t.if||t.restrict){const e=t.restrict?t.restrict.split("."):t.if.split(".");if(!Ra(r,e))return null}if(Array.isArray(t.conditions)&&!t.conditions.every((e=>{const t=e.key.split("."),n=e.operator?e.operator:"==";return va(e.value,n,Ra(r,t))})))return null;if(t.condition&&!t.condition(r))return null;let c=Ra(r,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}`,g="string"==typeof t.description?(0,d.createElement)("span",{dangerouslySetInnerHTML:{__html:t.description}}):t.description,_=t.customAttributes?t.customAttributes:{},h={label:t.label,value:u?c:"",onChange:s,className:m,help:g,..._};if(t.type&&!t.el&&(t.el=t.type,["toggle","switch","checkbox","checkbox_alt","text","number","email","tel","date","color"].includes(t.type)&&(t.el="input")),"select"===t.el)return t.multiple?(0,d.createElement)(Ca,{...h,options:p}):(p.find((e=>""===e?.value))||p.unshift({label:t.placeholder?t.placeholder:(0,ee.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,d.createElement)(C.SelectControl,{...h,options:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}));if("combobox"===t.el)return p.unshift({label:t.placeholder?t.placeholder:(0,ee.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,d.createElement)(wa,{...h,options:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0});if("form_token"===t.el||"token"===t.el)return(0,d.createElement)(C.FormTokenField,{...h,value:Array.isArray(h.value)?h.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,d.createElement)(Ma,{...h,options:p});if("conditional_logic"===t.el)return(0,d.createElement)(fa,{...h,availableSmartTags:n,comparisons:t.comparisons,toggleText:t.toggle_text,inModal:t.in_modal});if("time"===t.el)return(0,d.createElement)(pa,{...h});if("input"===t.el){if(t.type&&["toggle","switch","checkbox","checkbox_alt"].includes(t.type))return(0,d.createElement)(C.ToggleControl,{...h,checked:!!u&&c,onChange:e=>{s(e)}});if(t.type&&["number"].includes(t.type)){const e=e=>{if(e)return"string"==typeof e||e instanceof String?(0,d.createElement)(C.__experimentalInputControlSuffixWrapper,null,e):e},t=e=>{if(e)return"string"==typeof e||e instanceof String?(0,d.createElement)(C.__experimentalInputControlPrefixWrapper,null,e):e};return Array.isArray(h.suffix)?h.suffix=e(1===c||"1"===c?h.suffix[0]:h.suffix[1]):h.suffix=e(h.suffix),Array.isArray(h.prefix)?h.prefix=t(1===c||"1"===c?h.prefix[0]:h.prefix[1]):h.prefix=t(h.prefix),(0,d.createElement)(C.__experimentalNumberControl,{...h,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}return(0,d.createElement)(xa,{...h,setting:t,availableSmartTags:"trigger_settings"===a?[]:n,isPressEnterToChange:!t.isInputToChange})}return"textarea"===t.el?(0,d.createElement)(ka,{...h,placeholder:t.placeholder?t.placeholder:"",availableSmartTags:"trigger_settings"===a?[]:n}):"tinymce"===t.el?(0,d.createElement)(La,{...h}):"paragraph"===t.el?(0,d.createElement)("div",{className:m},(0,d.createElement)(C.Tip,null,t.content)):"hero"===t.el?(0,d.createElement)("div",{className:m},(0,d.createElement)("h3",null,t.content)):"key_value_repeater"===t.el||"webhook_key_value_repeater"===t.el?(0,d.createElement)(Aa,{...h,setting:t,availableSmartTags:"trigger_settings"===a?[]:n}):"repeater"===t.el?(0,d.createElement)(Pa,{...h,availableSmartTags:"trigger_settings"===a?[]:n}):"query_repeater"===t.el?(0,d.createElement)(Ba,{...h,availableSmartTags:"trigger_settings"===a?[]:n}):e}const Da=({...e})=>{const t=Jo();return e.disableMergeTags||(e.availableSmartTags=t),"image_size_select"===e.setting?.el&&(e.setting.el="select",Array.isArray(N.settings?.imageSizes)&&(e.setting.options=N.settings.imageSizes.map((({name:e,slug:t})=>({label:e,value:t}))))),(0,d.createElement)($a,{...e})},Va=e=>{const[t,n]=U("meta"),a=t?.campaign_data||{};return(0,d.createElement)(Da,{...e,saved:a,setAttributes:e=>{const a=t||{};n({...a,campaign_data:{...a.campaign_data||{},...e}})}})},Fa=function({type:e,help:t,...n}){return(0,d.createElement)(C.Fill,{name:`${A}-content__${e}`},(0,d.createElement)(C.Flex,{align:"top",justify:"center"},(0,d.createElement)(C.__experimentalVStack,{as:C.FlexBlock,spacing:8,style:{maxWidth:620,margin:32}},(0,d.createElement)(Va,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,ee.__)("Email Subject","newsletter-optin-box"),description:(0,ee.__)("Required. The subject of your email.","newsletter-optin-box")}}),(0,d.createElement)(Va,{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,d.createElement)(wt,null))))},Oa=window.wp.keyboardShortcuts;function Ha(){const{replaceBlocks:e}=(0,P.useDispatch)(B.store),{getBlockName:t,getSelectedBlockClientId:n,getBlockAttributes:a}=(0,P.useSelect)(B.store),r=(r,o)=>{r.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=a(i);e(i,(0,ne.createBlock)(l,{level:o,...c}))};return(0,Oa.useShortcut)("core/edit-email/transform-heading-to-paragraph",(e=>r(e,0))),[1,2,3,4,5,6].forEach((e=>{(0,Oa.useShortcut)(`core/edit-email/transform-paragraph-to-heading-${e}`,(t=>r(t,e)))})),null}Ha.Register=function(){const{registerShortcut:e}=(0,P.useDispatch)(Oa.store);return(0,S.useEffect)((()=>{e({name:"core/edit-email/keyboard-shortcuts",category:"main",description:(0,ee.__)("Display these keyboard shortcuts."),keyCombination:{modifier:"access",character:"h"}}),e({name:"core/edit-email/next-region",category:"global",description:(0,ee.__)("Navigate to the next part of the editor."),keyCombination:{modifier:"ctrl",character:"`"},aliases:[{modifier:"access",character:"n"}]}),e({name:"core/edit-email/previous-region",category:"global",description:(0,ee.__)("Navigate to the previous part of the editor."),keyCombination:{modifier:"ctrlShift",character:"`"},aliases:[{modifier:"access",character:"p"},{modifier:"ctrlShift",character:"~"}]}),e({name:"core/edit-email/transform-heading-to-paragraph",category:"block-library",description:(0,ee.__)("Transform heading to paragraph."),keyCombination:{modifier:"access",character:"0"}}),[1,2,3,4,5,6].forEach((t=>{e({name:`core/edit-email/transform-paragraph-to-heading-${t}`,category:"block-library",description:(0,ee.__)("Transform paragraph to heading."),keyCombination:{modifier:"access",character:`${t}`}})}))}),[e]),null};const ja=Ha,Ua=window.wp.notices;function Ga({text:e,children:t}){const{createInfoNotice:n}=(0,P.useDispatch)(Ua.store),a=(0,_.useCopyToClipboard)(e,(()=>{n((0,ee.__)("Error copied to clipboard."),{type:"snackbar"})}));return(0,d.createElement)(C.Button,{variant:"secondary",ref:a},t)}function Wa({message:e,error:t}){const n=[(0,d.createElement)(Ga,{key:"copy-error",text:t.stack},(0,ee.__)("Copy Error"))];return(0,d.createElement)(B.Warning,{className:"edit-post-error-boundary",actions:n},e)}class Ka extends S.Component{constructor(){super(...arguments),this.state={error:null}}componentDidCatch(e){(0,p.doAction)("editor.ErrorBoundary.errorLogged",e)}static getDerivedStateFromError(e){return{error:e}}render(){return this.state.error?(0,d.createElement)(Wa,{message:this.props.error||(0,ee.__)("The editor has encountered an unexpected error."),error:this.state.error}):this.props.children}}const qa=`${A}-content__visual`,Ya=({children:e})=>{const t=lt(),[n,a]=pt({heading:(0,ee.__)("Block Editor","newsletter-optin-box"),helpText:(0,ee.__)("A premium plan allows you to edit your emails using a drag and drop block editor.","newsletter-optin-box"),needsAddonsPack:!1,slug:"block-editor"}),r=b()("content",{"is-premium-feature":!n});return(0,d.createElement)(d.Fragment,null,N.styles&&Object.keys(N.styles).map((e=>(0,d.createElement)("link",{key:e,rel:"stylesheet",id:`${e}-css`,href:N.styles[e]}))),(0,d.createElement)("style",{dangerouslySetInnerHTML:{__html:t}}),(0,d.createElement)("div",{className:r,id:"noptin-email-content"},n?e:a))},Za=function(){const e=(0,P.useSelect)((e=>e(at).getPreviewDeviceType()),[]),t=(0,B.__experimentalUseResizeCanvas)(e),n=(0,B.__unstableUseTypingObserver)(),a={marginLeft:10,marginRight:10};return(0,_.useViewportMatch)("medium","<")&&(a.marginTop=48),(0,d.createElement)(C.Fill,{name:qa},(0,d.createElement)(ja,null),(0,d.createElement)(B.BlockTools,{style:t,className:`edit-post-visual-editor__editor-canvas is-${e.toLowerCase()}-preview`},(0,d.createElement)(B.BlockCanvas,{height:"100%"},(0,d.createElement)(Ya,null,(0,d.createElement)("div",{className:"editor-editor-canvas__post-title-wrapper",contentEditable:!1,ref:n,style:a},(0,d.createElement)(xo,null)),(0,d.createElement)(Ka,null,(0,d.createElement)(B.BlockList,{className:"edit-post-editor-canvas__block-list"}))))))},Qa=window.wp.autop,Xa=`${A}-content__normal`;function Ja(){const[e,t]=U("meta"),[n,a]=J("content_normal",e,t);let r=n||"";return(0,S.useEffect)((()=>{r=(0,Qa.autop)(n||"")}),[]),(0,d.createElement)(C.Fill,{name:Xa},(0,d.createElement)(C.Flex,{align:"top",justify:"center"},(0,d.createElement)(C.FlexBlock,{style:{maxWidth:620,margin:32}},(0,d.createElement)(C.__experimentalVStack,{spacing:8},(0,d.createElement)(Va,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,ee.__)("Email Subject","newsletter-optin-box"),description:(0,ee.__)("Required. The subject of your email.","newsletter-optin-box")}}),(0,d.createElement)(Va,{settingKey:"heading",setting:{el:"input",type:"text",label:(0,ee.__)("Email Heading","newsletter-optin-box"),description:(0,ee.__)("This text will be displayed at the top of the email.","newsletter-optin-box")}}),(0,d.createElement)(Ka,null,(0,d.createElement)(Va,{settingKey:"content_normal",setting:{el:"tinymce",label:(0,ee.__)("Email Content","newsletter-optin-box"),description:(0,ee.__)("The content of your email. You can use email tags to provide dynamic values.","newsletter-optin-box")}})),(0,d.createElement)(Va,{settingKey:"footer_text",setting:{el:"textarea",label:(0,ee.__)("Footer Text","newsletter-optin-box"),description:(0,ee.__)("This text will be displayed at the bottom of the email.","newsletter-optin-box")}}),(0,d.createElement)(wt,null)))))}function er({mode:e}){return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Za,null),(0,d.createElement)(Ja,null),(0,d.createElement)(Fa,{type:"plain_text",label:(0,ee.__)("Email Content","newsletter-optin-box"),placeholder:(0,ee.__)("Type your email content here","newsletter-optin-box"),help:(0,ee.__)("You can use email tags to provide dynamic values.","newsletter-optin-box")}),(0,d.createElement)(Fa,{type:"raw_html",label:(0,ee.__)("Email Content","newsletter-optin-box"),placeholder:(0,ee.__)("Paste the raw HTML of your email here","newsletter-optin-box"),help:(0,ee.__)("You can use email tags to provide dynamic values.","newsletter-optin-box")}),(0,d.createElement)(C.Slot,{name:`${A}-content__${e}`}))}function tr(){const{emailType:e}=X();return(0,d.createElement)(Ka,null,(0,d.createElement)(er,{mode:e}))}const nr=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),ar=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"})),rr=e=>{e.preventDefault()},or=(0,S.forwardRef)((function(e,t){const n=(0,St.isAppleOS)()?St.displayShortcut.primaryShift("`"):St.displayShortcut.primary("`"),a=(0,P.useSelect)((e=>e(at).isInserterOpened()),[]),{setIsInserterOpened:r}=(0,P.useDispatch)(at);return(0,d.createElement)(C.Button,{...e,ref:t,className:"edit-post-header-toolbar__inserter-toggle",variant:"primary",isPressed:a,"aria-expanded":a,onMouseDown:rr,onClick:()=>r(!a),icon:ar -/* translators: button label text should, if possible, be under 16 characters. */,label:(0,ee.__)("Toggle block inserter"),shortcut:n,showTooltip:!0})})),lr=function({contentType:e,hideActions:t}){const n=(0,ee.sprintf)(/* translators: %s: content type label. */ -(0,ee.__)("%s Email"),R[e]?.label||"");return(0,d.createElement)(B.NavigableToolbar,{className:"edit-post-header-toolbar","aria-label":(0,ee.__)("Email tools"),shouldUseKeyboardFocusShortcut:!0,variant:"unstyled"},(0,d.createElement)("div",{className:"edit-post-header-toolbar__left"},t?" ":(0,d.createElement)(d.Fragment,null,"visual"===e&&(0,d.createElement)(kt,{breakpoint:"large"},(0,d.createElement)(C.ToolbarItem,{as:or})),(0,d.createElement)(C.ToolbarItem,{as:T.EditorHistoryUndo,size:"compact"}),(0,d.createElement)(C.ToolbarItem,{as:T.EditorHistoryRedo,size:"compact"}),"visual"!==e&&(0,d.createElement)(C.__experimentalText,{className:"edit-post-header-toolbar__title",as:"span",size:14,weight:500,numberOfLines:1,truncate:!0,upperCase:!0},n))))},ir=function(){const[e,t]=U("meta");return(0,d.createElement)(C.MenuGroup,{label:(0,ee.__)("Editor")},(0,d.createElement)(C.MenuItemsChoice,{choices:z,value:e?.campaign_data?.email_type,onSelect:n=>{t({...e,campaign_data:Q({...e?.campaign_data||{},email_type:n})})}}))},{Fill:sr,Slot:cr}=(0,C.createSlotFill)("ToolsMoreMenuGroup");sr.Slot=({fillProps:e})=>(0,d.createElement)(cr,{fillProps:e},(e=>e.length>0&&(0,d.createElement)(C.MenuGroup,{label:(0,ee.__)("Tools")},e)));const ur=sr,pr=function(){return(0,d.createElement)(C.MenuGroup,{label:(0,ee._x)("View","noun")},(0,d.createElement)(re.PreferenceToggleMenuItem,{scope:at.name,name:"fullscreenMode",label:(0,ee.__)("Fullscreen mode"),info:(0,ee.__)("Show and hide admin UI"),messageActivated:(0,ee.__)("Fullscreen mode activated"),messageDeactivated:(0,ee.__)("Fullscreen mode deactivated")}))},mr=()=>(0,d.createElement)(_e,{toggleProps:{showTooltip:!0}},(({onClose:e})=>(0,d.createElement)(d.Fragment,null,(0,d.createElement)(kt,{breakpoint:"large",operator:"<"},(0,d.createElement)(me.Slot,{scope:A})),(0,d.createElement)(kt,{breakpoint:"medium"},(0,d.createElement)(pr,null)),(0,d.createElement)(ir,null),(0,d.createElement)(fe.Slot,{name:`${A}/plugin-more-menu`,label:(0,ee.__)("Plugins"),as:C.MenuGroup,fillProps:{onClick:e}}),(0,d.createElement)(ur.Slot,{fillProps:{onClose:e}})))),dr=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),gr=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),_r=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),hr=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),br=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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 fr({isVisual:e}){const t=(0,P.useSelect)((e=>e(at).getPreviewDeviceType()),[]),{setPreviewDeviceType:n}=(0,P.useDispatch)(at),a={"aria-label":(0,ee.__)("View options")},r={mobile:dr,tablet:gr,desktop:_r};return(0,d.createElement)(C.DropdownMenu,{className:"editor-preview-dropdown",popoverProps:{placement:"bottom-end"},toggleProps:{className:"editor-preview-dropdown__toggle",size:"compact",showTooltip:!0},menuProps:a,icon:r[t.toLowerCase()],label:(0,ee.__)("View")},(({onClose:a})=>(0,d.createElement)(d.Fragment,null,e&&(0,d.createElement)(C.MenuGroup,null,(0,d.createElement)(C.MenuItem,{onClick:()=>n("Desktop"),icon:"Desktop"===t&&hr},(0,ee.__)("Desktop")),(0,d.createElement)(C.MenuItem,{onClick:()=>n("Tablet"),icon:"Tablet"===t&&hr},(0,ee.__)("Tablet")),(0,d.createElement)(C.MenuItem,{onClick:()=>n("Mobile"),icon:"Mobile"===t&&hr},(0,ee.__)("Mobile"))),(0,d.createElement)(C.MenuGroup,null,(0,d.createElement)(T.PostPreviewButton,{className:"editor-preview-dropdown__button-external",role:"menuitem",textContent:(0,d.createElement)(d.Fragment,null,(0,ee.__)("Preview in new tab"),(0,d.createElement)(C.Icon,{icon:br})),onPreview:a})))))}const yr={hidden:{y:"-50px"},distractionFreeInactive:{y:0},hover:{y:0,transition:{type:"tween",delay:.2}}},vr=function({hideActions:e}){const{emailType:t}=X(),n="visual"===t;return(0,d.createElement)("div",{className:"edit-post-header"},(0,d.createElement)(C.Button,{className:"edit-post-fullscreen-mode-close",icon:nr,href:N.back,label:(0,ee.__)("Back"),showTooltip:!0}),(0,d.createElement)(C.__unstableMotion.div,{variants:yr,transition:{type:"tween",delay:.8},className:"edit-post-header__toolbar"},(0,d.createElement)(lr,{hideActions:e,contentType:t})),(0,d.createElement)(C.__unstableMotion.div,{variants:yr,transition:{type:"tween",delay:.8},className:"edit-post-header__settings"},(0,d.createElement)(kt,{breakpoint:"medium",operator:"<"},(0,d.createElement)(T.PostPreviewButton,{className:"edit-post-header__post-preview-button"})),(0,d.createElement)(T.PostSavedState,null),(0,d.createElement)(T.PostPublishButton,null),(0,d.createElement)(kt,{breakpoint:"large"},(0,d.createElement)(fr,{isVisual:n}),(0,d.createElement)(me.Slot,{scope:A})),(0,d.createElement)(mr,null)))};function Er(){return(0,d.createElement)("div",{className:"edit-post-layout__footer"},(0,d.createElement)(B.BlockBreadcrumb,{rootLabelText:(0,ee.__)("Email")}))}const xr=window.lodash,kr=(0,d.createElement)(de.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),wr=(0,d.createElement)(de.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),Cr=()=>{const[e,t]=U("title"),n=G(),{emailType:a}=X();return(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Email Settings","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,{spacing:4},(0,d.createElement)(Va,{settingKey:"email_type",setting:{el:"select",label:(0,ee.__)("Editor","newsletter-optin-box"),options:z,description:R[a]?.description||(0,ee.__)("Choose the type of email you want to create.","newsletter-optin-box"),sanitize:Q}}),"normal"===a&&(0,d.createElement)(Va,{settingKey:"template",setting:{el:"select",label:(0,ee.__)("Template","newsletter-optin-box"),options:$,description:(0,ee.__)("Choose the template you want to use.","newsletter-optin-box"),sanitize:Q}}),(0,d.createElement)(C.TextControl,{value:e||"",onChange:t,label:(0,ee.__)("Campaign Name","newsletter-optin-box"),help:(0,ee.__)("For your reference only.","newsletter-optin-box"),placeholder:(0,ee.__)("Example: Black Friday Sale","newsletter-optin-box")}),("visual"===a||"normal"===a)&&(0,d.createElement)(Va,{settingKey:"preview_text",setting:{el:"input",type:"text",label:(0,ee.__)("Preview Text","newsletter-optin-box"),description:(0,ee.__)("This is the text that appears in the inbox when the email is received.","newsletter-optin-box"),placeholder:(0,ee.__)("Example: Save up to 50%","newsletter-optin-box")}}),n?.extra_settings&&(0,d.createElement)(d.Fragment,null,Object.keys(n.extra_settings).map((e=>(0,d.createElement)(Va,{key:e,settingKey:e,setting:n.extra_settings[e]})))),(0,d.createElement)(C.Slot,{name:`${A}/editor-settings__main`})))},Sr={color:(0,ee.__)("Text"),link_color:(0,ee.__)("Link"),background_color:(0,ee.__)("Background"),content_background:(0,ee.__)("Content Background"),footer_text_color:(0,ee.__)("Footer text color")},Tr=()=>{const e=yt(),[t,n]=U("meta"),{templateSupports:a}=X(),r=(0,S.useMemo)((()=>(0,xr.compact)(Object.entries(Sr).map((([e,r])=>a(e)?{value:t?.campaign_data?.[e]||"",onChange:a=>n({...t||{},campaign_data:{...t?.campaign_data||{},[e]:a}}),label:r}:null)))),[a,t,n]);return(0,d.createElement)(d.Fragment,null,r.length>0&&(0,d.createElement)(B.PanelColorSettings,{__experimentalIsRenderedInSidebar:!0,enableAlpha:!1,showTitle:!0,disableCustomColors:!1,colors:e,title:(0,ee.__)("Colors"),colorSettings:r}))},Br=[{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"}],Pr=()=>{const[e,t]=U("meta"),[n,a]=J("width",e,t),{templateSupports:r}=X();return r("custom_css")||r("width")?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Design","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,{spacing:4},r("width")&&(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Width","newsletter-optin-box"),value:n||"600px",onChange:a,min:100,max:1e3,units:Br,help:(0,ee.__)("The width of your email's content area.","newsletter-optin-box")}),r("custom_css")&&(0,d.createElement)(Va,{settingKey:"custom_css",setting:{el:"textarea",label:(0,ee.__)("Custom CSS","newsletter-optin-box"),description:(0,ee.__)("Add custom CSS to your email. You can also use this field to import custom fonts.","newsletter-optin-box")}}),(0,d.createElement)(C.Slot,{name:`${A}/editor-settings__design`}))):null},Ir=()=>{const[e,t]=U("meta"),[n,a]=J("font_family",e,t),[r,o]=J("font_size",e,t),[l,i]=J("font_style",e,t),[s,c]=J("font_weight",e,t),[u,p]=J("line_height",e,t),{templateSupports:m}=X(),g=["font_family","font_size","font_style","font_weight","line_height"].some((e=>m(e))),_=(0,d.useCallback)((({fontStyle:e,fontWeight:t})=>{i(e),c(t)}),[c,i]),h={fontStyle:l,fontWeight:s};return g?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Typography","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,{spacing:4},m("font_family")&&(0,d.createElement)(xt,{value:n||"",onChange:a}),m("font_size")&&(0,d.createElement)(B.FontSizePicker,{__nextHasNoMarginBottom:!0,value:r||14,fallbackFontSize:14,onChange:o,label:(0,ee.__)("Font size","newsletter-optin-box"),disableCustomFontSizes:!1}),(m("font_style")||m("font_weight"))&&(0,d.createElement)(B.__experimentalFontAppearanceControl,{__nextHasNoMarginBottom:!0,hasFontStyles:m("font_style"),hasFontWeights:m("font_weight"),value:h,onChange:_}),m("line_height")&&(0,d.createElement)(B.LineHeightControl,{__nextHasNoMarginBottom:!0,value:u||"1.7",onChange:p,label:(0,ee.__)("Line height","newsletter-optin-box"),__unstableInputWidth:"100%"}),(0,d.createElement)(C.Slot,{name:`${A}/editor-settings__typography`}))):null},Ar=()=>{const[e,t]=pt({heading:(0,ee.__)("Attach Files","newsletter-optin-box"),helpText:(0,ee.__)("The add-ons pack allows you to attach images, videos, PDFs or other file types to this email.","newsletter-optin-box"),needsAddonsPack:!0,slug:"attachments"}),[n,a]=U("meta"),[r,o]=J("attachments",n,a),l=r||[],i=(0,S.useCallback)((()=>{o([...l,""])}),[l,o]),s=(0,S.useCallback)((e=>{o(l.filter(((t,n)=>n!==e)))}),[l,o]),c=(0,S.useCallback)(((e,t)=>{o(l.map(((n,a)=>a===e?t:n)))}),[l,o]);return(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Email Attachments","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,null,!e&&t,e&&(0,d.createElement)(d.Fragment,null,l.map(((e,t)=>(0,d.createElement)(C.__experimentalInputControl,{label:(0,ee.__)("Enter file path or URL","newsletter-optin-box"),value:e,onChange:e=>c(t,e),isPressEnterToChange:!0,hideLabelFromVision:!0,placeholder:(0,ee.__)("Enter file path or URL","newsletter-optin-box"),key:t,prefix:(0,d.createElement)(d.Fragment,null,(0,d.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,d.createElement)(C.Button,{variant:"tertiary",onClick:e,icon:"upload",label:(0,ee.__)("Upload","newsletter-optin-box"),showTooltip:!0})})),suffix:(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.Button,{isDestructive:!0,variant:"tertiary",onClick:()=>s(t),icon:"trash",label:(0,ee.__)("Remove","newsletter-optin-box"),showTooltip:!0}))}))),(0,d.createElement)(C.Button,{variant:"primary",onClick:i,style:{justifyContent:"center"}},(0,ee.__)("Add Attachment","newsletter-optin-box"),(0,d.createElement)(C.Icon,{icon:"plus"})),(0,d.createElement)("p",{className:"description"},(0,ee.__)("You can only attach files that are hosted on your server.","newsletter-optin-box")))))};function Nr(){return(0,d.createElement)(T.PostTrashCheck,null,(0,d.createElement)(T.PostTrash,null))}const Mr=(0,S.forwardRef)((({className:e,label:t,children:n},a)=>{const r={};return t||(r.width="100%"),(0,d.createElement)(C.__experimentalHStack,{className:b()("editor-post-panel__row",e),ref:a},t&&(0,d.createElement)("div",{className:"editor-post-panel__row-label"},t),(0,d.createElement)("div",{className:"editor-post-panel__row-control",style:r},n))})),Lr=function(){return(0,d.createElement)(T.PostPendingStatusCheck,null,(0,d.createElement)(Mr,null,(0,d.createElement)(T.PostPendingStatus,null)))},{Fill:Rr,Slot:zr}=(0,C.createSlotFill)("PluginPostStatusInfo"),$r=({children:e,className:t})=>(0,d.createElement)(Rr,null,(0,d.createElement)(C.PanelRow,{className:t},e));$r.Slot=zr;const Dr=$r;function Vr(){const[e,t]=(0,S.useState)(null),n=(0,S.useMemo)((()=>({anchor:e,"aria-label":(0,ee.__)("Change publish date"),placement:"bottom-end"})),[e]);return(0,d.createElement)(T.PostScheduleCheck,null,(0,d.createElement)(Mr,{label:(0,ee.__)("Publish"),ref:t},(0,d.createElement)(C.Dropdown,{popoverProps:n,focusOnMount:!0,className:"editor-post-schedule__panel-dropdown",contentClassName:"editor-post-schedule__dialog",renderToggle:({onToggle:e,isOpen:t})=>(0,d.createElement)(C.Button,{className:"editor-post-schedule__dialog-toggle",variant:"tertiary",onClick:e,label:(0,d.createElement)(T.PostScheduleLabel,{full:!0}),showTooltip:!0,"aria-expanded":t},(0,d.createElement)(T.PostScheduleLabel,null)),renderContent:({onClose:e})=>(0,d.createElement)(T.PostSchedule,{onClose:e})})))}const Fr=({onClose:e})=>{const t=H(),[n,a]=(0,S.useState)(N.user?.email||""),[r,o]=(0,S.useState)(!1),[l,i]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),u=(0,P.useSelect)((e=>e(T.store).isEditedPostDirty()),[]);return(0,S.useEffect)((()=>{l&&i(null),s&&c(null)}),[n]),(0,S.useEffect)((()=>{r&&(i(null),c(null),k()({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)})))}),[r]),u?(0,d.createElement)(C.Notice,{status:"warning",isDismissible:!1,className:"noptin-test-email-form__notice",actions:[{label:(0,ee.__)("Go Back"),onClick:e}]},(0,ee.__)("Please save your changes before sending a test email.")):(0,d.createElement)(C.__experimentalVStack,{className:"noptin-test-email-form"},(0,d.createElement)(C.TextControl,{label:(0,ee.__)("Email address"),type:"email",placeholder:(0,ee.__)("Enter email address"),help:(0,ee.__)("Enter the email address where you want to send the test email."),value:n,onChange:a}),(0,d.createElement)(C.Button,{variant:"primary",onClick:()=>o(!0),disabled:r||!n||!(0,E.isEmail)(n),isPressed:r,isBusy:r},!r&&(0,ee.__)("Send test email"),r&&(0,ee.__)("Sending..."),!r&&(0,d.createElement)(C.Icon,{icon:"arrow-right-alt"}),r&&(0,d.createElement)(C.Spinner,null)),(0,d.createElement)(C.Button,{variant:"secondary",onClick:e},s?(0,ee.__)("Close"):(0,ee.__)("Cancel")),l&&(0,d.createElement)(C.Notice,{status:"error",className:"noptin-test-email-form__notice",onDismiss:()=>i(null)},l),s&&(0,d.createElement)(C.Notice,{status:"success",className:"noptin-test-email-form__notice",onDismiss:()=>c(null)},s))};function Or(){const[e,t]=(0,S.useState)(null),n=(0,S.useMemo)((()=>({anchor:e,"aria-label":(0,ee.__)("Send a test email"),placement:"bottom-end"})),[e]);return(0,d.createElement)(Mr,{label:(0,ee.__)("Test"),ref:t},(0,d.createElement)(C.Dropdown,{popoverProps:n,focusOnMount:!0,className:"editor-post-test__panel-dropdown",contentClassName:"editor-post-test__dialog",renderToggle:({onToggle:e,isOpen:t})=>(0,d.createElement)(C.Button,{className:"editor-post-schedule__dialog-toggle",variant:"tertiary",onClick:e,label:(0,ee.__)("Send a test email"),showTooltip:!0,"aria-expanded":t},(0,ee.__)("Send a test email")),renderContent:({onClose:e})=>(0,d.createElement)(Fr,{onClose:e})}))}function Hr(){return(0,d.createElement)(C.PanelBody,{className:"edit-post-post-status",title:(0,ee.__)("Summary"),initialOpen:!1},(0,d.createElement)(Dr.Slot,null,(e=>(0,d.createElement)(C.__experimentalVStack,null,(0,d.createElement)(Vr,null),(0,d.createElement)(Or,null),e,(0,d.createElement)(Lr,null),(0,d.createElement)(C.__experimentalHStack,{style:{marginTop:"16px"},spacing:4,wrap:!0},(0,d.createElement)(T.PostSwitchToDraftButton,null),(0,d.createElement)(Nr,null))))))}const jr=[{label:(0,ee.__)("Select unit","newsletter-optin-box"),value:""},{label:(0,ee.__)("Minutes","newsletter-optin-box"),value:"minutes"},{label:(0,ee.__)("Hours","newsletter-optin-box"),value:"hours"},{label:(0,ee.__)("Days","newsletter-optin-box"),value:"days"},{label:(0,ee.__)("Weeks","newsletter-optin-box"),value:"weeks"},{label:(0,ee.__)("Months","newsletter-optin-box"),value:"months"},{label:(0,ee.__)("Years","newsletter-optin-box"),value:"years"}],Ur=[{label:(0,ee.__)("Select unit","newsletter-optin-box"),value:""},{label:(0,ee.__)("Minute","newsletter-optin-box"),value:"minutes"},{label:(0,ee.__)("Hour","newsletter-optin-box"),value:"hours"},{label:(0,ee.__)("Day","newsletter-optin-box"),value:"days"},{label:(0,ee.__)("Week","newsletter-optin-box"),value:"weeks"},{label:(0,ee.__)("Month","newsletter-optin-box"),value:"months"},{label:(0,ee.__)("Year","newsletter-optin-box"),value:"years"}],Gr=()=>{const e=G(),[t,n]=pt({heading:(0,ee.__)("Delay sending this email","newsletter-optin-box"),helpText:(0,ee.__)("The add-ons pack allows you to delay (schedule) this email for a given number of minutes, hours, or days.","newsletter-optin-box"),needsAddonsPack:!0,slug:"timing"}),[a,r]=U("meta"),[o,l]=J("when_to_run",a,r),[i,s]=J("sends_after",a,r),[c,u]=J("sends_after_unit",a,r),p="delayed"===o,m=(0,S.useCallback)((()=>{l(p?"immediately":"delayed")}),[p,l]);return e?.supports_timing?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Timing","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,null,!t&&n,t&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.ToggleControl,{label:(0,ee.__)("Delay sending this email","newsletter-optin-box"),checked:p,onChange:m,__nextHasNoMarginBottom:!0}),p&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.__experimentalHStack,null,(0,d.createElement)(C.__experimentalInputControl,{type:"number",label:(0,ee.__)("Send after","newsletter-optin-box"),placeholder:"1",value:i||"",onChange:s,min:1}),(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("Unit","newsletter-optin-box"),value:c||"",onChange:e=>u(e),options:1===parseInt(i)?Ur:jr})),(0,d.createElement)("p",{className:"description"},(0,ee.__)("This email will be sent after the specified time has elapsed.","newsletter-optin-box")))))):null},Wr=Object.entries(M.senders).map((([e,t])=>({label:t.label,value:e,disabled:!1}))),Kr=({recipient:e,recipientIds:t,setRecipientIds:n})=>{const a=(0,S.useCallback)((()=>{n(t.filter((t=>t!==e.id)))}),[e,t,n]);return e?(0,d.createElement)(C.__experimentalHStack,{wrap:!0},(0,d.createElement)("img",{src:e.avatar,width:32,alt:e.name}),(0,d.createElement)("p",null,e.name?e.email:`${e.name} <${e.email}>`),e.url&&(0,d.createElement)(C.Button,{href:e.url,target:"_blank"},(0,d.createElement)(C.Icon,{icon:"external"})),(0,d.createElement)(C.Button,{isDestructive:!0,onClick:a},(0,d.createElement)(C.Icon,{icon:"no-alt"}))):null},qr=({recipientData:e,recipientIds:t,setRecipientIds:n})=>(0,d.createElement)(d.Fragment,null,t.map((a=>(0,d.createElement)(Kr,{key:a,recipient:e.find((e=>e.id===a)),recipientIds:t,setRecipientIds:n})))),Yr=({sender:e})=>{const{fields:t,key:n,upsell:a,disableMergeTags:r=!0}=M.senders?.[e]?.settings||{},[o,l]=pt({heading:(0,ee.sprintf)((0,ee.__)("Filter %s","newsletter-optin-box"),M.senders?.[e]?.label||(0,ee.__)("Recipients","newsletter-optin-box")),helpText:a?.message||(0,ee.__)("A premium plan allows you to filter recipients by custom fields etc.","newsletter-optin-box"),needsAddonsPack:"noptin"===e,slug:"filter-subscribers"});if(!t||Array.isArray(t)||0===Object.keys(t).length)return null;const i="manual_recipients"===e||o;return(0,d.createElement)(d.Fragment,null,!i&&l,i&&(0,d.createElement)(d.Fragment,null,Object.entries(t).map((([e,t])=>(0,d.createElement)(Va,{key:e,settingKey:e,setting:t,prop:n,disableMergeTags:r})))))},Zr=()=>{const e=G(),[t,n]=U("meta"),[a,r]=J("manual_recipients_ids",t,n),o=Array.isArray(a)&&a.length>0;return e.supports_recipients?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Send To","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,{spacing:4},o?(0,d.createElement)(qr,{recipientData:e.manual_recipients,recipientIds:a,setRecipientIds:r}):(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Va,{settingKey:"email_sender",setting:{el:"select",label:(0,ee.__)("Send To","newsletter-optin-box"),options:Wr,customAttributes:{allowReset:!1,hideLabelFromVision:!0}}}),(0,d.createElement)(Yr,{sender:t?.campaign_data?.email_sender})))):null},Qr=()=>{const e=G(),[t,n]=U("noptin_automation_rule"),a=e=>{n({...t,saved:{...t.saved,...e}})};return e?.is_automation_rule?t.error?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Conditional Logic","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.Notice,{status:"error",isDismissible:!1},t.error)):t.settings?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Conditional Logic","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,null,Object.keys(t.settings).map((e=>(0,d.createElement)(Da,{key:e,settingKey:e,saved:t.saved,setAttributes:a,setting:t.settings[e]}))))):null:null},Xr="post_notifications",Jr="post_digest",eo=({isPostDigest:e})=>{const t=bt();if(!Array.isArray(t)||!t.length)return null;const n={el:"combobox",label:(0,ee.__)("Post type","newsletter-optin-box"),placeholder:(0,ee.__)("Select a post type","newsletter-optin-box"),description:e?(0,d.createElement)(d.Fragment,null,(0,ee.__)("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,d.createElement)("br",null),(0,d.createElement)(C.Button,{href:"https://noptin.com/guide/sending-emails/new-post-notifications/#set-digest-post-types",target:"_blank",variant:"link"},(0,ee.__)("Learn more","newsletter-optin-box"))):(0,ee.__)("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,d.createElement)(Va,{settingKey:"noptin-ap-post-type",setting:n})},to={"-1":(0,ee.__)("Do not filter by tags, categories, etc","noptin-addons-pack"),include:(0,ee.__)("Only send for some tags, categories, etc","noptin-addons-pack"),exclude:(0,ee.__)("Do not send for some tags, categories, etc","noptin-addons-pack")},no=({postType:e})=>{const[t,n]=U("meta"),{termsByTaxonomy:a}=G(),r=t?.campaign_data||{},o=r["noptin-ap-terms-action"]||"-1",l=ft(e),i=(0,S.useCallback)((e=>{const a=t||{};n({...a,campaign_data:{...a.campaign_data||{},...e}})}),[t,n]);return(0,S.useEffect)((()=>{Array.isArray(r["noptin-ap-terms"])&&a&&0!==Object.keys(a).length&&i({"noptin-ap-terms":"",tax_query:{...r.tax_query||{},...a}})}),[a,i]),l&&0!==l.length?(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Va,{settingKey:"noptin-ap-terms-action",setting:{el:"select",options:to,label:(0,ee.__)("Filter by terms","newsletter-optin-box"),description:(0,ee.__)("Optional. Select how to filter posts by terms.","newsletter-optin-box")}}),["include","exclude"].includes(o)&&(0,d.createElement)(To,{postType:e,attributes:r,setAttributes:i})):null},ao=()=>{const[e,t]=pt({heading:(0,ee.__)("Set post type","newsletter-optin-box"),helpText:(0,d.createElement)(d.Fragment,null,(0,ee.__)("This email will only send for blog posts.","newsletter-optin-box"),(0,d.createElement)("br",null),(0,ee.__)("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"),a=n?.campaign_type,r=n?.automation_type,o=n?.campaign_data?.["noptin-ap-post-type"];return"automation"===a&&[Jr,Xr].includes(r)?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Post settings","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,null,!e&&t,e&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(eo,{isPostDigest:Jr===r}),Xr===r&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Va,{settingKey:"noptin-ap-authors",setting:{el:"input",type:"text",label:(0,ee.__)("Authors","newsletter-optin-box"),placeholder:(0,ee.__)("Send for all authors","newsletter-optin-box"),description:(0,ee.__)("Enter a comma-separated list of author IDs or leave blank to send for all authors.","newsletter-optin-box")},disableMergeTags:!0}),N?.languages&&(0,d.createElement)(Va,{settingKey:"noptin-ap-language",setting:{el:"combobox",label:(0,ee.__)("Language","newsletter-optin-box"),placeholder:(0,ee.__)("All languages","newsletter-optin-box"),options:N.languages,description:(0,ee.__)("Optional. Send for posts in the selected language only.","newsletter-optin-box")}})),o&&(0,d.createElement)(no,{postType:o})))):null};function ro(){return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Hr,null),(0,d.createElement)(Cr,null),(0,d.createElement)(ao,null),(0,d.createElement)(Qr,null),(0,d.createElement)(Zr,null),(0,d.createElement)(Gr,null),(0,d.createElement)(Ar,null),(0,d.createElement)(Ir,null),(0,d.createElement)(Pr,null),(0,d.createElement)(Tr,null))}const oo=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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 lo({as:e=C.Button,name:t,...n}){const a=e,r=(0,P.useSelect)((e=>e(at).getCurrentSidebar()===t),[t]),{setCurrentSidebar:o}=(0,P.useDispatch)(at);return(0,d.createElement)(a,{isPressed:r,"aria-controls":t.replace("/",":"),onClick:()=>{o(r?null:t)},...n})}const io=({children:e,className:t,toggleButtonProps:n})=>{const a=(0,d.createElement)(lo,{icon:oo,...n});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)("div",{className:"components-panel__header interface-complementary-area-header__small"},a),(0,d.createElement)("div",{className:b()("components-panel__header","interface-complementary-area-header",t),tabIndex:-1},e,a))},so=`${A}/sidebar-area`;function co({children:e,className:t,id:n}){return(0,d.createElement)(C.Fill,{name:so},(0,d.createElement)("div",{id:n,className:t},e))}function uo({children:e,className:t,closeLabel:n=(0,ee.__)("Close plugin"),name:a,header:r,headerClassName:o,icon:l,panelClassName:i,title:s,isActiveByDefault:c=!1}){const u=(0,P.useSelect)((e=>e(at).getCurrentSidebar()),[a]),{setCurrentSidebar:p}=(0,P.useDispatch)(at),m=u===a,g=(0,_.useViewportMatch)("medium","<");return(0,S.useEffect)((()=>{c&&void 0===u&&!g&&p(a)}),[u,c,a,g]),(0,d.createElement)(d.Fragment,null,(0,d.createElement)(me,{scope:A},(0,d.createElement)(lo,{name:a,"aria-expanded":m,label:s,icon:l,showTooltip:!0,size:"compact"})),m&&(0,d.createElement)(co,{className:b()("interface-complementary-area",t),id:a.replace("/",":")},(0,d.createElement)(io,{className:o,toggleButtonProps:{label:n,name:a}},r),(0,d.createElement)(C.Panel,{className:i},e)))}uo.Slot=e=>(0,d.createElement)(C.Slot,{name:so,...e});const po=uo;function mo(){const[e,t]=(0,S.useState)(V),{emailType:n}=X(),a=(0,S.useCallback)((()=>{t(D)}),[t]),r=(0,S.useCallback)((()=>{t(V)}),[t]),{hasSelectedBlock:o}=(0,P.useSelect)((e=>({hasSelectedBlock:!!e(B.store).getSelectedBlock()})),[]);(0,S.useEffect)((()=>{"visual"===n||e!==D?(o&&e===V&&t(D),o||e!==D||t(V)):t(V)}),[o,t,n]);const l=(0,S.useMemo)((()=>(0,xr.compact)([{name:V,title:(0,ee.__)("Settings"),onClick:r},"visual"===n&&{name:D,title:(0,ee.__)("Block"),onClick:a}])),[r,a,n]);return(0,d.createElement)(po,{className:"edit-post-sidebar",header:(0,d.createElement)("ul",null,l.map((t=>(0,d.createElement)("li",{key:t.name},(0,d.createElement)(C.Button,{onClick:t.onClick,className:b()("edit-post-sidebar__panel-tab",t.name.replace(/\//g,"__").toLowerCase(),{"is-active":e===t.name}),"aria-label":e===t.name?(0,ee.sprintf)((0,ee.__)("%s (selected)"),t.title):t.title,"data-label":t.title},t.title))))),headerClassName:"edit-post-sidebar__panel-tabs" -/* translators: button label text should, if possible, be under 16 characters. */,title:e===V?(0,ee.__)("Settings"):(0,ee.__)("Block"),closeLabel:(0,ee.__)("Close Settings"),name:V,icon:(0,ee.isRTL)()?kr:wr,isActiveByDefault:!0},e===V&&(0,d.createElement)(ro,null),e===D&&(0,d.createElement)(B.BlockInspector,{showNoBlockSelectedMessage:!0}))}function go(){const e=(0,P.useSelect)((e=>e(at).getInsertionPoint()),[]);return(0,d.createElement)("div",{className:"edit-post-editor__inserter-panel"},(0,d.createElement)("div",{className:"edit-post-editor__inserter-panel-content"},(0,d.createElement)(B.__experimentalLibrary,{showInserterHelpPanel:!1,shouldFocusBlock:!0,rootClientId:e.rootClientId,__experimentalInsertionIndex:e.insertionIndex,__experimentalFilterValue:e.filterValue})))}function _o(){const e=(0,_.useFocusOnMount)("firstElement"),[t,n]=(0,S.useState)(null),a=(0,S.useRef)(),r=(0,_.useMergeRefs)([e,a,n]);return(0,d.createElement)("div",{className:"edit-post-editor__document-overview-panel"},(0,d.createElement)("div",{className:"edit-post-editor__list-view-container",ref:r},(0,d.createElement)("div",{className:"edit-post-editor__list-view-panel-content"},(0,d.createElement)(B.__experimentalListView,{dropZoneElement:t}))))}const ho=[{name:"blocks",title:(0,ee.__)("Blocks","newsletter-optin-box")},{name:"overview",title:(0,ee.__)("Overview","newsletter-optin-box")}];function bo(){return(0,d.createElement)(kt,{breakpoint:"medium"},(0,d.createElement)(C.TabPanel,{className:"block-editor-inserter__tabs edit-post-editor__inserter-panel",tabs:ho},(e=>(0,d.createElement)("div",{style:{width:350,overflow:"auto"}},(0,d.createElement)(C.__experimentalScrollable,null,"blocks"===e.name&&(0,d.createElement)(go,null),"overview"===e.name&&(0,d.createElement)(_o,null))))))}function fo(){const[e,t]=(0,S.useState)(0),n=H(),a=(0,_.usePrevious)(n);(0,S.useEffect)((()=>{n===a&&n===e||!n||r(n)}),[n,a,e]);const r=e=>{window.history.replaceState({noptin_campaign:e},"Email "+e,function(e){return(0,E.addQueryArgs)("admin.php",{noptin_campaign:e,page:"noptin-email-campaigns"})}(e)),t(e)};return null}const yo=window.wp.richText,vo=window.wp.dom,Eo=/[\r\n]+/g,xo=(0,S.forwardRef)((function(e,t){const[n,a]=(0,S.useState)(!1),{ref:r}=function(e){const t=(0,S.useRef)(),n=(0,P.useSelect)((e=>e(T.store).isCleanNewPost()),[]);return(0,S.useImperativeHandle)(e,(()=>({focus:()=>{t?.current?.focus()}}))),(0,S.useEffect)((()=>{if(!t.current)return;const{defaultView:e}=t.current.ownerDocument,{name:a,parent:r}=e,o="editor-canvas"===a?r.document:e.document,{activeElement:l,body:i}=o;!n||l&&i!==l||t.current.focus()}),[n]),{ref:t}}(t),[o,l]=U("meta"),[i,s]=J("subject",o,l),[c,u]=(0,S.useState)({}),{clearSelectedBlock:p,insertBlocks:m,insertDefaultBlock:g}=(0,P.useDispatch)(B.store);function h(e){m(e,0)}function f(){a(!1),u({})}const{ref:y}=(0,yo.__unstableUseRichText)({value:i,onChange:function(e){s(e.replace(Eo," "))},placeholder:(0,ee.__)("Enter email subject"),selectionStart:c.start,selectionEnd:c.end,onSelectionChange(e,t){u((n=>{const{start:a,end:r}=n;return a===e&&r===t?n:{start:e,end:t}}))},__unstableDisableFormats:!1}),v=b()("wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text",{"is-selected":n});return(0,d.createElement)("h1",{ref:(0,_.useMergeRefs)([y,r]),contentEditable:!0,className:v,"aria-label":(0,ee.__)("Enter email subject"),role:"textbox","aria-multiline":"true",onFocus:function(){a(!0),p()},onBlur:f,onKeyDown:function(e){e.keyCode===St.ENTER&&(e.preventDefault(),g(void 0,void 0,0))},onKeyPress:f,onPaste:function(e){const t=e.clipboardData;let n="",a="";try{n=t.getData("text/plain"),a=t.getData("text/html")}catch(e){try{a=t.getData("Text")}catch(e){return}}window.console.log("Received HTML:\n\n",a),window.console.log("Received plain text:\n\n",n);const r=(0,ne.pasteHandler)({HTML:a,plainText:n});if(e.preventDefault(),r.length)if("string"!=typeof r){const[e]=r;if(i||"core/heading"!==e.name&&"core/paragraph"!==e.name)h(r);else{const t=(0,vo.__unstableStripHTML)(e.attributes.content);s(t),h(r.slice(1))}}else{const e={...(0,yo.create)({html:i}),...c},t=(0,vo.__unstableStripHTML)(r),n=(0,yo.insert)(e,(0,yo.create)({html:t}));s((0,yo.toHTMLString)({value:n})),u({start:n.start,end:n.end})}}})})),ko=window.wp.htmlEntities,wo=[],Co={order:"asc",_fields:"id,name",context:"view"},So=(e,t)=>{const n=t?.id||e?.find((e=>e.name===t))?.id;if(n)return n;const a=t.toLocaleLowerCase();return e?.find((e=>e.name.toLocaleLowerCase()===a))?.id};function To({postType:e,attributes:t,setAttributes:n}){const{tax_query:a}=t,r=ft(e);return r&&0!==r.length?(0,d.createElement)(d.Fragment,null,r.map((e=>{const t=a?.[e.slug]||[];return(0,d.createElement)(Bo,{key:e.slug,taxonomy:e,termIds:t,onChange:t=>n({tax_query:{...a,[e.slug]:t}})})}))):null}function Bo({taxonomy:e,termIds:t,onChange:n}){const[a,r]=(0,S.useState)(""),[o,l]=(0,S.useState)(wo),[i,s]=(0,S.useState)(wo),c=(0,_.useDebounce)(r,250),{searchResults:u,searchHasResolved:p}=(0,P.useSelect)((n=>{if(!a)return{searchResults:wo,searchHasResolved:!0};const{getEntityRecords:r,hasFinishedResolution:o}=n(I.store),l=["taxonomy",e.slug,{...Co,search:a,orderby:"name",exclude:t,per_page:20}];return{searchResults:r(...l),searchHasResolved:o("getEntityRecords",l)}}),[a,t]),m=(0,P.useSelect)((n=>{if(!t?.length)return wo;const{getEntityRecords:a}=n(I.store);return a("taxonomy",e.slug,{...Co,include:t,per_page:t.length})}),[t]);return(0,S.useEffect)((()=>{if(t?.length||l(wo),!m?.length)return;const e=t.reduce(((e,t)=>{const n=m.find((e=>e.id===t));return n&&e.push({id:t,value:n.name}),e}),[]);l(e)}),[t,m]),(0,S.useEffect)((()=>{p&&s(u.map((e=>e.name)))}),[u,p]),(0,d.createElement)("div",{className:"block-library-query-inspector__taxonomy-control"},(0,d.createElement)(C.FormTokenField,{label:e.name,value:o,onInputChange:c,suggestions:i,displayTransform:ko.decodeEntities,onChange:e=>{const t=new Set;for(const n of e){const e=So(u,n);e&&t.add(e)}s(wo),n(Array.from(t))},__experimentalShowHowTo:!1}))}const Po={fontFamily:!1,fontSize:!0,fontAppearance:!1,lineHeight:!1,letterSpacing:!1,textTransform:!1,textDecoration:!1},Io=[{name:(0,ee.__)("Small"),slug:"small",size:13},{name:(0,ee.__)("Normal"),slug:"normal",size:16},{name:(0,ee.__)("Medium"),slug:"medium",size:20},{name:(0,ee.__)("Large"),slug:"large",size:36},{name:(0,ee.__)("Huge"),slug:"huge",size:42}];function Ao({attributes:e={style:{noptin:{typography:{}}}},setAttributes:t,settings:n,panelId:a,defaultControls:r=Po}){const[o,l,i]=it(e,t,"typography"),s=ae(n,"fontFamily"),c=o.fontFamily,u=e=>l({fontFamily:e}),p=ae(n,"fontSize"),m=o.fontSize,g=e=>l({fontSize:e}),_=ae(n,"fontStyle"),h=ae(n,"fontWeight"),b=_||h,f=o.fontStyle,y=o.fontWeight,v=({fontStyle:e,fontWeight:t})=>l({fontStyle:e,fontWeight:t}),E=ae(n,"lineHeight"),x=o.lineHeight,k=e=>l({lineHeight:e}),w=ae(n,"letterSpacing"),S=o.letterSpacing,T=e=>l({letterSpacing:e}),P=ae(n,"textTransform"),I=o.textTransform,A=e=>l({textTransform:e}),N=ae(n,"textDecoration"),M=o.textDecoration,L=e=>l({textDecoration:e});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Typography"),resetAll:i,panelId:a,className:"typography-block-support-panel"},s&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Font family"),hasValue:()=>!!c,onDeselect:()=>u(void 0),isShownByDefault:r.fontFamily,panelId:a},(0,d.createElement)(xt,{value:c||"",onChange:u})),p&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Font size"),hasValue:()=>!!m,onDeselect:()=>g(void 0),isShownByDefault:r.fontSize,panelId:a},(0,d.createElement)(C.FontSizePicker,{value:m,onChange:g,fontSizes:Io,disableCustomFontSizes:!1,withReset:!1,units:["px","em","rem"],withSlider:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0})),b&&(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"single-column",label:(0,ee.__)("Appearance"),hasValue:()=>!!f||!!y,onDeselect:()=>{v({fontStyle:void 0,fontWeight:void 0})},isShownByDefault:r.fontAppearance,panelId:a},(0,d.createElement)(B.__experimentalFontAppearanceControl,{value:{fontStyle:f,fontWeight:y},onChange:v,hasFontStyles:_,hasFontWeights:h,size:"__unstable-large",__nextHasNoMarginBottom:!0})),E&&(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"single-column",label:(0,ee.__)("Line height"),hasValue:()=>!!x,onDeselect:()=>k(void 0),isShownByDefault:r.lineHeight,panelId:a},(0,d.createElement)(B.LineHeightControl,{__nextHasNoMarginBottom:!0,__unstableInputWidth:"auto",value:x,onChange:k,size:"__unstable-large"})),w&&(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"single-column",label:(0,ee.__)("Letter spacing"),hasValue:()=>!!S,onDeselect:()=>T(void 0),isShownByDefault:r.letterSpacing,panelId:a},(0,d.createElement)(B.__experimentalLetterSpacingControl,{value:S,onChange:T,size:"__unstable-large",__unstableInputWidth:"auto"})),N&&(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"single-column",label:(0,ee.__)("Text decoration"),hasValue:()=>!!M,onDeselect:()=>L(void 0),isShownByDefault:r.textDecoration,panelId:a},(0,d.createElement)(B.__experimentalTextDecorationControl,{value:M,onChange:L,size:"__unstable-large",__unstableInputWidth:"auto"})),P&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Letter case"),hasValue:()=>!!I,onDeselect:()=>A(void 0),isShownByDefault:r.textTransform,panelId:a},(0,d.createElement)(B.__experimentalTextTransformControl,{value:I,onChange:A,showNone:!0,isBlock:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0}))))}const No=e=>{const[t]=it(e,null,"typography");return t};function Mo({attributes:e={style:{noptin:{border:{}}}},setAttributes:t=(e=>e),settings:n,panelId:a}){const[r,o,l]=it(e,t,"border"),i=yt();return(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Border"),resetAll:l,panelId:a,className:"border-block-support-panel"},ae(n,"border")&&(0,d.createElement)(C.__experimentalToolsPanelItem,{hasValue:()=>(0,C.__experimentalIsDefinedBorder)(r?.border),label:(0,ee.__)("Border"),onDeselect:()=>o({border:void 0}),isShownByDefault:!0,panelId:a},(0,d.createElement)(C.__experimentalBorderBoxControl,{colors:i,onChange:e=>o({border:e}),popoverOffset:40,popoverPlacement:"left-start",value:r?.border,__experimentalIsRenderedInSidebar:!0,size:"__unstable-large"})),ae(n,"radius")&&(0,d.createElement)(C.__experimentalToolsPanelItem,{hasValue:()=>{const e=r?.radius;return"object"==typeof e?Object.entries(e).some(Boolean):!!e},label:(0,ee.__)("Radius"),onDeselect:()=>o({radius:void 0}),isShownByDefault:!0,panelId:a},(0,d.createElement)(B.__experimentalBorderRadiusControl,{values:r?.radius,onChange:e=>o({radius:e})})))}const Lo=e=>{const[t]=it(e,null,"border");if(!t)return{};const n=(e,t)=>{if(!e)return{};const n={};return["style","width","color"].forEach((a=>{const r=e[a],o=`${t}${a.charAt(0).toUpperCase()+a.slice(1)}`;r&&(n[o]=r)})),n[`${t}Width`]&&!n[`${t}Style`]&&(n[`${t}Style`]="solid"),n},a=e?.style?.noptin?.border;return{...(0,C.__experimentalIsDefinedBorder)(a?.border)?(e=>{if(!(0,C.__experimentalHasSplitBorders)(e))return n(e,"border");let t={};return["top","right","bottom","left"].forEach((a=>{const r=e[a],o=`border${a.charAt(0).toUpperCase()+a.slice(1)}`;t={...t,...n(r,o)}})),t})(a?.border):{},...(r=t.radius,r&&"object"==typeof r?{borderRadius:["topLeft","topRight","bottomRight","bottomLeft"].reduce(((e,t)=>{const n=r[t];return n&&(e=`${e} ${n}`),e}),"")}:{borderRadius:r})};var r},Ro={},zo={},$o={placement:"left-start",offset:36,shift:!0},Do=({indicators:e,label:t})=>(0,d.createElement)(C.__experimentalHStack,{justify:"flex-start"},(0,d.createElement)(C.__experimentalZStack,{isLayered:!1,offset:-8},e.map(((e,t)=>(0,d.createElement)(C.Flex,{key:t,expanded:!1},(0,d.createElement)(C.ColorIndicator,{colorValue:e}))))),(0,d.createElement)(C.FlexItem,{className:"block-editor-panel-color-gradient-settings__color-name",title:t},t));function Vo({isGradient:e,inheritedValue:t,userValue:n,setValue:a,colorGradientControlSettings:r}){return(0,d.createElement)(B.__experimentalColorGradientControl,{...r,showTitle:!1,enableAlpha:!0,__experimentalIsRenderedInSidebar:!0,colorValue:e?void 0:t,gradientValue:e?t:void 0,onColorChange:e?void 0:a,onGradientChange:e?a:void 0,clearable:t===n,headingLevel:3})}function Fo({label:e,hasValue:t,resetValue:n,isShownByDefault:a,indicators:r,tabs:o,colorGradientControlSettings:l,panelId:i}){const s=o.map((({key:e,label:t})=>({name:e,title:t})));return(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"block-editor-tools-panel-color-gradient-settings__item",hasValue:t,label:e,onDeselect:n,isShownByDefault:a,panelId:i},(0,d.createElement)(C.Dropdown,{popoverProps:$o,className:"block-editor-tools-panel-color-gradient-settings__dropdown",renderToggle:({onToggle:t,isOpen:n})=>{const a={onClick:t,className:b()("block-editor-panel-color-gradient-settings__dropdown",{"is-open":n}),"aria-expanded":n,"aria-label":(0,ee.sprintf)(/* translators: %s is the type of color property, e.g., "background" */ -(0,ee.__)("Color %s styles"),e)};return(0,d.createElement)(C.Button,{...a},(0,d.createElement)(Do,{indicators:r,label:e}))},renderContent:()=>(0,d.createElement)(C.__experimentalDropdownContentWrapper,{paddingSize:"none"},(0,d.createElement)("div",{className:"block-editor-panel-color-gradient-settings__dropdown-content"},1===o.length&&(0,d.createElement)(Vo,{...o[0],colorGradientControlSettings:l}),o.length>1&&(0,d.createElement)(C.TabPanel,{tabs:s},(e=>{const t=o.find((t=>t.key===e.name));return t?(0,d.createElement)(Vo,{...t,colorGradientControlSettings:l}):null}))))}))}const Oo={text:!0,background:!0,link:!0,heading:!0,button:!0},Ho={text:{label:(0,ee.__)("Text"),prepare:(e,t)=>{t?.text&&(e.style.color=t.text)}},background:{label:(0,ee.__)("Background"),prepare:(e,t)=>{t?.background&&(e.style.backgroundColor=t.background)}},link:{label:(0,ee.__)("Link"),prepare:(e,t,n)=>{t?.link&&(e.css=`${e.css} ${n} a { color: ${t.link} }`)}},heading:{label:(0,ee.__)("Heading"),tabs:[{key:"heading",label:(0,ee.__)("Text")},{key:"headingBackground",label:(0,ee.__)("Background")}],prepare:(e,t,n)=>{t?.heading&&(e.css=`${e.css} ${n} h1,\n${n} h2,\n${n} h3,\n${n} h4,\n${n} h5,\n${n} h6 { color: ${t.heading} }`),t?.headingBackground&&(e.css=`${e.css} ${n} h1,\n${n} h2,\n${n} h3,\n${n} h4,\n${n} h5,\n${n} h6 { background-color: ${t.headingBackground} }`)}},button:{label:(0,ee.__)("Button"),tabs:[{key:"button",label:(0,ee.__)("Text")},{key:"buttonBackground",label:(0,ee.__)("Background")}],prepare:(e,t,n)=>{t?.button&&(e.css=`${e.css} ${n} .noptin-button-link,\n${n} .noptin-button-link__wrapper { color: ${t.button} }`),t?.buttonBackground&&(e.css=`${e.css} ${n} .noptin-button-link,\n${n} .noptin-button-link__wrapper { background-color: ${t.buttonBackground} }`)}}};function jo({settings:e,panelId:t,defaultControls:n=Oo,children:a=null,attributes:r,setAttributes:o}){const[l,i,s]=it(r,o,"color"),c=yt(),u=(0,xr.compact)(Object.keys(Ho).map((t=>{if(!ae(e,t))return!1;const a=Ho[t].tabs||[{key:t,label:Ho[t].label}];return{key:t,label:Ho[t].label,hasValue:()=>!!l[t],resetValue:()=>i({[t]:void 0}),isShownByDefault:n[t],indicators:[l?.[t]],tabs:a.map((({key:e,label:t})=>({key:e,label:t,setValue:t=>i({[e]:t}),userValue:l?.[e]})))}})));return(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Color"),resetAll:s,panelId:t,className:"color-block-support-panel"},(0,d.createElement)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0px, 1fr))",gap:"calc(16px) calc(8px)",gridColumn:"1 / -1",rowGap:0,borderTop:"1px solid #ddd"}},u.map((e=>(0,d.createElement)(Fo,{...e,colorGradientControlSettings:{colors:c,disableCustomColors:!1},panelId:t}))),a))}const Uo=e=>{const[t]=it(e,null,"color"),n={style:{},css:""};return t?(Object.values(Ho).forEach((a=>{a.prepare(n,t,`#noptin-email-content .${e.anchor}`)}),n),n):{style:{},css:""}},Go=["none","left","center","right"],Wo=e=>{const[t]=it(e,null,"align","none");return"none"===t?void 0:t};function Ko(e){if(!e)return;if(f.includes(e.name))return(0,ne.registerBlockType)({name:e.name,...e.metadata},e.settings);if(e.metadata.attributes=e.metadata.attributes||{},y.includes(e.name)||e.metadata.attributes?.anchor||(e.metadata.attributes.anchor={type:"string"}),e.metadata?.noptin&&!e.metadata.attributes?.style&&(e.metadata.attributes=e.metadata.attributes||{},e.metadata.attributes.style={type:"object",default:{}}),e.settings?.icon?.icon){let t={src:e.settings.icon.icon,foreground:e.settings.icon.fill||void 0};e.settings.icon=t}const{metadata:t,settings:n,name:a}=(({metadata:e,settings:t,...n})=>(e?.noptin?.color&&(t.edit=(0,_.createHigherOrderComponent)((t=>n=>{const[a,r]=Y(),o=n.attributes?.anchor,l=!y.includes(n.name);let i=o;(0,d.useEffect)((()=>{l&&((!o||Ro[o]&&Ro[o]!==n.clientId)&&(i=e.name.replace("/","-")+"-"+(1e5*Math.random()).toFixed(0)),Ro[i]=n.clientId,zo[n.clientId]=i)}),[]);const s=a[i]||"",c=(0,d.useMemo)((()=>y.includes(n.name)?"":Uo(n.attributes).css),[n.attributes,n.name]);return(0,d.useEffect)((()=>{if(!i||!l)return;const e=zo[n.clientId];s!==c?(r(i,c),e&&e!==o&&n.setAttributes({anchor:e})):o&&e&&e!==o&&n.setAttributes({anchor:e})}),[i,s,c,l]),(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,{group:"styles"},(0,d.createElement)(jo,{panelId:n.clientId,attributes:n.attributes,setAttributes:n.setAttributes,settings:e.noptin.color})),(0,d.createElement)(t,{...n}))}),"withNoptinColors")(t.edit)),{metadata:e,settings:t,...n}))((({metadata:e,settings:t,...n})=>(e?.noptin?.align&&(t.edit=(0,_.createHigherOrderComponent)((e=>t=>{const[n,a]=it(t.attributes,t.setAttributes,"align","none");return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(B.BlockAlignmentControl,{value:n,onChange:a,controls:Go})),(0,d.createElement)(e,{...t}))}),"withNoptinAlignmentSupport")(t.edit)),{metadata:e,settings:t,...n}))((({metadata:e,settings:t,...n})=>{if(e?.noptin?.typography){const n=t.edit;t.edit=t=>{const a=ae(e.noptin.typography,"textAlign"),[r,o]=it(t.attributes,t.setAttributes,"typography");return(0,d.createElement)(d.Fragment,null,a&&(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(B.AlignmentControl,{value:r.textAlign,onChange:e=>o({textAlign:e})})),(0,d.createElement)(B.InspectorControls,{group:"styles"},(0,d.createElement)(Ao,{panelId:t.clientId,attributes:t.attributes,setAttributes:t.setAttributes,settings:e.noptin.typography})),n(t))}}return{metadata:e,settings:t,...n}})((({metadata:e,settings:t,...n})=>{if(e?.noptin?.border){const n=t.edit;t.edit=t=>(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,{group:"styles"},(0,d.createElement)(Mo,{panelId:t.clientId,attributes:t.attributes,setAttributes:t.setAttributes,settings:e.noptin.border})),n(t))}return{metadata:e,settings:t,...n}})(e))));return(0,ne.registerBlockType)({name:a,...t},n)}const qo=e=>{const t={margin:{},padding:{}};return e?(Object.entries(e).forEach((([e,n])=>{e.startsWith("margin")?t.margin[e]=n:e.startsWith("padding")&&(t.padding[e]=n)})),t):t},Yo=(e,t=!1)=>{const n=(0,B.__experimentalGetSpacingClassesAndStyles)(e),a=n?.style||{};return t?qo(a):a};Yo.save=(e,t=!1)=>{const n=(0,B.__experimentalGetSpacingClassesAndStyles)(e),a=n?.style||{};return t?qo(a):a};const Zo=(0,d.memo)((function({blocks:e,isHidden:t,setActiveBlockContextId:n,style:a,className:r}){const o=(0,B.__experimentalUseBlockPreview)({blocks:e,props:{className:r}});return(0,d.createElement)("div",{...o,tabIndex:0,role:"button",onClick:n,onKeyPress:n,style:{...a,display:t?"none":void 0}})})),Qo=({name:e,template:t})=>{function n(e){const n=(0,B.useInnerBlocksProps)(e,{template:t,templateLock:!1});return(0,d.createElement)("div",{...n})}return({attributes:t,context:a,clientId:r})=>{const o=a[`noptin/${e}/isStackedOnMobile`],l=a[`noptin/${e}/columns`]||1,i=(e=>{if(1===e)return"100%";const t=1e12;return Math.round(100/e*t)/t+"%"})(l),s=a[`noptin/${e}/query`]?.number||10,c=Array(s).fill(0),u=Array.from({length:l},(()=>[]));c.forEach(((e,t)=>{u[t%l].push(t)}));const[p,m]=(0,d.useState)("0.0"),_={...No(t),...Lo(t),...Yo(t),...Uo(t).style},h=b()("noptin-records__wrapper",`noptin-${e}__wrapper`,{[`noptin-columns noptin-columns__${l}`]:l>1,"noptin-is-stacked-on-mobile":l>1&&o}),f=b()("noptin-records__column",`noptin-${e}__column`,{"noptin-column":l>1,"noptin-is-stacked-on-mobile":l>1&&o}),y=(0,P.useSelect)((e=>e(B.store).getBlocks(r)),[r]);return(0,d.createElement)("div",{...(0,B.useBlockProps)({className:h})},u.map(((e,t)=>(0,d.createElement)("div",{key:t,className:f,style:{width:i}},0===e.length&&(0,d.createElement)("span",null,"nbsp;"),e.map((e=>{const a=`${t}.${e}`;return(0,d.createElement)(g().Fragment,{key:a},a===p&&(0,d.createElement)(n,{style:_,className:"noptin-record"}),y.length>0&&(0,d.createElement)(Zo,{blocks:y,style:_,className:"noptin-record",setActiveBlockContextId:()=>m(a),isHidden:a===p}))}))))))}},Xo={},Jo=()=>{const e=G(),[t]=U("noptin_automation_rule");return(0,S.useMemo)((()=>e?.merge_tags?te(e.merge_tags,t?.saved||{}):[]),[e?.merge_tags,t?.saved])},el=()=>{const{getEditedPostAttribute:e,getSelectedBlockClientId:t}=(0,P.select)(T.store),{__experimentalGetActiveBlockIdByBlockNames:n,getBlockName:a}=(0,P.select)(B.store),r=e("noptin_automation_rule"),o=e("noptin_campaign_type");if(t()){const e=n(Object.keys(Xo));if(e){const t=Xo[a(e)];if(N.objects?.[t])return te(N.objects[t].merge_tags,r?.saved||{})}}return o?.merge_tags?te(o.merge_tags,r?.saved||{}):[]};function tl(e){const{batch:t}=(0,P.useRegistry)(),{moveBlocksToPosition:n,replaceInnerBlocks:a,duplicateBlocks:r,insertBlock:o}=(0,P.useDispatch)(B.store),{getBlockRootClientId:l,getBlockIndex:i,getBlockOrder:s,getBlockName:c,getBlock:u,getNextBlockClientId:p,canInsertBlockType:m}=(0,P.useSelect)(B.store),d=(0,S.useRef)(e);return d.current=e,(0,_.useRefEffect)((e=>{function g(e){if(e.defaultPrevented)return;if(e.keyCode!==St.ENTER)return;const{content:g,clientId:_}=d.current;if(g.length)return;const h=l(_);if(!(0,ne.hasBlockSupport)(c(h),"__experimentalOnEnter",!1))return;const b=s(h),f=b.indexOf(_);if(f===b.length-1){let t=h;for(;!m(c(_),l(t));)t=l(t);return void("string"==typeof t&&(e.preventDefault(),n([_],h,l(t),i(t)+1)))}const y=(0,ne.getDefaultBlockName)();if(!m(y,l(h)))return;e.preventDefault();const v=u(h);t((()=>{r([h]);const e=i(h);a(h,v.innerBlocks.slice(0,f)),a(p(h),v.innerBlocks.slice(f+1)),o((0,ne.createBlock)(y),e+1,l(h),!0)}))}return e.addEventListener("keydown",g),()=>{e.removeEventListener("keydown",g)}}),[])}(0,p.addFilter)("editor.Autocomplete.completers","noptin/edit-email/merge-tags-completer",(e=>{const t=e.filter((e=>"links"!==e.name));return t.push({name:"noptin-merge-tags",className:"block-editor-autocompleters__link",triggerPrefix:"[[",options:el,getOptionKeywords:({smart_tag:e,group:t,label:n,description:a})=>[...`${e} ${t} ${n} ${a}`.split(/\s+/)],getOptionLabel:({icon:e,label:t})=>(0,d.createElement)(d.Fragment,null,e&&(0,d.createElement)(C.Icon,{key:"icon",icon:e}),t),getOptionCompletion:({smart_tag:e,example:t})=>`[[${t||e}]]`}),t}));const nl={apiVersion:3,name:"core/paragraph",title:(0,ee.__)("Paragraph","newsletter-optin-box"),category:"content",description:(0,ee.__)("Start with the basic building block of all narrative.","newsletter-optin-box"),keywords:["text"],attributes:{content:{type:"string",source:"html",selector:"p",default:"",__experimentalRole:"content"},placeholder:{type:"string"}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0,link:!0}},supports:{anchor:!1,className:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0,padding:!1}},__experimentalSelector:"p",__unstablePasteTextInline:!0}},al={from:[{type:"raw",priority:20,selector:"p",schema:({phrasingContentSchema:e,isPaste:t})=>({p:{children:e,attributes:t?[]:["style","id"]}}),transform(e){const t=(0,ne.getBlockAttributes)("core/paragraph",e.outerHTML),{textAlign:n}=e.style||{};return"left"!==n&&"center"!==n&&"right"!==n||(t.style={...t.style||{},noptin:{...t.style?.noptin||{},typography:{...t.style?.noptin?.typography||{},textAlign:n}}}),(0,ne.createBlock)("core/paragraph",t)}}]},rl=al,{name:ol}=nl,ll={icon:"editor-paragraph",example:{attributes:{content:(0,ee.__)("In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.")}},__experimentalLabel(e,{context:t}){const n=e?.metadata?.name;if("list-view"===t&&n)return n;if("accessibility"===t){if(n)return n;const{content:t}=e;return t&&0!==t.length?t:(0,ee.__)("Empty")}},transforms:rl,merge:(e,t)=>({content:(e.content||"")+(t.content||"")}),edit:function({attributes:e,mergeBlocks:t,onReplace:n,onRemove:a,setAttributes:r,clientId:o}){const{content:l,placeholder:i}=e,s=(0,B.useBlockProps)({ref:tl({clientId:o,content:l}),style:{...No(e),...Lo(e),...Yo(e),...Uo(e).style}});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.RichText,{identifier:"content",tagName:"p",...s,value:l,onChange:e=>r({content:e}),onSplit:(t,n)=>{let a;(n||t)&&(a={...e,content:t});const r=(0,ne.createBlock)("core/paragraph",a);return n&&(r.clientId=o),r},onMerge:t,onReplace:n,onRemove:a,"aria-label":l?(0,ee.__)("Block: Paragraph"):(0,ee.__)("Empty block; start writing or type forward slash to choose a block"),"data-empty":!l,placeholder:i||(0,ee.__)("Start writing or type / to choose a block"),"data-custom-placeholder":!!i||void 0,__unstableAllowPrefixTransformations:!0}))},save:function({attributes:e}){const{content:t}=e,n=B.useBlockProps.save({style:{...No(e),...Lo(e),...Yo.save(e),...Uo(e).style}});return(0,d.createElement)("p",{...n},(0,d.createElement)(B.RichText.Content,{value:t}))}},il={apiVersion:3,name:"core/heading",title:(0,ee.__)("Heading","newsletter-optin-box"),category:"content",description:(0,ee.__)("Introduce new sections and organize content to help readers understand the structure of your content.","newsletter-optin-box"),keywords:["title","subtitle"],attributes:{content:{type:"string",source:"html",selector:"h1,h2,h3,h4,h5,h6",default:"",__experimentalRole:"content"},level:{type:"number",default:2},placeholder:{type:"string"}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0,link:!0}},supports:{anchor:!1,className:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0,padding:!1}},__unstablePasteTextInline:!0,__experimentalSlashInserter:!0}},sl={from:[{type:"block",isMultiBlock:!0,blocks:["core/paragraph"],transform:e=>e.map((({content:e,className:t,style:n})=>(0,ne.createBlock)("core/heading",{content:e,className:t,style:n})))},{type:"raw",selector:"h1,h2,h3,h4,h5,h6",schema:({phrasingContentSchema:e,isPaste:t})=>{const n={children:e,attributes:t?[]:["style","id"]};return{h1:n,h2:n,h3:n,h4:n,h5:n,h6:n}},transform(e){const t=(0,ne.getBlockAttributes)("core/heading",e.outerHTML),{textAlign:n}=e.style||{};var a;return t.level=(a=e.nodeName,Number(a.substr(1))),"left"!==n&&"center"!==n&&"right"!==n||(t.style={...t.style||{},noptin:{...t.style?.noptin||{},typography:{...t.style?.noptin?.typography||{},textAlign:n}}}),(0,ne.createBlock)("core/heading",t)}},...[1,2,3,4,5,6].map((e=>({type:"prefix",prefix:Array(e+1).join("#"),transform:t=>(0,ne.createBlock)("core/heading",{level:e,content:t})}))),...[1,2,3,4,5,6].map((e=>({type:"enter",regExp:new RegExp(`^/(h|H)${e}$`),transform:()=>(0,ne.createBlock)("core/heading",{level:e})})))],to:[{type:"block",isMultiBlock:!0,blocks:["core/paragraph"],transform:e=>e.map((({content:e,className:t,style:n})=>(0,ne.createBlock)("core/paragraph",{content:e,className:t,style:n})))}]},cl=sl,{name:ul}=il,pl={icon:"heading",example:{attributes:{content:(0,ee.__)("Code is Poetry"),level:2}},__experimentalLabel(e,{context:t}){const{content:n,level:a}=e,r=e?.metadata?.name;return"list-view"===t&&(r||n)?e?.metadata?.name||n:"accessibility"===t?n&&0!==n.length?(0,ee.sprintf)(/* translators: accessibility text. 1: heading level. 2: heading content. */ +`,pa=({value:e,onChange:t,...n})=>{const{baseControlProps:a,controlProps:r}=(0,C.useBaseControlProps)(n),o=e?e.split(":"):["07","00"],[l,i]=(0,d.useState)(o[0]),[s,c]=(0,d.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,d.useEffect)((()=>{e!==p&&t(p)}),[p]),(0,d.createElement)(C.BaseControl,{...a},(0,d.createElement)(C.__experimentalHStack,null,(0,d.createElement)(ua,null,(0,d.createElement)(sa,{value:u(l),onChange:i,min:0,max:23,step:1,...r,label:(0,ee.__)("Hours"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:aa(2)}),(0,d.createElement)(la,{"aria-hidden":"true"},":"),(0,d.createElement)(ca,{value:u(s),onChange:c,min:0,max:59,step:1,label:(0,ee.__)("Minutes"),spinControls:"none",isDragEnabled:!1,isShiftStepEnabled:!1,isPressEnterToChange:!0,hideLabelFromVision:!0,__next40pxDefaultSize:!0,__unstableStateReducer:aa(2)})),(0,d.createElement)(oa,null)))},ma=[{label:(0,ee.__)("Only run if","newsletter-optin-box"),value:"allow"},{label:(0,ee.__)("Do not run if","newsletter-optin-box"),value:"prevent"}],da=[{label:(0,ee.__)("all","newsletter-optin-box"),value:"all"},{label:(0,ee.__)("any","newsletter-optin-box"),value:"any"}];function ga(e,t){return(0,S.useMemo)((()=>[{label:t,value:"",disabled:!0},...e]),[e,t])}function _a({type:e,action:t,ruleCount:n,setConditionalLogicAttribute:a}){const r=n>1;return(0,d.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0},(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("If","newsletter-optin-box"),hideLabelFromVision:!0,value:t||"allow",options:ma,onChange:e=>a("action",e),size:"default",__nextHasNoMarginBottom:!0}),r&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("all","newsletter-optin-box"),hideLabelFromVision:!0,value:e||"all",options:da,onChange:e=>a("type",e),size:"default",__nextHasNoMarginBottom:!0}),(0,d.createElement)(C.__experimentalText,null,(0,ee.__)("of the following rules are true:","newsletter-optin-box"))))}function ha({rule:e,comparisons:t,availableSmartTags:n,index:a,updateRule:r,removeRule:o}){const l=(0,S.useCallback)((e=>r(a,"value",e)),[a,r]),i=(0,S.useCallback)((e=>r(a,"condition",e)),[a,r]),s=(0,S.useCallback)((()=>o(a)),[a,o]),c=(0,S.useMemo)((()=>{const t=e.type;if(void 0!==n[t])return n[t];const a=t.replace("_",".",1);if(void 0!==n[a])return n[a];for(const[e,a]of Object.entries(n)){if(-1!==e.indexOf(".")&&e.split(".").slice(1).join(".")===t)return a;const n=e=>Array.isArray(e)?e:e.split(/[\s,]+/);if(a.deprecated&&n(a.deprecated).includes(t))return a}return null}),[e.type,n]),u=(0,S.useMemo)((()=>{if(!c)return e.type;const t=c.group||"General",n=c.label||e.type;return"General"===t?n:`${n} (${t})`}),[e.type,n]),p=ga((m=c?.options,(0,S.useMemo)((()=>m?Array.isArray(m)?m.map(((e,t)=>({label:e,value:t}))):Object.keys(m).map((e=>({label:m[e],value:e}))):[]),[m])),(0,ee.__)("Select a value","newsletter-optin-box"));var m;const g=p.length>1,_=c?.conditional_logic||"string",h=ga((0,S.useMemo)((()=>{const e=[];return Object.keys(t).forEach((n=>{let a=t[n].type;if(g){if("string"===_&&"is"!=n&&"is_not"!=n)return;if("is_empty"===n||"is_not_empty"===n||"is_between"===n)return}"any"!==a&&a!=_||e.push({label:t[n].name,value:n})})),e}),[_,t]),(0,ee.__)("Select a comparison","newsletter-optin-box")),b="is_empty"===e.condition||"is_not_empty"===e.condition;return(0,d.createElement)(C.__experimentalHStack,{wrap:!0,expanded:!0},(0,d.createElement)(C.__experimentalText,{variant:"muted"},u),(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("Comparison","newsletter-optin-box"),hideLabelFromVision:!0,value:e.condition?e.condition:"is",options:h,onChange:i,size:"default",__nextHasNoMarginBottom:!0}),!b&&(0,d.createElement)(d.Fragment,null,g&&(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("Value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",options:p,onChange:l,size:"default",__nextHasNoMarginBottom:!0}),!g&&(0,d.createElement)(C.TextControl,{type:"number"===_?"number":"text",label:(0,ee.__)("Value","newsletter-optin-box"),hideLabelFromVision:!0,value:e.value?e.value:"",onChange:l,__nextHasNoMarginBottom:!0})),(0,d.createElement)(C.Button,{onClick:s,icon:"trash",variant:"tertiary",isDestructive:!0}))}function ba({rules:e,comparisons:t,availableSmartTags:n,setConditionalLogicAttribute:a,inModal:r,closeModal:o}){const l=(0,S.useMemo)((()=>Array.isArray(e)?e.filter((e=>e.type&&""!==e.type)):[]),[n]),i=(0,S.useMemo)((()=>{const e={};return n.forEach((t=>{t.conditional_logic&&(e[t.smart_tag]={...t,key:t.smart_tag,type:t.conditional_logic})})),e}),[n]),s=(0,S.useCallback)((e=>{const t=[...l];t.splice(e,1),a("rules",t)}),[l,a]),c=(0,S.useCallback)(((e,t,n)=>{const r=[...l];r[e][t]=n,a("rules",r)}),[l,a]),u=(0,S.useMemo)((()=>Object.values(i)),[i]),p=(0,S.useCallback)((e=>{const t=i[e],n=t?.options||[],r=t?.placeholder||"";let o=Array.isArray(n)&&n.length?Object.keys(n)[0]:r;t?.default&&(o=t.default);const s=[...l];s.push({type:e,condition:"is",value:o}),a("rules",s)}),[l]),m=0===l.length?(0,ee.__)("Add a conditional logic rule","newsletter-optin-box"):(0,ee.__)("Add another rule","newsletter-optin-box"),g=Ta({availableSmartTags:u,onMergeTagClick:p,raw:!0,icon:"plus",label:m,text:m,toggleProps:{variant:"primary"}});return(0,d.createElement)(C.__experimentalVStack,{className:"noptin-conditional-logic-rules"},l.map(((e,n)=>(0,d.createElement)(ha,{key:n,rule:e,index:n,updateRule:c,removeRule:s,comparisons:t,availableSmartTags:i}))),(0,d.createElement)(C.__experimentalHStack,{justify:"flex-start",wrap:!0},g,(0,d.createElement)(C.Button,{onClick:o,variant:"secondary"},(0,ee.__)("Return to editor","newsletter-optin-box"))))}function fa({onChange:e,value:t,comparisons:n,toggleText:a,availableSmartTags:r,className:o,inModal:l=!1}){const[i,s]=(0,S.useState)(!1);"object"!=typeof t&&(t={enabled:!1,action:"allow",rules:[{condition:"is",type:"date",value:""}],type:"all"});const c=(n,a)=>{e({...t,[n]:a})},u=(0,d.createElement)(C.__experimentalVStack,null,(0,d.createElement)(_a,{ruleCount:Array.isArray(t.rules)?t.rules.length:0,type:t.type,action:t.action,setConditionalLogicAttribute:c}),(0,d.createElement)(ba,{rules:t.rules,comparisons:n,availableSmartTags:r,setConditionalLogicAttribute:c,inModal:l,closeModal:()=>s(!1)}));return(0,d.createElement)(C.__experimentalVStack,{spacing:5,className:o},(0,d.createElement)(C.ToggleControl,{checked:!!t.enabled,onChange:e=>c("enabled",e),label:a||(0,ee.__)("Optionally enable/disable this trigger depending on specific conditions.","newsletter-optin-box"),__nextHasNoMarginBottom:!0}),t.enabled&&(0,d.createElement)(d.Fragment,null,l?(0,d.createElement)(d.Fragment,null,i&&(0,d.createElement)(C.Modal,{title:(0,ee.__)("Conditional Logic","newsletter-optin-box"),onRequestClose:()=>s(!1),size:"large"},u),(0,d.createElement)(C.Button,{variant:"secondary",className:"noptin-block-button",onClick:()=>s(!0)},(0,ee.__)("Edit Conditional Logic","newsletter-optin-box"))):(0,d.createElement)(d.Fragment,null,u)))}const ya={"==":(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),empty:e=>!e,"!empty":e=>e},va=(e,t,n)=>!!ya[t]&&ya[t](e,n),Ea=["number","search","email","password","tel","url","date"];function xa({setting:e,availableSmartTags:t,isPressEnterToChange:n,...a}){void 0===n&&(n=!0);const r=Ta({availableSmartTags:t,onMergeTagClick:(0,d.useCallback)((e=>{a.onChange&&a.onChange(a.value?`${a.value} ${e}`.trim():e)}),[a.value,a.onChange])});return"string"==typeof a.suffix||a.suffix instanceof String?a.suffix=(0,d.createElement)(C.__experimentalInputControlSuffixWrapper,null,a.suffix):a.suffix=r,e.disabled&&(a.readOnly=!0,a.onFocus=e=>e.target.select()),("string"==typeof a.prefix||a.prefix instanceof String)&&(a.prefix=(0,d.createElement)(C.__experimentalInputControlPrefixWrapper,null,a.prefix)),(0,d.createElement)(C.__experimentalInputControl,{...a,type:Ea.includes(e.type)?e.type:"text",placeholder:e.placeholder?e.placeholder:"",isPressEnterToChange:n,__next40pxDefaultSize:!0})}function ka({availableSmartTags:e,autoGrow:t=!1,label:n,id:a,...r}){const o=Ta({availableSmartTags:e,onMergeTagClick:(0,d.useCallback)((e=>{r.onChange&&r.onChange(r.value?`${r.value} ${e}`.trim():e)}),[r.value,r.onChange]),toggleProps:{size:"small"}}),l=(0,d.createElement)(C.__experimentalHStack,null,(0,d.createElement)("span",null,n),o),i=a||(0,_.useInstanceId)(ka,"noptin-textarea");return(0,d.useEffect)((()=>{if(t){const e=document.getElementById(i);e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}}),[r.value,t,i]),(0,d.createElement)(C.TextareaControl,{...r,id:i,label:l,__nextHasNoMarginBottom:!0})}function wa({options:e,...t}){const[n,a]=(0,d.useState)(e);return(0,d.createElement)(C.ComboboxControl,{...t,options:n,onFilterValueChange:t=>{a(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,d.createElement)("div",{...t,dangerouslySetInnerHTML:{__html:e.render}}):e.render:e.label,autocomplete:"off"})}function Ca({options:e,value:t,onChange:n,...a}){const r=Array.isArray(t)?t:[],o=(0,d.useMemo)((()=>e.map((e=>e.label))),[e]),l=(0,d.useCallback)((e=>o.includes(e)),[o]),i=(0,d.useMemo)((()=>r.map((t=>{const n=e.find((e=>e.value===t));return n?n.label:t}))),[t,e]),s=(0,d.useCallback)((t=>{const a=new Set;for(const n of t){const t=e.find((e=>e.label===n));t&&a.add(t.value)}n(Array.from(a))}),[n,e]),c=(0,d.useCallback)((t=>{const n=e.find((e=>e.label===t.item));return n&&n.render?(0,d.createElement)(S.RawHTML,null,n.render):(0,d.createElement)(d.Fragment,null,t.item)}),[e]);return(0,d.createElement)(C.FormTokenField,{value:i,suggestions:o,onChange:s,__experimentalShowHowTo:!1,__experimentalExpandOnFocus:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,__experimentalValidateInput:l,__experimentalRenderItem:c,...a})}const Sa=[{id:"key",label:(0,ee.__)("Key","noptin-addons-pack"),type:"text"},{id:"value",label:(0,ee.__)("Value","noptin-addons-pack"),type:"text"}];function Ta({availableSmartTags:e=[],onMergeTagClick:t=(e=>{}),raw:n=!1,icon:a="shortcode",label:r=(0,ee.__)("Insert merge tag","newsletter-optin-box"),...o}){const l=function(e){return(0,d.useMemo)((()=>{if(!Array.isArray(e))return{};const t={};return e.forEach((e=>{const n=e.group?e.group:(0,ee.__)("General","newsletter-optin-box");Array.isArray(t[n])||(t[n]=[]),t[n].push(e)})),t}),[e])}(e),i=Object.keys(l).length;let s=null;return i>0&&(s=(0,d.createElement)(C.DropdownMenu,{icon:a,label:r,...o},(({onClose:e})=>(0,d.createElement)(d.Fragment,null,Object.keys(l).map(((a,r)=>(0,d.createElement)(C.MenuGroup,{label:i>1?a:void 0,key:r},l[a].map((a=>(0,d.createElement)(C.MenuItem,{icon:a.icon||Ct,iconPosition:"left",onClick:()=>{if(t){const e=n?a.smart_tag:`[[${r=a,r.example?r.example:r.default?`${r.smart_tag} default="${r.default}"`:`${r.smart_tag}`}]]`;t(e)}var r;e()},key:a.smart_tag},(0,d.createElement)(S.RawHTML,null,a.label))))))))))),s}function Ba({value:e,onChange:t,...n}){const a="object"==typeof e?e:{},r=Array.isArray(a.items)&&a.items.length>1,o=(0,d.createElement)(d.Fragment,null,r&&(0,d.createElement)(C.__experimentalToggleGroupControl,{label:(0,ee.__)("Relation","noptin-addons-pack"),onChange:e=>{t({...a,relation:e})},__nextHasNoMarginBottom:!0},(0,d.createElement)(C.__experimentalToggleGroupControlOption,{value:"AND",label:"AND","aria-label":(0,ee.__)("All conditions must be met","noptin-addons-pack"),showTooltip:!0}),(0,d.createElement)(C.__experimentalToggleGroupControlOption,{value:"OR",label:"OR","aria-label":(0,ee.__)("At least one condition must be met","noptin-addons-pack"),showTooltip:!0})));return(0,d.createElement)(Pa,{...n,value:a.items,onChange:e=>{t({...a,items:e})},disabled:!!a.disabled,onDisable:e=>{t({...a,disabled:e})},prepend:o})}function Pa({availableSmartTags:e,value:t,onChange:n,button:a,fields:r,openModal:o,prepend:l,disable:i,disabled:s,onDisable:c,...u}){const[p,m]=(0,d.useState)(!1),g=Array.isArray(t)?t:[],{baseControlProps:_,controlProps:h}=(0,C.useBaseControlProps)(u),b={};if(!r)return console.warn("No fields provided to repeater control."),null;Object.keys(r).forEach((e=>{void 0!==r[e].default&&(b[e]=r[e].default)}));const f=!!o,y=(0,d.createElement)(C.__experimentalVStack,{...h},l,g.map(((t,a)=>(0,d.createElement)(C.Card,{key:a,variant:"secondary",size:"small",elevation:1},(0,d.createElement)(C.CardBody,null,(0,d.createElement)(Ia,{fields:r,value:t,availableSmartTags:e,onChange:e=>{const t=[...g];t[a]=e,n(t)},onDelete:()=>{const e=[...g];e.splice(a,1),n(e)}}))))),(0,d.createElement)(C.__experimentalHStack,null,(0,d.createElement)(C.Button,{onClick:()=>{const e=[...g];e.push(b),n(e)},variant:"primary"},a||(0,ee.__)("Add Item","newsletter-optin-box")),f&&(0,d.createElement)(C.Button,{onClick:()=>m(!1),variant:"secondary"},(0,ee.__)("Go Back","newsletter-optin-box")))),v=i&&s;return(0,d.createElement)(C.BaseControl,{..._},f&&(0,d.createElement)(d.Fragment,null,i&&(0,d.createElement)(C.ToggleControl,{label:i,checked:s,onChange:e=>{c&&c(e)}}),v&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.Button,{onClick:()=>m(!0),variant:"secondary"},o||(0,ee.__)("Set Items","newsletter-optin-box")),p&&(0,d.createElement)(C.Modal,{title:u.label||o||(0,ee.__)("Set Items","newsletter-optin-box"),onRequestClose:()=>m(!1),size:"medium"},y))),!f&&y)}function Ia({fields:e,availableSmartTags:t,value:n,onChange:a,onDelete:r}){return(0,d.createElement)(C.__experimentalVStack,null,Object.keys(e).map((r=>(0,d.createElement)(Da,{key:r,settingKey:r,availableSmartTags:t,setting:e[r],saved:n,setAttributes:e=>{a({...n,...e})}}))),(0,d.createElement)("div",null,(0,d.createElement)(C.Button,{variant:"link",onClick:r,text:(0,ee.__)("Remove Item","newsletter-optin-box"),isDestructive:!0})))}function Aa({setting:e,availableSmartTags:t,value:n,onChange:a,...r}){const{baseControlProps:o,controlProps:l}=(0,C.useBaseControlProps)(r);Array.isArray(n)||(n=[]);const i=(0,d.useCallback)((({item:e,index:r})=>(0,d.createElement)(C.Flex,{className:"noptin-repeater-item",wrap:!0},Sa.map(((o,l)=>(0,d.createElement)(Na,{key:l,availableSmartTags:t,field:o,value:void 0===e[o.id]?"":e[o.id],onChange:e=>{const t=[...n];t[r][o.id]=e,a(t)}}))),(0,d.createElement)(C.FlexItem,null,(0,d.createElement)(C.Button,{icon:"trash",variant:"tertiary",className:"noptin-component__field",label:(0,ee.__)("Delete","noptin-addons-pack"),showTooltip:!0,onClick:()=>{const e=[...n];e.splice(r,1),a(e)},isDestructive:!0})))),[n,a]);return(0,d.createElement)(C.BaseControl,{...o},(0,d.createElement)("div",{...l},n.map(((e,t)=>(0,d.createElement)(i,{key:t,item:e,index:t}))),(0,d.createElement)(C.Button,{onClick:()=>{const e=[...n];e.push({}),a(e)},variant:"secondary"},e.add_field?e.add_field:(0,ee.__)("Add","newsletter-optin-box"))))}function Na({field:e,availableSmartTags:t,value:n,onChange:a}){const r=Ta({availableSmartTags:t,onMergeTagClick:(0,d.useCallback)((e=>{a&&a(n?`${n} ${e}`.trim():e)}),[n,a])});return(0,d.createElement)(C.FlexBlock,null,(0,d.createElement)(C.__experimentalInputControl,{label:e.label,type:e.type,value:n,placeholder:(0,ee.sprintf)((0,ee.__)("Enter %s","noptin-addons-pack"),e.label),className:"noptin-component__field noptin-condition-field",suffix:r,onChange:a,isPressEnterToChange:!0,__next40pxDefaultSize:!0}))}function Ma({setting:e,value:t,options:n,onChange:a,...r}){const{baseControlProps:o,controlProps:l}=(0,C.useBaseControlProps)(r);return Array.isArray(t)||(t=[]),(0,d.createElement)(C.BaseControl,{...o},(0,d.createElement)("div",{...l},n.map(((e,n)=>(0,d.createElement)(C.CheckboxControl,{key:n,label:e.label,checked:t.includes(e.value),onChange:n=>{a(n?[...t,e.value]:t.filter((t=>t!==e.value)))}})))))}function La({value:e,onChange:t,...n}){const{baseControlProps:a,controlProps:r}=(0,C.useBaseControlProps)({...n,__nextHasNoMarginBottom:!0}),o=r.id,l=(0,d.useRef)(null),{wp:i}=window;return(0,d.useEffect)((()=>{if(!l.current)return;const t=window.tinymce?.get(o),n=t?.getContent();t&&n!==e&&t.setContent(e||"")}),[e]),(0,d.useEffect)((()=>{if(l.current)return i.oldEditor.initialize(o,{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:!0,setup:function(n){e&&n.on("loadContent",(()=>n.setContent(e))),n.on("blur",(()=>(t(n.getContent()),!1)));const a=(0,_.debounce)((()=>{const e=n.getContent();e!==n._lastChange&&(n._lastChange=e,t(e))}),250);n.on("Paste Change input Undo Redo",a),n.on("remove",a.cancel),n.on("keydown",(e=>{St.isKeyboardEvent.primary(e,"z")&&e.stopPropagation();const{altKey:t}=e;t&&e.keyCode===St.F10&&e.stopPropagation()}))}},mediaButtons:!0,quicktags:!0}),()=>{i.oldEditor.remove(o)}}),[l.current]),(0,d.createElement)(C.BaseControl,{...a},(0,d.createElement)("textarea",{...r,className:"wp-editor-area",value:e||"",onChange:e=>t(e.target.value),name:o,rows:10,style:{width:"100%"},ref:l}))}const Ra=(e,t)=>{if(0===t.length||!e||"object"!=typeof e)return;const[n,...a]=t;return 0===a.length?e[n]:Ra(e[n],a)},za=(e,t,n)=>{if(0===t.length)return e;const[a,...r]=t;return 0===r.length?{...e,[a]:n}:{...e,[a]:za(e[a]||{},r,n)}};function Da({settingKey:e,setting:t,availableSmartTags:n,prop:a,saved:r,setAttributes:o}){const l=(a?`${a}.${e}`:e).split("."),i=t.sanitize?t.sanitize:e=>e,s=e=>{const[t,...n]=l;return 0===n.length?o(i({[t]:e})):o(i({[t]:za(r[t]||{},n,e)}))};if(t.if||t.restrict){const e=t.restrict?t.restrict.split("."):t.if.split(".");if(!Ra(r,e))return null}if(Array.isArray(t.conditions)&&!t.conditions.every((e=>{const t=e.key.split("."),n=e.operator?e.operator:"==";return va(e.value,n,Ra(r,t))})))return null;if(t.condition&&!t.condition(r))return null;let c=Ra(r,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}`,g="string"==typeof t.description?(0,d.createElement)("span",{dangerouslySetInnerHTML:{__html:t.description}}):t.description,_=t.customAttributes?t.customAttributes:{},h={label:t.label,value:u?c:"",onChange:s,className:m,help:g,..._};if(t.type&&!t.el&&(t.el=t.type,["toggle","switch","checkbox","checkbox_alt","text","number","email","tel","date","color"].includes(t.type)&&(t.el="input")),"select"===t.el)return t.multiple?(0,d.createElement)(Ca,{...h,options:p}):(p.find((e=>""===e?.value))||p.unshift({label:t.placeholder?t.placeholder:(0,ee.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,d.createElement)(C.SelectControl,{...h,options:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}));if("combobox"===t.el)return p.unshift({label:t.placeholder?t.placeholder:(0,ee.__)("Select an option","newsletter-optin-box"),value:"",disabled:!t.canSelectPlaceholder}),(0,d.createElement)(wa,{...h,options:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0});if("form_token"===t.el||"token"===t.el)return(0,d.createElement)(C.FormTokenField,{...h,value:Array.isArray(h.value)?h.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,d.createElement)(Ma,{...h,options:p});if("conditional_logic"===t.el)return(0,d.createElement)(fa,{...h,availableSmartTags:n,comparisons:t.comparisons,toggleText:t.toggle_text,inModal:t.in_modal});if("time"===t.el)return(0,d.createElement)(pa,{...h});if("input"===t.el){if(t.type&&["toggle","switch","checkbox","checkbox_alt"].includes(t.type))return(0,d.createElement)(C.ToggleControl,{...h,checked:!!u&&c,onChange:e=>{s(e)}});if(t.type&&["number"].includes(t.type)){const e=e=>{if(e)return"string"==typeof e||e instanceof String?(0,d.createElement)(C.__experimentalInputControlSuffixWrapper,null,e):e},t=e=>{if(e)return"string"==typeof e||e instanceof String?(0,d.createElement)(C.__experimentalInputControlPrefixWrapper,null,e):e};return Array.isArray(h.suffix)?h.suffix=e(1===c||"1"===c?h.suffix[0]:h.suffix[1]):h.suffix=e(h.suffix),Array.isArray(h.prefix)?h.prefix=t(1===c||"1"===c?h.prefix[0]:h.prefix[1]):h.prefix=t(h.prefix),(0,d.createElement)(C.__experimentalNumberControl,{...h,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}return(0,d.createElement)(xa,{...h,setting:t,availableSmartTags:"trigger_settings"===a?[]:n,isPressEnterToChange:!t.isInputToChange})}return"textarea"===t.el?(0,d.createElement)(ka,{...h,placeholder:t.placeholder?t.placeholder:"",availableSmartTags:"trigger_settings"===a?[]:n}):"tinymce"===t.el?(0,d.createElement)(La,{...h}):"paragraph"===t.el?(0,d.createElement)("div",{className:m},(0,d.createElement)(C.Tip,null,t.content)):"hero"===t.el?(0,d.createElement)("div",{className:m},(0,d.createElement)("h3",null,t.content)):"key_value_repeater"===t.el||"webhook_key_value_repeater"===t.el?(0,d.createElement)(Aa,{...h,setting:t,availableSmartTags:"trigger_settings"===a?[]:n}):"repeater"===t.el?(0,d.createElement)(Pa,{...h,availableSmartTags:"trigger_settings"===a?[]:n}):"query_repeater"===t.el?(0,d.createElement)(Ba,{...h,availableSmartTags:"trigger_settings"===a?[]:n}):e}const $a=({...e})=>{const t=Zo();return e.disableMergeTags||(e.availableSmartTags=t),"image_size_select"===e.setting?.el&&(e.setting.el="select",Array.isArray(N.settings?.imageSizes)&&(e.setting.options=N.settings.imageSizes.map((({name:e,slug:t})=>({label:e,value:t}))))),(0,d.createElement)(Da,{...e})},Va=e=>{const[t]=U("meta"),{editPost:n}=(0,P.useDispatch)("core/editor");return(0,d.createElement)($a,{...e,saved:t?.campaign_data||{},setAttributes:e=>{const t=(0,P.select)("core/editor").getEditedPostAttribute("meta"),a={...t,campaign_data:{...t?.campaign_data,...e}};n({meta:a})}})},Fa=function({type:e,help:t,...n}){return(0,d.createElement)(C.Flex,{align:"top",justify:"center"},(0,d.createElement)(C.__experimentalVStack,{as:C.FlexBlock,spacing:8,style:{maxWidth:620,margin:32}},(0,d.createElement)(Va,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,ee.__)("Email Subject","newsletter-optin-box"),description:(0,ee.__)("Required. The subject of your email.","newsletter-optin-box")}}),(0,d.createElement)(Va,{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,d.createElement)(wt,null)))},Ha=window.wp.keyboardShortcuts;function Oa(){const{replaceBlocks:e}=(0,P.useDispatch)(B.store),{getBlockName:t,getSelectedBlockClientId:n,getBlockAttributes:a}=(0,P.useSelect)(B.store),r=(r,o)=>{r.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=a(i);e(i,(0,ne.createBlock)(l,{level:o,...c}))};return(0,Ha.useShortcut)("core/edit-email/transform-heading-to-paragraph",(e=>r(e,0))),[1,2,3,4,5,6].forEach((e=>{(0,Ha.useShortcut)(`core/edit-email/transform-paragraph-to-heading-${e}`,(t=>r(t,e)))})),null}Oa.Register=function(){const{registerShortcut:e}=(0,P.useDispatch)(Ha.store);return(0,S.useEffect)((()=>{e({name:"core/edit-email/keyboard-shortcuts",category:"main",description:(0,ee.__)("Display these keyboard shortcuts."),keyCombination:{modifier:"access",character:"h"}}),e({name:"core/edit-email/next-region",category:"global",description:(0,ee.__)("Navigate to the next part of the editor."),keyCombination:{modifier:"ctrl",character:"`"},aliases:[{modifier:"access",character:"n"}]}),e({name:"core/edit-email/previous-region",category:"global",description:(0,ee.__)("Navigate to the previous part of the editor."),keyCombination:{modifier:"ctrlShift",character:"`"},aliases:[{modifier:"access",character:"p"},{modifier:"ctrlShift",character:"~"}]}),e({name:"core/edit-email/transform-heading-to-paragraph",category:"block-library",description:(0,ee.__)("Transform heading to paragraph."),keyCombination:{modifier:"access",character:"0"}}),[1,2,3,4,5,6].forEach((t=>{e({name:`core/edit-email/transform-paragraph-to-heading-${t}`,category:"block-library",description:(0,ee.__)("Transform paragraph to heading."),keyCombination:{modifier:"access",character:`${t}`}})}))}),[e]),null};const ja=Oa,Ua=window.wp.notices;function Ga({text:e,children:t}){const{createInfoNotice:n}=(0,P.useDispatch)(Ua.store),a=(0,_.useCopyToClipboard)(e,(()=>{n((0,ee.__)("Error copied to clipboard."),{type:"snackbar"})}));return(0,d.createElement)(C.Button,{variant:"secondary",ref:a},t)}function Wa({message:e,error:t}){const n=[(0,d.createElement)(Ga,{key:"copy-error",text:t.stack},(0,ee.__)("Copy Error"))];return(0,d.createElement)(B.Warning,{className:"edit-post-error-boundary",actions:n},e)}class Ka extends S.Component{constructor(){super(...arguments),this.state={error:null}}componentDidCatch(e){(0,p.doAction)("editor.ErrorBoundary.errorLogged",e)}static getDerivedStateFromError(e){return{error:e}}render(){return this.state.error?(0,d.createElement)(Wa,{message:this.props.error||(0,ee.__)("The editor has encountered an unexpected error."),error:this.state.error}):this.props.children}}const qa=({children:e})=>{const t=lt(),[n,a]=pt({heading:(0,ee.__)("Block Editor","newsletter-optin-box"),helpText:(0,ee.__)("A premium plan allows you to edit your emails using a drag and drop block editor.","newsletter-optin-box"),needsAddonsPack:!1,slug:"block-editor"}),r=b()("content",{"is-premium-feature":!n});return(0,d.createElement)(d.Fragment,null,N.styles&&Object.keys(N.styles).map((e=>(0,d.createElement)("link",{key:e,rel:"stylesheet",id:`${e}-css`,href:N.styles[e]}))),(0,d.createElement)("style",{dangerouslySetInnerHTML:{__html:t}}),(0,d.createElement)("div",{className:r,id:"noptin-email-content"},n?e:a))},Ya=function(){const e=(0,P.useSelect)((e=>e(at).getPreviewDeviceType()),[]),t=(0,B.__experimentalUseResizeCanvas)(e),n=(0,B.__unstableUseTypingObserver)(),a={marginLeft:10,marginRight:10};return(0,_.useViewportMatch)("medium","<")&&(a.marginTop=48),(0,d.createElement)(d.Fragment,null,(0,d.createElement)(ja,null),(0,d.createElement)(B.BlockTools,{style:t,className:`edit-post-visual-editor__editor-canvas is-${e.toLowerCase()}-preview`},(0,d.createElement)(B.BlockCanvas,{height:"100%"},(0,d.createElement)(qa,null,(0,d.createElement)("div",{className:"editor-editor-canvas__post-title-wrapper",contentEditable:!1,ref:n,style:a},(0,d.createElement)(yo,null)),(0,d.createElement)(Ka,null,(0,d.createElement)(B.BlockList,{className:"edit-post-editor-canvas__block-list"}))))))};function Za(){return(0,d.createElement)(C.Flex,{align:"top",justify:"center"},(0,d.createElement)(C.FlexBlock,{style:{maxWidth:620,margin:32}},(0,d.createElement)(C.__experimentalVStack,{spacing:8},(0,d.createElement)(Va,{settingKey:"subject",setting:{el:"input",type:"text",label:(0,ee.__)("Email Subject","newsletter-optin-box"),description:(0,ee.__)("Required. The subject of your email.","newsletter-optin-box")}}),(0,d.createElement)(Va,{settingKey:"heading",setting:{el:"input",type:"text",label:(0,ee.__)("Email Heading","newsletter-optin-box"),description:(0,ee.__)("This text will be displayed at the top of the email.","newsletter-optin-box")}}),(0,d.createElement)(Ka,null,(0,d.createElement)(Va,{settingKey:"content_normal",setting:{el:"tinymce",label:(0,ee.__)("Email Content","newsletter-optin-box"),description:(0,ee.__)("The content of your email. You can use email tags to provide dynamic values.","newsletter-optin-box")}})),(0,d.createElement)(Va,{settingKey:"footer_text",setting:{el:"textarea",label:(0,ee.__)("Footer Text","newsletter-optin-box"),description:(0,ee.__)("This text will be displayed at the bottom of the email.","newsletter-optin-box")}}),(0,d.createElement)(wt,null))))}function Qa({mode:e}){return(0,d.createElement)(d.Fragment,null,"visual"===e&&(0,d.createElement)(Ya,null),"normal"===e&&(0,d.createElement)(Za,null),"plain_text"===e&&(0,d.createElement)(Fa,{type:"plain_text",label:(0,ee.__)("Email Content","newsletter-optin-box"),placeholder:(0,ee.__)("Type your email content here","newsletter-optin-box"),help:(0,ee.__)("You can use email tags to provide dynamic values.","newsletter-optin-box")}),"raw_html"===e&&(0,d.createElement)(Fa,{type:"raw_html",label:(0,ee.__)("Email Content","newsletter-optin-box"),placeholder:(0,ee.__)("Paste the raw HTML of your email here","newsletter-optin-box"),help:(0,ee.__)("You can use email tags to provide dynamic values.","newsletter-optin-box")}))}function Xa(){const{emailType:e}=X();return(0,d.createElement)(Ka,null,(0,d.createElement)(Qa,{mode:e}))}const Ja=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),er=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"})),tr=e=>{e.preventDefault()},nr=(0,S.forwardRef)((function(e,t){const n=(0,St.isAppleOS)()?St.displayShortcut.primaryShift("`"):St.displayShortcut.primary("`"),a=(0,P.useSelect)((e=>e(at).isInserterOpened()),[]),{setIsInserterOpened:r}=(0,P.useDispatch)(at);return(0,d.createElement)(C.Button,{...e,ref:t,className:"edit-post-header-toolbar__inserter-toggle",variant:"primary",isPressed:a,"aria-expanded":a,onMouseDown:tr,onClick:()=>r(!a),icon:er +/* translators: button label text should, if possible, be under 16 characters. */,label:(0,ee.__)("Toggle block inserter"),shortcut:n,showTooltip:!0})})),ar=function({contentType:e,hideActions:t}){const n=(0,ee.sprintf)(/* translators: %s: content type label. */ +(0,ee.__)("%s Email"),R[e]?.label||"");return(0,d.createElement)(B.NavigableToolbar,{className:"edit-post-header-toolbar","aria-label":(0,ee.__)("Email tools"),shouldUseKeyboardFocusShortcut:!0,variant:"unstyled"},(0,d.createElement)("div",{className:"edit-post-header-toolbar__left"},t?" ":(0,d.createElement)(d.Fragment,null,"visual"===e&&(0,d.createElement)(kt,{breakpoint:"large"},(0,d.createElement)(C.ToolbarItem,{as:nr})),(0,d.createElement)(C.ToolbarItem,{as:T.EditorHistoryUndo,size:"compact"}),(0,d.createElement)(C.ToolbarItem,{as:T.EditorHistoryRedo,size:"compact"}),"visual"!==e&&(0,d.createElement)(C.__experimentalText,{className:"edit-post-header-toolbar__title",as:"span",size:14,weight:500,numberOfLines:1,truncate:!0,upperCase:!0},n))))},rr=function(){const[e,t]=U("meta");return(0,d.createElement)(C.MenuGroup,{label:(0,ee.__)("Editor")},(0,d.createElement)(C.MenuItemsChoice,{choices:z,value:e?.campaign_data?.email_type,onSelect:n=>{t({...e,campaign_data:Q({...e?.campaign_data||{},email_type:n})})}}))},{Fill:or,Slot:lr}=(0,C.createSlotFill)("ToolsMoreMenuGroup");or.Slot=({fillProps:e})=>(0,d.createElement)(lr,{fillProps:e},(e=>e.length>0&&(0,d.createElement)(C.MenuGroup,{label:(0,ee.__)("Tools")},e)));const ir=or,sr=function(){return(0,d.createElement)(C.MenuGroup,{label:(0,ee._x)("View","noun")},(0,d.createElement)(re.PreferenceToggleMenuItem,{scope:at.name,name:"fullscreenMode",label:(0,ee.__)("Fullscreen mode"),info:(0,ee.__)("Show and hide admin UI"),messageActivated:(0,ee.__)("Fullscreen mode activated"),messageDeactivated:(0,ee.__)("Fullscreen mode deactivated")}))},cr=()=>(0,d.createElement)(_e,{toggleProps:{showTooltip:!0}},(({onClose:e})=>(0,d.createElement)(d.Fragment,null,(0,d.createElement)(kt,{breakpoint:"large",operator:"<"},(0,d.createElement)(me.Slot,{scope:A})),(0,d.createElement)(kt,{breakpoint:"medium"},(0,d.createElement)(sr,null)),(0,d.createElement)(rr,null),(0,d.createElement)(fe.Slot,{name:`${A}/plugin-more-menu`,label:(0,ee.__)("Plugins"),as:C.MenuGroup,fillProps:{onClick:e}}),(0,d.createElement)(ir.Slot,{fillProps:{onClose:e}})))),ur=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),pr=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),mr=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),dr=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),gr=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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 _r({isVisual:e}){const t=(0,P.useSelect)((e=>e(at).getPreviewDeviceType()),[]),{setPreviewDeviceType:n}=(0,P.useDispatch)(at),a={"aria-label":(0,ee.__)("View options")},r={mobile:ur,tablet:pr,desktop:mr};return(0,d.createElement)(C.DropdownMenu,{className:"editor-preview-dropdown",popoverProps:{placement:"bottom-end"},toggleProps:{className:"editor-preview-dropdown__toggle",size:"compact",showTooltip:!0},menuProps:a,icon:r[t.toLowerCase()],label:(0,ee.__)("View")},(({onClose:a})=>(0,d.createElement)(d.Fragment,null,e&&(0,d.createElement)(C.MenuGroup,null,(0,d.createElement)(C.MenuItem,{onClick:()=>n("Desktop"),icon:"Desktop"===t&&dr},(0,ee.__)("Desktop")),(0,d.createElement)(C.MenuItem,{onClick:()=>n("Tablet"),icon:"Tablet"===t&&dr},(0,ee.__)("Tablet")),(0,d.createElement)(C.MenuItem,{onClick:()=>n("Mobile"),icon:"Mobile"===t&&dr},(0,ee.__)("Mobile"))),(0,d.createElement)(C.MenuGroup,null,(0,d.createElement)(T.PostPreviewButton,{className:"editor-preview-dropdown__button-external",role:"menuitem",textContent:(0,d.createElement)(d.Fragment,null,(0,ee.__)("Preview in new tab"),(0,d.createElement)(C.Icon,{icon:gr})),onPreview:a})))))}const hr={hidden:{y:"-50px"},distractionFreeInactive:{y:0},hover:{y:0,transition:{type:"tween",delay:.2}}},br=function({hideActions:e}){const{emailType:t}=X(),n="visual"===t;return(0,d.createElement)("div",{className:"edit-post-header"},(0,d.createElement)(C.Button,{className:"edit-post-fullscreen-mode-close",icon:Ja,href:N.back,label:(0,ee.__)("Back"),showTooltip:!0}),(0,d.createElement)(C.__unstableMotion.div,{variants:hr,transition:{type:"tween",delay:.8},className:"edit-post-header__toolbar"},(0,d.createElement)(ar,{hideActions:e,contentType:t})),(0,d.createElement)(C.__unstableMotion.div,{variants:hr,transition:{type:"tween",delay:.8},className:"edit-post-header__settings"},(0,d.createElement)(kt,{breakpoint:"medium",operator:"<"},(0,d.createElement)(T.PostPreviewButton,{className:"edit-post-header__post-preview-button"})),(0,d.createElement)(T.PostSavedState,null),(0,d.createElement)(T.PostPublishButton,null),(0,d.createElement)(kt,{breakpoint:"large"},(0,d.createElement)(_r,{isVisual:n}),(0,d.createElement)(me.Slot,{scope:A})),(0,d.createElement)(cr,null)))};function fr(){return(0,d.createElement)("div",{className:"edit-post-layout__footer"},(0,d.createElement)(B.BlockBreadcrumb,{rootLabelText:(0,ee.__)("Email")}))}const yr=window.lodash,vr=(0,d.createElement)(de.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),Er=(0,d.createElement)(de.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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"})),xr=()=>{const[e,t]=U("title"),n=G(),{emailType:a}=X();return(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Email Settings","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,{spacing:4},(0,d.createElement)(Va,{settingKey:"email_type",setting:{el:"select",label:(0,ee.__)("Editor","newsletter-optin-box"),options:z,description:R[a]?.description||(0,ee.__)("Choose the type of email you want to create.","newsletter-optin-box"),sanitize:Q}}),"normal"===a&&(0,d.createElement)(Va,{settingKey:"template",setting:{el:"select",label:(0,ee.__)("Template","newsletter-optin-box"),options:D,description:(0,ee.__)("Choose the template you want to use.","newsletter-optin-box"),sanitize:Q}}),(0,d.createElement)(C.TextControl,{value:e||"",onChange:t,label:(0,ee.__)("Campaign Name","newsletter-optin-box"),help:(0,ee.__)("For your reference only.","newsletter-optin-box"),placeholder:(0,ee.__)("Example: Black Friday Sale","newsletter-optin-box")}),("visual"===a||"normal"===a)&&(0,d.createElement)(Va,{settingKey:"preview_text",setting:{el:"input",type:"text",label:(0,ee.__)("Preview Text","newsletter-optin-box"),description:(0,ee.__)("This is the text that appears in the inbox when the email is received.","newsletter-optin-box"),placeholder:(0,ee.__)("Example: Save up to 50%","newsletter-optin-box")}}),n?.extra_settings&&(0,d.createElement)(d.Fragment,null,Object.keys(n.extra_settings).map((e=>(0,d.createElement)(Va,{key:e,settingKey:e,setting:n.extra_settings[e]})))),(0,d.createElement)(C.Slot,{name:`${A}/editor-settings__main`})))},kr={color:(0,ee.__)("Text"),link_color:(0,ee.__)("Link"),background_color:(0,ee.__)("Background"),content_background:(0,ee.__)("Content Background"),footer_text_color:(0,ee.__)("Footer text color")},wr=()=>{const e=yt(),[t,n]=U("meta"),{templateSupports:a}=X(),r=(0,S.useMemo)((()=>(0,yr.compact)(Object.entries(kr).map((([e,r])=>a(e)?{value:t?.campaign_data?.[e]||"",onChange:a=>n({...t||{},campaign_data:{...t?.campaign_data||{},[e]:a}}),label:r}:null)))),[a,t,n]);return(0,d.createElement)(d.Fragment,null,r.length>0&&(0,d.createElement)(B.PanelColorSettings,{__experimentalIsRenderedInSidebar:!0,enableAlpha:!1,showTitle:!0,disableCustomColors:!1,colors:e,title:(0,ee.__)("Colors"),colorSettings:r}))},Cr=[{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"}],Sr=()=>{const[e,t]=U("meta"),[n,a]=J("width",e,t),{templateSupports:r}=X();return r("custom_css")||r("width")?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Design","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,{spacing:4},r("width")&&(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Width","newsletter-optin-box"),value:n||"600px",onChange:a,min:100,max:1e3,units:Cr,help:(0,ee.__)("The width of your email's content area.","newsletter-optin-box")}),r("custom_css")&&(0,d.createElement)(Va,{settingKey:"custom_css",setting:{el:"textarea",label:(0,ee.__)("Custom CSS","newsletter-optin-box"),description:(0,ee.__)("Add custom CSS to your email. You can also use this field to import custom fonts.","newsletter-optin-box")}}),(0,d.createElement)(C.Slot,{name:`${A}/editor-settings__design`}))):null},Tr=()=>{const[e,t]=U("meta"),[n,a]=J("font_family",e,t),[r,o]=J("font_size",e,t),[l,i]=J("font_style",e,t),[s,c]=J("font_weight",e,t),[u,p]=J("line_height",e,t),{templateSupports:m}=X(),g=["font_family","font_size","font_style","font_weight","line_height"].some((e=>m(e))),_=(0,d.useCallback)((({fontStyle:e,fontWeight:t})=>{i(e),c(t)}),[c,i]),h={fontStyle:l,fontWeight:s};return g?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Typography","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,{spacing:4},m("font_family")&&(0,d.createElement)(xt,{value:n||"",onChange:a}),m("font_size")&&(0,d.createElement)(B.FontSizePicker,{__nextHasNoMarginBottom:!0,value:r||14,fallbackFontSize:14,onChange:o,label:(0,ee.__)("Font size","newsletter-optin-box"),disableCustomFontSizes:!1}),(m("font_style")||m("font_weight"))&&(0,d.createElement)(B.__experimentalFontAppearanceControl,{__nextHasNoMarginBottom:!0,hasFontStyles:m("font_style"),hasFontWeights:m("font_weight"),value:h,onChange:_}),m("line_height")&&(0,d.createElement)(B.LineHeightControl,{__nextHasNoMarginBottom:!0,value:u||"1.7",onChange:p,label:(0,ee.__)("Line height","newsletter-optin-box"),__unstableInputWidth:"100%"}),(0,d.createElement)(C.Slot,{name:`${A}/editor-settings__typography`}))):null},Br=()=>{const[e,t]=pt({heading:(0,ee.__)("Attach Files","newsletter-optin-box"),helpText:(0,ee.__)("The add-ons pack allows you to attach images, videos, PDFs or other file types to this email.","newsletter-optin-box"),needsAddonsPack:!0,slug:"attachments"}),[n,a]=U("meta"),[r,o]=J("attachments",n,a),l=r||[],i=(0,S.useCallback)((()=>{o([...l,""])}),[l,o]),s=(0,S.useCallback)((e=>{o(l.filter(((t,n)=>n!==e)))}),[l,o]),c=(0,S.useCallback)(((e,t)=>{o(l.map(((n,a)=>a===e?t:n)))}),[l,o]);return(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Email Attachments","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,null,!e&&t,e&&(0,d.createElement)(d.Fragment,null,l.map(((e,t)=>(0,d.createElement)(C.__experimentalInputControl,{label:(0,ee.__)("Enter file path or URL","newsletter-optin-box"),value:e,onChange:e=>c(t,e),isPressEnterToChange:!0,hideLabelFromVision:!0,placeholder:(0,ee.__)("Enter file path or URL","newsletter-optin-box"),key:t,prefix:(0,d.createElement)(d.Fragment,null,(0,d.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,d.createElement)(C.Button,{variant:"tertiary",onClick:e,icon:"upload",label:(0,ee.__)("Upload","newsletter-optin-box"),showTooltip:!0})})),suffix:(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.Button,{isDestructive:!0,variant:"tertiary",onClick:()=>s(t),icon:"trash",label:(0,ee.__)("Remove","newsletter-optin-box"),showTooltip:!0}))}))),(0,d.createElement)(C.Button,{variant:"primary",onClick:i,style:{justifyContent:"center"}},(0,ee.__)("Add Attachment","newsletter-optin-box"),(0,d.createElement)(C.Icon,{icon:"plus"})),(0,d.createElement)("p",{className:"description"},(0,ee.__)("You can only attach files that are hosted on your server.","newsletter-optin-box")))))};function Pr(){return(0,d.createElement)(T.PostTrashCheck,null,(0,d.createElement)(T.PostTrash,null))}const Ir=(0,S.forwardRef)((({className:e,label:t,children:n},a)=>{const r={};return t||(r.width="100%"),(0,d.createElement)(C.__experimentalHStack,{className:b()("editor-post-panel__row",e),ref:a},t&&(0,d.createElement)("div",{className:"editor-post-panel__row-label"},t),(0,d.createElement)("div",{className:"editor-post-panel__row-control",style:r},n))})),Ar=function(){return(0,d.createElement)(T.PostPendingStatusCheck,null,(0,d.createElement)(Ir,null,(0,d.createElement)(T.PostPendingStatus,null)))},{Fill:Nr,Slot:Mr}=(0,C.createSlotFill)("PluginPostStatusInfo"),Lr=({children:e,className:t})=>(0,d.createElement)(Nr,null,(0,d.createElement)(C.PanelRow,{className:t},e));Lr.Slot=Mr;const Rr=Lr;function zr(){const[e,t]=(0,S.useState)(null),n=(0,S.useMemo)((()=>({anchor:e,"aria-label":(0,ee.__)("Change publish date"),placement:"bottom-end"})),[e]);return(0,d.createElement)(T.PostScheduleCheck,null,(0,d.createElement)(Ir,{label:(0,ee.__)("Publish"),ref:t},(0,d.createElement)(C.Dropdown,{popoverProps:n,focusOnMount:!0,className:"editor-post-schedule__panel-dropdown",contentClassName:"editor-post-schedule__dialog",renderToggle:({onToggle:e,isOpen:t})=>(0,d.createElement)(C.Button,{className:"editor-post-schedule__dialog-toggle",variant:"tertiary",onClick:e,label:(0,d.createElement)(T.PostScheduleLabel,{full:!0}),showTooltip:!0,"aria-expanded":t},(0,d.createElement)(T.PostScheduleLabel,null)),renderContent:({onClose:e})=>(0,d.createElement)(T.PostSchedule,{onClose:e})})))}const Dr=({onClose:e})=>{const t=O(),[n,a]=(0,S.useState)(N.user?.email||""),[r,o]=(0,S.useState)(!1),[l,i]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),u=(0,P.useSelect)((e=>e(T.store).isEditedPostDirty()),[]);return(0,S.useEffect)((()=>{l&&i(null),s&&c(null)}),[n]),(0,S.useEffect)((()=>{r&&(i(null),c(null),k()({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)})))}),[r]),u?(0,d.createElement)(C.Notice,{status:"warning",isDismissible:!1,className:"noptin-test-email-form__notice",actions:[{label:(0,ee.__)("Go Back"),onClick:e}]},(0,ee.__)("Please save your changes before sending a test email.")):(0,d.createElement)(C.__experimentalVStack,{className:"noptin-test-email-form"},(0,d.createElement)(C.TextControl,{label:(0,ee.__)("Email address"),type:"email",placeholder:(0,ee.__)("Enter email address"),help:(0,ee.__)("Enter the email address where you want to send the test email."),value:n,onChange:a}),(0,d.createElement)(C.Button,{variant:"primary",onClick:()=>o(!0),disabled:r||!n||!(0,E.isEmail)(n),isPressed:r,isBusy:r},!r&&(0,ee.__)("Send test email"),r&&(0,ee.__)("Sending..."),!r&&(0,d.createElement)(C.Icon,{icon:"arrow-right-alt"}),r&&(0,d.createElement)(C.Spinner,null)),(0,d.createElement)(C.Button,{variant:"secondary",onClick:e},s?(0,ee.__)("Close"):(0,ee.__)("Cancel")),l&&(0,d.createElement)(C.Notice,{status:"error",className:"noptin-test-email-form__notice",onDismiss:()=>i(null)},l),s&&(0,d.createElement)(C.Notice,{status:"success",className:"noptin-test-email-form__notice",onDismiss:()=>c(null)},s))};function $r(){const[e,t]=(0,S.useState)(null),n=(0,S.useMemo)((()=>({anchor:e,"aria-label":(0,ee.__)("Send a test email"),placement:"bottom-end"})),[e]);return(0,d.createElement)(Ir,{label:(0,ee.__)("Test"),ref:t},(0,d.createElement)(C.Dropdown,{popoverProps:n,focusOnMount:!0,className:"editor-post-test__panel-dropdown",contentClassName:"editor-post-test__dialog",renderToggle:({onToggle:e,isOpen:t})=>(0,d.createElement)(C.Button,{className:"editor-post-schedule__dialog-toggle",variant:"tertiary",onClick:e,label:(0,ee.__)("Send a test email"),showTooltip:!0,"aria-expanded":t},(0,ee.__)("Send a test email")),renderContent:({onClose:e})=>(0,d.createElement)(Dr,{onClose:e})}))}function Vr(){return(0,d.createElement)(C.PanelBody,{className:"edit-post-post-status",title:(0,ee.__)("Summary"),initialOpen:!1},(0,d.createElement)(Rr.Slot,null,(e=>(0,d.createElement)(C.__experimentalVStack,null,(0,d.createElement)(zr,null),(0,d.createElement)($r,null),e,(0,d.createElement)(Ar,null),(0,d.createElement)(C.__experimentalHStack,{style:{marginTop:"16px"},spacing:4,wrap:!0},(0,d.createElement)(T.PostSwitchToDraftButton,null),(0,d.createElement)(Pr,null))))))}const Fr=[{label:(0,ee.__)("Select unit","newsletter-optin-box"),value:""},{label:(0,ee.__)("Minutes","newsletter-optin-box"),value:"minutes"},{label:(0,ee.__)("Hours","newsletter-optin-box"),value:"hours"},{label:(0,ee.__)("Days","newsletter-optin-box"),value:"days"},{label:(0,ee.__)("Weeks","newsletter-optin-box"),value:"weeks"},{label:(0,ee.__)("Months","newsletter-optin-box"),value:"months"},{label:(0,ee.__)("Years","newsletter-optin-box"),value:"years"}],Hr=[{label:(0,ee.__)("Select unit","newsletter-optin-box"),value:""},{label:(0,ee.__)("Minute","newsletter-optin-box"),value:"minutes"},{label:(0,ee.__)("Hour","newsletter-optin-box"),value:"hours"},{label:(0,ee.__)("Day","newsletter-optin-box"),value:"days"},{label:(0,ee.__)("Week","newsletter-optin-box"),value:"weeks"},{label:(0,ee.__)("Month","newsletter-optin-box"),value:"months"},{label:(0,ee.__)("Year","newsletter-optin-box"),value:"years"}],Or=()=>{const e=G(),[t,n]=pt({heading:(0,ee.__)("Delay sending this email","newsletter-optin-box"),helpText:(0,ee.__)("The add-ons pack allows you to delay (schedule) this email for a given number of minutes, hours, or days.","newsletter-optin-box"),needsAddonsPack:!0,slug:"timing"}),[a,r]=U("meta"),[o,l]=J("when_to_run",a,r),[i,s]=J("sends_after",a,r),[c,u]=J("sends_after_unit",a,r),p="delayed"===o,m=(0,S.useCallback)((()=>{l(p?"immediately":"delayed")}),[p,l]);return e?.supports_timing?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Timing","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,null,!t&&n,t&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.ToggleControl,{label:(0,ee.__)("Delay sending this email","newsletter-optin-box"),checked:p,onChange:m,__nextHasNoMarginBottom:!0}),p&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.__experimentalHStack,null,(0,d.createElement)(C.__experimentalInputControl,{type:"number",label:(0,ee.__)("Send after","newsletter-optin-box"),placeholder:"1",value:i||"",onChange:s,min:1}),(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("Unit","newsletter-optin-box"),value:c||"",onChange:e=>u(e),options:1===parseInt(i)?Hr:Fr})),(0,d.createElement)("p",{className:"description"},(0,ee.__)("This email will be sent after the specified time has elapsed.","newsletter-optin-box")))))):null},jr=Object.entries(M.senders).map((([e,t])=>({label:t.label,value:e,disabled:!1}))),Ur=({recipient:e,recipientIds:t,setRecipientIds:n})=>{const a=(0,S.useCallback)((()=>{n(t.filter((t=>t!==e.id)))}),[e,t,n]);return e?(0,d.createElement)(C.__experimentalHStack,{wrap:!0},(0,d.createElement)("img",{src:e.avatar,width:32,alt:e.name}),(0,d.createElement)("p",null,e.name?e.email:`${e.name} <${e.email}>`),e.url&&(0,d.createElement)(C.Button,{href:e.url,target:"_blank"},(0,d.createElement)(C.Icon,{icon:"external"})),(0,d.createElement)(C.Button,{isDestructive:!0,onClick:a},(0,d.createElement)(C.Icon,{icon:"no-alt"}))):null},Gr=({recipientData:e,recipientIds:t,setRecipientIds:n})=>(0,d.createElement)(d.Fragment,null,t.map((a=>(0,d.createElement)(Ur,{key:a,recipient:e.find((e=>e.id===a)),recipientIds:t,setRecipientIds:n})))),Wr=({sender:e})=>{const{fields:t,key:n,upsell:a,disableMergeTags:r=!0}=M.senders?.[e]?.settings||{},[o,l]=pt({heading:(0,ee.sprintf)((0,ee.__)("Filter %s","newsletter-optin-box"),M.senders?.[e]?.label||(0,ee.__)("Recipients","newsletter-optin-box")),helpText:a?.message||(0,ee.__)("A premium plan allows you to filter recipients by custom fields etc.","newsletter-optin-box"),needsAddonsPack:"noptin"===e,slug:"filter-subscribers"});if(!t||Array.isArray(t)||0===Object.keys(t).length)return null;const i="manual_recipients"===e||o;return(0,d.createElement)(d.Fragment,null,!i&&l,i&&(0,d.createElement)(d.Fragment,null,Object.entries(t).map((([e,t])=>(0,d.createElement)(Va,{key:e,settingKey:e,setting:t,prop:n,disableMergeTags:r})))))},Kr=()=>{const e=G(),[t,n]=U("meta"),[a,r]=J("manual_recipients_ids",t,n),o=Array.isArray(a)&&a.length>0;return e.supports_recipients?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Send To","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,{spacing:4},o?(0,d.createElement)(Gr,{recipientData:e.manual_recipients,recipientIds:a,setRecipientIds:r}):(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Va,{settingKey:"email_sender",setting:{el:"select",label:(0,ee.__)("Send To","newsletter-optin-box"),options:jr,customAttributes:{allowReset:!1,hideLabelFromVision:!0}}}),(0,d.createElement)(Wr,{sender:t?.campaign_data?.email_sender})))):null},qr=()=>{const e=G(),[t,n]=U("noptin_automation_rule"),a=e=>{n({...t,saved:{...t.saved,...e}})};return e?.is_automation_rule?t.error?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Conditional Logic","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.Notice,{status:"error",isDismissible:!1},t.error)):t.settings?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Conditional Logic","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,null,Object.keys(t.settings).map((e=>(0,d.createElement)($a,{key:e,settingKey:e,saved:t.saved,setAttributes:a,setting:t.settings[e]}))))):null:null},Yr="post_notifications",Zr="post_digest",Qr=({isPostDigest:e})=>{const t=bt();if(!Array.isArray(t)||!t.length)return null;const n={el:"combobox",label:(0,ee.__)("Post type","newsletter-optin-box"),placeholder:(0,ee.__)("Select a post type","newsletter-optin-box"),description:e?(0,d.createElement)(d.Fragment,null,(0,ee.__)("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,d.createElement)("br",null),(0,d.createElement)(C.Button,{href:"https://noptin.com/guide/sending-emails/new-post-notifications/#set-digest-post-types",target:"_blank",variant:"link"},(0,ee.__)("Learn more","newsletter-optin-box"))):(0,ee.__)("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,d.createElement)(Va,{settingKey:"noptin-ap-post-type",setting:n})},Xr={"-1":(0,ee.__)("Do not filter by tags, categories, etc","noptin-addons-pack"),include:(0,ee.__)("Only send for some tags, categories, etc","noptin-addons-pack"),exclude:(0,ee.__)("Do not send for some tags, categories, etc","noptin-addons-pack")},Jr=({postType:e})=>{const[t,n]=U("meta"),{termsByTaxonomy:a}=G(),r=t?.campaign_data||{},o=r["noptin-ap-terms-action"]||"-1",l=ft(e),i=(0,S.useCallback)((e=>{const a=t||{};n({...a,campaign_data:{...a.campaign_data||{},...e}})}),[t,n]);return(0,S.useEffect)((()=>{Array.isArray(r["noptin-ap-terms"])&&a&&0!==Object.keys(a).length&&i({"noptin-ap-terms":"",tax_query:{...r.tax_query||{},...a}})}),[a,i]),l&&0!==l.length?(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Va,{settingKey:"noptin-ap-terms-action",setting:{el:"select",options:Xr,label:(0,ee.__)("Filter by terms","newsletter-optin-box"),description:(0,ee.__)("Optional. Select how to filter posts by terms.","newsletter-optin-box")}}),["include","exclude"].includes(o)&&(0,d.createElement)(wo,{postType:e,attributes:r,setAttributes:i})):null},eo=()=>{const[e,t]=pt({heading:(0,ee.__)("Set post type","newsletter-optin-box"),helpText:(0,d.createElement)(d.Fragment,null,(0,ee.__)("This email will only send for blog posts.","newsletter-optin-box"),(0,d.createElement)("br",null),(0,ee.__)("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"),a=n?.campaign_type,r=n?.automation_type,o=n?.campaign_data?.["noptin-ap-post-type"];return"automation"===a&&[Zr,Yr].includes(r)?(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Post settings","newsletter-optin-box"),initialOpen:!1},(0,d.createElement)(C.__experimentalVStack,null,!e&&t,e&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Qr,{isPostDigest:Zr===r}),Yr===r&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Va,{settingKey:"noptin-ap-authors",setting:{el:"input",type:"text",label:(0,ee.__)("Authors","newsletter-optin-box"),placeholder:(0,ee.__)("Send for all authors","newsletter-optin-box"),description:(0,ee.__)("Enter a comma-separated list of author IDs or leave blank to send for all authors.","newsletter-optin-box")},disableMergeTags:!0}),N?.languages&&(0,d.createElement)(Va,{settingKey:"noptin-ap-language",setting:{el:"combobox",label:(0,ee.__)("Language","newsletter-optin-box"),placeholder:(0,ee.__)("All languages","newsletter-optin-box"),options:N.languages,description:(0,ee.__)("Optional. Send for posts in the selected language only.","newsletter-optin-box")}})),o&&(0,d.createElement)(Jr,{postType:o})))):null};function to(){return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(Vr,null),(0,d.createElement)(xr,null),(0,d.createElement)(eo,null),(0,d.createElement)(qr,null),(0,d.createElement)(Kr,null),(0,d.createElement)(Or,null),(0,d.createElement)(Br,null),(0,d.createElement)(Tr,null),(0,d.createElement)(Sr,null),(0,d.createElement)(wr,null))}const no=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.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 ao({as:e=C.Button,name:t,...n}){const a=e,r=(0,P.useSelect)((e=>e(at).getCurrentSidebar()===t),[t]),{setCurrentSidebar:o}=(0,P.useDispatch)(at);return(0,d.createElement)(a,{isPressed:r,"aria-controls":t.replace("/",":"),onClick:()=>{o(r?null:t)},...n})}const ro=({children:e,className:t,toggleButtonProps:n})=>{const a=(0,d.createElement)(ao,{icon:no,...n});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)("div",{className:"components-panel__header interface-complementary-area-header__small"},a),(0,d.createElement)("div",{className:b()("components-panel__header","interface-complementary-area-header",t),tabIndex:-1},e,a))},oo=`${A}/sidebar-area`;function lo({children:e,className:t,id:n}){return(0,d.createElement)(C.Fill,{name:oo},(0,d.createElement)("div",{id:n,className:t},e))}function io({children:e,className:t,closeLabel:n=(0,ee.__)("Close plugin"),name:a,header:r,headerClassName:o,icon:l,panelClassName:i,title:s,isActiveByDefault:c=!1}){const u=(0,P.useSelect)((e=>e(at).getCurrentSidebar()),[a]),{setCurrentSidebar:p}=(0,P.useDispatch)(at),m=u===a,g=(0,_.useViewportMatch)("medium","<");return(0,S.useEffect)((()=>{c&&void 0===u&&!g&&p(a)}),[u,c,a,g]),(0,d.createElement)(d.Fragment,null,(0,d.createElement)(me,{scope:A},(0,d.createElement)(ao,{name:a,"aria-expanded":m,label:s,icon:l,showTooltip:!0,size:"compact"})),m&&(0,d.createElement)(lo,{className:b()("interface-complementary-area",t),id:a.replace("/",":")},(0,d.createElement)(ro,{className:o,toggleButtonProps:{label:n,name:a}},r),(0,d.createElement)(C.Panel,{className:i},e)))}io.Slot=e=>(0,d.createElement)(C.Slot,{name:oo,...e});const so=io;function co(){const[e,t]=(0,S.useState)(V),{emailType:n}=X(),a=(0,S.useCallback)((()=>{t($)}),[t]),r=(0,S.useCallback)((()=>{t(V)}),[t]),{hasSelectedBlock:o}=(0,P.useSelect)((e=>({hasSelectedBlock:!!e(B.store).getSelectedBlock()})),[]);(0,S.useEffect)((()=>{"visual"===n||e!==$?(o&&e===V&&t($),o||e!==$||t(V)):t(V)}),[o,t,n]);const l=(0,S.useMemo)((()=>(0,yr.compact)([{name:V,title:(0,ee.__)("Settings"),onClick:r},"visual"===n&&{name:$,title:(0,ee.__)("Block"),onClick:a}])),[r,a,n]);return(0,d.createElement)(so,{className:"edit-post-sidebar",header:(0,d.createElement)("ul",null,l.map((t=>(0,d.createElement)("li",{key:t.name},(0,d.createElement)(C.Button,{onClick:t.onClick,className:b()("edit-post-sidebar__panel-tab",t.name.replace(/\//g,"__").toLowerCase(),{"is-active":e===t.name}),"aria-label":e===t.name?(0,ee.sprintf)((0,ee.__)("%s (selected)"),t.title):t.title,"data-label":t.title},t.title))))),headerClassName:"edit-post-sidebar__panel-tabs" +/* translators: button label text should, if possible, be under 16 characters. */,title:e===V?(0,ee.__)("Settings"):(0,ee.__)("Block"),closeLabel:(0,ee.__)("Close Settings"),name:V,icon:(0,ee.isRTL)()?vr:Er,isActiveByDefault:!0},e===V&&(0,d.createElement)(to,null),e===$&&(0,d.createElement)(B.BlockInspector,{showNoBlockSelectedMessage:!0}))}function uo(){const e=(0,P.useSelect)((e=>e(at).getInsertionPoint()),[]);return(0,d.createElement)("div",{className:"edit-post-editor__inserter-panel"},(0,d.createElement)("div",{className:"edit-post-editor__inserter-panel-content"},(0,d.createElement)(B.__experimentalLibrary,{showInserterHelpPanel:!1,shouldFocusBlock:!0,rootClientId:e.rootClientId,__experimentalInsertionIndex:e.insertionIndex,__experimentalFilterValue:e.filterValue})))}function po(){const e=(0,_.useFocusOnMount)("firstElement"),[t,n]=(0,S.useState)(null),a=(0,S.useRef)(),r=(0,_.useMergeRefs)([e,a,n]);return(0,d.createElement)("div",{className:"edit-post-editor__document-overview-panel"},(0,d.createElement)("div",{className:"edit-post-editor__list-view-container",ref:r},(0,d.createElement)("div",{className:"edit-post-editor__list-view-panel-content"},(0,d.createElement)(B.__experimentalListView,{dropZoneElement:t}))))}const mo=[{name:"blocks",title:(0,ee.__)("Blocks","newsletter-optin-box")},{name:"overview",title:(0,ee.__)("Overview","newsletter-optin-box")}];function go(){return(0,d.createElement)(kt,{breakpoint:"medium"},(0,d.createElement)(C.TabPanel,{className:"block-editor-inserter__tabs edit-post-editor__inserter-panel",tabs:mo},(e=>(0,d.createElement)("div",{style:{width:350,overflow:"auto"}},(0,d.createElement)(C.__experimentalScrollable,null,"blocks"===e.name&&(0,d.createElement)(uo,null),"overview"===e.name&&(0,d.createElement)(po,null))))))}function _o(){const[e,t]=(0,S.useState)(0),n=O(),a=(0,_.usePrevious)(n);(0,S.useEffect)((()=>{n===a&&n===e||!n||r(n)}),[n,a,e]);const r=e=>{window.history.replaceState({noptin_campaign:e},"Email "+e,function(e){return(0,E.addQueryArgs)("admin.php",{noptin_campaign:e,page:"noptin-email-campaigns"})}(e)),t(e)};return null}const ho=window.wp.richText,bo=window.wp.dom,fo=/[\r\n]+/g,yo=(0,S.forwardRef)((function(e,t){const[n,a]=(0,S.useState)(!1),{ref:r}=function(e){const t=(0,S.useRef)(),n=(0,P.useSelect)((e=>e(T.store).isCleanNewPost()),[]);return(0,S.useImperativeHandle)(e,(()=>({focus:()=>{t?.current?.focus()}}))),(0,S.useEffect)((()=>{if(!t.current)return;const{defaultView:e}=t.current.ownerDocument,{name:a,parent:r}=e,o="editor-canvas"===a?r.document:e.document,{activeElement:l,body:i}=o;!n||l&&i!==l||t.current.focus()}),[n]),{ref:t}}(t),[o,l]=U("meta"),[i,s]=J("subject",o,l),[c,u]=(0,S.useState)({}),{clearSelectedBlock:p,insertBlocks:m,insertDefaultBlock:g}=(0,P.useDispatch)(B.store);function h(e){m(e,0)}function f(){a(!1),u({})}const{ref:y}=(0,ho.__unstableUseRichText)({value:i,onChange:function(e){s(e.replace(fo," "))},placeholder:(0,ee.__)("Enter email subject"),selectionStart:c.start,selectionEnd:c.end,onSelectionChange(e,t){u((n=>{const{start:a,end:r}=n;return a===e&&r===t?n:{start:e,end:t}}))},__unstableDisableFormats:!1}),v=b()("wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text",{"is-selected":n});return(0,d.createElement)("h1",{ref:(0,_.useMergeRefs)([y,r]),contentEditable:!0,className:v,"aria-label":(0,ee.__)("Enter email subject"),role:"textbox","aria-multiline":"true",onFocus:function(){a(!0),p()},onBlur:f,onKeyDown:function(e){e.keyCode===St.ENTER&&(e.preventDefault(),g(void 0,void 0,0))},onKeyPress:f,onPaste:function(e){const t=e.clipboardData;let n="",a="";try{n=t.getData("text/plain"),a=t.getData("text/html")}catch(e){try{a=t.getData("Text")}catch(e){return}}window.console.log("Received HTML:\n\n",a),window.console.log("Received plain text:\n\n",n);const r=(0,ne.pasteHandler)({HTML:a,plainText:n});if(e.preventDefault(),r.length)if("string"!=typeof r){const[e]=r;if(i||"core/heading"!==e.name&&"core/paragraph"!==e.name)h(r);else{const t=(0,bo.__unstableStripHTML)(e.attributes.content);s(t),h(r.slice(1))}}else{const e={...(0,ho.create)({html:i}),...c},t=(0,bo.__unstableStripHTML)(r),n=(0,ho.insert)(e,(0,ho.create)({html:t}));s((0,ho.toHTMLString)({value:n})),u({start:n.start,end:n.end})}}})})),vo=window.wp.htmlEntities,Eo=[],xo={order:"asc",_fields:"id,name",context:"view"},ko=(e,t)=>{const n=t?.id||e?.find((e=>e.name===t))?.id;if(n)return n;const a=t.toLocaleLowerCase();return e?.find((e=>e.name.toLocaleLowerCase()===a))?.id};function wo({postType:e,attributes:t,setAttributes:n}){const{tax_query:a}=t,r=ft(e);return r&&0!==r.length?(0,d.createElement)(d.Fragment,null,r.map((e=>{const t=a?.[e.slug]||[];return(0,d.createElement)(Co,{key:e.slug,taxonomy:e,termIds:t,onChange:t=>n({tax_query:{...a,[e.slug]:t}})})}))):null}function Co({taxonomy:e,termIds:t,onChange:n}){const[a,r]=(0,S.useState)(""),[o,l]=(0,S.useState)(Eo),[i,s]=(0,S.useState)(Eo),c=(0,_.useDebounce)(r,250),{searchResults:u,searchHasResolved:p}=(0,P.useSelect)((n=>{if(!a)return{searchResults:Eo,searchHasResolved:!0};const{getEntityRecords:r,hasFinishedResolution:o}=n(I.store),l=["taxonomy",e.slug,{...xo,search:a,orderby:"name",exclude:t,per_page:20}];return{searchResults:r(...l),searchHasResolved:o("getEntityRecords",l)}}),[a,t]),m=(0,P.useSelect)((n=>{if(!t?.length)return Eo;const{getEntityRecords:a}=n(I.store);return a("taxonomy",e.slug,{...xo,include:t,per_page:t.length})}),[t]);return(0,S.useEffect)((()=>{if(t?.length||l(Eo),!m?.length)return;const e=t.reduce(((e,t)=>{const n=m.find((e=>e.id===t));return n&&e.push({id:t,value:n.name}),e}),[]);l(e)}),[t,m]),(0,S.useEffect)((()=>{p&&s(u.map((e=>e.name)))}),[u,p]),(0,d.createElement)("div",{className:"block-library-query-inspector__taxonomy-control"},(0,d.createElement)(C.FormTokenField,{label:e.name,value:o,onInputChange:c,suggestions:i,displayTransform:vo.decodeEntities,onChange:e=>{const t=new Set;for(const n of e){const e=ko(u,n);e&&t.add(e)}s(Eo),n(Array.from(t))},__experimentalShowHowTo:!1}))}const So={fontFamily:!1,fontSize:!0,fontAppearance:!1,lineHeight:!1,letterSpacing:!1,textTransform:!1,textDecoration:!1},To=[{name:(0,ee.__)("Small"),slug:"small",size:13},{name:(0,ee.__)("Normal"),slug:"normal",size:16},{name:(0,ee.__)("Medium"),slug:"medium",size:20},{name:(0,ee.__)("Large"),slug:"large",size:36},{name:(0,ee.__)("Huge"),slug:"huge",size:42}];function Bo({attributes:e={style:{noptin:{typography:{}}}},setAttributes:t,settings:n,panelId:a,defaultControls:r=So}){const[o,l,i]=it(e,t,"typography"),s=ae(n,"fontFamily"),c=o.fontFamily,u=e=>l({fontFamily:e}),p=ae(n,"fontSize"),m=o.fontSize,g=e=>l({fontSize:e}),_=ae(n,"fontStyle"),h=ae(n,"fontWeight"),b=_||h,f=o.fontStyle,y=o.fontWeight,v=({fontStyle:e,fontWeight:t})=>l({fontStyle:e,fontWeight:t}),E=ae(n,"lineHeight"),x=o.lineHeight,k=e=>l({lineHeight:e}),w=ae(n,"letterSpacing"),S=o.letterSpacing,T=e=>l({letterSpacing:e}),P=ae(n,"textTransform"),I=o.textTransform,A=e=>l({textTransform:e}),N=ae(n,"textDecoration"),M=o.textDecoration,L=e=>l({textDecoration:e});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Typography"),resetAll:i,panelId:a,className:"typography-block-support-panel"},s&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Font family"),hasValue:()=>!!c,onDeselect:()=>u(void 0),isShownByDefault:r.fontFamily,panelId:a},(0,d.createElement)(xt,{value:c||"",onChange:u})),p&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Font size"),hasValue:()=>!!m,onDeselect:()=>g(void 0),isShownByDefault:r.fontSize,panelId:a},(0,d.createElement)(C.FontSizePicker,{value:m,onChange:g,fontSizes:To,disableCustomFontSizes:!1,withReset:!1,units:["px","em","rem"],withSlider:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0})),b&&(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"single-column",label:(0,ee.__)("Appearance"),hasValue:()=>!!f||!!y,onDeselect:()=>{v({fontStyle:void 0,fontWeight:void 0})},isShownByDefault:r.fontAppearance,panelId:a},(0,d.createElement)(B.__experimentalFontAppearanceControl,{value:{fontStyle:f,fontWeight:y},onChange:v,hasFontStyles:_,hasFontWeights:h,size:"__unstable-large",__nextHasNoMarginBottom:!0})),E&&(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"single-column",label:(0,ee.__)("Line height"),hasValue:()=>!!x,onDeselect:()=>k(void 0),isShownByDefault:r.lineHeight,panelId:a},(0,d.createElement)(B.LineHeightControl,{__nextHasNoMarginBottom:!0,__unstableInputWidth:"auto",value:x,onChange:k,size:"__unstable-large"})),w&&(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"single-column",label:(0,ee.__)("Letter spacing"),hasValue:()=>!!S,onDeselect:()=>T(void 0),isShownByDefault:r.letterSpacing,panelId:a},(0,d.createElement)(B.__experimentalLetterSpacingControl,{value:S,onChange:T,size:"__unstable-large",__unstableInputWidth:"auto"})),N&&(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"single-column",label:(0,ee.__)("Text decoration"),hasValue:()=>!!M,onDeselect:()=>L(void 0),isShownByDefault:r.textDecoration,panelId:a},(0,d.createElement)(B.__experimentalTextDecorationControl,{value:M,onChange:L,size:"__unstable-large",__unstableInputWidth:"auto"})),P&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Letter case"),hasValue:()=>!!I,onDeselect:()=>A(void 0),isShownByDefault:r.textTransform,panelId:a},(0,d.createElement)(B.__experimentalTextTransformControl,{value:I,onChange:A,showNone:!0,isBlock:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0}))))}const Po=e=>{const[t]=it(e,null,"typography");return t};function Io({attributes:e={style:{noptin:{border:{}}}},setAttributes:t=(e=>e),settings:n,panelId:a}){const[r,o,l]=it(e,t,"border"),i=yt();return(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Border"),resetAll:l,panelId:a,className:"border-block-support-panel"},ae(n,"border")&&(0,d.createElement)(C.__experimentalToolsPanelItem,{hasValue:()=>(0,C.__experimentalIsDefinedBorder)(r?.border),label:(0,ee.__)("Border"),onDeselect:()=>o({border:void 0}),isShownByDefault:!0,panelId:a},(0,d.createElement)(C.__experimentalBorderBoxControl,{colors:i,onChange:e=>o({border:e}),popoverOffset:40,popoverPlacement:"left-start",value:r?.border,__experimentalIsRenderedInSidebar:!0,size:"__unstable-large"})),ae(n,"radius")&&(0,d.createElement)(C.__experimentalToolsPanelItem,{hasValue:()=>{const e=r?.radius;return"object"==typeof e?Object.entries(e).some(Boolean):!!e},label:(0,ee.__)("Radius"),onDeselect:()=>o({radius:void 0}),isShownByDefault:!0,panelId:a},(0,d.createElement)(B.__experimentalBorderRadiusControl,{values:r?.radius,onChange:e=>o({radius:e})})))}const Ao=e=>{const[t]=it(e,null,"border");if(!t)return{};const n=(e,t)=>{if(!e)return{};const n={};return["style","width","color"].forEach((a=>{const r=e[a],o=`${t}${a.charAt(0).toUpperCase()+a.slice(1)}`;r&&(n[o]=r)})),n[`${t}Width`]&&!n[`${t}Style`]&&(n[`${t}Style`]="solid"),n},a=e?.style?.noptin?.border;return{...(0,C.__experimentalIsDefinedBorder)(a?.border)?(e=>{if(!(0,C.__experimentalHasSplitBorders)(e))return n(e,"border");let t={};return["top","right","bottom","left"].forEach((a=>{const r=e[a],o=`border${a.charAt(0).toUpperCase()+a.slice(1)}`;t={...t,...n(r,o)}})),t})(a?.border):{},...(r=t.radius,r&&"object"==typeof r?{borderRadius:["topLeft","topRight","bottomRight","bottomLeft"].reduce(((e,t)=>{const n=r[t];return n&&(e=`${e} ${n}`),e}),"")}:{borderRadius:r})};var r},No={},Mo={},Lo={placement:"left-start",offset:36,shift:!0},Ro=({indicators:e,label:t})=>(0,d.createElement)(C.__experimentalHStack,{justify:"flex-start"},(0,d.createElement)(C.__experimentalZStack,{isLayered:!1,offset:-8},e.map(((e,t)=>(0,d.createElement)(C.Flex,{key:t,expanded:!1},(0,d.createElement)(C.ColorIndicator,{colorValue:e}))))),(0,d.createElement)(C.FlexItem,{className:"block-editor-panel-color-gradient-settings__color-name",title:t},t));function zo({isGradient:e,inheritedValue:t,userValue:n,setValue:a,colorGradientControlSettings:r}){return(0,d.createElement)(B.__experimentalColorGradientControl,{...r,showTitle:!1,enableAlpha:!0,__experimentalIsRenderedInSidebar:!0,colorValue:e?void 0:t,gradientValue:e?t:void 0,onColorChange:e?void 0:a,onGradientChange:e?a:void 0,clearable:t===n,headingLevel:3})}function Do({label:e,hasValue:t,resetValue:n,isShownByDefault:a,indicators:r,tabs:o,colorGradientControlSettings:l,panelId:i}){const s=o.map((({key:e,label:t})=>({name:e,title:t})));return(0,d.createElement)(C.__experimentalToolsPanelItem,{className:"block-editor-tools-panel-color-gradient-settings__item",hasValue:t,label:e,onDeselect:n,isShownByDefault:a,panelId:i},(0,d.createElement)(C.Dropdown,{popoverProps:Lo,className:"block-editor-tools-panel-color-gradient-settings__dropdown",renderToggle:({onToggle:t,isOpen:n})=>{const a={onClick:t,className:b()("block-editor-panel-color-gradient-settings__dropdown",{"is-open":n}),"aria-expanded":n,"aria-label":(0,ee.sprintf)(/* translators: %s is the type of color property, e.g., "background" */ +(0,ee.__)("Color %s styles"),e)};return(0,d.createElement)(C.Button,{...a},(0,d.createElement)(Ro,{indicators:r,label:e}))},renderContent:()=>(0,d.createElement)(C.__experimentalDropdownContentWrapper,{paddingSize:"none"},(0,d.createElement)("div",{className:"block-editor-panel-color-gradient-settings__dropdown-content"},1===o.length&&(0,d.createElement)(zo,{...o[0],colorGradientControlSettings:l}),o.length>1&&(0,d.createElement)(C.TabPanel,{tabs:s},(e=>{const t=o.find((t=>t.key===e.name));return t?(0,d.createElement)(zo,{...t,colorGradientControlSettings:l}):null}))))}))}const $o={text:!0,background:!0,link:!0,heading:!0,button:!0},Vo={text:{label:(0,ee.__)("Text"),prepare:(e,t)=>{t?.text&&(e.style.color=t.text)}},background:{label:(0,ee.__)("Background"),prepare:(e,t)=>{t?.background&&(e.style.backgroundColor=t.background)}},link:{label:(0,ee.__)("Link"),prepare:(e,t,n)=>{t?.link&&(e.css=`${e.css} ${n} a { color: ${t.link} }`)}},heading:{label:(0,ee.__)("Heading"),tabs:[{key:"heading",label:(0,ee.__)("Text")},{key:"headingBackground",label:(0,ee.__)("Background")}],prepare:(e,t,n)=>{t?.heading&&(e.css=`${e.css} ${n} h1,\n${n} h2,\n${n} h3,\n${n} h4,\n${n} h5,\n${n} h6 { color: ${t.heading} }`),t?.headingBackground&&(e.css=`${e.css} ${n} h1,\n${n} h2,\n${n} h3,\n${n} h4,\n${n} h5,\n${n} h6 { background-color: ${t.headingBackground} }`)}},button:{label:(0,ee.__)("Button"),tabs:[{key:"button",label:(0,ee.__)("Text")},{key:"buttonBackground",label:(0,ee.__)("Background")}],prepare:(e,t,n)=>{t?.button&&(e.css=`${e.css} ${n} .noptin-button-link,\n${n} .noptin-button-link__wrapper { color: ${t.button} }`),t?.buttonBackground&&(e.css=`${e.css} ${n} .noptin-button-link,\n${n} .noptin-button-link__wrapper { background-color: ${t.buttonBackground} }`)}}};function Fo({settings:e,panelId:t,defaultControls:n=$o,children:a=null,attributes:r,setAttributes:o}){const[l,i,s]=it(r,o,"color"),c=yt(),u=(0,yr.compact)(Object.keys(Vo).map((t=>{if(!ae(e,t))return!1;const a=Vo[t].tabs||[{key:t,label:Vo[t].label}];return{key:t,label:Vo[t].label,hasValue:()=>!!l[t],resetValue:()=>i({[t]:void 0}),isShownByDefault:n[t],indicators:[l?.[t]],tabs:a.map((({key:e,label:t})=>({key:e,label:t,setValue:t=>i({[e]:t}),userValue:l?.[e]})))}})));return(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Color"),resetAll:s,panelId:t,className:"color-block-support-panel"},(0,d.createElement)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0px, 1fr))",gap:"calc(16px) calc(8px)",gridColumn:"1 / -1",rowGap:0,borderTop:"1px solid #ddd"}},u.map((e=>(0,d.createElement)(Do,{...e,colorGradientControlSettings:{colors:c,disableCustomColors:!1},panelId:t}))),a))}const Ho=e=>{const[t]=it(e,null,"color"),n={style:{},css:""};return t?(Object.values(Vo).forEach((a=>{a.prepare(n,t,`#noptin-email-content .${e.anchor}`)}),n),n):{style:{},css:""}},Oo=["none","left","center","right"],jo=e=>{const[t]=it(e,null,"align","none");return"none"===t?void 0:t};function Uo(e){if(!e)return;if(f.includes(e.name))return(0,ne.registerBlockType)({name:e.name,...e.metadata},e.settings);if(e.metadata.attributes=e.metadata.attributes||{},y.includes(e.name)||e.metadata.attributes?.anchor||(e.metadata.attributes.anchor={type:"string"}),e.metadata?.noptin&&!e.metadata.attributes?.style&&(e.metadata.attributes=e.metadata.attributes||{},e.metadata.attributes.style={type:"object",default:{}}),e.settings?.icon?.icon){let t={src:e.settings.icon.icon,foreground:e.settings.icon.fill||void 0};e.settings.icon=t}const{metadata:t,settings:n,name:a}=(({metadata:e,settings:t,...n})=>(e?.noptin?.color&&(t.edit=(0,_.createHigherOrderComponent)((t=>n=>{const[a,r]=Y(),o=n.attributes?.anchor,l=!y.includes(n.name);let i=o;(0,d.useEffect)((()=>{l&&((!o||No[o]&&No[o]!==n.clientId)&&(i=e.name.replace("/","-")+"-"+(1e5*Math.random()).toFixed(0)),No[i]=n.clientId,Mo[n.clientId]=i)}),[]);const s=a[i]||"",c=(0,d.useMemo)((()=>y.includes(n.name)?"":Ho(n.attributes).css),[n.attributes,n.name]);return(0,d.useEffect)((()=>{if(!i||!l)return;const e=Mo[n.clientId];s!==c?(r(i,c),e&&e!==o&&n.setAttributes({anchor:e})):o&&e&&e!==o&&n.setAttributes({anchor:e})}),[i,s,c,l]),(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,{group:"styles"},(0,d.createElement)(Fo,{panelId:n.clientId,attributes:n.attributes,setAttributes:n.setAttributes,settings:e.noptin.color})),(0,d.createElement)(t,{...n}))}),"withNoptinColors")(t.edit)),{metadata:e,settings:t,...n}))((({metadata:e,settings:t,...n})=>(e?.noptin?.align&&(t.edit=(0,_.createHigherOrderComponent)((e=>t=>{const[n,a]=it(t.attributes,t.setAttributes,"align","none");return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(B.BlockAlignmentControl,{value:n,onChange:a,controls:Oo})),(0,d.createElement)(e,{...t}))}),"withNoptinAlignmentSupport")(t.edit)),{metadata:e,settings:t,...n}))((({metadata:e,settings:t,...n})=>{if(e?.noptin?.typography){const n=t.edit;t.edit=t=>{const a=ae(e.noptin.typography,"textAlign"),[r,o]=it(t.attributes,t.setAttributes,"typography");return(0,d.createElement)(d.Fragment,null,a&&(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(B.AlignmentControl,{value:r.textAlign,onChange:e=>o({textAlign:e})})),(0,d.createElement)(B.InspectorControls,{group:"styles"},(0,d.createElement)(Bo,{panelId:t.clientId,attributes:t.attributes,setAttributes:t.setAttributes,settings:e.noptin.typography})),n(t))}}return{metadata:e,settings:t,...n}})((({metadata:e,settings:t,...n})=>{if(e?.noptin?.border){const n=t.edit;t.edit=t=>(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,{group:"styles"},(0,d.createElement)(Io,{panelId:t.clientId,attributes:t.attributes,setAttributes:t.setAttributes,settings:e.noptin.border})),n(t))}return{metadata:e,settings:t,...n}})(e))));return(0,ne.registerBlockType)({name:a,...t},n)}const Go=e=>{const t={margin:{},padding:{}};return e?(Object.entries(e).forEach((([e,n])=>{e.startsWith("margin")?t.margin[e]=n:e.startsWith("padding")&&(t.padding[e]=n)})),t):t},Wo=(e,t=!1)=>{const n=(0,B.__experimentalGetSpacingClassesAndStyles)(e),a=n?.style||{};return t?Go(a):a};Wo.save=(e,t=!1)=>{const n=(0,B.__experimentalGetSpacingClassesAndStyles)(e),a=n?.style||{};return t?Go(a):a};const Ko=(0,d.memo)((function({blocks:e,isHidden:t,setActiveBlockContextId:n,style:a,className:r}){const o=(0,B.__experimentalUseBlockPreview)({blocks:e,props:{className:r}});return(0,d.createElement)("div",{...o,tabIndex:0,role:"button",onClick:n,onKeyPress:n,style:{...a,display:t?"none":void 0}})})),qo=({name:e,template:t})=>{function n(e){const n=(0,B.useInnerBlocksProps)(e,{template:t,templateLock:!1});return(0,d.createElement)("div",{...n})}return({attributes:t,context:a,clientId:r})=>{const o=a[`noptin/${e}/isStackedOnMobile`],l=a[`noptin/${e}/columns`]||1,i=(e=>{if(1===e)return"100%";const t=1e12;return Math.round(100/e*t)/t+"%"})(l),s=a[`noptin/${e}/query`]?.number||10,c=Array(s).fill(0),u=Array.from({length:l},(()=>[]));c.forEach(((e,t)=>{u[t%l].push(t)}));const[p,m]=(0,d.useState)("0.0"),_={...Po(t),...Ao(t),...Wo(t),...Ho(t).style},h=b()("noptin-records__wrapper",`noptin-${e}__wrapper`,{[`noptin-columns noptin-columns__${l}`]:l>1,"noptin-is-stacked-on-mobile":l>1&&o}),f=b()("noptin-records__column",`noptin-${e}__column`,{"noptin-column":l>1,"noptin-is-stacked-on-mobile":l>1&&o}),y=(0,P.useSelect)((e=>e(B.store).getBlocks(r)),[r]);return(0,d.createElement)("div",{...(0,B.useBlockProps)({className:h})},u.map(((e,t)=>(0,d.createElement)("div",{key:t,className:f,style:{width:i}},0===e.length&&(0,d.createElement)("span",null,"nbsp;"),e.map((e=>{const a=`${t}.${e}`;return(0,d.createElement)(g().Fragment,{key:a},a===p&&(0,d.createElement)(n,{style:_,className:"noptin-record"}),y.length>0&&(0,d.createElement)(Ko,{blocks:y,style:_,className:"noptin-record",setActiveBlockContextId:()=>m(a),isHidden:a===p}))}))))))}},Yo={},Zo=()=>{const e=G(),[t]=U("noptin_automation_rule");return(0,S.useMemo)((()=>e?.merge_tags?te(e.merge_tags,t?.saved||{}):[]),[e?.merge_tags,t?.saved])},Qo=()=>{const{getEditedPostAttribute:e,getSelectedBlockClientId:t}=(0,P.select)(T.store),{__experimentalGetActiveBlockIdByBlockNames:n,getBlockName:a}=(0,P.select)(B.store),r=e("noptin_automation_rule"),o=e("noptin_campaign_type");if(t()){const e=n(Object.keys(Yo));if(e){const t=Yo[a(e)];if(N.objects?.[t])return te(N.objects[t].merge_tags,r?.saved||{})}}return o?.merge_tags?te(o.merge_tags,r?.saved||{}):[]};function Xo(e){const{batch:t}=(0,P.useRegistry)(),{moveBlocksToPosition:n,replaceInnerBlocks:a,duplicateBlocks:r,insertBlock:o}=(0,P.useDispatch)(B.store),{getBlockRootClientId:l,getBlockIndex:i,getBlockOrder:s,getBlockName:c,getBlock:u,getNextBlockClientId:p,canInsertBlockType:m}=(0,P.useSelect)(B.store),d=(0,S.useRef)(e);return d.current=e,(0,_.useRefEffect)((e=>{function g(e){if(e.defaultPrevented)return;if(e.keyCode!==St.ENTER)return;const{content:g,clientId:_}=d.current;if(g.length)return;const h=l(_);if(!(0,ne.hasBlockSupport)(c(h),"__experimentalOnEnter",!1))return;const b=s(h),f=b.indexOf(_);if(f===b.length-1){let t=h;for(;!m(c(_),l(t));)t=l(t);return void("string"==typeof t&&(e.preventDefault(),n([_],h,l(t),i(t)+1)))}const y=(0,ne.getDefaultBlockName)();if(!m(y,l(h)))return;e.preventDefault();const v=u(h);t((()=>{r([h]);const e=i(h);a(h,v.innerBlocks.slice(0,f)),a(p(h),v.innerBlocks.slice(f+1)),o((0,ne.createBlock)(y),e+1,l(h),!0)}))}return e.addEventListener("keydown",g),()=>{e.removeEventListener("keydown",g)}}),[])}(0,p.addFilter)("editor.Autocomplete.completers","noptin/edit-email/merge-tags-completer",(e=>{const t=e.filter((e=>"links"!==e.name));return t.push({name:"noptin-merge-tags",className:"block-editor-autocompleters__link",triggerPrefix:"[[",options:Qo,getOptionKeywords:({smart_tag:e,group:t,label:n,description:a})=>[...`${e} ${t} ${n} ${a}`.split(/\s+/)],getOptionLabel:({icon:e,label:t})=>(0,d.createElement)(d.Fragment,null,e&&(0,d.createElement)(C.Icon,{key:"icon",icon:e}),t),getOptionCompletion:({smart_tag:e,example:t})=>`[[${t||e}]]`}),t}));const Jo={apiVersion:3,name:"core/paragraph",title:(0,ee.__)("Paragraph","newsletter-optin-box"),category:"content",description:(0,ee.__)("Start with the basic building block of all narrative.","newsletter-optin-box"),keywords:["text"],attributes:{content:{type:"string",source:"html",selector:"p",default:"",__experimentalRole:"content"},placeholder:{type:"string"}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0,link:!0}},supports:{anchor:!1,className:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0,padding:!1}},__experimentalSelector:"p",__unstablePasteTextInline:!0}},el={from:[{type:"raw",priority:20,selector:"p",schema:({phrasingContentSchema:e,isPaste:t})=>({p:{children:e,attributes:t?[]:["style","id"]}}),transform(e){const t=(0,ne.getBlockAttributes)("core/paragraph",e.outerHTML),{textAlign:n}=e.style||{};return"left"!==n&&"center"!==n&&"right"!==n||(t.style={...t.style||{},noptin:{...t.style?.noptin||{},typography:{...t.style?.noptin?.typography||{},textAlign:n}}}),(0,ne.createBlock)("core/paragraph",t)}}]},tl=el,{name:nl}=Jo,al={icon:"editor-paragraph",example:{attributes:{content:(0,ee.__)("In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.")}},__experimentalLabel(e,{context:t}){const n=e?.metadata?.name;if("list-view"===t&&n)return n;if("accessibility"===t){if(n)return n;const{content:t}=e;return t&&0!==t.length?t:(0,ee.__)("Empty")}},transforms:tl,merge:(e,t)=>({content:(e.content||"")+(t.content||"")}),edit:function({attributes:e,mergeBlocks:t,onReplace:n,onRemove:a,setAttributes:r,clientId:o}){const{content:l,placeholder:i}=e,s=(0,B.useBlockProps)({ref:Xo({clientId:o,content:l}),style:{...Po(e),...Ao(e),...Wo(e),...Ho(e).style}});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.RichText,{identifier:"content",tagName:"p",...s,value:l,onChange:e=>r({content:e}),onSplit:(t,n)=>{let a;(n||t)&&(a={...e,content:t});const r=(0,ne.createBlock)("core/paragraph",a);return n&&(r.clientId=o),r},onMerge:t,onReplace:n,onRemove:a,"aria-label":l?(0,ee.__)("Block: Paragraph"):(0,ee.__)("Empty block; start writing or type forward slash to choose a block"),"data-empty":!l,placeholder:i||(0,ee.__)("Start writing or type / to choose a block"),"data-custom-placeholder":!!i||void 0,__unstableAllowPrefixTransformations:!0}))},save:function({attributes:e}){const{content:t}=e,n=B.useBlockProps.save({style:{...Po(e),...Ao(e),...Wo.save(e),...Ho(e).style}});return(0,d.createElement)("p",{...n},(0,d.createElement)(B.RichText.Content,{value:t}))}},rl={apiVersion:3,name:"core/heading",title:(0,ee.__)("Heading","newsletter-optin-box"),category:"content",description:(0,ee.__)("Introduce new sections and organize content to help readers understand the structure of your content.","newsletter-optin-box"),keywords:["title","subtitle"],attributes:{content:{type:"string",source:"html",selector:"h1,h2,h3,h4,h5,h6",default:"",__experimentalRole:"content"},level:{type:"number",default:2},placeholder:{type:"string"}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0,link:!0}},supports:{anchor:!1,className:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0,padding:!1}},__unstablePasteTextInline:!0,__experimentalSlashInserter:!0}},ol={from:[{type:"block",isMultiBlock:!0,blocks:["core/paragraph"],transform:e=>e.map((({content:e,className:t,style:n})=>(0,ne.createBlock)("core/heading",{content:e,className:t,style:n})))},{type:"raw",selector:"h1,h2,h3,h4,h5,h6",schema:({phrasingContentSchema:e,isPaste:t})=>{const n={children:e,attributes:t?[]:["style","id"]};return{h1:n,h2:n,h3:n,h4:n,h5:n,h6:n}},transform(e){const t=(0,ne.getBlockAttributes)("core/heading",e.outerHTML),{textAlign:n}=e.style||{};var a;return t.level=(a=e.nodeName,Number(a.substr(1))),"left"!==n&&"center"!==n&&"right"!==n||(t.style={...t.style||{},noptin:{...t.style?.noptin||{},typography:{...t.style?.noptin?.typography||{},textAlign:n}}}),(0,ne.createBlock)("core/heading",t)}},...[1,2,3,4,5,6].map((e=>({type:"prefix",prefix:Array(e+1).join("#"),transform:t=>(0,ne.createBlock)("core/heading",{level:e,content:t})}))),...[1,2,3,4,5,6].map((e=>({type:"enter",regExp:new RegExp(`^/(h|H)${e}$`),transform:()=>(0,ne.createBlock)("core/heading",{level:e})})))],to:[{type:"block",isMultiBlock:!0,blocks:["core/paragraph"],transform:e=>e.map((({content:e,className:t,style:n})=>(0,ne.createBlock)("core/paragraph",{content:e,className:t,style:n})))}]},ll=ol,{name:il}=rl,sl={icon:"heading",example:{attributes:{content:(0,ee.__)("Code is Poetry"),level:2}},__experimentalLabel(e,{context:t}){const{content:n,level:a}=e,r=e?.metadata?.name;return"list-view"===t&&(r||n)?e?.metadata?.name||n:"accessibility"===t?n&&0!==n.length?(0,ee.sprintf)(/* translators: accessibility text. 1: heading level. 2: heading content. */ (0,ee.__)("Level %1$s. %2$s"),a,n):(0,ee.sprintf)(/* translators: accessibility text. %s: heading level. */ -(0,ee.__)("Level %s. Empty."),a):void 0},transforms:cl,merge:(e,t)=>({content:(e.content||"")+(t.content||"")}),edit:function({attributes:e,setAttributes:t,mergeBlocks:n,onReplace:a,clientId:r}){const{placeholder:o,content:l,level:i}=e,s=(0,B.useBlockProps)({style:{...No(e),...Lo(e),...Yo(e),...Uo(e).style}});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(B.HeadingLevelDropdown,{value:i,onChange:e=>t({level:e})})),(0,d.createElement)(B.RichText,{identifier:"content",tagName:"h"+i,value:l,onChange:e=>{t({content:e})},onMerge:n,onSplit:(t,n)=>{let a;var o;return a=n||t?(0,ne.createBlock)("core/heading",{...e,content:t}):(0,ne.createBlock)(null!==(o=(0,ne.getDefaultBlockName)())&&void 0!==o?o:"core/heading"),n&&(a.clientId=r),a},onReplace:a,onRemove:()=>a([]),placeholder:o||(0,ee.__)("Enter heading..."),...s}))},save:function({attributes:e}){const{content:t,level:n}=e,a="h"+n,r=B.useBlockProps.save({style:{...No(e),...Lo(e),...Yo.save(e),...Uo(e).style}});return(0,d.createElement)(a,{...r},(0,d.createElement)(B.RichText.Content,{value:t}))}},ml=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z"})),dl=window.wp.blob,gl=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M6 5.5h12a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5ZM4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6Zm4 10h2v-1.5H8V16Zm5 0h-2v-1.5h2V16Zm1 0h2v-1.5h-2V16Z"})),_l=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M16.5 7.8v7H18v-7c0-1-.8-1.8-1.8-1.8h-7v1.5h7c.2 0 .3.1.3.3zm-8.7 8.7c-.1 0-.2-.1-.2-.2V2H6v4H2v1.5h4v8.8c0 1 .8 1.8 1.8 1.8h8.8v4H18v-4h4v-1.5H7.8z"})),hl=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})),bl=["image"],fl=({href:e,children:t})=>e?(0,d.createElement)("a",{href:e,onClick:e=>e.preventDefault(),"aria-disabled":!0,style:{pointerEvents:"none",cursor:"default",display:"block",textDecoration:"none",maxWidth:"100%",lineHeight:0}},t):t;function yl({temporaryURL:e,attributes:t,setAttributes:n,isSelected:a,insertBlocksAfter:r,onSelectImage:o,onSelectURL:l,onUploadError:i,containerRef:s,clientId:c,blockEditingMode:u}){const{url:p="",alt:m,caption:g,id:h,href:b,rel:f,linkClass:y,linkDestination:v,width:x,height:k,scale:w,sizeSlug:T}=t,A=Wo(t),N=x?parseInt(x,10):void 0,M=k?parseInt(k,10):void 0,L=(0,S.useRef)(),R=(0,_.usePrevious)(g),[z,$]=(0,S.useState)(!!g),{image:D,multiImageSelection:V}=(0,P.useSelect)((e=>{const{getMedia:t}=e(I.store),{getMultiSelectedBlockClientIds:n,getBlockName:r}=e(B.store),o=n();return{image:h&&a?t(h,{context:"view"}):null,multiImageSelection:o.length&&o.every((e=>"core/image"===r(e)))}}),[h,a]),{imageEditing:F,imageSizes:O,mediaUpload:H}=(0,P.useSelect)((e=>{const{getSettings:t}=e(B.store),n=t();return{imageEditing:n.imageEditing,imageSizes:n.imageSizes,mediaUpload:n.mediaUpload}}),[c]),{createErrorNotice:j,createSuccessNotice:U}=(0,P.useDispatch)(Ua.store),[{loadedNaturalWidth:G,loadedNaturalHeight:W},K]=(0,S.useState)({loadedNaturalWidth:void 0,loadedNaturalHeight:void 0}),[q,Y]=(0,S.useState)(!1),[Z,Q]=(0,S.useState)(),X=function(e,t){const[n,a]=(0,S.useState)();function r(){a(e.current?.clientWidth)}return(0,S.useEffect)(r,t),(0,S.useEffect)((()=>{const{defaultView:t}=e.current.ownerDocument;return t.addEventListener("resize",r),()=>{t.removeEventListener("resize",r)}}),[]),n}(s,[A]),J="default"===u,te=O.filter((({slug:e})=>D?.media_details?.sizes?.[e]?.source_url)).map((({name:e,slug:t})=>({value:t,label:e}))),ae=!!H;(0,S.useEffect)((()=>{vl(h,p)&&a&&ae?Z||window.fetch(p.includes("?")?p:p+"?").then((e=>e.blob())).then((e=>Q(e))).catch((()=>{})):Q(void 0)}),[h,p,a,Z,ae]),(0,S.useEffect)((()=>{g&&!R&&$(!0)}),[g,R]);const re=(0,S.useCallback)((e=>{e&&!g&&e.focus()}),[g]),{naturalWidth:oe,naturalHeight:le}=(0,S.useMemo)((()=>({naturalWidth:L.current?.naturalWidth||G||void 0,naturalHeight:L.current?.naturalHeight||W||void 0})),[G,W,L.current?.complete]);(0,S.useEffect)((()=>{a||(Y(!1),g||$(!1))}),[a,g]);const ie=h&&oe&&le&&F,se=!V&&ie&&!q,ce=()=>{n({width:void 0,height:void 0,scale:void 0})},ue=(0,C.__experimentalUseCustomUnits)({availableUnits:["px"]}),pe=(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Width"),isShownByDefault:!0,hasValue:()=>!!x,onDeselect:()=>n({width:void 0}),panelId:c,style:{gridColumn:"span 1"}},(0,d.createElement)(B.__experimentalUnitControl,{label:(0,ee.__)("Width"),placeholder:(0,ee.__)("Auto"),labelPosition:"top",min:0,value:x||"",onChange:e=>n({width:e}),size:"__unstable-large"})),(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Height"),isShownByDefault:!0,hasValue:()=>!!k,onDeselect:()=>n({height:void 0}),panelId:c,style:{gridColumn:"span 1"}},(0,d.createElement)(B.__experimentalUnitControl,{label:(0,ee.__)("Height"),placeholder:(0,ee.__)("Auto"),labelPosition:"top",units:ue,min:0,value:k||"",onChange:e=>n({height:e}),size:"__unstable-large"}))),me=(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},J&&(0,d.createElement)(C.ToolbarButton,{onClick:()=>{$(!z),z&&g&&n({caption:void 0})},icon:gl,isPressed:z,label:z?(0,ee.__)("Remove caption"):(0,ee.__)("Add caption")}),!V&&!q&&(0,d.createElement)(B.__experimentalImageURLInputUI,{url:b||"",onChangeUrl:n,linkDestination:v,mediaUrl:D&&D.source_url||p,mediaLink:D&&D.link,linkClass:y,rel:f}),se&&(0,d.createElement)(C.ToolbarButton,{onClick:()=>Y(!0),icon:_l,label:(0,ee.__)("Crop")})),!V&&!q&&(0,d.createElement)(B.BlockControls,{group:"other"},(0,d.createElement)(B.MediaReplaceFlow,{mediaId:h,mediaURL:p,allowedTypes:bl,accept:"image/*",onSelect:o,onSelectURL:l,onError:i})),!V&&Z&&(0,d.createElement)(B.BlockControls,null,(0,d.createElement)(C.ToolbarGroup,null,(0,d.createElement)(C.ToolbarButton,{onClick:function(){H({filesList:[Z],onFileChange([e]){o(e),(0,dl.isBlobURL)(e.url)||(Q(void 0),U((0,ee.__)("Image uploaded."),{type:"snackbar"}))},allowedTypes:bl,onError(e){j(e,{type:"snackbar"})}})},icon:hl,label:(0,ee.__)("Upload external image")}))),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Settings"),panelId:c,resetAll:ce},!V&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Alternative text"),isShownByDefault:!0,hasValue:()=>""!==m,panelId:c,onDeselect:()=>n({alt:void 0})},(0,d.createElement)(C.TextareaControl,{label:(0,ee.__)("Alternative text"),value:m,onChange:e=>n({alt:e}),help:(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.ExternalLink,{href:"https://www.w3.org/WAI/tutorials/images/decision-tree"},(0,ee.__)("Describe the purpose of the image.")),(0,d.createElement)("br",null),(0,ee.__)("Leave empty if decorative.")),__nextHasNoMarginBottom:!0})),J&&(0,d.createElement)(d.Fragment,null,te.length>0?(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Image size"),isShownByDefault:!0,hasValue:()=>"large"!==T,panelId:c,onDeselect:()=>n({sizeSlug:"large"})},(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("Image size"),value:T,options:te,onChange:function(e){const t=D?.media_details?.sizes?.[e]?.source_url;if(!t)return null;n({url:t,sizeSlug:e,height:void 0,width:D?.media_details?.sizes?.[e]?.width||void 0})},className:"noptin-field-control"})):null,pe)))),de=(0,E.getFilename)(p);let ge;ge=m||(de?(0,ee.sprintf)(/* translators: %s: file name */ -(0,ee.__)("This image has an empty alt attribute; its file name is %s"),de):(0,ee.__)("This image has an empty alt attribute"));const _e=L.current?.width||X,he=ie&&q,be=(0,d.createElement)(fl,{href:b},he?(0,d.createElement)(B.__experimentalImageEditor,{id:h,url:p,width:N,height:M,clientWidth:_e,naturalHeight:le,naturalWidth:oe,onSaveImage:e=>n(e),onFinishEditing:()=>{Y(!1)}}):(0,d.createElement)(d.Fragment,null,(0,d.createElement)("img",{src:e||p,alt:ge,onLoad:e=>{K({loadedNaturalWidth:e.target?.naturalWidth,loadedNaturalHeight:e.target?.naturalHeight})},ref:L,style:{width:!x&&k?"auto":x,height:k,objectFit:w,maxWidth:"100%"}}),e&&(0,d.createElement)(C.Spinner,null)));return p||e?(0,d.createElement)(d.Fragment,null,!e&&me,be,z&&(!B.RichText.isEmpty(g)||a)&&(0,d.createElement)(B.RichText,{identifier:"caption",ref:re,className:"wp-block-image__caption",tagName:"div","aria-label":(0,ee.__)("Image caption text"),placeholder:(0,ee.__)("Add caption"),value:g,onChange:e=>n({caption:e}),inlineToolbar:!0,__unstableOnSplitAtEnd:()=>r((0,ne.createBlock)((0,ne.getDefaultBlockName)())),style:{fontSize:"12px",textAlign:A,marginTop:"12px"}})):(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Settings"),panelId:c,resetAll:ce},J&&pe))}const vl=(e,t)=>t&&!e&&!(0,dl.isBlobURL)(t);function El(e,t){var n,a;return"url"in(null!==(n=e?.sizes?.[t])&&void 0!==n?n:{})||"source_url"in(null!==(a=e?.media_details?.sizes?.[t])&&void 0!==a?a:{})}const xl={apiVersion:3,name:"core/image",title:(0,ee.__)("Image","newsletter-optin-box"),category:"content",description:(0,ee.__)("Insert an image to make a visual statement.","newsletter-optin-box"),keywords:["img","picture","media","photo"],attributes:{url:{type:"string",source:"attribute",selector:"img",attribute:"src",__experimentalRole:"content"},alt:{type:"string",source:"attribute",selector:"img",attribute:"alt",default:"",__experimentalRole:"content"},caption:{type:"string",source:"html",selector:".wp-block-image__caption",__experimentalRole:"content"},href:{type:"string",source:"attribute",selector:"a",attribute:"href",__experimentalRole:"content"},rel:{type:"string",source:"attribute",selector:"a",attribute:"rel"},linkClass:{type:"string",source:"attribute",selector:"a",attribute:"class"},id:{type:"number",__experimentalRole:"content"},width:{type:"string"},height:{type:"string"},scale:{type:"string"},sizeSlug:{type:"string",default:"large"},linkDestination:{type:"string"},link:{type:"string"}},supports:{anchor:!1,spacing:{__experimentalSkipSerialization:!0,margin:["top","bottom"],padding:!0,__experimentalDefaultControls:{margin:!0}}},noptin:{border:!0,align:!0},selectors:{border:".wp-block-image img, .wp-block-image .wp-block-image__crop-area, .wp-block-image .components-placeholder"}};function kl(e,t){const{body:n}=document.implementation.createHTMLDocument("");n.innerHTML=e;const{firstElementChild:a}=n;if(a&&"A"===a.nodeName)return a.getAttribute(t)||void 0}const wl={img:{attributes:["src","alt"],classes:["alignleft","aligncenter","alignright","alignnone",/^wp-image-\d+$/]}},Cl={from:[{type:"raw",isMatch:e=>"FIGURE"===e.nodeName&&!!e.querySelector("img"),schema:({phrasingContentSchema:e})=>({figure:{require:["img"],children:{...wl,a:{attributes:["href","rel"],children:wl},figcaption:{children:e}}}}),transform:e=>{const t=e.className+" "+e.querySelector("img").className,n=/(?:^|\s)align(left|center|right)(?:$|\s)/.exec(t),a=""===e.id?void 0:e.id,r=n?n[1]:void 0,o=/(?:^|\s)wp-image-(\d+)(?:$|\s)/.exec(t),l=o?Number(o[1]):void 0,i=e.querySelector("a"),s=i&&i.href?"custom":void 0,c=i&&i.href?i.href:void 0,u=i&&i.rel?i.rel:void 0,p=i&&i.className?i.className:void 0,m=(0,ne.getBlockAttributes)("core/image",e.outerHTML,{id:l,linkDestination:s,href:c,rel:u,linkClass:p,anchor:a,style:{noptin:{align:r}}});return(0,ne.createBlock)("core/image",m)}},{type:"shortcode",tag:"caption",attributes:{url:{type:"string",source:"attribute",attribute:"src",selector:"img"},alt:{type:"string",source:"attribute",attribute:"alt",selector:"img"},caption:{shortcode:function(e,{shortcode:t}){const{body:n}=document.implementation.createHTMLDocument("");n.innerHTML=t.content;let a=n.querySelector("img");for(;a&&a.parentNode&&a.parentNode!==n;)a=a.parentNode;return a&&a.parentNode.removeChild(a),n.innerHTML.trim()}},href:{shortcode:(e,{shortcode:t})=>kl(t.content,"href")},rel:{shortcode:(e,{shortcode:t})=>kl(t.content,"rel")},linkClass:{shortcode:(e,{shortcode:t})=>kl(t.content,"class")},id:{type:"number",shortcode:({named:{id:e}})=>{if(e)return parseInt(e.replace("attachment_",""),10)}}}}]},Sl=Cl;window?.wp?.media?.view?.settings?.defaultProps&&Object.entries(window.wp.media.view.settings.defaultProps).forEach((([e,t])=>{xl.attributes[e]&&(xl.attributes[e].default=t)}));const{name:Tl}=xl,Bl={icon:ml,example:{attributes:{sizeSlug:"large",url:"https://s.w.org/images/core/5.3/MtBlanc1.jpg", +(0,ee.__)("Level %s. Empty."),a):void 0},transforms:ll,merge:(e,t)=>({content:(e.content||"")+(t.content||"")}),edit:function({attributes:e,setAttributes:t,mergeBlocks:n,onReplace:a,clientId:r}){const{placeholder:o,content:l,level:i}=e,s=(0,B.useBlockProps)({style:{...Po(e),...Ao(e),...Wo(e),...Ho(e).style}});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(B.HeadingLevelDropdown,{value:i,onChange:e=>t({level:e})})),(0,d.createElement)(B.RichText,{identifier:"content",tagName:"h"+i,value:l,onChange:e=>{t({content:e})},onMerge:n,onSplit:(t,n)=>{let a;var o;return a=n||t?(0,ne.createBlock)("core/heading",{...e,content:t}):(0,ne.createBlock)(null!==(o=(0,ne.getDefaultBlockName)())&&void 0!==o?o:"core/heading"),n&&(a.clientId=r),a},onReplace:a,onRemove:()=>a([]),placeholder:o||(0,ee.__)("Enter heading..."),...s}))},save:function({attributes:e}){const{content:t,level:n}=e,a="h"+n,r=B.useBlockProps.save({style:{...Po(e),...Ao(e),...Wo.save(e),...Ho(e).style}});return(0,d.createElement)(a,{...r},(0,d.createElement)(B.RichText.Content,{value:t}))}},cl=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z"})),ul=window.wp.blob,pl=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M6 5.5h12a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5ZM4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6Zm4 10h2v-1.5H8V16Zm5 0h-2v-1.5h2V16Zm1 0h2v-1.5h-2V16Z"})),ml=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M16.5 7.8v7H18v-7c0-1-.8-1.8-1.8-1.8h-7v1.5h7c.2 0 .3.1.3.3zm-8.7 8.7c-.1 0-.2-.1-.2-.2V2H6v4H2v1.5h4v8.8c0 1 .8 1.8 1.8 1.8h8.8v4H18v-4h4v-1.5H7.8z"})),dl=(0,d.createElement)(de.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(de.Path,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})),gl=["image"],_l=({href:e,children:t})=>e?(0,d.createElement)("a",{href:e,onClick:e=>e.preventDefault(),"aria-disabled":!0,style:{pointerEvents:"none",cursor:"default",display:"block",textDecoration:"none",maxWidth:"100%",lineHeight:0}},t):t;function hl({temporaryURL:e,attributes:t,setAttributes:n,isSelected:a,insertBlocksAfter:r,onSelectImage:o,onSelectURL:l,onUploadError:i,containerRef:s,clientId:c,blockEditingMode:u}){const{url:p="",alt:m,caption:g,id:h,href:b,rel:f,linkClass:y,linkDestination:v,width:x,height:k,scale:w,sizeSlug:T}=t,A=jo(t),N=x?parseInt(x,10):void 0,M=k?parseInt(k,10):void 0,L=(0,S.useRef)(),R=(0,_.usePrevious)(g),[z,D]=(0,S.useState)(!!g),{image:$,multiImageSelection:V}=(0,P.useSelect)((e=>{const{getMedia:t}=e(I.store),{getMultiSelectedBlockClientIds:n,getBlockName:r}=e(B.store),o=n();return{image:h&&a?t(h,{context:"view"}):null,multiImageSelection:o.length&&o.every((e=>"core/image"===r(e)))}}),[h,a]),{imageEditing:F,imageSizes:H,mediaUpload:O}=(0,P.useSelect)((e=>{const{getSettings:t}=e(B.store),n=t();return{imageEditing:n.imageEditing,imageSizes:n.imageSizes,mediaUpload:n.mediaUpload}}),[c]),{createErrorNotice:j,createSuccessNotice:U}=(0,P.useDispatch)(Ua.store),[{loadedNaturalWidth:G,loadedNaturalHeight:W},K]=(0,S.useState)({loadedNaturalWidth:void 0,loadedNaturalHeight:void 0}),[q,Y]=(0,S.useState)(!1),[Z,Q]=(0,S.useState)(),X=function(e,t){const[n,a]=(0,S.useState)();function r(){a(e.current?.clientWidth)}return(0,S.useEffect)(r,t),(0,S.useEffect)((()=>{const{defaultView:t}=e.current.ownerDocument;return t.addEventListener("resize",r),()=>{t.removeEventListener("resize",r)}}),[]),n}(s,[A]),J="default"===u,te=H.filter((({slug:e})=>$?.media_details?.sizes?.[e]?.source_url)).map((({name:e,slug:t})=>({value:t,label:e}))),ae=!!O;(0,S.useEffect)((()=>{bl(h,p)&&a&&ae?Z||window.fetch(p.includes("?")?p:p+"?").then((e=>e.blob())).then((e=>Q(e))).catch((()=>{})):Q(void 0)}),[h,p,a,Z,ae]),(0,S.useEffect)((()=>{g&&!R&&D(!0)}),[g,R]);const re=(0,S.useCallback)((e=>{e&&!g&&e.focus()}),[g]),{naturalWidth:oe,naturalHeight:le}=(0,S.useMemo)((()=>({naturalWidth:L.current?.naturalWidth||G||void 0,naturalHeight:L.current?.naturalHeight||W||void 0})),[G,W,L.current?.complete]);(0,S.useEffect)((()=>{a||(Y(!1),g||D(!1))}),[a,g]);const ie=h&&oe&&le&&F,se=!V&&ie&&!q,ce=()=>{n({width:void 0,height:void 0,scale:void 0})},ue=(0,C.__experimentalUseCustomUnits)({availableUnits:["px"]}),pe=(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Width"),isShownByDefault:!0,hasValue:()=>!!x,onDeselect:()=>n({width:void 0}),panelId:c,style:{gridColumn:"span 1"}},(0,d.createElement)(B.__experimentalUnitControl,{label:(0,ee.__)("Width"),placeholder:(0,ee.__)("Auto"),labelPosition:"top",min:0,value:x||"",onChange:e=>n({width:e}),size:"__unstable-large"})),(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Height"),isShownByDefault:!0,hasValue:()=>!!k,onDeselect:()=>n({height:void 0}),panelId:c,style:{gridColumn:"span 1"}},(0,d.createElement)(B.__experimentalUnitControl,{label:(0,ee.__)("Height"),placeholder:(0,ee.__)("Auto"),labelPosition:"top",units:ue,min:0,value:k||"",onChange:e=>n({height:e}),size:"__unstable-large"}))),me=(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},J&&(0,d.createElement)(C.ToolbarButton,{onClick:()=>{D(!z),z&&g&&n({caption:void 0})},icon:pl,isPressed:z,label:z?(0,ee.__)("Remove caption"):(0,ee.__)("Add caption")}),!V&&!q&&(0,d.createElement)(B.__experimentalImageURLInputUI,{url:b||"",onChangeUrl:n,linkDestination:v,mediaUrl:$&&$.source_url||p,mediaLink:$&&$.link,linkClass:y,rel:f}),se&&(0,d.createElement)(C.ToolbarButton,{onClick:()=>Y(!0),icon:ml,label:(0,ee.__)("Crop")})),!V&&!q&&(0,d.createElement)(B.BlockControls,{group:"other"},(0,d.createElement)(B.MediaReplaceFlow,{mediaId:h,mediaURL:p,allowedTypes:gl,accept:"image/*",onSelect:o,onSelectURL:l,onError:i})),!V&&Z&&(0,d.createElement)(B.BlockControls,null,(0,d.createElement)(C.ToolbarGroup,null,(0,d.createElement)(C.ToolbarButton,{onClick:function(){O({filesList:[Z],onFileChange([e]){o(e),(0,ul.isBlobURL)(e.url)||(Q(void 0),U((0,ee.__)("Image uploaded."),{type:"snackbar"}))},allowedTypes:gl,onError(e){j(e,{type:"snackbar"})}})},icon:dl,label:(0,ee.__)("Upload external image")}))),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Settings"),panelId:c,resetAll:ce},!V&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Alternative text"),isShownByDefault:!0,hasValue:()=>""!==m,panelId:c,onDeselect:()=>n({alt:void 0})},(0,d.createElement)(C.TextareaControl,{label:(0,ee.__)("Alternative text"),value:m,onChange:e=>n({alt:e}),help:(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.ExternalLink,{href:"https://www.w3.org/WAI/tutorials/images/decision-tree"},(0,ee.__)("Describe the purpose of the image.")),(0,d.createElement)("br",null),(0,ee.__)("Leave empty if decorative.")),__nextHasNoMarginBottom:!0})),J&&(0,d.createElement)(d.Fragment,null,te.length>0?(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Image size"),isShownByDefault:!0,hasValue:()=>"large"!==T,panelId:c,onDeselect:()=>n({sizeSlug:"large"})},(0,d.createElement)(C.SelectControl,{label:(0,ee.__)("Image size"),value:T,options:te,onChange:function(e){const t=$?.media_details?.sizes?.[e]?.source_url;if(!t)return null;n({url:t,sizeSlug:e,height:void 0,width:$?.media_details?.sizes?.[e]?.width||void 0})},className:"noptin-field-control"})):null,pe)))),de=(0,E.getFilename)(p);let ge;ge=m||(de?(0,ee.sprintf)(/* translators: %s: file name */ +(0,ee.__)("This image has an empty alt attribute; its file name is %s"),de):(0,ee.__)("This image has an empty alt attribute"));const _e=L.current?.width||X,he=ie&&q,be=(0,d.createElement)(_l,{href:b},he?(0,d.createElement)(B.__experimentalImageEditor,{id:h,url:p,width:N,height:M,clientWidth:_e,naturalHeight:le,naturalWidth:oe,onSaveImage:e=>n(e),onFinishEditing:()=>{Y(!1)}}):(0,d.createElement)(d.Fragment,null,(0,d.createElement)("img",{src:e||p,alt:ge,onLoad:e=>{K({loadedNaturalWidth:e.target?.naturalWidth,loadedNaturalHeight:e.target?.naturalHeight})},ref:L,style:{width:!x&&k?"auto":x,height:k,objectFit:w,maxWidth:"100%"}}),e&&(0,d.createElement)(C.Spinner,null)));return p||e?(0,d.createElement)(d.Fragment,null,!e&&me,be,z&&(!B.RichText.isEmpty(g)||a)&&(0,d.createElement)(B.RichText,{identifier:"caption",ref:re,className:"wp-block-image__caption",tagName:"div","aria-label":(0,ee.__)("Image caption text"),placeholder:(0,ee.__)("Add caption"),value:g,onChange:e=>n({caption:e}),inlineToolbar:!0,__unstableOnSplitAtEnd:()=>r((0,ne.createBlock)((0,ne.getDefaultBlockName)())),style:{fontSize:"12px",textAlign:A,marginTop:"12px"}})):(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Settings"),panelId:c,resetAll:ce},J&&pe))}const bl=(e,t)=>t&&!e&&!(0,ul.isBlobURL)(t);function fl(e,t){var n,a;return"url"in(null!==(n=e?.sizes?.[t])&&void 0!==n?n:{})||"source_url"in(null!==(a=e?.media_details?.sizes?.[t])&&void 0!==a?a:{})}const yl={apiVersion:3,name:"core/image",title:(0,ee.__)("Image","newsletter-optin-box"),category:"content",description:(0,ee.__)("Insert an image to make a visual statement.","newsletter-optin-box"),keywords:["img","picture","media","photo"],attributes:{url:{type:"string",source:"attribute",selector:"img",attribute:"src",__experimentalRole:"content"},alt:{type:"string",source:"attribute",selector:"img",attribute:"alt",default:"",__experimentalRole:"content"},caption:{type:"string",source:"html",selector:".wp-block-image__caption",__experimentalRole:"content"},href:{type:"string",source:"attribute",selector:"a",attribute:"href",__experimentalRole:"content"},rel:{type:"string",source:"attribute",selector:"a",attribute:"rel"},linkClass:{type:"string",source:"attribute",selector:"a",attribute:"class"},id:{type:"number",__experimentalRole:"content"},width:{type:"string"},height:{type:"string"},scale:{type:"string"},sizeSlug:{type:"string",default:"large"},linkDestination:{type:"string"},link:{type:"string"}},supports:{anchor:!1,spacing:{__experimentalSkipSerialization:!0,margin:["top","bottom"],padding:!0,__experimentalDefaultControls:{margin:!0}}},noptin:{border:!0,align:!0},selectors:{border:".wp-block-image img, .wp-block-image .wp-block-image__crop-area, .wp-block-image .components-placeholder"}};function vl(e,t){const{body:n}=document.implementation.createHTMLDocument("");n.innerHTML=e;const{firstElementChild:a}=n;if(a&&"A"===a.nodeName)return a.getAttribute(t)||void 0}const El={img:{attributes:["src","alt"],classes:["alignleft","aligncenter","alignright","alignnone",/^wp-image-\d+$/]}},xl={from:[{type:"raw",isMatch:e=>"FIGURE"===e.nodeName&&!!e.querySelector("img"),schema:({phrasingContentSchema:e})=>({figure:{require:["img"],children:{...El,a:{attributes:["href","rel"],children:El},figcaption:{children:e}}}}),transform:e=>{const t=e.className+" "+e.querySelector("img").className,n=/(?:^|\s)align(left|center|right)(?:$|\s)/.exec(t),a=""===e.id?void 0:e.id,r=n?n[1]:void 0,o=/(?:^|\s)wp-image-(\d+)(?:$|\s)/.exec(t),l=o?Number(o[1]):void 0,i=e.querySelector("a"),s=i&&i.href?"custom":void 0,c=i&&i.href?i.href:void 0,u=i&&i.rel?i.rel:void 0,p=i&&i.className?i.className:void 0,m=(0,ne.getBlockAttributes)("core/image",e.outerHTML,{id:l,linkDestination:s,href:c,rel:u,linkClass:p,anchor:a,style:{noptin:{align:r}}});return(0,ne.createBlock)("core/image",m)}},{type:"shortcode",tag:"caption",attributes:{url:{type:"string",source:"attribute",attribute:"src",selector:"img"},alt:{type:"string",source:"attribute",attribute:"alt",selector:"img"},caption:{shortcode:function(e,{shortcode:t}){const{body:n}=document.implementation.createHTMLDocument("");n.innerHTML=t.content;let a=n.querySelector("img");for(;a&&a.parentNode&&a.parentNode!==n;)a=a.parentNode;return a&&a.parentNode.removeChild(a),n.innerHTML.trim()}},href:{shortcode:(e,{shortcode:t})=>vl(t.content,"href")},rel:{shortcode:(e,{shortcode:t})=>vl(t.content,"rel")},linkClass:{shortcode:(e,{shortcode:t})=>vl(t.content,"class")},id:{type:"number",shortcode:({named:{id:e}})=>{if(e)return parseInt(e.replace("attachment_",""),10)}}}}]},kl=xl;window?.wp?.media?.view?.settings?.defaultProps&&Object.entries(window.wp.media.view.settings.defaultProps).forEach((([e,t])=>{yl.attributes[e]&&(yl.attributes[e].default=t)}));const{name:wl}=yl,Cl={icon:cl,example:{attributes:{sizeSlug:"large",url:"https://s.w.org/images/core/5.3/MtBlanc1.jpg", // translators: Caption accompanying an image of the Mont Blanc, which serves as an example for the Image block. -caption:(0,ee.__)("Mont Blanc appears—still, snowy, and serene.")}},__experimentalLabel(e,{context:t}){if("accessibility"===t){const{caption:t,alt:n,url:a}=e;return a?n?n+(t?". "+t:""):t||"":(0,ee.__)("Empty")}},transforms:Sl,edit:function({attributes:e,setAttributes:t,isSelected:n,className:a,insertBlocksAfter:r,onReplace:o,context:l,clientId:i}){const{url:s="",alt:c,caption:u,id:p,width:m,height:g,sizeSlug:_}=e,[h,f]=(0,S.useState)(),y=Wo(e),v=(0,S.useRef)();(0,S.useEffect)((()=>{v.current=c}),[c]);const E=(0,S.useRef)();(0,S.useEffect)((()=>{E.current=u}),[u]);const x=(0,S.useRef)(),{mediaUpload:k}=(0,P.useSelect)((e=>{const{getSettings:t}=e(B.store);return{mediaUpload:t().mediaUpload}}),[]),w=(0,B.useBlockEditingMode)(),{createErrorNotice:T}=(0,P.useDispatch)(Ua.store);function I(e){T(e,{type:"snackbar"}),t({src:void 0,id:void 0,url:void 0}),f(void 0)}function A(n){if(!n||!n.url)return void t({url:void 0,alt:void 0,id:void 0,caption:void 0});if((0,dl.isBlobURL)(n.url))return void f(n.url);f(void 0);let a="full";_&&El(n,_)?a=_:El(n,"large")&&(a="large");let r,o=((e,t)=>{const n=Object.fromEntries(Object.entries(null!=e?e:{}).filter((([e])=>["alt","id","link","caption","width","url"].includes(e)))),a=["width","url"];return e?.sizes?.[t]?a.forEach((a=>{e.sizes[t][a]&&(n[a]=e.sizes[t][a])})):e?.media_details?.sizes?.[t]&&a.forEach((a=>{e.media_details.sizes[t][a]?n[a]=e.media_details.sizes[t][a]:e.media_details.sizes[t][`source_${a}`]&&(n[a]=e.media_details.sizes[t][`source_${a}`])})),n.height=void 0,n})(n,a);if(E.current&&!o.caption){const{caption:e,...t}=o;o=t}r=n.id&&n.id===p?{url:s}:{sizeSlug:a};let l,i=e.linkDestination;switch(i){case"file":l=n.url;break;case"post":l=n.link}o.href=l,t({...o,...r,linkDestination:i})}function N(e){e!==s&&t({url:e,id:void 0,sizeSlug:"large"})}let M=((e,t)=>!e&&(0,dl.isBlobURL)(t))(p,s);(0,S.useEffect)((()=>{if(!M)return;const e=(0,dl.getBlobByURL)(s);e&&k({filesList:[e],onFileChange:([e])=>{A(e)},allowedTypes:bl,onError:e=>{M=!1,I(e)}})}),[]),(0,S.useEffect)((()=>{M?f(s):(0,dl.revokeBlobURL)(h)}),[M,s]);const L=vl(p,s)?s:void 0,R=s?(0,d.createElement)("img",{alt:(0,ee.__)("Edit image"),title:(0,ee.__)("Edit image"),className:"edit-image-preview",src:s}):void 0,z=b()(a,{"is-transient":h}),$=(0,B.useBlockProps)({ref:x,style:{borderSpacing:"0px",borderCollapse:"collapse",width:"100%"},className:z,border:0,cellPadding:"0",cellSpacing:"0",role:"presentation"}),D={...Lo(e),...Yo(e),width:e.width||void 0,display:"inline-block",maxWidth:"100%"};return(0,d.createElement)("table",{...$},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:y,className:b()({"is-selected":n})},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:D},(0,d.createElement)(yl,{temporaryURL:h,attributes:e,setAttributes:t,isSelected:n,insertBlocksAfter:r,onReplace:o,onSelectImage:A,onSelectURL:N,onUploadError:I,containerRef:x,context:l,clientId:i,blockEditingMode:w}),(0,d.createElement)(B.MediaPlaceholder,{icon:(0,d.createElement)(B.BlockIcon,{icon:ml}),onSelect:A,onSelectURL:N,onError:I,placeholder:e=>(0,d.createElement)(C.Placeholder,{className:"block-editor-media-placeholder",withIllustration:!0,icon:ml,label:(0,ee.__)("Image"),instructions:(0,ee.__)("Upload an image file, pick one from your media library, or add one with a URL."),style:{width:m,height:g}},e),accept:"image/*",allowedTypes:["image"],value:{id:p,src:L},mediaPreview:R,disableMediaButtons:h||s}))))))},save:function({attributes:e}){const{url:t,alt:n,caption:a,href:r,rel:o,linkClass:l,width:i,height:s}=e,c=Wo(e),u=(0,d.createElement)("img",{src:t,alt:n,style:{width:!i&&s?"auto":i,height:s,maxWidth:"100%"}}),p={...Lo(e),...Yo.save(e),width:i||void 0,display:"inline-block",maxWidth:"100%"},m=(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:p},r?(0,d.createElement)("a",{className:l,href:r,rel:o||void 0,style:{display:"block",textDecoration:"none",maxWidth:"100%",lineHeight:0}},u):u,!B.RichText.isEmpty(a)&&(0,d.createElement)(B.RichText.Content,{className:"wp-block-image__caption",tagName:"div",value:a,style:{fontSize:"12px",textAlign:"center",marginTop:"12px"}})),g=B.useBlockProps.save({style:{borderSpacing:"0px",borderCollapse:"collapse",width:"100%"},border:0,cellPadding:"0",cellSpacing:"0",role:"presentation"});return(0,d.createElement)("table",{...g},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:c},m))))}};function Pl(e){return e.replace(/<\/?a[^>]*>/g,"")}function Il({attributes:e,setAttributes:t}){return(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(B.URLInput,{label:(0,ee.__)("Button URL"),help:(0,ee.__)("The URL to link to."),className:"block-editor-link-control__field noptin-link-control__field",value:e.url||"",hasBorder:!0,isFullWidth:!0,onChange:e=>t({url:e})}),(0,d.createElement)(C.__experimentalToggleGroupControl,{label:(0,ee.__)("Button width"),className:"noptin-toggle-group-control",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isAdaptiveWidth:!0,isBlock:!0,isDeselectable:!0,onChange:function(n){const a=e.width===n?void 0:n;t({width:a})}},[25,50,75,100].map((e=>(0,d.createElement)(C.__experimentalToggleGroupControlOption,{key:e,label:`${e}%`,value:e})))))}const Al={apiVersion:3,name:"noptin/button",title:(0,ee.__)("Button","newsletter-optin-box"),category:"content",description:(0,ee.__)("Prompt readers to take action with a button-style link.","newsletter-optin-box"),keywords:["link","cta"],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href",__experimentalRole:"content"},title:{type:"string",source:"attribute",selector:"a",attribute:"title",__experimentalRole:"content"},text:{type:"string",source:"html",selector:"a",__experimentalRole:"content"},rel:{type:"string",source:"attribute",selector:"a",attribute:"rel",__experimentalRole:"content",default:"noopener noreferrer"},placeholder:{type:"string"},style:{type:"object",default:{noptin:{border:{radius:"5px"},typography:{textTransform:"none",textDecoration:"none",textAlign:"center"}}}},width:{type:"string"}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0},align:!0},supports:{anchor:!1,reusable:!1,shadow:!1,spacing:{__experimentalSkipSerialization:!0,padding:["horizontal","vertical"],margin:!0,__experimentalDefaultControls:{padding:!0,margin:!0}}}},{name:Nl}=Al,Ml={icon:"button",example:{attributes:{text:(0,ee.__)("Call to Action")}},edit:function(e){const{attributes:t,setAttributes:n,isSelected:a,onReplace:r,mergeBlocks:o,clientId:l}=e,{placeholder:i,rel:s,text:c,width:u}=t,p=Wo(t),m=No(t),[g,h]=(0,S.useState)(null),b=Lo(t),f=Uo(t).style,y=Yo(t,!0),v=(0,S.useRef)(),E=(0,S.useRef)(),x=(0,B.useBlockProps)({ref:(0,_.useMergeRefs)([h,v]),width:"100%",border:0,cellPadding:0,cellSpacing:0,role:"presentation",style:{lineHeight:"100%",width:"100%",borderCollapse:"separate",margin:"0px"}}),[k,w]=(0,S.useState)(!0);(0,S.useEffect)((()=>{a&&w(!0)}),[a]);const T=function(e){const{replaceBlocks:t,selectionChange:n}=(0,P.useDispatch)(B.store),{getBlock:a,getBlockRootClientId:r,getBlockIndex:o}=(0,P.useSelect)(B.store),l=(0,S.useRef)(e);return l.current=e,(0,_.useRefEffect)((e=>{function i(e){if(e.defaultPrevented||e.keyCode!==St.ENTER)return;const{content:i,clientId:s}=l.current;if(i.length)return;e.preventDefault();const c=a(r(s)),u=o(s),p=(0,ne.cloneBlock)({...c,innerBlocks:c.innerBlocks.slice(0,u)}),m=(0,ne.createBlock)((0,ne.getDefaultBlockName)()),d=c.innerBlocks.slice(u+1),g=d.length?[(0,ne.cloneBlock)({...c,innerBlocks:d})]:[];t(c.clientId,[p,m,...g],1),n(m.clientId)}return e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i)}}),[])}({content:c,clientId:l}),I=(0,_.useMergeRefs)([T,E]);return(0,d.createElement)(d.Fragment,null,(0,d.createElement)("table",{...x},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:p},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:y.margin},(0,d.createElement)("table",{width:u?`${u}%`:void 0},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{bgcolor:f.backgroundColor,role:"presentation",valign:"middle",className:"noptin-button-link__wrapper",style:{background:f.backgroundColor,textAlign:m?.textAlign,cursor:"auto",...b}},(0,d.createElement)(B.RichText,{ref:I,tagName:"span","aria-label":(0,ee.__)("Button text"),placeholder:i||(0,ee.__)("Add text…"),value:c,onChange:e=>n({text:Pl(e)}),withoutInteractiveFormatting:!0,className:"noptin-button-link",style:{...y.padding,...m||{},color:f.color,margin:"0px",display:"block",wordBreak:"break-word"},onSplit:e=>(0,ne.createBlock)("noptin/button",{...t,text:e}),onReplace:r,onMerge:o,identifier:"text"})))))))))),a&&k&&(0,d.createElement)(C.Popover,{placement:"bottom",onClose:()=>{w(!1),E.current?.focus()},anchor:g,focusOnMount:!1,__unstableSlotName:"__unstable-block-tools-after",shift:!0},(0,d.createElement)(B.URLInput,{label:(0,ee.__)("Button URL"),help:(0,ee.__)("The URL to link to."),className:"block-editor-link-control__field noptin-link-control-popover__field",value:t.url||"",onChange:e=>n({url:e})})),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(Il,{attributes:t,setAttributes:n})),(0,d.createElement)(B.InspectorControls,{group:"advanced"},(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Link rel"),value:s||"",onChange:e=>n({rel:e})})))},save:function({attributes:e}){const{rel:t,text:n,title:a,url:r,width:o}=e,l=Wo(e),i=Lo(e),s=Uo(e),c=s?.style?.backgroundColor,u=s?.style?.color,p=Yo.save(e,!0),m={...p.padding,...No(e),borderRadius:i?.borderRadius,margin:"0px",display:"block",color:u,wordBreak:"break-word"},g=B.useBlockProps.save({width:"100%",border:0,cellPadding:0,cellSpacing:0,role:"presentation",style:{lineHeight:"100%",width:"100%",borderCollapse:"separate",margin:"0px"}});return n?(0,d.createElement)("table",{...g},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:l},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:p.margin},(0,d.createElement)("table",{width:o?`${o}%`:void 0},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{bgcolor:c,role:"presentation",valign:"middle",className:"noptin-button-link__wrapper",style:{background:c,textAlign:m.textAlign,cursor:"auto",...i}},(0,d.createElement)(B.RichText.Content,{tagName:"a",className:"noptin-button-link",href:r,title:a,style:m,value:n,rel:t})))))))))):null},merge:(e,{text:t=""})=>({...e,text:(e.text||"")+t})},Ll=["noptin/social-link"],Rl=[{name:"facebook",color:"#3b5998",title:"Facebook"},{name:"twitter",color:"#55acee",title:"Twitter"},{name:"youtube",color:"#eb3323",title:"YouTube"}],zl=Rl.map((({name:e,title:t,color:n})=>["noptin/social-link",{img:`https://www.mailjet.com/images/theme/v1/icons/ico-social/${e}.png`,url:"#",label:t,style:{noptin:{border:{radius:"50%"},color:{background:n}}}}])),$l={iconSize:{label:(0,ee.__)("Icon size"),options:{"20px":(0,ee.__)("S"),"32px":(0,ee.__)("M"),"48px":(0,ee.__)("L"),"64px":(0,ee.__)("XL")}},iconSpacing:{label:(0,ee.__)("Icon spacing"),options:{"0px":(0,ee.__)("None"),"4px":(0,ee.__)("S"),"16px":(0,ee.__)("M"),"24px":(0,ee.__)("L")}},iconPadding:{label:(0,ee.__)("Icon padding"),options:{"0px":(0,ee.__)("None"),"4px":(0,ee.__)("S"),"16px":(0,ee.__)("M"),"24px":(0,ee.__)("L")}}};function Dl({attributes:e,setAttributes:t}){return(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Icon settings")},Object.entries($l).map((([n,a])=>(0,d.createElement)(C.__experimentalToggleGroupControl,{key:n,label:a.label,value:e[n],onChange:e=>t({[n]:e}),className:"noptin-field-control",__nextHasNoMarginBottom:!0,isAdaptiveWidth:!0,isBlock:!0,isDeselectable:!0},Object.entries(a.options).map((([e,t])=>(0,d.createElement)(C.__experimentalToggleGroupControlOption,{key:`${n}__${e}`,label:t,value:e})))))))}const Vl={apiVersion:3,name:"noptin/social-links",title:(0,ee.__)("Social Icons","newsletter-optin-box"),category:"content",description:(0,ee.__)("Display icons linking to your social media profiles or sites.","newsletter-optin-box"),keywords:["links"],attributes:{iconSize:{type:"string",default:"20px"},iconSpacing:{type:"string",default:"4px"},iconPadding:{type:"string",default:"4px"}},providesContext:{"noptin/social-links/iconSize":"iconSize"},noptin:{border:!0,color:{background:!0},align:!0},supports:{anchor:!1,__experimentalExposeControlsToChildren:!0,spacing:{margin:!0,padding:!0,units:["px","em","rem"],__experimentalSkipSerialization:!0,__experimentalDefaultControls:{margin:!0,padding:!1}}}},{name:Fl}=Vl,Ol={example:{innerBlocks:Rl.map((({name:e,title:t,color:n})=>({name:"noptin/social-link",attributes:{img:`https://www.mailjet.com/images/theme/v1/icons/ico-social/${e}.png`,url:"#",label:t,style:{noptin:{border:{radius:"50%"},color:{background:n}}}}})))},icon:"share",edit:function({attributes:e,setAttributes:t}){const{iconSpacing:n,iconPadding:a}=e,r=Wo(e),o=Yo(e,!0),l=Lo(e),i=(0,B.useBlockProps)({style:o.margin,className:"noptin-block__margin-wrapper"}),s=(0,B.useInnerBlocksProps)({},{allowedBlocks:Ll,template:zl,templateLock:!1,orientation:"horizontal",__experimentalAppenderTagName:"td"}),c={lineHeight:"100%",width:"100%",borderCollapse:"separate",...Uo(e).style,...l};return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(Dl,{attributes:e,setAttributes:t})),(0,d.createElement)("div",{...i},(0,d.createElement)("table",{role:"presentation",cellPadding:0,cellSpacing:0,border:0,width:"100%",style:c},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:r,style:o.padding,border:"0",role:"presentation",valign:"middle"},(0,d.createElement)("table",{align:r,cellPadding:a||0,cellSpacing:n||0,style:{borderCollapse:"separate"}},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",{...s})))))))))},save:({attributes:e})=>{const{iconSpacing:t,iconPadding:n}=e,a=Wo(e),r=Yo.save(e,!0),o=Lo(e),l=B.useBlockProps.save({style:r.margin,className:"noptin-block__margin-wrapper"}),i={lineHeight:"100%",width:"100%",borderCollapse:"separate",...Uo(e).style,...o};return(0,d.createElement)("div",{...l},(0,d.createElement)("table",{role:"presentation",cellPadding:0,cellSpacing:0,border:0,width:"100%",style:i},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:a,style:r.padding,border:"0",role:"presentation",valign:"middle"},(0,d.createElement)("table",{align:a,cellPadding:n||0,cellSpacing:t||0,style:{borderCollapse:"separate"}},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)(B.InnerBlocks.Content,null)))))))))}},Hl={apiVersion:3,name:"noptin/social-link",title:(0,ee.__)("Social Icon","newsletter-optin-box"),category:"content",parent:["noptin/social-links"],description:(0,ee.__)("Display an icon linking to a social media profile or site.","newsletter-optin-box"),attributes:{iconSize:{type:"string",default:"20px"},url:{type:"string"},img:{type:"string"},label:{type:"string"},rel:{type:"string",default:"noopener noreferrer"}},usesContext:["noptin/social-links/iconSize"],noptin:{border:!0,color:{background:!0}},supports:{reusable:!1,anchor:!1,html:!1}},jl=[{name:"facebook",color:"#3b5998",title:"Facebook"},{name:"twitter",color:"#55acee",title:"Twitter"},{name:"google-plus",color:"#dc4e41",title:"Google Plus",icon:"google"},{name:"pinterest",color:"#bd081c",title:"Pinterest"},{name:"linkedin",color:"#0077b5",title:"linkedIn"},{name:"instagram",color:"#3f729b",title:"Instagram"},{name:"youtube",color:"#eb3323",title:"YouTube"},{name:"tumblr",color:"#344356",title:"Tumblr",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M17.04 21.28h-3.28c-2.84 0-4.94-1.37-4.94-5.02v-5.67H6.08V7.5c2.93-.73 4.11-3.3 4.3-5.48h3.01v4.93h3.47v3.65H13.4v4.93c0 1.47.73 2.01 1.92 2.01h1.73v3.75z"}))},{name:"github",color:"#000000",title:"GitHub",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"}))},{name:"xing",color:"#296366",title:"Xing"},{name:"vimeo",color:"#53B4E7",title:"Vimeo",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M22.396,7.164c-0.093,2.026-1.507,4.799-4.245,8.32C15.322,19.161,12.928,21,10.97,21c-1.214,0-2.24-1.119-3.079-3.359 c-0.56-2.053-1.119-4.106-1.68-6.159C5.588,9.243,4.921,8.122,4.206,8.122c-0.156,0-0.701,0.328-1.634,0.98L1.594,7.841 c1.027-0.902,2.04-1.805,3.037-2.708C6.001,3.95,7.03,3.327,7.715,3.264c1.619-0.156,2.616,0.951,2.99,3.321 c0.404,2.557,0.685,4.147,0.841,4.769c0.467,2.121,0.981,3.181,1.542,3.181c0.435,0,1.09-0.688,1.963-2.065 c0.871-1.376,1.338-2.422,1.401-3.142c0.125-1.187-0.343-1.782-1.401-1.782c-0.498,0-1.012,0.115-1.541,0.341 c1.023-3.35,2.977-4.977,5.862-4.884C21.511,3.066,22.52,4.453,22.396,7.164z"}))},{name:"medium",color:"#000000",title:"Medium",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M20.962,7.257l-5.457,8.867l-3.923-6.375l3.126-5.08c0.112-0.182,0.319-0.286,0.527-0.286c0.05,0,0.1,0.008,0.149,0.02 c0.039,0.01,0.078,0.023,0.114,0.041l5.43,2.715l0.006,0.003c0.004,0.002,0.007,0.006,0.011,0.008 C20.971,7.191,20.98,7.227,20.962,7.257z M9.86,8.592v5.783l5.14,2.57L9.86,8.592z M15.772,17.331l4.231,2.115 C20.554,19.721,21,19.529,21,19.016V8.835L15.772,17.331z M8.968,7.178L3.665,4.527C3.569,4.479,3.478,4.456,3.395,4.456 C3.163,4.456,3,4.636,3,4.938v11.45c0,0.306,0.224,0.669,0.498,0.806l4.671,2.335c0.12,0.06,0.234,0.088,0.337,0.088 c0.29,0,0.494-0.225,0.494-0.602V7.231C9,7.208,8.988,7.188,8.968,7.178z"}))},{name:"soundcloud",color:"#EF7F31",title:"SoundCloud",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M8.9,16.1L9,14L8.9,9.5c0-0.1,0-0.1-0.1-0.1c0,0-0.1-0.1-0.1-0.1c-0.1,0-0.1,0-0.1,0.1c0,0-0.1,0.1-0.1,0.1L8.3,14l0.1,2.1 c0,0.1,0,0.1,0.1,0.1c0,0,0.1,0.1,0.1,0.1C8.8,16.3,8.9,16.3,8.9,16.1z M11.4,15.9l0.1-1.8L11.4,9c0-0.1,0-0.2-0.1-0.2 c0,0-0.1,0-0.1,0s-0.1,0-0.1,0c-0.1,0-0.1,0.1-0.1,0.2l0,0.1l-0.1,5c0,0,0,0.7,0.1,2v0c0,0.1,0,0.1,0.1,0.1c0.1,0.1,0.1,0.1,0.2,0.1 c0.1,0,0.1,0,0.2-0.1c0.1,0,0.1-0.1,0.1-0.2L11.4,15.9z M2.4,12.9L2.5,14l-0.2,1.1c0,0.1,0,0.1-0.1,0.1c0,0-0.1,0-0.1-0.1L2.1,14 l0.1-1.1C2.2,12.9,2.3,12.9,2.4,12.9C2.3,12.9,2.4,12.9,2.4,12.9z M3.1,12.2L3.3,14l-0.2,1.8c0,0.1,0,0.1-0.1,0.1 c-0.1,0-0.1,0-0.1-0.1L2.8,14L3,12.2C3,12.2,3,12.2,3.1,12.2C3.1,12.2,3.1,12.2,3.1,12.2z M3.9,11.9L4.1,14l-0.2,2.1 c0,0.1,0,0.1-0.1,0.1c-0.1,0-0.1,0-0.1-0.1L3.5,14l0.2-2.1c0-0.1,0-0.1,0.1-0.1C3.9,11.8,3.9,11.8,3.9,11.9z M4.7,11.9L4.9,14 l-0.2,2.1c0,0.1-0.1,0.1-0.1,0.1c-0.1,0-0.1,0-0.1-0.1L4.3,14l0.2-2.2c0-0.1,0-0.1,0.1-0.1C4.7,11.7,4.7,11.8,4.7,11.9z M5.6,12 l0.2,2l-0.2,2.1c0,0.1-0.1,0.1-0.1,0.1c0,0-0.1,0-0.1,0c0,0,0-0.1,0-0.1L5.1,14l0.2-2c0,0,0-0.1,0-0.1s0.1,0,0.1,0 C5.5,11.9,5.5,11.9,5.6,12L5.6,12z M6.4,10.7L6.6,14l-0.2,2.1c0,0,0,0.1,0,0.1c0,0-0.1,0-0.1,0c-0.1,0-0.1-0.1-0.2-0.2L5.9,14 l0.2-3.3c0-0.1,0.1-0.2,0.2-0.2c0,0,0.1,0,0.1,0C6.4,10.7,6.4,10.7,6.4,10.7z M7.2,10l0.2,4.1l-0.2,2.1c0,0,0,0.1,0,0.1 c0,0-0.1,0-0.1,0c-0.1,0-0.2-0.1-0.2-0.2l-0.1-2.1L6.8,10c0-0.1,0.1-0.2,0.2-0.2c0,0,0.1,0,0.1,0S7.2,9.9,7.2,10z M8,9.6L8.2,14 L8,16.1c0,0.1-0.1,0.2-0.2,0.2c-0.1,0-0.2-0.1-0.2-0.2L7.5,14l0.1-4.4c0-0.1,0-0.1,0.1-0.1c0,0,0.1-0.1,0.1-0.1c0.1,0,0.1,0,0.1,0.1 C8,9.6,8,9.6,8,9.6z M11.4,16.1L11.4,16.1L11.4,16.1z M9.7,9.6L9.8,14l-0.1,2.1c0,0.1,0,0.1-0.1,0.2s-0.1,0.1-0.2,0.1 c-0.1,0-0.1,0-0.1-0.1s-0.1-0.1-0.1-0.2L9.2,14l0.1-4.4c0-0.1,0-0.1,0.1-0.2s0.1-0.1,0.2-0.1c0.1,0,0.1,0,0.2,0.1S9.7,9.5,9.7,9.6 L9.7,9.6z M10.6,9.8l0.1,4.3l-0.1,2c0,0.1,0,0.1-0.1,0.2c0,0-0.1,0.1-0.2,0.1c-0.1,0-0.1,0-0.2-0.1c0,0-0.1-0.1-0.1-0.2L10,14 l0.1-4.3c0-0.1,0-0.1,0.1-0.2c0,0,0.1-0.1,0.2-0.1c0.1,0,0.1,0,0.2,0.1S10.6,9.7,10.6,9.8z M12.4,14l-0.1,2c0,0.1,0,0.1-0.1,0.2 c-0.1,0.1-0.1,0.1-0.2,0.1c-0.1,0-0.1,0-0.2-0.1c-0.1-0.1-0.1-0.1-0.1-0.2l-0.1-1l-0.1-1l0.1-5.5v0c0-0.1,0-0.2,0.1-0.2 c0.1,0,0.1-0.1,0.2-0.1c0,0,0.1,0,0.1,0c0.1,0,0.1,0.1,0.1,0.2L12.4,14z M22.1,13.9c0,0.7-0.2,1.3-0.7,1.7c-0.5,0.5-1.1,0.7-1.7,0.7 h-6.8c-0.1,0-0.1,0-0.2-0.1c-0.1-0.1-0.1-0.1-0.1-0.2V8.2c0-0.1,0.1-0.2,0.2-0.3c0.5-0.2,1-0.3,1.6-0.3c1.1,0,2.1,0.4,2.9,1.1 c0.8,0.8,1.3,1.7,1.4,2.8c0.3-0.1,0.6-0.2,1-0.2c0.7,0,1.3,0.2,1.7,0.7C21.8,12.6,22.1,13.2,22.1,13.9L22.1,13.9z"}))},{name:"dribbble",color:"#D95988",title:"Dribbble",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M12,22C6.486,22,2,17.514,2,12S6.486,2,12,2c5.514,0,10,4.486,10,10S17.514,22,12,22z M20.434,13.369 c-0.292-0.092-2.644-0.794-5.32-0.365c1.117,3.07,1.572,5.57,1.659,6.09C18.689,17.798,20.053,15.745,20.434,13.369z M15.336,19.876c-0.127-0.749-0.623-3.361-1.822-6.477c-0.019,0.006-0.038,0.013-0.056,0.019c-4.818,1.679-6.547,5.02-6.701,5.334 c1.448,1.129,3.268,1.803,5.243,1.803C13.183,20.555,14.311,20.313,15.336,19.876z M5.654,17.724 c0.193-0.331,2.538-4.213,6.943-5.637c0.111-0.036,0.224-0.07,0.337-0.102c-0.214-0.485-0.448-0.971-0.692-1.45 c-4.266,1.277-8.405,1.223-8.778,1.216c-0.003,0.087-0.004,0.174-0.004,0.261C3.458,14.207,4.29,16.21,5.654,17.724z M3.639,10.264 c0.382,0.005,3.901,0.02,7.897-1.041c-1.415-2.516-2.942-4.631-3.167-4.94C5.979,5.41,4.193,7.613,3.639,10.264z M9.998,3.709 c0.236,0.316,1.787,2.429,3.187,5c3.037-1.138,4.323-2.867,4.477-3.085C16.154,4.286,14.17,3.471,12,3.471 C11.311,3.471,10.641,3.554,9.998,3.709z M18.612,6.612C18.432,6.855,17,8.69,13.842,9.979c0.199,0.407,0.389,0.821,0.567,1.237 c0.063,0.148,0.124,0.295,0.184,0.441c2.842-0.357,5.666,0.215,5.948,0.275C20.522,9.916,19.801,8.065,18.612,6.612z"}))}].map((({name:e,title:t,color:n,icon:a})=>{return{isDefault:"facebook"===e,name:e,title:t,attributes:(r=`https://www.mailjet.com/images/theme/v1/icons/ico-social/${e}.png`,o=t,l=n,{img:r,label:o,style:{noptin:{border:{radius:"50%"},color:{background:l}}}}),icon:a||e,isActive:(t,n)=>t.img&&t.img.includes(e)||t.label&&t.label.includes(e)||t.url&&t.url.includes(e)};var r,o,l})),{name:Ul}=Hl,Gl={icon:"share",edit:({attributes:e,context:t,setAttributes:n,isSelected:a})=>{const{img:r,label:o,rel:l,iconSize:i}=e,[s,c]=(0,d.useState)(!0),[u,p]=(0,d.useState)(null),m=t["noptin/social-links/iconSize"];(0,d.useEffect)((()=>{i!==m&&n({iconSize:m})}),[m,i]),(0,d.useEffect)((()=>{a&&c(!0)}),[a]);const g=Uo(e),_=g?.style?.backgroundColor,h=(0,B.useBlockProps)({ref:p,style:{color:_,backgroundColor:_,boxSizing:"border-box",align:"center",borderCollapse:"separate",...Lo(e)}});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings"),initialOpen:!0},(0,d.createElement)(C.PanelRow,null,(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Image URL"),help:(0,ee.__)("Enter the URL of the image to use as an icon."),value:r||"",onChange:e=>n({img:e})})),(0,d.createElement)(C.PanelRow,null,(0,d.createElement)(B.URLInput,{label:(0,ee.__)("Social URL"),help:(0,ee.__)("The URL to link to."),className:"block-editor-link-control__field noptin-link-control__field",value:e.url||"",hasBorder:!0,isFullWidth:!0,onChange:e=>n({url:e})})),(0,d.createElement)(C.PanelRow,null,(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Social Network"),help:(0,ee.__)("The name of the social network."),value:o||"",onChange:e=>n({label:e})})))),(0,d.createElement)(B.InspectorControls,{group:"advanced"},(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Link rel"),value:l||"",onChange:e=>n({rel:e})})),a&&s&&(0,d.createElement)(C.Popover,{placement:"bottom",onClose:()=>{c(!1)},anchor:u,focusOnMount:!1,__unstableSlotName:"__unstable-block-tools-after",shift:!0},(0,d.createElement)(B.URLInput,{label:(0,ee.__)("Social URL"),help:(0,ee.__)("The URL to link to."),className:"block-editor-link-control__field noptin-link-control-popover__field",value:e.url||"",onChange:e=>n({url:e})})),(0,d.createElement)("td",{...h,width:i},(0,d.createElement)("img",{src:r||"https://placehold.co/30x30@2x.png",alt:o,width:i,height:i})))},save:function({attributes:e}){const{url:t,img:n,label:a,rel:r,iconSize:o}=e,l=Uo(e),i=l?.style?.backgroundColor,s=B.useBlockProps.save({width:o,style:{color:i,backgroundColor:i,borderCollapse:"separate",...Lo(e)}});return(0,d.createElement)("td",{...s,width:o},(0,d.createElement)("a",{href:t,rel:r||void 0,style:{display:"inline-block",textDecoration:"none"}},(0,d.createElement)("img",{src:n||"https://placehold.co/30x30@2x.png",alt:a,width:o,height:o})))},variations:jl},Wl={apiVersion:3,name:"core/html",title:(0,ee.__)("RAW","newsletter-optin-box"),category:"content",description:(0,ee.__)("Add custom HTML code or merge tags to your email.","newsletter-optin-box"),keywords:["code","raw"],attributes:{content:{type:"string",source:"raw"}},supports:{customClassName:!1,className:!1,html:!1,anchor:!1}},{name:Kl}=Wl,ql={icon:"editor-code",example:{attributes:{content:""+(0,ee.__)("Welcome to the wonderful world of blocks…")+""}},edit:function e({attributes:t,setAttributes:n}){const[a,r]=(0,S.useState)(!1),o=(0,S.useContext)(C.Disabled.Context),l=(0,_.useInstanceId)(e,"html-edit-desc"),i=(0,B.useBlockProps)({className:"block-library-html__edit","aria-describedby":a?l:void 0});return(0,d.createElement)("div",{...i},(0,d.createElement)(B.BlockControls,null,(0,d.createElement)(C.ToolbarGroup,null,(0,d.createElement)(C.ToolbarButton,{className:"components-tab-button",isPressed:!a,onClick:function(){r(!1)}},"HTML"),(0,d.createElement)(C.ToolbarButton,{className:"components-tab-button",isPressed:a,onClick:function(){r(!0)}},(0,ee.__)("Preview")))),a||o?(0,d.createElement)(S.RawHTML,null,t.content):(0,d.createElement)(B.PlainText,{value:t.content,onChange:e=>n({content:e}),placeholder:(0,ee.__)("Write HTML…"),"aria-label":(0,ee.__)("HTML")}))},save:function({attributes:e}){return(0,d.createElement)(S.RawHTML,null,e.content)}},Yl=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M18 4h-7c-1.1 0-2 .9-2 2v3H6c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2v-3h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h3V13c0 1.1.9 2 2 2h2.5v3zm0-4.5H11c-.3 0-.5-.2-.5-.5v-2.5H13c.3 0 .5.2.5.5v2.5zm5-.5c0 .3-.2.5-.5.5h-3V11c0-1.1-.9-2-2-2h-2.5V6c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5v7z"})),Zl=e=>{const t={style:{},vml:null};return e.style?.background?.backgroundImage?.url?(t.style.backgroundImage=`url("${e.style.background.backgroundImage.url}")`,t.style.backgroundSize="cover",t):t},Ql={apiVersion:3,name:"noptin/group",title:(0,ee.__)("Section","newsletter-optin-box"),category:"design",description:(0,ee.__)("Gather blocks in a layout container.","newsletter-optin-box"),keywords:["container","wrapper","row","section"],attributes:{templateLock:{type:["string","boolean"],enum:["all","insert","contentOnly",!1]},allowedBlocks:{type:"array"},style:{type:"object",default:{noptin:{align:"center",color:{background:"#ffffff"}}}},width:{type:"string",default:"600px"}},noptin:{typography:!0,border:!0,color:!0,align:!0},supports:{__experimentalOnEnter:!0,__experimentalOnMerge:!0,__experimentalSettings:!0,anchor:!1,html:!1,background:{__experimentalSkipSerialization:!0,backgroundImage:!0},spacing:{__experimentalSkipSerialization:!0,margin:["top","bottom"],padding:!0,__experimentalDefaultControls:{margin:!0,padding:!0}}}},Xl={from:[{type:"block",isMultiBlock:!0,blocks:["*"],__experimentalConvert(e){const t=e.map((e=>(0,ne.createBlock)(e.name,e.attributes,e.innerBlocks)));return(0,ne.createBlock)("noptin/group",{},t)}}]},Jl=Xl,{name:ei}=Ql,ti={icon:Yl,example:{attributes:{style:{color:{text:"#000000",background:"#ffffff"}}},innerBlocks:[{name:"core/paragraph",attributes:{customTextColor:"#cf2e2e",fontSize:"large",content:(0,ee.__)("One.")}},{name:"core/paragraph",attributes:{customTextColor:"#ff6900",fontSize:"large",content:(0,ee.__)("Two.")}},{name:"core/paragraph",attributes:{customTextColor:"#fcb900",fontSize:"large",content:(0,ee.__)("Three.")}},{name:"core/paragraph",attributes:{customTextColor:"#00d084",fontSize:"large",content:(0,ee.__)("Four.")}},{name:"core/paragraph",attributes:{customTextColor:"#0693e3",fontSize:"large",content:(0,ee.__)("Five.")}},{name:"core/paragraph",attributes:{customTextColor:"#9b51e0",fontSize:"large",content:(0,ee.__)("Six.")}}]},transforms:Jl,edit:({attributes:e,setAttributes:t})=>{const{width:n}=e,a=Wo(e),r=Yo(e,!0),o={width:n,maxWidth:"100%",borderCollapse:"separate",...Lo(e),...Uo(e).style,...Zl(e).style},l=(0,B.useInnerBlocksProps)({style:No(e)},{templateLock:e.templateLock,allowedBlocks:e.allowedBlocks}),i=(0,C.__experimentalUseCustomUnits)({availableUnits:["%","px","em","rem","vw"]});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Section settings")},(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Width"),labelPosition:"edge",__unstableInputWidth:"80px",min:10,value:n||"",onChange:e=>t({width:e}),units:i}))),(0,d.createElement)("div",{...(0,B.useBlockProps)({style:r.margin})},(0,d.createElement)("table",{width:n,align:a,cellPadding:0,cellSpacing:0,role:"presentation",style:o},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{className:"noptin-block-group__inner",style:r.padding,align:a},(0,d.createElement)("table",{border:0,cellPadding:0,cellSpacing:0,width:"100%"},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{...l}))))))))))},save:({attributes:e})=>{const{width:t}=e,n=Yo.save(e,!0),a=Wo(e),r={width:t,maxWidth:"100%",borderCollapse:"separate",...Lo(e),...Uo(e).style,...Zl(e).style};return(0,d.createElement)("div",{...B.useBlockProps.save({style:n.margin})},(0,d.createElement)("table",{width:t,align:a,cellPadding:0,cellSpacing:0,role:"presentation",style:r},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{className:"noptin-block-group__inner",style:n.padding,align:a},(0,d.createElement)("table",{border:"0",cellPadding:"0",cellSpacing:"0",width:"100%"},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{style:{...No(e),...Uo(e).style}},(0,d.createElement)(B.InnerBlocks.Content,null))))))))))}},ni=e=>{const t=parseFloat(e);return Number.isFinite(t)?parseFloat(t.toFixed(2)):void 0};function ai(e,t){const{width:n=100/t}=e.attributes;return ni(n)}function ri(e,t,n=e.length){const a=function(e,t=e.length){return e.reduce(((e,n)=>e+ai(n,t)),0)}(e,n);return Object.fromEntries(Object.entries(function(e,t=e.length){return e.reduce(((e,n)=>{const a=ai(n,t);return Object.assign(e,{[n.clientId]:a})}),{})}(e,n)).map((([e,n])=>[e,ni(t*n/a)])))}function oi(e,t){return e.map((e=>({...e,attributes:{...e.attributes,width:`${t[e.clientId]}%`}})))}const li=["noptin/column"];function ii({attributes:e,setAttributes:t,clientId:n}){const{isStackedOnMobile:a,verticalAlignment:r,templateLock:o}=e,{replaceInnerBlocks:l}=(0,P.useDispatch)(B.store),{count:i,canInsertColumnBlock:s,minCount:c,innerBlocks:u}=(0,P.useSelect)((e=>{const{canInsertBlockType:t,canRemoveBlock:a,getBlocks:r,getBlockCount:o}=e(B.store),l=r(n),i=l.reduce(((e,t,n)=>(a(t.clientId)||e.push(n),e)),[]);return{count:o(n),canInsertColumnBlock:t("noptin/column",n),minCount:Math.max(...i)+1,innerBlocks:l}}),[n]),p=(0,B.useBlockProps)({className:b()("noptin-columns noptin-columns__wrapper",{"noptin-is-stacked-on-mobile":a}),style:{...No(e),...Lo(e),...Yo(e),...Uo(e).style}}),m=(0,B.useInnerBlocksProps)(p,{allowedBlocks:li,orientation:"horizontal",renderAppender:!1,templateLock:o});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,null,(0,d.createElement)(B.BlockVerticalAlignmentToolbar,{onChange:e=>t({verticalAlignment:e}),value:r})),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,null,s&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.RangeControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,ee.__)("Columns"),value:i,onChange:e=>((e,t)=>{let a=[...u];const r=u.every((e=>{const t=e.attributes.width;return Number.isFinite(t?.endsWith?.("%")?parseFloat(t):t)})),o=t>e;if(o&&r){const n=ni(100/t),r=ri(u,100-n);a=[...oi(u,r),...Array.from({length:t-e}).map((()=>(0,ne.createBlock)("noptin/column",{width:`${n}%`})))]}else if(o)a=[...u,...Array.from({length:t-e}).map((()=>(0,ne.createBlock)("noptin/column")))];else if(tt({isStackedOnMobile:!a})}))),(0,d.createElement)("div",{...m}))}function si({clientId:e,name:t,setAttributes:n}){const{blockType:a,defaultVariation:r,variations:o}=(0,P.useSelect)((e=>{const{getBlockVariations:n,getBlockType:a,getDefaultBlockVariation:r}=e(ne.store);return{blockType:a(t),defaultVariation:r(t,"block"),variations:n(t,"block")}}),[t]),{replaceInnerBlocks:l}=(0,P.useDispatch)(B.store),i=(0,B.useBlockProps)();return(0,d.createElement)("div",{...i},(0,d.createElement)(B.__experimentalBlockVariationPicker,{icon:a?.icon?.src,label:a?.title,variations:o,onSelect:(t=r)=>{t.attributes&&n(t.attributes),t.innerBlocks&&l(e,(0,ne.createBlocksFromInnerBlocksTemplate)(t.innerBlocks),!0)},allowSkip:!0}))}const ci={apiVersion:3,name:"noptin/columns",title:(0,ee.__)("Columns","newsletter-optin-box"),category:"design",description:(0,ee.__)("Display content in multiple columns, with blocks added to each column.","newsletter-optin-box"),attributes:{verticalAlignment:{type:"string",default:"top"},isStackedOnMobile:{type:"boolean",default:!0},templateLock:{type:["string","boolean"],enum:["all","insert","contentOnly",!1]}},providesContext:{"noptin/columns/verticalAlignment":"verticalAlignment","noptin/columns/isStackedOnMobile":"isStackedOnMobile"},noptin:{typography:!0,border:!0,color:!0},supports:{anchor:!1,html:!1,__experimentalExposeControlsToChildren:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,__experimentalDefaultControls:{margin:!0}}}};function ui(e,t=!1){return`\n ${t?"\x3c!--[if !true]>\x3c!--\x3e":"\x3c!--[if true]>"}\n ${e}\n ${t?"\x3c!--{const t=+(100/e.length).toFixed(2),n=e.map((({name:e,attributes:n,innerBlocks:a})=>["noptin/column",{width:`${t}%`},[[e,{...n},a]]]));return(0,ne.createBlock)("noptin/columns",{},(0,ne.createBlocksFromInnerBlocksTemplate)(n))},isMatch:({length:e},t)=>(1!==t.length||"noptin/columns"!==t[0].name)&&e&&e<=6}],ungroup:(e,t)=>t.flatMap((e=>e.innerBlocks))},{name:di}=ci,gi={icon:"columns",variations:pi,edit:e=>{const{clientId:t}=e,n=(0,P.useSelect)((e=>e(B.store).getBlocks(t).length>0),[t])?ii:si;return(0,d.createElement)(n,{...e})},save:function({attributes:e}){const{isStackedOnMobile:t}=e,n={...No(e),...Lo(e),...Yo.save(e),...Uo(e).style},a=B.useBlockProps.save({className:b()("noptin-columns noptin-columns__wrapper",{"noptin-is-stacked-on-mobile":t}),style:n}),r=ui(``),o=ui("
");return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(S.RawHTML,{children:`${r}\x3c!--[if !true]>\x3c!--\x3e`}),(0,d.createElement)("div",{...a},(0,d.createElement)(S.RawHTML,{children:"\x3c!--\x3c!--\x3e"})),(0,d.createElement)(S.RawHTML,{children:`\x3c!--"center"===e?"middle":e||void 0,bi={apiVersion:3,name:"noptin/column",title:(0,ee.__)("Column","newsletter-optin-box"),category:"design",parent:["noptin/columns"],description:(0,ee.__)("A single column within a columns block.","newsletter-optin-box"),attributes:{verticalAlignment:{type:"string",default:"top"},isStackedOnMobile:{type:"boolean",default:!0},width:{type:"string"},allowedBlocks:{type:"array"},templateLock:{type:["string","boolean"],enum:["all","insert","contentOnly",!1]}},usesContext:["noptin/columns/verticalAlignment","noptin/columns/isStackedOnMobile"],noptin:{typography:!0,border:!0,color:!0},supports:{__experimentalOnEnter:!0,anchor:!1,reusable:!1,html:!1,spacing:{__experimentalSkipSerialization:!0,padding:!0,margin:!0,__experimentalDefaultControls:{padding:!0,margin:!0}}}},{name:fi}=bi,yi={icon:_i,edit:function({attributes:{width:e,templateLock:t,verticalAlignment:n,isStackedOnMobile:a,allowedBlocks:r,...o},setAttributes:l,clientId:i,context:s}){const c=s["noptin/columns/verticalAlignment"];(0,d.useEffect)((()=>{n!==c&&l({verticalAlignment:c})}),[c,n]);const u=s["noptin/columns/isStackedOnMobile"];(0,d.useEffect)((()=>{a!==u&&l({isStackedOnMobile:u})}),[u,a]);const p=(0,C.__experimentalUseCustomUnits)({availableUnits:["%","px","em","rem","vw"]}),m=(0,P.useSelect)((e=>e(B.store).getBlockOrder(i).length>0),[i]),g={verticalAlign:hi(n)};if(e&&/\d/.test(e)){let t=Number.isFinite(e)?e+"%":e;if(!Number.isFinite(e)&&e?.endsWith("%")){const n=1e12;t=Math.round(Number.parseFloat(e)*n)/n+"%"}g.width=t}const _=(0,B.useBlockProps)({className:b()("noptin-column",{"noptin-is-stacked-on-mobile":a}),style:g}),h={...No(o),...Lo(o),...Yo(o),...Uo(o).style};return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Column settings")},(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Width"),labelPosition:"edge",__unstableInputWidth:"80px",value:e||"",onChange:e=>{e=0>parseFloat(e)?"0":e,l({width:e})},units:p}))),(0,d.createElement)("div",{..._},(0,d.createElement)("div",{className:"noptin-column__inner",style:h},(0,d.createElement)(B.InnerBlocks,{templateLock:t,allowedBlocks:r,renderAppender:m?void 0:B.InnerBlocks.ButtonBlockAppender}))))},save:function({attributes:e}){const{width:t,verticalAlignment:n,isStackedOnMobile:a}=e,r={verticalAlign:hi(n)};if(t&&/\d/.test(t)){let e=Number.isFinite(t)?t+"%":t;if(!Number.isFinite(t)&&t?.endsWith("%")){const n=1e12;e=Math.round(Number.parseFloat(t)*n)/n+"%"}r.width=e}const o=B.useBlockProps.save({className:b()("noptin-column",{"noptin-is-stacked-on-mobile":a}),style:r}),l=ui(``),i=ui(""),s={...No(e),...Lo(e),...Yo(e),...Uo(e).style};return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(S.RawHTML,{children:`${l}\x3c!--[if !true]>\x3c!--\x3e`}),(0,d.createElement)("div",{...o},(0,d.createElement)(S.RawHTML,{children:"\x3c!--[if !true]>\x3c!--\x3e"}),(0,d.createElement)("div",{className:"noptin-column__inner",style:s},(0,d.createElement)(B.InnerBlocks.Content,null)),(0,d.createElement)(S.RawHTML,{children:"\x3c!--[if !true]>\x3c!--\x3e"})),(0,d.createElement)(S.RawHTML,{children:`\x3c!--(0,ne.createBlock)("noptin/separator")},{type:"raw",selector:"hr",schema:{hr:{}}}]},{name:ki}=Ei,wi={icon:vi,transforms:xi,edit:function({attributes:e,setAttributes:t}){const{width:n,height:a}=e,r=Uo(e),o=r?.style?.backgroundColor,l=(0,C.__experimentalUseCustomUnits)({availableUnits:["%","px","em","rem"]});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Width"),labelPosition:"edge",__unstableInputWidth:"80px",value:n||"",onChange:e=>{e=0>parseFloat(e)?"0":e,t({width:e})},units:l}),(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Height"),labelPosition:"edge",__unstableInputWidth:"80px",value:a||"",onChange:e=>{e=e?0>parseFloat(e)?"0":e:"1em",t({height:e})},units:l}))),(0,d.createElement)("hr",{...(0,B.useBlockProps)({style:{color:o,backgroundColor:o,borderWidth:0,height:a||"1em",width:n||"100%",maxWidth:"100%",...Yo(e)},align:Wo(e)})}))},save:function({attributes:e}){const{width:t,height:n}=e,a=Uo(e),r=a?.style?.backgroundColor;return(0,d.createElement)("hr",{...B.useBlockProps.save({style:{color:r,backgroundColor:r,borderWidth:0,height:n||"1em",width:t||"100%",maxWidth:"100%",...Yo.save(e)},align:Wo(e)})})}},Ci=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M7 18h4.5v1.5h-7v-7H6V17L17 6h-4.5V4.5h7v7H18V7L7 18Z"})),Si={apiVersion:3,name:"noptin/spacer",title:(0,ee.__)("Spacer","newsletter-optin-box"),category:"design",description:(0,ee.__)("Add a blank space between blocks and customize its height.","newsletter-optin-box"),attributes:{height:{type:"string",default:"100px"}},noptin:{color:{background:!0}},supports:{anchor:!1,spacing:{__experimentalSkipSerialization:!0,margin:["top","bottom"],__experimentalDefaultControls:{margin:!0}}}},{name:Ti}=Si,Bi={icon:Ci,edit:({attributes:e,isSelected:t,setAttributes:n})=>{const{height:a}=e,r=Uo(e),o=r?.style?.backgroundColor,l={backgroundColor:o||(t?"#95a5a6":void 0),height:a,...Yo(e)},i=(0,C.__experimentalUseCustomUnits)({availableUnits:["px","em","rem"],defaultValues:{px:100,em:10,rem:10}});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)("div",{...(0,B.useBlockProps)({style:l})}," "),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Height"),labelPosition:"edge",__unstableInputWidth:"80px",value:a||"",onChange:e=>{e=e?0>parseFloat(e)?"0px":e:"0px",n({height:e})},units:i,min:0}))))},save:function({attributes:e}){const{height:t}=e,n=Uo(e),a=n?.style?.backgroundColor;return(0,d.createElement)("div",{...B.useBlockProps.save({style:{color:a,backgroundColor:a,height:t||"100px",lineHeight:t||"100px",...Yo.save(e)}})}," ")}},Pi=(0,P.withDispatch)(((e,{clientId:t,attributes:n})=>{const{replaceBlock:a}=e(B.store);return{convertToHTML(){a(t,(0,ne.createBlock)("core/html",{content:n.originalUndelimitedContent}))}}}))((function({attributes:e,convertToHTML:t,clientId:n}){const{originalName:a,originalUndelimitedContent:r}=e,o=!!r,{hasHTMLBlock:l}=(0,P.useSelect)((e=>{const{canInsertBlockType:t,getBlockRootClientId:a}=e(B.store);return{hasHTMLBlock:t("core/html",a(n))}}),[n]),i=[];let s;const c=(0,d.createElement)(C.Button,{key:"convert",onClick:t,variant:"primary"},(0,ee.__)("Keep as HTML"));return o&&l?(s=(0,ee.sprintf)(/* translators: %s: block name */ +caption:(0,ee.__)("Mont Blanc appears—still, snowy, and serene.")}},__experimentalLabel(e,{context:t}){if("accessibility"===t){const{caption:t,alt:n,url:a}=e;return a?n?n+(t?". "+t:""):t||"":(0,ee.__)("Empty")}},transforms:kl,edit:function({attributes:e,setAttributes:t,isSelected:n,className:a,insertBlocksAfter:r,onReplace:o,context:l,clientId:i}){const{url:s="",alt:c,caption:u,id:p,width:m,height:g,sizeSlug:_}=e,[h,f]=(0,S.useState)(),y=jo(e),v=(0,S.useRef)();(0,S.useEffect)((()=>{v.current=c}),[c]);const E=(0,S.useRef)();(0,S.useEffect)((()=>{E.current=u}),[u]);const x=(0,S.useRef)(),{mediaUpload:k}=(0,P.useSelect)((e=>{const{getSettings:t}=e(B.store);return{mediaUpload:t().mediaUpload}}),[]),w=(0,B.useBlockEditingMode)(),{createErrorNotice:T}=(0,P.useDispatch)(Ua.store);function I(e){T(e,{type:"snackbar"}),t({src:void 0,id:void 0,url:void 0}),f(void 0)}function A(n){if(!n||!n.url)return void t({url:void 0,alt:void 0,id:void 0,caption:void 0});if((0,ul.isBlobURL)(n.url))return void f(n.url);f(void 0);let a="full";_&&fl(n,_)?a=_:fl(n,"large")&&(a="large");let r,o=((e,t)=>{const n=Object.fromEntries(Object.entries(null!=e?e:{}).filter((([e])=>["alt","id","link","caption","width","url"].includes(e)))),a=["width","url"];return e?.sizes?.[t]?a.forEach((a=>{e.sizes[t][a]&&(n[a]=e.sizes[t][a])})):e?.media_details?.sizes?.[t]&&a.forEach((a=>{e.media_details.sizes[t][a]?n[a]=e.media_details.sizes[t][a]:e.media_details.sizes[t][`source_${a}`]&&(n[a]=e.media_details.sizes[t][`source_${a}`])})),n.height=void 0,n})(n,a);if(E.current&&!o.caption){const{caption:e,...t}=o;o=t}r=n.id&&n.id===p?{url:s}:{sizeSlug:a};let l,i=e.linkDestination;switch(i){case"file":l=n.url;break;case"post":l=n.link}o.href=l,t({...o,...r,linkDestination:i})}function N(e){e!==s&&t({url:e,id:void 0,sizeSlug:"large"})}let M=((e,t)=>!e&&(0,ul.isBlobURL)(t))(p,s);(0,S.useEffect)((()=>{if(!M)return;const e=(0,ul.getBlobByURL)(s);e&&k({filesList:[e],onFileChange:([e])=>{A(e)},allowedTypes:gl,onError:e=>{M=!1,I(e)}})}),[]),(0,S.useEffect)((()=>{M?f(s):(0,ul.revokeBlobURL)(h)}),[M,s]);const L=bl(p,s)?s:void 0,R=s?(0,d.createElement)("img",{alt:(0,ee.__)("Edit image"),title:(0,ee.__)("Edit image"),className:"edit-image-preview",src:s}):void 0,z=b()(a,{"is-transient":h}),D=(0,B.useBlockProps)({ref:x,style:{borderSpacing:"0px",borderCollapse:"collapse",width:"100%"},className:z,border:0,cellPadding:"0",cellSpacing:"0",role:"presentation"}),$={...Ao(e),...Wo(e),width:e.width||void 0,display:"inline-block",maxWidth:"100%"};return(0,d.createElement)("table",{...D},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:y,className:b()({"is-selected":n})},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:$},(0,d.createElement)(hl,{temporaryURL:h,attributes:e,setAttributes:t,isSelected:n,insertBlocksAfter:r,onReplace:o,onSelectImage:A,onSelectURL:N,onUploadError:I,containerRef:x,context:l,clientId:i,blockEditingMode:w}),(0,d.createElement)(B.MediaPlaceholder,{icon:(0,d.createElement)(B.BlockIcon,{icon:cl}),onSelect:A,onSelectURL:N,onError:I,placeholder:e=>(0,d.createElement)(C.Placeholder,{className:"block-editor-media-placeholder",withIllustration:!0,icon:cl,label:(0,ee.__)("Image"),instructions:(0,ee.__)("Upload an image file, pick one from your media library, or add one with a URL."),style:{width:m,height:g}},e),accept:"image/*",allowedTypes:["image"],value:{id:p,src:L},mediaPreview:R,disableMediaButtons:h||s}))))))},save:function({attributes:e}){const{url:t,alt:n,caption:a,href:r,rel:o,linkClass:l,width:i,height:s}=e,c=jo(e),u=(0,d.createElement)("img",{src:t,alt:n,style:{width:!i&&s?"auto":i,height:s,maxWidth:"100%"}}),p={...Ao(e),...Wo.save(e),width:i||void 0,display:"inline-block",maxWidth:"100%"},m=(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:p},r?(0,d.createElement)("a",{className:l,href:r,rel:o||void 0,style:{display:"block",textDecoration:"none",maxWidth:"100%",lineHeight:0}},u):u,!B.RichText.isEmpty(a)&&(0,d.createElement)(B.RichText.Content,{className:"wp-block-image__caption",tagName:"div",value:a,style:{fontSize:"12px",textAlign:"center",marginTop:"12px"}})),g=B.useBlockProps.save({style:{borderSpacing:"0px",borderCollapse:"collapse",width:"100%"},border:0,cellPadding:"0",cellSpacing:"0",role:"presentation"});return(0,d.createElement)("table",{...g},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:c},m))))}};function Sl(e){return e.replace(/<\/?a[^>]*>/g,"")}function Tl({attributes:e,setAttributes:t}){return(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(B.URLInput,{label:(0,ee.__)("Button URL"),help:(0,ee.__)("The URL to link to."),className:"block-editor-link-control__field noptin-link-control__field",value:e.url||"",hasBorder:!0,isFullWidth:!0,onChange:e=>t({url:e})}),(0,d.createElement)(C.__experimentalToggleGroupControl,{label:(0,ee.__)("Button width"),className:"noptin-toggle-group-control",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isAdaptiveWidth:!0,isBlock:!0,isDeselectable:!0,onChange:function(n){const a=e.width===n?void 0:n;t({width:a})}},[25,50,75,100].map((e=>(0,d.createElement)(C.__experimentalToggleGroupControlOption,{key:e,label:`${e}%`,value:e})))))}const Bl={apiVersion:3,name:"noptin/button",title:(0,ee.__)("Button","newsletter-optin-box"),category:"content",description:(0,ee.__)("Prompt readers to take action with a button-style link.","newsletter-optin-box"),keywords:["link","cta"],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href",__experimentalRole:"content"},title:{type:"string",source:"attribute",selector:"a",attribute:"title",__experimentalRole:"content"},text:{type:"string",source:"html",selector:"a",__experimentalRole:"content"},rel:{type:"string",source:"attribute",selector:"a",attribute:"rel",__experimentalRole:"content",default:"noopener noreferrer"},placeholder:{type:"string"},style:{type:"object",default:{noptin:{border:{radius:"5px"},typography:{textTransform:"none",textDecoration:"none",textAlign:"center"}}}},width:{type:"string"}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0},align:!0},supports:{anchor:!1,reusable:!1,shadow:!1,spacing:{__experimentalSkipSerialization:!0,padding:["horizontal","vertical"],margin:!0,__experimentalDefaultControls:{padding:!0,margin:!0}}}},{name:Pl}=Bl,Il={icon:"button",example:{attributes:{text:(0,ee.__)("Call to Action")}},edit:function(e){const{attributes:t,setAttributes:n,isSelected:a,onReplace:r,mergeBlocks:o,clientId:l}=e,{placeholder:i,rel:s,text:c,width:u}=t,p=jo(t),m=Po(t),[g,h]=(0,S.useState)(null),b=Ao(t),f=Ho(t).style,y=Wo(t,!0),v=(0,S.useRef)(),E=(0,S.useRef)(),x=(0,B.useBlockProps)({ref:(0,_.useMergeRefs)([h,v]),width:"100%",border:0,cellPadding:0,cellSpacing:0,role:"presentation",style:{lineHeight:"100%",width:"100%",borderCollapse:"separate",margin:"0px"}}),[k,w]=(0,S.useState)(!0);(0,S.useEffect)((()=>{a&&w(!0)}),[a]);const T=function(e){const{replaceBlocks:t,selectionChange:n}=(0,P.useDispatch)(B.store),{getBlock:a,getBlockRootClientId:r,getBlockIndex:o}=(0,P.useSelect)(B.store),l=(0,S.useRef)(e);return l.current=e,(0,_.useRefEffect)((e=>{function i(e){if(e.defaultPrevented||e.keyCode!==St.ENTER)return;const{content:i,clientId:s}=l.current;if(i.length)return;e.preventDefault();const c=a(r(s)),u=o(s),p=(0,ne.cloneBlock)({...c,innerBlocks:c.innerBlocks.slice(0,u)}),m=(0,ne.createBlock)((0,ne.getDefaultBlockName)()),d=c.innerBlocks.slice(u+1),g=d.length?[(0,ne.cloneBlock)({...c,innerBlocks:d})]:[];t(c.clientId,[p,m,...g],1),n(m.clientId)}return e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i)}}),[])}({content:c,clientId:l}),I=(0,_.useMergeRefs)([T,E]);return(0,d.createElement)(d.Fragment,null,(0,d.createElement)("table",{...x},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:p},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:y.margin},(0,d.createElement)("table",{width:u?`${u}%`:void 0},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{bgcolor:f.backgroundColor,role:"presentation",valign:"middle",className:"noptin-button-link__wrapper",style:{background:f.backgroundColor,textAlign:m?.textAlign,cursor:"auto",...b}},(0,d.createElement)(B.RichText,{ref:I,tagName:"span","aria-label":(0,ee.__)("Button text"),placeholder:i||(0,ee.__)("Add text…"),value:c,onChange:e=>n({text:Sl(e)}),withoutInteractiveFormatting:!0,className:"noptin-button-link",style:{...y.padding,...m||{},color:f.color,margin:"0px",display:"block",wordBreak:"break-word"},onSplit:e=>(0,ne.createBlock)("noptin/button",{...t,text:e}),onReplace:r,onMerge:o,identifier:"text"})))))))))),a&&k&&(0,d.createElement)(C.Popover,{placement:"bottom",onClose:()=>{w(!1),E.current?.focus()},anchor:g,focusOnMount:!1,__unstableSlotName:"__unstable-block-tools-after",shift:!0},(0,d.createElement)(B.URLInput,{label:(0,ee.__)("Button URL"),help:(0,ee.__)("The URL to link to."),className:"block-editor-link-control__field noptin-link-control-popover__field",value:t.url||"",onChange:e=>n({url:e})})),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(Tl,{attributes:t,setAttributes:n})),(0,d.createElement)(B.InspectorControls,{group:"advanced"},(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Link rel"),value:s||"",onChange:e=>n({rel:e})})))},save:function({attributes:e}){const{rel:t,text:n,title:a,url:r,width:o}=e,l=jo(e),i=Ao(e),s=Ho(e),c=s?.style?.backgroundColor,u=s?.style?.color,p=Wo.save(e,!0),m={...p.padding,...Po(e),borderRadius:i?.borderRadius,margin:"0px",display:"block",color:u,wordBreak:"break-word"},g=B.useBlockProps.save({width:"100%",border:0,cellPadding:0,cellSpacing:0,role:"presentation",style:{lineHeight:"100%",width:"100%",borderCollapse:"separate",margin:"0px"}});return n?(0,d.createElement)("table",{...g},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:l},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:p.margin},(0,d.createElement)("table",{width:o?`${o}%`:void 0},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{bgcolor:c,role:"presentation",valign:"middle",className:"noptin-button-link__wrapper",style:{background:c,textAlign:m.textAlign,cursor:"auto",...i}},(0,d.createElement)(B.RichText.Content,{tagName:"a",className:"noptin-button-link",href:r,title:a,style:m,value:n,rel:t})))))))))):null},merge:(e,{text:t=""})=>({...e,text:(e.text||"")+t})},Al=["noptin/social-link"],Nl=[{name:"facebook",color:"#3b5998",title:"Facebook"},{name:"twitter",color:"#55acee",title:"Twitter"},{name:"youtube",color:"#eb3323",title:"YouTube"}],Ml=Nl.map((({name:e,title:t,color:n})=>["noptin/social-link",{img:`https://www.mailjet.com/images/theme/v1/icons/ico-social/${e}.png`,url:"#",label:t,style:{noptin:{border:{radius:"50%"},color:{background:n}}}}])),Ll={iconSize:{label:(0,ee.__)("Icon size"),options:{"20px":(0,ee.__)("S"),"32px":(0,ee.__)("M"),"48px":(0,ee.__)("L"),"64px":(0,ee.__)("XL")}},iconSpacing:{label:(0,ee.__)("Icon spacing"),options:{"0px":(0,ee.__)("None"),"4px":(0,ee.__)("S"),"16px":(0,ee.__)("M"),"24px":(0,ee.__)("L")}},iconPadding:{label:(0,ee.__)("Icon padding"),options:{"0px":(0,ee.__)("None"),"4px":(0,ee.__)("S"),"16px":(0,ee.__)("M"),"24px":(0,ee.__)("L")}}};function Rl({attributes:e,setAttributes:t}){return(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Icon settings")},Object.entries(Ll).map((([n,a])=>(0,d.createElement)(C.__experimentalToggleGroupControl,{key:n,label:a.label,value:e[n],onChange:e=>t({[n]:e}),className:"noptin-field-control",__nextHasNoMarginBottom:!0,isAdaptiveWidth:!0,isBlock:!0,isDeselectable:!0},Object.entries(a.options).map((([e,t])=>(0,d.createElement)(C.__experimentalToggleGroupControlOption,{key:`${n}__${e}`,label:t,value:e})))))))}const zl={apiVersion:3,name:"noptin/social-links",title:(0,ee.__)("Social Icons","newsletter-optin-box"),category:"content",description:(0,ee.__)("Display icons linking to your social media profiles or sites.","newsletter-optin-box"),keywords:["links"],attributes:{iconSize:{type:"string",default:"20px"},iconSpacing:{type:"string",default:"4px"},iconPadding:{type:"string",default:"4px"}},providesContext:{"noptin/social-links/iconSize":"iconSize"},noptin:{border:!0,color:{background:!0},align:!0},supports:{anchor:!1,__experimentalExposeControlsToChildren:!0,spacing:{margin:!0,padding:!0,units:["px","em","rem"],__experimentalSkipSerialization:!0,__experimentalDefaultControls:{margin:!0,padding:!1}}}},{name:Dl}=zl,$l={example:{innerBlocks:Nl.map((({name:e,title:t,color:n})=>({name:"noptin/social-link",attributes:{img:`https://www.mailjet.com/images/theme/v1/icons/ico-social/${e}.png`,url:"#",label:t,style:{noptin:{border:{radius:"50%"},color:{background:n}}}}})))},icon:"share",edit:function({attributes:e,setAttributes:t}){const{iconSpacing:n,iconPadding:a}=e,r=jo(e),o=Wo(e,!0),l=Ao(e),i=(0,B.useBlockProps)({style:o.margin,className:"noptin-block__margin-wrapper"}),s=(0,B.useInnerBlocksProps)({},{allowedBlocks:Al,template:Ml,templateLock:!1,orientation:"horizontal",__experimentalAppenderTagName:"td"}),c={lineHeight:"100%",width:"100%",borderCollapse:"separate",...Ho(e).style,...l};return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(Rl,{attributes:e,setAttributes:t})),(0,d.createElement)("div",{...i},(0,d.createElement)("table",{role:"presentation",cellPadding:0,cellSpacing:0,border:0,width:"100%",style:c},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:r,style:o.padding,border:"0",role:"presentation",valign:"middle"},(0,d.createElement)("table",{align:r,cellPadding:a||0,cellSpacing:n||0,style:{borderCollapse:"separate"}},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",{...s})))))))))},save:({attributes:e})=>{const{iconSpacing:t,iconPadding:n}=e,a=jo(e),r=Wo.save(e,!0),o=Ao(e),l=B.useBlockProps.save({style:r.margin,className:"noptin-block__margin-wrapper"}),i={lineHeight:"100%",width:"100%",borderCollapse:"separate",...Ho(e).style,...o};return(0,d.createElement)("div",{...l},(0,d.createElement)("table",{role:"presentation",cellPadding:0,cellSpacing:0,border:0,width:"100%",style:i},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:a,style:r.padding,border:"0",role:"presentation",valign:"middle"},(0,d.createElement)("table",{align:a,cellPadding:n||0,cellSpacing:t||0,style:{borderCollapse:"separate"}},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)(B.InnerBlocks.Content,null)))))))))}},Vl={apiVersion:3,name:"noptin/social-link",title:(0,ee.__)("Social Icon","newsletter-optin-box"),category:"content",parent:["noptin/social-links"],description:(0,ee.__)("Display an icon linking to a social media profile or site.","newsletter-optin-box"),attributes:{iconSize:{type:"string",default:"20px"},url:{type:"string"},img:{type:"string"},label:{type:"string"},rel:{type:"string",default:"noopener noreferrer"}},usesContext:["noptin/social-links/iconSize"],noptin:{border:!0,color:{background:!0}},supports:{reusable:!1,anchor:!1,html:!1}},Fl=[{name:"facebook",color:"#3b5998",title:"Facebook"},{name:"twitter",color:"#55acee",title:"Twitter"},{name:"google-plus",color:"#dc4e41",title:"Google Plus",icon:"google"},{name:"pinterest",color:"#bd081c",title:"Pinterest"},{name:"linkedin",color:"#0077b5",title:"linkedIn"},{name:"instagram",color:"#3f729b",title:"Instagram"},{name:"youtube",color:"#eb3323",title:"YouTube"},{name:"tumblr",color:"#344356",title:"Tumblr",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M17.04 21.28h-3.28c-2.84 0-4.94-1.37-4.94-5.02v-5.67H6.08V7.5c2.93-.73 4.11-3.3 4.3-5.48h3.01v4.93h3.47v3.65H13.4v4.93c0 1.47.73 2.01 1.92 2.01h1.73v3.75z"}))},{name:"github",color:"#000000",title:"GitHub",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"}))},{name:"xing",color:"#296366",title:"Xing"},{name:"vimeo",color:"#53B4E7",title:"Vimeo",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M22.396,7.164c-0.093,2.026-1.507,4.799-4.245,8.32C15.322,19.161,12.928,21,10.97,21c-1.214,0-2.24-1.119-3.079-3.359 c-0.56-2.053-1.119-4.106-1.68-6.159C5.588,9.243,4.921,8.122,4.206,8.122c-0.156,0-0.701,0.328-1.634,0.98L1.594,7.841 c1.027-0.902,2.04-1.805,3.037-2.708C6.001,3.95,7.03,3.327,7.715,3.264c1.619-0.156,2.616,0.951,2.99,3.321 c0.404,2.557,0.685,4.147,0.841,4.769c0.467,2.121,0.981,3.181,1.542,3.181c0.435,0,1.09-0.688,1.963-2.065 c0.871-1.376,1.338-2.422,1.401-3.142c0.125-1.187-0.343-1.782-1.401-1.782c-0.498,0-1.012,0.115-1.541,0.341 c1.023-3.35,2.977-4.977,5.862-4.884C21.511,3.066,22.52,4.453,22.396,7.164z"}))},{name:"medium",color:"#000000",title:"Medium",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M20.962,7.257l-5.457,8.867l-3.923-6.375l3.126-5.08c0.112-0.182,0.319-0.286,0.527-0.286c0.05,0,0.1,0.008,0.149,0.02 c0.039,0.01,0.078,0.023,0.114,0.041l5.43,2.715l0.006,0.003c0.004,0.002,0.007,0.006,0.011,0.008 C20.971,7.191,20.98,7.227,20.962,7.257z M9.86,8.592v5.783l5.14,2.57L9.86,8.592z M15.772,17.331l4.231,2.115 C20.554,19.721,21,19.529,21,19.016V8.835L15.772,17.331z M8.968,7.178L3.665,4.527C3.569,4.479,3.478,4.456,3.395,4.456 C3.163,4.456,3,4.636,3,4.938v11.45c0,0.306,0.224,0.669,0.498,0.806l4.671,2.335c0.12,0.06,0.234,0.088,0.337,0.088 c0.29,0,0.494-0.225,0.494-0.602V7.231C9,7.208,8.988,7.188,8.968,7.178z"}))},{name:"soundcloud",color:"#EF7F31",title:"SoundCloud",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M8.9,16.1L9,14L8.9,9.5c0-0.1,0-0.1-0.1-0.1c0,0-0.1-0.1-0.1-0.1c-0.1,0-0.1,0-0.1,0.1c0,0-0.1,0.1-0.1,0.1L8.3,14l0.1,2.1 c0,0.1,0,0.1,0.1,0.1c0,0,0.1,0.1,0.1,0.1C8.8,16.3,8.9,16.3,8.9,16.1z M11.4,15.9l0.1-1.8L11.4,9c0-0.1,0-0.2-0.1-0.2 c0,0-0.1,0-0.1,0s-0.1,0-0.1,0c-0.1,0-0.1,0.1-0.1,0.2l0,0.1l-0.1,5c0,0,0,0.7,0.1,2v0c0,0.1,0,0.1,0.1,0.1c0.1,0.1,0.1,0.1,0.2,0.1 c0.1,0,0.1,0,0.2-0.1c0.1,0,0.1-0.1,0.1-0.2L11.4,15.9z M2.4,12.9L2.5,14l-0.2,1.1c0,0.1,0,0.1-0.1,0.1c0,0-0.1,0-0.1-0.1L2.1,14 l0.1-1.1C2.2,12.9,2.3,12.9,2.4,12.9C2.3,12.9,2.4,12.9,2.4,12.9z M3.1,12.2L3.3,14l-0.2,1.8c0,0.1,0,0.1-0.1,0.1 c-0.1,0-0.1,0-0.1-0.1L2.8,14L3,12.2C3,12.2,3,12.2,3.1,12.2C3.1,12.2,3.1,12.2,3.1,12.2z M3.9,11.9L4.1,14l-0.2,2.1 c0,0.1,0,0.1-0.1,0.1c-0.1,0-0.1,0-0.1-0.1L3.5,14l0.2-2.1c0-0.1,0-0.1,0.1-0.1C3.9,11.8,3.9,11.8,3.9,11.9z M4.7,11.9L4.9,14 l-0.2,2.1c0,0.1-0.1,0.1-0.1,0.1c-0.1,0-0.1,0-0.1-0.1L4.3,14l0.2-2.2c0-0.1,0-0.1,0.1-0.1C4.7,11.7,4.7,11.8,4.7,11.9z M5.6,12 l0.2,2l-0.2,2.1c0,0.1-0.1,0.1-0.1,0.1c0,0-0.1,0-0.1,0c0,0,0-0.1,0-0.1L5.1,14l0.2-2c0,0,0-0.1,0-0.1s0.1,0,0.1,0 C5.5,11.9,5.5,11.9,5.6,12L5.6,12z M6.4,10.7L6.6,14l-0.2,2.1c0,0,0,0.1,0,0.1c0,0-0.1,0-0.1,0c-0.1,0-0.1-0.1-0.2-0.2L5.9,14 l0.2-3.3c0-0.1,0.1-0.2,0.2-0.2c0,0,0.1,0,0.1,0C6.4,10.7,6.4,10.7,6.4,10.7z M7.2,10l0.2,4.1l-0.2,2.1c0,0,0,0.1,0,0.1 c0,0-0.1,0-0.1,0c-0.1,0-0.2-0.1-0.2-0.2l-0.1-2.1L6.8,10c0-0.1,0.1-0.2,0.2-0.2c0,0,0.1,0,0.1,0S7.2,9.9,7.2,10z M8,9.6L8.2,14 L8,16.1c0,0.1-0.1,0.2-0.2,0.2c-0.1,0-0.2-0.1-0.2-0.2L7.5,14l0.1-4.4c0-0.1,0-0.1,0.1-0.1c0,0,0.1-0.1,0.1-0.1c0.1,0,0.1,0,0.1,0.1 C8,9.6,8,9.6,8,9.6z M11.4,16.1L11.4,16.1L11.4,16.1z M9.7,9.6L9.8,14l-0.1,2.1c0,0.1,0,0.1-0.1,0.2s-0.1,0.1-0.2,0.1 c-0.1,0-0.1,0-0.1-0.1s-0.1-0.1-0.1-0.2L9.2,14l0.1-4.4c0-0.1,0-0.1,0.1-0.2s0.1-0.1,0.2-0.1c0.1,0,0.1,0,0.2,0.1S9.7,9.5,9.7,9.6 L9.7,9.6z M10.6,9.8l0.1,4.3l-0.1,2c0,0.1,0,0.1-0.1,0.2c0,0-0.1,0.1-0.2,0.1c-0.1,0-0.1,0-0.2-0.1c0,0-0.1-0.1-0.1-0.2L10,14 l0.1-4.3c0-0.1,0-0.1,0.1-0.2c0,0,0.1-0.1,0.2-0.1c0.1,0,0.1,0,0.2,0.1S10.6,9.7,10.6,9.8z M12.4,14l-0.1,2c0,0.1,0,0.1-0.1,0.2 c-0.1,0.1-0.1,0.1-0.2,0.1c-0.1,0-0.1,0-0.2-0.1c-0.1-0.1-0.1-0.1-0.1-0.2l-0.1-1l-0.1-1l0.1-5.5v0c0-0.1,0-0.2,0.1-0.2 c0.1,0,0.1-0.1,0.2-0.1c0,0,0.1,0,0.1,0c0.1,0,0.1,0.1,0.1,0.2L12.4,14z M22.1,13.9c0,0.7-0.2,1.3-0.7,1.7c-0.5,0.5-1.1,0.7-1.7,0.7 h-6.8c-0.1,0-0.1,0-0.2-0.1c-0.1-0.1-0.1-0.1-0.1-0.2V8.2c0-0.1,0.1-0.2,0.2-0.3c0.5-0.2,1-0.3,1.6-0.3c1.1,0,2.1,0.4,2.9,1.1 c0.8,0.8,1.3,1.7,1.4,2.8c0.3-0.1,0.6-0.2,1-0.2c0.7,0,1.3,0.2,1.7,0.7C21.8,12.6,22.1,13.2,22.1,13.9L22.1,13.9z"}))},{name:"dribbble",color:"#D95988",title:"Dribbble",icon:()=>(0,d.createElement)(de.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",version:"1.1"},(0,d.createElement)(de.Path,{d:"M12,22C6.486,22,2,17.514,2,12S6.486,2,12,2c5.514,0,10,4.486,10,10S17.514,22,12,22z M20.434,13.369 c-0.292-0.092-2.644-0.794-5.32-0.365c1.117,3.07,1.572,5.57,1.659,6.09C18.689,17.798,20.053,15.745,20.434,13.369z M15.336,19.876c-0.127-0.749-0.623-3.361-1.822-6.477c-0.019,0.006-0.038,0.013-0.056,0.019c-4.818,1.679-6.547,5.02-6.701,5.334 c1.448,1.129,3.268,1.803,5.243,1.803C13.183,20.555,14.311,20.313,15.336,19.876z M5.654,17.724 c0.193-0.331,2.538-4.213,6.943-5.637c0.111-0.036,0.224-0.07,0.337-0.102c-0.214-0.485-0.448-0.971-0.692-1.45 c-4.266,1.277-8.405,1.223-8.778,1.216c-0.003,0.087-0.004,0.174-0.004,0.261C3.458,14.207,4.29,16.21,5.654,17.724z M3.639,10.264 c0.382,0.005,3.901,0.02,7.897-1.041c-1.415-2.516-2.942-4.631-3.167-4.94C5.979,5.41,4.193,7.613,3.639,10.264z M9.998,3.709 c0.236,0.316,1.787,2.429,3.187,5c3.037-1.138,4.323-2.867,4.477-3.085C16.154,4.286,14.17,3.471,12,3.471 C11.311,3.471,10.641,3.554,9.998,3.709z M18.612,6.612C18.432,6.855,17,8.69,13.842,9.979c0.199,0.407,0.389,0.821,0.567,1.237 c0.063,0.148,0.124,0.295,0.184,0.441c2.842-0.357,5.666,0.215,5.948,0.275C20.522,9.916,19.801,8.065,18.612,6.612z"}))}].map((({name:e,title:t,color:n,icon:a})=>{return{isDefault:"facebook"===e,name:e,title:t,attributes:(r=`https://www.mailjet.com/images/theme/v1/icons/ico-social/${e}.png`,o=t,l=n,{img:r,label:o,style:{noptin:{border:{radius:"50%"},color:{background:l}}}}),icon:a||e,isActive:(t,n)=>t.img&&t.img.includes(e)||t.label&&t.label.includes(e)||t.url&&t.url.includes(e)};var r,o,l})),{name:Hl}=Vl,Ol={icon:"share",edit:({attributes:e,context:t,setAttributes:n,isSelected:a})=>{const{img:r,label:o,rel:l,iconSize:i}=e,[s,c]=(0,d.useState)(!0),[u,p]=(0,d.useState)(null),m=t["noptin/social-links/iconSize"];(0,d.useEffect)((()=>{i!==m&&n({iconSize:m})}),[m,i]),(0,d.useEffect)((()=>{a&&c(!0)}),[a]);const g=Ho(e),_=g?.style?.backgroundColor,h=(0,B.useBlockProps)({ref:p,style:{color:_,backgroundColor:_,boxSizing:"border-box",align:"center",borderCollapse:"separate",...Ao(e)}});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings"),initialOpen:!0},(0,d.createElement)(C.PanelRow,null,(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Image URL"),help:(0,ee.__)("Enter the URL of the image to use as an icon."),value:r||"",onChange:e=>n({img:e})})),(0,d.createElement)(C.PanelRow,null,(0,d.createElement)(B.URLInput,{label:(0,ee.__)("Social URL"),help:(0,ee.__)("The URL to link to."),className:"block-editor-link-control__field noptin-link-control__field",value:e.url||"",hasBorder:!0,isFullWidth:!0,onChange:e=>n({url:e})})),(0,d.createElement)(C.PanelRow,null,(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Social Network"),help:(0,ee.__)("The name of the social network."),value:o||"",onChange:e=>n({label:e})})))),(0,d.createElement)(B.InspectorControls,{group:"advanced"},(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Link rel"),value:l||"",onChange:e=>n({rel:e})})),a&&s&&(0,d.createElement)(C.Popover,{placement:"bottom",onClose:()=>{c(!1)},anchor:u,focusOnMount:!1,__unstableSlotName:"__unstable-block-tools-after",shift:!0},(0,d.createElement)(B.URLInput,{label:(0,ee.__)("Social URL"),help:(0,ee.__)("The URL to link to."),className:"block-editor-link-control__field noptin-link-control-popover__field",value:e.url||"",onChange:e=>n({url:e})})),(0,d.createElement)("td",{...h,width:i},(0,d.createElement)("img",{src:r||"https://placehold.co/30x30@2x.png",alt:o,width:i,height:i})))},save:function({attributes:e}){const{url:t,img:n,label:a,rel:r,iconSize:o}=e,l=Ho(e),i=l?.style?.backgroundColor,s=B.useBlockProps.save({width:o,style:{color:i,backgroundColor:i,borderCollapse:"separate",...Ao(e)}});return(0,d.createElement)("td",{...s,width:o},(0,d.createElement)("a",{href:t,rel:r||void 0,style:{display:"inline-block",textDecoration:"none"}},(0,d.createElement)("img",{src:n||"https://placehold.co/30x30@2x.png",alt:a,width:o,height:o})))},variations:Fl},jl={apiVersion:3,name:"core/html",title:(0,ee.__)("RAW","newsletter-optin-box"),category:"content",description:(0,ee.__)("Add custom HTML code or merge tags to your email.","newsletter-optin-box"),keywords:["code","raw"],attributes:{content:{type:"string",source:"raw"}},supports:{customClassName:!1,className:!1,html:!1,anchor:!1}},{name:Ul}=jl,Gl={icon:"editor-code",example:{attributes:{content:""+(0,ee.__)("Welcome to the wonderful world of blocks…")+""}},edit:function e({attributes:t,setAttributes:n}){const[a,r]=(0,S.useState)(!1),o=(0,S.useContext)(C.Disabled.Context),l=(0,_.useInstanceId)(e,"html-edit-desc"),i=(0,B.useBlockProps)({className:"block-library-html__edit","aria-describedby":a?l:void 0});return(0,d.createElement)("div",{...i},(0,d.createElement)(B.BlockControls,null,(0,d.createElement)(C.ToolbarGroup,null,(0,d.createElement)(C.ToolbarButton,{className:"components-tab-button",isPressed:!a,onClick:function(){r(!1)}},"HTML"),(0,d.createElement)(C.ToolbarButton,{className:"components-tab-button",isPressed:a,onClick:function(){r(!0)}},(0,ee.__)("Preview")))),a||o?(0,d.createElement)(S.RawHTML,null,t.content):(0,d.createElement)(B.PlainText,{value:t.content,onChange:e=>n({content:e}),placeholder:(0,ee.__)("Write HTML…"),"aria-label":(0,ee.__)("HTML")}))},save:function({attributes:e}){return(0,d.createElement)(S.RawHTML,null,e.content)}},Wl=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M18 4h-7c-1.1 0-2 .9-2 2v3H6c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2v-3h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h3V13c0 1.1.9 2 2 2h2.5v3zm0-4.5H11c-.3 0-.5-.2-.5-.5v-2.5H13c.3 0 .5.2.5.5v2.5zm5-.5c0 .3-.2.5-.5.5h-3V11c0-1.1-.9-2-2-2h-2.5V6c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5v7z"})),Kl=e=>{const t={style:{},vml:null};return e.style?.background?.backgroundImage?.url?(t.style.backgroundImage=`url("${e.style.background.backgroundImage.url}")`,t.style.backgroundSize="cover",t):t},ql={apiVersion:3,name:"noptin/group",title:(0,ee.__)("Section","newsletter-optin-box"),category:"design",description:(0,ee.__)("Gather blocks in a layout container.","newsletter-optin-box"),keywords:["container","wrapper","row","section"],attributes:{templateLock:{type:["string","boolean"],enum:["all","insert","contentOnly",!1]},allowedBlocks:{type:"array"},style:{type:"object",default:{noptin:{align:"center",color:{background:"#ffffff"}}}},width:{type:"string",default:"600px"}},noptin:{typography:!0,border:!0,color:!0,align:!0},supports:{__experimentalOnEnter:!0,__experimentalOnMerge:!0,__experimentalSettings:!0,anchor:!1,html:!1,background:{__experimentalSkipSerialization:!0,backgroundImage:!0},spacing:{__experimentalSkipSerialization:!0,margin:["top","bottom"],padding:!0,__experimentalDefaultControls:{margin:!0,padding:!0}}}},Yl={from:[{type:"block",isMultiBlock:!0,blocks:["*"],__experimentalConvert(e){const t=e.map((e=>(0,ne.createBlock)(e.name,e.attributes,e.innerBlocks)));return(0,ne.createBlock)("noptin/group",{},t)}}]},Zl=Yl,{name:Ql}=ql,Xl={icon:Wl,example:{attributes:{style:{color:{text:"#000000",background:"#ffffff"}}},innerBlocks:[{name:"core/paragraph",attributes:{customTextColor:"#cf2e2e",fontSize:"large",content:(0,ee.__)("One.")}},{name:"core/paragraph",attributes:{customTextColor:"#ff6900",fontSize:"large",content:(0,ee.__)("Two.")}},{name:"core/paragraph",attributes:{customTextColor:"#fcb900",fontSize:"large",content:(0,ee.__)("Three.")}},{name:"core/paragraph",attributes:{customTextColor:"#00d084",fontSize:"large",content:(0,ee.__)("Four.")}},{name:"core/paragraph",attributes:{customTextColor:"#0693e3",fontSize:"large",content:(0,ee.__)("Five.")}},{name:"core/paragraph",attributes:{customTextColor:"#9b51e0",fontSize:"large",content:(0,ee.__)("Six.")}}]},transforms:Zl,edit:({attributes:e,setAttributes:t})=>{const{width:n}=e,a=jo(e),r=Wo(e,!0),o={width:n,maxWidth:"100%",borderCollapse:"separate",...Ao(e),...Ho(e).style,...Kl(e).style},l=(0,B.useInnerBlocksProps)({style:Po(e)},{templateLock:e.templateLock,allowedBlocks:e.allowedBlocks}),i=(0,C.__experimentalUseCustomUnits)({availableUnits:["%","px","em","rem","vw"]});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Section settings")},(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Width"),labelPosition:"edge",__unstableInputWidth:"80px",min:10,value:n||"",onChange:e=>t({width:e}),units:i}))),(0,d.createElement)("div",{...(0,B.useBlockProps)({style:r.margin})},(0,d.createElement)("table",{width:n,align:a,cellPadding:0,cellSpacing:0,role:"presentation",style:o},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{className:"noptin-block-group__inner",style:r.padding,align:a},(0,d.createElement)("table",{border:0,cellPadding:0,cellSpacing:0,width:"100%"},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{...l}))))))))))},save:({attributes:e})=>{const{width:t}=e,n=Wo.save(e,!0),a=jo(e),r={width:t,maxWidth:"100%",borderCollapse:"separate",...Ao(e),...Ho(e).style,...Kl(e).style};return(0,d.createElement)("div",{...B.useBlockProps.save({style:n.margin})},(0,d.createElement)("table",{width:t,align:a,cellPadding:0,cellSpacing:0,role:"presentation",style:r},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{className:"noptin-block-group__inner",style:n.padding,align:a},(0,d.createElement)("table",{border:"0",cellPadding:"0",cellSpacing:"0",width:"100%"},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{style:{...Po(e),...Ho(e).style}},(0,d.createElement)(B.InnerBlocks.Content,null))))))))))}},Jl=e=>{const t=parseFloat(e);return Number.isFinite(t)?parseFloat(t.toFixed(2)):void 0};function ei(e,t){const{width:n=100/t}=e.attributes;return Jl(n)}function ti(e,t,n=e.length){const a=function(e,t=e.length){return e.reduce(((e,n)=>e+ei(n,t)),0)}(e,n);return Object.fromEntries(Object.entries(function(e,t=e.length){return e.reduce(((e,n)=>{const a=ei(n,t);return Object.assign(e,{[n.clientId]:a})}),{})}(e,n)).map((([e,n])=>[e,Jl(t*n/a)])))}function ni(e,t){return e.map((e=>({...e,attributes:{...e.attributes,width:`${t[e.clientId]}%`}})))}const ai=["noptin/column"];function ri({attributes:e,setAttributes:t,clientId:n}){const{isStackedOnMobile:a,verticalAlignment:r,templateLock:o}=e,{replaceInnerBlocks:l}=(0,P.useDispatch)(B.store),{count:i,canInsertColumnBlock:s,minCount:c,innerBlocks:u}=(0,P.useSelect)((e=>{const{canInsertBlockType:t,canRemoveBlock:a,getBlocks:r,getBlockCount:o}=e(B.store),l=r(n),i=l.reduce(((e,t,n)=>(a(t.clientId)||e.push(n),e)),[]);return{count:o(n),canInsertColumnBlock:t("noptin/column",n),minCount:Math.max(...i)+1,innerBlocks:l}}),[n]),p=(0,B.useBlockProps)({className:b()("noptin-columns noptin-columns__wrapper",{"noptin-is-stacked-on-mobile":a}),style:{...Po(e),...Ao(e),...Wo(e),...Ho(e).style}}),m=(0,B.useInnerBlocksProps)(p,{allowedBlocks:ai,orientation:"horizontal",renderAppender:!1,templateLock:o});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,null,(0,d.createElement)(B.BlockVerticalAlignmentToolbar,{onChange:e=>t({verticalAlignment:e}),value:r})),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,null,s&&(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.RangeControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,ee.__)("Columns"),value:i,onChange:e=>((e,t)=>{let a=[...u];const r=u.every((e=>{const t=e.attributes.width;return Number.isFinite(t?.endsWith?.("%")?parseFloat(t):t)})),o=t>e;if(o&&r){const n=Jl(100/t),r=ti(u,100-n);a=[...ni(u,r),...Array.from({length:t-e}).map((()=>(0,ne.createBlock)("noptin/column",{width:`${n}%`})))]}else if(o)a=[...u,...Array.from({length:t-e}).map((()=>(0,ne.createBlock)("noptin/column")))];else if(tt({isStackedOnMobile:!a})}))),(0,d.createElement)("div",{...m}))}function oi({clientId:e,name:t,setAttributes:n}){const{blockType:a,defaultVariation:r,variations:o}=(0,P.useSelect)((e=>{const{getBlockVariations:n,getBlockType:a,getDefaultBlockVariation:r}=e(ne.store);return{blockType:a(t),defaultVariation:r(t,"block"),variations:n(t,"block")}}),[t]),{replaceInnerBlocks:l}=(0,P.useDispatch)(B.store),i=(0,B.useBlockProps)();return(0,d.createElement)("div",{...i},(0,d.createElement)(B.__experimentalBlockVariationPicker,{icon:a?.icon?.src,label:a?.title,variations:o,onSelect:(t=r)=>{t.attributes&&n(t.attributes),t.innerBlocks&&l(e,(0,ne.createBlocksFromInnerBlocksTemplate)(t.innerBlocks),!0)},allowSkip:!0}))}const li={apiVersion:3,name:"noptin/columns",title:(0,ee.__)("Columns","newsletter-optin-box"),category:"design",description:(0,ee.__)("Display content in multiple columns, with blocks added to each column.","newsletter-optin-box"),attributes:{verticalAlignment:{type:"string",default:"top"},isStackedOnMobile:{type:"boolean",default:!0},templateLock:{type:["string","boolean"],enum:["all","insert","contentOnly",!1]}},providesContext:{"noptin/columns/verticalAlignment":"verticalAlignment","noptin/columns/isStackedOnMobile":"isStackedOnMobile"},noptin:{typography:!0,border:!0,color:!0},supports:{anchor:!1,html:!1,__experimentalExposeControlsToChildren:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,__experimentalDefaultControls:{margin:!0}}}};function ii(e,t=!1){return`\n ${t?"\x3c!--[if !true]>\x3c!--\x3e":"\x3c!--[if true]>"}\n ${e}\n ${t?"\x3c!--{const t=+(100/e.length).toFixed(2),n=e.map((({name:e,attributes:n,innerBlocks:a})=>["noptin/column",{width:`${t}%`},[[e,{...n},a]]]));return(0,ne.createBlock)("noptin/columns",{},(0,ne.createBlocksFromInnerBlocksTemplate)(n))},isMatch:({length:e},t)=>(1!==t.length||"noptin/columns"!==t[0].name)&&e&&e<=6}],ungroup:(e,t)=>t.flatMap((e=>e.innerBlocks))},{name:ui}=li,pi={icon:"columns",variations:si,edit:e=>{const{clientId:t}=e,n=(0,P.useSelect)((e=>e(B.store).getBlocks(t).length>0),[t])?ri:oi;return(0,d.createElement)(n,{...e})},save:function({attributes:e}){const{isStackedOnMobile:t}=e,n={...Po(e),...Ao(e),...Wo.save(e),...Ho(e).style},a=B.useBlockProps.save({className:b()("noptin-columns noptin-columns__wrapper",{"noptin-is-stacked-on-mobile":t}),style:n}),r=ii(``),o=ii("
");return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(S.RawHTML,{children:`${r}\x3c!--[if !true]>\x3c!--\x3e`}),(0,d.createElement)("div",{...a},(0,d.createElement)(S.RawHTML,{children:"\x3c!--\x3c!--\x3e"})),(0,d.createElement)(S.RawHTML,{children:`\x3c!--"center"===e?"middle":e||void 0,gi={apiVersion:3,name:"noptin/column",title:(0,ee.__)("Column","newsletter-optin-box"),category:"design",parent:["noptin/columns"],description:(0,ee.__)("A single column within a columns block.","newsletter-optin-box"),attributes:{verticalAlignment:{type:"string",default:"top"},isStackedOnMobile:{type:"boolean",default:!0},width:{type:"string"},allowedBlocks:{type:"array"},templateLock:{type:["string","boolean"],enum:["all","insert","contentOnly",!1]}},usesContext:["noptin/columns/verticalAlignment","noptin/columns/isStackedOnMobile"],noptin:{typography:!0,border:!0,color:!0},supports:{__experimentalOnEnter:!0,anchor:!1,reusable:!1,html:!1,spacing:{__experimentalSkipSerialization:!0,padding:!0,margin:!0,__experimentalDefaultControls:{padding:!0,margin:!0}}}},{name:_i}=gi,hi={icon:mi,edit:function({attributes:{width:e,templateLock:t,verticalAlignment:n,isStackedOnMobile:a,allowedBlocks:r,...o},setAttributes:l,clientId:i,context:s}){const c=s["noptin/columns/verticalAlignment"];(0,d.useEffect)((()=>{n!==c&&l({verticalAlignment:c})}),[c,n]);const u=s["noptin/columns/isStackedOnMobile"];(0,d.useEffect)((()=>{a!==u&&l({isStackedOnMobile:u})}),[u,a]);const p=(0,C.__experimentalUseCustomUnits)({availableUnits:["%","px","em","rem","vw"]}),m=(0,P.useSelect)((e=>e(B.store).getBlockOrder(i).length>0),[i]),g={verticalAlign:di(n)};if(e&&/\d/.test(e)){let t=Number.isFinite(e)?e+"%":e;if(!Number.isFinite(e)&&e?.endsWith("%")){const n=1e12;t=Math.round(Number.parseFloat(e)*n)/n+"%"}g.width=t}const _=(0,B.useBlockProps)({className:b()("noptin-column",{"noptin-is-stacked-on-mobile":a}),style:g}),h={...Po(o),...Ao(o),...Wo(o),...Ho(o).style};return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Column settings")},(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Width"),labelPosition:"edge",__unstableInputWidth:"80px",value:e||"",onChange:e=>{e=0>parseFloat(e)?"0":e,l({width:e})},units:p}))),(0,d.createElement)("div",{..._},(0,d.createElement)("div",{className:"noptin-column__inner",style:h},(0,d.createElement)(B.InnerBlocks,{templateLock:t,allowedBlocks:r,renderAppender:m?void 0:B.InnerBlocks.ButtonBlockAppender}))))},save:function({attributes:e}){const{width:t,verticalAlignment:n,isStackedOnMobile:a}=e,r={verticalAlign:di(n)};if(t&&/\d/.test(t)){let e=Number.isFinite(t)?t+"%":t;if(!Number.isFinite(t)&&t?.endsWith("%")){const n=1e12;e=Math.round(Number.parseFloat(t)*n)/n+"%"}r.width=e}const o=B.useBlockProps.save({className:b()("noptin-column",{"noptin-is-stacked-on-mobile":a}),style:r}),l=ii(``),i=ii(""),s={...Po(e),...Ao(e),...Wo(e),...Ho(e).style};return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(S.RawHTML,{children:`${l}\x3c!--[if !true]>\x3c!--\x3e`}),(0,d.createElement)("div",{...o},(0,d.createElement)(S.RawHTML,{children:"\x3c!--[if !true]>\x3c!--\x3e"}),(0,d.createElement)("div",{className:"noptin-column__inner",style:s},(0,d.createElement)(B.InnerBlocks.Content,null)),(0,d.createElement)(S.RawHTML,{children:"\x3c!--[if !true]>\x3c!--\x3e"})),(0,d.createElement)(S.RawHTML,{children:`\x3c!--(0,ne.createBlock)("noptin/separator")},{type:"raw",selector:"hr",schema:{hr:{}}}]},{name:vi}=fi,Ei={icon:bi,transforms:yi,edit:function({attributes:e,setAttributes:t}){const{width:n,height:a}=e,r=Ho(e),o=r?.style?.backgroundColor,l=(0,C.__experimentalUseCustomUnits)({availableUnits:["%","px","em","rem"]});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Width"),labelPosition:"edge",__unstableInputWidth:"80px",value:n||"",onChange:e=>{e=0>parseFloat(e)?"0":e,t({width:e})},units:l}),(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Height"),labelPosition:"edge",__unstableInputWidth:"80px",value:a||"",onChange:e=>{e=e?0>parseFloat(e)?"0":e:"1em",t({height:e})},units:l}))),(0,d.createElement)("hr",{...(0,B.useBlockProps)({style:{color:o,backgroundColor:o,borderWidth:0,height:a||"1em",width:n||"100%",maxWidth:"100%",...Wo(e)},align:jo(e)})}))},save:function({attributes:e}){const{width:t,height:n}=e,a=Ho(e),r=a?.style?.backgroundColor;return(0,d.createElement)("hr",{...B.useBlockProps.save({style:{color:r,backgroundColor:r,borderWidth:0,height:n||"1em",width:t||"100%",maxWidth:"100%",...Wo.save(e)},align:jo(e)})})}},xi=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M7 18h4.5v1.5h-7v-7H6V17L17 6h-4.5V4.5h7v7H18V7L7 18Z"})),ki={apiVersion:3,name:"noptin/spacer",title:(0,ee.__)("Spacer","newsletter-optin-box"),category:"design",description:(0,ee.__)("Add a blank space between blocks and customize its height.","newsletter-optin-box"),attributes:{height:{type:"string",default:"100px"}},noptin:{color:{background:!0}},supports:{anchor:!1,spacing:{__experimentalSkipSerialization:!0,margin:["top","bottom"],__experimentalDefaultControls:{margin:!0}}}},{name:wi}=ki,Ci={icon:xi,edit:({attributes:e,isSelected:t,setAttributes:n})=>{const{height:a}=e,r=Ho(e),o=r?.style?.backgroundColor,l={backgroundColor:o||(t?"#95a5a6":void 0),height:a,...Wo(e)},i=(0,C.__experimentalUseCustomUnits)({availableUnits:["px","em","rem"],defaultValues:{px:100,em:10,rem:10}});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)("div",{...(0,B.useBlockProps)({style:l})}," "),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(C.__experimentalUnitControl,{label:(0,ee.__)("Height"),labelPosition:"edge",__unstableInputWidth:"80px",value:a||"",onChange:e=>{e=e?0>parseFloat(e)?"0px":e:"0px",n({height:e})},units:i,min:0}))))},save:function({attributes:e}){const{height:t}=e,n=Ho(e),a=n?.style?.backgroundColor;return(0,d.createElement)("div",{...B.useBlockProps.save({style:{color:a,backgroundColor:a,height:t||"100px",lineHeight:t||"100px",...Wo.save(e)}})}," ")}},Si=(0,P.withDispatch)(((e,{clientId:t,attributes:n})=>{const{replaceBlock:a}=e(B.store);return{convertToHTML(){a(t,(0,ne.createBlock)("core/html",{content:n.originalUndelimitedContent}))}}}))((function({attributes:e,convertToHTML:t,clientId:n}){const{originalName:a,originalUndelimitedContent:r}=e,o=!!r,{hasHTMLBlock:l}=(0,P.useSelect)((e=>{const{canInsertBlockType:t,getBlockRootClientId:a}=e(B.store);return{hasHTMLBlock:t("core/html",a(n))}}),[n]),i=[];let s;const c=(0,d.createElement)(C.Button,{key:"convert",onClick:t,variant:"primary"},(0,ee.__)("Keep as HTML"));return o&&l?(s=(0,ee.sprintf)(/* translators: %s: block name */ (0,ee.__)('Your site doesn’t include support for the "%s" block. You can leave this block intact, convert its content to a RAW block, or remove it entirely.'),a),i.push(c)):s=(0,ee.sprintf)(/* translators: %s: block name */ -(0,ee.__)('Your site doesn’t include support for the "%s" block. You can leave this block intact or remove it entirely.'),a),(0,d.createElement)("div",{...(0,B.useBlockProps)({className:"has-warning"})},(0,d.createElement)(B.Warning,{actions:i},s),(0,d.createElement)(S.RawHTML,null,(0,vo.safeHTML)(r)))})),Ii={apiVersion:3,name:"noptin/missing",title:(0,ee.__)("Unsupported Block","newsletter-optin-box"),category:"content",description:(0,ee.__)("This block is not supported in the email editor.","newsletter-optin-box"),attributes:{originalName:{type:"string"},originalUndelimitedContent:{type:"string"},originalContent:{type:"string",source:"raw"}},supports:{className:!1,customClassName:!1,inserter:!1,html:!1,reusable:!1,anchor:!1}},{name:Ai}=Ii,Ni={name:Ai,edit:Pi,save:function({attributes:e}){return(0,d.createElement)(S.RawHTML,null,e.originalContent)}},Mi={apiVersion:3,name:"noptin/shortcode",title:(0,ee.__)("Merge Tag","newsletter-optin-box"),category:"dynamic",description:(0,ee.__)("Insert additional custom elements with a WordPress shortcode or Noptin Merge tag.","newsletter-optin-box"),keywords:["merge tag","smart tag","shortcode","noptin"],attributes:{text:{type:"string",source:"raw"}},supports:{customClassName:!1,className:!1,html:!1,anchor:!1}},Li={from:[{type:"shortcode",tag:"[a-z][a-z0-9_.-]*",attributes:{text:{type:"string",shortcode:(e,{content:t})=>(0,Qa.removep)((0,Qa.autop)(t))}},priority:20}]},{name:Ri}=Mi,zi={icon:"shortcode",transforms:Li,edit:function e({attributes:t,setAttributes:n}){const a=`blocks-shortcode-input-${(0,_.useInstanceId)(e)}`;return(0,d.createElement)("div",{...(0,B.useBlockProps)({className:"components-placeholder"})},(0,d.createElement)("label",{htmlFor:a,className:"components-placeholder__label"},(0,d.createElement)(C.Icon,{icon:"shortcode"}),(0,ee.__)("Merge tag / Shortcode","newsletter-optin-box")),(0,d.createElement)(B.PlainText,{className:"blocks-shortcode__textarea",id:a,value:t.text,"aria-label":(0,ee.__)("Shortcode text"),placeholder:(0,ee.__)("Write merge tag or shortcode here…"),onChange:e=>n({text:e})}))},save:function({attributes:e}){return(0,d.createElement)(S.RawHTML,null,e.text)}},$i=[{label:(0,ee.__)("Newest to oldest"),value:"date/desc"},{label:(0,ee.__)("Oldest to newest"),value:"date/asc"},{ +(0,ee.__)('Your site doesn’t include support for the "%s" block. You can leave this block intact or remove it entirely.'),a),(0,d.createElement)("div",{...(0,B.useBlockProps)({className:"has-warning"})},(0,d.createElement)(B.Warning,{actions:i},s),(0,d.createElement)(S.RawHTML,null,(0,bo.safeHTML)(r)))})),Ti={apiVersion:3,name:"noptin/missing",title:(0,ee.__)("Unsupported Block","newsletter-optin-box"),category:"content",description:(0,ee.__)("This block is not supported in the email editor.","newsletter-optin-box"),attributes:{originalName:{type:"string"},originalUndelimitedContent:{type:"string"},originalContent:{type:"string",source:"raw"}},supports:{className:!1,customClassName:!1,inserter:!1,html:!1,reusable:!1,anchor:!1}},{name:Bi}=Ti,Pi={name:Bi,edit:Si,save:function({attributes:e}){return(0,d.createElement)(S.RawHTML,null,e.originalContent)}},Ii={apiVersion:3,name:"noptin/shortcode",title:(0,ee.__)("Merge Tag","newsletter-optin-box"),category:"dynamic",description:(0,ee.__)("Insert additional custom elements with a WordPress shortcode or Noptin Merge tag.","newsletter-optin-box"),keywords:["merge tag","smart tag","shortcode","noptin"],attributes:{text:{type:"string",source:"raw"}},supports:{customClassName:!1,className:!1,html:!1,anchor:!1}},Ai=window.wp.autop,Ni={from:[{type:"shortcode",tag:"[a-z][a-z0-9_.-]*",attributes:{text:{type:"string",shortcode:(e,{content:t})=>(0,Ai.removep)((0,Ai.autop)(t))}},priority:20}]},{name:Mi}=Ii,Li={icon:"shortcode",transforms:Ni,edit:function e({attributes:t,setAttributes:n}){const a=`blocks-shortcode-input-${(0,_.useInstanceId)(e)}`;return(0,d.createElement)("div",{...(0,B.useBlockProps)({className:"components-placeholder"})},(0,d.createElement)("label",{htmlFor:a,className:"components-placeholder__label"},(0,d.createElement)(C.Icon,{icon:"shortcode"}),(0,ee.__)("Merge tag / Shortcode","newsletter-optin-box")),(0,d.createElement)(B.PlainText,{className:"blocks-shortcode__textarea",id:a,value:t.text,"aria-label":(0,ee.__)("Shortcode text"),placeholder:(0,ee.__)("Write merge tag or shortcode here…"),onChange:e=>n({text:e})}))},save:function({attributes:e}){return(0,d.createElement)(S.RawHTML,null,e.text)}},Ri=[{label:(0,ee.__)("Newest to oldest"),value:"date/desc"},{label:(0,ee.__)("Oldest to newest"),value:"date/asc"},{ /* translators: label for ordering posts by title in ascending order */ label:(0,ee.__)("A → Z"),value:"title/asc"},{ /* translators: label for ordering posts by title in descending order */ -label:(0,ee.__)("Z → A"),value:"title/desc"}],Di=function({order:e,orderBy:t,onChange:n,options:a}){const r=a||$i;return(0,d.createElement)(C.SelectControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Order by"),value:`${t}/${e}`,options:r,onChange:e=>{const[t,a]=e.split("/");n({order:a,orderby:t})}})},Vi={popoverProps:{placement:"left-start",offset:259}},Fi=({filterKey:e,filter:t,query:n,setQuery:a})=>{const r=(0,d.createElement)(Da,{settingKey:e,setting:t,saved:n,setAttributes:a});return(0,d.createElement)(d.Fragment,null,r&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:t.label,hasValue:()=>!!n[e],onDeselect:()=>a({[e]:null})},r))},Oi=({type:e,label:t,orderOptions:n,filters:a})=>{const r=[`noptin/${e}-template`],o=[[`noptin/${e}-template`]],l={number:10,order:"desc",orderby:"date"};a&&Object.keys(a).forEach((e=>{void 0!==a[e].default&&(l[e]=a[e].default)}));const i=({setAttributes:e,attributes:i})=>{const s=i.columns>1,{query:c}=i,u=(0,d.useCallback)((t=>{e({query:{...c,...t}})}),[c,e]),p=a&&Object.keys(a).length>0,m=(0,B.useBlockProps)({style:{...No(i),...Lo(i),...Yo(i),...Uo(i).style}}),g=(0,B.useInnerBlocksProps)(m,{allowedBlocks:r,renderAppender:!1,template:o,templateLock:"all"});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(Di,{order:c.order,orderBy:c.orderby,options:n,onChange:u}),(0,d.createElement)(C.RangeControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,ee.sprintf)(/* translators: %s: plural name of the post type */ +label:(0,ee.__)("Z → A"),value:"title/desc"}],zi=function({order:e,orderBy:t,onChange:n,options:a}){const r=a||Ri;return(0,d.createElement)(C.SelectControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Order by"),value:`${t}/${e}`,options:r,onChange:e=>{const[t,a]=e.split("/");n({order:a,orderby:t})}})},Di={popoverProps:{placement:"left-start",offset:259}},$i=({filterKey:e,filter:t,query:n,setQuery:a})=>{const r=(0,d.createElement)($a,{settingKey:e,setting:t,saved:n,setAttributes:a});return(0,d.createElement)(d.Fragment,null,r&&(0,d.createElement)(C.__experimentalToolsPanelItem,{label:t.label,hasValue:()=>!!n[e],onDeselect:()=>a({[e]:null})},r))},Vi=({type:e,label:t,orderOptions:n,filters:a})=>{const r=[`noptin/${e}-template`],o=[[`noptin/${e}-template`]],l={number:10,order:"desc",orderby:"date"};a&&Object.keys(a).forEach((e=>{void 0!==a[e].default&&(l[e]=a[e].default)}));const i=({setAttributes:e,attributes:i})=>{const s=i.columns>1,{query:c}=i,u=(0,d.useCallback)((t=>{e({query:{...c,...t}})}),[c,e]),p=a&&Object.keys(a).length>0,m=(0,B.useBlockProps)({style:{...Po(i),...Ao(i),...Wo(i),...Ho(i).style}}),g=(0,B.useInnerBlocksProps)(m,{allowedBlocks:r,renderAppender:!1,template:o,templateLock:"all"});return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(zi,{order:c.order,orderBy:c.orderby,options:n,onChange:u}),(0,d.createElement)(C.RangeControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,ee.sprintf)(/* translators: %s: plural name of the post type */ (0,ee.__)("Number of %s to show"),t),value:c.number,onChange:e=>u({number:e}),min:1,max:20}),(0,d.createElement)(C.RangeControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,ee.__)("Columns"),value:i.columns,onChange:t=>e({columns:t}),min:1,max:4}),s&&(0,d.createElement)(C.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Stack on mobile"),checked:i.isStackedOnMobile,onChange:()=>e({isStackedOnMobile:!i.isStackedOnMobile})}),(0,d.createElement)(C.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,ee.sprintf)(/* translators: %s: plural name of the post type */ -(0,ee.__)("Skip sending this email if no %s are found"),t),checked:i.skipOnEmpty,onChange:()=>e({skipOnEmpty:!i.skipOnEmpty})}))),p&&(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.__experimentalToolsPanel,{className:"block-library-query-toolspanel__filters",label:(0,ee.__)("Filters"),resetAll:()=>u(l),dropdownMenuProps:Vi,as:"div"},Object.entries(a).map((([e,t])=>(0,d.createElement)(Fi,{key:e,filterKey:e,filter:t,query:c,setQuery:u}))))),(0,d.createElement)("div",{...g}))};return e=>{const{clientId:t}=e,n=(0,P.useSelect)((e=>e(B.store).getBlocks(t).length>0),[t])?i:si;return(0,d.createElement)(n,{...e})}},Hi=({name:e})=>({attributes:t})=>{const{isStackedOnMobile:n,skipOnEmpty:a,query:r,columns:o}=t,l={...No(t),...Lo(t),...Yo.save(t),...Uo(t).style},i={...r};Object.keys(i).forEach((e=>{""===i[e]&&delete i[e]}));const s=`noptin_${e}_list`,c=(0,E.addQueryArgs)("",i);return(0,d.createElement)("div",{...B.useBlockProps.save({style:l})},`[${s} query="${c.slice(1)}" columns=${o} responsive=${n?"yes":"no"} skiponempty=${a?"yes":"no"}]`,(0,d.createElement)(B.InnerBlocks.Content,null),`[/${s}]`)},ji=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})),Ui=(e,t)=>{let n=t||"";const a=n.includes("/")?n:"core/heading";return[a,{anchor:`block-${e}__list-heading`,style:{noptin:{typography:{fontSize:20,lineHeight:"1.3"}},spacing:{margin:{bottom:"10px"}}},..."core/heading"===a?{content:n}:{}}]},Gi=(e,t,n="left")=>{if(t)return[t,{anchor:`block-${e}__list-action`,style:{noptin:{border:{radius:"5px"},typography:{textTransform:"none",textDecoration:"none",textAlign:"center"},align:n}}}]},Wi=(e,t,n)=>{if(!t)return;const a=n?"10px":"0px";return[t,{anchor:`block-${e}__list-featured-image`,width:n?"150px":"",caption:"",style:{noptin:{typography:{textTransform:"none",textDecoration:"none",textAlign:"center"}},spacing:{margin:{top:a,bottom:a,right:a,left:a},padding:{right:"0px",left:"0px"}}}}]},Ki=({name:e,type:t,template:n={}})=>{const{image:a,heading:r,description:o,meta:l,button:i}=n;return[{name:"list",title:(0,ee.__)("List"),icon:ji,isDefault:!0,attributes:{isStackedOnMobile:!1,columns:1,anchor:`block-${e}__list`,style:{noptin:{border:{border:{bottom:void 0,right:void 0,top:{color:"#e0dede",style:"solid",width:"1px"},left:void 0},radius:void 0}}}},innerBlocks:[[`noptin/${t}-template`,{style:{noptin:{border:{border:{top:void 0,right:void 0,bottom:{color:"#e0dede",style:"solid",width:"1px"},left:void 0},radius:void 0},color:{link:"#111111"}},spacing:{margin:{right:"0px",left:"0px",top:"0px",bottom:"0px"}}},anchor:`block-${e}__list-template`},[["noptin/columns",{verticalAlignment:"middle",isStackedOnMobile:!0,anchor:`block-${e}__list-columns`},(0,xr.compact)([a&&["noptin/column",{width:"150px",verticalAlignment:"middle",anchor:`block-${e}__list-column__left`,style:{spacing:{margin:{right:"0px",left:"0px",top:"0px",bottom:"0px"},padding:{right:"0px",left:"0px",top:"0px",bottom:"0px"}}}},[Wi(e,a,!0)]],["noptin/column",{width:"",verticalAlignment:"middle",anchor:`block-${e}__list-column__right`,style:{spacing:{margin:{right:"10px",left:"10px",top:"10px",bottom:"10px"},padding:{right:"0px",left:"0px",top:"0px",bottom:"0px"}}}},(0,xr.compact)([Ui(e,r),o&&["core/paragraph",{content:o,anchor:`block-${e}__list-description`,style:{noptin:{typography:{lineHeight:"1.4"}},spacing:{margin:{bottom:"10px"}}}}],l&&["core/paragraph",{content:l,anchor:`block-${e}__list-meta`,style:{noptin:{color:{text:"#666666"},typography:{fontSize:13}},spacing:{margin:{bottom:"10px"}}}}],Gi(e,i)])]])]]]],scope:["block"]},{name:"grid",title:(0,ee.__)("Grid"),icon:"grid-view",isDefault:!1,attributes:{isStackedOnMobile:!0,columns:2,anchor:`block-${e}__grid`},innerBlocks:[[`noptin/${t}-template`,{style:{noptin:{border:{border:{color:"#e0dede",style:"solid",width:"1px"},radius:void 0},typography:{textAlign:"center"},color:{link:"#111111"}},spacing:{margin:{bottom:"24px"}}},anchor:`block-${e}__grid__template`},(0,xr.compact)([Wi(e,a,!1),Ui(e,r),o&&["core/paragraph",{content:o,anchor:`block-${e}__list-description`,style:{noptin:{typography:{lineHeight:"1.4"}},spacing:{margin:{bottom:"10px"}}}}],l&&["core/paragraph",{content:l,anchor:`block-${e}__list-meta`,style:{noptin:{color:{text:"#666666"},typography:{fontSize:13}},spacing:{margin:{bottom:"10px"}}}}],Gi(e,i,"center")])]],scope:["block"]}]};function qi({attributes:e,setAttributes:t,isSelected:n,insertBlocksAfter:a,clientId:r,settings:o}){const{alt:l,caption:i,href:s,width:c,height:u,scale:p}=e,m=(0,_.usePrevious)(i),[g,h]=(0,S.useState)(!!i);(0,S.useEffect)((()=>{i&&!m&&h(!0)}),[i,m]);const b=(0,S.useCallback)((e=>{e&&!i&&e.focus()}),[i]);(0,S.useEffect)((()=>{n||i||h(!1)}),[n,i]);const f=(0,C.__experimentalUseCustomUnits)({availableUnits:["px"]});let y;return y=c&&u?`https://placehold.co/${parseInt(c)}x${parseInt(u)}`:c?`https://placehold.co/${parseInt(c)}`:u?`https://placehold.co/${parseInt(u)}`:"https://placehold.co/600",(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(C.ToolbarButton,{onClick:()=>{h(!g),g&&i&&t({caption:void 0})},icon:gl,isPressed:g,label:g?(0,ee.__)("Remove caption"):(0,ee.__)("Add caption")})),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Settings"),panelId:r,resetAll:()=>{t({width:void 0,height:void 0})}},(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Alternative text"),isShownByDefault:!0,hasValue:()=>""!==l,panelId:r,onDeselect:()=>t({alt:void 0})},(0,d.createElement)(Da,{settingKey:"alt",saved:e,setAttributes:t,setting:{el:"textarea",label:(0,ee.__)("Alternative text"),description:(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.ExternalLink,{href:"https://www.w3.org/WAI/tutorials/images/decision-tree"},(0,ee.__)("Describe the purpose of the image.")),(0,d.createElement)("br",null),(0,ee.__)("Leave empty if decorative."))}})),(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Link to"),isShownByDefault:!0,hasValue:()=>!!s,panelId:r,onDeselect:()=>t({href:void 0})},(0,d.createElement)(Da,{settingKey:"href",saved:e,setAttributes:t,setting:{el:"input",type:"text",label:(0,ee.__)("Link to"),description:(0,ee.__)("Enter URL to make the image a link.")}})),o&&Object.entries(o).map((([n,a])=>(0,d.createElement)(C.__experimentalToolsPanelItem,{label:a.label,isShownByDefault:!0,hasValue:()=>""!==e[n]&&void 0!==e[n],onDeselect:()=>t({key:void 0}),panelId:r,key:n},(0,d.createElement)(Da,{settingKey:n,prop:"settings",saved:e,setAttributes:t,setting:a})))),(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Width"),isShownByDefault:!0,hasValue:()=>!!c,onDeselect:()=>t({width:void 0}),panelId:r,style:{gridColumn:"span 1"}},(0,d.createElement)(B.__experimentalUnitControl,{label:(0,ee.__)("Width"),placeholder:(0,ee.__)("Auto"),labelPosition:"top",min:0,value:c||"",onChange:e=>t({width:e}),size:"__unstable-large"})),(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Height"),isShownByDefault:!0,hasValue:()=>!!u,onDeselect:()=>t({height:void 0}),panelId:r,style:{gridColumn:"span 1"}},(0,d.createElement)(B.__experimentalUnitControl,{label:(0,ee.__)("Height"),placeholder:(0,ee.__)("Auto"),labelPosition:"top",units:f,min:0,value:u||"",onChange:e=>t({height:e}),size:"__unstable-large"})))),(0,d.createElement)(fl,{href:s},(0,d.createElement)("img",{src:`${y}/31343c/fff.png?text=Placeholder`,alt:l||"Placeholder Image",style:{width:!c&&u?"auto":c,height:u,objectFit:p,maxWidth:"100%"}})),g&&(!B.RichText.isEmpty(i)||n)&&(0,d.createElement)(B.RichText,{identifier:"caption",ref:b,className:"wp-block-image__caption",tagName:"div","aria-label":(0,ee.__)("Image caption text"),placeholder:(0,ee.__)("Add caption"),value:i,onChange:e=>t({caption:e}),inlineToolbar:!0,__unstableOnSplitAtEnd:()=>a((0,ne.createBlock)((0,ne.getDefaultBlockName)())),style:{fontSize:"12px",textAlign:"center",marginTop:"12px"}}))}const Yi=({settings:e})=>function({attributes:t,setAttributes:n,isSelected:a,insertBlocksAfter:r,clientId:o}){const l=Wo(t),i=(0,B.useBlockProps)({style:{borderSpacing:"0px",borderCollapse:"collapse",width:"100%"},border:0,cellPadding:"0",cellSpacing:"0"}),s={...Lo(t),...Yo(t),width:t.width||void 0,display:"inline-block",maxWidth:"100%"};return(0,d.createElement)("table",{...i},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:l,className:b()({"is-selected":a})},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:s},(0,d.createElement)(qi,{attributes:t,setAttributes:n,isSelected:a,insertBlocksAfter:r,clientId:o,settings:e}))))))},Zi=(e,t)=>{let n="";return e&&Object.entries(e).forEach((([e,t])=>{if(t||0===t||!1===t){let a=t;"boolean"==typeof a&&(a=a?1:0),n+="number"==typeof a?` ${e}=${a}`:` ${e}="${a}"`}})),`[[${t}${n}]]`},Qi=({settings:e,attributes:t,setAttributes:n})=>e?(0,d.createElement)(d.Fragment,null,Object.entries(e).map((([e,a])=>(0,d.createElement)(Da,{key:e,settingKey:e,saved:t,prop:"settings",setAttributes:n,setting:a})))):null,Xi=({mergeTag:e,settings:t,linksTo:n})=>function({attributes:a,setAttributes:r}){const o=a.link&&!!n,l={...No(a),...Lo(a),...Yo(a),...Uo(a).style},i=(0,B.useBlockProps)({style:o?{cursor:"pointer"}:l}),s="h"+a.level,c=Zi(a.settings,e);return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(B.HeadingLevelDropdown,{value:a.level,onChange:e=>r({level:e})}),n&&(0,d.createElement)(C.ToolbarButton,{icon:"admin-links",label:(0,ee.__)("Link"),onClick:()=>r({link:!a.link}),isPressed:a.link,size:"compact"})),t&&(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,null,(0,d.createElement)(C.__experimentalVStack,null,(0,d.createElement)(Qi,{settings:t,attributes:a,setAttributes:r})))),(0,d.createElement)((()=>o?(0,d.createElement)("a",{href:`${n}`,...i},(0,d.createElement)(s,{style:l},c)):(0,d.createElement)(s,{...i},c)),null))},Ji=({mergeTag:e})=>function({attributes:t}){const{alt:n,caption:a,href:r,width:o,height:l}=t,i=Wo(t),s=Zi(t.settings,e),c=(0,d.createElement)("img",{src:s,alt:n,style:{width:!o&&l?"auto":o,height:l,maxWidth:"100%"}}),u={...Lo(t),...Yo.save(t),width:o||void 0,display:"inline-block",maxWidth:"100%"},p=(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:u},r?(0,d.createElement)("a",{href:r,style:{display:"block",textDecoration:"none",maxWidth:"100%",lineHeight:0}},c):c,!B.RichText.isEmpty(a)&&(0,d.createElement)(B.RichText.Content,{className:"wp-block-image__caption",tagName:"div",value:a,style:{fontSize:"12px",textAlign:"center",marginTop:"12px"}})),m=B.useBlockProps.save({style:{borderSpacing:"0px",borderCollapse:"collapse",width:"100%"},border:0,cellPadding:"0",cellSpacing:"0",role:"presentation"});return(0,d.createElement)("table",{...m},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:i},p))))},es=({mergeTag:e,linksTo:t})=>function({attributes:n}){const a="h"+n.level,r=Zi(n.settings,e),o=n.link&&!!t,l={...No(n),...Lo(n),...Yo.save(n),...Uo(n).style},i=B.useBlockProps.save({style:o?{cursor:"pointer"}:l});return(0,d.createElement)((()=>o?(0,d.createElement)("a",{href:`${t}`,...i},(0,d.createElement)(a,{style:l},r)):(0,d.createElement)(a,{...i},r)),null)},ts=({mergeTag:e,settings:t})=>function({attributes:n,setAttributes:a}){const r=(0,B.useBlockProps)({className:"noptin-block__margin-wrapper",style:{...No(n),...Lo(n),...Yo(n),...Uo(n).style}}),o=n.element||"p";return(0,d.createElement)(d.Fragment,null,t&&(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,null,(0,d.createElement)(C.__experimentalVStack,null,(0,d.createElement)(Qi,{attributes:n,setAttributes:a,settings:t})))),(0,d.createElement)(o,{...r},Zi(n.settings,e)))},ns=({mergeTag:e})=>function({attributes:t}){const n=B.useBlockProps.save({className:"noptin-block__margin-wrapper",style:{...No(t),...Lo(t),...Yo.save(t),...Uo(t).style}}),a=t.element||"p";return(0,d.createElement)(a,{...n},Zi(t.settings,e))},as={el:"input",type:"text",label:(0,ee.__)("Button URL"),description:(0,ee.__)("The URL to link to.")},rs=({settings:e})=>function(t){const{attributes:n,setAttributes:a,isSelected:r,onReplace:o,mergeBlocks:l,clientId:i}=t,{placeholder:s,rel:c,text:u,width:p}=n,m=Wo(n),g=No(n),[h,b]=(0,S.useState)(null),f=Lo(n),y=Uo(n).style,v=Yo(n,!0),E=(0,S.useRef)(),x=(0,S.useRef)(),k=(0,B.useBlockProps)({ref:(0,_.useMergeRefs)([b,E]),width:"100%",border:0,cellPadding:0,cellSpacing:0,role:"presentation",style:{lineHeight:"100%",width:"100%",borderCollapse:"separate",margin:"0px"}}),[w,T]=(0,S.useState)(!0);(0,S.useEffect)((()=>{r&&T(!0)}),[r]);const I=function(e){const{replaceBlocks:t,selectionChange:n}=(0,P.useDispatch)(B.store),{getBlock:a,getBlockRootClientId:r,getBlockIndex:o}=(0,P.useSelect)(B.store),l=(0,S.useRef)(e);return l.current=e,(0,_.useRefEffect)((e=>{function i(e){if(e.defaultPrevented||e.keyCode!==St.ENTER)return;const{content:i,clientId:s}=l.current;if(i.length)return;e.preventDefault();const c=a(r(s)),u=o(s),p=(0,ne.cloneBlock)({...c,innerBlocks:c.innerBlocks.slice(0,u)}),m=(0,ne.createBlock)((0,ne.getDefaultBlockName)()),d=c.innerBlocks.slice(u+1),g=d.length?[(0,ne.cloneBlock)({...c,innerBlocks:d})]:[];t(c.clientId,[p,m,...g],1),n(m.clientId)}return e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i)}}),[])}({content:u,clientId:i}),A=(0,_.useMergeRefs)([I,x]);return(0,d.createElement)(d.Fragment,null,(0,d.createElement)("table",{...k},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:m},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:v.margin},(0,d.createElement)("table",{width:p?`${p}%`:void 0},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{bgcolor:y.backgroundColor,role:"presentation",valign:"middle",className:"noptin-button-link__wrapper",style:{background:y.backgroundColor,textAlign:g?.textAlign,cursor:"auto",...f}},(0,d.createElement)(B.RichText,{ref:A,tagName:"span","aria-label":(0,ee.__)("Button text"),placeholder:s||(0,ee.__)("Add text…"),value:u,onChange:e=>a({text:Pl(e)}),withoutInteractiveFormatting:!0,className:"noptin-button-link",style:{...v.padding,...g||{},color:y.color,margin:"0px",display:"block",wordBreak:"break-word"},onSplit:e=>(0,ne.createBlock)("noptin/button",{...n,text:e}),onReplace:o,onMerge:l,identifier:"text"})))))))))),r&&w&&(0,d.createElement)(C.Popover,{placement:"bottom",onClose:()=>{T(!1),x.current?.focus()},anchor:h,focusOnMount:!1,__unstableSlotName:"__unstable-block-tools-after",shift:!0},(0,d.createElement)("div",{style:{padding:"1em",minWidth:240}},(0,d.createElement)(Da,{settingKey:"url",saved:n,setAttributes:a,setting:as}))),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)(Da,{settingKey:"url",saved:n,setAttributes:a,setting:as}),(0,d.createElement)(Qi,{settings:e,attributes:n,setAttributes:a}),(0,d.createElement)(C.__experimentalToggleGroupControl,{label:(0,ee.__)("Button width"),className:"noptin-toggle-group-control",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isAdaptiveWidth:!0,isBlock:!0,isDeselectable:!0,onChange:function(e){const t=n.width===e?void 0:e;a({width:t})}},[25,50,75,100].map((e=>(0,d.createElement)(C.__experimentalToggleGroupControlOption,{key:e,label:`${e}%`,value:e})))))),(0,d.createElement)(B.InspectorControls,{group:"advanced"},(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Link rel"),value:c||"",onChange:e=>a({rel:e})})))},os=(e,t)=>{(0,ne.setCategories)([{slug:"content",title:(0,ee.__)("Content","newsletter-optin-box"),icon:"admin-generic"},{slug:"dynamic",title:(0,ee.__)("Dynamic","newsletter-optin-box"),icon:"image-filter"},{slug:"design",title:(0,ee.__)("Design","newsletter-optin-box"),icon:"welcome-widgets-menus"}]),Ko({name:ol,metadata:nl,settings:ll}),Ko({name:ul,metadata:il,settings:pl}),Ko({name:Tl,metadata:xl,settings:Bl}),Ko({name:Nl,metadata:Al,settings:Ml}),Ko({name:Fl,metadata:Vl,settings:Ol}),Ko({name:Ul,metadata:Hl,settings:Gl}),Ko({name:Kl,metadata:Wl,settings:ql}),Ko({name:ei,metadata:Ql,settings:ti}),Ko({name:di,metadata:ci,settings:gi}),Ko({name:fi,metadata:bi,settings:yi}),Ko({name:ki,metadata:Ei,settings:wi}),Ko({name:Ti,metadata:Si,settings:Bi}),Ko({name:Ai,metadata:Ii,settings:Ni}),Ko({name:Ri,metadata:Mi,settings:zi}),((e,t)=>{e.forEach((e=>{Array.isArray(e.metadata?.ancestor)&&Array.isArray(t)&&e.metadata.ancestor.some((e=>t.includes(e)))&&delete e.metadata.ancestor,(e=>{switch(e.defaults||(e.defaults={}),e.settings&&Object.entries(e.settings).forEach((([t,n])=>{void 0!==n.default&&(e.defaults[t]=n.default)})),e.element){case"heading":(e=>{const t=(({name:e,title:t,description:n,linksTo:a,metadata:r,defaults:o})=>{const l={level:{type:"number",default:o.level||2},anchor:{type:"string",default:t.toLowerCase().replace(" ","-")},settings:{type:"object",default:o.settings||{}}};return a&&(l.link={type:"boolean",default:!0}),{apiVersion:3,name:e,title:t,category:"dynamic",description:n,attributes:{...l,...r?.attributes||{}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0}},supports:{anchor:!1,className:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0,padding:!1}}},...r||{}}})(e),{name:n}=t;Ko({name:n,metadata:t,settings:{icon:e.icon||"plus-alt2",example:{attributes:{level:2}},edit:Xi(e),save:es(e)}})})(e);break;case"image":(e=>{const t=(({name:e,title:t,description:n,metadata:a,defaults:r})=>({apiVersion:3,name:e,title:t,category:"dynamic",description:n,attributes:{anchor:{type:"string",default:t.toLowerCase().replace(" ","-")},alt:{type:"string",source:"attribute",selector:"img",attribute:"alt",default:r.alt||"",__experimentalRole:"content"},caption:{type:"string",source:"html",selector:".wp-block-image__caption",default:r.alt||void 0,__experimentalRole:"content"},href:{type:"string",source:"attribute",selector:"a",attribute:"href",default:r.href||"",__experimentalRole:"content"},width:{type:"string"},height:{type:"string"},settings:{type:"object",default:r.settings||{}}},supports:{anchor:!1,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0}}},noptin:{border:!0,align:!0},...a||{}}))(e),{name:n}=t;Ko({name:n,metadata:t,settings:{icon:e.icon||ml,example:{attributes:{level:2}},edit:Yi(e),save:Ji(e)}})})(e);break;case"button":(e=>{const t=(({name:e,title:t,description:n,metadata:a,defaults:r})=>({apiVersion:3,name:e,title:t,category:"noptin/button"===e?"content":"dynamic",description:n,keywords:["link","cta"],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href",__experimentalRole:"content",default:r.url||""},text:{type:"string",source:"html",selector:"a",__experimentalRole:"content",default:r.text||""},rel:{type:"string",source:"attribute",selector:"a",attribute:"rel",__experimentalRole:"content"},placeholder:{type:"string",default:r.placeholder||void 0},style:{type:"object",default:{noptin:{border:{radius:"5px"},typography:{textTransform:"none",textDecoration:"none",textAlign:"center"}}}},width:{type:"string"},settings:{type:"object",default:r.settings||{}}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0},align:!0},supports:{anchor:!1,reusable:!1,shadow:!1,spacing:{__experimentalSkipSerialization:!0,padding:["horizontal","vertical"],margin:!0,__experimentalDefaultControls:{padding:!0,margin:!0}}},...a||{}}))(e),{name:n}=t;Ko({name:n,metadata:t,settings:{icon:e.icon||"button",example:{attributes:{}},edit:rs(e),save:function({attributes:e}){const{rel:t,text:n,url:a,width:r}=e,o=Wo(e),l=Lo(e),i=Uo(e),s=i?.style?.backgroundColor,c=i?.style?.color,u=Yo.save(e,!0),p={...u.padding,...No(e),borderRadius:l?.borderRadius,margin:"0px",display:"block",color:c,wordBreak:"break-word"},m=B.useBlockProps.save({width:"100%",border:0,cellPadding:0,cellSpacing:0,role:"presentation",style:{lineHeight:"100%",width:"100%",borderCollapse:"separate",margin:"0px"}});return n?(0,d.createElement)("table",{...m},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:o},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:u.margin},(0,d.createElement)("table",{width:r?`${r}%`:void 0},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{bgcolor:s,role:"presentation",valign:"middle",className:"noptin-button-link__wrapper",style:{background:s,textAlign:p.textAlign,cursor:"auto",...l}},(0,d.createElement)(B.RichText.Content,{tagName:"a",className:"noptin-button-link",href:a,style:p,value:n,rel:t})))))))))):null}}})})(e);break;default:(e=>{const t=(({name:e,title:t,description:n,defaults:a,element:r,metadata:o})=>({apiVersion:3,name:e,title:t,category:"dynamic",description:n,attributes:{anchor:{type:"string",default:t.toLowerCase().replace(" ","-")},element:{type:"string",default:r||"p"},settings:{type:"object",default:a.settings||{}}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0,link:!0}},supports:{anchor:!1,className:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0,padding:!1}},__experimentalSelector:r||"p"},...o||{}}))(e),{name:n}=t;Ko({name:n,metadata:t,settings:{icon:e.icon||"plus-alt2",example:{attributes:{}},edit:ts(e),save:ns(e)}})})(e)}})({...e})}))})(e,t),N.objects&&Object.keys(N.objects).forEach((e=>{(e=>{const t=(({name:e,label:t,singular_label:n,type:a,object_type:r,filters:o})=>{const l={};return o&&Object.keys(o).forEach((e=>{o[e].default&&(l[e]=o[e].default)})),{apiVersion:3,name:`noptin/${e.toLowerCase().replace(/[^a-z0-9\-]/g,"-")}`,title:t,category:"dynamic",description:(0,ee.sprintf)((0,ee.__)("Displays %s in a list or a grid","newsletter-optin-box"),t),keywords:[n,a,r,e,t],attributes:{query:{type:"object",default:{number:10,order:"desc",orderby:"date",...l}},skipOnEmpty:{type:"boolean",default:!1},isStackedOnMobile:{type:"boolean",default:!0},columns:{type:"number",default:1}},providesContext:{[`noptin/${e}/query`]:"query",[`noptin/${e}/isStackedOnMobile`]:"isStackedOnMobile",[`noptin/${e}/columns`]:"columns"},noptin:{typography:!0,border:!0,color:!0},supports:{anchor:!1,html:!1,__experimentalExposeControlsToChildren:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,__experimentalDefaultControls:{margin:!0}}}}})(e),{name:n}=t;Ko({name:n,metadata:t,settings:{icon:e.icon,edit:Oi(e),save:Hi(e),variations:Ki(e)}})})(N.objects[e]),(e=>{const t=(({name:e,type:t,singular_label:n})=>({apiVersion:3,name:`noptin/${t.toLowerCase().replace(/[^a-z0-9\-]/g,"-")}-template`,parent:[`noptin/${e.toLowerCase().replace(/[^a-z0-9\-]/g,"-")}`],title:(0,ee.sprintf)((0,ee.__)("%s Template","newsletter-optin-box"),n),category:"dynamic",description:(0,ee.sprintf)((0,ee.__)("Contains the block elements used to render a %s","newsletter-optin-box"),n),attributes:{style:{type:"object",default:{noptin:{border:{border:{color:"#95a5a6",width:"1px"},radius:"4px"}}}}},usesContext:[`noptin/${e}/isStackedOnMobile`,`noptin/${e}/columns`,`noptin/${e}/query`],noptin:{typography:!0,border:!0,color:!0},supports:{anchor:!1,html:!1,className:!1,customClassName:!1,spacing:{__experimentalSkipSerialization:!0,padding:!0,margin:!0,__experimentalDefaultControls:{padding:!0,margin:!0}}}}))(e),{name:n}=t;Xo[n]=e.type,Ko({name:n,metadata:t,settings:{icon:"art",edit:Qo(e),save:({attributes:e})=>{const t={...No(e),...Lo(e),...Yo.save(e),...Uo(e).style};return(0,d.createElement)("div",{...B.useBlockProps.save({style:t,className:"noptin-record"})},(0,d.createElement)(B.InnerBlocks.Content,null))}}})})(N.objects[e])})),(0,ne.setDefaultBlockName)("core/paragraph"),(0,ne.setFreeformContentHandlerName)("core/html"),(0,ne.setUnregisteredTypeHandlerName)("noptin/missing"),(0,ne.setGroupingBlockName)("noptin/group")},ls=window.wp.commands,is=window.wp.plugins,ss={ +(0,ee.__)("Skip sending this email if no %s are found"),t),checked:i.skipOnEmpty,onChange:()=>e({skipOnEmpty:!i.skipOnEmpty})}))),p&&(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.__experimentalToolsPanel,{className:"block-library-query-toolspanel__filters",label:(0,ee.__)("Filters"),resetAll:()=>u(l),dropdownMenuProps:Di,as:"div"},Object.entries(a).map((([e,t])=>(0,d.createElement)($i,{key:e,filterKey:e,filter:t,query:c,setQuery:u}))))),(0,d.createElement)("div",{...g}))};return e=>{const{clientId:t}=e,n=(0,P.useSelect)((e=>e(B.store).getBlocks(t).length>0),[t])?i:oi;return(0,d.createElement)(n,{...e})}},Fi=({name:e})=>({attributes:t})=>{const{isStackedOnMobile:n,skipOnEmpty:a,query:r,columns:o}=t,l={...Po(t),...Ao(t),...Wo.save(t),...Ho(t).style},i={...r};Object.keys(i).forEach((e=>{""===i[e]&&delete i[e]}));const s=`noptin_${e}_list`,c=(0,E.addQueryArgs)("",i);return(0,d.createElement)("div",{...B.useBlockProps.save({style:l})},`[${s} query="${c.slice(1)}" columns=${o} responsive=${n?"yes":"no"} skiponempty=${a?"yes":"no"}]`,(0,d.createElement)(B.InnerBlocks.Content,null),`[/${s}]`)},Hi=(0,d.createElement)(de.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(de.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})),Oi=(e,t)=>{let n=t||"";const a=n.includes("/")?n:"core/heading";return[a,{anchor:`block-${e}__list-heading`,style:{noptin:{typography:{fontSize:20,lineHeight:"1.3"}},spacing:{margin:{bottom:"10px"}}},..."core/heading"===a?{content:n}:{}}]},ji=(e,t,n="left")=>{if(t)return[t,{anchor:`block-${e}__list-action`,style:{noptin:{border:{radius:"5px"},typography:{textTransform:"none",textDecoration:"none",textAlign:"center"},align:n}}}]},Ui=(e,t,n)=>{if(!t)return;const a=n?"10px":"0px";return[t,{anchor:`block-${e}__list-featured-image`,width:n?"150px":"",caption:"",style:{noptin:{typography:{textTransform:"none",textDecoration:"none",textAlign:"center"}},spacing:{margin:{top:a,bottom:a,right:a,left:a},padding:{right:"0px",left:"0px"}}}}]},Gi=({name:e,type:t,template:n={}})=>{const{image:a,heading:r,description:o,meta:l,button:i}=n;return[{name:"list",title:(0,ee.__)("List"),icon:Hi,isDefault:!0,attributes:{isStackedOnMobile:!1,columns:1,anchor:`block-${e}__list`,style:{noptin:{border:{border:{bottom:void 0,right:void 0,top:{color:"#e0dede",style:"solid",width:"1px"},left:void 0},radius:void 0}}}},innerBlocks:[[`noptin/${t}-template`,{style:{noptin:{border:{border:{top:void 0,right:void 0,bottom:{color:"#e0dede",style:"solid",width:"1px"},left:void 0},radius:void 0},color:{link:"#111111"}},spacing:{margin:{right:"0px",left:"0px",top:"0px",bottom:"0px"}}},anchor:`block-${e}__list-template`},[["noptin/columns",{verticalAlignment:"middle",isStackedOnMobile:!0,anchor:`block-${e}__list-columns`},(0,yr.compact)([a&&["noptin/column",{width:"150px",verticalAlignment:"middle",anchor:`block-${e}__list-column__left`,style:{spacing:{margin:{right:"0px",left:"0px",top:"0px",bottom:"0px"},padding:{right:"0px",left:"0px",top:"0px",bottom:"0px"}}}},[Ui(e,a,!0)]],["noptin/column",{width:"",verticalAlignment:"middle",anchor:`block-${e}__list-column__right`,style:{spacing:{margin:{right:"10px",left:"10px",top:"10px",bottom:"10px"},padding:{right:"0px",left:"0px",top:"0px",bottom:"0px"}}}},(0,yr.compact)([Oi(e,r),o&&["core/paragraph",{content:o,anchor:`block-${e}__list-description`,style:{noptin:{typography:{lineHeight:"1.4"}},spacing:{margin:{bottom:"10px"}}}}],l&&["core/paragraph",{content:l,anchor:`block-${e}__list-meta`,style:{noptin:{color:{text:"#666666"},typography:{fontSize:13}},spacing:{margin:{bottom:"10px"}}}}],ji(e,i)])]])]]]],scope:["block"]},{name:"grid",title:(0,ee.__)("Grid"),icon:"grid-view",isDefault:!1,attributes:{isStackedOnMobile:!0,columns:2,anchor:`block-${e}__grid`},innerBlocks:[[`noptin/${t}-template`,{style:{noptin:{border:{border:{color:"#e0dede",style:"solid",width:"1px"},radius:void 0},typography:{textAlign:"center"},color:{link:"#111111"}},spacing:{margin:{bottom:"24px"}}},anchor:`block-${e}__grid__template`},(0,yr.compact)([Ui(e,a,!1),Oi(e,r),o&&["core/paragraph",{content:o,anchor:`block-${e}__list-description`,style:{noptin:{typography:{lineHeight:"1.4"}},spacing:{margin:{bottom:"10px"}}}}],l&&["core/paragraph",{content:l,anchor:`block-${e}__list-meta`,style:{noptin:{color:{text:"#666666"},typography:{fontSize:13}},spacing:{margin:{bottom:"10px"}}}}],ji(e,i,"center")])]],scope:["block"]}]};function Wi({attributes:e,setAttributes:t,isSelected:n,insertBlocksAfter:a,clientId:r,settings:o}){const{alt:l,caption:i,href:s,width:c,height:u,scale:p}=e,m=(0,_.usePrevious)(i),[g,h]=(0,S.useState)(!!i);(0,S.useEffect)((()=>{i&&!m&&h(!0)}),[i,m]);const b=(0,S.useCallback)((e=>{e&&!i&&e.focus()}),[i]);(0,S.useEffect)((()=>{n||i||h(!1)}),[n,i]);const f=(0,C.__experimentalUseCustomUnits)({availableUnits:["px"]});let y;return y=c&&u?`https://placehold.co/${parseInt(c)}x${parseInt(u)}`:c?`https://placehold.co/${parseInt(c)}`:u?`https://placehold.co/${parseInt(u)}`:"https://placehold.co/600",(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(C.ToolbarButton,{onClick:()=>{h(!g),g&&i&&t({caption:void 0})},icon:pl,isPressed:g,label:g?(0,ee.__)("Remove caption"):(0,ee.__)("Add caption")})),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.__experimentalToolsPanel,{label:(0,ee.__)("Settings"),panelId:r,resetAll:()=>{t({width:void 0,height:void 0})}},(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Alternative text"),isShownByDefault:!0,hasValue:()=>""!==l,panelId:r,onDeselect:()=>t({alt:void 0})},(0,d.createElement)($a,{settingKey:"alt",saved:e,setAttributes:t,setting:{el:"textarea",label:(0,ee.__)("Alternative text"),description:(0,d.createElement)(d.Fragment,null,(0,d.createElement)(C.ExternalLink,{href:"https://www.w3.org/WAI/tutorials/images/decision-tree"},(0,ee.__)("Describe the purpose of the image.")),(0,d.createElement)("br",null),(0,ee.__)("Leave empty if decorative."))}})),(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Link to"),isShownByDefault:!0,hasValue:()=>!!s,panelId:r,onDeselect:()=>t({href:void 0})},(0,d.createElement)($a,{settingKey:"href",saved:e,setAttributes:t,setting:{el:"input",type:"text",label:(0,ee.__)("Link to"),description:(0,ee.__)("Enter URL to make the image a link.")}})),o&&Object.entries(o).map((([n,a])=>(0,d.createElement)(C.__experimentalToolsPanelItem,{label:a.label,isShownByDefault:!0,hasValue:()=>""!==e[n]&&void 0!==e[n],onDeselect:()=>t({key:void 0}),panelId:r,key:n},(0,d.createElement)($a,{settingKey:n,prop:"settings",saved:e,setAttributes:t,setting:a})))),(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Width"),isShownByDefault:!0,hasValue:()=>!!c,onDeselect:()=>t({width:void 0}),panelId:r,style:{gridColumn:"span 1"}},(0,d.createElement)(B.__experimentalUnitControl,{label:(0,ee.__)("Width"),placeholder:(0,ee.__)("Auto"),labelPosition:"top",min:0,value:c||"",onChange:e=>t({width:e}),size:"__unstable-large"})),(0,d.createElement)(C.__experimentalToolsPanelItem,{label:(0,ee.__)("Height"),isShownByDefault:!0,hasValue:()=>!!u,onDeselect:()=>t({height:void 0}),panelId:r,style:{gridColumn:"span 1"}},(0,d.createElement)(B.__experimentalUnitControl,{label:(0,ee.__)("Height"),placeholder:(0,ee.__)("Auto"),labelPosition:"top",units:f,min:0,value:u||"",onChange:e=>t({height:e}),size:"__unstable-large"})))),(0,d.createElement)(_l,{href:s},(0,d.createElement)("img",{src:`${y}/31343c/fff.png?text=Placeholder`,alt:l||"Placeholder Image",style:{width:!c&&u?"auto":c,height:u,objectFit:p,maxWidth:"100%"}})),g&&(!B.RichText.isEmpty(i)||n)&&(0,d.createElement)(B.RichText,{identifier:"caption",ref:b,className:"wp-block-image__caption",tagName:"div","aria-label":(0,ee.__)("Image caption text"),placeholder:(0,ee.__)("Add caption"),value:i,onChange:e=>t({caption:e}),inlineToolbar:!0,__unstableOnSplitAtEnd:()=>a((0,ne.createBlock)((0,ne.getDefaultBlockName)())),style:{fontSize:"12px",textAlign:"center",marginTop:"12px"}}))}const Ki=({settings:e})=>function({attributes:t,setAttributes:n,isSelected:a,insertBlocksAfter:r,clientId:o}){const l=jo(t),i=(0,B.useBlockProps)({style:{borderSpacing:"0px",borderCollapse:"collapse",width:"100%"},border:0,cellPadding:"0",cellSpacing:"0"}),s={...Ao(t),...Wo(t),width:t.width||void 0,display:"inline-block",maxWidth:"100%"};return(0,d.createElement)("table",{...i},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:l,className:b()({"is-selected":a})},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:s},(0,d.createElement)(Wi,{attributes:t,setAttributes:n,isSelected:a,insertBlocksAfter:r,clientId:o,settings:e}))))))},qi=(e,t)=>{let n="";return e&&Object.entries(e).forEach((([e,t])=>{if(t||0===t||!1===t){let a=t;"boolean"==typeof a&&(a=a?1:0),n+="number"==typeof a?` ${e}=${a}`:` ${e}="${a}"`}})),`[[${t}${n}]]`},Yi=({settings:e,attributes:t,setAttributes:n})=>e?(0,d.createElement)(d.Fragment,null,Object.entries(e).map((([e,a])=>(0,d.createElement)($a,{key:e,settingKey:e,saved:t,prop:"settings",setAttributes:n,setting:a})))):null,Zi=({mergeTag:e,settings:t,linksTo:n})=>function({attributes:a,setAttributes:r}){const o=a.link&&!!n,l={...Po(a),...Ao(a),...Wo(a),...Ho(a).style},i=(0,B.useBlockProps)({style:o?{cursor:"pointer"}:l}),s="h"+a.level,c=qi(a.settings,e);return(0,d.createElement)(d.Fragment,null,(0,d.createElement)(B.BlockControls,{group:"block"},(0,d.createElement)(B.HeadingLevelDropdown,{value:a.level,onChange:e=>r({level:e})}),n&&(0,d.createElement)(C.ToolbarButton,{icon:"admin-links",label:(0,ee.__)("Link"),onClick:()=>r({link:!a.link}),isPressed:a.link,size:"compact"})),t&&(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,null,(0,d.createElement)(C.__experimentalVStack,null,(0,d.createElement)(Yi,{settings:t,attributes:a,setAttributes:r})))),(0,d.createElement)((()=>o?(0,d.createElement)("a",{href:`${n}`,...i},(0,d.createElement)(s,{style:l},c)):(0,d.createElement)(s,{...i},c)),null))},Qi=({mergeTag:e})=>function({attributes:t}){const{alt:n,caption:a,href:r,width:o,height:l}=t,i=jo(t),s=qi(t.settings,e),c=(0,d.createElement)("img",{src:s,alt:n,style:{width:!o&&l?"auto":o,height:l,maxWidth:"100%"}}),u={...Ao(t),...Wo.save(t),width:o||void 0,display:"inline-block",maxWidth:"100%"},p=(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:u},r?(0,d.createElement)("a",{href:r,style:{display:"block",textDecoration:"none",maxWidth:"100%",lineHeight:0}},c):c,!B.RichText.isEmpty(a)&&(0,d.createElement)(B.RichText.Content,{className:"wp-block-image__caption",tagName:"div",value:a,style:{fontSize:"12px",textAlign:"center",marginTop:"12px"}})),m=B.useBlockProps.save({style:{borderSpacing:"0px",borderCollapse:"collapse",width:"100%"},border:0,cellPadding:"0",cellSpacing:"0",role:"presentation"});return(0,d.createElement)("table",{...m},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:i},p))))},Xi=({mergeTag:e,linksTo:t})=>function({attributes:n}){const a="h"+n.level,r=qi(n.settings,e),o=n.link&&!!t,l={...Po(n),...Ao(n),...Wo.save(n),...Ho(n).style},i=B.useBlockProps.save({style:o?{cursor:"pointer"}:l});return(0,d.createElement)((()=>o?(0,d.createElement)("a",{href:`${t}`,...i},(0,d.createElement)(a,{style:l},r)):(0,d.createElement)(a,{...i},r)),null)},Ji=({mergeTag:e,settings:t})=>function({attributes:n,setAttributes:a}){const r=(0,B.useBlockProps)({className:"noptin-block__margin-wrapper",style:{...Po(n),...Ao(n),...Wo(n),...Ho(n).style}}),o=n.element||"p";return(0,d.createElement)(d.Fragment,null,t&&(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,null,(0,d.createElement)(C.__experimentalVStack,null,(0,d.createElement)(Yi,{attributes:n,setAttributes:a,settings:t})))),(0,d.createElement)(o,{...r},qi(n.settings,e)))},es=({mergeTag:e})=>function({attributes:t}){const n=B.useBlockProps.save({className:"noptin-block__margin-wrapper",style:{...Po(t),...Ao(t),...Wo.save(t),...Ho(t).style}}),a=t.element||"p";return(0,d.createElement)(a,{...n},qi(t.settings,e))},ts={el:"input",type:"text",label:(0,ee.__)("Button URL"),description:(0,ee.__)("The URL to link to.")},ns=({settings:e})=>function(t){const{attributes:n,setAttributes:a,isSelected:r,onReplace:o,mergeBlocks:l,clientId:i}=t,{placeholder:s,rel:c,text:u,width:p}=n,m=jo(n),g=Po(n),[h,b]=(0,S.useState)(null),f=Ao(n),y=Ho(n).style,v=Wo(n,!0),E=(0,S.useRef)(),x=(0,S.useRef)(),k=(0,B.useBlockProps)({ref:(0,_.useMergeRefs)([b,E]),width:"100%",border:0,cellPadding:0,cellSpacing:0,role:"presentation",style:{lineHeight:"100%",width:"100%",borderCollapse:"separate",margin:"0px"}}),[w,T]=(0,S.useState)(!0);(0,S.useEffect)((()=>{r&&T(!0)}),[r]);const I=function(e){const{replaceBlocks:t,selectionChange:n}=(0,P.useDispatch)(B.store),{getBlock:a,getBlockRootClientId:r,getBlockIndex:o}=(0,P.useSelect)(B.store),l=(0,S.useRef)(e);return l.current=e,(0,_.useRefEffect)((e=>{function i(e){if(e.defaultPrevented||e.keyCode!==St.ENTER)return;const{content:i,clientId:s}=l.current;if(i.length)return;e.preventDefault();const c=a(r(s)),u=o(s),p=(0,ne.cloneBlock)({...c,innerBlocks:c.innerBlocks.slice(0,u)}),m=(0,ne.createBlock)((0,ne.getDefaultBlockName)()),d=c.innerBlocks.slice(u+1),g=d.length?[(0,ne.cloneBlock)({...c,innerBlocks:d})]:[];t(c.clientId,[p,m,...g],1),n(m.clientId)}return e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i)}}),[])}({content:u,clientId:i}),A=(0,_.useMergeRefs)([I,x]);return(0,d.createElement)(d.Fragment,null,(0,d.createElement)("table",{...k},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:m},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:v.margin},(0,d.createElement)("table",{width:p?`${p}%`:void 0},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{bgcolor:y.backgroundColor,role:"presentation",valign:"middle",className:"noptin-button-link__wrapper",style:{background:y.backgroundColor,textAlign:g?.textAlign,cursor:"auto",...f}},(0,d.createElement)(B.RichText,{ref:A,tagName:"span","aria-label":(0,ee.__)("Button text"),placeholder:s||(0,ee.__)("Add text…"),value:u,onChange:e=>a({text:Sl(e)}),withoutInteractiveFormatting:!0,className:"noptin-button-link",style:{...v.padding,...g||{},color:y.color,margin:"0px",display:"block",wordBreak:"break-word"},onSplit:e=>(0,ne.createBlock)("noptin/button",{...n,text:e}),onReplace:o,onMerge:l,identifier:"text"})))))))))),r&&w&&(0,d.createElement)(C.Popover,{placement:"bottom",onClose:()=>{T(!1),x.current?.focus()},anchor:h,focusOnMount:!1,__unstableSlotName:"__unstable-block-tools-after",shift:!0},(0,d.createElement)("div",{style:{padding:"1em",minWidth:240}},(0,d.createElement)($a,{settingKey:"url",saved:n,setAttributes:a,setting:ts}))),(0,d.createElement)(B.InspectorControls,null,(0,d.createElement)(C.PanelBody,{title:(0,ee.__)("Settings")},(0,d.createElement)($a,{settingKey:"url",saved:n,setAttributes:a,setting:ts}),(0,d.createElement)(Yi,{settings:e,attributes:n,setAttributes:a}),(0,d.createElement)(C.__experimentalToggleGroupControl,{label:(0,ee.__)("Button width"),className:"noptin-toggle-group-control",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isAdaptiveWidth:!0,isBlock:!0,isDeselectable:!0,onChange:function(e){const t=n.width===e?void 0:e;a({width:t})}},[25,50,75,100].map((e=>(0,d.createElement)(C.__experimentalToggleGroupControlOption,{key:e,label:`${e}%`,value:e})))))),(0,d.createElement)(B.InspectorControls,{group:"advanced"},(0,d.createElement)(C.TextControl,{__nextHasNoMarginBottom:!0,label:(0,ee.__)("Link rel"),value:c||"",onChange:e=>a({rel:e})})))},as=(e,t)=>{(0,ne.setCategories)([{slug:"content",title:(0,ee.__)("Content","newsletter-optin-box"),icon:"admin-generic"},{slug:"dynamic",title:(0,ee.__)("Dynamic","newsletter-optin-box"),icon:"image-filter"},{slug:"design",title:(0,ee.__)("Design","newsletter-optin-box"),icon:"welcome-widgets-menus"}]),Uo({name:nl,metadata:Jo,settings:al}),Uo({name:il,metadata:rl,settings:sl}),Uo({name:wl,metadata:yl,settings:Cl}),Uo({name:Pl,metadata:Bl,settings:Il}),Uo({name:Dl,metadata:zl,settings:$l}),Uo({name:Hl,metadata:Vl,settings:Ol}),Uo({name:Ul,metadata:jl,settings:Gl}),Uo({name:Ql,metadata:ql,settings:Xl}),Uo({name:ui,metadata:li,settings:pi}),Uo({name:_i,metadata:gi,settings:hi}),Uo({name:vi,metadata:fi,settings:Ei}),Uo({name:wi,metadata:ki,settings:Ci}),Uo({name:Bi,metadata:Ti,settings:Pi}),Uo({name:Mi,metadata:Ii,settings:Li}),((e,t)=>{e.forEach((e=>{Array.isArray(e.metadata?.ancestor)&&Array.isArray(t)&&e.metadata.ancestor.some((e=>t.includes(e)))&&delete e.metadata.ancestor,(e=>{switch(e.defaults||(e.defaults={}),e.settings&&Object.entries(e.settings).forEach((([t,n])=>{void 0!==n.default&&(e.defaults[t]=n.default)})),e.element){case"heading":(e=>{const t=(({name:e,title:t,description:n,linksTo:a,metadata:r,defaults:o})=>{const l={level:{type:"number",default:o.level||2},anchor:{type:"string",default:t.toLowerCase().replace(" ","-")},settings:{type:"object",default:o.settings||{}}};return a&&(l.link={type:"boolean",default:!0}),{apiVersion:3,name:e,title:t,category:"dynamic",description:n,attributes:{...l,...r?.attributes||{}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0}},supports:{anchor:!1,className:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0,padding:!1}}},...r||{}}})(e),{name:n}=t;Uo({name:n,metadata:t,settings:{icon:e.icon||"plus-alt2",example:{attributes:{level:2}},edit:Zi(e),save:Xi(e)}})})(e);break;case"image":(e=>{const t=(({name:e,title:t,description:n,metadata:a,defaults:r})=>({apiVersion:3,name:e,title:t,category:"dynamic",description:n,attributes:{anchor:{type:"string",default:t.toLowerCase().replace(" ","-")},alt:{type:"string",source:"attribute",selector:"img",attribute:"alt",default:r.alt||"",__experimentalRole:"content"},caption:{type:"string",source:"html",selector:".wp-block-image__caption",default:r.alt||void 0,__experimentalRole:"content"},href:{type:"string",source:"attribute",selector:"a",attribute:"href",default:r.href||"",__experimentalRole:"content"},width:{type:"string"},height:{type:"string"},settings:{type:"object",default:r.settings||{}}},supports:{anchor:!1,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0}}},noptin:{border:!0,align:!0},...a||{}}))(e),{name:n}=t;Uo({name:n,metadata:t,settings:{icon:e.icon||cl,example:{attributes:{level:2}},edit:Ki(e),save:Qi(e)}})})(e);break;case"button":(e=>{const t=(({name:e,title:t,description:n,metadata:a,defaults:r})=>({apiVersion:3,name:e,title:t,category:"noptin/button"===e?"content":"dynamic",description:n,keywords:["link","cta"],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href",__experimentalRole:"content",default:r.url||""},text:{type:"string",source:"html",selector:"a",__experimentalRole:"content",default:r.text||""},rel:{type:"string",source:"attribute",selector:"a",attribute:"rel",__experimentalRole:"content"},placeholder:{type:"string",default:r.placeholder||void 0},style:{type:"object",default:{noptin:{border:{radius:"5px"},typography:{textTransform:"none",textDecoration:"none",textAlign:"center"}}}},width:{type:"string"},settings:{type:"object",default:r.settings||{}}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0},align:!0},supports:{anchor:!1,reusable:!1,shadow:!1,spacing:{__experimentalSkipSerialization:!0,padding:["horizontal","vertical"],margin:!0,__experimentalDefaultControls:{padding:!0,margin:!0}}},...a||{}}))(e),{name:n}=t;Uo({name:n,metadata:t,settings:{icon:e.icon||"button",example:{attributes:{}},edit:ns(e),save:function({attributes:e}){const{rel:t,text:n,url:a,width:r}=e,o=jo(e),l=Ao(e),i=Ho(e),s=i?.style?.backgroundColor,c=i?.style?.color,u=Wo.save(e,!0),p={...u.padding,...Po(e),borderRadius:l?.borderRadius,margin:"0px",display:"block",color:c,wordBreak:"break-word"},m=B.useBlockProps.save({width:"100%",border:0,cellPadding:0,cellSpacing:0,role:"presentation",style:{lineHeight:"100%",width:"100%",borderCollapse:"separate",margin:"0px"}});return n?(0,d.createElement)("table",{...m},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{align:o},(0,d.createElement)("div",{className:"noptin-block__margin-wrapper",style:u.margin},(0,d.createElement)("table",{width:r?`${r}%`:void 0},(0,d.createElement)("tbody",null,(0,d.createElement)("tr",null,(0,d.createElement)("td",{bgcolor:s,role:"presentation",valign:"middle",className:"noptin-button-link__wrapper",style:{background:s,textAlign:p.textAlign,cursor:"auto",...l}},(0,d.createElement)(B.RichText.Content,{tagName:"a",className:"noptin-button-link",href:a,style:p,value:n,rel:t})))))))))):null}}})})(e);break;default:(e=>{const t=(({name:e,title:t,description:n,defaults:a,element:r,metadata:o})=>({apiVersion:3,name:e,title:t,category:"dynamic",description:n,attributes:{anchor:{type:"string",default:t.toLowerCase().replace(" ","-")},element:{type:"string",default:r||"p"},settings:{type:"object",default:a.settings||{}}},noptin:{typography:!0,border:!0,color:{background:!0,text:!0,link:!0}},supports:{anchor:!1,className:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,padding:!0,__experimentalDefaultControls:{margin:!0,padding:!1}},__experimentalSelector:r||"p"},...o||{}}))(e),{name:n}=t;Uo({name:n,metadata:t,settings:{icon:e.icon||"plus-alt2",example:{attributes:{}},edit:Ji(e),save:es(e)}})})(e)}})({...e})}))})(e,t),N.objects&&Object.keys(N.objects).forEach((e=>{(e=>{const t=(({name:e,label:t,singular_label:n,type:a,object_type:r,filters:o})=>{const l={};return o&&Object.keys(o).forEach((e=>{o[e].default&&(l[e]=o[e].default)})),{apiVersion:3,name:`noptin/${e.toLowerCase().replace(/[^a-z0-9\-]/g,"-")}`,title:t,category:"dynamic",description:(0,ee.sprintf)((0,ee.__)("Displays %s in a list or a grid","newsletter-optin-box"),t),keywords:[n,a,r,e,t],attributes:{query:{type:"object",default:{number:10,order:"desc",orderby:"date",...l}},skipOnEmpty:{type:"boolean",default:!1},isStackedOnMobile:{type:"boolean",default:!0},columns:{type:"number",default:1}},providesContext:{[`noptin/${e}/query`]:"query",[`noptin/${e}/isStackedOnMobile`]:"isStackedOnMobile",[`noptin/${e}/columns`]:"columns"},noptin:{typography:!0,border:!0,color:!0},supports:{anchor:!1,html:!1,__experimentalExposeControlsToChildren:!0,spacing:{__experimentalSkipSerialization:!0,margin:!0,__experimentalDefaultControls:{margin:!0}}}}})(e),{name:n}=t;Uo({name:n,metadata:t,settings:{icon:e.icon,edit:Vi(e),save:Fi(e),variations:Gi(e)}})})(N.objects[e]),(e=>{const t=(({name:e,type:t,singular_label:n})=>({apiVersion:3,name:`noptin/${t.toLowerCase().replace(/[^a-z0-9\-]/g,"-")}-template`,parent:[`noptin/${e.toLowerCase().replace(/[^a-z0-9\-]/g,"-")}`],title:(0,ee.sprintf)((0,ee.__)("%s Template","newsletter-optin-box"),n),category:"dynamic",description:(0,ee.sprintf)((0,ee.__)("Contains the block elements used to render a %s","newsletter-optin-box"),n),attributes:{style:{type:"object",default:{noptin:{border:{border:{color:"#95a5a6",width:"1px"},radius:"4px"}}}}},usesContext:[`noptin/${e}/isStackedOnMobile`,`noptin/${e}/columns`,`noptin/${e}/query`],noptin:{typography:!0,border:!0,color:!0},supports:{anchor:!1,html:!1,className:!1,customClassName:!1,spacing:{__experimentalSkipSerialization:!0,padding:!0,margin:!0,__experimentalDefaultControls:{padding:!0,margin:!0}}}}))(e),{name:n}=t;Yo[n]=e.type,Uo({name:n,metadata:t,settings:{icon:"art",edit:qo(e),save:({attributes:e})=>{const t={...Po(e),...Ao(e),...Wo.save(e),...Ho(e).style};return(0,d.createElement)("div",{...B.useBlockProps.save({style:t,className:"noptin-record"})},(0,d.createElement)(B.InnerBlocks.Content,null))}}})})(N.objects[e])})),(0,ne.setDefaultBlockName)("core/paragraph"),(0,ne.setFreeformContentHandlerName)("core/html"),(0,ne.setUnregisteredTypeHandlerName)("noptin/missing"),(0,ne.setGroupingBlockName)("noptin/group")},rs=window.wp.commands,os=window.wp.plugins,ls={ /* translators: accessibility text for the editor top bar landmark region. */ header:(0,ee.__)("Editor top bar","newsletter-optin-box"), /* translators: accessibility text for the editor content landmark region. */ @@ -85,5 +85,5 @@ actions:(0,ee.__)("Editor publish","newsletter-optin-box"), /* translators: accessibility text for the editor footer landmark region. */ footer:(0,ee.__)("Editor footer","newsletter-optin-box"), /* translators: accessibility text for the editor secondary sidebar landmark region. */ -secondarySidebar:(0,ee.__)("Document Overview","newsletter-optin-box")},cs=function({premiumFeature:e}){const t=(0,_.useViewportMatch)("large","<"),n=(0,_.useViewportMatch)("huge","<"),{setIsInserterOpened:a,setCurrentSidebar:r}=(0,P.useDispatch)(at),{emailType:o}=X(),{hasComplementaryArea:l,isInserterOpened:i,previousShortcut:s,nextShortcut:c}=(0,P.useSelect)((e=>{const{getAllShortcutKeyCombinations:n}=e(Oa.store);return{isInserterOpened:!t&&!!e(at).isInserterOpened()&&"visual"===o,hasComplementaryArea:!t&&!!e(at).getCurrentSidebar(),previousShortcut:n("core/edit-email/previous-region"),nextShortcut:n("core/edit-email/next-region")}}),[t,o]);(0,S.useEffect)((()=>{i&&n&&r(null)}),[i,r,a,n]),(0,S.useEffect)((()=>{l&&n&&a(!1)}),[l,a,n]);const u=b()("edit-post-layout","is-mode-"+o,{"is-sidebar-opened":l,"is-inserter-opened":i}),p="visual"===o&&!t;return(0,d.createElement)(ue,{isDistractionFree:!1,className:u,labels:ss,header:(0,d.createElement)(vr,{hideActions:!!e}),editorNotices:(0,d.createElement)(T.EditorNotices,null),notices:(0,d.createElement)(T.EditorSnackbars,null),secondarySidebar:!e&&i&&(0,d.createElement)(bo,null),sidebar:!e&&l&&(0,d.createElement)(po.Slot,null),content:e?(0,d.createElement)("div",{style:{padding:20}},e):(0,d.createElement)(tr,null),footer:p&&(0,d.createElement)(Er,null),shortcuts:{previous:s,next:c}})};function us(){const e=(0,_.useViewportMatch)("medium","<"),{createErrorNotice:t}=(0,P.useDispatch)(Ua.store),n=K(),a=_t(n,M.license?.data?.sub_types?.[n]?.category),[r,o]=pt({heading:(0,ee.__)("Unlock Premium Feature","newsletter-optin-box"),helpText:(0,ee.__)("This email type is only available to premium license holders.","newsletter-optin-box"),needsAddonsPack:!1,slug:"emails"}),l=(0,P.useSelect)((e=>!!e(re.store).get(A,"fullscreenMode")),[]);return(0,d.createElement)(Ka,null,(0,d.createElement)(T.UnsavedChangesWarning,null),(0,d.createElement)(T.AutosaveMonitor,null),(0,d.createElement)(T.LocalAutosaveMonitor,null),(0,d.createElement)(fo,null),(0,d.createElement)(ie,{isActive:l&&!e}),(0,d.createElement)(ja.Register,null),(0,d.createElement)(T.EditorKeyboardShortcutsRegister,null),(0,d.createElement)(T.EditorKeyboardShortcuts,null),(0,d.createElement)(cs,{premiumFeature:!r&&a?o:void 0}),(0,d.createElement)(mo,null),(0,d.createElement)(is.PluginArea,{onError:function(e){t((0,ee.sprintf)(/* translators: %s: plugin name */ -(0,ee.__)('The "%s" plugin has encountered an error and cannot be rendered.'),e))}}))}const ps=function({postId:e,postType:t,settings:n,initialEdits:a,...r}){const o=(0,P.useSelect)((n=>n(I.store).getEntityRecord("postType",t,e)),[t,e]),l=ot(n);return o?(0,d.createElement)(C.SlotFillProvider,null,(0,d.createElement)(T.EditorProvider,{settings:l,post:o,initialEdits:a,useSubRegistry:!1,...r},(0,d.createElement)(T.ErrorBoundary,null,(0,d.createElement)(ls.CommandMenu,null),(0,d.createElement)(us,null)),(0,d.createElement)(T.PostLockedModal,null))):(0,d.createElement)(C.Spinner,null)};function ms(e,t,n,a={},r={}){const o=document.getElementById(e);if(!o)return;const l=S.createRoot?(0,S.createRoot)(o):void 0;(0,P.dispatch)(re.store).setDefaults(A,{fullscreenMode:!0,focusMode:!1,keepCaretInsideBlock:!1,welcomeGuide:!0,welcomeGuideStyles:!0,welcomeGuidePage:!0,welcomeGuideTemplate:!0,showListViewByDefault:!1,isComplementaryAreaVisible:!0}),(0,P.dispatch)(ne.store).reapplyBlockTypeFilters(),(0,P.select)(re.store).get(A,"showListViewByDefault")&&(0,P.dispatch)(T.store).setIsListViewOpened(!0),os(N.dynamicBlocks||{},N.context),"Standards"!=("CSS1Compat"===document.compatMode?"Standards":"Quirks")&&console.warn("Your browser is using Quirks Mode. \nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening . Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins."),window.addEventListener("dragover",(e=>e.preventDefault()),!1),window.addEventListener("drop",(e=>e.preventDefault()),!1),l?l.render((0,d.createElement)(ps,{settings:a,postId:n,postType:t,initialEdits:r})):(0,S.render)((0,d.createElement)(ps,{settings:a,postId:n,postType:t,initialEdits:r}),o)}window.noptin=window.noptin||{},window.noptin.editEmail=u},184:(e,t)=>{var n;!function(){"use strict";var a={}.hasOwnProperty;function r(){for(var e=[],t=0;t{"use strict";var a=n(296),r={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function s(e){return a.isMemo(e)?l:i[e.$$typeof]||r}i[a.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[a.Memo]=l;var c=Object.defineProperty,u=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,m=Object.getOwnPropertyDescriptor,d=Object.getPrototypeOf,g=Object.prototype;e.exports=function e(t,n,a){if("string"!=typeof n){if(g){var r=d(n);r&&r!==g&&e(t,r,a)}var l=u(n);p&&(l=l.concat(p(n)));for(var i=s(t),_=s(n),h=0;h{"use strict";var n="function"==typeof Symbol&&Symbol.for,a=n?Symbol.for("react.element"):60103,r=n?Symbol.for("react.portal"):60106,o=n?Symbol.for("react.fragment"):60107,l=n?Symbol.for("react.strict_mode"):60108,i=n?Symbol.for("react.profiler"):60114,s=n?Symbol.for("react.provider"):60109,c=n?Symbol.for("react.context"):60110,u=n?Symbol.for("react.async_mode"):60111,p=n?Symbol.for("react.concurrent_mode"):60111,m=n?Symbol.for("react.forward_ref"):60112,d=n?Symbol.for("react.suspense"):60113,g=n?Symbol.for("react.suspense_list"):60120,_=n?Symbol.for("react.memo"):60115,h=n?Symbol.for("react.lazy"):60116,b=n?Symbol.for("react.block"):60121,f=n?Symbol.for("react.fundamental"):60117,y=n?Symbol.for("react.responder"):60118,v=n?Symbol.for("react.scope"):60119;function E(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case a:switch(e=e.type){case u:case p:case o:case i:case l:case d:return e;default:switch(e=e&&e.$$typeof){case c:case m:case h:case _:case s:return e;default:return t}}case r:return t}}}function x(e){return E(e)===p}t.AsyncMode=u,t.ConcurrentMode=p,t.ContextConsumer=c,t.ContextProvider=s,t.Element=a,t.ForwardRef=m,t.Fragment=o,t.Lazy=h,t.Memo=_,t.Portal=r,t.Profiler=i,t.StrictMode=l,t.Suspense=d,t.isAsyncMode=function(e){return x(e)||E(e)===u},t.isConcurrentMode=x,t.isContextConsumer=function(e){return E(e)===c},t.isContextProvider=function(e){return E(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===a},t.isForwardRef=function(e){return E(e)===m},t.isFragment=function(e){return E(e)===o},t.isLazy=function(e){return E(e)===h},t.isMemo=function(e){return E(e)===_},t.isPortal=function(e){return E(e)===r},t.isProfiler=function(e){return E(e)===i},t.isStrictMode=function(e){return E(e)===l},t.isSuspense=function(e){return E(e)===d},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===p||e===i||e===l||e===d||e===g||"object"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===_||e.$$typeof===s||e.$$typeof===c||e.$$typeof===m||e.$$typeof===f||e.$$typeof===y||e.$$typeof===v||e.$$typeof===b)},t.typeOf=E},296:(e,t,n)=>{"use strict";e.exports=n(103)}},n={};function a(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,a),o.exports}a.m=t,e=[],a.O=(t,n,r,o)=>{if(!n){var l=1/0;for(u=0;u=o)&&Object.keys(a.O).every((e=>a.O[e](n[s])))?n.splice(s--,1):(i=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={257:0,410:0};a.O.j=t=>0===e[t];var t=(t,n)=>{var r,o,[l,i,s]=n,c=0;if(l.some((t=>0!==e[t]))){for(r in i)a.o(i,r)&&(a.m[r]=i[r]);if(s)var u=s(a)}for(t&&t(n);ca(409)));r=a.O(r)})(); \ No newline at end of file +secondarySidebar:(0,ee.__)("Document Overview","newsletter-optin-box")},is=function({premiumFeature:e}){const t=(0,_.useViewportMatch)("large","<"),n=(0,_.useViewportMatch)("huge","<"),{setIsInserterOpened:a,setCurrentSidebar:r}=(0,P.useDispatch)(at),{emailType:o}=X(),{hasComplementaryArea:l,isInserterOpened:i,previousShortcut:s,nextShortcut:c}=(0,P.useSelect)((e=>{const{getAllShortcutKeyCombinations:n}=e(Ha.store);return{isInserterOpened:!t&&!!e(at).isInserterOpened()&&"visual"===o,hasComplementaryArea:!t&&!!e(at).getCurrentSidebar(),previousShortcut:n("core/edit-email/previous-region"),nextShortcut:n("core/edit-email/next-region")}}),[t,o]);(0,S.useEffect)((()=>{i&&n&&r(null)}),[i,r,a,n]),(0,S.useEffect)((()=>{l&&n&&a(!1)}),[l,a,n]);const u=b()("edit-post-layout","is-mode-"+o,{"is-sidebar-opened":l,"is-inserter-opened":i}),p="visual"===o&&!t;return(0,d.createElement)(ue,{isDistractionFree:!1,className:u,labels:ls,header:(0,d.createElement)(br,{hideActions:!!e}),editorNotices:(0,d.createElement)(T.EditorNotices,null),notices:(0,d.createElement)(T.EditorSnackbars,null),secondarySidebar:!e&&i&&(0,d.createElement)(go,null),sidebar:!e&&l&&(0,d.createElement)(so.Slot,null),content:e?(0,d.createElement)("div",{style:{padding:20}},e):(0,d.createElement)(Xa,null),footer:p&&(0,d.createElement)(fr,null),shortcuts:{previous:s,next:c}})};function ss(){const e=(0,_.useViewportMatch)("medium","<"),{createErrorNotice:t}=(0,P.useDispatch)(Ua.store),n=K(),a=_t(n,M.license?.data?.sub_types?.[n]?.category),[r,o]=pt({heading:(0,ee.__)("Unlock Premium Feature","newsletter-optin-box"),helpText:(0,ee.__)("This email type is only available to premium license holders.","newsletter-optin-box"),needsAddonsPack:!1,slug:"emails"}),l=(0,P.useSelect)((e=>!!e(re.store).get(A,"fullscreenMode")),[]);return(0,d.createElement)(Ka,null,(0,d.createElement)(T.UnsavedChangesWarning,null),(0,d.createElement)(T.AutosaveMonitor,null),(0,d.createElement)(T.LocalAutosaveMonitor,null),(0,d.createElement)(_o,null),(0,d.createElement)(ie,{isActive:l&&!e}),(0,d.createElement)(ja.Register,null),(0,d.createElement)(T.EditorKeyboardShortcutsRegister,null),(0,d.createElement)(T.EditorKeyboardShortcuts,null),(0,d.createElement)(is,{premiumFeature:!r&&a?o:void 0}),(0,d.createElement)(co,null),(0,d.createElement)(os.PluginArea,{onError:function(e){t((0,ee.sprintf)(/* translators: %s: plugin name */ +(0,ee.__)('The "%s" plugin has encountered an error and cannot be rendered.'),e))}}))}const cs=function({postId:e,postType:t,settings:n,initialEdits:a,...r}){const o=(0,P.useSelect)((n=>n(I.store).getEntityRecord("postType",t,e)),[t,e]),l=ot(n);return o?(0,d.createElement)(C.SlotFillProvider,null,(0,d.createElement)(T.EditorProvider,{settings:l,post:o,initialEdits:a,useSubRegistry:!1,...r},(0,d.createElement)(T.ErrorBoundary,null,(0,d.createElement)(rs.CommandMenu,null),(0,d.createElement)(ss,null)),(0,d.createElement)(T.PostLockedModal,null))):(0,d.createElement)(C.Spinner,null)};function us(e,t,n,a={},r={}){const o=document.getElementById(e);if(!o)return;const l=S.createRoot?(0,S.createRoot)(o):void 0;(0,P.dispatch)(re.store).setDefaults(A,{fullscreenMode:!0,focusMode:!1,keepCaretInsideBlock:!1,welcomeGuide:!0,welcomeGuideStyles:!0,welcomeGuidePage:!0,welcomeGuideTemplate:!0,showListViewByDefault:!1,isComplementaryAreaVisible:!0}),(0,P.dispatch)(ne.store).reapplyBlockTypeFilters(),(0,P.select)(re.store).get(A,"showListViewByDefault")&&(0,P.dispatch)(T.store).setIsListViewOpened(!0),as(N.dynamicBlocks||{},N.context),"Standards"!=("CSS1Compat"===document.compatMode?"Standards":"Quirks")&&console.warn("Your browser is using Quirks Mode. \nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening . Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins."),window.addEventListener("dragover",(e=>e.preventDefault()),!1),window.addEventListener("drop",(e=>e.preventDefault()),!1),l?l.render((0,d.createElement)(cs,{settings:a,postId:n,postType:t,initialEdits:r})):(0,S.render)((0,d.createElement)(cs,{settings:a,postId:n,postType:t,initialEdits:r}),o)}window.noptin=window.noptin||{},window.noptin.editEmail=u},184:(e,t)=>{var n;!function(){"use strict";var a={}.hasOwnProperty;function r(){for(var e=[],t=0;t{"use strict";var a=n(296),r={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function s(e){return a.isMemo(e)?l:i[e.$$typeof]||r}i[a.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[a.Memo]=l;var c=Object.defineProperty,u=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,m=Object.getOwnPropertyDescriptor,d=Object.getPrototypeOf,g=Object.prototype;e.exports=function e(t,n,a){if("string"!=typeof n){if(g){var r=d(n);r&&r!==g&&e(t,r,a)}var l=u(n);p&&(l=l.concat(p(n)));for(var i=s(t),_=s(n),h=0;h{"use strict";var n="function"==typeof Symbol&&Symbol.for,a=n?Symbol.for("react.element"):60103,r=n?Symbol.for("react.portal"):60106,o=n?Symbol.for("react.fragment"):60107,l=n?Symbol.for("react.strict_mode"):60108,i=n?Symbol.for("react.profiler"):60114,s=n?Symbol.for("react.provider"):60109,c=n?Symbol.for("react.context"):60110,u=n?Symbol.for("react.async_mode"):60111,p=n?Symbol.for("react.concurrent_mode"):60111,m=n?Symbol.for("react.forward_ref"):60112,d=n?Symbol.for("react.suspense"):60113,g=n?Symbol.for("react.suspense_list"):60120,_=n?Symbol.for("react.memo"):60115,h=n?Symbol.for("react.lazy"):60116,b=n?Symbol.for("react.block"):60121,f=n?Symbol.for("react.fundamental"):60117,y=n?Symbol.for("react.responder"):60118,v=n?Symbol.for("react.scope"):60119;function E(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case a:switch(e=e.type){case u:case p:case o:case i:case l:case d:return e;default:switch(e=e&&e.$$typeof){case c:case m:case h:case _:case s:return e;default:return t}}case r:return t}}}function x(e){return E(e)===p}t.AsyncMode=u,t.ConcurrentMode=p,t.ContextConsumer=c,t.ContextProvider=s,t.Element=a,t.ForwardRef=m,t.Fragment=o,t.Lazy=h,t.Memo=_,t.Portal=r,t.Profiler=i,t.StrictMode=l,t.Suspense=d,t.isAsyncMode=function(e){return x(e)||E(e)===u},t.isConcurrentMode=x,t.isContextConsumer=function(e){return E(e)===c},t.isContextProvider=function(e){return E(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===a},t.isForwardRef=function(e){return E(e)===m},t.isFragment=function(e){return E(e)===o},t.isLazy=function(e){return E(e)===h},t.isMemo=function(e){return E(e)===_},t.isPortal=function(e){return E(e)===r},t.isProfiler=function(e){return E(e)===i},t.isStrictMode=function(e){return E(e)===l},t.isSuspense=function(e){return E(e)===d},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===p||e===i||e===l||e===d||e===g||"object"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===_||e.$$typeof===s||e.$$typeof===c||e.$$typeof===m||e.$$typeof===f||e.$$typeof===y||e.$$typeof===v||e.$$typeof===b)},t.typeOf=E},296:(e,t,n)=>{"use strict";e.exports=n(103)}},n={};function a(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,a),o.exports}a.m=t,e=[],a.O=(t,n,r,o)=>{if(!n){var l=1/0;for(u=0;u=o)&&Object.keys(a.O).every((e=>a.O[e](n[s])))?n.splice(s--,1):(i=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={257:0,410:0};a.O.j=t=>0===e[t];var t=(t,n)=>{var r,o,[l,i,s]=n,c=0;if(l.some((t=>0!==e[t]))){for(r in i)a.o(i,r)&&(a.m[r]=i[r]);if(s)var u=s(a)}for(t&&t(n);ca(409)));r=a.O(r)})(); \ No newline at end of file diff --git a/includes/emails/automated-email-types/class-type-automation-rule.php b/includes/emails/automated-email-types/class-type-automation-rule.php index 28bf15aa..66d2d56a 100644 --- a/includes/emails/automated-email-types/class-type-automation-rule.php +++ b/includes/emails/automated-email-types/class-type-automation-rule.php @@ -385,10 +385,16 @@ public static function sync_campaign_to_rule( $campaign, $trigger_settings = nul if ( $is_new ) { $campaign_data = get_post_meta( $campaign->id, 'campaign_data', true ); + + // If data is stdClass, convert it to an array. + if ( is_object( $campaign_data ) ) { + $campaign_data = (array) $campaign_data; + } + $campaign_data = ! is_array( $campaign_data ) ? array() : $campaign_data; $campaign_data['automation_rule'] = $rule->get_id(); - update_post_meta( $campaign->id, 'campaign_data', $campaign_data ); + update_post_meta( $campaign->id, 'campaign_data', (object) $campaign_data ); } return $rule->get_data();