芝麻web文件管理V1.00
编辑当前文件:/home/ezdajrnh/public_html/wp-content/plugins/woocommerce/assets/client/admin/email-editor/index.js
/*! For license information please see index.js.LICENSE.txt */ (()=>{"use strict";var e={24148:(e,t,o)=>{o.d(t,{A:()=>r});var n=o(86087);const r=(0,n.forwardRef)((function({icon:e,size:t=24,...o},r){return(0,n.cloneElement)(e,{width:t,height:t,...o,ref:r})}))},30221:(e,t,o)=>{o.d(t,{P:()=>y});var n=o(39793),r=o(56427),s=o(47143),i=o(24148),a=o(5573);const l=(0,n.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsx)(a.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})});var c=o(27723),d=o(86087),m=o(48558);const p=window.wp.url;var u=o(52619),_=o(58039),g=o(49851),h=o(59191);const y=(0,d.memo)((function(){const e=(0,d.useRef)(null),{requestSendingNewsletterPreview:t,togglePreviewModal:o,updateSendPreviewEmail:a}=(0,s.useDispatch)(_.H),{toEmail:y,isSendingPreviewEmail:f,sendingPreviewStatus:x,isModalOpened:w,errorMessage:v,postType:b}=(0,s.useSelect)((e=>({...e(_.H).getPreviewState(),postType:e(_.H).getEmailPostType()})),[]),S=()=>{t(y)},j=(0,d.useMemo)((()=>(0,u.applyFilters)("woocommerce_email_editor_check_sending_method_configuration_link",`https://www.mailpoet.com/blog/mailpoet-smtp-plugin/?utm_source=woocommerce_email_editor&utm_medium=plugin&utm_source_platform=${b}`)),[b]),k=()=>{(0,h.yM)("send_preview_email_modal_closed"),o(!1)};return(0,d.useEffect)((()=>{w&&(e.current?.focus(),(0,h.yM)("send_preview_email_modal_opened"))}),[w]),w?(0,n.jsxs)(r.Modal,{className:"woocommerce-send-preview-email",title:(0,c.__)("Send a test email","woocommerce"),onRequestClose:k,focusOnMount:!1,children:[x===g.T.ERROR?(0,n.jsxs)("div",{className:"woocommerce-send-preview-modal-notice-error",children:[(0,n.jsx)("p",{children:(0,c.__)("Sorry, we were unable to send this email.","woocommerce")}),(0,n.jsx)("strong",{children:v&&(0,c.sprintf)((0,c.__)("Error: %s","woocommerce"),v)}),(0,n.jsxs)("ul",{children:[(0,n.jsx)("li",{children:j&&(0,d.createInterpolateElement)((0,c.__)("Please check your
sending method configuration with your hosting provider.","woocommerce"),{link:(0,n.jsx)("a",{href:j,target:"_blank",rel:"noopener noreferrer",onClick:()=>(0,h.yM)("send_preview_email_modal_check_sending_method_configuration_link_clicked")})})}),(0,n.jsx)("li",{children:(0,d.createInterpolateElement)((0,c.__)("Or, sign up for MailPoet Sending Service to easily send emails.
Sign up for free","woocommerce"),{link:(0,n.jsx)("a",{href:`https://account.mailpoet.com/?s=1&g=1&utm_source=woocommerce_email_editor&utm_medium=plugin&utm_source_platform=${b}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>(0,h.yM)("send_preview_email_modal_sign_up_for_mailpoet_sending_service_link_clicked")},"sign-up-for-free")})})]})]}):null,(0,n.jsx)("p",{children:(0,c.__)("Send yourself a test email to test how your email would look like in different email apps.","woocommerce")}),(0,n.jsx)(r.TextControl,{label:(0,c.__)("Send to","woocommerce"),onChange:e=>{a(e),(0,h.xW)("send_preview_email_modal_send_to_field_updated")},onKeyDown:e=>{const{keyCode:t}=e;t===m.ENTER&&(e.preventDefault(),S(),(0,h.yM)("send_preview_email_modal_send_to_field_key_code_enter"))},className:"woocommerce-send-preview-email__send-to-field",value:y,type:"email",ref:e,required:!0,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),x===g.T.SUCCESS?(0,n.jsxs)("p",{className:"woocommerce-send-preview-modal-notice-success",children:[(0,n.jsx)(i.A,{icon:l,style:{fill:"#4AB866"}}),(0,c.__)("Test email sent successfully!","woocommerce")]}):null,(0,n.jsxs)("div",{className:"woocommerce-send-preview-modal-footer",children:[(0,n.jsx)(r.Button,{variant:"tertiary",onClick:()=>{(0,h.yM)("send_preview_email_modal_close_button_clicked"),k()},children:(0,c.__)("Cancel","woocommerce")}),(0,n.jsx)(r.Button,{variant:"primary",onClick:()=>{S(),(0,h.yM)("send_preview_email_modal_send_test_email_button_clicked")},disabled:f||!(0,p.isEmail)(y),children:f?(0,c.__)("Sending…","woocommerce"):(0,c.__)("Send test email","woocommerce")})]})]}):null}))},94723:(e,t,o)=>{o.d(t,{G:()=>s,h:()=>i});var n=o(74997);const r=new Map;function s(e,t){const o=(0,n.getBlockType)(e);if(!o)return!1;const{name:s,...i}=o;try{r.has(s)||r.set(s,{...i});const e=t(i),o={...i,...e};return(0,n.unregisterBlockType)(s),(0,n.registerBlockType)(s,o),!0}catch(t){return console.error("Failed to update block settings for",e,t),!1}}function i(){const e=[];for(const[t,o]of r.entries())try{(0,n.unregisterBlockType)(t),(0,n.registerBlockType)(t,o),e.push(t),r.delete(t)}catch(e){console.error("Failed to restore block settings for",t,e)}return e}},93524:(e,t,o)=>{o.d(t,{oj:()=>a,r8:()=>l});var n=o(74997),r=o(47143);const s=new Set,i=new Map;function a(e,t){const o=((0,r.select)("core/blocks").getBlockStyles(e)||[]).find((e=>e.name===t));if(o){const n=i.get(e)||[];n.find((e=>e.name===t))||(n.push(o),i.set(e,n))}(0,n.unregisterBlockStyle)(e,t)}function l(){for(const e of s){const[t,o]=e.split("||");(0,n.unregisterBlockStyle)(t,o)}s.clear();for(const[e,t]of i.entries())t.forEach((t=>(0,n.registerBlockStyle)(e,t))),i.delete(e)}},43583:(e,t,o)=>{o.d(t,{$:()=>i,z:()=>s});var n=o(74997);const r=new Set;function s(e,t){(0,n.registerBlockVariation)(e,t),r.add(function(e,t){return`${e}||${t}`}(e,t.name))}function i(){for(const e of r){const[t,o]=e.split("||");(0,n.unregisterBlockVariation)(t,o)}r.clear()}},56554:(e,t,o)=>{o.d(t,{HY:()=>a,hC:()=>c,tN:()=>l});var n=o(52619);const r=new Set,s=new Set;function i(e,t){return`${e}||${t}`}function a(e,t,o,s){(0,n.addFilter)(e,t,o,s),r.add(i(e,t))}function l(e,t,o,r){(0,n.addAction)(e,t,o,r),s.add(i(e,t))}function c(){!function(){for(const e of r){const[t,o]=e.split("||");(0,n.removeFilter)(t,o),r.delete(e)}}(),function(){for(const e of s){const[t,o]=e.split("||");(0,n.removeAction)(t,o),s.delete(e)}}()}},16205:(e,t,o)=>{o.d(t,{aW:()=>l,gG:()=>i,le:()=>a});var n=o(50876);const r=new Set,s=new Map;function i(e,t){(0,n.registerFormatType)(e,t),r.add(e)}function a(e){const t=(0,n.unregisterFormatType)(e);t&&s.set(e,t)}function l(){for(const e of r)(0,n.unregisterFormatType)(e);r.clear();for(const[e,t]of s.entries())(0,n.registerFormatType)(e,t),s.delete(e)}},46701:(e,t,o)=>{o.d(t,{IF:()=>l});var n=o(93524),r=o(43583),s=o(16205),i=o(56554),a=o(94723);function l(){(0,a.h)(),(0,n.r8)(),(0,r.$)(),(0,s.aW)(),(0,i.hC)()}},59191:(e,t,o)=>{o.d(t,{T7:()=>d,V1:()=>s,oh:()=>a,vD:()=>i,xW:()=>c,yM:()=>l});var n=o(66087),r=o(52619);const s=()=>(0,r.applyFilters)("woocommerce_email_editor_events_tracking_enabled",!1),i="email_editor_events",a=new EventTarget,l=(e,t={})=>{if(!s())return;const o={name:`${i}_${e}`,..."object"!=typeof t?{data:t}:t};a.dispatchEvent(new CustomEvent(i,{detail:o}))},c=function(){const e={};return(t,o={})=>{if(!s())return;const n=`${t}_${JSON.stringify(o).length}`;e[n]||(l(t,o),e[n]=!0)}}(),d=(0,n.debounce)(l,700)},89832:(e,t,o)=>{o.d(t,{L:()=>i});var n=o(47143),r=o(43656),s=o(58039);function i(){return(0,n.useSelect)((e=>{const t=e(s.H);if(!t)return!1;const o=t.getEmailPostId(),n=t.getEmailPostType(),i=e(r.store).getCurrentPostId(),a=e(r.store).getCurrentPostType();if(String(i)===String(o)&&String(a)===String(n))return!0;if("wp_template"===a){const e=t.getCurrentTemplate();if(!e)return!1;const o=t.getEmailTemplates();return!!o&&o.some((t=>t.id===e.id&&t.post_types?.includes(n)))}return!1}),[])}},58039:(e,t,o)=>{o.d(t,{H:()=>n});const n="email-editor/editor"},68908:(e,t,o)=>{o.d(t,{y$:()=>ie});var n={};o.r(n),o.d(n,{requestSendingNewsletterPreview:()=>h,setContentValidation:()=>x,setEditorConfig:()=>S,setEditorSettings:()=>w,setEditorTheme:()=>v,setEditorUrls:()=>b,setEmailPost:()=>_,setIsFetchingPersonalizationTags:()=>y,setPersonalizationTagsList:()=>f,setTemplateToPost:()=>g,togglePreviewModal:()=>p,updateSendPreviewEmail:()=>u});var r={};o.r(r),o.d(r,{canUserEditGlobalEmailStyles:()=>$,canUserEditTemplates:()=>F,getBlockPatternsForEmailTemplate:()=>R,getContentValidation:()=>re,getCurrentTemplate:()=>V,getCurrentTemplateContent:()=>G,getEditedEmailContent:()=>A,getEditedPostTemplate:()=>D,getEmailPostId:()=>q,getEmailPostType:()=>Y,getEmailTemplates:()=>U,getGlobalEmailStylesPost:()=>W,getGlobalStylesPostId:()=>oe,getInitialEditorSettings:()=>Z,getPaletteColors:()=>J,getPersonalizationTagsList:()=>Q,getPersonalizationTagsState:()=>X,getPreviewState:()=>K,getSentEmailEditorPosts:()=>L,getStyles:()=>ee,getTheme:()=>te,getUrls:()=>ne,hasEdits:()=>H,hasEmptyContent:()=>B,isEmailSent:()=>z,isFeatureActive:()=>I});var s={};o.r(s),o.d(s,{getPersonalizationTagsList:()=>se});var i=o(47143);const a=window.wp.dataControls;var l=o(3582),c=o(58039),d=o(49851),m=o(59191);function p(e){return{type:"CHANGE_PREVIEW_STATE",state:{isModalOpened:e}}}function u(e){return{type:"CHANGE_PREVIEW_STATE",state:{toEmail:e}}}function _(e,t){if(!e||!t)throw new Error("setEmailPost requires valid postId and postType parameters");return{type:"SET_EMAIL_POST",state:{postId:e,postType:t}}}const g=e=>async({registry:t})=>{const o=t.select(c.H).getEmailPostId(),n=t.select(c.H).getEmailPostType();t.dispatch(l.store).editEntityRecord("postType",n,o,{template:e})};function*h(e){if(!(0,i.select)(c.H).getPreviewState().isSendingPreviewEmail){yield{type:"CHANGE_PREVIEW_STATE",state:{sendingPreviewStatus:null,isSendingPreviewEmail:!0}};try{const t=(0,i.select)(c.H).getEmailPostId();yield(0,a.apiFetch)({path:"/woocommerce-email-editor/v1/send_preview_email",method:"POST",data:{email:e,postId:t}}),yield{type:"CHANGE_PREVIEW_STATE",state:{sendingPreviewStatus:d.T.SUCCESS,isSendingPreviewEmail:!1}},(0,m.yM)("sent_preview_email",{postId:t,email:e})}catch(t){(0,m.yM)("sent_preview_email_error",{email:e}),yield{type:"CHANGE_PREVIEW_STATE",state:{sendingPreviewStatus:d.T.ERROR,isSendingPreviewEmail:!1,errorMessage:JSON.stringify(t?.error)}}}}}function y(e){return{type:"SET_IS_FETCHING_PERSONALIZATION_TAGS",state:{isFetching:e}}}function f(e){return{type:"SET_PERSONALIZATION_TAGS_LIST",state:{list:e}}}function x(e){return{type:"SET_CONTENT_VALIDATION",validation:e}}function w(e){return{type:"SET_EDITOR_SETTINGS",editorSettings:e}}function v(e){return{type:"SET_EDITOR_THEME",theme:e}}function b(e){return{type:"SET_EDITOR_URLS",urls:e}}function S(e){return{type:"SET_EDITOR_CONFIG",config:e}}function j(e,t){var o;switch(t.type){case"CHANGE_PREVIEW_STATE":return{...e,preview:{...e.preview,...t.state}};case"SET_EMAIL_POST":return{...e,...t.state};case"CHANGE_PERSONALIZATION_TAGS_STATE":case"SET_IS_FETCHING_PERSONALIZATION_TAGS":case"SET_PERSONALIZATION_TAGS_LIST":return{...e,personalizationTags:{...e.personalizationTags,...t.state}};case"SET_PERSONALIZATION_TAGS":return{...e,personalizationTags:{...e.personalizationTags,list:t.personalizationTags}};case"SET_CONTENT_VALIDATION":return{...e,contentValidation:t.validation};case"SET_EDITOR_SETTINGS":return{...e,editorSettings:t.editorSettings};case"SET_EDITOR_THEME":return{...e,theme:t.theme};case"SET_EDITOR_URLS":return{...e,urls:{...e.urls,...t.urls}};case"SET_EDITOR_CONFIG":return{...e,editorSettings:t.config.editorSettings,theme:t.config.theme,urls:t.config.urls,preview:{...e.preview,toEmail:t.config.userEmail},styles:{...e.styles,globalStylesPostId:null!==(o=t.config.globalStylesPostId)&&void 0!==o?o:null}};default:return e}}var k=o(43656),E=o(41233),T=o(74997);function C(e){return e?.content&&"function"==typeof e.content?e.content(e):e?.blocks?(0,T.serialize)(e.blocks):e?.content?e.content:""}const P=new WeakMap;function M(e){let t=P.get(e);return t||(t={...e,get blocks(){return(0,T.parse)(e.content)}},P.set(e,t)),t}function N(e){return e?{...e,title:e?.title?.raw||e?.title||"",content:e?.content?.raw||e?.content||""}:null}const I=(0,i.createRegistrySelector)((e=>(t,o)=>!!e(E.store).get(c.H,o))),H=(0,i.createRegistrySelector)((e=>()=>{const t=e(c.H).getEmailPostId(),o=e(c.H).getEmailPostType();return!!e(l.store).hasEditsForEntityRecord("postType",o,t)})),B=(0,i.createRegistrySelector)((e=>()=>{const t=e(c.H).getEmailPostId(),o=e(c.H).getEmailPostType(),n=e(l.store).getEntityRecord("postType",o,t);if(!n)return!0;const{content:r}=n;return!r.raw})),z=(0,i.createRegistrySelector)((e=>()=>{const t=e(c.H).getEmailPostId(),o=e(c.H).getEmailPostType(),n=e(l.store).getEntityRecord("postType",o,t);return!!n&&"sent"===n.status})),A=(0,i.createRegistrySelector)((e=>()=>{const t=e(c.H).getEmailPostId(),o=e(c.H).getEmailPostType(),n=e(l.store).getEditedEntityRecord("postType",o,t);return n?C(n):""})),L=(0,i.createRegistrySelector)((e=>()=>{const t=e(c.H).getEmailPostType();return e(l.store).getEntityRecords("postType",t,{per_page:30,status:"publish,sent"})?.filter((e=>""!==e?.content?.raw))||[]})),R=(0,i.createRegistrySelector)((e=>{const t=e(c.H).getEmailPostType();return(0,i.createSelector)((()=>t?e(l.store).getBlockPatterns().filter((({templateTypes:e,postTypes:o})=>Array.isArray(e)&&e.includes("email-template")&&(void 0===o||0===o.length||o.includes(t)))).map(M):[]),(()=>[e(l.store).getBlockPatterns(),t]))})),F=(0,i.createRegistrySelector)((e=>()=>e(l.store).canUser("create",{kind:"postType",name:"wp_template"})));function O(e,t){return F()?e(l.store).getEditedEntityRecord("postType","wp_template",t):N(e(l.store).getEntityRecord("postType","wp_template",t,{context:"view"}))}const D=(0,i.createRegistrySelector)((e=>(t,o)=>{const n=o||e(k.store).getEditedPostAttribute("template");if(n){const t={context:"view",per_page:-1,_woocommerce_email_editor:"fetch-all-templates"},o=e(l.store).getEntityRecords("postType","wp_template",t)?.find((e=>e.slug===n));return o?O(e,o.id):null}const r=e(l.store).getDefaultTemplateId({slug:"email-general"});return O(e,r)})),V=(0,i.createRegistrySelector)((e=>()=>{if("wp_template"===e(k.store).getCurrentPostType()){const t=e(k.store).getCurrentPostId();return e(l.store).getEditedEntityRecord("postType","wp_template",t)}return e(c.H).getEditedPostTemplate()})),G=()=>{const e=V();return e?C(e):""},$=(0,i.createRegistrySelector)((e=>()=>{const t=e(c.H).getGlobalStylesPostId();return{postId:t,canEdit:e(l.store).canUser("update",{kind:"root",name:"globalStyles",id:t})}})),W=(0,i.createRegistrySelector)((e=>()=>{const{postId:t,canEdit:o}=$();return t&&void 0!==o&&t?o?e(l.store).getEditedEntityRecord("postType","wp_global_styles",t):N(e(l.store).getEntityRecord("postType","wp_global_styles",t,{context:"view"})):null})),U=(0,i.createRegistrySelector)((e=>()=>{const t=e(c.H).getEmailPostType();return e(l.store).getEntityRecords("postType","wp_template",{per_page:-1,post_type:t,context:"view"})?.filter((e=>e.post_types.includes(t)))}));function q(e){return e.postId}function Y(e){return e.postType}function Z(e){return e.editorSettings}function J(e){return e.editorSettings?.__experimentalFeatures?.color?.palette}function K(e){return e.preview}function X(e){return e.personalizationTags}const Q=(0,i.createRegistrySelector)((e=>t=>{const o=t.personalizationTags.list,n=e(c.H).getEmailPostType();if(!n)return o;if("wp_template"===n){const t=e(c.H).getCurrentTemplate();return o.filter((e=>void 0===e.postTypes||0===e.postTypes.length||Array.isArray(t.post_types)&&t.post_types.some((t=>e.postTypes.includes(t)))))}return o.filter((e=>void 0===e.postTypes||0===e.postTypes.length||e.postTypes.includes(n)))}));function ee(e){return e.theme?.styles}function te(e){return e.theme}function oe(e){return e.styles.globalStylesPostId}function ne(e){return e.urls}function re(e){return e.contentValidation}function*se(){const e=yield(0,i.select)(c.H),t=e.personalizationTags?.isFetching;if(!t){yield y(!0);try{const e=yield(0,a.apiFetch)({path:"/woocommerce-email-editor/v1/get_personalization_tags",method:"GET"});yield f(e.result)}finally{yield y(!1)}}}const ie=()=>{if(void 0!==(0,i.select)(c.H))return(0,i.select)(c.H);const e=(0,i.createReduxStore)(c.H,{actions:n,controls:a.controls,selectors:r,resolvers:s,reducer:j,initialState:{editorSettings:void 0,theme:void 0,styles:{globalStylesPostId:null},urls:{back:"",listings:""},preview:{toEmail:"",isModalOpened:!1,isSendingPreviewEmail:!1,sendingPreviewStatus:null},personalizationTags:{list:[],isFetching:!1},contentValidation:void 0}});return(0,i.register)(e),e}},49851:(e,t,o)=>{var n;o.d(t,{T:()=>n}),function(e){e.SUCCESS="success",e.ERROR="error"}(n||(n={}))},76597:e=>{var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===o}(e)}(e)},o="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((o=e,Array.isArray(o)?[]:{}),e,t):e;var o}function r(e,t,o){return e.concat(t).map((function(e){return n(e,o)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function i(e,t){try{return t in e}catch(e){return!1}}function a(e,o,l){(l=l||{}).arrayMerge=l.arrayMerge||r,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(o);return c===Array.isArray(e)?c?l.arrayMerge(e,o,l):function(e,t,o){var r={};return o.isMergeableObject(e)&&s(e).forEach((function(t){r[t]=n(e[t],o)})),s(t).forEach((function(s){(function(e,t){return i(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(i(e,s)&&o.isMergeableObject(t[s])?r[s]=function(e,t){if(!t.customMerge)return a;var o=t.customMerge(e);return"function"==typeof o?o:a}(s,o)(e[s],t[s],o):r[s]=n(t[s],o))})),r}(e,o,l):n(o,l)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,o){return a(e,o,t)}),{})};var l=a;e.exports=l},94931:(e,t,o)=>{var n=o(51609),r=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,o){var n,s={},c=null,d=null;for(n in void 0!==o&&(c=""+o),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(d=t.ref),t)i.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:r,type:e,key:c,ref:d,props:s,_owner:a.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},39793:(e,t,o)=>{e.exports=o(94931)},51609:e=>{e.exports=window.React},66087:e=>{e.exports=window.lodash},74997:e=>{e.exports=window.wp.blocks},56427:e=>{e.exports=window.wp.components},3582:e=>{e.exports=window.wp.coreData},47143:e=>{e.exports=window.wp.data},43656:e=>{e.exports=window.wp.editor},86087:e=>{e.exports=window.wp.element},52619:e=>{e.exports=window.wp.hooks},27723:e=>{e.exports=window.wp.i18n},48558:e=>{e.exports=window.wp.keycodes},41233:e=>{e.exports=window.wp.preferences},5573:e=>{e.exports=window.wp.primitives},50876:e=>{e.exports=window.wp.richText},4921:(e,t,o)=>{function n(e){var t,o,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var s=e.length;for(t=0;t
r});const r=function(){for(var e,t,o=0,r="",s=arguments.length;o
{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};o.r(n),o.d(n,{ExperimentalEmailEditor:()=>No,SendPreviewEmail:()=>Ct.P,createStore:()=>oo.y$,initializeEditor:()=>Ho,storeName:()=>P.H,useIsEmailEditor:()=>Io.L});var r=o(39793),s=o(47143),i=o(86087),a=o(52619),l=o(43656);const c=window.wp.compose;window.wp.formatLibrary;var d=o(74997);function m(){try{return(0,d.getBlockTypes)().filter((e=>!0===e.supports?.email)).map((e=>e.name))}catch(e){return console.error("Failed to get allowed block names:",e),[]}}const p=window.wp.blockLibrary,u=window.wp.blockEditor;var _=o(94723),g=o(56554);const h=(0,c.createHigherOrderComponent)((e=>function(t){return"core/columns"!==t.name?(0,r.jsx)(e,{...t}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e,{...t}),(0,r.jsx)(u.InspectorControls,{children:(0,r.jsx)("style",{children:"\n .components-panel__body .components-toggle-control .components-form-toggle { opacity: 0.3; }\n .components-panel__body .components-toggle-control .components-form-toggle__input { pointer-events: none; }\n .components-panel__body .components-toggle-control label { pointer-events: none; }\n "})})]})}),"columnsEditCallback"),y=["core/column","core/columns"];var f=o(27723);function x({layoutClassNames:e}){const t=(0,u.useBlockProps)({className:e});return(0,r.jsxs)("div",{...t,children:[(0,r.jsx)("p",{children:(0,f.__)("This is the Content block.","woocommerce")}),(0,r.jsx)("p",{children:(0,f.__)("It will display all the blocks in the email content, which might be only simple text paragraphs. You can enrich your message with images, incorporate data through tables, explore different layout designs with columns, or use any other block type.","woocommerce")})]})}const w=(0,c.createHigherOrderComponent)((e=>function(t){return"core/image"!==t.name?(0,r.jsx)(e,{...t}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e,{...t}),(0,r.jsx)(u.InspectorControls,{children:(0,r.jsx)("style",{children:"\n .components-tools-panel .components-toggle-control { display: none; }\n "})})]})}),"imageEditCallback");var v=o(50876),b=o(56427);const S=(e,t)=>{const o=e.current.ownerDocument.defaultView.getSelection();if(!o.rangeCount)return{start:0,end:0};const n=o.getRangeAt(0);if(null===o.anchorNode.previousSibling)return{start:o.anchorOffset,end:o.anchorOffset+n.toString().length};const r=(0,v.create)({html:t});let s=o.anchorNode.previousSibling;s=function(e){let t=e;for(;t&&t?.children?.length>0;)t=t.children[0];return t}(s);const i=function(e,t){let o=null;for(const[n,r]of t.entries())if(r)for(const t of r)t?.attributes&&e.tagName.toLowerCase()===t.tagName?.toLowerCase()&&e.getAttribute("data-link-href")===t?.attributes["data-link-href"]&&(o=n);return o}(s,r.formats);if(null!==i)return{start:i+o.anchorOffset+1,end:i+o.anchorOffset+n.toString().length};const a=function(e,t){for(const[o,n]of t.entries()){if(!n)continue;const{attributes:t}=n;if(e.getAttribute("data-rich-text-comment")===t["data-rich-text-comment"])return o}return null}(s,r.replacements);return null!==a?{start:a+o.anchorOffset+1,end:a+o.anchorOffset+n.toString().length}:{start:r.text.length,end:r.text.length+n.toString().length}},j=(e,t)=>(t.forEach((t=>{if(!e.includes(t.token.slice(0,t.token.length-1)))return;const o=t.token.substring(1,t.token.length-1).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`(?`\x3c!--${e}--\x3e`))})),e),k=({groupedTags:e,activeCategory:t,onCategorySelect:o})=>{const n=e=>e===t?"woocommerce-personalization-tags-modal-menu-item-active":"";return(0,r.jsxs)(b.MenuGroup,{className:"woocommerce-personalization-tags-modal-menu",children:[(0,r.jsx)(b.MenuItem,{onClick:()=>o(null),className:n(null),children:(0,f.__)("All","woocommerce")}),(0,r.jsx)("div",{className:"woocommerce-personalization-tags-modal-menu-separator","aria-hidden":"true",role:"presentation","data-testid":"woocommerce-personalization-tags-modal-menu-separator"}),Object.keys(e).map(((e,t,s)=>(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)(b.MenuItem,{onClick:()=>o(e),className:n(e),children:e}),t
{const{updateBlockAttributes:l}=(0,s.useDispatch)(u.store),c=(0,s.useSelect)((e=>e(u.store).getSelectedBlockClientId())),d=(0,s.useSelect)((e=>e(u.store).getBlock(c))),m=["core/button"].includes(d?.name),p=null===t?Object.entries(e):[[t,e[t]||[]]];return(0,r.jsx)(r.Fragment,{children:p.map((([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"woocommerce-personalization-tags-modal-category",children:e}),(0,r.jsx)("div",{className:"woocommerce-personalization-tags-modal-category-group",children:t.map((t=>{const s=/\burl\b/.test(t.token);return(0,r.jsxs)("div",{className:"woocommerce-personalization-tags-modal-category-group-item",children:[(0,r.jsxs)("div",{className:"woocommerce-personalization-tags-modal-item-text",children:[(0,r.jsx)("strong",{children:t.name}),t.valueToInsert]}),(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[(0,r.jsx)(b.Button,{variant:"link",onClick:()=>{o&&o(t.valueToInsert,!1)},children:(0,f.__)("Insert","woocommerce")}),m&&s&&(0,r.jsx)(b.Button,{variant:"link",onClick:()=>{l(c,{url:t.valueToInsert}),i()},children:(0,f.__)("Set as URL","woocommerce")}),e===(0,f.__)("Link","woocommerce")&&n&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(b.Button,{variant:"link",onClick:()=>{i(),a(t)},children:(0,f.__)("Insert as link","woocommerce")})})]})]},t.token)}))})]},e)))})},T=({onInsert:e,isOpened:t,closeCallback:o,tag:n})=>{const[s,a]=(0,i.useState)((0,f.__)("Link","woocommerce"));return t?(0,r.jsxs)(b.Modal,{size:"small",title:(0,f.__)("Insert Link","woocommerce"),onRequestClose:o,className:"woocommerce-personalization-tags-modal",children:[(0,r.jsx)(b.TextControl,{label:(0,f.__)("Link Text","woocommerce"),value:s,onChange:a}),(0,r.jsx)(b.Button,{isPrimary:!0,onClick:()=>{e&&e(n.token,s)},children:(0,f.__)("Insert","woocommerce")})]}):null};var C=o(59191),P=o(58039);const M=({onInsert:e,isOpened:t,closeCallback:o,canInsertLink:n=!1,openedBy:a=""})=>{const[l,c]=(0,i.useState)(null),[d,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),[_,g]=(0,i.useState)(!1),h=(0,s.useSelect)((e=>e(P.H).getPersonalizationTagsList()),[]);if(_)return(0,r.jsx)(T,{onInsert:(t,o)=>{e(t,o),g(!1)},isOpened:_,closeCallback:()=>g(!1),tag:p});if(!t)return null;(0,C.xW)("personalization_tags_modal_opened",{openedBy:a});const y=h.reduce(((e,t)=>{const{category:o,name:n,token:r}=t;return(!d||n.toLowerCase().includes(d.toLowerCase())||r.toLowerCase().includes(d.toLowerCase()))&&(e[o]||(e[o]=[]),e[o].push(t)),e}),{});return(0,r.jsxs)(b.Modal,{size:"medium",title:(0,f.__)("Personalization Tags","woocommerce"),onRequestClose:()=>{o(),(0,C.yM)("personalization_tags_modal_closed",{openedBy:a})},className:"woocommerce-personalization-tags-modal",children:[(0,r.jsxs)("p",{children:[(0,f.__)("Insert personalization tags to dynamically fill in information and personalize your emails.","woocommerce")," ",(0,r.jsx)(b.ExternalLink,{href:"https://kb.mailpoet.com/article/435-a-guide-to-personalisation-tags-for-tailored-newsletters#list",onClick:()=>(0,C.yM)("personalization_tags_modal_learn_more_link_clicked",{openedBy:a}),children:(0,f.__)("Learn more","woocommerce")})]}),(0,r.jsx)(b.SearchControl,{onChange:e=>{m(e),(0,C.xW)("personalization_tags_modal_search_control_input_updated",{openedBy:a})},value:d}),(0,r.jsx)(k,{groupedTags:y,activeCategory:l,onCategorySelect:e=>{c(e),(0,C.yM)("personalization_tags_modal_category_menu_clicked",{category:e,openedBy:a})}}),(0,r.jsx)(E,{groupedTags:y,activeCategory:l,onInsert:t=>{e(t),(0,C.yM)("personalization_tags_modal_tag_insert_button_clicked",{insertedTag:t,activeCategory:l,openedBy:a})},closeCallback:o,canInsertLink:n,openLinkModal:e=>{u(e),g(!0)}})]})},N=({contentRef:e,onUpdate:t})=>{const[o,n]=(0,i.useState)(!1),[s,a]=(0,i.useState)(null),[l,c]=(0,i.useState)(""),[d,m]=(0,i.useState)("");return(0,i.useEffect)((()=>{if(!e||!e.current)return;const t=e.current,o=e=>{const t=e.target.closest("span[data-rich-text-comment]");if(t){const e=t.innerText.replace(/^\[|\]$/g,"");m(e),c(e),a(t),n(!0)}};return t.addEventListener("click",o),()=>{t.removeEventListener("click",o)}}),[e]),(0,r.jsx)(r.Fragment,{children:o&&s&&(0,r.jsx)(b.Popover,{position:"bottom right",onClose:()=>n(!1),anchor:s,className:"woocommerce-personalization-tag-popover",children:(0,r.jsxs)("div",{className:"woocommerce-personalization-tag-popover-content",children:[(0,r.jsx)(b.TextControl,{label:(0,f.__)("Personalization Tag","woocommerce"),value:l,onChange:e=>c(e),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,r.jsxs)("div",{className:"woocommerce-personalization-tag-popover-content-buttons",children:[(0,r.jsx)(b.Button,{isTertiary:!0,onClick:()=>{n(!1)},children:(0,f.__)("Cancel","woocommerce")}),(0,r.jsx)(b.Button,{isPrimary:!0,onClick:()=>{t(d,l),n(!1)},children:(0,f.__)("Update","woocommerce")})]})]})})})},I=({contentRef:e,onUpdate:t})=>{const[o,n]=(0,i.useState)(!1),[a,l]=(0,i.useState)(null),[c,d]=(0,i.useState)(""),[m,p]=(0,i.useState)(""),u=(0,s.useSelect)((e=>e(P.H).getPersonalizationTagsList()),[]);return(0,i.useEffect)((()=>{if(!e||!e.current)return;const t=e.current,o=e=>{const t=e.target.closest("a[data-link-href]");t&&(l(t),p(t.getAttribute("data-link-href")||""),d(t.textContent||""),n(!0))};return t.addEventListener("click",o),()=>{t.removeEventListener("click",o)}}),[e]),(0,r.jsx)(r.Fragment,{children:o&&a&&(0,r.jsx)(b.Popover,{position:"bottom left",onClose:()=>n(!1),anchor:a,className:"woocommerce-personalization-tag-popover",children:(0,r.jsxs)("div",{className:"woocommerce-personalization-tag-popover-content",children:[(0,r.jsx)(b.TextControl,{label:(0,f.__)("Link Text","woocommerce"),value:c,onChange:e=>d(e),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,autoComplete:"off"}),(0,r.jsx)(b.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,f.__)("Link tag","woocommerce"),value:m,onChange:e=>{p(e)},options:u.filter((e=>e.category===(0,f.__)("Link","woocommerce"))).map((e=>({label:e.name,value:e.token})))}),(0,r.jsxs)("div",{className:"woocommerce-personalization-tag-popover-content-buttons",children:[(0,r.jsx)(b.Button,{isTertiary:!0,onClick:()=>{n(!1)},children:(0,f.__)("Cancel","woocommerce")}),(0,r.jsx)(b.Button,{isPrimary:!0,onClick:()=>{n(!1),t(a,m,c)},children:(0,f.__)("Update link","woocommerce")})]})]})})})};var H=o(16205);function B({contentRef:e}){const[t,o]=(0,i.useState)(!1),n=(0,s.useSelect)((e=>e("core/block-editor").getSelectedBlockClientId())),{updateBlockAttributes:a}=(0,s.useDispatch)("core/block-editor"),l=(0,s.useSelect)((e=>e("core/block-editor").getBlockAttributes(n))),c="text"in l?"text":"content",d=l?.[c]?.originalHTML||l?.[c]||"",m=(0,i.useCallback)(((t,o)=>{let{start:r,end:s}=S(e,d),i="";if(o){let e=(0,v.create)({html:d});e=(0,v.insert)(e,o,r,s),s=r+o.length,e=(0,v.applyFormat)(e,{type:"woocommerce-email-editor/link-shortcode",attributes:{"data-link-href":t,contenteditable:"false",style:"text-decoration: underline;"}},r,s),i=(0,v.toHTMLString)({value:e})}else{let e=(0,v.create)({html:d});e=(0,v.insert)(e,(0,v.create)({html:`\x3c!--${t}--\x3e `}),r,s),i=(0,v.toHTMLString)({value:e})}a(n,{[c]:i})}),[d,c,e,n,a]);return(0,r.jsx)(u.BlockControls,{children:(0,r.jsxs)(b.ToolbarGroup,{children:[(0,r.jsx)(b.ToolbarButton,{icon:"shortcode",title:(0,f.__)("Personalization Tags","woocommerce"),onClick:()=>{o(!0),(0,C.yM)("block_controls_personalization_tags_button_clicked")}}),(0,r.jsx)(N,{contentRef:e,onUpdate:(e,t)=>{const o=d.replace(`\x3c!--[${e}]--\x3e`,`\x3c!--[${t}]--\x3e`);a(n,{[c]:o})}}),(0,r.jsx)(I,{contentRef:e,onUpdate:(e,t,o)=>{const r=e.getAttribute("data-link-href").replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`
]*?)data-link-href="${r}"([^>]*?)>${e.textContent}
`,"gi"),i=d.replace(s,((e,n,r)=>`
${o}
`));a(n,{content:i})}}),(0,r.jsx)(M,{isOpened:t,onInsert:(e,t)=>{m(e,t),o(!1)},closeCallback:()=>o(!1),canInsertLink:!0,openedBy:"block-controls"})]})})}const z=(0,c.createHigherOrderComponent)((e=>t=>{const{attributes:o,setAttributes:n,name:a}=t,{content:l}=o,c=(0,s.useSelect)((e=>e(P.H).getPersonalizationTagsList()),[]),d=(0,i.useCallback)((()=>l?j(l,c):""),[l,c]),m=(0,i.useCallback)((e=>{if(void 0!==e.content){const t=j(e.content,c);n({...e,content:t})}else n(e)}),[c,n]);return"core/paragraph"===a||"core/heading"===a||"core/list-item"===a?(0,r.jsx)(e,{...t,attributes:{...o,content:d()},setAttributes:m}):(0,r.jsx)(e,{...t})}),"personalizationTagsLiveContentUpdate"),A=window.wp.domReady;var L=o.n(A),R=o(93524);const F=["core/social-links"];function O(){(0,d.getBlockTypes)().forEach((e=>{const t=e.name;if(F.includes(t))return;const o=(0,s.select)("core/blocks").getBlockStyles(t);Array.isArray(o)&&0!==o?.length&&o.forEach((e=>{(0,R.oj)(t,e.name)}))}))}const D=e=>t=>{const{setAttributes:o}=t,n=(0,i.useCallback)((e=>{e?.url&&e.url?.startsWith("http://[")&&(e.url=e.url.replace("http://[","[")),o(e)}),[o]);return(0,r.jsx)(e,{...t,setAttributes:n})};var V=o(43583);const G=["behance","bluesky","chain","discord","facebook","feed","github","gravatar","instagram","linkedin","mail","mastodon","medium","patreon","pinterest","reddit","spotify","telegram","threads","tiktok","tumblr","twitch","twitter","vimeo","wordpress","whatsapp","x","youtube"],$=e=>t=>{if("core/social-links"!==t.name)return(0,r.jsx)(e,{...t});const o=`\n\t\t.block-editor-tools-panel-color-gradient-settings__item:has([title="${(0,f.__)("Icon color")}"]) {\n\t\t\tdisplay: none !important;\n\t\t}\n\t\t.block-editor-tools-panel-color-gradient-settings__item:nth-child(2 of .block-editor-tools-panel-color-gradient-settings__item){\n\t\t\tborder-top:1px solid #ddd;\n\t\t\tborder-top-left-radius:2px;\n\t\t\tborder-top-right-radius:2px;\n\t\t}\n\t\t`;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e,{...t}),(0,r.jsx)(u.InspectorControls,{group:"color",children:(0,r.jsx)("style",{children:o})})]})};const W=window.wp.privateApis,{unlock:U}=(0,W.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.","@wordpress/edit-site"),{ColorPanel:q}=U(u.privateApis),{useGlobalStylesOutputWithConfig:Y}=U(u.privateApis),{Editor:Z,FullscreenMode:J,ViewMoreMenuGroup:K,BackButton:X}=U(l.privateApis),{registerEntityAction:Q,unregisterEntityAction:ee}=U((0,s.dispatch)(l.store));var te=o(3582);const oe=window.wp.notices;var ne=o(5573);const re=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})}),se=window.wp.htmlEntities;function ie(e){return"string"==typeof e.title?(0,se.decodeEntities)(e.title):e.title&&"rendered"in e.title?(0,se.decodeEntities)(e.title.rendered):e.title&&"raw"in e.title?(0,se.decodeEntities)(e.title.raw):""}function ae(e,t){return t?e.length>1?(0,f.sprintf)((0,f._n)("Are you sure you want to permanently delete %d item?","Are you sure you want to permanently delete %d items?",e.length,"woocommerce"),e.length):(0,f.sprintf)((0,f.__)('Are you sure you want to permanently delete "%s"?',"woocommerce"),(0,se.decodeEntities)(ie(e[0]))):e.length>1?(0,f.sprintf)((0,f._n)("Are you sure you want to move %d item to the trash ?","Are you sure you want to move %d items to the trash ?",e.length,"woocommerce"),e.length):(0,f.sprintf)((0,f.__)('Are you sure you want to move "%s" to the trash?',"woocommerce"),ie(e[0]))}const le=e=>{ee("postType",e,"move-to-trash"),Q("postType",e,(()=>{const e=(0,a.applyFilters)("woocommerce_email_editor_trash_modal_should_permanently_delete",!1);return{id:"trash-email-post",label:e?(0,f.__)("Permanently delete","woocommerce"):(0,f.__)("Move to trash","woocommerce"),supportsBulk:!0,icon:re,isEligible(e){if("wp_template"===e.type||"wp_template_part"===e.type||"wp_block"===e.type)return!1;const{permissions:t}=e;return t?.delete},hideModalHeader:!0,modalFocusOnMount:"firstContentElement",RenderModal:({items:t,closeModal:o,onActionPerformed:n})=>{const[a,l]=(0,i.useState)(!1),{createSuccessNotice:c,createErrorNotice:d}=(0,s.useDispatch)(oe.store),{deleteEntityRecord:m}=(0,s.useDispatch)(te.store),{urls:p}=(0,s.useSelect)((e=>({urls:e(P.H).getUrls()})),[]);return(0,r.jsxs)(b.__experimentalVStack,{spacing:"5",children:[(0,r.jsx)(b.__experimentalText,{children:ae(t,e)}),(0,r.jsxs)(b.__experimentalHStack,{justify:"right",children:[(0,r.jsx)(b.Button,{variant:"tertiary",onClick:()=>{o?.(),(0,C.yM)("trash_modal_cancel_button_clicked")},disabled:a,__next40pxDefaultSize:!0,children:(0,f.__)("Cancel","woocommerce")}),(0,r.jsx)(b.Button,{variant:"primary",onClick:async()=>{(0,C.yM)("trash_modal_move_to_trash_button_clicked"),l(!0);const r=await Promise.allSettled(t.map((t=>m("postType",t.type,t.id,{force:e},{throwOnError:!0}))));if(r.every((({status:e})=>"fulfilled"===e))){let o;o=1===r.length?e?(0,f.sprintf)((0,f.__)('"%s" permanently deleted.',"woocommerce"),ie(t[0])):(0,f.sprintf)((0,f.__)('"%s" moved to the trash.',"woocommerce"),ie(t[0])):e?(0,f.__)("The items were permanently deleted.","woocommerce"):(0,f.sprintf)((0,f._n)("%s item moved to the trash.","%s items moved to the trash.",t.length,"woocommerce"),t.length),c(o,{type:"snackbar",id:"trash-email-post-action"}),n?.(t),p?.listings&&(window.location.href=p.listings)}else{let e;if(1===r.length){const t=r[0];e=t.reason?.message?t.reason.message:(0,f.__)("An error occurred while performing the action.","woocommerce")}else{const t=new Set,o=r.filter((({status:e})=>"rejected"===e));for(const e of o){const o=e;o.reason?.message&&t.add(o.reason.message)}e=0===t.size?(0,f.__)("An error occurred while performing the action.","woocommerce"):1===t.size?(0,f.sprintf)((0,f.__)("An error occurred while performing the action: %s","woocommerce"),[...t][0]):(0,f.sprintf)((0,f.__)("Some errors occurred while performing the action: %s","woocommerce"),[...t].join(","))}(0,C.yM)("trash_modal_move_to_trash_error",{errorMessage:e}),d(e,{type:"snackbar"})}l(!1),o?.()},isBusy:a,disabled:a,__next40pxDefaultSize:!0,children:e?(0,f.__)("Delete permanently","woocommerce"):(0,f.__)("Move to trash","woocommerce")})]})]})}}})())};function ce(){(0,d.getBlockType)("core/paragraph")||(0,p.registerCoreBlocks)(),(0,g.HY)("editor.BlockEdit","woocommerce-email-editor/filter-set-url-attribute",D),(0,g.HY)("editor.BlockEdit","woocommerce-email-editor/deactivate-stack-on-mobile",h),(0,g.HY)("editor.BlockEdit","woocommerce-email-editor/hide-expand-on-click",w),(0,_.G)("core/image",(e=>({...e,supports:{...e.supports||{},filter:{...e.supports?.filter||{},duetone:!1}}}))),["core/image","core/code","core/language"].forEach((e=>{(0,H.le)(e)})),y.forEach((e=>{(0,_.G)(e,(e=>({...e,supports:{...e.supports||{},layout:!1,background:{...e.support?.background||{},backgroundImage:!0}}})))})),(0,_.G)("core/group",(e=>{var t;const o=null!==(t=e.variations)&&void 0!==t?t:[];return{...e,variations:o.filter((e=>"group"===e.name)),supports:{...e.supports||{},layout:!1}}})),(0,_.G)("core/buttons",(e=>{var t;return{...e,supports:{...null!==(t=e.supports)&&void 0!==t?t:{},layout:!1,__experimentalEmailFlexLayout:!0}}})),(0,_.G)("core/post-content",(e=>{return{...e,edit:(t=e.edit,function(e){const{postId:o,postType:n}=e.context,{__unstableLayoutClassNames:s}=e;return o&&n?(0,r.jsx)(t,{...e}):(0,r.jsx)(x,{layoutClassNames:s})})};var t})),(0,_.G)("core/quote",(e=>({...e,styles:[],supports:{...e.supports,align:[]}}))),(0,H.gG)("woocommerce-email-editor/shortcode",{name:"woocommerce-email-editor/shortcode",title:(0,f.__)("Personalization Tags","woocommerce"),className:"woocommerce-email-editor-personalization-tags",tagName:"span",attributes:{},interactive:!0,edit:B}),(0,H.gG)("woocommerce-email-editor/link-shortcode",{name:"woocommerce-email-editor/link-shortcode",title:(0,f.__)("Personalization Tags Link","woocommerce"),className:"woocommerce-email-editor-personalization-tags-link",tagName:"a",attributes:{"data-link-href":"data-link-href",contenteditable:"contenteditable",style:"style"},interactive:!0,edit:null}),(0,g.HY)("editor.BlockEdit","woocommerce-email-editor/with-live-content-update",z),(0,d.getBlockTypes)().forEach((e=>{e.supports?.shadow&&(0,_.G)(e.name,(e=>({...e,supports:{...e.supports,shadow:!1}})))})),(0,_.G)("core/social-link",(e=>({...e,variations:(e.variations||[]).filter((e=>G.includes(e.name))),supports:{...e.supports,layout:!1}}))),(0,V.z)("core/social-links",{name:"social-links-default",title:"Social Icons",attributes:{openInNewTab:!0,showLabels:!1,align:"center",className:"is-style-logos-only"},isDefault:!0,innerBlocks:[{name:"core/social-link",attributes:{service:"wordpress",url:"https://wordpress.org"}},{name:"core/social-link",attributes:{service:"facebook",url:"https://www.facebook.com/WordPress/"}},{name:"core/social-link",attributes:{service:"x",url:"https://x.com/WordPress"}}]}),(0,g.HY)("editor.BlockEdit","woocommerce-email-editor/disable-social-links-icon-color",$),(0,g.tN)("core.registerPostTypeSchema","woocommerce-email-editor/modify-move-to-trash-action",(e=>{le(e)})),(0,g.tN)("core.registerPostTypeActions","woocommerce-email-editor/modify-move-to-trash-action",(e=>{le(e)})),(0,V.z)("core/site-logo",{name:"site-logo-default",title:"Site Logo",attributes:{align:"center",width:120},isDefault:!0}),L()(O)}var de=o(4921);const me=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M9 9v6h11V9H9zM4 20h1.5V4H4v16z"})}),pe=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M12.5 15v5H11v-5H4V9h7V4h1.5v5h7v6h-7Z"})}),ue=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z"})}),_e="__experimentalEmailFlexLayout";function ge(e){return(0,d.hasBlockSupport)(e,_e)}function he({justificationValue:e,onChange:t,isToolbar:o=!1}){const n=[{value:"left",icon:me,label:(0,f.__)("Justify items left","woocommerce")},{value:"center",icon:pe,label:(0,f.__)("Justify items center","woocommerce")},{value:"right",icon:ue,label:(0,f.__)("Justify items right","woocommerce")}];if(o){const o=n.map((e=>e.value));return(0,r.jsx)(u.JustifyContentControl,{value:e,onChange:t,allowedControls:o,popoverProps:{placement:"bottom-start"}})}return(0,r.jsx)(b.__experimentalToggleGroupControl,{__nextHasNoMarginBottom:!0,label:(0,f.__)("Justification","woocommerce"),value:e,onChange:t,className:"block-editor-hooks__flex-layout-justification-controls",children:n.map((({value:e,icon:t,label:o})=>(0,r.jsx)(b.__experimentalToggleGroupControlOptionIcon,{value:e,icon:t,label:o},e)))})}function ye({setAttributes:e,attributes:t,name:o}){if(!(0,d.getBlockSupport)(o,_e,{}))return null;const{justifyContent:n="left"}=t.layout||{},s=o=>{e({layout:{...t.layout,justifyContent:o}})},i=()=>{const{justifyContent:o,...n}=t.layout||{};e({layout:n})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.InspectorControls,{children:(0,r.jsx)(b.__experimentalToolsPanel,{label:(0,f.__)("Layout","woocommerce"),resetAll:i,children:(0,r.jsx)(b.__experimentalToolsPanelItem,{isShownByDefault:!0,onDeselect:i,hasValue:()=>t.layout?.justifyContent||!1,label:(0,f.__)("Justification","woocommerce"),children:(0,r.jsx)(b.Flex,{children:(0,r.jsx)(b.FlexItem,{children:(0,r.jsx)(he,{justificationValue:n,onChange:s})})})})})}),(0,r.jsx)(u.BlockControls,{group:"block",__experimentalShareWithChildBlocks:!0,children:(0,r.jsx)(he,{justificationValue:n,onChange:s,isToolbar:!0})})]})}const fe=(0,c.createHigherOrderComponent)((e=>t=>[ge(t.name)&&(0,r.jsx)(ye,{...t},"layout"),(0,r.jsx)(e,{...t},"edit")]),"withLayoutControls");function xe({block:e,props:t}){const{attributes:o}=t,{layout:n}=o,s=`is-content-justification-${n?.justifyContent||"left"}`,i=(0,de.A)(s,"is-layout-email-flex is-layout-flex");return(0,r.jsx)(e,{...t,className:i})}const we=(0,c.createHigherOrderComponent)((e=>function(t){return ge(t.name)?(0,r.jsx)(xe,{block:e,props:t}):(0,r.jsx)(e,{...t})}),"withLayoutStyles");const ve=window.wp.commands;var be=o(76597),Se=o.n(be);function je(){const{globalStylePost:e}=(0,s.useSelect)((e=>({globalStylePost:e(P.H).getGlobalEmailStylesPost()||null})),[]),t=(0,i.useCallback)((t=>{e&&(0,s.dispatch)(te.store).editEntityRecord("postType","wp_global_styles",e.id,{styles:t.styles,settings:t.settings})}),[e]);return{userTheme:{settings:e?.settings,styles:e?.styles},updateUserTheme:t}}function ke(e){if("string"!=typeof e)return null;const t=e.match(/^var:preset\|([a-zA-Z0-9-]+)\|([a-zA-Z0-9-]+)$/);return t?`--wp--preset--${t[1]}--${t[2]}`:null}function Ee(e){const t=ke(e);return t?`var(${t})`:e}function Te(e){const t=ke(e);if(!t)return e;const o=document.querySelector(":root");return o&&getComputedStyle(o).getPropertyValue(t).trim()||e}const Ce=[];function Pe(){const{userTheme:e}=je(),{editorTheme:t,layout:o,deviceType:n,editorSettingsStyles:r}=(0,s.useSelect)((e=>{const{getEditorSettings:t,getDeviceType:o}=e(l.store),n=t();return{editorTheme:e(P.H).getTheme(),layout:n?.__experimentalFeatures?.layout,deviceType:o(),editorSettingsStyles:n?.styles}}),[]),a=(0,i.useMemo)((()=>Se().all([{},t||{},e||{}])),[t,e]),[c]=Y(a);let d="";o&&"Mobile"!==n&&(d=`display:flow-root; width:${o?.contentSize}; margin: 0 auto;box-sizing: border-box;`);const m=a.styles?.spacing?.padding;return m&&(d+=`padding-left:${Ee(m.left)};`,d+=`padding-right:${Ee(m.right)};`),[(0,i.useMemo)((()=>[...null!=c?c:[],{css:`.is-root-container{ ${d} }`},...null!=r?r:[]]),[c,r,d])||Ce]}const Me=()=>{const e=".editor-preview-dropdown__button-external",t=async t=>{const o=t.target,n=o?.closest(e);if(!n)return;const r=(0,s.select)(l.store),i=r?.isEditedPostDirty();i&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),(0,s.dispatch)(oe.store).createNotice("warning",(0,f.__)("You have unsaved changes. Please save the post before previewing.","woocommerce"),{context:"email-editor",isDismissible:!0}))},o=(0,i.useCallback)((o=>{try{const n=o.target;"Enter"!==o.key&&" "!==o.key||!n?.closest(e)||t(o)}catch(e){console.warn("Preview save message guard error:",e)}}),[e]);return(0,i.useEffect)((()=>(document.addEventListener("click",t,!0),document.addEventListener("auxclick",t,!0),document.addEventListener("keydown",o,!0),()=>{document.removeEventListener("click",t,!0),document.removeEventListener("auxclick",t,!0),document.removeEventListener("keydown",o,!0)})),[o]),null},Ne=[];function Ie(e,t){return e.map((e=>"core/post-content"===e.name?{...e,name:"core/group",innerBlocks:t}:e.innerBlocks?.length?{...e,innerBlocks:Ie(e.innerBlocks,t)}:e))}const He={};function Be(e=""){const{templates:t,patterns:o,emailPosts:n,hasEmailPosts:r}=(0,s.useSelect)((t=>{const o="swap"!==e?t(P.H).getSentEmailEditorPosts():void 0;return{templates:t(P.H).getEmailTemplates(),patterns:t(P.H).getBlockPatternsForEmailTemplate(),emailPosts:o,hasEmailPosts:!(!o||!o?.length)}}),[e]),l=(0,i.useMemo)((()=>{let n=[];const r=e&&(0,d.parse)(e);if(n=r?[{blocks:r}]:o,!n||!t)return Ne;const s=[];return t?.filter((e=>"email-general"!==e.slug))?.forEach((e=>{n?.forEach((t=>{let o=(0,d.parse)(e.content?.raw);o=Ie(o,t.blocks),s.push({id:e.id,slug:e.slug,previewContentParsed:o,emailParsed:t.blocks,template:e,category:"basic",type:e.type,displayName:t.title?`${e.title.rendered} - ${t.title}`:e.title.rendered})}))})),s}),[t,o,e]),c=(0,i.useMemo)((()=>n?.map((e=>{const t=(0,a.applyFilters)("woocommerce_email_editor_preferred_template_title","",e),{postTemplateContent:o}=function(e,t=[]){const o=e.template,n={postTemplateContent:null};if(!o)return n;if(He[o])return He[o];const r=t.find((e=>e.slug===o));if(!r)return n;const s={postTemplateContent:r?.template};return He[o]=s,s}(e,l),n=(0,d.parse)(e.content?.raw);let r=n;o?.content?.raw&&(r=Ie((0,d.parse)(o?.content?.raw),n));const s={...e,title:{raw:e.title.raw,rendered:t||e.title.rendered}};return{id:e.id,slug:e.slug,previewContentParsed:r,emailParsed:n,category:"recent",type:e.type,displayName:s.title.rendered,template:s}}))),[n,l]);return[l||Ne,c||Ne,r]}var ze=o(24148);const Ae=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"})}),Le=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"})}),Re=(0,window.wp.priorityQueue.createQueue)();function Fe({children:e,placeholder:t}){const[o,n]=(0,i.useState)(!1);return(0,i.useEffect)((()=>{const e={};return Re.add(e,(()=>{(0,i.flushSync)((()=>{n(!0)}))})),()=>{Re.cancel(e)}}),[]),o?e:t}function Oe(){return(0,r.jsxs)("div",{className:"block-editor-inserter__no-results",children:[(0,r.jsx)(ze.A,{className:"block-editor-inserter__no-results-icon",icon:Ae}),(0,r.jsx)("p",{children:(0,f.__)("No recent templates.","woocommerce")}),(0,r.jsx)("p",{children:(0,f.__)("Your recent creations will appear here as soon as you begin.","woocommerce")})]})}const De=(0,i.memo)((function({templates:e,onTemplateSelection:t,selectedCategory:o}){const{layout:n}=(0,s.useSelect)((e=>{const{getEditorSettings:t}=e(l.store),o=t();return{layout:o?.__experimentalFeatures?.layout}})),[i]=Pe(),a=i.reduce(((e,t)=>{var o;return e+(null!==(o=t.css)&&void 0!==o?o:"")}),"")+`.is-root-container { width: ${n.contentSize}; margin: 0 auto; }`;return"recent"===o&&0===e.length?(0,r.jsx)(Oe,{}):(0,r.jsx)("div",{className:"block-editor-block-patterns-list",role:"listbox",children:e.map((e=>(0,r.jsx)("div",{className:"block-editor-block-patterns-list__list-item email-editor-pattern__list-item",children:(0,r.jsx)("div",{className:"block-editor-block-patterns-list__item",role:"button",tabIndex:0,onClick:()=>{t(e)},onKeyPress:o=>{"Enter"!==o.key&&" "!==o.key||t(e)},children:(0,r.jsxs)(Fe,{placeholder:(0,r.jsx)("p",{children:(0,f.__)("rendering template","woocommerce")}),children:[(0,r.jsx)(u.BlockPreview,{blocks:e.previewContentParsed,viewportWidth:900,minHeight:300,additionalStyles:[{css:a}]}),(0,r.jsx)(b.__experimentalHStack,{className:"block-editor-patterns__pattern-details",children:(0,r.jsx)("h4",{className:"block-editor-block-patterns-list__item-title",children:e.displayName})})]})})},`${e.slug}_${e.displayName}_${e.id}`)))})}),((e,t)=>e.templates.length===t.templates.length&&e.selectedCategory===t.selectedCategory));function Ve({templates:e,onTemplateSelection:t,selectedCategory:o}){const n=(0,i.useMemo)((()=>e.filter((e=>e.category===o))),[o,e]);return(0,r.jsxs)("div",{className:"block-editor-block-patterns-explorer__list",children:["recent"===o&&(0,r.jsx)("div",{className:"email-editor-recent-templates-info",children:(0,r.jsxs)(b.__experimentalHStack,{spacing:1,expanded:!1,justify:"start",children:[(0,r.jsx)(ze.A,{icon:Le}),(0,r.jsx)("p",{children:(0,f.__)("Templates created on the legacy editor will not appear here.","woocommerce")})]})}),(0,r.jsx)(De,{templates:n,onTemplateSelection:t,selectedCategory:o})]})}function Ge({selectedCategory:e,templateCategories:t,onClickCategory:o}){const n="block-editor-block-patterns-explorer__sidebar";return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:`${n}__categories-list`,children:t.map((({name:t,label:s})=>(0,r.jsx)(b.Button,{label:s,className:`${n}__categories-list__item`,isPressed:e===t,onClick:()=>{o(t)},children:s},t)))})})}const $e=[{name:"recent",label:"Recent"},{name:"basic",label:"Basic"}],We=(0,i.memo)((function({hasEmailPosts:e,templates:t,handleTemplateSelection:o,templateSelectMode:n}){const[s,a]=(0,i.useState)($e[1].name),l="swap"===n,c=$e.filter((({name:e})=>"recent"!==e||!l));return(0,i.useEffect)((()=>{setTimeout((()=>{e&&!l&&a($e[0].name)}),1e3)}),[e,l]),(0,r.jsxs)("div",{className:"block-editor-block-patterns-explorer",children:[(0,r.jsx)(Ge,{templateCategories:c,selectedCategory:s,onClickCategory:e=>{(0,C.yM)("template_select_modal_category_change",{category:e}),a(e)}}),(0,r.jsx)(Ve,{templates:t,onTemplateSelection:o,selectedCategory:s})]})}));function Ue({onSelectCallback:e,closeCallback:t=null,previewContent:o="",postType:n}){const i=o?"swap":"new";(0,C.xW)("template_select_modal_opened",{templateSelectMode:i});const[a,c,d]=Be(o),m=a?.length>0,p=t=>{const r=t.type===n,a=t.template;(0,C.yM)("template_select_modal_template_selected",{templateSlug:t.slug,templateSelectMode:i,templateType:t.type}),o||(0,s.dispatch)(l.store).resetEditorBlocks(t.emailParsed),(0,s.dispatch)(P.H).setTemplateToPost(r?a.template:t.slug),e()},u=()=>{var e;const t=null!==(e=a[0])&&void 0!==e?e:null;t&&((0,C.yM)("template_select_modal_handle_close_without_template_selected"),p(t))};return(0,r.jsxs)(b.Modal,{title:"new"===i?(0,f.__)("Start with an email preset","woocommerce"):(0,f.__)("Select a template","woocommerce"),onRequestClose:()=>((0,C.yM)("template_select_modal_closed",{templateSelectMode:i}),t?t():u()),isFullScreen:!0,children:[(0,r.jsx)(We,{hasEmailPosts:d,templates:[...a,...c],handleTemplateSelection:p,templateSelectMode:i}),(0,r.jsx)(b.Flex,{className:"email-editor-modal-footer",justify:"flex-end",children:(0,r.jsx)(b.FlexItem,{children:(0,r.jsx)(b.Button,{variant:"tertiary",className:"email-editor-start_from_scratch_button",onClick:()=>((0,C.yM)("template_select_modal_start_from_scratch_clicked"),u()),isBusy:!m,children:(0,f.__)("Start from scratch","woocommerce")})})})]})}function qe(){const[e,t]=(0,i.useState)(!1),{emailContentIsEmpty:o,emailHasEdits:n,postType:a}=(0,s.useSelect)((e=>({emailContentIsEmpty:e(P.H).hasEmptyContent(),emailHasEdits:e(P.H).hasEdits(),postType:e(P.H).getEmailPostType()})),[]);return!o||n||e?null:(0,r.jsx)(Ue,{onSelectCallback:()=>t(!0),postType:a})}const Ye=(0,r.jsx)(ne.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)(ne.Path,{d:"M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z"})}),Ze=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M6.9 7L3 17.8h1.7l1-2.8h4.1l1 2.8h1.7L8.6 7H6.9zm-.7 6.6l1.5-4.3 1.5 4.3h-3zM21.6 17c-.1.1-.2.2-.3.2-.1.1-.2.1-.4.1s-.3-.1-.4-.2c-.1-.1-.1-.3-.1-.6V12c0-.5 0-1-.1-1.4-.1-.4-.3-.7-.5-1-.2-.2-.5-.4-.9-.5-.4 0-.8-.1-1.3-.1s-1 .1-1.4.2c-.4.1-.7.3-1 .4-.2.2-.4.3-.6.5-.1.2-.2.4-.2.7 0 .3.1.5.2.8.2.2.4.3.8.3.3 0 .6-.1.8-.3.2-.2.3-.4.3-.7 0-.3-.1-.5-.2-.7-.2-.2-.4-.3-.6-.4.2-.2.4-.3.7-.4.3-.1.6-.1.8-.1.3 0 .6 0 .8.1.2.1.4.3.5.5.1.2.2.5.2.9v1.1c0 .3-.1.5-.3.6-.2.2-.5.3-.9.4-.3.1-.7.3-1.1.4-.4.1-.8.3-1.1.5-.3.2-.6.4-.8.7-.2.3-.3.7-.3 1.2 0 .6.2 1.1.5 1.4.3.4.9.5 1.6.5.5 0 1-.1 1.4-.3.4-.2.8-.6 1.1-1.1 0 .4.1.7.3 1 .2.3.6.4 1.2.4.4 0 .7-.1.9-.2.2-.1.5-.3.7-.4h-.3zm-3-.9c-.2.4-.5.7-.8.8-.3.2-.6.2-.8.2-.4 0-.6-.1-.9-.3-.2-.2-.3-.6-.3-1.1 0-.5.1-.9.3-1.2s.5-.5.8-.7c.3-.2.7-.3 1-.5.3-.1.6-.3.7-.6v3.4z"})}),Je=(0,r.jsx)(ne.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)(ne.Path,{d:"M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z"})}),Ke=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"})}),Xe={};function Qe(e){return!Object.keys(e).some((t=>Object.keys(e[t]).length>0))}function et(e){const t=e=>{if("object"==typeof e&&null!==e||void 0===e){if(Array.isArray(e)&&0===e.length)return;for(const o in e)if(e.hasOwnProperty(o)){const n=t(e[o]);void 0===n||Qe(n)?delete e[o]:e[o]=n}}return e};return t(e)}const tt=()=>{const{userTheme:e,updateUserTheme:t}=je(),o=(0,i.useMemo)((()=>e?et(function(e){const t=e=>{if("object"==typeof e&&null!==e)for(const o in e)e.hasOwnProperty(o)&&(e[o]=t(e[o]));else if("string"==typeof e)return e.replace(/var\(--([a-z]+)--([a-z]+(?:--[a-z0-9]+(?:-[a-z0-9]+)*)*)--([a-z0-9-]+)\)/g,((e,t,o,n)=>`var:${o.split("--").concat(n).join("|")}`));return e};return t(e)}(e?.styles)):Xe),[e]),{styles:n}=(0,s.useSelect)((e=>({styles:e(P.H).getStyles()}))),r=(0,i.useCallback)((o=>{const n={...e,styles:et(o)};t(n)}),[t,e]),a=(0,i.useCallback)(((o,n)=>{const r=function(e,t,o){const n=Array.isArray(t)?[...t]:[t],r=Array.isArray(e)?[...e]:{...e},s=n.pop();let i=r;return n.forEach((e=>{const t=i[e];i[e]=Array.isArray(t)?[...t]:{...t},i=i[e]})),i[s]=o,r}(e,["styles",...o],n);t(r)}),[t,e]);return{styles:(0,i.useMemo)((()=>n?o?Se().all([n,o]):n:Xe),[n,o]),userStyles:e?.styles,defaultStyles:n,updateStyleProp:a,updateStyles:r}},ot=[],nt={start:{scale:1,opacity:1},hover:{scale:0,opacity:0}},rt={hover:{opacity:1},start:{opacity:.5}},st={hover:{scale:1,opacity:1},start:{scale:0,opacity:0}};function it({label:e,isFocused:t,withHoverView:o}){const{colors:n}=(0,s.useSelect)((e=>({colors:e(P.H).getPaletteColors()})),[]),a=(0,i.useMemo)((()=>(n?.theme||ot).concat(n?.default||ot)),[n]),{styles:l}=tt(),{backgroundColor:c,headingColor:d,highlightedColors:m}=(0,i.useMemo)((()=>{const e=Te(l?.color?.background)||"white",t=Te(l?.color?.text)||"black",o=Te(l?.elements?.h1?.color?.text)||t,n=Te(l?.elements?.link?.color?.text)||o,r=Te(l?.elements?.button?.color?.background)||n,s=a.find((({color:e})=>e.toLowerCase()===t.toLowerCase())),i=a.find((({color:e})=>e.toLowerCase()===r.toLowerCase())),c=[...s?[s]:ot,...i?[i]:ot,...a].filter((({color:t},o,n)=>t.toLowerCase()!==e.toLowerCase()&&o===n.findIndex((e=>e.color.toLowerCase()===t.toLowerCase())))).slice(0,2);return{backgroundColor:e,headingColor:o,highlightedColors:c}}),[l,a]),p=l?.elements?.heading?.typography?.fontWeight||"inherit",u=l?.elements?.heading?.typography?.fontFamily||"inherit",[_,g]=(0,i.useState)(!1);return(0,r.jsx)("div",{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:(0,r.jsxs)(b.__unstableMotion.div,{style:{height:152,width:"100%",background:c,cursor:o?"pointer":void 0},initial:"start",animate:(_||t)&&e?"hover":"start",children:[(0,r.jsx)(b.__unstableMotion.div,{variants:nt,style:{height:"100%",overflow:"hidden"},children:(0,r.jsxs)(b.__experimentalHStack,{spacing:10,justify:"center",style:{height:"100%",overflow:"hidden"},children:[(0,r.jsx)(b.__unstableMotion.div,{style:{fontFamily:u,fontSize:65,color:d,fontWeight:p},animate:{scale:1,opacity:1},initial:{scale:.1,opacity:0},transition:{delay:.3,type:"tween"},children:"Aa"}),(0,r.jsx)(b.__experimentalVStack,{spacing:4,children:m.map((({slug:e,color:t},o)=>(0,r.jsx)(b.__unstableMotion.div,{style:{height:32,width:32,background:t,borderRadius:16},animate:{scale:1,opacity:1},initial:{scale:.1,opacity:0},transition:{delay:1===o?.2:.1}},e)))})]})}),(0,r.jsx)(b.__unstableMotion.div,{variants:o&&rt,style:{height:"100%",width:"100%",position:"absolute",top:0,overflow:"hidden",filter:"blur(60px)",opacity:.1},children:(0,r.jsx)(b.__experimentalHStack,{spacing:0,justify:"flex-start",style:{height:"100%",overflow:"hidden"},children:a.slice(0,4).map((({color:e})=>(0,r.jsx)("div",{style:{height:"100%",background:e,flexGrow:1}},e)))})}),(0,r.jsx)(b.__unstableMotion.div,{variants:st,style:{height:"100%",width:"100%",overflow:"hidden",position:"absolute",top:0},children:(0,r.jsx)(b.__experimentalVStack,{spacing:3,justify:"center",style:{height:"100%",overflow:"hidden",padding:10,boxSizing:"border-box"},children:e&&(0,r.jsx)("div",{style:{fontSize:40,fontFamily:u,color:d,fontWeight:p,lineHeight:"1em",textAlign:"center"},children:e})})})]})})}function at(){return(0,r.jsx)(b.Card,{size:"small",className:"edit-site-global-styles-screen-root",variant:"primary",children:(0,r.jsx)(b.CardBody,{children:(0,r.jsxs)(b.__experimentalVStack,{spacing:4,children:[(0,r.jsx)(b.Card,{children:(0,r.jsx)(b.CardMedia,{children:(0,r.jsx)(it,{})})}),(0,r.jsxs)(b.__experimentalItemGroup,{children:[(0,r.jsx)(b.__experimentalNavigatorButton,{path:"/typography",onClick:()=>(0,C.yM)("styles_sidebar_navigation_click",{path:"typography"}),children:(0,r.jsx)(b.__experimentalItem,{children:(0,r.jsxs)(b.__experimentalHStack,{justify:"flex-start",children:[(0,r.jsx)(b.Icon,{icon:Ze,size:24}),(0,r.jsx)(b.FlexItem,{children:(0,f.__)("Typography","woocommerce")})]})})}),(0,r.jsx)(b.__experimentalNavigatorButton,{path:"/colors",onClick:()=>(0,C.yM)("styles_sidebar_navigation_click",{path:"colors"}),children:(0,r.jsx)(b.__experimentalItem,{children:(0,r.jsxs)(b.__experimentalHStack,{justify:"flex-start",children:[(0,r.jsx)(b.Icon,{icon:Je,size:24}),(0,r.jsx)(b.FlexItem,{children:(0,f.__)("Colors","woocommerce")})]})})}),(0,r.jsx)(b.__experimentalNavigatorButton,{path:"/layout",onClick:()=>(0,C.yM)("styles_sidebar_navigation_click",{path:"layout"}),children:(0,r.jsx)(b.__experimentalItem,{children:(0,r.jsxs)(b.__experimentalHStack,{justify:"flex-start",children:[(0,r.jsx)(b.Icon,{icon:Ke,size:24}),(0,r.jsx)(b.FlexItem,{children:(0,f.__)("Layout","woocommerce")})]})})})]})]})})})}const lt={typography:{},color:{}},ct=(e,t,o="heading",n=!1)=>{switch(t){case"text":return{typography:e.typography,color:e.color};case"heading":return((e,t="heading",o=!1)=>o?Se().all([lt,e.elements.heading||{},e.elements[t]||{}]):{...lt,...e.elements.heading||{},...e.elements[t]||{}})(e,null!=o?o:"heading",n);default:return e.elements[t]||lt}};function dt({element:e,label:t}){const{styles:o}=tt(),n=ct(o,e,null,!0),{fontFamily:s,fontStyle:i,fontWeight:a,letterSpacing:l,textDecoration:c,textTransform:d}=n.typography,m=n.color?.text||"inherit",p=n.color?.background||"#f0f0f0",u=(0,f.sprintf)((0,f.__)("Typography %s styles","woocommerce"),t);return(0,r.jsx)(b.__experimentalItem,{children:(0,r.jsx)(b.__experimentalNavigatorButton,{path:`/typography/${e}`,"aria-label":u,onClick:()=>(0,C.yM)("styles_sidebar_screen_typography_button_click",{element:e,label:t,path:`typography/${e}`}),children:(0,r.jsxs)(b.__experimentalHStack,{justify:"flex-start",children:[(0,r.jsx)(b.FlexItem,{className:"edit-site-global-styles-screen-typography__indicator",style:{fontFamily:null!=s?s:"serif",background:p,color:m,fontStyle:null!=i?i:"normal",fontWeight:null!=a?a:"normal",letterSpacing:null!=l?l:"normal",textDecoration:null!=c?c:"link"===e?"underline":"none",textTransform:null!=d?d:"none"},children:"Aa"}),(0,r.jsx)(b.FlexItem,{children:t})]})})})}const mt=function(){return(0,r.jsx)(b.Card,{size:"small",variant:"primary",isBorderless:!0,children:(0,r.jsx)(b.CardBody,{children:(0,r.jsxs)(b.__experimentalVStack,{spacing:3,children:[(0,r.jsx)(b.__experimentalHeading,{level:3,className:"edit-site-global-styles-subtitle",children:(0,f.__)("Elements","woocommerce")}),(0,r.jsxs)(b.__experimentalItemGroup,{isBordered:!0,isSeparated:!0,size:"small",children:[(0,r.jsx)(dt,{element:"text",label:(0,f.__)("Text","woocommerce")}),(0,r.jsx)(dt,{element:"link",label:(0,f.__)("Links","woocommerce")}),(0,r.jsx)(dt,{element:"heading",label:(0,f.__)("Headings","woocommerce")}),(0,r.jsx)(dt,{element:"button",label:(0,f.__)("Buttons","woocommerce")})]})]})})})},pt=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"})}),ut=b.Navigator||b.__experimentalNavigatorProvider;function _t({title:e,description:t,onBack:o}){return(0,r.jsxs)(b.__experimentalVStack,{spacing:0,children:[(0,r.jsx)(b.__experimentalView,{children:(0,r.jsx)(b.__experimentalSpacer,{marginBottom:0,paddingX:4,paddingY:3,children:(0,r.jsxs)(b.__experimentalHStack,{spacing:2,children:[(0,r.jsx)(ut.BackButton,{style:{minWidth:24,padding:0},icon:pt,size:"small","aria-label":(0,f.__)("Navigate to the previous view","woocommerce"),onClick:o}),(0,r.jsx)(b.__experimentalSpacer,{children:(0,r.jsx)(b.__experimentalHeading,{className:"woocommerce-email-editor-styles-header",level:2,size:13,children:e})})]})})}),t&&(0,r.jsx)("p",{className:"woocommerce-email-editor-styles-header-description",children:t})]})}b.Navigator||(ut.Screen=b.__experimentalNavigatorScreen,ut.BackButton=b.__experimentalNavigatorBackButton);const gt=_t;function ht(){return(0,C.xW)("styles_sidebar_screen_typography_opened"),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(gt,{title:(0,f.__)("Typography","woocommerce"),description:(0,f.__)("Manage the typography settings for different elements.","woocommerce")}),(0,r.jsx)(mt,{})]})}const yt={fontFamily:!0,fontSize:!0,fontAppearance:!0,lineHeight:!0,letterSpacing:!1,textTransform:!1,textDecoration:!1,writingMode:!0,textColumns:!0},ft=function({element:e,headingLevel:t,defaultControls:o=yt}){const[n,s]=(0,u.useSettings)("typography.fontSizes","typography.fontFamilies"),a=s?.default||[],{styles:l,defaultStyles:c,updateStyleProp:d}=tt(),m=ct(l,e,t),p=ct(c,e,t),{fontFamily:_,fontSize:g,fontStyle:h,fontWeight:y,lineHeight:x,letterSpacing:w,textDecoration:v,textTransform:S}=m.typography,{fontFamily:j,fontSize:k,fontStyle:E,fontWeight:T,lineHeight:P,letterSpacing:M,textDecoration:N,textTransform:I}=p.typography,H="heading"!==e||"heading"!==t,B=(0,i.useCallback)(((o,n)=>{d("heading"===e?["elements",t,...o]:"text"===e?[...o]:["elements",e,...o],n)}),[e,d,t]),z=t=>{B(["typography","letterSpacing"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_letter_spacing",{element:e,newValue:t,selectedDefaultLetterSpacing:t===M})},A=t=>{B(["typography","lineHeight"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_line_height",{element:e,newValue:t,selectedDefaultLineHeight:t===P})},L=o=>{B(["typography","fontSize"],o),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_font_size",{element:e,headingLevel:t,newValue:o,selectedDefaultFontSize:o===k})},R=t=>{B(["typography","fontFamily"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_font_family",{element:e,newValue:t,selectedDefaultFontFamily:t===j})},F=t=>{B(["typography","textDecoration"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_text_decoration",{element:e,newValue:t,selectedDefaultTextDecoration:t===N})},O=t=>{B(["typography","textTransform"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_text_transform",{element:e,newValue:t,selectedDefaultTextTransform:t===I})},D=({fontStyle:t,fontWeight:o})=>{B(["typography","fontStyle"],t),B(["typography","fontWeight"],o),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_font_appearance",{element:e,newFontStyle:t,newFontWeight:o,selectedDefaultFontStyle:t===E,selectedDefaultFontWeight:o===T})};return(0,r.jsxs)(b.__experimentalToolsPanel,{label:(0,f.__)("Typography","woocommerce"),resetAll:()=>{B(["typography"],{}),(0,C.yM)("styles_sidebar_screen_typography_element_panel_reset_all_styles_selected",{element:e,headingLevel:t})},children:[(0,r.jsx)(b.__experimentalToolsPanelItem,{label:(0,f.__)("Font family","woocommerce"),hasValue:()=>_!==j,onDeselect:()=>R(void 0),isShownByDefault:o.fontFamily,children:(0,r.jsx)(u.__experimentalFontFamilyControl,{value:_,onChange:R,size:"__unstable-large",fontFamilies:a,__nextHasNoMarginBottom:!0})}),H&&(0,r.jsx)(b.__experimentalToolsPanelItem,{label:(0,f.__)("Font size","woocommerce"),hasValue:()=>g!==k,onDeselect:()=>L(void 0),isShownByDefault:o.fontSize,children:(0,r.jsx)(b.FontSizePicker,{value:g,onChange:L,fontSizes:n,disableCustomFontSizes:!1,withReset:!1,withSlider:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0})}),(0,r.jsx)(b.__experimentalToolsPanelItem,{className:"single-column",label:(0,f.__)("Appearance","woocommerce"),hasValue:()=>y!==T||h!==E,onDeselect:()=>{D({fontStyle:void 0,fontWeight:void 0})},isShownByDefault:o.fontAppearance,children:(0,r.jsx)(u.__experimentalFontAppearanceControl,{value:{fontStyle:h,fontWeight:y},onChange:D,hasFontStyles:!0,hasFontWeights:!0,size:"__unstable-large"})}),(0,r.jsx)(b.__experimentalToolsPanelItem,{className:"single-column",label:(0,f.__)("Line height","woocommerce"),hasValue:()=>x!==P,onDeselect:()=>A(void 0),isShownByDefault:o.lineHeight,children:(0,r.jsx)(u.LineHeightControl,{__nextHasNoMarginBottom:!0,__unstableInputWidth:"auto",value:x,onChange:A,size:"__unstable-large"})}),(0,r.jsx)(b.__experimentalToolsPanelItem,{className:"single-column",label:(0,f.__)("Letter spacing","woocommerce"),hasValue:()=>w!==M,onDeselect:()=>z(void 0),isShownByDefault:o.letterSpacing,children:(0,r.jsx)(u.__experimentalLetterSpacingControl,{value:w,onChange:z,size:"__unstable-large",__unstableInputWidth:"auto"})}),(0,r.jsx)(b.__experimentalToolsPanelItem,{className:"single-column",label:(0,f.__)("Text decoration","woocommerce"),hasValue:()=>v!==N,onDeselect:()=>F(void 0),isShownByDefault:o.textDecoration,children:(0,r.jsx)(u.__experimentalTextDecorationControl,{value:v,onChange:F,size:"__unstable-large",__unstableInputWidth:"auto"})}),(0,r.jsx)(b.__experimentalToolsPanelItem,{label:(0,f.__)("Letter case","woocommerce"),hasValue:()=>S!==I,onDeselect:()=>O(I),isShownByDefault:o.textTransform,children:(0,r.jsx)(u.__experimentalTextTransformControl,{value:S,onChange:O,showNone:!0,isBlock:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0})})]})};function xt({element:e,headingLevel:t}){const{styles:o}=tt(),n=ct(o,e,t,!0),{fontFamily:s,fontSize:i,fontStyle:a,fontWeight:l,lineHeight:c,letterSpacing:d,textDecoration:m,textTransform:p}=n.typography,u=n.color?.text||"inherit",_=n.color?.background||"#f0f0f0",g="link"===e?{textDecoration:null!=m?m:"underline"}:{};return(0,r.jsx)("div",{className:"edit-site-typography-preview",style:{fontFamily:null!=s?s:"serif",background:_,color:u,lineHeight:c,fontSize:i,fontStyle:a,fontWeight:l,letterSpacing:d,textDecoration:m,textTransform:p,...g},children:"Aa"})}const wt={text:{title:(0,f.__)("Text","woocommerce"),description:(0,f.__)("Manage the fonts and typography used on text.","woocommerce"),defaultControls:yt},link:{title:(0,f.__)("Links","woocommerce"),description:(0,f.__)("Manage the fonts and typography used on links.","woocommerce"),defaultControls:{...yt,textDecoration:!0}},heading:{title:(0,f.__)("Headings","woocommerce"),description:(0,f.__)("Manage the fonts and typography used on headings.","woocommerce"),defaultControls:{...yt,textTransform:!0}},button:{title:(0,f.__)("Buttons","woocommerce"),description:(0,f.__)("Manage the fonts and typography used on buttons.","woocommerce"),defaultControls:yt}};function vt({element:e}){(0,C.xW)("styles_sidebar_screen_typography_element_opened",{element:e});const[t,o]=(0,i.useState)("heading");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(gt,{title:wt[e].title,description:wt[e].description}),(0,r.jsx)(b.__experimentalSpacer,{marginX:4,children:(0,r.jsx)(xt,{element:e,headingLevel:t})}),"heading"===e&&(0,r.jsx)(b.__experimentalSpacer,{marginX:4,marginBottom:"1em",children:(0,r.jsxs)(b.__experimentalToggleGroupControl,{label:(0,f.__)("Select heading level","woocommerce"),hideLabelFromVision:!0,value:t,onChange:e=>{o(e.toString()),(0,C.yM)("styles_sidebar_screen_typography_element_heading_level_selected",{value:e})},isBlock:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0,children:[(0,r.jsx)(b.__experimentalToggleGroupControlOption,{value:"heading",label:(0,f._x)("All","heading levels","woocommerce")}),(0,r.jsx)(b.__experimentalToggleGroupControlOption,{value:"h1",label:(0,f._x)("H1","Heading Level","woocommerce")}),(0,r.jsx)(b.__experimentalToggleGroupControlOption,{value:"h2",label:(0,f._x)("H2","Heading Level","woocommerce")}),(0,r.jsx)(b.__experimentalToggleGroupControlOption,{value:"h3",label:(0,f._x)("H3","Heading Level","woocommerce")}),(0,r.jsx)(b.__experimentalToggleGroupControlOption,{value:"h4",label:(0,f._x)("H4","Heading Level","woocommerce")}),(0,r.jsx)(b.__experimentalToggleGroupControlOption,{value:"h5",label:(0,f._x)("H5","Heading Level","woocommerce")}),(0,r.jsx)(b.__experimentalToggleGroupControlOption,{value:"h6",label:(0,f._x)("H6","Heading Level","woocommerce")})]})}),(0,r.jsx)(ft,{element:e,headingLevel:t,defaultControls:wt[e].defaultControls})]})}function bt(){(0,C.xW)("styles_sidebar_screen_colors_opened");const{userStyles:e,styles:t,updateStyles:o}=tt(),n=(0,s.useSelect)((e=>e(P.H).getTheme()),[]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(gt,{title:(0,f.__)("Colors","woocommerce"),description:(0,f.__)("Manage palettes and the default color of different global elements.","woocommerce")}),(0,r.jsx)(q,{value:e,inheritedValue:t,onChange:e=>{o(e),(0,C.yM)("styles_sidebar_screen_colors_styles_updated")},settings:n?.settings,panelId:"colors"})]})}var St=o(66087);function jt(){const[e]=(0,u.useSettings)("spacing.units"),t=(0,b.__experimentalUseCustomUnits)({availableUnits:e}),{styles:o,defaultStyles:n,updateStyleProp:s}=tt();return(0,r.jsxs)(b.__experimentalToolsPanel,{label:(0,f.__)("Dimensions","woocommerce"),resetAll:()=>{s(["spacing"],n.spacing),(0,C.yM)("styles_sidebar_screen_layout_dimensions_reset_all_selected")},children:[(0,r.jsx)(b.__experimentalToolsPanelItem,{isShownByDefault:!0,hasValue:()=>!(0,St.isEqual)(o.spacing.padding,n.spacing.padding),label:(0,f.__)("Padding","woocommerce"),onDeselect:()=>{s(["spacing","padding"],n.spacing.padding),(0,C.yM)("styles_sidebar_screen_layout_dimensions_padding_reset_clicked")},className:"tools-panel-item-spacing",children:(0,r.jsx)(u.__experimentalSpacingSizesControl,{allowReset:!0,values:o.spacing.padding,onChange:e=>{s(["spacing","padding"],e),(0,C.T7)("styles_sidebar_screen_layout_dimensions_padding_updated",{value:e})},label:(0,f.__)("Padding","woocommerce"),sides:["horizontal","vertical","top","left","right","bottom"],units:t})}),(0,r.jsx)(b.__experimentalToolsPanelItem,{isShownByDefault:!0,label:(0,f.__)("Block spacing","woocommerce"),hasValue:()=>o.spacing.blockGap!==n.spacing.blockGap,onDeselect:()=>{s(["spacing","blockGap"],n.spacing.blockGap),(0,C.yM)("styles_sidebar_screen_layout_dimensions_block_spacing_reset_clicked")},className:"tools-panel-item-spacing",children:(0,r.jsx)(u.__experimentalSpacingSizesControl,{label:(0,f.__)("Block spacing","woocommerce"),min:0,onChange:e=>{s(["spacing","blockGap"],e.top),(0,C.T7)("styles_sidebar_screen_layout_dimensions_block_spacing_updated",{value:e})},showSideInLabel:!1,sides:["top"],values:{top:o.spacing.blockGap},allowReset:!0})})]})}function kt(){return(0,C.xW)("styles_sidebar_screen_layout_opened"),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(_t,{title:(0,f.__)("Layout","woocommerce")}),(0,r.jsx)(jt,{})]})}const Et=(0,i.memo)((function(){const{userCanEditGlobalStyles:e}=(0,s.useSelect)((e=>{const{canEdit:t}=e(P.H).canUserEditGlobalEmailStyles();return{userCanEditGlobalStyles:t}}),[]);return e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.PluginSidebarMoreMenuItem,{target:"email-styles-sidebar",icon:Ye,children:(0,f.__)("Email styles","woocommerce")}),(0,r.jsx)(l.PluginSidebar,{name:"email-styles-sidebar",icon:Ye,title:(0,f.__)("Styles","woocommerce"),className:"woocommerce-email-editor-styles-panel",header:(0,f.__)("Styles","woocommerce"),children:(0,r.jsxs)(ut,{initialPath:"/",children:[(0,r.jsx)(ut.Screen,{path:"/",children:(0,r.jsx)(at,{})}),(0,r.jsx)(ut.Screen,{path:"/typography",children:(0,r.jsx)(ht,{})}),(0,r.jsx)(ut.Screen,{path:"/typography/text",children:(0,r.jsx)(vt,{element:"text"})}),(0,r.jsx)(ut.Screen,{path:"/typography/link",children:(0,r.jsx)(vt,{element:"link"})}),(0,r.jsx)(ut.Screen,{path:"/typography/heading",children:(0,r.jsx)(vt,{element:"heading"})}),(0,r.jsx)(ut.Screen,{path:"/typography/button",children:(0,r.jsx)(vt,{element:"button"})}),(0,r.jsx)(ut.Screen,{path:"/colors",children:(0,r.jsx)(bt,{})}),(0,r.jsx)(ut.Screen,{path:"/layout",children:(0,r.jsx)(kt,{})})]})})]})})),Tt=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.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"})});var Ct=o(30221);function Pt(){const{togglePreviewModal:e}=(0,s.useDispatch)(P.H);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.PluginPreviewMenuItem,{icon:Tt,onClick:()=>{(0,C.yM)("header_preview_dropdown_send_test_email_selected"),e(!0)},children:(0,f.__)("Send a test email","woocommerce")}),(0,r.jsx)(Ct.P,{})]})}var Mt=o(48558),Nt=o(41233);const It=()=>{const e=(0,c.useViewportMatch)("large");return(0,r.jsx)(r.Fragment,{children:e&&(0,r.jsx)(K,{children:(0,r.jsx)(Nt.PreferenceToggleMenuItem,{scope:P.H,name:"fullscreenMode",label:(0,f.__)("Fullscreen mode","woocommerce"),info:(0,f.__)("Show and hide the admin user interface","woocommerce"),messageActivated:(0,f.__)("Fullscreen mode activated.","woocommerce"),messageDeactivated:(0,f.__)("Fullscreen mode deactivated.","woocommerce"),shortcut:Mt.displayShortcut.secondary("f")})})})};function Ht({label:e,labelSuffix:t,help:o,placeholder:n,attributeName:a,attributeValue:l,updateProperty:c=()=>{}}){const[d,m]=(0,i.useState)(null),[p,_]=(0,i.useState)(!1),g=(0,s.useSelect)((e=>e(P.H).getPersonalizationTagsList()),[]),h=(0,i.useRef)(null),y=(0,i.useCallback)(((e,t,o)=>{var n,r;const s=null!==(n=o?.start)&&void 0!==n?n:t.length,i=null!==(r=o?.end)&&void 0!==r?r:t.length;let l=(0,v.create)({html:t});l=(0,v.insert)(l,(0,v.create)({html:`\x3c!--${e}--\x3e`}),s,i);const d=(0,v.toHTMLString)({value:l});c(a,d),m(null)}),[a,c]),x=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:e}),(0,r.jsx)(b.Button,{className:"woocommerce-settings-panel-personalization-tags-button",icon:"shortcode",title:(0,f.__)("Personalization Tags","woocommerce"),onClick:()=>{_(!0),(0,C.yM)("rich_text_with_button_personalization_tags_shortcode_icon_clicked",{attributeName:a,label:e})}}),t]});return a?(0,r.jsxs)(b.BaseControl,{id:"",label:x,className:`woocommerce-settings-panel-${a}-text`,help:o,__nextHasNoMarginBottom:!0,children:[(0,r.jsx)(M,{isOpened:p,onInsert:e=>{y(e,null!=l?l:"",d),_(!1),(0,C.yM)("rich_text_with_button_personalization_tags_inserted",{attributeName:a,value:e})},closeCallback:()=>_(!1),openedBy:"RichTextWithButton-BaseControl"}),(0,r.jsx)(N,{contentRef:h,onUpdate:(e,t)=>{const o=(null!=l?l:"").replace(`\x3c!--[${e}]--\x3e`,`\x3c!--[${t}]--\x3e`);c(a,o)}}),(0,r.jsx)(u.RichText,{ref:h,className:"woocommerce-settings-panel-richtext",placeholder:n,onFocus:()=>{m(S(h,null!=l?l:""))},onKeyUp:()=>{m(S(h,null!=l?l:""))},onClick:()=>{m(S(h,null!=l?l:""))},onChange:e=>{var t;e=j(null!==(t=e)&&void 0!==t?t:"",g),c(a,e),(0,C.xW)("rich_text_with_button_input_field_updated",{attributeName:a})},value:null!=l?l:"","data-automation-id":`email_${a}`})]}):null}function Bt({close:e}){(0,C.xW)("edit_template_modal_opened");const{onNavigateToEntityRecord:t,template:o}=(0,s.useSelect)((e=>{const{getEditorSettings:t}=e(l.store),o=t();return{onNavigateToEntityRecord:o?.onNavigateToEntityRecord,template:e(P.H).getCurrentTemplate()}}),[]);return(0,r.jsxs)(b.Modal,{size:"medium",onRequestClose:e,__experimentalHideHeader:!0,children:[(0,r.jsx)("p",{children:(0,f.__)("This template is used by multiple emails. Any changes made would affect other emails on the site. Are you sure you want to edit the template?","woocommerce")}),(0,r.jsxs)(b.Flex,{justify:"end",children:[(0,r.jsx)(b.FlexItem,{children:(0,r.jsx)(b.Button,{variant:"tertiary",onClick:()=>{(0,C.yM)("edit_template_modal_cancel_button_clicked"),e()},children:(0,f.__)("Cancel","woocommerce")})}),(0,r.jsx)(b.FlexItem,{children:(0,r.jsx)(b.Button,{variant:"primary",onClick:()=>{(0,C.yM)("edit_template_modal_continue_button_clicked",{templateId:o.id}),t?.({postId:o.id,postType:"wp_template"})},disabled:!o.id||!t,children:(0,f.__)("Edit template","woocommerce")})})]})]})}function zt(){const{template:e,currentEmailContent:t,canUpdateTemplates:o,postType:n}=(0,s.useSelect)((e=>({template:e(P.H).getCurrentTemplate(),currentEmailContent:e(P.H).getEditedEmailContent(),canUpdateTemplates:e(P.H).canUserEditTemplates(),postType:e(P.H).getEmailPostType()})),[]),[a]=Be("swap"),[l,c]=(0,i.useState)(!1),[d,m]=(0,i.useState)(!1);return(0,r.jsxs)(r.Fragment,{children:[e&&(0,r.jsx)(b.PanelRow,{children:(0,r.jsxs)(b.Flex,{justify:"start",children:[(0,r.jsx)(b.FlexItem,{className:"editor-post-panel__row-label",children:(0,f.__)("Template","woocommerce")}),(0,r.jsxs)(b.FlexItem,{children:[!(a?.length>1||o)&&(0,r.jsx)("b",{children:e?.title}),(a?.length>1||o)&&(0,r.jsx)(b.DropdownMenu,{icon:null,text:e?.title,toggleProps:{variant:"tertiary"},label:(0,f.__)("Template actions","woocommerce"),onToggle:t=>(0,C.yM)("sidebar_template_actions_clicked",{currentTemplate:e?.title,isOpen:t}),children:({onClose:e})=>(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(b.MenuItem,{onClick:()=>{(0,C.yM)("sidebar_template_actions_edit_template_clicked"),c(!0),e()},children:(0,f.__)("Edit template","woocommerce")}),a?.length>1&&(0,r.jsx)(b.MenuItem,{onClick:()=>{(0,C.yM)("sidebar_template_actions_swap_template_clicked"),m(!0),e()},children:(0,f.__)("Swap template","woocommerce")})]})})]})]})}),l&&(0,r.jsx)(Bt,{close:()=>((0,C.yM)("edit_template_modal_closed"),c(!1))}),d&&(0,r.jsx)(Ue,{onSelectCallback:()=>m(!1),closeCallback:()=>m(!1),previewContent:t,postType:n})]})}const At={recordEvent:C.yM,recordEventOnce:C.xW,debouncedRecordEvent:C.T7};function Lt(){const e=(0,i.useMemo)((()=>(0,a.applyFilters)("woocommerce_email_editor_setting_sidebar_extension_component",Ht,At)),[]),t=(0,i.useMemo)((()=>(0,a.applyFilters)("woocommerce_email_editor_setting_sidebar_email_status_component",(()=>null),At)),[]);return(0,r.jsxs)(l.PluginDocumentSettingPanel,{name:"email-settings-panel",title:(0,f.__)("Settings","woocommerce"),className:"woocommerce-email-editor__settings-panel",children:[(0,r.jsx)(t,{}),(0,r.jsx)(zt,{}),(0,r.jsx)(l.ErrorBoundary,{canCopyContent:!0,children:(0,r.jsx)(e,{})})]})}const Rt={recordEvent:C.yM,recordEventOnce:C.xW,debouncedRecordEvent:C.T7};function Ft(){const e=(0,a.applyFilters)("woocommerce_email_editor_template_sections",[],Rt);return 0===e.length?null:(0,r.jsx)(l.PluginDocumentSettingPanel,{name:"template-settings-panel",title:(0,f.__)("Settings","woocommerce"),className:"woocommerce-email-editor__settings-panel",children:e.map((e=>(0,r.jsx)(l.ErrorBoundary,{children:(0,r.jsx)("div",{children:e.render()},e.id)},`error-boundary-${e.id}`)))})}function Ot(){const{isDirty:e}=(0,l.useEntitiesSavedStatesIsDirty)(),{hasEmptyContent:t,isEmailSent:o,urls:n}=(0,s.useSelect)((e=>({hasEmptyContent:e(P.H).hasEmptyContent(),isEmailSent:e(P.H).isEmailSent(),urls:e(P.H).getUrls()})),[]);function i(){n.send&&(window.location.href=n.send)}const c=t||o||e,d=(0,a.applyFilters)("woocommerce_email_editor_send_button_label",(0,f.__)("Send","woocommerce"));return(0,r.jsx)(b.Button,{variant:"primary",size:"compact",onClick:()=>{(0,C.yM)("header_send_button_clicked"),(0,a.applyFilters)("woocommerce_email_editor_send_action_callback",i)()},disabled:c,"data-automation-id":"email_editor_send_button",children:d})}function Dt({children:e}){const t=(0,i.useRef)(document.createElement("div"));return(0,i.useEffect)((()=>{const e=document.getElementsByClassName("editor-post-publish-button__button")[0];e&&e.parentNode?.insertBefore(t.current,e.nextSibling)}),[t]),(0,i.createPortal)((0,r.jsx)(r.Fragment,{children:e}),t.current)}function Vt(){const e=(0,i.useRef)(null),{hasNonPostEntityChanges:t,isEditedPostDirty:o,isEditingTemplate:n}=(0,s.useSelect)((e=>({hasNonPostEntityChanges:e(l.store).hasNonPostEntityChanges(),isEditedPostDirty:e(l.store).isEditedPostDirty(),isEditingTemplate:"wp_template"===e(l.store).getCurrentPostType()})),[]),a=n||t||o&&t,c=(0,i.useCallback)(((e,t)=>{t&&e.classList.contains("force-hidden")&&e.classList.remove("force-hidden"),t||e.classList.contains("force-hidden")||e.classList.add("force-hidden")}),[]);return(0,i.useEffect)((()=>{const t=document.getElementsByClassName("editor-post-publish-button__button")[0];return c(t,a),t?(e.current&&e.current.disconnect(),e.current=new MutationObserver((()=>{c(t,a)})),e.current.observe(t,{attributes:!0,childList:!0,subtree:!1}),()=>e.current?.disconnect()):()=>e.current?.disconnect()}),[a,c]),(0,r.jsx)(Dt,{children:!a&&(0,r.jsx)(Ot,{})})}const Gt=()=>{const e="email-validation",t=(0,s.useSelect)((t=>t(oe.store).getNotices(e)));return{notices:t,hasValidationNotice:(0,i.useCallback)((e=>e?void 0!==t.find((t=>t.id===e)):t?.length>0),[t]),addValidationNotice:(0,i.useCallback)(((t,o,n=[])=>{(0,s.dispatch)(oe.store).createNotice("error",o,{id:t,isDismissible:!1,actions:n,context:e})}),[e]),removeValidationNotice:(0,i.useCallback)((t=>{(0,s.dispatch)(oe.store).removeNotice(t,e)}),[e])}};function $t(){const{notices:e}=Gt();return 0===e.length?null:(0,r.jsx)(b.Notice,{status:"error",className:"woocommerce-email-editor-validation-errors components-editor-notices__pinned",isDismissible:!1,children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:(0,f.__)("Fix errors to continue:","woocommerce")}),(0,r.jsx)("ul",{children:e.map((({id:e,content:t,actions:o})=>(0,r.jsxs)("li",{children:[t,o.length>0?o.map((({label:e,onClick:t})=>(0,r.jsx)(b.Button,{onClick:t,variant:"link",children:e},e))):null]},e)))})]})})}function Wt({context:e="email-editor"}){const{notices:t}=(0,s.useSelect)((t=>({notices:t(oe.store).getNotices(e)})),[e]),o=(0,i.useMemo)((()=>({"site-editor-save-success":{content:(0,f.__)("Email design updated.","woocommerce"),removeActions:!0},"editor-save":{content:(0,f.__)("Email saved.","woocommerce"),removeActions:!1,contentCheck:e=>e.content.includes((0,f.__)("Post updated."))}})),[]),{removeNotice:n}=(0,s.useDispatch)(oe.store),a=t.filter((({type:e})=>"snackbar"===e)).map((e=>o[e.id]?o[e.id].contentCheck&&!o[e.id].contentCheck(e)?e:{...e,content:o[e.id].content,spokenMessage:o[e.id].content,actions:o[e.id].removeActions?[]:e.actions}:e));return(0,r.jsx)(b.SnackbarList,{notices:a,className:"components-editor-notices__snackbar",onRemove:t=>n(t,e)})}function Ut({children:e}){const[t]=(0,i.useState)(document.createElement("div"));return(0,i.useEffect)((()=>{const e=document.getElementsByClassName("editor-visual-editor ")[0];e&&e.parentNode?.insertBefore(t,e)}),[t]),(0,i.createPortal)((0,r.jsx)(r.Fragment,{children:e}),t)}function qt(){const{notices:e}=(0,s.useSelect)((e=>({notices:e(oe.store).getNotices("email-editor")})),[]),{removeNotice:t}=(0,s.useDispatch)(oe.store),o=e.filter((({isDismissible:e,type:t})=>e&&"default"===t)),n=e.filter((({isDismissible:e,type:t})=>!e&&"default"===t));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(Ut,{children:[(0,r.jsx)(b.NoticeList,{notices:n,className:"components-editor-notices__pinned"}),(0,r.jsx)(b.NoticeList,{notices:o,className:"components-editor-notices__dismissible",onRemove:e=>t(e,"email-editor")}),(0,r.jsx)($t,{})]}),(0,r.jsx)(Wt,{context:"global"}),(0,r.jsx)(Wt,{context:"email-editor"})]})}const Yt=e=>{const t=(0,d.getBlockSupport)(e,"background");return t&&!1!==t?.backgroundImage};function Zt(){const e=(0,s.useSelect)((e=>e("core/block-editor").getSelectedBlock()),[]),t=(0,d.hasBlockSupport)(e?.name,"border",!1)||(0,d.hasBlockSupport)(e?.name,"__experimentalBorder",!1);return(0,r.jsxs)(r.Fragment,{children:[t&&(0,r.jsx)(b.Fill,{name:"InspectorControlsBorder",children:(0,r.jsxs)(b.Notice,{className:"woocommerce-grid-full-width",status:"warning",isDismissible:!1,children:[(0,f.__)("Border display may vary or be unsupported in some email clients.","woocommerce"),(0,r.jsx)("br",{}),(0,f.__)("Units other than pixels (px) lack support in old email clients.","woocommerce")]})}),Yt(e?.name)&&(0,r.jsx)(b.Fill,{name:"InspectorControlsBackground",children:(0,r.jsx)(b.Notice,{className:"woocommerce-grid-full-width",status:"warning",isDismissible:!1,children:(0,f.__)("Select a background color for email clients that do not support background images.","woocommerce")})})]})}const Jt=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24",children:(0,r.jsx)(ne.Path,{d:"M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"})}),Kt=(0,r.jsx)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(ne.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})}),Xt={edit:{opacity:0,scale:.2},hover:{opacity:1,scale:1,clipPath:"inset( 22% round 2px )"}},Qt={edit:{clipPath:"inset(0% round 0px)"},hover:{clipPath:"inset( 22% round 2px )"},tap:{clipPath:"inset(0% round 0px)"}},eo=()=>{const{urls:e}=(0,s.useSelect)((e=>({urls:e(P.H).getUrls()})),[]);function t(){e.listings&&(window.location.href=e.back)}return(0,r.jsx)(X,{children:({length:e})=>e<=1&&(0,r.jsxs)(b.__unstableMotion.div,{className:"woocommerce-email-editor__view-mode-toggle",transition:{duration:.2},animate:"edit",initial:"edit",whileHover:"hover",whileTap:"tap",children:[(0,r.jsx)(b.Button,{label:(0,f.__)("Close editor","woocommerce"),showTooltip:!0,tooltipPosition:"middle right",onClick:()=>{(0,C.yM)("header_close_button_clicked"),(0,a.applyFilters)("woocommerce_email_editor_close_action_callback",t)()},children:(0,r.jsx)(b.__unstableMotion.div,{variants:Qt,children:(0,r.jsx)("div",{className:"woocommerce-email-editor__view-mode-toggle-icon",children:(0,r.jsx)(ze.A,{className:"woocommerce-email-editor-icon__icon",icon:Jt,size:48})})})}),(0,r.jsx)(b.__unstableMotion.div,{className:"woocommerce-email-editor-icon",variants:Xt,children:(0,r.jsx)(ze.A,{icon:Kt})})]})})};function to({postId:e,postType:t,settings:o,contentRef:n}){const{currentPost:a,onNavigateToEntityRecord:c,onNavigateToPreviousEntityRecord:d}=function(e,t,o){const[n,r]=(0,i.useReducer)(((e,{type:t,post:o,previousRenderingMode:n})=>"push"===t?[...e,{post:o,previousRenderingMode:n}]:"pop"===t&&e.length>1?e.slice(0,-1):e),[{post:{postId:e,postType:t}}]),{post:a,previousRenderingMode:c}=n[n.length-1],{getRenderingMode:d}=(0,s.useSelect)(l.store),{setRenderingMode:m}=(0,s.useDispatch)(l.store),p=(0,i.useCallback)((e=>{r({type:"push",post:{postId:e.postId,postType:e.postType},previousRenderingMode:d()}),m(o)}),[d,m,o]),u=(0,i.useCallback)((()=>{r({type:"pop"}),c&&m(c)}),[m,c]);return{currentPost:a,onNavigateToEntityRecord:p,onNavigateToPreviousEntityRecord:n.length>1?u:void 0}}(e,t,"post-only"),{post:m,template:p}=(0,s.useSelect)((e=>{const{getEntityRecord:t}=e(te.store),{getEditedPostTemplate:o}=e(P.H),n=t("postType",a.postType,a.postId);return{template:n&&"wp_template"!==a.postType?o(n.template):null,post:n}}),[a.postType,a.postId]),{isFullscreenEnabled:u,allCommands:_}=(0,s.useSelect)((e=>({isFullscreenEnabled:e(P.H).isFeatureActive("fullscreenMode"),allCommands:e(ve.store).getCommands()})),[]),{isFullScreenForced:g,displaySendEmailButton:h}=o,{removeEditorPanel:y}=(0,s.useDispatch)(l.store);(0,i.useEffect)((()=>{y("post-status")}),[y]);const[f]=Pe(),x=(0,i.useMemo)((()=>({...o,onNavigateToEntityRecord:c,onNavigateToPreviousEntityRecord:d,defaultRenderingMode:"wp_template"===a.postType?"post-only":"template-locked",supportsTemplateMode:!0})),[o,c,d,a.postType]);return m&&("wp_template"===a.postType||m.template===p?.slug||!m.template&&p)?((0,C.xW)("editor_layout_loaded"),(0,r.jsx)(b.SlotFillProvider,{children:(0,r.jsxs)(l.ErrorBoundary,{canCopyContent:!0,children:[(!_||0===_.length)&&(0,r.jsx)(ve.CommandMenu,{}),(0,r.jsxs)(Z,{postId:a.postId,postType:a.postType,settings:x,templateId:p&&p.id,styles:f,contentRef:n,children:[(0,r.jsx)(l.AutosaveMonitor,{}),(0,r.jsx)(l.LocalAutosaveMonitor,{}),(0,r.jsx)(l.UnsavedChangesWarning,{}),(0,r.jsx)(l.EditorKeyboardShortcutsRegister,{}),(0,r.jsx)(l.PostLockedModal,{}),(0,r.jsx)(qe,{}),(0,r.jsx)(Et,{}),(0,r.jsx)(Pt,{}),(0,r.jsx)(Me,{}),(0,r.jsx)(J,{isActive:g||u}),(g||u)&&(0,r.jsx)(eo,{}),!g&&(0,r.jsx)(It,{}),"wp_template"===a.postType?(0,r.jsx)(Ft,{}):(0,r.jsx)(Lt,{}),h&&(0,r.jsx)(Vt,{}),(0,r.jsx)(qt,{}),(0,r.jsx)(Zt,{})]})]})})):(0,r.jsx)("div",{className:"spinner-container",children:(0,r.jsx)(b.Spinner,{style:{width:"80px",height:"80px"}})})}var oo=o(68908);const no=window.wp.mediaUtils,ro=()=>{(0,g.HY)("editor.MediaUpload","woocommerce/email-editor/replace-media-upload",(()=>no.MediaUpload))},so=()=>{const e={"You’ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?":{domain:"default",replacementText:(0,f.__)("You’ve tried to select a block that is part of a template that may be used in other emails. Would you like to edit the template?","woocommerce")}};(0,g.HY)("i18n.gettext","woocommerce/email-editor/override-text",((t,o,n)=>e[o]&&e[o].domain===(n||"default")?e[o].replacementText:t))},io=e=>{(0,a.doAction)("woocommerce_email_editor_events",e.detail)},ao=()=>{(0,C.V1)()&&C.oh.addEventListener(C.vD,io)};window.addEventListener("unload",(function(){(0,C.V1)()&&C.oh.removeEventListener(C.vD,io)}));const lo=(...e)=>{const t=(0,s.select)(l.store).isInserterOpened(),o=!!document.getElementsByClassName("block-editor-inserter__quick-inserter").length;let n="other_inserter";t?n="inserter_sidebar":o&&(n="quick_inserter");const r=e[0],i=e[5];!1===Array.isArray(r)&&"object"==typeof r&&(0,C.yM)(`${n}_library_block_selected`,{blockName:r.name}),Array.isArray(r)&&i&&i.patternName&&(0,C.yM)(`${n}_library_pattern_selected`,{patternName:i.patternName})},co={"core/editor":{autosave:"editor_content_auto_saved",setDeviceType:e=>{(0,C.yM)(`header_preview_dropdown_${e.toLowerCase()}_selected`)},setRenderingMode:e=>{(0,s.select)(l.store).getRenderingMode()!==e&&document.querySelector(`[aria-label="${(0,f.__)("View options")}"]`)&&(0,C.yM)("preview_dropdown_rendering_mode_changed",{renderingMode:e})}},"core/block-editor":{insertBlock:lo,insertBlocks:lo},"core/preferences":{set:(e,t,o)=>{if((0,s.select)(Nt.store).get(e,t)===o)return;const n={focusMode:"focus_mode_toggle",fullscreenMode:"full_screen_mode_toggle",distractionFree:"distraction_free_toggle",fixedToolbar:"fixed_toolbar_toggle"};n[t]&&(0,C.yM)(n[t],{isEnabled:o})}},"core/commands":{open:"command_menu_opened",close:"command_menu_closed"}},mo={},po={},uo=()=>{(0,C.V1)()&&(0,s.use)((e=>({dispatch:t=>{const o="object"==typeof t?t.name:t,n=e.dispatch(o),r=co[o];if(!r)return n;mo[o]||(mo[o]={}),po[o]||(po[o]={});for(const[e,t]of Object.entries(r))po[o][e]||(po[o][e]=n[e],mo[o][e]=(...n)=>{try{"function"==typeof t?t(...n):"string"==typeof t&&(0,C.yM)(t)}catch(e){console.error("Error tracking event",e)}return po[o][e](...n)}),n[e]=mo[o][e];return n}})))};let _o=[];function go(e){_o.forEach((t=>{const o=e.target?.matches?.(t.selector)?e.target:e.target?.closest?.(t.selector);o&&("function"==typeof t.track?t.track(o,e):(0,C.yM)(t.track))}))}const ho=new WeakMap,yo={core:["saveEditedEntityRecord","saveEntityRecord"]},fo=()=>{Object.keys(ho).length>0||(0,s.use)((e=>({dispatch:t=>{const o="object"==typeof t?t.name:t;if(!yo[o])return e.dispatch(o);const n=e.dispatch(o);ho[o]||(ho[o]={});const r=yo[o].filter((e=>!ho[o][e]));if(r.length>0)for(const t of r)ho[o][t]=n[t],n[t]=async(...n)=>{const r=e.select(P.H).getContentValidation(),s=r?.validateContent;if(s){let e;try{e=s()}catch(t){e=!1}if(!e)return Promise.reject(new Error((0,f.__)("Content validation failed.","woocommerce")))}return await ho[o][t](...n)};return n}})))},xo=window.wp.isShallowEqual;var wo=o.n(xo);function vo(e){const t=(0,i.useRef)(e);return wo()(e,t.current)||(t.current=e),t.current}const bo=[],So=()=>{const{addValidationNotice:e,hasValidationNotice:t,removeValidationNotice:o}=Gt(),{editedContent:n,editedTemplateContent:r}=(0,s.useSelect)((e=>({editedContent:e(P.H).getEditedEmailContent(),editedTemplateContent:e(P.H).getCurrentTemplateContent()}))),l=vo(n),c=vo(r),d=(0,i.useCallback)((()=>((e,t,{addValidationNotice:o,hasValidationNotice:n,removeValidationNotice:r})=>{const s=(0,a.applyFilters)("woocommerce_email_editor_content_validation_rules",bo);let i=!0;return s.forEach((({id:s,testContent:a,message:l,actions:c})=>{a(e+t)?(o(s,l,c),i=!1):n(s)&&r(s)})),i})(l,c,{addValidationNotice:e,hasValidationNotice:t,removeValidationNotice:o})),[l,c,e,o,t]);return(0,i.useEffect)((()=>((0,s.dispatch)(P.H).setContentValidation({validateContent:d}),()=>{(0,s.dispatch)(P.H).setContentValidation(void 0)})),[d]),(0,i.useEffect)((()=>{const e=(0,s.subscribe)((()=>{t()&&d()}),te.store);return()=>e()}),[t,d]),{validateContent:d}},jo=()=>{const e=(0,i.useMemo)((()=>{const e=(0,f.__)("Saving failed.");return new RegExp("^"+e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}),[]);(0,i.useEffect)((()=>{const t=(0,s.subscribe)((()=>{(0,s.select)(oe.store).getNotices().forEach((t=>{"string"==typeof t.content&&e.test(t.content)&&(0,s.dispatch)(oe.store).removeNotice(t.id)}))}));return()=>{t()}}),[e])},ko=()=>{const e=(0,i.useRef)(null),[t,o]=(0,i.useState)(0),n=(0,i.useCallback)((t=>{e.current=t,o((e=>++e))}),[e,o]),r=(0,s.useSelect)((e=>{var t;const{getEditorSettings:o}=e(l.store);return null!==(t=o()?.allowedIframeStyleHandles)&&void 0!==t?t:[]}));return(0,i.useEffect)((()=>{if(!e.current)return;const{ownerDocument:t}=e.current;Array.from(document.styleSheets).filter((e=>{if(!(e?.ownerNode instanceof Element))return!1;const t=e.ownerNode.getAttribute("id"),o=t&&!r.includes(t);return(0,a.applyFilters)("woocommerce_email_editor_iframe_stylesheet_should_remove",o,e)})).map((e=>e.ownerNode.getAttribute("id"))).forEach((e=>{const o=t.getElementById(e);o&&o.remove();const n=t.createElement("style");n.id=e,t.head.appendChild(n)}))}),[r,t]),n};var Eo=o(46701);function To(){if(!window.WooCommerceEmailEditor)throw new Error("WooCommerceEmailEditor global object is not available. This is required for the email editor to work.");const e=window.WooCommerceEmailEditor.editor_settings,t=window.WooCommerceEmailEditor.editor_theme,o=window.WooCommerceEmailEditor.urls,n=window.WooCommerceEmailEditor.current_wp_user_email,r=window.WooCommerceEmailEditor.user_theme_post_id;if(!e)throw new Error("window.WooCommerceEmailEditor.editor_settings is required.");if(!t)throw new Error("window.WooCommerceEmailEditor.editor_theme is required.");if(!o||"string"!=typeof o.back||"string"!=typeof o.listings)throw new Error("window.WooCommerceEmailEditor.urls.back and .listings are required strings.");return{editorSettings:e,theme:t,urls:o,userEmail:n,globalStylesPostId:null!=r?r:null}}function Co({postId:e,postType:t,isPreview:o=!1,contentRef:n=null}){const[a,l]=(0,i.useState)(!1),{settings:d}=(0,s.useSelect)((e=>({settings:e(P.H).getInitialEditorSettings()})),[]);So(),jo();const{setEmailPost:p}=(0,s.useDispatch)(P.H);(0,i.useEffect)((()=>{p(e,t),l(!0)}),[e,t,p]);const u=ko(),_=(0,c.useMergeRefs)([u,n]);if(!a)return null;const g={...d,allowedBlockTypes:m(),isPreviewMode:o};return(0,r.jsx)(i.StrictMode,{children:(0,r.jsx)(to,{postId:e,postType:t,settings:g,contentRef:_})})}function Po(){ao(),uo(),(0,C.V1)()&&(_o=[{track:"header_preview_dropdown_preview_in_new_tab_selected",selector:".editor-preview-dropdown__button-external"},{track:()=>{const e=document.getElementsByClassName("is-collapsed editor-collapsible-block-toolbar").length;(0,C.yM)("header_blocks_tool_button_clicked",{isBlockToolsCollapsed:e})},selector:".editor-collapsible-block-toolbar__toggle"},{track:e=>{const t=e.classList.contains("is-opened");(0,C.yM)("header_more_menu_dropdown_toggle",{isOpened:t})},selector:`.components-dropdown-menu__toggle[aria-label="${(0,f.__)("Options")}"]`},{track:e=>{(e.textContent===(0,f.__)("Save")&&"false"===e.getAttribute("aria-disabled")||e.textContent===(0,f.__)("Saving…"))&&(0,C.yM)("header_save_button_clicked")},selector:".editor-post-publish-button"},{track:"header_save_email_button_clicked",selector:".editor-post-saved-state.is-saving"},{track:"inserter_sidebar_library_close_icon_clicked",selector:".block-editor-inserter__menu .block-editor-tabbed-sidebar__close-button"},{track:e=>{const t=e.classList.contains("is-opened");(0,C.yM)("header_preview_dropdown_clicked",{isOpened:t})},selector:".editor-preview-dropdown__toggle"},{track:()=>{(0,C.yM)("sidebar_tab_selected",{tab:"document"})},selector:'[data-tab-id="edit-post/document"]'},{track:()=>{(0,C.yM)("sidebar_tab_selected",{tab:"block"})},selector:'[data-tab-id="edit-post/block"]'},{track:e=>{const t=e.classList.contains("is-pressed");(0,C.yM)("header_inserter_sidebar_clicked",{isOpened:t})},selector:".editor-document-tools__inserter-toggle"},{track:e=>{const t=e.classList.contains("is-pressed");(0,C.yM)("header_listview_sidebar_clicked",{isOpened:t})},selector:".editor-document-tools__document-overview-toggle"},{track:e=>{(0,C.yM)("command_bar_command_clicked",{command:e.dataset?.value})},selector:'.commands-command-menu__container [role="option"]'}],document.addEventListener("click",go)),(0,oo.y$)(),fo(),(0,d.getBlockTypes)().forEach((e=>{ge(e.name)&&(0,_.G)(e.name,(e=>({...e,attributes:{...e.attributes,layout:{type:"object"}}})))})),(0,g.HY)("editor.BlockListBlock","woocommerce-email-editor/with-layout-styles",we),(0,g.HY)("editor.BlockEdit","woocommerce-email-editor/with-inspector-controls",fe),ce(),ro(),so()}function Mo(e){const t=document.getElementById(e);if(!t)return;const{current_post_id:o,current_post_type:n}=window.WooCommerceEmailEditor;if(null==o)throw new Error("current_post_id is required but not provided.");if(!n)throw new Error("current_post_type is required but not provided.");const l=(0,a.applyFilters)("woocommerce_email_editor_wrap_editor_component",Co);Po();const c=To();(0,s.dispatch)(P.H).setEditorConfig(c),(0,i.createRoot)(t).render((0,r.jsx)(l,{postId:o,postType:n}))}function No({postId:e,postType:t,isPreview:o=!1,contentRef:n=null,config:c}){const[d,m]=(0,i.useState)(!1);(0,i.useLayoutEffect)((()=>{const e=(0,s.select)(l.store).getEditorSettings();Po();const t=c||To();return(0,s.dispatch)(P.H).setEditorConfig(t),m(!0),()=>{try{(0,Eo.IF)()}finally{(0,s.dispatch)(l.store).updateEditorSettings(e)}}}),[c]);const p=(0,a.applyFilters)("woocommerce_email_editor_wrap_editor_component",Co);return d?(0,r.jsx)(p,{postId:e,postType:t,isPreview:o,contentRef:n}):null}var Io=o(89832);function Ho(e){"loading"===document.readyState?window.addEventListener("DOMContentLoaded",(()=>{Mo(e)}),{once:!0}):Mo(e)}(window.wc=window.wc||{}).emailEditor=n})();