@emailmaker/emailmaker 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/{emailmaker-core.b63d7b8b.js → emailmaker-core.a4e11bd0.js} +9 -9
  2. package/emailmaker-esm.js +11 -11
  3. package/{emailmaker-po.b63d7b8b.js → emailmaker-po.a4e11bd0.js} +1 -1
  4. package/emailmaker.js +6 -6
  5. package/iframe/.vite/manifest.json +4 -4
  6. package/iframe/{iframe-eblock.b63d7b8b.html → iframe-eblock.a4e11bd0.html} +2 -2
  7. package/iframe/{iframe.b63d7b8b.html → iframe.a4e11bd0.html} +2 -2
  8. package/iframe/js/{elMarkupHelper.C4wWAApZ.js → elMarkupHelper.Dc_IFMml.js} +3 -3
  9. package/iframe/js/{iframe-eblock.body.b63d7b8b.js → iframe-eblock.body.a4e11bd0.js} +1 -1
  10. package/iframe/js/iframe-eblock.js +2 -2
  11. package/iframe/js/{iframe.body.b63d7b8b.js → iframe.body.a4e11bd0.js} +1 -1
  12. package/iframe/js/iframe.js +2 -2
  13. package/package.json +1 -1
  14. package/runtime/react/index.js +1 -1
  15. package/static/core/{c266ad76.js → 0c2b284d.js} +1 -1
  16. package/static/core/{fa6f5198.js → 1708db7c.js} +1 -1
  17. package/static/core/{a9d62c49.js → 1c5fcd3e.js} +1 -1
  18. package/static/core/{40574d12.js → 1d705ef4.js} +1 -1
  19. package/static/core/{e2694475.js → 2f2b6a03.js} +2 -2
  20. package/static/core/{7a9faff8.js → 44ad0bec.js} +1 -1
  21. package/static/core/{66a5de32.js → 462ebf44.js} +1 -1
  22. package/static/core/{aea50cd5.js → 5b124cab.js} +1 -1
  23. package/static/core/{8fdd9471.js → 5c396b20.js} +1 -1
  24. package/static/core/{85accd9c.js → 64c240c3.js} +1 -1
  25. package/static/core/{d402573d.js → 6dfc3524.js} +1 -1
  26. package/static/core/{4fef179c.js → 762d0d48.js} +1 -1
  27. package/static/core/{9f6b8cdd.js → 76d1e927.js} +1 -1
  28. package/static/core/{5e13bbc1.js → 7c519fb4.js} +1 -1
  29. package/static/core/{69842511.js → 8608a2b9.js} +1 -1
  30. package/static/core/{cd715a88.js → 892bb74e.js} +1 -1
  31. package/static/core/{3a876cdd.js → 9c4c7364.js} +1 -1
  32. package/static/core/{86e5503b.js → a30b0fae.js} +1 -1
  33. package/static/core/{bb58b8a1.js → a4d994c7.js} +5 -5
  34. package/static/core/{e8edbf21.js → aa75c19b.js} +1 -1
  35. package/static/core/{f85176c7.js → b0c57adf.js} +1 -1
  36. package/static/core/{a6518f19.js → b9f59067.js} +1 -1
  37. package/static/core/{253d6f68.js → c16f27f8.js} +2 -2
  38. package/static/core/{4f63baad.js → cd998f60.js} +1 -1
  39. package/static/core/{d0d2525d.js → e123b734.js} +1 -1
  40. package/static/core/{6319e32c.js → e70683db.js} +1 -1
  41. package/static/core/{89fb48c9.js → ec552634.js} +1 -1
  42. package/static/umd-runtime/{runtime.9w1dxMVc.js → runtime.C95Dj7XR.js} +1 -1
  43. package/vendor/@emailmaker/ui-kit/package.json +1 -1
package/emailmaker-esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import{n as Ws,r as kc}from"./static/esm/971f1b2c.js";import{$ as xc,A as Mc,At as Or,B as Lc,Bt as mt,C as Qn,Ct as Nc,D as Fc,Dt as ft,E as xe,Et as Ie,F as Bc,Ft as _e,G as zs,Gt as ge,H as jc,Ht as Ce,I as Ks,It as uo,J as en,K as fo,L as Uc,Lt as En,M as po,Mt as Zn,N as Hc,Nt as $c,O as Vc,Ot as Ue,P as qc,Pt as Gc,Q as Wc,R as zc,Rt as ne,S as Kc,St as Yc,T as ho,Tt as qt,U as Ys,Ut as Xc,V as Mn,Vt as H,W as Jc,Wt as Qc,X as Zc,Y as ed,Z as Gt,_ as td,_t as mo,a as nd,at as Wt,b as go,bt as rd,c as Xs,ct as He,d as od,dt as ve,et as id,f as sd,ft as W,g as ad,gt as be,h as Ln,ht as vo,i as ld,it as cd,j as dd,jt as ud,k as ni,kt as fd,l as pd,lt as Js,m as hd,mt as Nn,n as md,nt as bo,o as gd,p as z,pt as Pe,q as vd,r as bd,rt as ri,s as _t,st as Qs,t as Te,tt as lt,u as yd,ut as Zs,vt as Me,w as Ed,wt as $,x as Fe,xt as oi,y as _d,yt as wd,z as Sd,zt as Id}from"./static/esm/74f083c2.js";import{t as Cd}from"./static/esm/f76c9d9d.js";(function(){"use strict";var e=window.__emailmaker__=window.__emailmaker__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var h=(function(){if(typeof document<"u"&&document.querySelector)try{var M=document.querySelector('script[src*="emailmaker-esm.js"]')||document.querySelector('script[src*="emailmaker.js"]');if(M&&M.src)return M.src.substring(0,M.src.lastIndexOf("/")+1)}catch{}try{var _=import.meta.url;if(_)return _.substring(0,_.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var f=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(f)||f.indexOf("//")===0)return f.charAt(f.length-1)==="/"?f:f+"/";var u=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",g=u?new URL(f,u).href:f;return g.charAt(g.length-1)==="/"?g:g+"/"}catch{var O=String(h);return O.charAt(O.length-1)==="/"?O:O+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var f=h==null?"":String(h);f||(f="./");try{var u=String(f);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0)return u.charAt(u.length-1)==="/"?u:u+"/";var g=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",O=g?new URL(u,g).href:u;return O.charAt(O.length-1)==="/"?O:O+"/"}catch{var M=String(f);return M.charAt(M.length-1)==="/"?M:M+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var f="";try{if(typeof window<"u"){for(var u in window)if(!(u==="__emailmaker__"||!/^__[^_].*__$/.test(u))){var g;try{g=window[u]}catch{continue}if(g&&typeof g=="object"&&g.publicPath){f=" Another product namespace ("+u+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function f(I){try{var F=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return F?new URL(String(I||""),F).href:String(I||"")}catch{return String(I||"")}}var u=String(h||"");if(!u)return"";if(/^(?:data:|blob:)/.test(u))return u;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0||u.charAt(0)==="/")return f(u);var g=u.replace(/^\.\/+/,"").replace(/^\/+/,""),O="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),M=O&&g.indexOf(O+"/")!==0?O+"/"+g:g,_=e.publicPath||"./";try{return new URL(M,_).href}catch{return _.slice(-1)!=="/"&&(_+="/"),f(_+M)}}),e.version||(e.version="1.3.2");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
1
+ import{n as zs,r as kc}from"./static/esm/971f1b2c.js";import{$ as xc,A as Mc,At as Or,B as Lc,Bt as mt,C as Qn,Ct as Nc,D as Fc,Dt as ft,E as xe,Et as Ie,F as Bc,Ft as _e,G as Ws,Gt as ge,H as jc,Ht as Ce,I as Ks,It as uo,J as en,K as fo,L as Uc,Lt as En,M as po,Mt as Zn,N as Hc,Nt as $c,O as Vc,Ot as Ue,P as qc,Pt as Gc,Q as zc,R as Wc,Rt as ne,S as Kc,St as Yc,T as ho,Tt as qt,U as Ys,Ut as Xc,V as Mn,Vt as H,W as Jc,Wt as Qc,X as Zc,Y as ed,Z as Gt,_ as td,_t as mo,a as nd,at as zt,b as go,bt as rd,c as Xs,ct as He,d as od,dt as ve,et as id,f as sd,ft as z,g as ad,gt as be,h as Ln,ht as vo,i as ld,it as cd,j as dd,jt as ud,k as ni,kt as fd,l as pd,lt as Js,m as hd,mt as Nn,n as md,nt as bo,o as gd,p as W,pt as Pe,q as vd,r as bd,rt as ri,s as _t,st as Qs,t as Te,tt as lt,u as yd,ut as Zs,vt as Me,w as Ed,wt as $,x as Fe,xt as oi,y as _d,yt as wd,z as Sd,zt as Id}from"./static/esm/74f083c2.js";import{t as Cd}from"./static/esm/f76c9d9d.js";(function(){"use strict";var e=window.__emailmaker__=window.__emailmaker__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var h=(function(){if(typeof document<"u"&&document.querySelector)try{var M=document.querySelector('script[src*="emailmaker-esm.js"]')||document.querySelector('script[src*="emailmaker.js"]');if(M&&M.src)return M.src.substring(0,M.src.lastIndexOf("/")+1)}catch{}try{var _=import.meta.url;if(_)return _.substring(0,_.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var f=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(f)||f.indexOf("//")===0)return f.charAt(f.length-1)==="/"?f:f+"/";var u=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",g=u?new URL(f,u).href:f;return g.charAt(g.length-1)==="/"?g:g+"/"}catch{var O=String(h);return O.charAt(O.length-1)==="/"?O:O+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var f=h==null?"":String(h);f||(f="./");try{var u=String(f);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0)return u.charAt(u.length-1)==="/"?u:u+"/";var g=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",O=g?new URL(u,g).href:u;return O.charAt(O.length-1)==="/"?O:O+"/"}catch{var M=String(f);return M.charAt(M.length-1)==="/"?M:M+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var f="";try{if(typeof window<"u"){for(var u in window)if(!(u==="__emailmaker__"||!/^__[^_].*__$/.test(u))){var g;try{g=window[u]}catch{continue}if(g&&typeof g=="object"&&g.publicPath){f=" Another product namespace ("+u+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function f(I){try{var F=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return F?new URL(String(I||""),F).href:String(I||"")}catch{return String(I||"")}}var u=String(h||"");if(!u)return"";if(/^(?:data:|blob:)/.test(u))return u;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0||u.charAt(0)==="/")return f(u);var g=u.replace(/^\.\/+/,"").replace(/^\/+/,""),O="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),M=O&&g.indexOf(O+"/")!==0?O+"/"+g:g,_=e.publicPath||"./";try{return new URL(M,_).href}catch{return _.slice(-1)!=="/"&&(_+="/"),f(_+M)}}),e.version||(e.version="1.3.3");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
2
2
  * Async AMD Loader (IIFE version for injection)
3
3
  *
4
4
  * This file is injected at the beginning of iframe entry points.
@@ -993,15 +993,15 @@ import{n as Ws,r as kc}from"./static/esm/971f1b2c.js";import{$ as xc,A as Mc,At
993
993
  __amdEnv.syncRequire = syncRequire;
994
994
  __amdEnv.diagnosticsBuffer = diagBuffer;
995
995
  })();
996
- `,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"emailmaker-core.b63d7b8b.js",po:"emailmaker-po.b63d7b8b.js",monaco:"static/monaco/index.CCINpETE.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var o=function(h){var f,u=function(){return f||(f=Promise.resolve().then(h))};return{then:function(g,O){return u().then(g,O)},catch:function(g){return u().catch(g)},finally:function(g){return u().finally(g)}}},i=o(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=o(function(){return i.then(function(h){return h.React})}),t.ReactDom=o(function(){return i.then(function(h){return h.ReactDom})}),t.ReactDomClient=o(function(){return i.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=o(function(){return i.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=o(function(){return i.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=o(function(){return i.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=o(function(){return i.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=o(function(){return i.then(function(h){return h.Classnames})}),t.Dayjs=o(function(){return i.then(function(h){return h.Dayjs})});var s=o(function(){return Promise.all([i]).then(function(h){var f=h[0]||Object.create(null),u=Object.create(null);for(var g in f)Object.prototype.hasOwnProperty.call(f,g)&&(u[g]=f[g]);for(var O in u)Object.prototype.hasOwnProperty.call(u,O)&&(t[O]=u[O]);return u})}),a={Uuid:"the shared `uuid` package was removed from the editor runtime; bundle `uuid` into the plugin or use `crypto.randomUUID()`"},l=["then","toString","valueOf","constructor","inspect","$$typeof"];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&t[c]===void 0&&(t[c]=(function(h,f){return new Proxy(Object.create(null),{get:function(u,g){if(!(typeof g=="symbol"||l.indexOf(g)!==-1))throw new Error("[shared-runtime] "+h+"."+String(g)+" is not available: "+f+".")}})})(c,a[c]));var d={},m={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKit:"[runtime] `@emailmaker/ui-kit` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKitIcons:"[runtime] `@emailmaker/ui-kit/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},b={Antd:"[runtime] `antd` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",AntDesignIcons:"[runtime] `@ant-design/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKit:"[runtime] `@emailmaker/ui-kit` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKitIcons:"[runtime] `@emailmaker/ui-kit/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version."},v=Object.create(null),w=function(h){for(var f=String(h&&h.stack||"").split(`
997
- `),u="",g=0;g<f.length;g+=1){var O=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(f[g]);if(O){if(!u){u=O[1];continue}if(O[1]!==u)return O[1]}}return""},C=function(h){var f=w(new Error(h)),u=f?h+" Requested by: "+f+".":h;return e.__compatMissingReason=u,u};if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var f in h)Object.prototype.hasOwnProperty.call(h,f)&&(v[f]=h[f])},e.__compatPending){for(var y=0;y<e.__compatPending.length;y+=1)e.registerCompat(e.__compatPending[y]);e.__compatPending=void 0}for(var S in m)Object.prototype.hasOwnProperty.call(m,S)&&(function(h,f,u){var g=!1,O=function(){if(!(h in v))throw new Error(C(f));return v[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var M=O();return g||(g=!0),M},set:function(M){v[h]=M}}),Object.defineProperty(d,h,{configurable:!0,enumerable:!0,get:O,set:function(M){v[h]=M}})})(S,m[S],b[S]);var A=t;for(var B in d)Object.prototype.hasOwnProperty.call(d,B)&&(A===t&&(A=Object.create(t)),Object.defineProperty(A,B,Object.getOwnPropertyDescriptor(d,B)));var k=s,P=[],T=function(){for(var h=[],f=0;f<P.length;f+=1)(function(u){var g=t[u];g&&typeof g.then=="function"&&h.push(Promise.resolve(g).then(function(O){t[u]=O}))})(P[f]);return Promise.all(h)},x=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(T).then(function(){if(typeof x=="function")return x.call(e)})},typeof e.define=="function"){let h=function(f){if(!f||typeof f!="object"&&typeof f!="function"||f.__esModule)return f;if(R){var u=R.get(f);if(u)return u}var g=Object.create(null);Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var O=Reflect.ownKeys(f),M=0;M<O.length;M++){var _=O[M];if(_!=="__esModule"){var I=Object.getOwnPropertyDescriptor(f,_);I&&Object.defineProperty(g,_,I)}}return Object.prototype.hasOwnProperty.call(g,"default")||Object.defineProperty(g,"default",{enumerable:!0,value:f,writable:!1}),R&&R.set(f,g),g};var R=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var f=A.React;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.React)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.React;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react",[],function(){var f=A.React;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.React)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.React;return h(g)})}),e.define("react-dom",[],function(){var f=A.ReactDom;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactDom)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactDom;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react-dom",[],function(){var f=A.ReactDom;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactDom)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactDom;return h(g)})}),e.define("react-dom/client",[],function(){var f=A.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactDomClient)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactDomClient;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react-dom/client",[],function(){var f=A.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactDomClient)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactDomClient;return h(g)})}),e.define("react/jsx-runtime",[],function(){var f=A.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactJsxRuntime)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactJsxRuntime;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-runtime",[],function(){var f=A.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactJsxRuntime)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactJsxRuntime;return h(g)})}),e.define("react/jsx-dev-runtime",[],function(){var f=A.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactJsxDevRuntime)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactJsxDevRuntime;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-dev-runtime",[],function(){var f=A.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactJsxDevRuntime)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactJsxDevRuntime;return h(g)})}),e.define("antd",[],function(){var f=A.Antd;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Antd)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Antd;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/antd",[],function(){var f=A.Antd;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Antd)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Antd;return h(g)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var f=A.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignIconBase)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignIconBase;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var f=A.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignIconBase)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignIconBase;return h(g)})}),e.define("@ant-design/icons",[],function(){var f=A.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignIcons)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignIcons;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons",[],function(){var f=A.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignIcons)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignIcons;return h(g)})}),e.define("@ant-design/cssinjs",[],function(){var f=A.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignCssinjs)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignCssinjs;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/cssinjs",[],function(){var f=A.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignCssinjs)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignCssinjs;return h(g)})}),e.define("classnames",[],function(){var f=A.Classnames;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Classnames)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Classnames;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/classnames",[],function(){var f=A.Classnames;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Classnames)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Classnames;return h(g)})}),e.define("dayjs",[],function(){var f=A.Dayjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Dayjs)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Dayjs;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/dayjs",[],function(){var f=A.Dayjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Dayjs)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Dayjs;return h(g)})}),e.define("@emailmaker/ui-kit",[],function(){var f=A.UiKit;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.UiKit)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.UiKit;return h(g)})}),e.define("@emailmaker/emailmaker/ui-kit",[],function(){var f=A.UiKit;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.UiKit)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.UiKit;return h(g)})}),e.define("@emailmaker/emailmaker/ui-kit/icons",[],function(){var f=A.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.UiKitIcons)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.UiKitIcons;return h(g)})}),e.define("@emailmaker/ui-kit/icons",[],function(){var f=A.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.UiKitIcons)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.UiKitIcons;return h(g)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Td=new Function("url","return import(url)");function Ad(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function yo(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function ea(e){return e.type==="umd"||e.resolve==="registry"}var Rd="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function Pd(e){const t=Array.isArray(e)?e[0]:e;return yo(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Od(e,t){const n=Pd(e),r=yo(e)?e:void 0,o=t instanceof Error?t.message:String(t),i=r&&ea(r)&&!/compat/iu.test(o)?` ${Rd}`:"",s=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${i}`);return s.cause=t,{name:n,url:r?.url,error:s}}function Dd(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var kd=class{_context;_pluginRegistry;_options;_map=new Map;_optionsMap=new Map;_readyMap=new Map;_resolveMap=new Map;_initializingPlugins=new Map;_creatingPlugins=new Set;_initializedPlugins=new Set;_creationOrder=[];_lifecycleListeners=new Set;_activated=!1;constructor(e,t,n={}){this._context=e,this._pluginRegistry=t,this._options=n}activate(){return this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}activateSync(){this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}onLifecycle(e){return this._lifecycleListeners.add(e),{dispose:()=>this._lifecycleListeners.delete(e)}}_emitLifecycle(e){for(const t of Array.from(this._lifecycleListeners))try{t(e)}catch{}}async _resolveEntry(e){if(typeof e=="string"||typeof e=="symbol"){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);return{ctor:t}}if(typeof e=="function")return e.length===0?{ctor:await e()}:{ctor:e};if(Array.isArray(e)){const[t,n]=e;if(typeof t=="function")return{ctor:t,options:n};const r=await this._pluginRegistry.getAsync(t);if(!r)throw new Error(`Plugin "${String(t)}" not registered.`);return{ctor:r,options:n}}if(yo(e))return this._resolveDescriptor(e);throw new Error(`Unknown plugin entry format: ${JSON.stringify(e)}`)}async _resolveDescriptor(e){const t=e.resolve??(e.type==="umd"?"window":"module");if(ea(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Td(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let o;const i=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):Dd(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},s=()=>window.removeEventListener("error",i);window.addEventListener("error",i),r.onload=()=>{if(s(),o){n(o);return}t()},r.onerror=()=>{s(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const o=await this._resolveOrSkip(r);if(!o)continue;const i=this._createOrSkip(o.ctor,o.options);i&&!n.has(i)&&(n.add(i),t.push(i))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveOrSkip(s);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const c=this._creationOrder.indexOf(l);c>=0&&this._creationOrder.splice(c,1)}const o=[],i=new Set;for(const{ctor:s,options:a}of n){const l=this._createOrSkip(s,a);l&&!i.has(l)&&(i.add(l),o.push(l))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let i,s=!1;const a=()=>{s||(s=!0,i&&clearTimeout(i),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(i=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),o(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),o=this._createPluginInstance(e,r),i=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:i}),o.required?.(),this._map.set(n,o),this._creationOrder.push(o),this._setupReadyPromise(o)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Od(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return Ad(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const o of t){if(this._initializedPlugins.has(o))continue;const i=this._initializingPlugins.get(o);if(i){n.add(i);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const i of r)this._initializingPlugins.set(i,o);n.add(o),o.finally(()=>{for(const i of r)this._initializingPlugins.get(i)===o&&this._initializingPlugins.delete(i)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const o=this._options.openEarlyWindow?.();try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}finally{o?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(o){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:o})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},xd=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const o of n)try{o.callback(t)}catch{}const r=n.filter(o=>!o.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(o=>(t.ctor=o,t.loading=void 0,this._notifyListeners(e,o),o));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!1};return r.push(o),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!0};return r.push(o),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(o=>o.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Md=class{resolveRegistry;constructor(e){this.resolveRegistry=e}target(){return this.resolveRegistry()}get(e){return this.target().get(e)}getAsync(e){return this.target().getAsync(e)}add(e,t){return this.target().add(e,t)}addAll(e){return this.target().addAll(e)}addAsync(e,t){return this.target().addAsync(e,t)}has(e){return this.target().has(e)}isLoaded(e){return this.target().isLoaded(e)}override(e,t){return this.target().override(e,t)}on(e,t){return this.target().on(e,t)}once(e,t){return this.target().once(e,t)}off(e,t){return this.target().off(e,t)}keys(){return this.target().keys()}forContext(){return this.target().forContext()}},ii=class{capacity;items=[];constructor(e){this.capacity=e}push(e){this.items.length>=this.capacity&&this.items.shift(),this.items.push(e)}snapshot(){return this.items.slice()}size(){return this.items.length}clear(){this.items=[]}};function Ld(e,t){return t+e}function Nd(){return typeof performance>"u"?Date.now():Ld(performance.now(),performance.timeOrigin)}var Fd="emailmaker:diagnostics",Bd="diagnostics",jd="diagnostics";function si(e,t){return t?`${e}${e.includes("?")?"&":"?"}${jd}=1`:e}var er;function Ud(){try{const e=new URLSearchParams(window.location.search).get(Bd);return e===null?void 0:e!=="0"}catch{return}}function Hd(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function $d(){try{const e=window.localStorage.getItem(Fd);return e===null?void 0:e==="1"}catch{return}}function Ft(){return er===void 0&&(er=typeof window>"u"?!1:Ud()??Hd()??$d()??!1),er}function Vd(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var me={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},qw=Object.values(me),Gw=[me.canvasPainted,me.canvasSettled,me.appVisible,me.editorVisible],qd=5e3,Gd=3e3,ai="diagnosticsStore",tn,St;function li(){return{marks:new ii(qd),resources:new ii(Gd)}}function ta(){if(St)return St;const e=Eo();return e?(St=e[ai]??tn??li(),e[ai]=St,tn=void 0,St):(tn??=li(),tn)}function ie(e,t){Ft()&&ta().marks.push({phase:e,at:Nd(),...t})}function Eo(){if(typeof window.__emailmaker__<"u"&&window.__emailmaker__)return window.__emailmaker__;if(typeof window>"u")return;const e=window[Vd()];return e!==null&&typeof e=="object"?e:void 0}function Wd(e){const t=e.length,n=ta();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function zd(){const e=Eo();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Wd(e.diagnosticsBuffer)}var Kd="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function je(){const e=new Error(Kd);return e.name="DestroyedInstanceError",e}function Yd(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Dr(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const i=e,s=t;return i.length===s.length&&i.every((a,l)=>Dr(a,s[l]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Dr(e[i],t[i]))}function na(e,t){const n={watch(r){let o,i=!1;return e.watch(s=>{const a=t(s);i&&Dr(o,a)||(o=a,i=!0,r(a))})},select(r){return na(n,r)}};return n}function Ee(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(i){t=i,n=!0;for(const s of Array.from(r))s(i)},watch(i){return r.add(i),n&&i(t),{dispose:()=>r.delete(i)}},select(i){return na(o,i)}};return o}var Xd=class{http;constructor(e){this.http=e}app_init_create=(e,t={})=>this.http.request({path:"/app/v1/app_init",method:"POST",body:e,type:Jc.UrlEncoded,...t})},ra=class{http;constructor(e){this.http=e}get_translations2=({file:e,...t},n={})=>this.http.request({path:`/translations/v1/${e}`,method:"GET",...n});get_translations3=({id:e,file:t,...n},r={})=>this.http.request({path:`/translations/v1/${t}/${e}`,method:"GET",...r})};function Jd(e){return String(e||"").trim()||void 0}var Qd=class extends ge{deps;_app;_baseUrl;_appInit;_restBaseUrl;_prevApp;constructor(e){super(),this.deps=e,this.addDisposable(e.options.select(t=>this._slice(t)).watch(t=>this._start(t)))}get app(){return this._app}_slice(e){return Object.prototype.hasOwnProperty.call(e,"baseUrl")&&(this._baseUrl=Jd(e.baseUrl)),Object.prototype.hasOwnProperty.call(e,"appInit")&&(this._appInit=e.appInit),{appInit:this._appInit,user:e.user,project:e.project,baseUrl:this._baseUrl,restBaseUrl:this.deps.resolveRestBaseUrl(this._baseUrl),standalone:this.deps.isStandalone()}}_start(e){if(this._restBaseUrl!==e.restBaseUrl&&(this._restBaseUrl=e.restBaseUrl,this.deps.setRestBaseUrl(e.restBaseUrl)),e.standalone)return;const t=e.appInit||this.deps.fallbackAppInit,n=Promise.resolve(t({baseUrl:e.baseUrl,user:e.user,project:e.project,prevApp:this._prevApp}));this._app=n,n.then(r=>{this._app===n&&(this._prevApp=r)},()=>{}),this.deps.publish(n)}},_o=H("AppInitService");function Zd(e){return async()=>{const t=await e();return(await new Xd(t).app_init_create({})).data}}function eu(e){e.injectFactory(_o,(t,n)=>{if(n)return n;const r=new Qd({options:e.getInstance(be),isStandalone:()=>!!e.getInstance(Me),resolveRestBaseUrl:o=>o?ni(o):ni()||void 0,setRestBaseUrl:o=>{e.getInstance(Fc)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:Zd(()=>e.getInstanceAsync(jc)),publish:o=>{e.inject(He,o)}});return e.getInstance(W)?.addDisposable(r),r},!0)}var wo=H("documentSession.emailDocuments");function ct(e){return e?.getInstance(wo)}var tu=H("RevisionServiceFlag");function oa(e){return e.getOrCreateInstance(tu,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function ia(e){return oa(e).isEnabled()}var nu=H("EmailRightsResolver");function ru(e,t){const n=e.getInstance(nu);return n?n(t):!0}var So={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},sa=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],aa=2e4,ou=sa.reduce((e,t)=>e+So[t],0),la=aa+ou+3e3;function iu(e){return sa.reduce((t,n)=>t+ca(n,e),0)}function ca(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:So[e]}function da(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:la}function ua(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:aa}function zt(e=la){return e+3e3}function fa(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var su=()=>zt();function au(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function lu(e){return t=>au(e.getOrCreateInstance($.BEFORE_SAVE_EMAIL,()=>new Ue).fire(t),su())}var et=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},pa=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[emailmaker] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Fn=class extends Error{timeoutMs;constructor(e,t="handleSaveEmail",n="email"){super(`[emailmaker] ${t} did not respond within ${e}ms — the ${n} was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function fe(e){return e.getOrCreateInstance(Gt,()=>new Wt)}var ha=new WeakMap,kr=new WeakMap;function we(e){return ha.get(e)??0}function _n(e,t){let n=kr.get(e);return n||(n=new Set,kr.set(e,n)),n.add(t),()=>{n?.delete(t)}}function cu(e){ha.set(e,we(e)+1),kr.get(e)?.forEach(t=>t())}function xr(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var du=H("documentSession.canvasReceipts");function uu(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const o={guid:n,version:r};return e=o,()=>{e===o&&(e=void 0)}},note(n,r){const o=xr(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(o,n)}},read(n){if(!e)return;const{scope:r}=t,o={guid:e.guid,rev:e.version()};return r.originId!==null?{...o,changeId:t.changeId,originId:r.originId}:{...o,changeId:r.generation===n?t.changeId:0}}}}function ma(e){return e.getOrCreateInstance(du,uu)}var fu=2e3,pu=yd+od+fu;function hu(e,t=pu){return async()=>{const n=fe(e);let r;const o=new Promise(i=>{r=setTimeout(()=>i("silent"),t)});try{const i=ma(e).read(we(n)),s=await Promise.race([n.sendAsync(z.SANDBOX_CANVAS_SYNCED,i?{applied:i}:void 0,!1),o]);if(s==="silent"||s&&!s.synced)throw s==="silent"||s?.unsent,new et("canvas-not-synced")}finally{clearTimeout(r)}}}var mu="em_autosave_pending";function wn(e){return`${mu}_${e}`}function Mr(e,t){try{return sessionStorage.setItem(wn(e),JSON.stringify(t)),!0}catch{return!1}}function Bn(e){try{const t=sessionStorage.getItem(wn(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(wn(e)),null):n}catch{return null}}function Ye(e){try{sessionStorage.removeItem(wn(e))}catch{}}function Io(e){return`block:${e}`}function ga(e,t){return t?Io(e):e}function Co(e,t){(Bn(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&Ye(e)}function gu(e){return e!=null&&e!==""}function va(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var ci;function vu(){return va(Ln.em_revisions_v2)??!0}function bu(){return ci??=vu(),ci}function wt(e){return ia(e)&&bu()}function yu(){return!1}var ba;function Bt(e,t){return ba?.capture(e,t)}function Eu(e,t){return ba?.captureMessage(e,t)}var _u=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],wu=200;function ya(e=new Set){const t=new Set;return(n,r)=>{if(!_u.some(([i,s])=>!e.has(i)&&s.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=wu&&t.clear(),t.add(o))}}function Ea(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:ya()}}var Su=Ea();function Ve(e){return e?.getInstance(fo)??Su}function Iu(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function nn(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Re=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${nn(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${nn(this.oldText)}")`:`(replace@${this.oldPosition} "${nn(this.oldText)}" with "${nn(this.newText)}")`}};function di(e,t){return e===null||e.length===0?t:new Cu(e,t).compress()}var Cu=class De{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[l,c]=De._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(l),o=c;continue}if(r.newPosition<o.oldPosition){const[l,c]=De._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(l),r=c;continue}let s,a;if(o.oldEnd===r.newEnd)s=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[l,c]=De._splitPrev(r,o.oldLength);s=l,a=o,r=c,o=this._getCurr(++n)}else{const[l,c]=De._splitCurr(o,r.newLength);s=r,a=l,r=this._getPrev(++t),o=c}this._result[this._resultLen++]=new Re(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const i=De._merge(this._result);return De._removeNoOps(i)}_acceptCurr(t){this._result[this._resultLen++]=De._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=De._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new Re(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Re(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),o=t.newText.substr(n);return[new Re(t.oldPosition,t.oldText,t.newPosition,r),new Re(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new Re(t.oldPosition,r,t.newPosition,t.newText),new Re(t.oldPosition+n,o,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,o=t[0];for(let i=1;i<t.length;i++){const s=t[i];o.oldEnd===s.oldPosition?o=new Re(o.oldPosition,o.oldText+s.oldText,o.newPosition,o.newText+s.newText):(n[r++]=o,o=s)}return n[r++]=o,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let o=0;o<t.length;o++){const i=t[o];i.oldText!==i.newText&&(n[r++]=i)}return n}};function Tu(e){return new Re(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Au(e){return e.map(Tu)}function ui(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Ru(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const o=t[r];n=n.slice(0,o.oldPosition)+o.newText+n.slice(o.oldEnd)}return n}function Pu(e,t,n){let r=0;const o=e.start===e.end;for(const i of t){const s=i.newLength-i.oldLength;if(i.oldLength===0){const a=i.oldPosition;if(o&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(o){if(e.start>=i.oldEnd)r+=s;else if(e.start>i.oldPosition)return null;continue}if(e.start>=i.oldEnd)r+=s;else if(e.end>i.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var tt=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},fi=0,Ou=Math.random().toString(36).slice(2,8);function Du(){return fi+=1,`doc-${Ou}-${fi}`}function ku(e){const t=e.createBuffer(),n=e.docId??Du();let r=e.serverId??null,o=0,i=null,s=e.attributes??{};const a=new Set;let l=!1,c=!1,d;const m=new Set;let b=null;const v=()=>(b?.version!==o&&(b={version:o,value:t.read()}),b.value),w=C=>Object.entries(C).some(([y,S])=>s[y]!==S);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:i,attributes:s}),getContent:v,mutate(C,{source:y}){if(l)return o;const S=C.changes?.length?C.changes:void 0,A=S?Ru(v(),S):C.content!==void 0?C.content:void 0,B=A!==void 0&&A!==v(),k=C.attributes!==void 0&&w(C.attributes);if(!B&&!k)return o;const P=!(o>(i??-1)),T=k?Object.keys(C.attributes).filter(R=>s[R]!==C.attributes[R]):[];B&&t.write(A),k&&(s={...s,...C.attributes}),o+=1,y!=="user"&&P&&(i=o);const x={source:y,version:o,changes:S,...B?{content:!0}:{},...T.length>0?{attributes:T}:{}};return a.forEach(R=>R(x)),o},markSaved(C,y){const S={serverId:r,savedVersion:i};y!==void 0&&(r=y),(i===null||C>i)&&(i=C),(S.serverId!==r||S.savedVersion!==i)&&a.forEach(A=>A({source:"system",version:o}))},markUnsaved(){l||i===null||i<o||(i=o-1,a.forEach(C=>C({source:"system",version:o})))},markReady(){c||d!==void 0||(c=!0,m.forEach(C=>C.resolve()),m.clear(),a.forEach(C=>C({source:"system",version:o})))},isReady:()=>c,markFailed(C){c||d!==void 0||l||(d=C,m.forEach(y=>y.reject(new tt(C))),m.clear(),a.forEach(y=>y({source:"system",version:o})))},failure:()=>d,whenReady(){return c?Promise.resolve():d!==void 0?Promise.reject(new tt(d)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((C,y)=>{m.add({resolve:C,reject:y})})},subscribe(C){return a.add(C),()=>a.delete(C)},isNew:()=>r===null,isDirty:()=>o>(i??-1),isDisposed:()=>l,dispose(){l=!0,m.forEach(C=>C.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),m.clear(),a.clear(),t.dispose()}}}var xu=500,Mu=100,tr=0;function pi(e,t){let n=0;for(const r of t){if(r.oldPosition>e||r.oldPosition===e&&r.oldLength>0)break;if(r.oldEnd>e)return r.newEnd;n=r.newEnd-r.oldEnd}return e+n}function Lu(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function Nu(e,t){const n=e?.after;return n?{...e,after:{start:pi(n.start,t),end:pi(n.end,t)}}:e}function Fu(e,t={}){const n=t.groupIntervalMs??xu,r=t.maxSteps??Mu,o=t.now??(()=>0);let i=[],s=0,a=tr+=1,l=null,c,d,m,b=!1,v=!1,w=!1,C=!1;const y=new Set,S=()=>y.forEach(u=>u()),A=(u,g)=>{if(u.length){w=!0;try{e.mutate({changes:u},{source:g})}finally{w=!1}}},B=u=>A(u,"user"),k=u=>{const g=c?.from??o();if(v&&l!==null&&b===(c!==void 0)&&g>=l&&g-l<n){const O=i[s-1];i[s-1]={changes:di(O.changes,u),selection:Lu(O.selection,d)}}else i=i.slice(0,s),i.push({changes:u,selection:d}),s=i.length,v=!0,i.length>r&&(i=i.slice(i.length-r),s=i.length,a=tr+=1);l=c?.to??g,b=c!==void 0,S()},P=()=>{v=!1,l=null},T=u=>{if(!u.length)return;const g=i.length>s;if(g&&(i=i.slice(0,s)),s>0){const O=i[s-1];i[s-1]={changes:di(O.changes,u),selection:Nu(O.selection,u)}}P(),g&&S()},x=e.subscribe(({source:u,changes:g})=>{if(!(C||w||!g?.length)){if(u==="remote"){R();return}if(u!=="user"){T(g);return}k(g)}}),R=()=>{i=[],s=0,P(),a=tr+=1,S()},h=(u,g)=>{m=g;try{B(u)}finally{m=void 0}},f=(u=!1)=>{if(s===0)return!1;const g=i[s-1],O=Au(g.changes);return ui(e.getContent(),O)?(h(O,u?{kind:"undo",selection:g.selection?.before}:void 0),s-=1,P(),!0):(i=i.slice(0,s-1),s=i.length,P(),S(),!1)};return{recordAt(u,g,O){const M=c,_=d;c=u,d=O;try{return g()}finally{c=M,d=_}},activeMove:()=>m,canUndo:()=>s>0,canRedo:()=>s<i.length,undo(){f(!0)&&S(),P()},redo(){if(s>=i.length){P();return}const u=i[s];if(!ui(e.getContent(),u.changes)){i=i.slice(0,s),P(),S();return}h(u.changes,{kind:"redo",selection:u.selection?.after}),s+=1,P(),S()},clear:R,closeGroup:P,applyWithoutHistory(u){const g=e.get().version;if(A(u,"system"),e.get().version===g){P();return}T(u)},getPast:u=>i.slice(0,s).reverse().slice(0,u).map(g=>g.changes),getFuture:u=>i.slice(s).reverse().slice(0,u).map(g=>g.changes),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(u){if(u.stackId!==a||u.index>s)return!1;for(;s>u.index;)if(!f())return S(),!1;return S(),!0},subscribe(u){return y.add(u),()=>y.delete(u)},dispose(){C=!0,x(),y.clear(),i=[],s=0}}}var Bu=["edit","move","resize","insert"];function nr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ju(e){return typeof e=="string"?e:null}function Uu(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Hu(e){return Bu.includes(e)?e:null}function $u(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:ju(t.originId),changeId:nr(t.changeId),rev:nr(t.rev),baseRev:nr(t.baseRev),expected:Uu(t.expected),intent:Hu(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var hi=new WeakMap,_a=new WeakMap;function Vu(e,t){_a.set(e,t)}function qu(e,t){const n=(hi.get(e)??Promise.resolve()).then(t,t);return hi.set(e,n.catch(()=>{})),n}function Gu(e,t){return _a.get(e)?.(t)??qu(e,t)}var It=new Map,mi=new Map;function Wu(e){return It.set(e,(It.get(e)??0)+1),()=>{const t=(It.get(e)??1)-1;if(t>0){It.set(e,t);return}It.delete(e);const n=mi.get(e);mi.delete(e),n?.forEach(r=>r())}}var To=e=>e.replace(/\r\n?/g,`
998
- `),zu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function Lr(e){return typeof e=="string"&&zu.test(e)}var Ku=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function Yu(){return typeof navigator<"u"&&navigator.onLine===!1}function Xu(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const o=r.data;typeof r.data=="object"&&o.error!=null&&t.push(o.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function wa(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return wa(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function Ju(e){return Yu()?!0:Xu(e).some(wa)}var Sa=new WeakSet,Ia=new WeakMap;function Ca(e){typeof e=="object"&&e!==null&&Sa.add(e)}function Qu(e,t){typeof e=="object"&&e!==null&&Ia.set(e,t)}function Zu(e){return typeof e=="object"&&e!==null?Ia.get(e):void 0}function ef(e){return e instanceof Fn||e instanceof pa||typeof e=="object"&&e!==null&&Sa.has(e)}function tf(e){return e instanceof et||Ta(e)||e instanceof Ku||ef(e)}function Ta(e){return Ao(e)?.v2Error?.data?.code==="blocks.block_locked"}function gi(e){return Ao(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function Ao(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function nf(e){if(e instanceof et)return e.reason==="canvas-not-synced";if(tf(e))return!1;const t=Ao(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?gi(e):!0}return Ju(e)||gi(e)}var Aa="draft";function st(e){return e==null||e===""?Aa:String(e)}function Sn(e){return e==null||e===""?`${Nr}${Aa}`:`${Nr}${String(e)}`}var Nr="block:";function oe(e){return e?.startsWith(Nr)===!0}function dt(e){return oe(e.sessionKey())?void 0:e.current()}function Je(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return ie(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(ie(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const i=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw uo(o)?(`${e}`,{...n}):(`${e}`,{error:fa(o),...n},void 0),o})}var rf=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function of(e){const t=e?.trim()??"";if(!rf.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function kt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Ro(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function sf(e,t={}){const n=kt((e??[]).filter(r=>r?.html?.trim()));return Ro(n,t)?n:null}function af(e,t){const n=Date.parse(kt(e)?.modified??""),r=sf(e),o=Date.parse(r?.modified??""),i=t===void 0||Number.isFinite(o)&&o>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:i?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function vi(e,t,n){const r=kt((e??[]).filter(l=>l?.html?.trim())),o=Date.parse(r?.modified??""),i=Date.parse(kt((n??[]).filter(l=>l?.html?.trim()))?.modified??""),s=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(i>o),a=[Date.parse(kt(e??[])?.modified??""),t??NaN].filter(l=>Number.isFinite(l));return{autosave:s&&Ro(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function lf({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var bi=["recovery","plugin","rest"],cf=["subject","preheader"];function df(e){let t={},n;for(let o=bi.length-1;o>=0;o--){const i=e.get(bi[o]);i&&(i.attributes&&(t={...t,...i.attributes}),i.content!==void 0&&(n=i.content))}const r=e.get("plugin")?.attributes;for(const o of cf){const i=r?.[o];typeof i=="string"&&i!==""&&(t={...t,[o]:i})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function In(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?To(t.content):void 0,o=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...o?{changes:[new Re(0,n,0,r)]}:{}},{source:"remote"})}var rr=e=>typeof e=="string"?e.trim():"";function uf(e,t,n,r){const{version:o,attributes:i}=e.get(),s=i,a=r==="snapshot"||r==="anchor",l=a?s.author:void 0,c=a?s.date_gmt:void 0,d=rr(s.title)||rr(s.subject)||rr(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:d,subject:s.subject,preheader:s.preheader,description:s.description,common_styles:s.common_styles||"",meta:s.meta,utm_parameters:s.utm_parameters,parent_email:s.parent_email,is_template:s.is_template||!1,is_inited:s.is_inited,tags:s.tags,emailtags:s.emailtags,group:s.group,projectCategories:s.projectCategories,renderGuid:e.get().docId,project:t.project??s.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...l!=null&&l!==""?{author:l}:{},...c?{excerpt:c}:{}}}}var ff=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function pf(e){const t={};for(const n of ff)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function hf(e,t,n,r,o,i){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(o);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,o):t.saveAutosave(r,o,i==null?void 0:{wpId:i})}function Le(e,t=!1){const n={};for(const r of Object.keys(e)){let o=e[r];o!==void 0&&!(typeof o=="number"&&Number.isNaN(o))&&(t&&typeof o=="object"&&o!==null&&(o=Le(o)),n[r]=o)}return n}function mf(e){return typeof e=="string"&&e.includes("autosave")}var gf=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Ra(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!gf.has(t))):{}}function gt(e,t,n={}){e&&e.mutate({attributes:vf(e.get().attributes,t)},{source:n.source??"user"})}function vf(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Po(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function bf(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Pa(e){if(!e)return null;const t=Ra(e);return e.common_styles!==void 0&&(t.common_styles=bf(e.common_styles)),Po(e.html,t)}function Oa(e){return e?Po(e.html,Le(Ra(e))):null}var yf=["common_styles","subject","preheader","meta"];function yi(e){if(!e?.html?.trim())return null;const t={};for(const n of yf)Ef(n,e[n])&&(t[n]=e[n]);return Po(e.html,t)}function Ef(e,t){return e==="common_styles"?typeof t=="string"&&t.startsWith("{"):e==="meta"?typeof t=="object"&&t!==null&&!Array.isArray(t):typeof t=="string"}var _f=["modified","lock","wpId","secretHash"];function Ei(e){if(!e)return null;const t={};for(const n of _f)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var wf=10,Sf=(e,t)=>e.key===t.key&&If(e.serverId,t.serverId),If=(e,t)=>e==null||e===t;function Cf(e){return typeof e?.then=="function"}var _i=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Da=e=>{e.request.serverId!=null&&!jn(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},Tf=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),jn=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),wi=(e,t)=>t?.content!==void 0&&lf({hasUnsavedUserEdit:jn(e)})==="skip",Si=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},Af=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),Rf=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent(),e.userTouched.clear(),e.document.get().docId))},Pf=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,i])=>e.attributes[o]!==i)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Of=e=>{const t=df(e.reports),n=Pf(e.lastMerged,t);e.lastMerged=t,e.broughtContent=Un(t.content)??e.broughtContent,n&&(In(e.document,n),Da(e))},or=(e,t)=>{if(!e.ready&&!jn(e)){Of(e);return}e.broughtContent=Un(t?.content)??e.broughtContent,In(e.document,t)},Un=e=>e===void 0?void 0:To(e),Df=(e,t)=>t.content===void 0||Un(t.content)!==e.broughtContent||!jn(e)?t:{...t,content:void 0},kf=e=>{const{attributes:t,serverId:n,docId:r}=e.document.get();return{...t,html:e.document.getContent(),id:n??void 0,isNew:n==null,renderGuid:r}};function xf(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:i,canEdit:s,notifyBeforeSave:a,awaitCanvasSynced:l,savedEchoForm:c=p=>p,queuesOutsideWrites:d,onAdapterError:m,onTimeout:b}=e;let v,w;const C=new Set,y=new Set,S=()=>C.forEach(p=>p()),A=(p,E)=>{if(!(p.closed||p.ready)){if(p.error!==void 0){p.document.markFailed(p.error),p.document.get().docId;return}Da(p),p.ready=!0,p.document.markReady(),p.document.get().docId,[...p.reports.keys()]}},B=(p,E,D)=>{m?.(E.id,D),!(!E.required||p.closed)&&(p.error=D,p.document.get().docId,E.id,S())},k=(p,E)=>{const D=new Set(E.map(q=>q.id));E.forEach(q=>{q.watch&&p.watchers.push(q.watch(G=>p.closed?!1:p.ready&&(wi(p,G)||p.contentShown===!0&&G?.content!==void 0)?(p.document.get().docId,q.id,!1):(G&&p.reports.set(q.id,G),or(p,G),G?.content!==void 0&&(p.showFill=void 0),!0)))});const N=(q,G)=>{if(!p.closed){if(!q.required&&wi(p,G)){p.document.get().docId,q.id,q.loaded?.(!1);return}G&&(p.reports.set(q.id,G),q.id==="plugin"&&Si(p,G)),or(p,G),q.loaded?.(G!==null)}},U=()=>{D.size>0||p.closed||(_i(p),A(p,[]))},Y=[];if(E.forEach(q=>{let G;try{G=q.load()}catch(ee){B(p,q,ee),D.delete(q.id);return}if(Cf(G)){Y.push({id:q.id,required:q.required,load:()=>G,...q.loaded?{loaded:ee=>q.loaded?.(ee)}:{}});return}N(q,G),D.delete(q.id)}),Y.length===0){U();return}p.timer=setTimeout(()=>{p.timer=void 0,b?.([...D]),p.document.get().docId,[...D],A(p,[...D])},n),p.timer.unref?.(),Y.forEach(q=>{q.load().then(G=>N(q,G)).catch(G=>{B(p,q,G)}).finally(()=>{D.delete(q.id),U()})})},P=async(p,E,D)=>{if(D==="snapshot"||D==="anchor")return;const N=i?.();if(N)return N.resolve({project:E.project??p.project,tags:(p.tags??[]).map(U=>({name:U}))})},T=p=>{if(p.lock===!0&&s?.(p)===!1)return new et("locked");const E=p.tags?.length??0,D=p.emailtags?.length??0;if(Math.max(E,D)>wf)return new et("too-many-tags")},x=(p,E)=>{const D=p.document.get().serverId;D!=null&&(p.createKey=void 0),!(E||D==null)&&(p.recoveryFacts={emailId:D,historyLoaded:!0,isRecovering:!1},oe(p.request.key)||(p.request={...p.request,key:st(D),serverId:D}))},R=(p,E,D)=>{if(p.closed||D?.id==null)return;const N=p.document.get().serverId,U=N!=null;U&&N!==String(D.id)||(p.document.markSaved(E,String(D.id)),x(p,U),p.document.get().serverId,S())},h=(p,E,D)=>{if(!(E==="materialize"||E==="publish"&&p.document.get().serverId==null))return D;const N=p.createKey,U=N&&N.project===D.project?N:{key:Ce(),project:D.project};return p.createKey=U,{...D,idempotencyKey:U.key}},f=async(p,E,D)=>{try{await p.document.whenReady()}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,!1}if(p.closed)return!1;const N=T(p.document.get().attributes);if(N)return p.saveError=N,p.saveFailures+=1,p.failedIntent=E,N.reason,S(),!1;if(a&&(await a(kf(p)).catch(()=>{}),p.closed))return!1;if(l){try{await l()}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}if(p.closed)return!1}if(Tf(p))return E==="snapshot"||(p.saveError=new et("empty-content"),p.saveFailures+=1,p.failedIntent=E,S()),!1;let U;try{U=await P(p.document.get().attributes,D,E)}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}if(p.closed)return!1;const{payload:Y,version:q}=uf(p.document,D,U,E),G=h(p,E,Y);p.document.get().docId;try{const ee=p.document.get().serverId!=null,L=await hf(r(),o(p.request.key),E,p.document.get().serverId,G,p.document.get().attributes.wpId);if(p.closed)return!0;let Q;if(E==="snapshot"||E==="anchor"){const re=L?.modified!=null?Date.parse(L.modified):NaN;Q=Number.isFinite(re)?re:Date.now(),p.snapshotVersion=q,p.lastRevisionAt=Q}else{p.document.markSaved(q,L?.id!=null?String(L.id):void 0),p.savedContent=G.html;const re=L;In(p.document,Ei(re&&{wpId:re.wpId,secretHash:re.secretHash})),p.broughtContent=Un(c(G.html))}x(p,ee),p.saveError=void 0,p.saveFailures=0,p.failedIntent=void 0,p.document.get().serverId,S();const Z={intent:E,serverId:p.document.get().serverId,created:!ee,...Q!==void 0?{revisionAt:Q}:{}};return y.forEach(re=>re(Z)),!0}catch(ee){return(E==="publish"||E==="materialize")&&Zu(ee)?.then(L=>R(p,q,L)),p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}},u=p=>{p.closed=!0,p.watchers.forEach(E=>E()),p.watchers=[],_i(p),p.history.dispose(),p.document.dispose()},g=()=>{v&&(u(v),v=void 0)},O=()=>{w&&(u(w),w=void 0)},M=(p,E,D)=>{let N=!1;E.show&&(p.show?.id!==E.show.id||p.show.token!==E.show.token)&&(p.show=E.show,N=!0,{docId:p.document.get().docId,...E.show});const U=D==="show"?Oa(E.patch):null;if(U){p.reports.set("plugin",U),Si(p,U);const Y=Df(p,U);or(p,Y),Rf(p,Y)}N&&S()},_=(p,E={})=>j(v,p,E),I=()=>v&&oe(v.request.key??"")?w:v,F=p=>({error:p?.saveError,failures:p?.saveFailures??0,saving:p?.saving===!0,failedIntent:p?.failedIntent}),j=(p,E,D)=>!p||p.closed||E==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?E==="snapshot"||E==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>j(p,E,D)):(p.saving=!0,S(),p.inFlight=f(p,E,D).finally(()=>K(p)),p.inFlight),K=p=>{p.saving=!1,p.inFlight=void 0,v===p&&!p.closed&&S()},de=(p,E)=>{if(p.closed)return E();if(p.saving)return(p.inFlight??Promise.resolve(!1)).then(()=>de(p,E));p.saving=!0,S();const D=Promise.resolve().then(E);return p.inFlight=D.then(()=>!0,()=>!1).finally(()=>K(p)),D},se=(p,E)=>{const D=p.document.get().serverId,N=D==null?void 0:Wu(D);return de(p,E).finally(N)},X=(p,E="open",D=!1)=>{if(v&&!v.closed&&E!=="new"&&Sf(v.request,p))return M(v,p,E),v.document;g(),D||O();const N=ku({createBuffer:()=>Iu(""),serverId:p.serverId??null}),U={request:p,show:p.show,document:N,history:Fu(N,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return v=U,Vu(N,Y=>d?.(U.request.key)===!0?se(U,Y):void 0),U.watchers.push(Af(U)),N.get().docId,p.serverId,k(U,t(p,{publishRecoveryFacts(Y){U.closed||(U.recoveryFacts=Y,S())},readShownContent:()=>U.closed?null:U.document.getContent(),readWpId:()=>U.closed?void 0:U.document.get().attributes.wpId})),S(),N},J=(p,E,D)=>({key:oe(p)?p:Sn(p),serverId:E?.id!=null?String(E.id):null,email:E,show:D});return{openWith:X,open:(p,E={})=>X({key:st(p),serverId:p,email:E.email,patch:E.patch,show:E.show},"open"),openDraft:(p,E={})=>X({key:st(void 0),serverId:null,email:p,patch:E.patch,show:E.show},"open"),startNewDraft:(p,E={})=>X({key:st(void 0),serverId:null,email:p,patch:E.patch,show:E.show},"new"),reload:(p,E={})=>X({key:st(p),serverId:p,email:E.email,patch:E.patch,show:E.show},"new"),openBlock:(p,E,D)=>X(J(p,E,D),"open"),reloadBlock:(p,E,D)=>X(J(p,E,D),"new"),openBlockOver:(p,E)=>{const D=J(p,E);return v&&!v.closed&&v.request.key===D.key?v.document:(v&&!v.closed&&!oe(v.request.key)&&(O(),w=v,v=void 0),X(D,"open",!0))},resumeSuspended:()=>{if(w)return g(),v=w,w=void 0,S(),v.document},hasSuspended:()=>!!w,suspendedDocument:()=>w?.document,show:(p,E)=>{const D=v;if(!(!D||D.closed))return X({...D.request,patch:p,show:E},"show")},current:()=>v?.document,noteServerFacts:({serverId:p,block:E},D)=>{const N=v;!N||N.closed||N.request.serverId!==p||oe(N.request.key??"")===E&&In(N.document,Ei(D))},save:_,saveEmail:(p,E={})=>j(I(),p,E),saveState:()=>F(v),emailSaveState:()=>F(I()),revisionFacts(){if(!v)return;const p=v.revisionFactsSnapshot;return p&&p.snapshotVersion===v.snapshotVersion&&p.lastRevisionAt===v.lastRevisionAt?p:(v.revisionFactsSnapshot={snapshotVersion:v.snapshotVersion,lastRevisionAt:v.lastRevisionAt},v.revisionFactsSnapshot)},recoveryFacts:()=>v?.recoveryFacts,history:()=>v?.history,forcedHeaders:()=>v?.forcedHeaders,beginForcedHeaders(p){v&&!v.closed&&(v.forcedHeaders=p)},endForcedHeaders(){for(const p of[v,w])p&&(p.forcedHeaders=void 0)},onSaved(p){return y.add(p),()=>y.delete(p)},showFacts:()=>v?.show,shownHeaders:()=>({...v?.shownHeaders}),showFill:()=>v?.showFill,beginShowFill(p){v&&!v.closed&&(v.showFill={showId:p,codeEdits:0})},noteCodeEdit(){v?.showFill&&(v.showFill.codeEdits+=1)},endShowFill(p){for(const E of[v,w])E?.showFill?.showId===p&&(E.showFill=void 0)},sessionKey:()=>v?.request.key,openError:()=>v?.error,subscribe(p){return C.add(p),()=>C.delete(p)},close(){!v&&!w||(g(),O(),S())}}}var Oo=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Do(e){if(e instanceof Oo)return e.reason;if(e instanceof tt)return Do(e.reason)}function Mf(e){const t=e instanceof tt?e.reason:e;return t instanceof Oo&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Lf(e){const t=Do(e);return t!==void 0&&t!=="unavailable"}function Nf(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Oo("not-found");return Pa(n)}}}var ka=H("EmailPort");function Ff(e){return e.getInstance(ka)}function Bf(e,t){e.inject(ka,t)}var xa=H("documentSession.restEmailPortFactories");function Ma(e){return e.getInstance(xa)!==void 0}function rt(e){const t=e.getInstance(xa);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var jf=H("EmailTermsResolver");function Uf(e){return e.getInstance(jf)}var La=H("EmailHistoryPort"),Hf=H("BlockHistoryPort");function Na(e){return e.getInstance(Hf)}function Fa(e){return e.getInstance(La)}function $f(e,t){e.inject(La,t)}var Vf=2e3,qf=5e3,Gf=5,Wf=5e3,zf=4;function Kf(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function hn(e,t){return e==null||t==null?!1:e.replaceAll(`\r
996
+ `,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"emailmaker-core.a4e11bd0.js",po:"emailmaker-po.a4e11bd0.js",monaco:"static/monaco/index.CCINpETE.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var o=function(h){var f,u=function(){return f||(f=Promise.resolve().then(h))};return{then:function(g,O){return u().then(g,O)},catch:function(g){return u().catch(g)},finally:function(g){return u().finally(g)}}},i=o(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=o(function(){return i.then(function(h){return h.React})}),t.ReactDom=o(function(){return i.then(function(h){return h.ReactDom})}),t.ReactDomClient=o(function(){return i.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=o(function(){return i.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=o(function(){return i.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=o(function(){return i.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=o(function(){return i.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=o(function(){return i.then(function(h){return h.Classnames})}),t.Dayjs=o(function(){return i.then(function(h){return h.Dayjs})});var s=o(function(){return Promise.all([i]).then(function(h){var f=h[0]||Object.create(null),u=Object.create(null);for(var g in f)Object.prototype.hasOwnProperty.call(f,g)&&(u[g]=f[g]);for(var O in u)Object.prototype.hasOwnProperty.call(u,O)&&(t[O]=u[O]);return u})}),a={Uuid:"the shared `uuid` package was removed from the editor runtime; bundle `uuid` into the plugin or use `crypto.randomUUID()`"},l=["then","toString","valueOf","constructor","inspect","$$typeof"];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&t[c]===void 0&&(t[c]=(function(h,f){return new Proxy(Object.create(null),{get:function(u,g){if(!(typeof g=="symbol"||l.indexOf(g)!==-1))throw new Error("[shared-runtime] "+h+"."+String(g)+" is not available: "+f+".")}})})(c,a[c]));var d={},m={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKit:"[runtime] `@emailmaker/ui-kit` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKitIcons:"[runtime] `@emailmaker/ui-kit/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},b={Antd:"[runtime] `antd` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",AntDesignIcons:"[runtime] `@ant-design/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKit:"[runtime] `@emailmaker/ui-kit` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKitIcons:"[runtime] `@emailmaker/ui-kit/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version."},v=Object.create(null),w=function(h){for(var f=String(h&&h.stack||"").split(`
997
+ `),u="",g=0;g<f.length;g+=1){var O=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(f[g]);if(O){if(!u){u=O[1];continue}if(O[1]!==u)return O[1]}}return""},C=function(h){var f=w(new Error(h)),u=f?h+" Requested by: "+f+".":h;return e.__compatMissingReason=u,u};if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var f in h)Object.prototype.hasOwnProperty.call(h,f)&&(v[f]=h[f])},e.__compatPending){for(var y=0;y<e.__compatPending.length;y+=1)e.registerCompat(e.__compatPending[y]);e.__compatPending=void 0}for(var S in m)Object.prototype.hasOwnProperty.call(m,S)&&(function(h,f,u){var g=!1,O=function(){if(!(h in v))throw new Error(C(f));return v[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var M=O();return g||(g=!0),M},set:function(M){v[h]=M}}),Object.defineProperty(d,h,{configurable:!0,enumerable:!0,get:O,set:function(M){v[h]=M}})})(S,m[S],b[S]);var A=t;for(var B in d)Object.prototype.hasOwnProperty.call(d,B)&&(A===t&&(A=Object.create(t)),Object.defineProperty(A,B,Object.getOwnPropertyDescriptor(d,B)));var k=s,P=[],T=function(){for(var h=[],f=0;f<P.length;f+=1)(function(u){var g=t[u];g&&typeof g.then=="function"&&h.push(Promise.resolve(g).then(function(O){t[u]=O}))})(P[f]);return Promise.all(h)},x=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(T).then(function(){if(typeof x=="function")return x.call(e)})},typeof e.define=="function"){let h=function(f){if(!f||typeof f!="object"&&typeof f!="function"||f.__esModule)return f;if(R){var u=R.get(f);if(u)return u}var g=Object.create(null);Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var O=Reflect.ownKeys(f),M=0;M<O.length;M++){var _=O[M];if(_!=="__esModule"){var I=Object.getOwnPropertyDescriptor(f,_);I&&Object.defineProperty(g,_,I)}}return Object.prototype.hasOwnProperty.call(g,"default")||Object.defineProperty(g,"default",{enumerable:!0,value:f,writable:!1}),R&&R.set(f,g),g};var R=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var f=A.React;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.React)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.React;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react",[],function(){var f=A.React;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.React)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.React;return h(g)})}),e.define("react-dom",[],function(){var f=A.ReactDom;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactDom)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactDom;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react-dom",[],function(){var f=A.ReactDom;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactDom)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactDom;return h(g)})}),e.define("react-dom/client",[],function(){var f=A.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactDomClient)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactDomClient;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react-dom/client",[],function(){var f=A.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactDomClient)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactDomClient;return h(g)})}),e.define("react/jsx-runtime",[],function(){var f=A.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactJsxRuntime)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactJsxRuntime;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-runtime",[],function(){var f=A.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactJsxRuntime)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactJsxRuntime;return h(g)})}),e.define("react/jsx-dev-runtime",[],function(){var f=A.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactJsxDevRuntime)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactJsxDevRuntime;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-dev-runtime",[],function(){var f=A.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.ReactJsxDevRuntime)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.ReactJsxDevRuntime;return h(g)})}),e.define("antd",[],function(){var f=A.Antd;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Antd)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Antd;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/antd",[],function(){var f=A.Antd;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Antd)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Antd;return h(g)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var f=A.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignIconBase)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignIconBase;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var f=A.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignIconBase)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignIconBase;return h(g)})}),e.define("@ant-design/icons",[],function(){var f=A.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignIcons)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignIcons;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons",[],function(){var f=A.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignIcons)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignIcons;return h(g)})}),e.define("@ant-design/cssinjs",[],function(){var f=A.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignCssinjs)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignCssinjs;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/cssinjs",[],function(){var f=A.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.AntDesignCssinjs)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.AntDesignCssinjs;return h(g)})}),e.define("classnames",[],function(){var f=A.Classnames;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Classnames)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Classnames;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/classnames",[],function(){var f=A.Classnames;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Classnames)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Classnames;return h(g)})}),e.define("dayjs",[],function(){var f=A.Dayjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Dayjs)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Dayjs;return h(g)})}),e.define("@emailmaker/emailmaker/runtime/dayjs",[],function(){var f=A.Dayjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.Dayjs)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.Dayjs;return h(g)})}),e.define("@emailmaker/ui-kit",[],function(){var f=A.UiKit;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.UiKit)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.UiKit;return h(g)})}),e.define("@emailmaker/emailmaker/ui-kit",[],function(){var f=A.UiKit;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.UiKit)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.UiKit;return h(g)})}),e.define("@emailmaker/emailmaker/ui-kit/icons",[],function(){var f=A.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.UiKitIcons)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.UiKitIcons;return h(g)})}),e.define("@emailmaker/ui-kit/icons",[],function(){var f=A.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?k.then(function(g){return h(g.UiKitIcons)}):h(u)}):f!==void 0?h(f):k.then(function(u){var g=u.UiKitIcons;return h(g)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Td=new Function("url","return import(url)");function Ad(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function yo(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function ea(e){return e.type==="umd"||e.resolve==="registry"}var Rd="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function Pd(e){const t=Array.isArray(e)?e[0]:e;return yo(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Od(e,t){const n=Pd(e),r=yo(e)?e:void 0,o=t instanceof Error?t.message:String(t),i=r&&ea(r)&&!/compat/iu.test(o)?` ${Rd}`:"",s=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${i}`);return s.cause=t,{name:n,url:r?.url,error:s}}function Dd(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var kd=class{_context;_pluginRegistry;_options;_map=new Map;_optionsMap=new Map;_readyMap=new Map;_resolveMap=new Map;_initializingPlugins=new Map;_creatingPlugins=new Set;_initializedPlugins=new Set;_creationOrder=[];_lifecycleListeners=new Set;_activated=!1;constructor(e,t,n={}){this._context=e,this._pluginRegistry=t,this._options=n}activate(){return this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}activateSync(){this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}onLifecycle(e){return this._lifecycleListeners.add(e),{dispose:()=>this._lifecycleListeners.delete(e)}}_emitLifecycle(e){for(const t of Array.from(this._lifecycleListeners))try{t(e)}catch{}}async _resolveEntry(e){if(typeof e=="string"||typeof e=="symbol"){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);return{ctor:t}}if(typeof e=="function")return e.length===0?{ctor:await e()}:{ctor:e};if(Array.isArray(e)){const[t,n]=e;if(typeof t=="function")return{ctor:t,options:n};const r=await this._pluginRegistry.getAsync(t);if(!r)throw new Error(`Plugin "${String(t)}" not registered.`);return{ctor:r,options:n}}if(yo(e))return this._resolveDescriptor(e);throw new Error(`Unknown plugin entry format: ${JSON.stringify(e)}`)}async _resolveDescriptor(e){const t=e.resolve??(e.type==="umd"?"window":"module");if(ea(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Td(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let o;const i=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):Dd(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},s=()=>window.removeEventListener("error",i);window.addEventListener("error",i),r.onload=()=>{if(s(),o){n(o);return}t()},r.onerror=()=>{s(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const o=await this._resolveOrSkip(r);if(!o)continue;const i=this._createOrSkip(o.ctor,o.options);i&&!n.has(i)&&(n.add(i),t.push(i))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveOrSkip(s);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const c=this._creationOrder.indexOf(l);c>=0&&this._creationOrder.splice(c,1)}const o=[],i=new Set;for(const{ctor:s,options:a}of n){const l=this._createOrSkip(s,a);l&&!i.has(l)&&(i.add(l),o.push(l))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let i,s=!1;const a=()=>{s||(s=!0,i&&clearTimeout(i),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(i=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),o(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),o=this._createPluginInstance(e,r),i=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:i}),o.required?.(),this._map.set(n,o),this._creationOrder.push(o),this._setupReadyPromise(o)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Od(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return Ad(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const o of t){if(this._initializedPlugins.has(o))continue;const i=this._initializingPlugins.get(o);if(i){n.add(i);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const i of r)this._initializingPlugins.set(i,o);n.add(o),o.finally(()=>{for(const i of r)this._initializingPlugins.get(i)===o&&this._initializingPlugins.delete(i)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const o=this._options.openEarlyWindow?.();try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}finally{o?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(o){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:o})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},xd=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const o of n)try{o.callback(t)}catch{}const r=n.filter(o=>!o.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(o=>(t.ctor=o,t.loading=void 0,this._notifyListeners(e,o),o));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!1};return r.push(o),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!0};return r.push(o),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(o=>o.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Md=class{resolveRegistry;constructor(e){this.resolveRegistry=e}target(){return this.resolveRegistry()}get(e){return this.target().get(e)}getAsync(e){return this.target().getAsync(e)}add(e,t){return this.target().add(e,t)}addAll(e){return this.target().addAll(e)}addAsync(e,t){return this.target().addAsync(e,t)}has(e){return this.target().has(e)}isLoaded(e){return this.target().isLoaded(e)}override(e,t){return this.target().override(e,t)}on(e,t){return this.target().on(e,t)}once(e,t){return this.target().once(e,t)}off(e,t){return this.target().off(e,t)}keys(){return this.target().keys()}forContext(){return this.target().forContext()}},ii=class{capacity;items=[];constructor(e){this.capacity=e}push(e){this.items.length>=this.capacity&&this.items.shift(),this.items.push(e)}snapshot(){return this.items.slice()}size(){return this.items.length}clear(){this.items=[]}};function Ld(e,t){return t+e}function Nd(){return typeof performance>"u"?Date.now():Ld(performance.now(),performance.timeOrigin)}var Fd="emailmaker:diagnostics",Bd="diagnostics",jd="diagnostics";function si(e,t){return t?`${e}${e.includes("?")?"&":"?"}${jd}=1`:e}var er;function Ud(){try{const e=new URLSearchParams(window.location.search).get(Bd);return e===null?void 0:e!=="0"}catch{return}}function Hd(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function $d(){try{const e=window.localStorage.getItem(Fd);return e===null?void 0:e==="1"}catch{return}}function Ft(){return er===void 0&&(er=typeof window>"u"?!1:Ud()??Hd()??$d()??!1),er}function Vd(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var me={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},qw=Object.values(me),Gw=[me.canvasPainted,me.canvasSettled,me.appVisible,me.editorVisible],qd=5e3,Gd=3e3,ai="diagnosticsStore",tn,St;function li(){return{marks:new ii(qd),resources:new ii(Gd)}}function ta(){if(St)return St;const e=Eo();return e?(St=e[ai]??tn??li(),e[ai]=St,tn=void 0,St):(tn??=li(),tn)}function ie(e,t){Ft()&&ta().marks.push({phase:e,at:Nd(),...t})}function Eo(){if(typeof window.__emailmaker__<"u"&&window.__emailmaker__)return window.__emailmaker__;if(typeof window>"u")return;const e=window[Vd()];return e!==null&&typeof e=="object"?e:void 0}function zd(e){const t=e.length,n=ta();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Wd(){const e=Eo();return!e||!Array.isArray(e.diagnosticsBuffer)?0:zd(e.diagnosticsBuffer)}var Kd="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function je(){const e=new Error(Kd);return e.name="DestroyedInstanceError",e}function Yd(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Dr(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const i=e,s=t;return i.length===s.length&&i.every((a,l)=>Dr(a,s[l]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Dr(e[i],t[i]))}function na(e,t){const n={watch(r){let o,i=!1;return e.watch(s=>{const a=t(s);i&&Dr(o,a)||(o=a,i=!0,r(a))})},select(r){return na(n,r)}};return n}function Ee(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(i){t=i,n=!0;for(const s of Array.from(r))s(i)},watch(i){return r.add(i),n&&i(t),{dispose:()=>r.delete(i)}},select(i){return na(o,i)}};return o}var Xd=class{http;constructor(e){this.http=e}app_init_create=(e,t={})=>this.http.request({path:"/app/v1/app_init",method:"POST",body:e,type:Jc.UrlEncoded,...t})},ra=class{http;constructor(e){this.http=e}get_translations2=({file:e,...t},n={})=>this.http.request({path:`/translations/v1/${e}`,method:"GET",...n});get_translations3=({id:e,file:t,...n},r={})=>this.http.request({path:`/translations/v1/${t}/${e}`,method:"GET",...r})};function Jd(e){return String(e||"").trim()||void 0}var Qd=class extends ge{deps;_app;_baseUrl;_appInit;_restBaseUrl;_prevApp;constructor(e){super(),this.deps=e,this.addDisposable(e.options.select(t=>this._slice(t)).watch(t=>this._start(t)))}get app(){return this._app}_slice(e){return Object.prototype.hasOwnProperty.call(e,"baseUrl")&&(this._baseUrl=Jd(e.baseUrl)),Object.prototype.hasOwnProperty.call(e,"appInit")&&(this._appInit=e.appInit),{appInit:this._appInit,user:e.user,project:e.project,baseUrl:this._baseUrl,restBaseUrl:this.deps.resolveRestBaseUrl(this._baseUrl),standalone:this.deps.isStandalone()}}_start(e){if(this._restBaseUrl!==e.restBaseUrl&&(this._restBaseUrl=e.restBaseUrl,this.deps.setRestBaseUrl(e.restBaseUrl)),e.standalone)return;const t=e.appInit||this.deps.fallbackAppInit,n=Promise.resolve(t({baseUrl:e.baseUrl,user:e.user,project:e.project,prevApp:this._prevApp}));this._app=n,n.then(r=>{this._app===n&&(this._prevApp=r)},()=>{}),this.deps.publish(n)}},_o=H("AppInitService");function Zd(e){return async()=>{const t=await e();return(await new Xd(t).app_init_create({})).data}}function eu(e){e.injectFactory(_o,(t,n)=>{if(n)return n;const r=new Qd({options:e.getInstance(be),isStandalone:()=>!!e.getInstance(Me),resolveRestBaseUrl:o=>o?ni(o):ni()||void 0,setRestBaseUrl:o=>{e.getInstance(Fc)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:Zd(()=>e.getInstanceAsync(jc)),publish:o=>{e.inject(He,o)}});return e.getInstance(z)?.addDisposable(r),r},!0)}var wo=H("documentSession.emailDocuments");function ct(e){return e?.getInstance(wo)}var tu=H("RevisionServiceFlag");function oa(e){return e.getOrCreateInstance(tu,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function ia(e){return oa(e).isEnabled()}var nu=H("EmailRightsResolver");function ru(e,t){const n=e.getInstance(nu);return n?n(t):!0}var So={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},sa=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],aa=2e4,ou=sa.reduce((e,t)=>e+So[t],0),la=aa+ou+3e3;function iu(e){return sa.reduce((t,n)=>t+ca(n,e),0)}function ca(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:So[e]}function da(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:la}function ua(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:aa}function Wt(e=la){return e+3e3}function fa(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var su=()=>Wt();function au(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function lu(e){return t=>au(e.getOrCreateInstance($.BEFORE_SAVE_EMAIL,()=>new Ue).fire(t),su())}var et=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},pa=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[emailmaker] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Fn=class extends Error{timeoutMs;constructor(e,t="handleSaveEmail",n="email"){super(`[emailmaker] ${t} did not respond within ${e}ms — the ${n} was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function fe(e){return e.getOrCreateInstance(Gt,()=>new zt)}var ha=new WeakMap,kr=new WeakMap;function we(e){return ha.get(e)??0}function _n(e,t){let n=kr.get(e);return n||(n=new Set,kr.set(e,n)),n.add(t),()=>{n?.delete(t)}}function cu(e){ha.set(e,we(e)+1),kr.get(e)?.forEach(t=>t())}function xr(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var du=H("documentSession.canvasReceipts");function uu(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const o={guid:n,version:r};return e=o,()=>{e===o&&(e=void 0)}},note(n,r){const o=xr(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(o,n)}},read(n){if(!e)return;const{scope:r}=t,o={guid:e.guid,rev:e.version()};return r.originId!==null?{...o,changeId:t.changeId,originId:r.originId}:{...o,changeId:r.generation===n?t.changeId:0}}}}function ma(e){return e.getOrCreateInstance(du,uu)}var fu=2e3,pu=yd+od+fu;function hu(e,t=pu){return async()=>{const n=fe(e);let r;const o=new Promise(i=>{r=setTimeout(()=>i("silent"),t)});try{const i=ma(e).read(we(n)),s=await Promise.race([n.sendAsync(W.SANDBOX_CANVAS_SYNCED,i?{applied:i}:void 0,!1),o]);if(s==="silent"||s&&!s.synced)throw s==="silent"||s?.unsent,new et("canvas-not-synced")}finally{clearTimeout(r)}}}var mu="em_autosave_pending";function wn(e){return`${mu}_${e}`}function Mr(e,t){try{return sessionStorage.setItem(wn(e),JSON.stringify(t)),!0}catch{return!1}}function Bn(e){try{const t=sessionStorage.getItem(wn(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(wn(e)),null):n}catch{return null}}function Ye(e){try{sessionStorage.removeItem(wn(e))}catch{}}function Io(e){return`block:${e}`}function ga(e,t){return t?Io(e):e}function Co(e,t){(Bn(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&Ye(e)}function gu(e){return e!=null&&e!==""}function va(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var ci;function vu(){return va(Ln.em_revisions_v2)??!0}function bu(){return ci??=vu(),ci}function wt(e){return ia(e)&&bu()}function yu(){return!1}var ba;function Bt(e,t){return ba?.capture(e,t)}function Eu(e,t){return ba?.captureMessage(e,t)}var _u=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],wu=200;function ya(e=new Set){const t=new Set;return(n,r)=>{if(!_u.some(([i,s])=>!e.has(i)&&s.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=wu&&t.clear(),t.add(o))}}function Ea(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:ya()}}var Su=Ea();function Ve(e){return e?.getInstance(fo)??Su}function Iu(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function nn(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Re=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${nn(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${nn(this.oldText)}")`:`(replace@${this.oldPosition} "${nn(this.oldText)}" with "${nn(this.newText)}")`}};function di(e,t){return e===null||e.length===0?t:new Cu(e,t).compress()}var Cu=class De{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[l,c]=De._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(l),o=c;continue}if(r.newPosition<o.oldPosition){const[l,c]=De._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(l),r=c;continue}let s,a;if(o.oldEnd===r.newEnd)s=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[l,c]=De._splitPrev(r,o.oldLength);s=l,a=o,r=c,o=this._getCurr(++n)}else{const[l,c]=De._splitCurr(o,r.newLength);s=r,a=l,r=this._getPrev(++t),o=c}this._result[this._resultLen++]=new Re(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const i=De._merge(this._result);return De._removeNoOps(i)}_acceptCurr(t){this._result[this._resultLen++]=De._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=De._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new Re(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Re(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),o=t.newText.substr(n);return[new Re(t.oldPosition,t.oldText,t.newPosition,r),new Re(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new Re(t.oldPosition,r,t.newPosition,t.newText),new Re(t.oldPosition+n,o,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,o=t[0];for(let i=1;i<t.length;i++){const s=t[i];o.oldEnd===s.oldPosition?o=new Re(o.oldPosition,o.oldText+s.oldText,o.newPosition,o.newText+s.newText):(n[r++]=o,o=s)}return n[r++]=o,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let o=0;o<t.length;o++){const i=t[o];i.oldText!==i.newText&&(n[r++]=i)}return n}};function Tu(e){return new Re(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Au(e){return e.map(Tu)}function ui(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Ru(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const o=t[r];n=n.slice(0,o.oldPosition)+o.newText+n.slice(o.oldEnd)}return n}function Pu(e,t,n){let r=0;const o=e.start===e.end;for(const i of t){const s=i.newLength-i.oldLength;if(i.oldLength===0){const a=i.oldPosition;if(o&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(o){if(e.start>=i.oldEnd)r+=s;else if(e.start>i.oldPosition)return null;continue}if(e.start>=i.oldEnd)r+=s;else if(e.end>i.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var tt=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},fi=0,Ou=Math.random().toString(36).slice(2,8);function Du(){return fi+=1,`doc-${Ou}-${fi}`}function ku(e){const t=e.createBuffer(),n=e.docId??Du();let r=e.serverId??null,o=0,i=null,s=e.attributes??{};const a=new Set;let l=!1,c=!1,d;const m=new Set;let b=null;const v=()=>(b?.version!==o&&(b={version:o,value:t.read()}),b.value),w=C=>Object.entries(C).some(([y,S])=>s[y]!==S);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:i,attributes:s}),getContent:v,mutate(C,{source:y}){if(l)return o;const S=C.changes?.length?C.changes:void 0,A=S?Ru(v(),S):C.content!==void 0?C.content:void 0,B=A!==void 0&&A!==v(),k=C.attributes!==void 0&&w(C.attributes);if(!B&&!k)return o;const P=!(o>(i??-1)),T=k?Object.keys(C.attributes).filter(R=>s[R]!==C.attributes[R]):[];B&&t.write(A),k&&(s={...s,...C.attributes}),o+=1,y!=="user"&&P&&(i=o);const x={source:y,version:o,changes:S,...B?{content:!0}:{},...T.length>0?{attributes:T}:{}};return a.forEach(R=>R(x)),o},markSaved(C,y){const S={serverId:r,savedVersion:i};y!==void 0&&(r=y),(i===null||C>i)&&(i=C),(S.serverId!==r||S.savedVersion!==i)&&a.forEach(A=>A({source:"system",version:o}))},markUnsaved(){l||i===null||i<o||(i=o-1,a.forEach(C=>C({source:"system",version:o})))},markReady(){c||d!==void 0||(c=!0,m.forEach(C=>C.resolve()),m.clear(),a.forEach(C=>C({source:"system",version:o})))},isReady:()=>c,markFailed(C){c||d!==void 0||l||(d=C,m.forEach(y=>y.reject(new tt(C))),m.clear(),a.forEach(y=>y({source:"system",version:o})))},failure:()=>d,whenReady(){return c?Promise.resolve():d!==void 0?Promise.reject(new tt(d)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((C,y)=>{m.add({resolve:C,reject:y})})},subscribe(C){return a.add(C),()=>a.delete(C)},isNew:()=>r===null,isDirty:()=>o>(i??-1),isDisposed:()=>l,dispose(){l=!0,m.forEach(C=>C.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),m.clear(),a.clear(),t.dispose()}}}var xu=500,Mu=100,tr=0;function pi(e,t){let n=0;for(const r of t){if(r.oldPosition>e||r.oldPosition===e&&r.oldLength>0)break;if(r.oldEnd>e)return r.newEnd;n=r.newEnd-r.oldEnd}return e+n}function Lu(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function Nu(e,t){const n=e?.after;return n?{...e,after:{start:pi(n.start,t),end:pi(n.end,t)}}:e}function Fu(e,t={}){const n=t.groupIntervalMs??xu,r=t.maxSteps??Mu,o=t.now??(()=>0);let i=[],s=0,a=tr+=1,l=null,c,d,m,b=!1,v=!1,w=!1,C=!1;const y=new Set,S=()=>y.forEach(u=>u()),A=(u,g)=>{if(u.length){w=!0;try{e.mutate({changes:u},{source:g})}finally{w=!1}}},B=u=>A(u,"user"),k=u=>{const g=c?.from??o();if(v&&l!==null&&b===(c!==void 0)&&g>=l&&g-l<n){const O=i[s-1];i[s-1]={changes:di(O.changes,u),selection:Lu(O.selection,d)}}else i=i.slice(0,s),i.push({changes:u,selection:d}),s=i.length,v=!0,i.length>r&&(i=i.slice(i.length-r),s=i.length,a=tr+=1);l=c?.to??g,b=c!==void 0,S()},P=()=>{v=!1,l=null},T=u=>{if(!u.length)return;const g=i.length>s;if(g&&(i=i.slice(0,s)),s>0){const O=i[s-1];i[s-1]={changes:di(O.changes,u),selection:Nu(O.selection,u)}}P(),g&&S()},x=e.subscribe(({source:u,changes:g})=>{if(!(C||w||!g?.length)){if(u==="remote"){R();return}if(u!=="user"){T(g);return}k(g)}}),R=()=>{i=[],s=0,P(),a=tr+=1,S()},h=(u,g)=>{m=g;try{B(u)}finally{m=void 0}},f=(u=!1)=>{if(s===0)return!1;const g=i[s-1],O=Au(g.changes);return ui(e.getContent(),O)?(h(O,u?{kind:"undo",selection:g.selection?.before}:void 0),s-=1,P(),!0):(i=i.slice(0,s-1),s=i.length,P(),S(),!1)};return{recordAt(u,g,O){const M=c,_=d;c=u,d=O;try{return g()}finally{c=M,d=_}},activeMove:()=>m,canUndo:()=>s>0,canRedo:()=>s<i.length,undo(){f(!0)&&S(),P()},redo(){if(s>=i.length){P();return}const u=i[s];if(!ui(e.getContent(),u.changes)){i=i.slice(0,s),P(),S();return}h(u.changes,{kind:"redo",selection:u.selection?.after}),s+=1,P(),S()},clear:R,closeGroup:P,applyWithoutHistory(u){const g=e.get().version;if(A(u,"system"),e.get().version===g){P();return}T(u)},getPast:u=>i.slice(0,s).reverse().slice(0,u).map(g=>g.changes),getFuture:u=>i.slice(s).reverse().slice(0,u).map(g=>g.changes),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(u){if(u.stackId!==a||u.index>s)return!1;for(;s>u.index;)if(!f())return S(),!1;return S(),!0},subscribe(u){return y.add(u),()=>y.delete(u)},dispose(){C=!0,x(),y.clear(),i=[],s=0}}}var Bu=["edit","move","resize","insert"];function nr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ju(e){return typeof e=="string"?e:null}function Uu(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Hu(e){return Bu.includes(e)?e:null}function $u(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:ju(t.originId),changeId:nr(t.changeId),rev:nr(t.rev),baseRev:nr(t.baseRev),expected:Uu(t.expected),intent:Hu(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var hi=new WeakMap,_a=new WeakMap;function Vu(e,t){_a.set(e,t)}function qu(e,t){const n=(hi.get(e)??Promise.resolve()).then(t,t);return hi.set(e,n.catch(()=>{})),n}function Gu(e,t){return _a.get(e)?.(t)??qu(e,t)}var It=new Map,mi=new Map;function zu(e){return It.set(e,(It.get(e)??0)+1),()=>{const t=(It.get(e)??1)-1;if(t>0){It.set(e,t);return}It.delete(e);const n=mi.get(e);mi.delete(e),n?.forEach(r=>r())}}var To=e=>e.replace(/\r\n?/g,`
998
+ `),Wu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function Lr(e){return typeof e=="string"&&Wu.test(e)}var Ku=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function Yu(){return typeof navigator<"u"&&navigator.onLine===!1}function Xu(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const o=r.data;typeof r.data=="object"&&o.error!=null&&t.push(o.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function wa(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return wa(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function Ju(e){return Yu()?!0:Xu(e).some(wa)}var Sa=new WeakSet,Ia=new WeakMap;function Ca(e){typeof e=="object"&&e!==null&&Sa.add(e)}function Qu(e,t){typeof e=="object"&&e!==null&&Ia.set(e,t)}function Zu(e){return typeof e=="object"&&e!==null?Ia.get(e):void 0}function ef(e){return e instanceof Fn||e instanceof pa||typeof e=="object"&&e!==null&&Sa.has(e)}function tf(e){return e instanceof et||Ta(e)||e instanceof Ku||ef(e)}function Ta(e){return Ao(e)?.v2Error?.data?.code==="blocks.block_locked"}function gi(e){return Ao(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function Ao(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function nf(e){if(e instanceof et)return e.reason==="canvas-not-synced";if(tf(e))return!1;const t=Ao(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?gi(e):!0}return Ju(e)||gi(e)}var Aa="draft";function st(e){return e==null||e===""?Aa:String(e)}function Sn(e){return e==null||e===""?`${Nr}${Aa}`:`${Nr}${String(e)}`}var Nr="block:";function oe(e){return e?.startsWith(Nr)===!0}function dt(e){return oe(e.sessionKey())?void 0:e.current()}function Je(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return ie(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(ie(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const i=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw uo(o)?(`${e}`,{...n}):(`${e}`,{error:fa(o),...n},void 0),o})}var rf=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function of(e){const t=e?.trim()??"";if(!rf.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function kt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Ro(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function sf(e,t={}){const n=kt((e??[]).filter(r=>r?.html?.trim()));return Ro(n,t)?n:null}function af(e,t){const n=Date.parse(kt(e)?.modified??""),r=sf(e),o=Date.parse(r?.modified??""),i=t===void 0||Number.isFinite(o)&&o>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:i?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function vi(e,t,n){const r=kt((e??[]).filter(l=>l?.html?.trim())),o=Date.parse(r?.modified??""),i=Date.parse(kt((n??[]).filter(l=>l?.html?.trim()))?.modified??""),s=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(i>o),a=[Date.parse(kt(e??[])?.modified??""),t??NaN].filter(l=>Number.isFinite(l));return{autosave:s&&Ro(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function lf({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var bi=["recovery","plugin","rest"],cf=["subject","preheader"];function df(e){let t={},n;for(let o=bi.length-1;o>=0;o--){const i=e.get(bi[o]);i&&(i.attributes&&(t={...t,...i.attributes}),i.content!==void 0&&(n=i.content))}const r=e.get("plugin")?.attributes;for(const o of cf){const i=r?.[o];typeof i=="string"&&i!==""&&(t={...t,[o]:i})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function In(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?To(t.content):void 0,o=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...o?{changes:[new Re(0,n,0,r)]}:{}},{source:"remote"})}var rr=e=>typeof e=="string"?e.trim():"";function uf(e,t,n,r){const{version:o,attributes:i}=e.get(),s=i,a=r==="snapshot"||r==="anchor",l=a?s.author:void 0,c=a?s.date_gmt:void 0,d=rr(s.title)||rr(s.subject)||rr(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:d,subject:s.subject,preheader:s.preheader,description:s.description,common_styles:s.common_styles||"",meta:s.meta,utm_parameters:s.utm_parameters,parent_email:s.parent_email,is_template:s.is_template||!1,is_inited:s.is_inited,tags:s.tags,emailtags:s.emailtags,group:s.group,projectCategories:s.projectCategories,renderGuid:e.get().docId,project:t.project??s.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...l!=null&&l!==""?{author:l}:{},...c?{excerpt:c}:{}}}}var ff=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function pf(e){const t={};for(const n of ff)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function hf(e,t,n,r,o,i){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(o);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,o):t.saveAutosave(r,o,i==null?void 0:{wpId:i})}function Le(e,t=!1){const n={};for(const r of Object.keys(e)){let o=e[r];o!==void 0&&!(typeof o=="number"&&Number.isNaN(o))&&(t&&typeof o=="object"&&o!==null&&(o=Le(o)),n[r]=o)}return n}function mf(e){return typeof e=="string"&&e.includes("autosave")}var gf=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Ra(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!gf.has(t))):{}}function gt(e,t,n={}){e&&e.mutate({attributes:vf(e.get().attributes,t)},{source:n.source??"user"})}function vf(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Po(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function bf(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Pa(e){if(!e)return null;const t=Ra(e);return e.common_styles!==void 0&&(t.common_styles=bf(e.common_styles)),Po(e.html,t)}function Oa(e){return e?Po(e.html,Le(Ra(e))):null}var yf=["common_styles","subject","preheader","meta"];function yi(e){if(!e?.html?.trim())return null;const t={};for(const n of yf)Ef(n,e[n])&&(t[n]=e[n]);return Po(e.html,t)}function Ef(e,t){return e==="common_styles"?typeof t=="string"&&t.startsWith("{"):e==="meta"?typeof t=="object"&&t!==null&&!Array.isArray(t):typeof t=="string"}var _f=["modified","lock","wpId","secretHash"];function Ei(e){if(!e)return null;const t={};for(const n of _f)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var wf=10,Sf=(e,t)=>e.key===t.key&&If(e.serverId,t.serverId),If=(e,t)=>e==null||e===t;function Cf(e){return typeof e?.then=="function"}var _i=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Da=e=>{e.request.serverId!=null&&!jn(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},Tf=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),jn=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),wi=(e,t)=>t?.content!==void 0&&lf({hasUnsavedUserEdit:jn(e)})==="skip",Si=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},Af=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),Rf=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent(),e.userTouched.clear(),e.document.get().docId))},Pf=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,i])=>e.attributes[o]!==i)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Of=e=>{const t=df(e.reports),n=Pf(e.lastMerged,t);e.lastMerged=t,e.broughtContent=Un(t.content)??e.broughtContent,n&&(In(e.document,n),Da(e))},or=(e,t)=>{if(!e.ready&&!jn(e)){Of(e);return}e.broughtContent=Un(t?.content)??e.broughtContent,In(e.document,t)},Un=e=>e===void 0?void 0:To(e),Df=(e,t)=>t.content===void 0||Un(t.content)!==e.broughtContent||!jn(e)?t:{...t,content:void 0},kf=e=>{const{attributes:t,serverId:n,docId:r}=e.document.get();return{...t,html:e.document.getContent(),id:n??void 0,isNew:n==null,renderGuid:r}};function xf(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:i,canEdit:s,notifyBeforeSave:a,awaitCanvasSynced:l,savedEchoForm:c=p=>p,queuesOutsideWrites:d,onAdapterError:m,onTimeout:b}=e;let v,w;const C=new Set,y=new Set,S=()=>C.forEach(p=>p()),A=(p,E)=>{if(!(p.closed||p.ready)){if(p.error!==void 0){p.document.markFailed(p.error),p.document.get().docId;return}Da(p),p.ready=!0,p.document.markReady(),p.document.get().docId,[...p.reports.keys()]}},B=(p,E,D)=>{m?.(E.id,D),!(!E.required||p.closed)&&(p.error=D,p.document.get().docId,E.id,S())},k=(p,E)=>{const D=new Set(E.map(q=>q.id));E.forEach(q=>{q.watch&&p.watchers.push(q.watch(G=>p.closed?!1:p.ready&&(wi(p,G)||p.contentShown===!0&&G?.content!==void 0)?(p.document.get().docId,q.id,!1):(G&&p.reports.set(q.id,G),or(p,G),G?.content!==void 0&&(p.showFill=void 0),!0)))});const N=(q,G)=>{if(!p.closed){if(!q.required&&wi(p,G)){p.document.get().docId,q.id,q.loaded?.(!1);return}G&&(p.reports.set(q.id,G),q.id==="plugin"&&Si(p,G)),or(p,G),q.loaded?.(G!==null)}},U=()=>{D.size>0||p.closed||(_i(p),A(p,[]))},Y=[];if(E.forEach(q=>{let G;try{G=q.load()}catch(ee){B(p,q,ee),D.delete(q.id);return}if(Cf(G)){Y.push({id:q.id,required:q.required,load:()=>G,...q.loaded?{loaded:ee=>q.loaded?.(ee)}:{}});return}N(q,G),D.delete(q.id)}),Y.length===0){U();return}p.timer=setTimeout(()=>{p.timer=void 0,b?.([...D]),p.document.get().docId,[...D],A(p,[...D])},n),p.timer.unref?.(),Y.forEach(q=>{q.load().then(G=>N(q,G)).catch(G=>{B(p,q,G)}).finally(()=>{D.delete(q.id),U()})})},P=async(p,E,D)=>{if(D==="snapshot"||D==="anchor")return;const N=i?.();if(N)return N.resolve({project:E.project??p.project,tags:(p.tags??[]).map(U=>({name:U}))})},T=p=>{if(p.lock===!0&&s?.(p)===!1)return new et("locked");const E=p.tags?.length??0,D=p.emailtags?.length??0;if(Math.max(E,D)>wf)return new et("too-many-tags")},x=(p,E)=>{const D=p.document.get().serverId;D!=null&&(p.createKey=void 0),!(E||D==null)&&(p.recoveryFacts={emailId:D,historyLoaded:!0,isRecovering:!1},oe(p.request.key)||(p.request={...p.request,key:st(D),serverId:D}))},R=(p,E,D)=>{if(p.closed||D?.id==null)return;const N=p.document.get().serverId,U=N!=null;U&&N!==String(D.id)||(p.document.markSaved(E,String(D.id)),x(p,U),p.document.get().serverId,S())},h=(p,E,D)=>{if(!(E==="materialize"||E==="publish"&&p.document.get().serverId==null))return D;const N=p.createKey,U=N&&N.project===D.project?N:{key:Ce(),project:D.project};return p.createKey=U,{...D,idempotencyKey:U.key}},f=async(p,E,D)=>{try{await p.document.whenReady()}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,!1}if(p.closed)return!1;const N=T(p.document.get().attributes);if(N)return p.saveError=N,p.saveFailures+=1,p.failedIntent=E,N.reason,S(),!1;if(a&&(await a(kf(p)).catch(()=>{}),p.closed))return!1;if(l){try{await l()}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}if(p.closed)return!1}if(Tf(p))return E==="snapshot"||(p.saveError=new et("empty-content"),p.saveFailures+=1,p.failedIntent=E,S()),!1;let U;try{U=await P(p.document.get().attributes,D,E)}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}if(p.closed)return!1;const{payload:Y,version:q}=uf(p.document,D,U,E),G=h(p,E,Y);p.document.get().docId;try{const ee=p.document.get().serverId!=null,L=await hf(r(),o(p.request.key),E,p.document.get().serverId,G,p.document.get().attributes.wpId);if(p.closed)return!0;let Q;if(E==="snapshot"||E==="anchor"){const re=L?.modified!=null?Date.parse(L.modified):NaN;Q=Number.isFinite(re)?re:Date.now(),p.snapshotVersion=q,p.lastRevisionAt=Q}else{p.document.markSaved(q,L?.id!=null?String(L.id):void 0),p.savedContent=G.html;const re=L;In(p.document,Ei(re&&{wpId:re.wpId,secretHash:re.secretHash})),p.broughtContent=Un(c(G.html))}x(p,ee),p.saveError=void 0,p.saveFailures=0,p.failedIntent=void 0,p.document.get().serverId,S();const Z={intent:E,serverId:p.document.get().serverId,created:!ee,...Q!==void 0?{revisionAt:Q}:{}};return y.forEach(re=>re(Z)),!0}catch(ee){return(E==="publish"||E==="materialize")&&Zu(ee)?.then(L=>R(p,q,L)),p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}},u=p=>{p.closed=!0,p.watchers.forEach(E=>E()),p.watchers=[],_i(p),p.history.dispose(),p.document.dispose()},g=()=>{v&&(u(v),v=void 0)},O=()=>{w&&(u(w),w=void 0)},M=(p,E,D)=>{let N=!1;E.show&&(p.show?.id!==E.show.id||p.show.token!==E.show.token)&&(p.show=E.show,N=!0,{docId:p.document.get().docId,...E.show});const U=D==="show"?Oa(E.patch):null;if(U){p.reports.set("plugin",U),Si(p,U);const Y=Df(p,U);or(p,Y),Rf(p,Y)}N&&S()},_=(p,E={})=>j(v,p,E),I=()=>v&&oe(v.request.key??"")?w:v,F=p=>({error:p?.saveError,failures:p?.saveFailures??0,saving:p?.saving===!0,failedIntent:p?.failedIntent}),j=(p,E,D)=>!p||p.closed||E==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?E==="snapshot"||E==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>j(p,E,D)):(p.saving=!0,S(),p.inFlight=f(p,E,D).finally(()=>K(p)),p.inFlight),K=p=>{p.saving=!1,p.inFlight=void 0,v===p&&!p.closed&&S()},de=(p,E)=>{if(p.closed)return E();if(p.saving)return(p.inFlight??Promise.resolve(!1)).then(()=>de(p,E));p.saving=!0,S();const D=Promise.resolve().then(E);return p.inFlight=D.then(()=>!0,()=>!1).finally(()=>K(p)),D},se=(p,E)=>{const D=p.document.get().serverId,N=D==null?void 0:zu(D);return de(p,E).finally(N)},X=(p,E="open",D=!1)=>{if(v&&!v.closed&&E!=="new"&&Sf(v.request,p))return M(v,p,E),v.document;g(),D||O();const N=ku({createBuffer:()=>Iu(""),serverId:p.serverId??null}),U={request:p,show:p.show,document:N,history:Fu(N,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return v=U,Vu(N,Y=>d?.(U.request.key)===!0?se(U,Y):void 0),U.watchers.push(Af(U)),N.get().docId,p.serverId,k(U,t(p,{publishRecoveryFacts(Y){U.closed||(U.recoveryFacts=Y,S())},readShownContent:()=>U.closed?null:U.document.getContent(),readWpId:()=>U.closed?void 0:U.document.get().attributes.wpId})),S(),N},J=(p,E,D)=>({key:oe(p)?p:Sn(p),serverId:E?.id!=null?String(E.id):null,email:E,show:D});return{openWith:X,open:(p,E={})=>X({key:st(p),serverId:p,email:E.email,patch:E.patch,show:E.show},"open"),openDraft:(p,E={})=>X({key:st(void 0),serverId:null,email:p,patch:E.patch,show:E.show},"open"),startNewDraft:(p,E={})=>X({key:st(void 0),serverId:null,email:p,patch:E.patch,show:E.show},"new"),reload:(p,E={})=>X({key:st(p),serverId:p,email:E.email,patch:E.patch,show:E.show},"new"),openBlock:(p,E,D)=>X(J(p,E,D),"open"),reloadBlock:(p,E,D)=>X(J(p,E,D),"new"),openBlockOver:(p,E)=>{const D=J(p,E);return v&&!v.closed&&v.request.key===D.key?v.document:(v&&!v.closed&&!oe(v.request.key)&&(O(),w=v,v=void 0),X(D,"open",!0))},resumeSuspended:()=>{if(w)return g(),v=w,w=void 0,S(),v.document},hasSuspended:()=>!!w,suspendedDocument:()=>w?.document,show:(p,E)=>{const D=v;if(!(!D||D.closed))return X({...D.request,patch:p,show:E},"show")},current:()=>v?.document,noteServerFacts:({serverId:p,block:E},D)=>{const N=v;!N||N.closed||N.request.serverId!==p||oe(N.request.key??"")===E&&In(N.document,Ei(D))},save:_,saveEmail:(p,E={})=>j(I(),p,E),saveState:()=>F(v),emailSaveState:()=>F(I()),revisionFacts(){if(!v)return;const p=v.revisionFactsSnapshot;return p&&p.snapshotVersion===v.snapshotVersion&&p.lastRevisionAt===v.lastRevisionAt?p:(v.revisionFactsSnapshot={snapshotVersion:v.snapshotVersion,lastRevisionAt:v.lastRevisionAt},v.revisionFactsSnapshot)},recoveryFacts:()=>v?.recoveryFacts,history:()=>v?.history,forcedHeaders:()=>v?.forcedHeaders,beginForcedHeaders(p){v&&!v.closed&&(v.forcedHeaders=p)},endForcedHeaders(){for(const p of[v,w])p&&(p.forcedHeaders=void 0)},onSaved(p){return y.add(p),()=>y.delete(p)},showFacts:()=>v?.show,shownHeaders:()=>({...v?.shownHeaders}),showFill:()=>v?.showFill,beginShowFill(p){v&&!v.closed&&(v.showFill={showId:p,codeEdits:0})},noteCodeEdit(){v?.showFill&&(v.showFill.codeEdits+=1)},endShowFill(p){for(const E of[v,w])E?.showFill?.showId===p&&(E.showFill=void 0)},sessionKey:()=>v?.request.key,openError:()=>v?.error,subscribe(p){return C.add(p),()=>C.delete(p)},close(){!v&&!w||(g(),O(),S())}}}var Oo=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Do(e){if(e instanceof Oo)return e.reason;if(e instanceof tt)return Do(e.reason)}function Mf(e){const t=e instanceof tt?e.reason:e;return t instanceof Oo&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Lf(e){const t=Do(e);return t!==void 0&&t!=="unavailable"}function Nf(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Oo("not-found");return Pa(n)}}}var ka=H("EmailPort");function Ff(e){return e.getInstance(ka)}function Bf(e,t){e.inject(ka,t)}var xa=H("documentSession.restEmailPortFactories");function Ma(e){return e.getInstance(xa)!==void 0}function rt(e){const t=e.getInstance(xa);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var jf=H("EmailTermsResolver");function Uf(e){return e.getInstance(jf)}var La=H("EmailHistoryPort"),Hf=H("BlockHistoryPort");function Na(e){return e.getInstance(Hf)}function Fa(e){return e.getInstance(La)}function $f(e,t){e.inject(La,t)}var Vf=2e3,qf=5e3,Gf=5,zf=5e3,Wf=4;function Kf(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function hn(e,t){return e==null||t==null?!1:e.replaceAll(`\r
999
999
  `,`
1000
1000
  `)===t.replaceAll(`\r
1001
1001
  `,`
1002
- `)}function Cn(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function xt(e,t){return Ro(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function Yf(e,t,n){const{latest:r}=e,o=hn(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(i=>hn(i,r.html))?o?{revision:null,phase:"normal"}:{revision:Cn(t),phase:"timeout"}:o?{revision:xt(e),phase:"normal"}:hn(t.html,r.html)?{revision:Cn(t),phase:"found"}:{revision:xt(e),phase:"normal"}}function Xf({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:o=!1,readShownContent:i,onFacts:s,onLate:a,onError:l,pageLoadTs:c=Kf()}){const d=r??e;let m=null,b=!1,v=!1,w=0,C={emailId:e,historyLoaded:!1,isRecovering:!1},y=null;const S=new Promise(_=>{y=_}),A=_=>{C={...C,..._},s(C)};let B;const k=_=>{w+=1,A({applied:{phase:_,seq:w}})},P=()=>{m?.timer&&clearTimeout(m.timer),m=null},T=_=>{if(!v){if(y){const I=y;y=null,I(_),B=_.revision?_.phase:void 0;return}a(_)&&_.revision&&k(_.phase)}},x=()=>{if(!m||v)return;const _=m.phase==="fast",I=_?Vf:Wf,F=_?Gf:zf;m.timer=setTimeout(()=>{const j=m;if(!(!j||v)){if(j.attempts+=1,u(),_&&j.attempts>=F){const{pending:K}=j;Ye(d),A({isRecovering:!1}),T({revision:Cn(K),phase:"timeout"}),b=!0,j.phase="bg",j.attempts=0,x();return}if(!_&&j.attempts>=F){Ye(d),P(),A({isRecovering:!1}),b=!0;return}x()}},I),m.timer.unref?.()},R=_=>{m={phase:"fast",attempts:0,pending:_,timer:null},A({isRecovering:!0}),x()},h=_=>{if(v)return;if(A({historyLoaded:!0,latestRevisionAt:_.latestAt!==void 0&&Number.isFinite(_.latestAt)?_.latestAt:void 0}),n&&m){const j=xt(_,m.pending.sentAt);if(!j)return;const K=m.phase==="fast"?"found":"bg";Ye(d),P(),A({isRecovering:!1}),b=!0,T({revision:j,phase:K});return}if(b)return;const I=n?Bn(d):null,F=I&&(I.sentAt<c||!hn(I.html,i()))?I:null;if(F){if(o&&(F.baseRevisionId!==void 0||F.baseOpen)){Ye(d),b=!0,T(Yf(_,F,i()));return}const j=xt(_,F.sentAt);if(j){Ye(d),b=!0,T({revision:j,phase:"found"});return}if(o){if(Ye(d),b=!0,_.latestAt!==void 0&&_.latestAt>F.sentAt+5e3){T({revision:null,phase:"normal"});return}T({revision:Cn(F),phase:"timeout"});return}R(F);return}b=!0,T({revision:xt(_),phase:"normal"})},f=_=>{v||(l?.(_),C.historyLoaded||(A({historyLoaded:!1,latestRevisionAt:void 0}),M()),!m&&T({revision:null,phase:"normal"}))},u=()=>t(e).then(h).catch(f);let g,O=!1;const M=()=>{O||m||v||(O=!0,g=setTimeout(()=>{g=void 0,!v&&!C.historyLoaded&&u()},qf))};return u(),{verdict:()=>S,confirmVerdict(_){const I=B;B=void 0,_&&I!==void 0&&!v&&k(I)},dispose(){v=!0,g!==void 0&&(clearTimeout(g),g=void 0),P()}}}function Jf({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:o,wpId:i,readShownContent:s,onFacts:a}){let l=null;const c=Xf({emailId:o,readAutosave:d=>i?e.readAutosave(d,{wpId:i()}):e.readAutosave(d),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:s,onFacts:a,onLate:({revision:d,phase:m})=>{const b=yi(d);return l?.(b)??!1},onError:d=>{d instanceof Error&&d.message}});return{id:"recovery",load:()=>c.verdict().then(({revision:d})=>yi(d)),loaded(d){c.confirmVerdict(d)},watch(d){return l=d,()=>{l=null,c.dispose()}}}}var Qf=5e3,Zf=H("plugin.knownRevisions");function vt(e){return e.getOrCreateInstance(Zf,()=>new Map)}function ko(e,t,n,r){const o=n?.get(t)??[],i=o.filter(s=>s!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...o.length>Ba?{baseOpen:!0}:i.length?{baseHtmls:i}:{}}}var ep=H("plugin.uncertainWrites"),Ba=3;function Kt(e){return e.getOrCreateInstance(ep,()=>new Map)}function tp(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>Ba||e.set(t,[...r,n])}function ja(e,t){Mr(e,t)||!t.baseHtmls||Mr(e,{...t,baseHtmls:void 0,baseOpen:!0})}function Tn(e,t,n,r=!1){const o=Bn(e);!n||o?.sentAt!==t||!(r||o.baseOpen||o.baseHtmls)||Mr(e,{...o,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function Ua(e,t,n,r){(Bn(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||ja(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var np=/(?:Z|[+-]\d{2}:?\d{2})$/i;function rp(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",o=np.test(r)?Date.parse(r):NaN;return!Number.isFinite(o)||o>=t-Qf}function Ha(e,t,{pendingKey:n=s=>s,knownRevisions:r=new Map,uncertainWrites:o,synchronousHistory:i=!1}={}){return{readRevisions:(s,a,l)=>t.readRevisions(s,a,l),readRevision:(s,a,l)=>t.readRevision?t.readRevision(s,a,l):Promise.resolve(null),readAutosave:(s,a)=>t.readAutosave(s,a),async saveAutosave(s,a,l){const c=n(s),d=Date.now();ja(c,{sentAt:d,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...ko(r,c,o,a.html??"")});const m=await t.saveAutosave(s,a,l),b=m?.id;return rp(m,d)?Tn(c,d,b):b&&i&&(m.isAutosave===!0?Co(c,d):Tn(c,d,b,!0)),await e.saveAutosave(s,a),m}}}function op(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,o){const i=Date.now();n&&Ua(r,o,i,ko(n.knownRevisions,r,n.uncertainWrites,o.html??""));const s=await t.updateEmail(r,o);return n&&Tn(r,i,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,o),Co(r,i),s&&{...s,id:r}}}}var $a=H("CurrentUser"),Va={};function xo(e){return e.getOrCreateInstance($a,()=>Ee(Va))}function qa(e){return e?.getInstance($a)?.get()??Va}var Ga=H("HeadlessMode");function Wa(e){return e.getOrCreateInstance(Ga,()=>Ee(!1))}function ip(e){return e?.getInstance(Ga)?.get()??!1}var sp=H("HiddenMount");function ap(e){return e.getOrCreateInstance(sp,()=>Ee(!1))}function lp(e){if(!e)return!1;try{return!!ho(e).data?.act_as}catch{return!1}}function cp(e){return lp(e?.getInstance(zs)?.get(pd.em_token))}function za(e){return e?.getInstance(ve)?.get()??{}}function Hn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function dp(e,t){return t.modeDefaults(Hn(e,t.fallbackMode))}function Ka(e,t){const n=Hn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Ya(e,t){const n=Hn(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function up(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function fp(e){return qc(e.map(t=>t?.resourceProxy))}function pp(e){return Bc(e.map(t=>t?.resourceProxyPolicy))}function hp(e){return Hc(e.map(t=>t?.backendProxy))}function mp(e){return Ks(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function gp(e,t){return[e.base,dp(e,t),e.profile,e.serverSide,Ka(e,t.fallbackMode),e.local,e.user,Ya(e,t.fallbackMode)]}function ir(e,t){const n=gp(e,t),r=Ks(n),o=up(n);o!==void 0&&(r.fileManager=o);const i=fp(n);i!==void 0&&(r.resourceProxy=i);const s=pp(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=hp(n);a!==void 0&&(r.backendProxy=a);const l=mp(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}function vp(e,t,n){const r=Ka(e,n),o=Ya(e,n);return Uc([o,e.user,r,e.serverSide],t)}var bp=1.5;function yp(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=bp*e.autosaveTimeoutMs?"none":"revision"}function Ep(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,i=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const l=h=>a!==void 0&&a.version===h.get().version?i()-a.failuresAtStart:0,c=h=>{const f=l(h);if(f<=0)return!1;const u=n().retryMaxAttempts??5;return!s()||f>u},d=()=>{const{autosaveTimeoutMs:h,retryIntervalMs:f}=n(),u=t();return u!==void 0&&l(u)>0&&f!==void 0&&f>0?f:h},m=h=>h.isNew()&&i()>=3,b=()=>{const h=t();if(!h||h.isDisposed()||c(h))return"none";const{latestRevisionAt:f,snapshotVersion:u,...g}=n(),O=Date.now(),M=yp({...g,isDirty:h.isDirty(),isNew:h.isNew(),isReady:h.isReady(),latestRevisionAgeMs:f!=null&&f<=O?O-f:void 0,isSnapshotSent:u!=null&&u===h.get().version});return M==="create"&&m(h)?"none":M},v=()=>{const h=t();if(!h||h.isDisposed()||m(h)||c(h)||n().isHeadless)return!1;if(!h.isDirty())return h.isNew();const{snapshotVersion:f}=n();return!(f!=null&&f===h.get().version)};let w,C=0,y=0,S,A,B,k=!1;const P=()=>{S=void 0;const h=t();if(!h||h.isDisposed())return;if(h.get().docId!==w){T();return}const f=b();f!=="none"&&a?.version!==h.get().version&&(a={version:h.get().version,failuresAtStart:i()}),f==="create"?r():f==="revision"?o():v()&&(w=h.get().docId,C=d(),y=i(),S=setTimeout(P,C))},T=()=>{const h=t();if(k||!h)return;const f=a?.version===h.get().version&&y!==i();S!==void 0&&(C!==d()||f)&&(clearTimeout(S),S=void 0),!(S!==void 0||b()==="none"&&!v())&&(w=h.get().docId,C=d(),y=i(),S=setTimeout(P,C))},x=h=>{const f=t();h.source==="user"?a=void 0:a&&f&&(a.version=f.get().version),h.source==="user"&&S!==void 0&&(clearTimeout(S),S=void 0),T()},R=()=>{const h=t();h!==A&&(B?.(),A=h,a=void 0,B=h?.subscribe(x),S!==void 0&&(clearTimeout(S),S=void 0))};return R(),T(),{refresh:()=>{k||(R(),T())},stop:()=>{k=!0,B?.(),B=void 0,A=void 0,S!==void 0&&(clearTimeout(S),S=void 0)}}}var Xa=H("documentSession.autosaveUiFacts"),Ja={isUserBusy:!1,saveContext:{}};function _p(e){return e.getOrCreateInstance(Xa,()=>Ee(Ja))}function Fr(e){return e?.getInstance(Xa)?.get()??Ja}function Qa(e){return Fr(e).saveContext.fallbackTitle||"Untitled email."}var wp=1e4,Sp=3e4;function Ip(e,t){const n=b=>{const v=e.getInstance(ve)?.layers?.(),w=v?vp(v,b):void 0;return typeof w=="number"&&w>=0?w:void 0};let r;const o=b=>{const{error:v,failures:w}=t.saveState();return Ta(v)?(r?.failures!==w&&(r={failures:w,saved:b??null}),r.saved===(b??null)):(r=void 0,!1)},i=()=>{const b=t.current(),v=b?.get().serverId??void 0,w=oe(t.sessionKey()),C=t.recoveryFacts(),y=C?.emailId===v?C:void 0,S=t.revisionFacts(),A=y?.latestRevisionAt,B=S?.lastRevisionAt,k=qa(e).profile;return{isInited:w||b?.get().attributes.is_inited===!0,isEnabled:!!k?.autosaves&&!cp(e)&&!o(b?.get().savedVersion),isHistoryLoaded:y?.historyLoaded===!0,isUserBusy:Fr(e).isUserBusy,isHeadless:ip(e),autosaveTimeoutMs:za(e).autosaveTimeout||wp,latestRevisionAt:A!==void 0||B!==void 0?Math.max(A??0,B??0):void 0,snapshotVersion:S?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Sp,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},s=()=>{const b=Fr(e).saveContext;return{...b,project:b.project??t.current()?.get().attributes.project,fallbackTitle:Qa(e)}},a=Ep({readDocument:()=>t.current(),readEnvironment:i,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>nf(t.saveState().error),onCreate:()=>{oe(t.sessionKey())||t.save("materialize",s())},onRevision:()=>{t.save("snapshot",{project:s().project})}}),l=t.subscribe(()=>{o(t.current()?.get().savedVersion),a.refresh()}),c=xo(e).watch(()=>a.refresh()),d=_p(e).watch(()=>a.refresh()),m=Wa(e).watch(()=>a.refresh());return()=>{l(),c.dispose(),d.dispose(),m.dispose(),a.stop()}}var Ii=12e3;function he(e){return e.getOrCreateInstance(wo,()=>{const t=xf({resolveAdapters:(r,o)=>Ap(r,e,o),resolveWritePort:()=>Za(e),resolveHistoryPort:r=>oe(r)?tl(e):el(e),resolveTerms:()=>Uf(e),canEdit:r=>ru(e,r),notifyBeforeSave:lu(e),awaitCanvasSynced:hu(e),savedEchoForm:r=>{const o=Ve(e);return o.toEditorForm(o.toOutputForm(r))},queuesOutsideWrites:r=>oe(r)&&(yu()||wt(e)),timeoutMs:Ii,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const i=Lf(o),s=Mf(o);Bt(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(i),network_failure:String(s)},level:i||s?"warning":"error"})},onTimeout:r=>{}}),n=Ip(e,t);return e.getInstance(W)?.addDispose(n),t})}function nt(e){return e?.getInstance(wo)}function Za(e){const t=Ff(e);return t?$n(e)?op(t,rt(e).email(e),wt(e)?{knownRevisions:vt(e),uncertainWrites:Kt(e)}:void 0):t:rt(e).email(e)}function Cp(e){return Fa(e)!==void 0||Ma(e)}function el(e){const t=Fa(e);return t?$n(e)?(ie("port:history:server-backed"),Ha(t,rt(e).history(e),{knownRevisions:vt(e),uncertainWrites:Kt(e),synchronousHistory:wt(e)})):(ie("port:history:integrator"),t):(ie("port:history:rest (порт не зарегистрирован)"),rt(e).history(e))}function tl(e){const t=Na(e);return t?$n(e)?(ie("port:block-history:server-backed"),Ha(t,rt(e).blockHistory(e),{pendingKey:Io,knownRevisions:vt(e),uncertainWrites:Kt(e),synchronousHistory:wt(e)})):(ie("port:block-history:integrator"),t):(ie("port:block-history:rest (порт не зарегистрирован)"),rt(e).blockHistory(e))}function Tp(e){return Na(e)!==void 0||Ma(e)}function $n(e){return ia(e)}function Ap({email:e,patch:t,serverId:n,key:r},o,i){const s=[];e?s.push({id:"rest",load:()=>Pa(e),required:!0}):n&&s.push(Nf(Za(o),n)),t&&s.push({id:"plugin",load:()=>Oa(t)});const a=oe(r);return gu(n)&&(a?Tp(o):Cp(o))&&s.push(Jf({port:a?tl(o):el(o),revisionServiceEnabled:$n(o),pendingKey:ga(n,a),historyIsSynchronous:wt(o),emailId:n,wpId:()=>i.readWpId(),readShownContent:()=>i.readShownContent(),onFacts:l=>i.publishRecoveryFacts(l)})),s}function Rp(e){const t=he(e),n=fe(e).addListener(z.APPLICATION_HAS_AMP,r=>{dt(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(W)?.addDispose(()=>n.dispose())}function Pp(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Op(e){const t=e.fetchImpl??((i,s)=>fetch(i,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=i=>{try{const s=new URL(i,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:o,async load(i){if(!o(i))return;const s=!r.has(i);r.add(i);try{const a=await t(i,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const l=await a.blob();return Pp(l)?l:void 0}catch{return}}}}var Ze={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Dp(e){const t={maxBytes:e.maxBytes??Ze.maxBytes,maxImageBytes:e.maxImageBytes??Ze.maxImageBytes,ttlMs:e.ttlMs??Ze.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,i={hits:0,loads:0,failures:0};let s=0;const a=m=>{const b=r.get(m);b&&(s-=b.bytes,r.delete(m))},l=m=>t.ttlMs<=0||n()-m.storedAt<t.ttlMs,c=()=>{if(s<=t.maxBytes)return;const m=[...r.entries()].sort((b,v)=>b[1].usedAt-v[1].usedAt);for(const[b]of m){if(s<=t.maxBytes)return;a(b)}},d=(m,b)=>{b.size>t.maxImageBytes||(r.set(m,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,c())};return{async get(m){const b=r.get(m);if(b&&l(b))return b.usedAt=n(),i.hits+=1,b.blob;b&&a(m);const v=o.get(m);if(v!==void 0)return v;i.loads+=1;const w=(async()=>{try{const C=await e.load(m);return C?d(m,C):i.failures+=1,C}catch{i.failures+=1;return}finally{o.delete(m)}})();return o.set(m,w),w},forget(m){a(m),o.delete(m)},configure(m){Object.assign(t,{maxBytes:m.maxBytes??t.maxBytes,maxImageBytes:m.maxImageBytes??t.maxImageBytes,ttlMs:m.ttlMs??t.ttlMs});for(const[b,v]of r)v.bytes>t.maxImageBytes&&a(b);c()},clear(){r.clear(),o.clear(),s=0},stats(){return{entries:r.size,bytes:s,...i}}}}var kp=["emcdn.ru","scr.emcdn.ru"];function xp(e){const t=String(e??"").trim();if(!t)return"";try{return new URL(t.includes("//")?t:`https://${t}`).hostname}catch{return t.split("/")[0].split(":")[0]}}function Mp(e,t){const n=(r,o)=>{const i=new Set(o?t:[]);for(const s of r){const a=xp(s);a&&i.add(a)}return[...i]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Lp(e){const t=e??{},n=t.isPlugin!==!0?kp:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ze};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:Mp(o.sourceHosts,n),maxBytes:o.maxBytes??Ze.maxBytes,maxImageBytes:o.maxImageBytes??Ze.maxImageBytes,ttlMs:o.ttlMs??Ze.ttlMs}}function Np(e){const t=fe(e),n=e.getInstance(ve),r=()=>Lp({...n?.get(),isPlugin:!0});let o=r();const i=Op({sourceHosts:()=>o.sourceHosts}),s=Dp({load:C=>i.load(C),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(z.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},l=t.onInit(()=>a()),c=n?.watch(()=>{const C=r(),y=JSON.stringify(C)!==JSON.stringify(o);o=C,s.configure(C),C.enabled||s.clear(),y&&t.isInited()&&a()}),d={asked:0,served:0,refused:0},m=[],b=(C,y)=>(d.refused+=1,m.push({url:C,reason:y}),m.length>20&&m.shift(),{refused:!0}),v=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...d},refusals:[...m],store:s.stats()})}),w=t.addListenerAsync(z.APPLICATION_CANVAS_IMAGE_GET,async C=>{const y=C?.url??"";if(d.asked+=1,!o.enabled||!y)return b(y,"disabled");if(!i.accepts(y))return b(y,"host");C.fresh&&s.forget(y);const S=await s.get(y);return S?(d.served+=1,{blob:S}):b(y,"load-failed")});e.getInstance(W)?.addDispose(()=>{l.dispose(),c?.dispose(),w.dispose(),s.clear(),delete v.__emmCanvasImages__})}var Fp=2e3;function Bp(e){const t=fe(e),n=new Map,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;clearTimeout(n.get(s));const a=new MessageChannel;let l=!1,c=!1;const d=b=>{b.data?.operationId==="em:port-ready"&&(l=!0,a.port1.removeEventListener("message",d),c&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",d),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const m=setTimeout(()=>{n.get(s)===m&&n.delete(s),!(l||!t.hasPort(s,a.port1))&&(Bt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),c=!0,t.holdPort(s))},Fp);n.set(s,m)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),i=t.onInit(()=>r());e.getInstance(W)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);i.dispose(),delete o.__emmCanvasPort__})}var jp=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Up(e){return jp.test(e)||e.indexOf("//")===0}function rn(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Hp(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Ci(e,t){const n=e==null||e===""?"./":String(e);if(Up(n))return rn(n);const r=t??Hp();if(!r)return rn(n);try{return rn(new URL(n,r).href)}catch{return rn(n)}}function $p(){return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.publicPath?Ci(window.__emailmaker__.publicPath):Ci("/")}var Vp=()=>"",qp=()=>"b63d7b8b";function Gp(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function nl(e){const t=e?"iframe-eblock":"iframe",n=Vp();if(n){const i=Gp(n,window.location).replace(/\/?$/,"/");return si(`${i}${t}.html`,Ft())}const r=qp(),o=`${$p().replace(/\/?$/,"/")}iframe/`;return si(`${o}${t}${r?`.${r}`:""}.html`,Ft())}var Ti="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Br(e){return/^file:/i.test(String(e||"").trim())}function Wp(e){return Br(e)?`${Ti} allow-same-origin`:Ti}var zp="em:module-body-ack";function Kp(e,t,n){try{const r=new URL("./",new URL(t,n)).href,o=new URL(e,r).href;return o.startsWith(r)?o:void 0}catch{return}}function Mo(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function Yp(e){const t=Mo(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function Xp(e,t){const n=Mo(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function Jp(e,t){const n=Mo(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),i=[r],s=[];for(;i.length>0;)for(const a of e[i.shift()]??[])o.has(a)||(o.add(a),s.push(a),i.push(a));return s}var Qp=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Zp(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&Qp.test(t[t.length-2])}async function eh(e,t){const n=Zp(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function th(e){const t=new Map,n=(r,o)=>{const i=Kp(r,e.canvasSrc,e.origin);if(!i)return;const s=t.get(i);if(s!==void 0)return s;const a=e.fetchBody(i,o);return t.set(i,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const i of r)n(i,o)},reset(){t.clear()},get size(){return t.size}}}var ke;function nh(e){try{return Br(new URL(e,window.location.href).href)}catch{return Br(window.location.href)}}function rl(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.preload?.canvasCrossOrigin===!0}var rh=()=>Promise.resolve(void 0);function ol(){const e=nl(!1);if(!nh(e)){if(!ke||ke.canvasSrc!==e){const t=rl(e)?eh:rh;ke={canvasSrc:e,store:th({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return ke.store}}async function oh(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const o=await r.json();t(Xp(o,e))}catch{}}function Lo(e){const t=ol();if(!t||!ke||ke.warmed||!rl(ke.canvasSrc))return;ke.warmed=!0;const{canvasSrc:n}=ke,r=Yp(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.C4wWAApZ.js"],"js/iframe.js":["js/elMarkupHelper.C4wWAApZ.js"],"js/darkreader.CLd5EML2.js":[],"js/elMarkupHelper.C4wWAApZ.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.Mun9CrLC.js":[]};o?t.warm(Jp(o,n),e):oh(n,i=>t.warm(i,e))}function ih(e){const t=ol();if(!t)return;Lo();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const i=r.source;i&&(i.postMessage({operationId:zp,for:o.result},"*"),t.take(o.data?.url??"").then(s=>{i.postMessage({operationId:o.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(W)?.addDispose(()=>{window.removeEventListener("message",n)})}var ut=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,sh=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,bt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Ai=/display:\s*none\s*!important/gi,ah=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,lh=/\s*height\s*:\s*100%\s*!important\s*;?/gi,ch=/height\s*:\s*100%\s*!important/i,dh=[".socialshare,",".advertisment,",".adHolder,",".adsbygoogle-noablate","#ab_adblock","#popmechanic-snippet","filter_ads_by_classname","clever-core-ads","--gn-ov-ad-height","pub_728x90.text-ad.textAd","html-load.com/player","content-loader.com/player",".adblock","#advblock","body { overflow: visible!important; }"];function uh(e){return Ai.lastIndex=0,(e.match(Ai)||[]).length}function il(e){const t=e.trim(),n=uh(t);if(n===0)return!1;if(t.includes(".advertisment,")&&t.includes(".adHolder,")&&(t.includes(".socialshare,")||n>=3||t.length>2e3))return!0;const r=dh.filter(o=>t.includes(o)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function fh(e){bt.lastIndex=0;for(const t of e.matchAll(bt))if(il(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function ph(e){let t=!1;return bt.lastIndex=0,{html:e.replace(bt,n=>il(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function hh(e){return ut.lastIndex=0,ut.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||fh(e)}function mh(e){if(!hh(e))return{html:e,found:!1};let t=!1,n=e;ut.lastIndex=0,ut.test(n)&&(ut.lastIndex=0,n=n.replace(ut,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(sh,""),t=!0);const r=ph(n);return n=r.html,t=t||r.found,{html:n,found:t}}function gh(e){return!e||!ch.test(e)?e:(bt.lastIndex=0,e.replace(bt,t=>t.replace(ah,(n,r,o,i)=>`${r}${o.replace(lh,"")}${i}`)))}function sl(e){const t=mh(e.replaceAll(`\r
1002
+ `)}function Cn(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function xt(e,t){return Ro(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function Yf(e,t,n){const{latest:r}=e,o=hn(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(i=>hn(i,r.html))?o?{revision:null,phase:"normal"}:{revision:Cn(t),phase:"timeout"}:o?{revision:xt(e),phase:"normal"}:hn(t.html,r.html)?{revision:Cn(t),phase:"found"}:{revision:xt(e),phase:"normal"}}function Xf({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:o=!1,readShownContent:i,onFacts:s,onLate:a,onError:l,pageLoadTs:c=Kf()}){const d=r??e;let m=null,b=!1,v=!1,w=0,C={emailId:e,historyLoaded:!1,isRecovering:!1},y=null;const S=new Promise(_=>{y=_}),A=_=>{C={...C,..._},s(C)};let B;const k=_=>{w+=1,A({applied:{phase:_,seq:w}})},P=()=>{m?.timer&&clearTimeout(m.timer),m=null},T=_=>{if(!v){if(y){const I=y;y=null,I(_),B=_.revision?_.phase:void 0;return}a(_)&&_.revision&&k(_.phase)}},x=()=>{if(!m||v)return;const _=m.phase==="fast",I=_?Vf:zf,F=_?Gf:Wf;m.timer=setTimeout(()=>{const j=m;if(!(!j||v)){if(j.attempts+=1,u(),_&&j.attempts>=F){const{pending:K}=j;Ye(d),A({isRecovering:!1}),T({revision:Cn(K),phase:"timeout"}),b=!0,j.phase="bg",j.attempts=0,x();return}if(!_&&j.attempts>=F){Ye(d),P(),A({isRecovering:!1}),b=!0;return}x()}},I),m.timer.unref?.()},R=_=>{m={phase:"fast",attempts:0,pending:_,timer:null},A({isRecovering:!0}),x()},h=_=>{if(v)return;if(A({historyLoaded:!0,latestRevisionAt:_.latestAt!==void 0&&Number.isFinite(_.latestAt)?_.latestAt:void 0}),n&&m){const j=xt(_,m.pending.sentAt);if(!j)return;const K=m.phase==="fast"?"found":"bg";Ye(d),P(),A({isRecovering:!1}),b=!0,T({revision:j,phase:K});return}if(b)return;const I=n?Bn(d):null,F=I&&(I.sentAt<c||!hn(I.html,i()))?I:null;if(F){if(o&&(F.baseRevisionId!==void 0||F.baseOpen)){Ye(d),b=!0,T(Yf(_,F,i()));return}const j=xt(_,F.sentAt);if(j){Ye(d),b=!0,T({revision:j,phase:"found"});return}if(o){if(Ye(d),b=!0,_.latestAt!==void 0&&_.latestAt>F.sentAt+5e3){T({revision:null,phase:"normal"});return}T({revision:Cn(F),phase:"timeout"});return}R(F);return}b=!0,T({revision:xt(_),phase:"normal"})},f=_=>{v||(l?.(_),C.historyLoaded||(A({historyLoaded:!1,latestRevisionAt:void 0}),M()),!m&&T({revision:null,phase:"normal"}))},u=()=>t(e).then(h).catch(f);let g,O=!1;const M=()=>{O||m||v||(O=!0,g=setTimeout(()=>{g=void 0,!v&&!C.historyLoaded&&u()},qf))};return u(),{verdict:()=>S,confirmVerdict(_){const I=B;B=void 0,_&&I!==void 0&&!v&&k(I)},dispose(){v=!0,g!==void 0&&(clearTimeout(g),g=void 0),P()}}}function Jf({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:o,wpId:i,readShownContent:s,onFacts:a}){let l=null;const c=Xf({emailId:o,readAutosave:d=>i?e.readAutosave(d,{wpId:i()}):e.readAutosave(d),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:s,onFacts:a,onLate:({revision:d,phase:m})=>{const b=yi(d);return l?.(b)??!1},onError:d=>{d instanceof Error&&d.message}});return{id:"recovery",load:()=>c.verdict().then(({revision:d})=>yi(d)),loaded(d){c.confirmVerdict(d)},watch(d){return l=d,()=>{l=null,c.dispose()}}}}var Qf=5e3,Zf=H("plugin.knownRevisions");function vt(e){return e.getOrCreateInstance(Zf,()=>new Map)}function ko(e,t,n,r){const o=n?.get(t)??[],i=o.filter(s=>s!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...o.length>Ba?{baseOpen:!0}:i.length?{baseHtmls:i}:{}}}var ep=H("plugin.uncertainWrites"),Ba=3;function Kt(e){return e.getOrCreateInstance(ep,()=>new Map)}function tp(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>Ba||e.set(t,[...r,n])}function ja(e,t){Mr(e,t)||!t.baseHtmls||Mr(e,{...t,baseHtmls:void 0,baseOpen:!0})}function Tn(e,t,n,r=!1){const o=Bn(e);!n||o?.sentAt!==t||!(r||o.baseOpen||o.baseHtmls)||Mr(e,{...o,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function Ua(e,t,n,r){(Bn(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||ja(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var np=/(?:Z|[+-]\d{2}:?\d{2})$/i;function rp(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",o=np.test(r)?Date.parse(r):NaN;return!Number.isFinite(o)||o>=t-Qf}function Ha(e,t,{pendingKey:n=s=>s,knownRevisions:r=new Map,uncertainWrites:o,synchronousHistory:i=!1}={}){return{readRevisions:(s,a,l)=>t.readRevisions(s,a,l),readRevision:(s,a,l)=>t.readRevision?t.readRevision(s,a,l):Promise.resolve(null),readAutosave:(s,a)=>t.readAutosave(s,a),async saveAutosave(s,a,l){const c=n(s),d=Date.now();ja(c,{sentAt:d,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...ko(r,c,o,a.html??"")});const m=await t.saveAutosave(s,a,l),b=m?.id;return rp(m,d)?Tn(c,d,b):b&&i&&(m.isAutosave===!0?Co(c,d):Tn(c,d,b,!0)),await e.saveAutosave(s,a),m}}}function op(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,o){const i=Date.now();n&&Ua(r,o,i,ko(n.knownRevisions,r,n.uncertainWrites,o.html??""));const s=await t.updateEmail(r,o);return n&&Tn(r,i,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,o),Co(r,i),s&&{...s,id:r}}}}var $a=H("CurrentUser"),Va={};function xo(e){return e.getOrCreateInstance($a,()=>Ee(Va))}function qa(e){return e?.getInstance($a)?.get()??Va}var Ga=H("HeadlessMode");function za(e){return e.getOrCreateInstance(Ga,()=>Ee(!1))}function ip(e){return e?.getInstance(Ga)?.get()??!1}var sp=H("HiddenMount");function ap(e){return e.getOrCreateInstance(sp,()=>Ee(!1))}function lp(e){if(!e)return!1;try{return!!ho(e).data?.act_as}catch{return!1}}function cp(e){return lp(e?.getInstance(Ws)?.get(pd.em_token))}function Wa(e){return e?.getInstance(ve)?.get()??{}}function Hn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function dp(e,t){return t.modeDefaults(Hn(e,t.fallbackMode))}function Ka(e,t){const n=Hn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Ya(e,t){const n=Hn(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function up(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function fp(e){return qc(e.map(t=>t?.resourceProxy))}function pp(e){return Bc(e.map(t=>t?.resourceProxyPolicy))}function hp(e){return Hc(e.map(t=>t?.backendProxy))}function mp(e){return Ks(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function gp(e,t){return[e.base,dp(e,t),e.profile,e.serverSide,Ka(e,t.fallbackMode),e.local,e.user,Ya(e,t.fallbackMode)]}function ir(e,t){const n=gp(e,t),r=Ks(n),o=up(n);o!==void 0&&(r.fileManager=o);const i=fp(n);i!==void 0&&(r.resourceProxy=i);const s=pp(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=hp(n);a!==void 0&&(r.backendProxy=a);const l=mp(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}function vp(e,t,n){const r=Ka(e,n),o=Ya(e,n);return Uc([o,e.user,r,e.serverSide],t)}var bp=1.5;function yp(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=bp*e.autosaveTimeoutMs?"none":"revision"}function Ep(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,i=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const l=h=>a!==void 0&&a.version===h.get().version?i()-a.failuresAtStart:0,c=h=>{const f=l(h);if(f<=0)return!1;const u=n().retryMaxAttempts??5;return!s()||f>u},d=()=>{const{autosaveTimeoutMs:h,retryIntervalMs:f}=n(),u=t();return u!==void 0&&l(u)>0&&f!==void 0&&f>0?f:h},m=h=>h.isNew()&&i()>=3,b=()=>{const h=t();if(!h||h.isDisposed()||c(h))return"none";const{latestRevisionAt:f,snapshotVersion:u,...g}=n(),O=Date.now(),M=yp({...g,isDirty:h.isDirty(),isNew:h.isNew(),isReady:h.isReady(),latestRevisionAgeMs:f!=null&&f<=O?O-f:void 0,isSnapshotSent:u!=null&&u===h.get().version});return M==="create"&&m(h)?"none":M},v=()=>{const h=t();if(!h||h.isDisposed()||m(h)||c(h)||n().isHeadless)return!1;if(!h.isDirty())return h.isNew();const{snapshotVersion:f}=n();return!(f!=null&&f===h.get().version)};let w,C=0,y=0,S,A,B,k=!1;const P=()=>{S=void 0;const h=t();if(!h||h.isDisposed())return;if(h.get().docId!==w){T();return}const f=b();f!=="none"&&a?.version!==h.get().version&&(a={version:h.get().version,failuresAtStart:i()}),f==="create"?r():f==="revision"?o():v()&&(w=h.get().docId,C=d(),y=i(),S=setTimeout(P,C))},T=()=>{const h=t();if(k||!h)return;const f=a?.version===h.get().version&&y!==i();S!==void 0&&(C!==d()||f)&&(clearTimeout(S),S=void 0),!(S!==void 0||b()==="none"&&!v())&&(w=h.get().docId,C=d(),y=i(),S=setTimeout(P,C))},x=h=>{const f=t();h.source==="user"?a=void 0:a&&f&&(a.version=f.get().version),h.source==="user"&&S!==void 0&&(clearTimeout(S),S=void 0),T()},R=()=>{const h=t();h!==A&&(B?.(),A=h,a=void 0,B=h?.subscribe(x),S!==void 0&&(clearTimeout(S),S=void 0))};return R(),T(),{refresh:()=>{k||(R(),T())},stop:()=>{k=!0,B?.(),B=void 0,A=void 0,S!==void 0&&(clearTimeout(S),S=void 0)}}}var Xa=H("documentSession.autosaveUiFacts"),Ja={isUserBusy:!1,saveContext:{}};function _p(e){return e.getOrCreateInstance(Xa,()=>Ee(Ja))}function Fr(e){return e?.getInstance(Xa)?.get()??Ja}function Qa(e){return Fr(e).saveContext.fallbackTitle||"Untitled email."}var wp=1e4,Sp=3e4;function Ip(e,t){const n=b=>{const v=e.getInstance(ve)?.layers?.(),w=v?vp(v,b):void 0;return typeof w=="number"&&w>=0?w:void 0};let r;const o=b=>{const{error:v,failures:w}=t.saveState();return Ta(v)?(r?.failures!==w&&(r={failures:w,saved:b??null}),r.saved===(b??null)):(r=void 0,!1)},i=()=>{const b=t.current(),v=b?.get().serverId??void 0,w=oe(t.sessionKey()),C=t.recoveryFacts(),y=C?.emailId===v?C:void 0,S=t.revisionFacts(),A=y?.latestRevisionAt,B=S?.lastRevisionAt,k=qa(e).profile;return{isInited:w||b?.get().attributes.is_inited===!0,isEnabled:!!k?.autosaves&&!cp(e)&&!o(b?.get().savedVersion),isHistoryLoaded:y?.historyLoaded===!0,isUserBusy:Fr(e).isUserBusy,isHeadless:ip(e),autosaveTimeoutMs:Wa(e).autosaveTimeout||wp,latestRevisionAt:A!==void 0||B!==void 0?Math.max(A??0,B??0):void 0,snapshotVersion:S?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Sp,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},s=()=>{const b=Fr(e).saveContext;return{...b,project:b.project??t.current()?.get().attributes.project,fallbackTitle:Qa(e)}},a=Ep({readDocument:()=>t.current(),readEnvironment:i,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>nf(t.saveState().error),onCreate:()=>{oe(t.sessionKey())||t.save("materialize",s())},onRevision:()=>{t.save("snapshot",{project:s().project})}}),l=t.subscribe(()=>{o(t.current()?.get().savedVersion),a.refresh()}),c=xo(e).watch(()=>a.refresh()),d=_p(e).watch(()=>a.refresh()),m=za(e).watch(()=>a.refresh());return()=>{l(),c.dispose(),d.dispose(),m.dispose(),a.stop()}}var Ii=12e3;function he(e){return e.getOrCreateInstance(wo,()=>{const t=xf({resolveAdapters:(r,o)=>Ap(r,e,o),resolveWritePort:()=>Za(e),resolveHistoryPort:r=>oe(r)?tl(e):el(e),resolveTerms:()=>Uf(e),canEdit:r=>ru(e,r),notifyBeforeSave:lu(e),awaitCanvasSynced:hu(e),savedEchoForm:r=>{const o=Ve(e);return o.toEditorForm(o.toOutputForm(r))},queuesOutsideWrites:r=>oe(r)&&(yu()||wt(e)),timeoutMs:Ii,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const i=Lf(o),s=Mf(o);Bt(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(i),network_failure:String(s)},level:i||s?"warning":"error"})},onTimeout:r=>{}}),n=Ip(e,t);return e.getInstance(z)?.addDispose(n),t})}function nt(e){return e?.getInstance(wo)}function Za(e){const t=Ff(e);return t?$n(e)?op(t,rt(e).email(e),wt(e)?{knownRevisions:vt(e),uncertainWrites:Kt(e)}:void 0):t:rt(e).email(e)}function Cp(e){return Fa(e)!==void 0||Ma(e)}function el(e){const t=Fa(e);return t?$n(e)?(ie("port:history:server-backed"),Ha(t,rt(e).history(e),{knownRevisions:vt(e),uncertainWrites:Kt(e),synchronousHistory:wt(e)})):(ie("port:history:integrator"),t):(ie("port:history:rest (порт не зарегистрирован)"),rt(e).history(e))}function tl(e){const t=Na(e);return t?$n(e)?(ie("port:block-history:server-backed"),Ha(t,rt(e).blockHistory(e),{pendingKey:Io,knownRevisions:vt(e),uncertainWrites:Kt(e),synchronousHistory:wt(e)})):(ie("port:block-history:integrator"),t):(ie("port:block-history:rest (порт не зарегистрирован)"),rt(e).blockHistory(e))}function Tp(e){return Na(e)!==void 0||Ma(e)}function $n(e){return ia(e)}function Ap({email:e,patch:t,serverId:n,key:r},o,i){const s=[];e?s.push({id:"rest",load:()=>Pa(e),required:!0}):n&&s.push(Nf(Za(o),n)),t&&s.push({id:"plugin",load:()=>Oa(t)});const a=oe(r);return gu(n)&&(a?Tp(o):Cp(o))&&s.push(Jf({port:a?tl(o):el(o),revisionServiceEnabled:$n(o),pendingKey:ga(n,a),historyIsSynchronous:wt(o),emailId:n,wpId:()=>i.readWpId(),readShownContent:()=>i.readShownContent(),onFacts:l=>i.publishRecoveryFacts(l)})),s}function Rp(e){const t=he(e),n=fe(e).addListener(W.APPLICATION_HAS_AMP,r=>{dt(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(z)?.addDispose(()=>n.dispose())}function Pp(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Op(e){const t=e.fetchImpl??((i,s)=>fetch(i,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=i=>{try{const s=new URL(i,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:o,async load(i){if(!o(i))return;const s=!r.has(i);r.add(i);try{const a=await t(i,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const l=await a.blob();return Pp(l)?l:void 0}catch{return}}}}var Ze={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Dp(e){const t={maxBytes:e.maxBytes??Ze.maxBytes,maxImageBytes:e.maxImageBytes??Ze.maxImageBytes,ttlMs:e.ttlMs??Ze.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,i={hits:0,loads:0,failures:0};let s=0;const a=m=>{const b=r.get(m);b&&(s-=b.bytes,r.delete(m))},l=m=>t.ttlMs<=0||n()-m.storedAt<t.ttlMs,c=()=>{if(s<=t.maxBytes)return;const m=[...r.entries()].sort((b,v)=>b[1].usedAt-v[1].usedAt);for(const[b]of m){if(s<=t.maxBytes)return;a(b)}},d=(m,b)=>{b.size>t.maxImageBytes||(r.set(m,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,c())};return{async get(m){const b=r.get(m);if(b&&l(b))return b.usedAt=n(),i.hits+=1,b.blob;b&&a(m);const v=o.get(m);if(v!==void 0)return v;i.loads+=1;const w=(async()=>{try{const C=await e.load(m);return C?d(m,C):i.failures+=1,C}catch{i.failures+=1;return}finally{o.delete(m)}})();return o.set(m,w),w},forget(m){a(m),o.delete(m)},configure(m){Object.assign(t,{maxBytes:m.maxBytes??t.maxBytes,maxImageBytes:m.maxImageBytes??t.maxImageBytes,ttlMs:m.ttlMs??t.ttlMs});for(const[b,v]of r)v.bytes>t.maxImageBytes&&a(b);c()},clear(){r.clear(),o.clear(),s=0},stats(){return{entries:r.size,bytes:s,...i}}}}var kp=["emcdn.ru","scr.emcdn.ru"];function xp(e){const t=String(e??"").trim();if(!t)return"";try{return new URL(t.includes("//")?t:`https://${t}`).hostname}catch{return t.split("/")[0].split(":")[0]}}function Mp(e,t){const n=(r,o)=>{const i=new Set(o?t:[]);for(const s of r){const a=xp(s);a&&i.add(a)}return[...i]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Lp(e){const t=e??{},n=t.isPlugin!==!0?kp:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ze};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:Mp(o.sourceHosts,n),maxBytes:o.maxBytes??Ze.maxBytes,maxImageBytes:o.maxImageBytes??Ze.maxImageBytes,ttlMs:o.ttlMs??Ze.ttlMs}}function Np(e){const t=fe(e),n=e.getInstance(ve),r=()=>Lp({...n?.get(),isPlugin:!0});let o=r();const i=Op({sourceHosts:()=>o.sourceHosts}),s=Dp({load:C=>i.load(C),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(W.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},l=t.onInit(()=>a()),c=n?.watch(()=>{const C=r(),y=JSON.stringify(C)!==JSON.stringify(o);o=C,s.configure(C),C.enabled||s.clear(),y&&t.isInited()&&a()}),d={asked:0,served:0,refused:0},m=[],b=(C,y)=>(d.refused+=1,m.push({url:C,reason:y}),m.length>20&&m.shift(),{refused:!0}),v=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...d},refusals:[...m],store:s.stats()})}),w=t.addListenerAsync(W.APPLICATION_CANVAS_IMAGE_GET,async C=>{const y=C?.url??"";if(d.asked+=1,!o.enabled||!y)return b(y,"disabled");if(!i.accepts(y))return b(y,"host");C.fresh&&s.forget(y);const S=await s.get(y);return S?(d.served+=1,{blob:S}):b(y,"load-failed")});e.getInstance(z)?.addDispose(()=>{l.dispose(),c?.dispose(),w.dispose(),s.clear(),delete v.__emmCanvasImages__})}var Fp=2e3;function Bp(e){const t=fe(e),n=new Map,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;clearTimeout(n.get(s));const a=new MessageChannel;let l=!1,c=!1;const d=b=>{b.data?.operationId==="em:port-ready"&&(l=!0,a.port1.removeEventListener("message",d),c&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",d),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const m=setTimeout(()=>{n.get(s)===m&&n.delete(s),!(l||!t.hasPort(s,a.port1))&&(Bt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),c=!0,t.holdPort(s))},Fp);n.set(s,m)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),i=t.onInit(()=>r());e.getInstance(z)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);i.dispose(),delete o.__emmCanvasPort__})}var jp=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Up(e){return jp.test(e)||e.indexOf("//")===0}function rn(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Hp(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Ci(e,t){const n=e==null||e===""?"./":String(e);if(Up(n))return rn(n);const r=t??Hp();if(!r)return rn(n);try{return rn(new URL(n,r).href)}catch{return rn(n)}}function $p(){return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.publicPath?Ci(window.__emailmaker__.publicPath):Ci("/")}var Vp=()=>"",qp=()=>"a4e11bd0";function Gp(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function nl(e){const t=e?"iframe-eblock":"iframe",n=Vp();if(n){const i=Gp(n,window.location).replace(/\/?$/,"/");return si(`${i}${t}.html`,Ft())}const r=qp(),o=`${$p().replace(/\/?$/,"/")}iframe/`;return si(`${o}${t}${r?`.${r}`:""}.html`,Ft())}var Ti="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Br(e){return/^file:/i.test(String(e||"").trim())}function zp(e){return Br(e)?`${Ti} allow-same-origin`:Ti}var Wp="em:module-body-ack";function Kp(e,t,n){try{const r=new URL("./",new URL(t,n)).href,o=new URL(e,r).href;return o.startsWith(r)?o:void 0}catch{return}}function Mo(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function Yp(e){const t=Mo(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function Xp(e,t){const n=Mo(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function Jp(e,t){const n=Mo(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),i=[r],s=[];for(;i.length>0;)for(const a of e[i.shift()]??[])o.has(a)||(o.add(a),s.push(a),i.push(a));return s}var Qp=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Zp(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&Qp.test(t[t.length-2])}async function eh(e,t){const n=Zp(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function th(e){const t=new Map,n=(r,o)=>{const i=Kp(r,e.canvasSrc,e.origin);if(!i)return;const s=t.get(i);if(s!==void 0)return s;const a=e.fetchBody(i,o);return t.set(i,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const i of r)n(i,o)},reset(){t.clear()},get size(){return t.size}}}var ke;function nh(e){try{return Br(new URL(e,window.location.href).href)}catch{return Br(window.location.href)}}function rl(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.preload?.canvasCrossOrigin===!0}var rh=()=>Promise.resolve(void 0);function ol(){const e=nl(!1);if(!nh(e)){if(!ke||ke.canvasSrc!==e){const t=rl(e)?eh:rh;ke={canvasSrc:e,store:th({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return ke.store}}async function oh(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const o=await r.json();t(Xp(o,e))}catch{}}function Lo(e){const t=ol();if(!t||!ke||ke.warmed||!rl(ke.canvasSrc))return;ke.warmed=!0;const{canvasSrc:n}=ke,r=Yp(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.Dc_IFMml.js"],"js/iframe.js":["js/elMarkupHelper.Dc_IFMml.js"],"js/darkreader.CLd5EML2.js":[],"js/elMarkupHelper.Dc_IFMml.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.Mun9CrLC.js":[]};o?t.warm(Jp(o,n),e):oh(n,i=>t.warm(i,e))}function ih(e){const t=ol();if(!t)return;Lo();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const i=r.source;i&&(i.postMessage({operationId:Wp,for:o.result},"*"),t.take(o.data?.url??"").then(s=>{i.postMessage({operationId:o.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(z)?.addDispose(()=>{window.removeEventListener("message",n)})}var ut=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,sh=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,bt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Ai=/display:\s*none\s*!important/gi,ah=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,lh=/\s*height\s*:\s*100%\s*!important\s*;?/gi,ch=/height\s*:\s*100%\s*!important/i,dh=[".socialshare,",".advertisment,",".adHolder,",".adsbygoogle-noablate","#ab_adblock","#popmechanic-snippet","filter_ads_by_classname","clever-core-ads","--gn-ov-ad-height","pub_728x90.text-ad.textAd","html-load.com/player","content-loader.com/player",".adblock","#advblock","body { overflow: visible!important; }"];function uh(e){return Ai.lastIndex=0,(e.match(Ai)||[]).length}function il(e){const t=e.trim(),n=uh(t);if(n===0)return!1;if(t.includes(".advertisment,")&&t.includes(".adHolder,")&&(t.includes(".socialshare,")||n>=3||t.length>2e3))return!0;const r=dh.filter(o=>t.includes(o)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function fh(e){bt.lastIndex=0;for(const t of e.matchAll(bt))if(il(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function ph(e){let t=!1;return bt.lastIndex=0,{html:e.replace(bt,n=>il(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function hh(e){return ut.lastIndex=0,ut.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||fh(e)}function mh(e){if(!hh(e))return{html:e,found:!1};let t=!1,n=e;ut.lastIndex=0,ut.test(n)&&(ut.lastIndex=0,n=n.replace(ut,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(sh,""),t=!0);const r=ph(n);return n=r.html,t=t||r.found,{html:n,found:t}}function gh(e){return!e||!ch.test(e)?e:(bt.lastIndex=0,e.replace(bt,t=>t.replace(ah,(n,r,o,i)=>`${r}${o.replace(lh,"")}${i}`)))}function sl(e){const t=mh(e.replaceAll(`\r
1003
1003
  `,`
1004
- `));return{html:gh(t.html),hasBrowserExtensionArtifacts:t.found}}function jt(e){return e?.getContent()??""}function al(e,t){e?.mutate({content:To(t)},{source:"remote"})}function Vn(e){return H(e)}function pe(e,t){return e.getOrCreateInstance(t,()=>new Ue)}function te(e,t){return e.getOrCreateInstance(t,()=>new Ue).event}function An(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var vh=class extends Error{label;timeoutMs;constructor(e){super(`[sandbox:ready] iframe handshake timed out after ${e}ms`),this.name="SandboxReadyTimeoutError",this.label="sandbox:ready",this.timeoutMs=e}};function bh(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.isInited=="function"&&typeof t.getTarget=="function"&&typeof t.onInit=="function"}function yh(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(ne(n),new Promise((r,o)=>{let i=!1,s,a;const l=d=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",c),d())},c=()=>{l(()=>o(_e(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>o(new vh(t)))},t)),n?.addEventListener("abort",c)}))}var Eh=class extends Error{label;timeoutMs;constructor(e,t){super(`[${e}] timed out after ${t}ms`),this.name="OperationTimeoutError",this.label=e,this.timeoutMs=t}};function _h(e,t,n){return t<=0?e:new Promise((r,o)=>{let i=!1,s;const a=l=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{a(()=>o(new Eh(n,t)))},t),e.then(l=>{a(()=>r(l))},l=>{a(()=>o(l))})})}var wh=2,At=Symbol("sandbox:frame-replaced");function Ri(e){return e===At}function Xe(e,t,n,r,o,i,s){const a=`sandbox:${t}`,l=i?.getSandboxTimeoutMs(t)??So[t],c=()=>{let w=_h(e.sendAsync(n,r),l,a);return w=En(w,i?.signal),Je(a,w,o)};if(t==="INIT_START"&&bh(e)){const w=i?.getSandboxReadyTimeoutMs()??2e4,C=e,y=S=>{const A=yh(C,w,i?.signal);return Je("sandbox:INIT_START:ready-wait",A,o).then(()=>{if(!s||S<=0)return c();const B=s.getGeneration();let k;const P=new Promise((x,R)=>{k=s.onChange(()=>{s.getGeneration()!==B&&R(At)})}),T=c();return T.catch(()=>{}),Promise.race([T,P]).finally(()=>k?.()).catch(x=>{if(x!==At)throw x;return{...o},y(S-1)})})};return y(wh)}if(!s)return c();const d=s.getGeneration();let m;const b=new Promise((w,C)=>{m=s.onChange(()=>{s.getGeneration()!==d&&C(At)})}),v=c();return v.catch(()=>{}),Promise.race([v,b]).finally(()=>m?.()).catch(w=>{throw w===At&&{...o},w})}var ll="self-init:";function Sh(e){return e.startsWith(ll)}function No(e,t){const n=e.getActiveShowRequest();return Sh(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Ih(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let i="",s;const a=w=>{s={target:e.readTarget?.(),docId:w}},l=()=>e.readDocument()?jt(e.readDocument()):i,c=()=>Ve(e.container).editorPolicy,d=()=>e.readEmail(),m=()=>{const w=d();return{...w,id:e.isTemplate()||w.isNew?void 0:w.id,html:l()}};let b=!1;const v={readContent:l,publicEmail:m,sendInitStart:()=>Xe(n,"INIT_START",z.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>Xe(n,"INITED",z.SANDBOX_INITED,{guid:d().renderGuid},void 0,r(),o()),async sendContent(){const w=d(),{html:C,hasBrowserExtensionArtifacts:y}=sl(w?.html||"");y&&e.events.browserExtensionDetected(),al(e.readDocument(),C),i=C,a(w.renderGuid),await Xe(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,An(l(),w.renderGuid,c(),e.readDocument()?.get().version),{guid:w.renderGuid,emailId:w.id??null},r(),o())},refreshContent:()=>(a(d().renderGuid),Xe(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,An(l(),d().renderGuid,c(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const w=d();if(w.preheader!==void 0)return Xe(n,"PREHEADER",z.SANDBOX_PREHEADER_UPDATE,{value:w.preheader,guid:w.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const w=d();if(w.subject!==void 0)return Xe(n,"SUBJECT",z.SANDBOX_SUBJECT_UPDATE,{value:w.subject,guid:w.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:w=>e.showFilled?.(w),noteFilled:(w,C)=>e.noteFilled?.(w,C),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(m()),fireInit(w,C){if(!No(t(),w)){t().getActiveShowRequest()?.showId;return}const y=d();y.id,y.renderGuid,t().completeShow(w);const S=e.readDocument();gt(S,{is_inited:!0},{source:"system"});const A=()=>{const k=m();C&&(k.reset=!0);const P=e.events.inited(k);return C||(b&&v.fireEmailChanged(),b=!0),P};if(!S||S.isReady())return A();const{docId:B}=S.get();return S.whenReady().then(()=>e.readDocument()?.get().docId===B?A():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(m())},fireContentChanged(){e.events.contentChanged(l())}};return v}var Ch=class extends Error{showId;constructor(e,t){super(`[emailmaker] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},Th=class{_activeRequest=null;_pending=new Map;_listeners=new Set;getActiveShowRequest(){return this._activeRequest}onShowRequested(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}requestShow(e,t,n){return this._rejectPending(_e("Superseded by newer show()")),n.aborted?Promise.reject(_e(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const i=setTimeout(()=>{this._settle(e.showId,()=>{o(new Ch(e.showId,t))})},t);i.unref?.();const s=()=>{this._settle(e.showId,()=>{o(_e(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(i),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:i,dispose:a});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Ah(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Rh(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=da(e),n=ua(e),r=iu(e.sandbox);t<n+r}var cl=class{_controller=new AbortController;_externalSignalDisposable=new ge;_sessionChangeListeners=new Set;_showRegistry=new Th;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return da(this._timeouts)}getSandboxTimeoutMs(e){return ca(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return ua(this._timeouts)}bumpGeneration(){this._generation+=1}getActiveShowRequest(){return this._showRegistry.getActiveShowRequest()}onShowRequested(e){return this._showRegistry.onShowRequested(e)}requestShow(e){return this._showRegistry.requestShow(e,this.contentReadyTimeoutMs,this._controller.signal)}completeShow(e){this._showRegistry.completeShow(e)}hasPendingShow(e){return this._showRegistry.hasPendingShow(e)}failShow(e,t){this._showRegistry.failShow(e,t)}rejectAllPendingShows(e){this._showRegistry.rejectAll(e)}onSessionReplaced(e){return this._sessionChangeListeners.add(e),()=>{this._sessionChangeListeners.delete(e)}}configure(e){e.timeouts!==void 0&&(this._timeouts=Ah(this._timeouts,e.timeouts),Rh(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ge,this._linkExternalSignal(e)}abort(e){const t=e??_e("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ge}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ge,this._showRegistry.rejectAll(_e("Init session replaced")),this._controller.signal.aborted||this._controller.abort(_e("Init session replaced")),this._controller=new AbortController,this._emitSessionReplaced()}_emitSessionReplaced(){for(const e of this._sessionChangeListeners)e()}_linkExternalSignal(e){if(!e)return;if(e.aborted){this._controller.signal.aborted||(this._controller.abort(e.reason??_e()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??_e()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Fo=(()=>{const e=new cl;return e.configure({}),e})();function ot(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function Ge(e){return!e||e==="none"}function Ph(e){const t=e.contain??"",n=e.willChange??"";return!Ge(e.transform)||!Ge(e.perspective)||!Ge(e.filter)||!Ge(e.backdropFilter)||!Ge(e.translate)||!Ge(e.rotate)||!Ge(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Pi(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function Oh(e){const t=[],n=document.documentElement,r=Pi(getComputedStyle(n)),o=r.x||r.y;let i="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(i=s);for(let a=ot(e);a&&a!==n;a=ot(a)){const l=getComputedStyle(a),c=i==="none"||Ph(l)||i==="absolute"&&!!l.position&&l.position!=="static",d=a===document.body&&!o;if(c){i="none";const m=d?{x:!1,y:!1}:Pi(l);(m.x||m.y)&&t.push({node:a,...m})}(l.position==="absolute"||l.position==="fixed")&&(i==="none"||l.position==="fixed")&&(i=l.position==="fixed"?"fixed":"absolute")}return t}function dl(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function on(e){return Number.parseFloat(e)||0}function jr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=dl(e),o=on(n.borderLeftWidth),i=on(n.borderTopWidth),s=on(n.borderRightWidth),a=on(n.borderBottomWidth),l=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-s):0,c=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-i-a):0;return{left:t.left+o*r.x,top:t.top+i*r.y,right:t.right-(s+l)*r.x,bottom:t.bottom-(a+c)*r.y}}function Dh(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(i,s,a)=>{s&&(r.left=Math.max(r.left,i.left),r.right=Math.min(r.right,i.right)),a&&(r.top=Math.max(r.top,i.top),r.bottom=Math.min(r.bottom,i.bottom))};return t.forEach(i=>o(jr(i.node),i.x,i.y)),n&&o(jr(n),!0,!0),r}var Ur={originX:0,originY:0,scaleX:1,scaleY:1};function Rn(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function ul(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,o=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*o,scaleX:r,scaleY:o}}function fl(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var kh=1e3;function xh(e){const{slot:t,own:n}=e;let r,o=0,i=!1;const s=()=>{if(r=void 0,!i){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(s))}},a=()=>{!i&&r===void 0&&(r=window.requestAnimationFrame(s))},l=()=>{o=performance.now()+kh,a()},c=[window],d=[document.documentElement];for(let y=t;y;y=ot(y)){const S=y.getRootNode();S instanceof ShadowRoot&&!c.includes(S)&&(c.push(S),d.push(S))}const m=[["scroll",a],["load",a],["transitionrun",l],["transitionend",a],["transitioncancel",a],["animationstart",l],["animationend",a],["animationcancel",a]];c.forEach(y=>m.forEach(([S,A])=>y.addEventListener(S,A,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const b=typeof MutationObserver=="function"?new MutationObserver(y=>{y.some(S=>!n.contains(S.target))&&a()}):void 0;d.forEach(y=>b?.observe(y,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let v;try{if(typeof ResizeObserver=="function"){const y=new ResizeObserver(a);typeof y.observe=="function"&&(v=y)}}catch{v=void 0}let w=[];return{schedule:a,observe:y=>{!v||y.length===w.length&&y.every((S,A)=>S===w[A])||(v.disconnect(),w=y,y.forEach(S=>v?.observe(S)))},dispose(){i=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),c.forEach(y=>m.forEach(([S,A])=>y.removeEventListener(S,A,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),b?.disconnect(),v?.disconnect()}}}var Mh="pluginZoom",Lh=/^(?:ant|vscode|monaco|docs)-/;function Nh(e){return Lh.test(e)}function Fh(){const e="em".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var Bh=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function jh(){return Bh}var Uh=new Set;function Hh(e,t,n=Uh){return e.startsWith(`${t}-`)?!1:!Nh(e)&&!n.has(e)}function $h(e,t){return`--${t}-${e}`}function pl(e){const t=Fh();return Hh(e,t,jh())?$h(e,t):`--${e}`}function Vh(e,t){const n=pl(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function hl(e,t){return Vh(e,t)}var ml=300,Oi=15e3,qh=5e3,Di="em-canvas-busy-style";function Gh(){if(document.getElementById(Di))return;const e=document.createElement("style");e.id=Di,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var Wh="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function zh(e){const t=hl("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(pl("colorPrimary")).trim()||t}function gl(e){Gh();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",Wh),n.appendChild(r);const o=document.createElement("span");return o.setAttribute("role","img"),o.setAttribute("aria-label","loading"),o.setAttribute("style",`display:inline-flex;color:${zh(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function Kh(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),i=Math.min(r.right,e.right,n.width),s=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return i<=o||a<=s?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+i)/2-e.left,y:(s+a)/2-e.top}}function Yh(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const o={left:n.left,top:n.top,right:n.right,bottom:n.bottom},i=r.getBoundingClientRect();if(i.width>0&&!fl({left:i.left,top:i.top,width:i.width,height:i.height},o)){const s=Rn(o,ul(i,Rn(o,Ur),Ur));Object.assign(r.style,{left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const s=Kh(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${s.x}px`,top:`${s.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(gl(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function sr(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(gl(e))},ml);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var Xh=8e3;function Jh(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function Qh(e,t){for(let n=ot(e);n;n=ot(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",i=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>at(s)>0);if(o&&i)return n;if(n===t)return null}return null}function at(e){return Number.parseFloat(e)||0}function sn(e,t){return Math.abs(e-t)<=1}function Zh(e){const t=getComputedStyle(e),n=at(t.borderTopWidth),r=at(t.borderRightWidth),o=at(t.borderBottomWidth),i=at(t.borderLeftWidth),s=(a,l,c)=>Math.max(0,at(a)-Math.max(l,c));return{...jr(e),radii:[s(t.borderTopLeftRadius,n,i),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,o,r),s(t.borderBottomLeftRadius,o,i)]}}function em(e,t){const n=sn(t.top,e.top),r=sn(t.bottom,e.bottom),o=sn(t.left,e.left),i=sn(t.right,e.right),s=[n&&o?e.radii[0]:0,n&&i?e.radii[1]:0,r&&i?e.radii[2]:0,r&&o?e.radii[3]:0];return s.every(a=>a===0)?"":s.map(a=>`${a}px`).join(" ")}function tm(e,t,n,r,o,i){const s=n.readyTimeoutMs??Xh,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden",a.style.setProperty("zoom",hl(Mh,"1"));const l=n.resolveSrc(e),c=document.createElement("iframe");c.setAttribute("sandbox",n.resolveSandbox(l)),c.setAttribute("allow","clipboard-read; clipboard-write"),c.setAttribute("title","Email content"),c.style.width="100%",c.style.border="0",c.style.display="block",c.style.minHeight="600px",c.src=l,a.appendChild(c),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(c);const d=new ge;let m=!1,b,v=!1,w,C,y,S;const A=()=>{clearTimeout(S),S=setTimeout(()=>{v||(v=!0,C?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},B=()=>m?(y=Promise.resolve(),v=!0,y):(v=!1,y=new Promise((p,E)=>{w=p,C=E}),A(),y),k=()=>{if(clearTimeout(S),m=!0,v){y=Promise.resolve();return}v=!0,n.mark?.("loaded"),w?.()};c.addEventListener("load",k),d.addDispose(()=>{clearTimeout(S),c.removeEventListener("load",k)});let P;const T=()=>{P??=n.bindResizer?.(c)},x=()=>{P?.dispose(),P=void 0};let R=null,h=null,f,u=Ur,g="",O="",M=0;const _=p=>{const E=JSON.stringify(p);return E===g?!1:(g=E,a.style.visibility=p.visibility,a.style.left=`${p.css.left}px`,a.style.top=`${p.css.top}px`,a.style.width=`${p.css.width}px`,a.style.height=`${p.css.height}px`,a.style.borderRadius=p.radius,c.style.width=p.elementWidth>0?`${p.elementWidth}px`:"100%",c.style.transform=p.shiftX!==0?`translate(${p.shiftX}px, ${p.shiftY}px)`:`translateY(${p.shiftY}px)`,!0)};let I=!1;const F=()=>{if(!R)return g="",a.style.visibility="hidden",c.removeAttribute("id"),!1;n.elementId&&(c.id=n.elementId);const p=R.getBoundingClientRect(),E=Oh(R),D=h?.isConnected?h:null;f?.observe([R,c,...E.map(le=>le.node),...D?[D]:[]]);const N=Dh(p,E,D),U=Math.max(0,N.right-N.left),Y=Math.max(0,N.bottom-N.top),q=getComputedStyle(R).visibility==="visible",G=U<=0||Y<=0,ee=G?{left:N.left,top:N.top,right:N.left,bottom:N.top}:N,L=G?null:Qh(R,D??E[0]?.node??null),Q=L?em(Zh(L),ee):"",Z=le=>_({visibility:q&&!I?"":"hidden",css:Rn(ee,le),elementWidth:p.width/le.scaleX,shiftX:(p.left-ee.left)/le.scaleX,shiftY:(p.top-ee.top)/le.scaleY,radius:Q});let re=Z(u);if(!G){const le=a.getBoundingClientRect();le.width>0&&!fl({left:le.left,top:le.top,width:le.width,height:le.height},ee)&&(u=ul(le,Rn(ee,u),u),re=Z(u)||re)}return re},j=()=>{if(!R)return!1;let p=F();const E=c.getBoundingClientRect().height;E>0&&E!==M&&(M=E,R.style.height=`${E/dl(R).y}px`,p=!0);const D=getComputedStyle(R).pointerEvents;return D!==O&&(O=D,a.style.pointerEvents=D),p},K=()=>{f?.dispose(),f=void 0},de=p=>{f=xh({slot:p,own:a,measure:j,onDetached:K})};let se=[];const X=(p,E)=>{if(h=E,p&&se.length>0){const D=se;se=[],D.forEach(N=>N())}if(p===R){p&&!f&&de(p),j();return}if(K(),R&&R.style.removeProperty("height"),g="",M=0,O="",R=p,!p){F(),x();return}n.onShown?.(c),de(p),j(),T()};d.addDispose(K);const J=p=>{m=!1,b=void 0,i?.(),p&&n.onReload?.(c);let E;v||y===void 0?E=B():(A(),E=y);try{c.contentWindow?.location.reload()}catch{c.src=l}return E};return{element:c,ready(){return y??B()},reload:()=>J(!0),reloadQuietly:()=>J(!1),followReload:()=>{b=void 0,i?.(),n.onReload?.(c)},moveTo(p){if(a.parentNode===p)return y??B();m=!1,b=void 0,i?.();let E;return v||y===void 0?E=B():(A(),E=y),p.appendChild(a),n.onReload?.(c),g="",f?.schedule(),E},get shown(){return R!==null},get slot(){return R},whenShown(){return R!==null?Promise.resolve():new Promise(p=>{se.push(p)})},get filled(){return b},noteFilled(p){b=p},alignTo(p,E){X(p,E??null)},hold(p){I!==p&&(I=p,F())},scrollBy(p,E){let D=p,N=E;for(let U=R?ot(R):null;U;U=ot(U)){if(Math.abs(D)<1&&Math.abs(N)<1)return;const Y=getComputedStyle(U);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&U.scrollHeight>U.clientHeight){const q=U.scrollTop,G=U.scrollLeft;U.scrollBy({left:D,top:N,behavior:"instant"}),D-=U.scrollLeft-G,N-=U.scrollTop-q}}(Math.abs(D)>=1||Math.abs(N)>=1)&&window.scrollBy({left:D,top:N,behavior:"instant"})},resize(){P?.resize()},dispose(){X(null,null),x(),d.dispose(),a.remove()}}}function nm(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(u,g)=>u==="email"?`email:${g??n}`:u,i=new Map;let s,a=[],l=!1,c,d,m=!1,b,v,w="shown",C=0,y,S,A;const B=u=>d!==void 0&&u.filled!==void 0&&u.filled!==d,k=()=>{y=void 0;const u=b;!m||!u||d===void 0||S===d||!B(u)||(S=d,e.onForeignDocument?.({wanted:d,filled:u.filled,role:w,heldMs:Date.now()-C}))},P=()=>{m=!1,b=void 0,v=void 0,clearTimeout(y),y=void 0},T=(u,g)=>{const O=i.get("email"),M=O?.slot??null;return u&&M&&B(u)?(u.alignTo(null),m||(m=!0,C=Date.now(),y=setTimeout(k,qh)),w=g,b=u,!(s!==void 0||l)&&v!==u&&(v=u,e.onShown?.(u.element)),!c&&!s&&(c=sr(M)),!1):(m&&(P(),c?.remove(),c=void 0),u?.alignTo(M,O?.clip??null),!0)},x=()=>{m&&!l&&T(t.get(o("email")),"shown")},R=()=>{a.forEach(u=>clearTimeout(u)),a=[],s?.remove(),s=void 0,c?.remove(),c=void 0,(l||m)&&(l=!1,T(t.get(o("email")),"shown"))},h=(u,g,O)=>{const M=o(u,g),_=t.get(M);if(_)return _;const I=e.resolveMount();if(!I)return Jh();const F=tm(u,I,e,u==="email"?g??n:void 0,O,u==="email"?()=>x():void 0);return t.set(M,F),F},f={get:u=>h(u),current:u=>h(u),peek:u=>t.get(o(u)),spare:()=>t.get(o("email",r())),ensureSpare:()=>h("email",r(),!0),promote(){const u=t.get(o("email",r()));if(!u)return;const g=t.get(o("email"));n=r(),A=void 0,T(u,"spare"),g?.alignTo(null)},alignSurface(u,g,O){const M=i.get(u);if(i.set(u,{slot:g,clip:O??null}),u==="email"&&l){c?.remove(),c=g?sr(g):void 0;return}const _=g?h(u):t.get(o(u));if(u!=="email"){_?.alignTo(g,O??null);return}if(!g){A=M?.slot&&_?.shown?{slot:M.slot,handle:_}:void 0,m&&(P(),c?.remove(),c=void 0),_?.alignTo(null);return}const I=A?.slot===g&&A.handle===_;if(A=void 0,M?.slot===g&&_?.shown||I){_?.alignTo(g,O??null);return}T(_,"shown")},want(u){d=u,u!==void 0&&x()},noteFilled(u,g){const O=f.byWindow(u);O&&(O.noteFilled(g),O===t.get(o("email"))&&x())},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const g of t.values())if(g.element.contentWindow===u)return g}},busy(u){if(R(),!u)return;if(!f.visible()){l=!0,c?.remove(),c=void 0;const M=i.get("email");M?.slot&&(c=sr(M.slot)),a=[setTimeout(R,Oi)];return}const g=e.resolveMount();if(!g)return;const O=Yh(g,()=>f.visible()?.element.parentElement?.getBoundingClientRect()??null);s=O,a=[setTimeout(()=>O.showSpinner(),ml),setTimeout(R,Oi)]},remount(u){R();const g=o("email");t.forEach((O,M)=>{if(M===g){O.moveTo(u).catch(()=>{});return}O.dispose(),t.delete(M)})},dispose(){d=void 0,l=!1,P(),A=void 0,R(),t.forEach(u=>u.dispose()),t.clear(),i.clear(),n="a",d=void 0,S=void 0}};return f}var rm=H("canvas.resizerBinder"),Hr=H("canvas.service"),om={created:me.canvasCreated,loaded:me.canvasLoaded},vl=new WeakMap;function $r(e){return vl.get(e)??0}function im(e,t){if(e.getInstance(Hr))return;const n=nm({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:Wp,elementId:t.elementId,bindResizer:o=>e.getInstance(rm)?.(o),onCreated:o=>Mt(e,o,"fresh"),onReload:o=>{vl.set(o,$r(o)+1),Mt(e,o,"fresh")},onShown:o=>{const i=n.byWindow(fe(e).getTarget());i&&i.element!==o&&ki(i.element)===ki(o)||Mt(e,o,"switch")},mark:o=>t.mark?.(om[o]),onForeignDocument:o=>{({...o},Eu("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:o.role},contexts:{canvasIdentity:{...o,path:window.location.pathname}}}))}}),r=fe(e).addListener(z.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(Hr,n),e.getInstance(W)?.addDispose(()=>{r.dispose(),n.dispose()})}function ki(e){return e.parentElement?.dataset.canvasHost}function Mt(e,t,n){const r=fe(e),o=t.contentWindow;if(!o)return;const i=r.getTarget()===o;i&&n==="switch"||(n==="fresh"&&(r.forget(o),i&&r.setTarget(void 0)),r.setTarget(o),cu(r))}function sm(e,t){Mt(e,t,"promote")}function am(e,t){Mt(e,t,"switch")}function lm(e,t){const n=t.contentWindow;n&&fe(e).greet(n)}function bl(e,t){const n=t.contentWindow;n&&fe(e).forget(n)}function cm(e,t){const n=ue(e)?.byWindow(t)?.element;if(!n)return;const r=$r(n);return()=>$r(n)!==r}function ue(e){return e.getInstance(Hr)}function yl({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:i}){if(!r)return;const s={id:o??void 0,renderGuid:n,showId:i?.id,isNew:o==null,showToken:i?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function qn(e){return{...yl({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function mn(e){const t=he(e),n=t.current();if(!n||!oe(t.sessionKey()))return;const r=qn(n),o=n.isDirty();pe(e,$.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function dm(e){const t=he(e);return!t.current()||!oe(t.sessionKey())?!1:(mn(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function um(e){const t=he(e),n=fe(e),r=()=>e.getInstance(Pe)??Fo;let o,i,s=!1,a=!1,l,c;const d=O=>qn(O),m=()=>{const O=B(),M=O?.get().docId;if(!O||!M||M!==l||s)return;const _=O.get().version;_!==c&&(c=_,pe(e,$.ON_BLOCK_CHANGED_ID).fire(d(O)))};let b;const v=O=>{const M=t.showFacts();!M||M.id===b||!No(O,M.id)||(b=M.id,O.completeShow(M.id))},w=async(O,M,_)=>{const I=_.generation,F=()=>_.generation!==I||_.signal.aborted||t.current()!==O||a,j=we(n);let K;const de=new Promise(X=>{K=_n(n,()=>X("regenerated"))}),se=async(...X)=>await Promise.race([Xe(...X).then(()=>"sent"),de])==="sent";s=!0;try{if(!await se(n,"INIT_START",z.SANDBOX_INIT_START,{guid:M},void 0,_)||F())return;const{html:X,hasBrowserExtensionArtifacts:J}=sl(jt(O));if(J&&pe(e,$.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),al(O,X),!await se(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,An(jt(O),M,Ve(e).editorPolicy,O.get().version),void 0,_)||F()||!await se(n,"INITED",z.SANDBOX_INITED,{guid:M},void 0,_)||F())return;o=M,i=j,k(),c=O.get().version,l!==M&&(l=M,pe(e,$.ON_BLOCK_INIT_ID).fire(d(O))),v(_)}finally{K?.(),s=!1,we(n)!==j&&x()}};let C,y,S;const A=()=>{const O=ue(e)?.peek("block");return O?.reload?(O.reload().catch(()=>{}),!0):!1},B=()=>oe(t.sessionKey())?t.current():void 0,k=()=>{const O=B()?.get().docId,M=!O||S===O||o===O&&i===we(n);ue(e)?.peek("block")?.hold(!M)},P=()=>{if(a||(k(),m(),s))return;const O=B(),M=O?.get().docId;if(!O||!M)return;if(o===M&&i===we(n)){v(r());return}if(!O.isReady())return;const _=r();_.signal.aborted||o!==void 0&&o!==M&&C!==M&&(C=M,A())||w(O,M,_).catch(()=>{if(!(a||t.current()!==O)){if(y!==M){y=M,A();return}S=M,k()}})};let T=!1;const x=()=>{T||a||(T=!0,queueMicrotask(()=>{T=!1,P()}))};let R,h;const f=()=>{const O=B(),M=O?.get().docId;M!==h&&(R?.(),h=M,R=O?.subscribe(x)),k(),x()},u=t.subscribe(f),g=_n(n,()=>{k(),x()});f(),e.getInstance(W)?.addDispose(()=>{a=!0,g(),R?.(),u()})}function fm(e){const t=he(e);let n="email";const r=()=>{if(!t.current())return;const i=oe(t.sessionKey())?"block":"email",s=ue(e);if(i===n||!s)return;n=i;const a=s.peek(i);if(a){am(e,a.element);return}s.get(i)},o=t.subscribe(r);e.getInstance(W)?.addDispose(o)}var pm=200;function hm({startVersion:e,limit:t=pm}){let n=[],r=e;const o=i=>{n=n.filter(s=>s.version>i),r=Math.max(r,i)};return{record(i){!i.changes?.length&&!i.contentReplaced||(n.push(i),n.length>t&&o(n[n.length-t-1].version))},rebase(i,s){if(s<r)return null;const a=n.filter(c=>c.version>s);o(s);let l=i;for(const c of a){if(c.contentReplaced||!c.changes)return null;const d=c.changes,m=[];for(const b of l){if(c.fromCanvas&&d.some(w=>b.range.start<=w.oldEnd&&b.range.end>=w.oldPosition))return null;const v=Pu(b.range,d,"after");if(!v)return null;m.push({range:v,text:b.text})}l=m}return l}}}function mm(e,t){let n=0;return e.map(({start:r,end:o,text:i})=>{const s=new Re(r,t.slice(r,o),r+n,i);return n+=i.length-(o-r),s})}function gm(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return mm(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function vm(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var bm=32;function ym(e=bm){const t=new Map;return{find(n,r){const o=t.get(n);return o&&xr(o.scope,r)?o.echo:void 0},remember(n,r,o){t.delete(n),t.set(n,{scope:r,echo:o}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>xr(r.scope,n)).map(r=>r.echo)}}}function Em(e,t){const n=Kc(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var Bo=H("canvas.sandboxFill");function El(e){return e.getInstance(Bo)?.pipeline.isEventsLocked()===!0}var _m=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,wm=/<\/?[a-zA-Z]/g;function xi(e){return e.match(wm)?.length??0}function Mi(e){return[...e.matchAll(_m)].map(t=>[t.index,t.index+t[0].length])}function ar(e,t,n){let r=0,o=0;for(const[i,s]of n){for(;o<t.length&&t[o][1]<=i;)o++;let a=i;for(let l=o;l<t.length&&t[l][0]<s;l++)r+=xi(e.substring(a,Math.max(a,t[l][0]))),a=Math.max(a,t[l][1]);r+=xi(e.substring(Math.min(a,s),s))}return r}function Sm(e,t){const n=[...t].sort((l,c)=>l.oldPosition-c.oldPosition||l.oldEnd-c.oldEnd),r=[],o=[],i=[];let s=0,a=0;for(const l of n){const c=e.substring(s,l.oldPosition);r.push(c,l.newText),a+=c.length,o.push([l.oldPosition,l.oldEnd]),i.push([a,a+l.newText.length]),a+=l.newText.length,s=l.oldEnd}return r.push(e.substring(s)),{next:r.join(""),removed:o,inserted:i}}function Im(e,t){if(e.reduce((s,a)=>s+a.oldLength,0)<=200)return null;const n=Mi(t),r=Sm(t,e),o=ar(t,n,r.removed)-ar(r.next,Mi(r.next),r.inserted),i=ar(t,n,[[0,t.length]]);return o>100&&o>i*.2?{removed:o,total:i}:null}function We(e){Bt(e,{origin:"canvas-channel"})}var Cm=100;function Tm(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===z.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function Am(e){const t=he(e),n=fe(e);let r;const o=(l,c)=>{const d=l.get().docId;let m=!1,b=null,v=null,w;const C=hm({startVersion:l.get().version});let y=l.getContent();const S=ym(),A=ma(e),B=A.open(d,()=>l.get().version);let k=!1;const P=E=>({generation:we(n),originId:E});let T=P(null),x=!0;const R=(E,D)=>{!x||t.current()!==l||(Bt(D,{origin:"canvas-channel"}),v?.splice(0,v.length),n.sendAsync(z.SANDBOX_SET_ENTITY,An(jt(l),d,Ve(e).editorPolicy,l.get().version)).catch(We))},h=E=>{const D=E[E.length-1],N=[...E].reverse().find(q=>q.answer?.actionId!==void 0)?.answer?.actionId,U=D.answer?.selection,Y=N!==void 0||U?{...N!==void 0?{actionId:N}:{},...U?{selection:U}:{}}:void 0;return{edits:E.map(q=>q.edits),guid:d,rev:D.rev,...Y?{historyAnswer:Y}:{}}},f=()=>{const E=c.activeMove(),D=E&&w?.action===E.kind?w:void 0;if(D&&(w=void 0),!(!D&&!E?.selection))return{...D?{actionId:D.actionId}:{},...E?.selection?{selection:E.selection}:{}}},u=E=>{g({edits:[],rev:l.get().version,answer:{actionId:E.actionId}}).catch(We)},g=async E=>{if(v){v.push(E);return}v=[E];try{do await n.sendAsync(z.SANDBOX_UPDATE_ENTITY,h(v.splice(0,v.length)));while(v.length)}catch(D){R("app edits failed to reach the canvas",D)}finally{v=null}},O=E=>{E.length&&n.sendAsync(z.SANDBOX_UPDATE_ENTITY,h(E)).catch(We)},M=(E,D)=>{k=!0,O(v?.splice(0,v.length)??[]);const N={edits:[E],guid:d,rev:l.get().version,...D!==null?{changeId:D}:{}};D!==null&&S.remember(D,T,N),n.sendAsync(z.SANDBOX_UPDATE_ENTITY,N).catch(We)},_=new Set,I=(E,D,N)=>{M([],N);const{length:U,hash:Y}=Qn(JSON.stringify(D.map(ee=>[ee.oldText,ee.newText]))),q=`${U}:${Y}`;if(_.has(q))return;_.add(q);const G=new Error(`canvas service batch removes ${E.removed} of ${E.total} tags`);R("canvas service batch removes a large part of the email",G)},F=({changeId:E,baseRev:D})=>{!k&&(E!==null||D!==null)&&M([],E)},j=E=>{if(E.guid!==d)return;const D=$u(E);k=!1,T=P(D.originId);try{K(E,D)}catch(N){F(D),R("canvas batch failed to apply",N)}finally{F(D),D.changeId!==null&&A.note(D.changeId,T)}},K=(E,D)=>{const{pushUndoStop:N}=E,U=D.changeId!==null?S.find(D.changeId,T):void 0;if(U){k=!0,n.sendAsync(z.SANDBOX_UPDATE_ENTITY,U).catch(We);return}let{edits:Y,selection:q}=E;if(D.baseRev!==null){const G=C.rebase(Y,D.baseRev);if(!G){Bt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),M([],D.changeId);return}G!==Y&&(q=void 0),Y=G}try{m=!0,b=D.changeId;const G=gm(Y,l.getContent());if(N===!1){const ee=Im(G,l.getContent());if(ee){I(ee,G,D.changeId);return}c.applyWithoutHistory(G)}else c.recordAt(E.typedAt,()=>l.mutate({changes:G},{source:El(e)?"system":"user"}),q),E.closesStep&&c.closeGroup()}finally{m=!1,b=null}},de=l.subscribe(({changes:E,version:D})=>{const N=l.getContent(),U=!E?.length&&N!==y;if(y=N,C.record({version:D,changes:E,contentReplaced:U,fromCanvas:m}),!E?.length)return;const Y=vm(E);m?M(Y,b):g({edits:Y,rev:D,answer:f()}).catch(We)}),se=n.addListener(z.APPLICATION_UPDATE_ENTITY,j),X=n.addListenerAsyncPipe(cd,(E,D)=>{w=Tm(E);try{return D?.(E)}finally{const N=w;w=void 0,N&&u(N)}},Cm),J=(E,D,{reportId:N,dropsCovered:U})=>{const Y=v?.splice(0,v.length)??[];n.sendAsync(z.SANDBOX_UPDATE_ENTITY,{edits:[Em(E,D)],guid:d,rev:l.get().version,resync:{textFingerprint:Qn(D),reportId:N}}).catch(q=>R("canvas resync edit failed to reach the canvas",q)),U&&O(Y)},p=n.addListener(z.APPLICATION_SYNC_DRIFT,E=>{if(!((E.reason==="echo-timeout"||E.reason==="resync-failed")&&E.guid!==void 0&&E.guid!==d)){if(E.reason==="resync-failed"){R("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(E.reason==="echo-timeout"){const{textFingerprint:D}=E,N=jt(l),U=Qn(N);if(D?.length===U.length&&D.hash===U.hash){S.echoes(P(E.originId??null)).forEach(q=>{n.sendAsync(z.SANDBOX_UPDATE_ENTITY,q).catch(We)}),E.reportId!==void 0&&J(N,N,E);return}const Y=new Error(`canvas echo timeout, ${E.unsent??0} edits unsent`);if(E.canvasText===void 0){R("canvas lost the echo of its batch",Y);return}J(E.canvasText,N,E)}}});return()=>{x=!1,B(),de(),se.dispose(),X.dispose(),p.dispose()}};let i;const s=()=>{const l=t.current(),c=t.history(),d=l?.get().docId;d!==i&&(r?.(),r=void 0,i=d,l&&c&&(r=o(l,c)))},a=t.subscribe(s);s(),e.getInstance(W)?.addDispose(()=>{r?.(),a()})}function Rm(e){const t=fe(e),n=()=>ue(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(z.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(z.RELOAD,a=>{const l=ue(e)?.byWindow(a);l&&bl(e,l.element)}),i=t.addListener(a=>{a.data?.operation===z.SANDBOX_RESIZED&&n()?.resize()}),s=te(e,$.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(W)?.addDispose(()=>{r.dispose(),o.dispose(),i.dispose(),s.dispose()})}function Li(){const e=document.createElement("div");return e.dataset.canvasOffscreen="true",e.style.position="absolute",e.style.left="-10000px",e.style.top="-10000px",e.style.width="1600px",e.style.height="1000px",document.body.appendChild(e),e}function Pm(e){const t=e.getInstance(be);let n,r;e.getInstance(W)?.addDispose(()=>{r?.remove(),r=void 0}),im(e,{resolveMount:()=>n,resolveSrc:i=>nl(i==="block"),elementId:"email_iframe",mark:i=>ie(i)}),t?.watch(i=>{const s=i?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,ue(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(i!==void 0){n=r??=Li(),ue(e)?.alignSurface("email",r,r);return}else return;ue(e)?.get("email")}});let o;e.getInstance(W)?.addDispose(()=>{o?.remove(),o=void 0}),ap(e).watch(i=>{const s=ue(e);if(s){if(i){o??=Li(),s.alignSurface("email",o,o);return}o&&(s.alignSurface("email",null),o.remove(),o=void 0)}})}var jo=H("canvas.headerFlow"),Ni=["subject","preheader"],Fi=3e3,Om=3,Dm={subject:z.SANDBOX_SUBJECT_UPDATE,preheader:z.SANDBOX_PREHEADER_UPDATE};function km(e){const t=he(e),n=fe(e),r=P=>P?"remote":El(e)?"system":"user",o=(P,{guid:T,value:x,forced:R})=>{const h=dt(t);if(!h||typeof x!="string"||T&&T!==h.get().docId)return;const f=t.forcedHeaders();if(f?.[P]!==void 0&&!R&&x!==f[P])return;const u=h.get().attributes[P];if(!R&&v(P,x,u))return;const g=!R&&m.delete(P);R&&(y.delete(P),y.size===0&&t.endForcedHeaders()),l=!0;try{gt(h,{[P]:x},{source:g?"system":r(R)})}finally{l=!1}i[P]=x};let i={},s,a,l=!1,c=Promise.resolve();const d={},m=new Map,b=(P,T)=>{i[P]=T;const x={};m.set(P,x);const R=()=>{m.get(P)===x&&m.delete(P)};w(P,T,{force:!0}).then(R),setTimeout(R,Fi)},v=(P,T,x)=>{const R=t.showFill();if(!R||typeof x!="string")return!1;const h=d[P]?.showId===R.showId?d[P]:void 0;return T===x?(d[P]=h??{showId:R.showId,codeEdits:R.codeEdits,corrections:0},!1):h&&R.codeEdits>h.codeEdits&&T!==h.stale?!1:((!h||T===h.stale&&h.corrections<Om)&&(d[P]={showId:R.showId,stale:T,codeEdits:R.codeEdits,corrections:(h?.corrections??0)+1},b(P,x)),!0)},w=(P,T,{force:x=!1,echo:R=!1,undoStep:h=!1})=>(c=n.sendAsync(Dm[P],{value:T,guid:dt(t)?.get().docId,...x?{force:!0}:{},...R?{echo:!0}:{},...h?{undoStep:!0}:{}}).catch(f=>{}),c);let C;const y=new Set;e.inject(jo,{whenDelivered:async()=>{await c},reassert:P=>{const T=dt(t),x=Ni.filter(R=>typeof P[R]=="string");if(!(!T||x.length===0)){l=!0;try{gt(T,Object.fromEntries(x.map(R=>[R,P[R]])),{source:"system"})}finally{l=!1}t.beginForcedHeaders(Object.fromEntries(x.map(R=>[R,P[R]]))),clearTimeout(C),C=setTimeout(()=>{y.clear(),t.endForcedHeaders()},Fi),y.clear();for(const R of x)y.add(R);for(const R of x)i[R]=P[R],w(R,P[R],{force:!0,echo:!0})}}});const S=()=>{s?.(),s=void 0;const P=dt(t);if(P!==a&&m.clear(),a=P,!P){i={};return}const T=P.get().attributes;i={subject:T.subject,preheader:T.preheader},s=P.subscribe(({source:x})=>{if(l)return;const R=P.get().attributes,h=t.forcedHeaders();for(const f of Ni){const u=R[f];if(u===i[f])continue;i[f]=u,m.delete(f);const g=x==="system"&&h?.[f]!==void 0;w(f,u??"",{force:g,echo:g,undoStep:x==="user"})}})};S();const A=t.subscribe(S),B=n.addListenerAsync(z.APPLICATION_SUBJECT_UPDATE,P=>o("subject",P)),k=n.addListenerAsync(z.APPLICATION_PREHEADER_UPDATE,P=>o("preheader",P));e.getInstance(W)?.addDispose(()=>{B.dispose(),k.dispose(),A(),s?.(),clearTimeout(C)})}function xm(e){const t=he(e);let n={document:void 0,seq:0};const r=()=>{const i=t.recoveryFacts(),s=dt(t);if(!i?.applied||!s||String(i.emailId)!==String(s.get().serverId)||(n.document!==s&&(n={document:s,seq:0}),i.applied.seq<=n.seq))return;n={document:s,seq:i.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(jo)?.reassert(a)},o=t.subscribe(r);e.getInstance(W)?.addDispose(o)}function Mm(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?sd:hd}function Lm(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function Nm(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Bi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Vr(e,t){const n={...e};for(const r of Object.keys(t)){const o=t[r],i=e[r];Bi(o)&&Bi(i)?n[r]=Vr(i,o):o!==void 0&&(n[r]=o)}return n}function Fm(e,t){const n=go;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const o=JSON.parse(r);if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0)return Vr(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Vr(n,t):n}var Bm=Ee(void 0),ji=Bm,_l=H("CodeMode");function wl(){let e;try{const t=window.localStorage?.getItem(Ln.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function jm(e){try{window.localStorage?.setItem(Ln.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function Uo(e){return e.getOrCreateInstance(_l,()=>{const t=Ee(wl());return t.watch(jm),t})}function Sl(e){return e?.getInstance(_l)?.get()??wl()}function qr(e,t){const n=Uo(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function Um(e,t){const n=Uo(e);n.set({...n.get(),direction:t})}var Hm=H("DefaultCommonStyles");function Il(e){return e.getOrCreateInstance(Hm,()=>Ee(void 0))}function $m(e,t){Il(e).set(t)}var Vm=H("CanvasViewport"),qm=H("CanvasPreviewPage");function Be(e,t,n){let r,o;const i=()=>{if(!r||!e.isInited())return;const l=r.value===void 0?"undefined":JSON.stringify(r.value);l!==o&&(o=l,e.send(t,r.value))},s=n.watch(l=>{r={value:l},i()}),a=e.onInit(()=>{o=void 0,i()});return{dispose(){s.dispose(),a.dispose()}}}function an(e){const t=Ee(e());return{source:t,refresh:()=>t.set(e())}}function Gm(e){const t=fe(e),n=e.getInstance(ve),r=e.getInstance(be),o=he(e),i=Uo(e),s=matchMedia(td),a=()=>n?.get()??{};let l;const c=an(()=>Mm(ji.get()??a().theme,s.matches)),d=an(()=>Lm(a(),oe(o.sessionKey()))),m=an(()=>a().lockEditor),b=an(()=>Fm(o.current()?.get().attributes?.common_styles,l)),v=e.getOrCreateInstance(Vm,()=>Ee()),w=e.getOrCreateInstance(qm,()=>Ee()),C=[Be(t,Fe.theme,c.source),Be(t,Fe.flags,d.source),Be(t,Fe.lockEditor,m.source),Be(t,Fe.commonStyles,b.source),Be(t,Fe.codeMode,i.select(Nm)),Be(t,Fe.appName,Ee("emailmaker")),Be(t,Fe.previewPage,w),Be(t,Fe.viewport,v)],y=()=>{c.refresh(),d.refresh(),m.refresh()},S=n?.watch(y),A=Il(e).watch(h=>{l=h,b.refresh()}),B=r?.watch(h=>{h&&"commonStyles"in h&&(l=h.commonStyles),b.refresh()});let k;const P=()=>{k?.(),k=o.current()?.subscribe(()=>b.refresh()),b.refresh(),d.refresh()};P();const T=o.subscribe(P),x=()=>c.refresh();s.addEventListener("change",x);const R=ji.watch(()=>c.refresh());e.getInstance(W)?.addDispose(()=>{C.forEach(h=>h.dispose()),S?.dispose(),A.dispose(),B?.dispose(),k?.(),T(),s.removeEventListener("change",x),R.dispose()})}var Gr;(function(e){function t(o,i,s=(a,l)=>a===l){if(o===i)return!0;if(o.length!==i.length)return!1;for(let a=0;a<o.length;a++)if(!s(o[a],i[a]))return!1;return!0}e.isEqual=t;function n(o,i=s=>s){const s=new Set;return o.filter(a=>{const l=i(a);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(o=[],i=[],s=(a,l)=>a===l){const a=[],l=[],c=[];for(const d of o){const m=i.find(b=>s(d,b));m?c.push({prev:d,next:m}):l.push(d)}for(const d of i)o.find(m=>s(d,m))||a.push(d);return{added:a,removed:l,exists:c}}e.diff=r})(Gr||(Gr={}));function Wm(e,t){return e.type===t.type&&e.key===t.key}function zm(e){const t=fe(e),n=()=>e.getServices(lt)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(z.SANDBOX_ADD_EXTENSIONS,r)}),i=Qc(lt),s=e.onInject(a=>{if(a!==i)return;const l=n();if(!t.isInited()){r=l;return}const{added:c,removed:d}=Gr.diff(r,l,Wm);if(r=l,d.length){if(d.some(m=>m.type==="script")){t.send(z.RELOAD);return}t.send(z.SANDBOX_REMOVE_EXTENSIONS,d.map(m=>m.key))}c.length&&t.send(z.SANDBOX_ADD_EXTENSIONS,c)});e.getInstance(W)?.addDispose(()=>{o.dispose(),s?.dispose()})}var Km=new Set([...Object.values(z).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(bo)]);function Ym(e){return e.length>0&&!e.startsWith("em:")&&!Km.has(e)}function Xm(e){const t=fe(e),n=new Map;let r=!1,o=-1,i=new Set;const s=c=>(c!==o&&(o=c,i=new Set),i),a=t.observeOutgoing((c,d)=>{if(!r||!Ym(c))return;const m=we(t);n.set(c,{data:d,generation:m,scripts:new Set(s(m))})}),l=t.addListener(bo,c=>{if(c.phase!=="ready"||c.status!=="success")return;r=!0;const d=we(t),m=s(d);m.add(c.key);for(const[b,v]of n)v.generation===d||![...v.scripts].every(w=>m.has(w))||(v.generation=d,t.send(Qs(b),v.data))});e.getInstance(W)?.addDispose(()=>{a.dispose(),l.dispose()})}var Jm=H("prewarm.editorVisible");function Qm(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Zm(e={}){const t=e.paint??Qm;let n=!1,r=!1,o=!1,i=!1,s=!1;const a=[],l=()=>{s||i||!n||!r||!o||(i=!0,t(()=>{s=!0,ie(me.editorVisible);for(const c of a.splice(0))c()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){o=!0,l()},whenVisible(c){if(s){c();return}a.push(c)},contentShown:()=>o}}function eg(e){return e.getOrCreateInstance(Jm,()=>Zm())}var tg=500,ng=500,rg=5e3;function og(e){const t=e.quietMs??tg,n=e.floorMs??ng,r=e.ceilingMs??rg;let o,i,s=0;const a=()=>{clearTimeout(o),clearTimeout(i),o=void 0,i=void 0},l=()=>{a(),e.run()},c=()=>{clearTimeout(o);const d=n-(Date.now()-s);o=setTimeout(l,Math.max(t,d))};return{start(){a(),s=Date.now(),i=setTimeout(l,r),c()},notify(){o!==void 0&&c()},cancel:a}}var ig=2;function Ui(){return new Error("[sandbox] document reloaded during fill")}function sg(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function lr(e){try{e()}catch{}}function ag(e){let t;return lr(()=>{t=e()}),{stage:n=>lr(()=>t?.stage(n)),end:(n,r)=>lr(()=>t?.end(n,r))}}function lg(e){const t=()=>e.initPipeline();let n=!1,r,o,i,s=0,a,l;const c=()=>{const T=e.readTarget?.(),x=e.readSandboxGeneration?.();return T===void 0||x===void 0?void 0:{target:T,generation:x}},d=()=>{const T=c();return T&&{...T,canvasReplaced:e.trackDocument?.(T.target)}},m=T=>{if(T?.canvasReplaced?.())return!0;const x=c();return T!==void 0&&x?.target===T.target&&x.generation!==T.generation},v=Ih({...e,waitScope:()=>({getSandboxTimeoutMs:T=>t().getSandboxTimeoutMs(T),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const T=l;if(!(!T||!e.onSandboxGenerationChange))return{getGeneration:()=>c()?.generation??T.generation,onChange:x=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===T.target||T.canvasReplaced?.())&&x()})??(()=>{})}}});let w;const C=(T,x)=>{if(w===T)return;w=T;const R=s;setTimeout(()=>{s!==R||t().signal.aborted||B(T,x).catch(()=>{})},0)},y=()=>{a?.abort(),a=void 0};let S;const A=()=>{const T=t().signal;T!==S&&(S?.removeEventListener("abort",y),S=T,T.addEventListener("abort",y))};async function B(T,x,R=0){const h=++s;y(),a=new AbortController,l=void 0,A();const f=()=>s!==h,u=v.readTarget(),g=t().generation,O=()=>g===t().generation&&!t().signal.aborted,M=x?"init:reset-":"init:",_=ag(()=>e.observeShow?.(sg(T,x,e.readEmail())));if(!x){const X=v.publicEmail();X?.id,X?.renderGuid,X?.preheader}let I=!1,F=!1,j,K=!1;const de=()=>{if(m(j))throw Ui()},se=()=>{if(f())throw _e("Fill superseded")};try{n=!0,await v.sendInitStart(),se(),j=d(),l=j,R===0&&v.fireWillInit(),await(x||R>0?v.refreshContent():v.sendContent()),I=!0,se(),de();const X=v.contentSent();v.noteFilled(X?.target,X?.docId),_.stage("content"),x||v.publicEmail()?.id;try{await v.sendPreheader()}catch(J){if(Ri(J)||f())throw J;`${M}`,String(J)}se();try{await v.sendSubject()}catch(J){if(Ri(J)||f())throw J;`${M}`,String(J)}if(se(),de(),v.showFilled(u),await v.sendInited(),se(),de(),F=!0,o===T){const J=e.readSandboxGeneration?.()??i;J!==void 0&&(r=J)}_.stage("reveal"),await v.revealFilled(),de(),_.end("revealed")}catch(X){const J=!f()&&O()&&m(j),p=J?Ui():void 0,E=p??X,D=J&&R<ig?P(T,x,R+1):void 0;K=J&&D===void 0;const N=f()?void 0:{showId:T,contentApplied:I,sandboxInitedAcked:F,superseded:!1,...e.describeSurface?.(),error:String(p??X)};N&&(`${M}`,void 0);const U=!f()&&e.recoverFailedFill?.(u)===!0;if(_.end(f()?"superseded":U?"recovered":uo(E)||!O()?"aborted":"failed",N),!U&&!f()&&No(t(),T)&&t().failShow(T,E),D!==void 0)return D;throw E}finally{k(T,x,M,{superseded:f(),sessionGeneration:g,contentApplied:I,sandboxInitedAcked:F&&!K,retry:!K,commit:O()})}}function k(T,x,R,h){const{superseded:f,contentApplied:u,sandboxInitedAcked:g}=h;if(f){`${R}`;return}g&&h.commit?v.fireInit(T,x||void 0):g?(`${R}`,h.sessionGeneration,t().generation,t().signal.aborted,void 0):u?(`${R}`,void 0):(`${R}`,void 0),n=!1,a=void 0,!g&&o===T&&(o=void 0,r===i&&(r=void 0)),!g&&u&&h.retry&&C(T,x)}function P(T,x,R){return B(T,x,R)}return{channel:v,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:T=>{r=T},lastCorrelation:()=>o,markCorrelation:T=>{o=T},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:T=>{i=T},fill:T=>B(T,!1),refill:T=>B(T,!0),stop:()=>{s+=1,y(),n=!1,S?.removeEventListener("abort",y),S=void 0}}}function cg(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const r=t.emailId??t.navId;return r!=null&&String(e.id??"")!==String(r)?!1:Cl(e,n)}function Cl(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function dg(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:i}=e,s=d=>{const m=n(),b=o();if(!cg(m,d,b)){d.showId,d.navId,d.emailId,m?.id,m?.showId,m?.renderGuid;return}d.showId,m?.id,m?.renderGuid,t.markFilled(i()),t.markCorrelation(d.showId),t.fill(d.showId).catch(()=>{})};return{showRequested:d=>{s(d)},showRequestIdentityChanged:()=>{const d=e.initPipeline().getActiveShowRequest();d&&s(d)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const d=i();if(t.filledGeneration()===d)return;const m=n(),b=o();if(!m?.renderGuid||!Cl(m,b))return;const v=`${ll}${m.renderGuid}`;t.markFilled(d),t.markCorrelation(v);const w=r()?.isReady()===!0;m.id,m.renderGuid,(w?C=>t.refill(C):C=>t.fill(C))(v).catch(()=>{t.lastCorrelation()===v&&t.markFilled(void 0)})},saasChanged:()=>{const d=n();d?.renderGuid,d?.showToken,d?.id,r()}}}var ug=H("canvas.health");function fg(e){return e??""}function pg(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Hi(e){return e.length>0}function hg(e){const t=he(e),n=fe(e),r=()=>oe(t.sessionKey())?void 0:t.current(),o=()=>{const L=r();return yl({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},i=()=>e.getInstance(Pe)??Fo;let s={},a=!1;const l=e.getInstance(be)?.watch(L=>{a=!!L?.element});let c=!1,d=!1,m=!1,b=0;const v=()=>{const L=ue(e);if(!L)return;const Q=++b,Z=L.spare();return Z&&bl(e,Z.element),(Z?Z.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(Q!==b)return;c=!0;const re=L.spare();re&&lm(e,re.element),m&&(m=!1,g(),J())})},w=og({run:()=>{m||v()?.catch(()=>{})}}),C=()=>{eg(e).noteContentShown(),!c&&!m&&w.start()};let y=!1;const S=L=>{const Q=ue(e),Z=Q?.spare()?.element.contentWindow;d&&Q&&Z&&L===Z&&(d=!1,Q.promote(),Q.busy(!1),y=!0)};let A=!1;const P=lg({container:e,messageService:n,initPipeline:i,readDocument:r,readEmail:o,revealFilled:()=>{const L=ue(e);return y&&L&&(y=!1,w.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:S,noteFilled:(L,Q)=>ue(e)?.noteFilled(L,Q),recoverFailedFill:L=>{const Q=ue(e),Z=Q?.spare()?.element.contentWindow;return!d||!Q||!Z||L!==Z?!1:(d=!1,c=!1,f="reload",Q.busy(!1),Q.peek("email")?.reload(),A=!0,J(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>we(n),onSandboxGenerationChange:L=>_n(n,L),trackDocument:L=>cm(e,L),observeShow:L=>e.getInstance(ug)?.begin(L),describeSurface:()=>({canvasPath:f,promoted:d,spareClean:c,handshake:n.isInited(),generation:we(n)}),events:{willInit:L=>{pe(e,$.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{C(),pe(e,$.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{pe(e,$.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{pe(e,$.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{pe(e,$.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),T=dg({pipeline:P,initPipeline:i,readEmail:o,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>we(n)});let x="",R="",h="",f="none";const u=()=>{const L=ue(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:z.SANDBOX_LOCK_EDIT,data:!0})},g=()=>{const L=ue(e)?.spare();L&&(u(),c=!1,d=!0,sm(e,L.element))},O=(L,Q)=>{const Z=ue(e);if(!Z)return!0;const re=Z.spare(),le=re&&c?"spare":"prepare";if(f=le,Z.busy(!0),re&&c)return g(),!0;w.cancel(),u();const qe=v();if(qe===void 0)return f="reload",Z.busy(!1),Z.peek("email")?.reload(),!0;m=!0;const Ne=b;return qe.catch(()=>{!m||Ne!==b||(m=!1,f="reload",Z.busy(!1),Z.peek("email")?.reload())}),!1},M=()=>{if(oe(t.sessionKey()))return;Y(),P.noteSandboxGeneration(we(n));const L=o(),Q=pg(L?.renderGuid,L?.showId,L?.id,s.emailId),Z=fg(L?.renderGuid);if(Z!==R){const qe=R;R=Z;const Ne=ue(e)?.peek("email")?.filled,Dc=Ne!==void 0&&Ne!==Z;Hi(Z)&&(Hi(qe)||Dc)&&O(qe||(Ne??""),Z)}if(m)return;(Q!==x||A)&&(A=!1,x=Q,T.showRequestIdentityChanged());const re=r(),le=`${Q}|${re?.get().docId??""}|${we(n)}`;le!==h&&re?.isReady()===!0&&(h=le,T.selfInitChanged()),T.saasChanged(),se()};let _=!1,I="",F="",j=!1,K=!1;const de=L=>{L.source==="user"?K=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(j=!0),J()},se=()=>{const L=o();if(!L?.renderGuid)return;const Q=P.channel.readContent(),Z=JSON.stringify([L.preheader,L.common_styles,L.meta,L.subject,L.utm_parameters?.utm_campaign??"",L.utm_parameters?.utm_content??"",L.utm_parameters?.utm_medium??"",L.utm_parameters?.utm_source??"",L.utm_parameters?.utm_term??""]),re=_&&Q!==F,le=_&&Z!==I;_=!0,F=Q,I=Z;const qe=j&&!K;if(j=!1,K=!1,P.isEventsLocked()||qe)return;const Ne={...L,id:s.isTemplate||L.isNew?void 0:L.id,html:Q};if(re){pe(e,$.ON_CONTENT_CHANGED_ID).fire(Q),pe(e,$.ON_EMAIL_CHANGED_ID).fire(Ne);return}le&&L.is_inited&&pe(e,$.ON_EMAIL_CHANGED_ID).fire(Ne)};let X=!1;const J=()=>{X||(X=!0,queueMicrotask(()=>{X=!1,M()}))};e.inject(Bo,{pipeline:P,setRoute:L=>{L.emailId===s.emailId&&!!L.isTemplate==!!s.isTemplate||(s=L,J())}});let p,E;const D=()=>{const L=r()?.get().docId;L!==E&&(p?.(),E=L,p=r()?.subscribe(de)),J()};let N,U;const Y=()=>{const L=e.getInstance(Pe);!L||L===N||(U?.(),N=L,U=L.onShowRequested(Q=>T.showRequested(Q)))},q=n.addListener(L=>{L.data?.operation===z.SANDBOX_RESIZED&&w.notify()}),G=t.subscribe(D),ee=_n(n,J);D(),e.getInstance(W)?.addDispose(()=>{l?.dispose(),U?.(),ee(),G(),p?.(),q.dispose(),w.cancel(),P.stop()})}function mg(){return _d!=="emailmaker"}var gg={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Tl={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},$i=Tl,vg=["pro"],Wr={};function bg(e){Wr=e}var Al=e=>vg.includes(e)?$i:Wr[e]??Wr.editor??$i,zr={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},yg={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Eg={...zr,config:{...zr.config,imageCenterFileManagerView:!1}};bg({pro:Tl,editor:yg,simple:mg()?zr:Eg,blocks:gg});function _g(e,t,n=e.getInstance(ve)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Sl(e).isCodeMode&&qr(e,!1)}function wg(e){e.getInstance(wd)||e.inject(Me,void 0)}function Gn(e){return String(e.standaloneKey||"").trim()||void 0}function Sg(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function Ho(e){return Sg(e)?!!Gn(e):!1}function Yt(e){return!!Gn(e)&&!Ho(e)}var Ig=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Vi(e){return e==="server"?"serverSide":e}function Cg({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=Ee();let i={kind:"pending"},s;const a=new Promise(b=>{s=b}),l=n===void 0?void 0:setTimeout(()=>{d({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function c(){i.kind!=="pending"&&o.set(ir(r,e))}function d(b){if(i.kind!=="pending")return;clearTimeout(l),i=b;const v=ir(r,e);o.set(v),s(v)}function m(b,v){r[Vi(b)]=v,b==="server"&&i.kind==="pending"?d({kind:"applied"}):c()}return{watch:b=>o.watch(b),select:b=>o.select(b),get:()=>o.get(),ready:()=>a,state:()=>i,layers:()=>({...r}),bootstrap(){const b=ir(r,e);return Object.fromEntries(Ig.map(v=>[v,b[v]]))},merge(b,v){m(v,{...r[Vi(v)],...b})},replace(b,v){m(v,b)},setMode(b){r.user={...r.user,mode:b},c()},setAdvancedConfigs(b){r.advancedConfigs=b,c()},serverAbsent(b){d({kind:"absent",reason:b})},applyServerResponse(b){i.kind==="pending"&&m("server",{...r.serverSide,...b})},dispose(){clearTimeout(l)}}}var Tg=5e3;function Ag(){return{...Al("pro")?.config,mergeTags:void 0}}function Rg(e,t){e.getInstance(be)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},o=t.layers().user.mode;t.replace(r.mode===void 0&&o!==void 0?{...r,mode:o}:r,"user")})}function Pg(e,t){let n;xo(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const i={};r?.theme&&(i.theme=r.theme),r?.locale&&(i.locale=r.locale),t.replace(i,"profile")})}function Og(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Dg(e,t){let n,r=!1,o;const i=a=>{o??=Hn(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&_g(e,a,t)},s=xo(e).watch(({profile:a})=>{const l=a?.email_builder_config,c=Og(l);if(c===void 0||l===n)return;const d=n===void 0;n=l,!(d&&r)&&i(c)});e.getInstance(W)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const l=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",l),r=n===void 0,i(l)})}var qi="замкнутый контур: app_init не выполняется";function kg(e,t){if(e.getInstance(Me)){t.serverAbsent(qi);return}const n=e.getInstance(be)?.watch(r=>{Yt(r)&&t.serverAbsent(qi)});n&&e.getInstance(W)?.addDisposable(n)}async function xg(e,t){if(e.getInstance(_o)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(He);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function Mg(e){e.injectFactory(ve,(t,n)=>{if(n)return n;const r=Cg({base:Ag(),env:{modeDefaults:o=>Al(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Tg});return Rg(e,r),Pg(e,r),Dg(e,r),kg(e,r),xg(e,r),e.getInstance(W)?.addDisposable(r),r},!0)}var pt=class extends ge{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function V(e,t,n){const r=Gc(e);return(o,i,s)=>{const a=r(async l=>{const c=t?t(l):l;s&&o.bind(s);const d=await o(c);return n?n(d):d},i,s);return()=>a.dispose()}}var Lg=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Or;this.handleDestroy=V(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new pt(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},$o=H("DestroyableService");function Ng(e){e.injectFactory($o,(t,n)=>{if(n)return n;const r=e.getInstance(W);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Lg({lifetime:r,options:e.getInstance(be),getInstance:()=>e.getInstance(Nn),release:()=>zc(e.getInstance(Nc)??e)})},!0)}function Fg(e){const t=e.getInstance($o);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var Bg=1e3;function Rl(e,t,n=Bg,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const s of o)if(!Rl(e[s],t[s],n,r+1))return!1;return!0}return!1}function Lt(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const o=t[r],i=e[r];Rl(o,i)||(n[r]=o)}return n}var jg=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function Ug(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function Hg({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??zt();let i;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,l)=>{i=setTimeout(()=>{const c=new Fn(o);n.value.id,Qu(c,Ug(s,r)),l(c)},o)})])}catch(s){throw Ca(s),s}finally{i!==void 0&&clearTimeout(i)}}function $g(e){const{emails:t}=e,n=async(r,o)=>{const i=jg(o),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...i}:i,l=s?Lt(s,i):i,c=d=>{const m=String(d.id??r??Ce()),b=d.id===void 0?{...d,id:m}:d;return t.cache.addOrUpdate(m,()=>b)};return await c(await Hg(e,{prev:s,patch:l,value:a,source:o.source??""},c))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const o=await n(void 0,r);return o?.renderGuid?o:{...o,renderGuid:Ce()}},async updateEmail(r,o){return await n(r,o)}}}var cr=20;function Vg(e){const t=qg(e);return e.saveTimeoutMs?Gg(t,e.saveTimeoutMs):t}function qg({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:i}){const s=async(a,l)=>(t.clear(),await t.get(a,{page:l}),(await e.cache.values()??[]).filter(c=>String(c?.parent)===String(a)));return{async readRevisions(a,l=1){const c=await s(a,l);return{revisions:c.slice(cr*(l-1),cr*l),page:l,hasMore:c.length>cr*l}},async readAutosave(a){const l=await r?.(a)??NaN,c=Number.isFinite(l)?l:void 0,d=await n?.(a);if(!d?.asked)return af(await s(a,1),c);if(!d.revision)return vi([],c);const m={...d.revision,parent:a,isAutosave:!0};return vi([m],c,await s(a,1))},async saveAutosave(a,l){const c=await o?.(a),d=i?.();return await e.create({...pf(l),...c!==void 0?{author:c}:{},...d!==void 0?{project:d}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Gg(e,t,n){return{...e,async saveAutosave(r,o){const i=t();if(i===void 0)return e.saveAutosave(r,o);let s;try{return await Promise.race([e.saveAutosave(r,o),new Promise((a,l)=>{s=setTimeout(()=>l(new pa(i,n)),i)})])}catch(a){throw Ca(a),a}finally{s!==void 0&&clearTimeout(s)}}}}var Wg=class extends fd{async execute([e],t){for(const n of t){const r=await n(e);r&&(r.id===void 0&&(r.id=e.value.id),e.value=r)}return e.value}},zg=class extends Ue{};var Gi=class extends ge{_items=new Map;_onChangeEmitter=new ud;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const o=await t(n);return xe(n,o)||this._onChangeEmitter.fire(),o}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([o,i])=>o)),r=(await this.entries()).filter(([o,i])=>!n.has(o));for(const[o,i]of e)t.push(this.addOrUpdate(o,()=>i)),n.add(o);for(const[o]of r)t.push(this.remove(o));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function Kg(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:i=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(c=>{for(const d of l){const m=c[d],b=t[d];return d==="id"||typeof m!="string"?m===b:typeof b=="string"&&m.startsWith(b)}return!0}),a=e.length}return r&&(e=e.sort((l,c)=>(l[r]>c[r]?1:c[r]>l[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(i*(o-1),i*o)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/i)}}function Yg(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const o=t.get(r.id)||{};t.set(r.id,{...o,...r})}return[...t].map(([n,r])=>r)}function Xg(e,t){return Wi(e)&&Wi(t)?String(e)===String(t):e===t}function Wi(e){return typeof e=="string"||typeof e=="number"}var Jg=class extends ge{_cache=new Gi;_readEmitter=new Ue;_saveEmitter=this.addDisposable(new Wg);_removeEmitter=this.addDisposable(new zg);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ge);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Gi),o=n.addDisposable(new Ue);t=this._foreignCache[e]={get:async(i,s={})=>{await r.getOrCreate(i,async()=>{try{const l=Yg(await o.fire(i))||[];for(const c of l)c[e]=i,await this._cache.add(c.id,c);return l}catch{return[]}});const a=(await this._cache.values()||[]).filter(l=>{const c=l[e];return c==null||Xg(c,i)});return Kg(a,s)},first(i,s={}){return t.get(i,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:o.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=Ce()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async o=>{const i=o?{...o,...t}:t;if(!r)return t=o?Lt(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:i,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Xt(e){const t=H(e);return n=>n.getOrCreateInstance(t,()=>new Jg)}function Pl(e){const t=e.getInstance(W);if(!t)throw new Error("Failed");return t}function zi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function ln(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function Qg(e,t,n){return e&&!zi(t)&&zi(e)?{...n,meta:e.meta}:n}var Zg=H("CurrentProject"),ev={};function Jt(e){return e?.getInstance(Zg)?.get()??ev}function Vo(e){const t=Jt(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Ol=Xt("plugin.dataSource.emails"),Dl=Xt("plugin.dataSource.emailRevisions"),kl=Vn("plugin.readEmailAutosave"),Ki=H("emailDocuments.provided");function tv(e){const t=Ol(e),n=Dl(e),r=n.byForeignKey("parent");if(e.getInstance(Ki))return{emails:t,emailRevisions:n};e.inject(Ki,!0);const o=()=>zt(e.getInstance(Pe)?.contentReadyTimeoutMs),i=$g({emails:t,saveTimeoutMs:o}),s=new Map,a=(l,c)=>d=>{const m=d?.id??c;return(typeof m=="string"||typeof m=="number")&&s.set(String(m),l),d};return Bf(e,{...i,createEmail:l=>i.createEmail(l).then(a(Date.now())),updateEmail:(l,c)=>i.updateEmail(l,c).then(a(Date.now(),l))}),$f(e,Vg({revisions:n,revisionsByEmail:r,readAutosave:async l=>{const c=await pe(e,kl).fire(l);return c.length===0?{asked:!1}:{asked:!0,revision:c[0]??null}},savedAt:async l=>{const c=of((await t.cache.getIfPresent(l))?.modified),d=s.get(String(l))??NaN;return Number.isFinite(d)&&!(c>=d)?d:c},emailAuthor:async l=>(await t.cache.getIfPresent(l))?.author,saveTimeoutMs:o,integratorProject:()=>Jt(e).requested})),Pl(e).addDisposable(t.onSave(({prev:l,patch:c,value:d})=>Qg(l,c,d),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Yi(e,t){return!e?.data||!t||e.id!==t.locale?!1:t.contentHash?e.hash===t.contentHash:t.updatedAt>0&&t.updatedAt<=e.time}function nv(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var rv="po",cn=null;function ov(){const e=typeof window.__emailmaker__<"u"?window.__emailmaker__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([rv],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function iv(){return cn===null&&(cn=ov().catch(e=>{throw cn=null,e})),cn}async function xl(e){if(typeof e=="object")return qo(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?sv(t):av(t)}function qo(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function sv(e){try{return qo(JSON.parse(e))}catch{return}}var Xi=!1;async function av(e){try{return qo((await iv()).parsePoCatalog(e))}catch{Xi||(Xi=!0);return}}var lv="em_locale",cv="em_ant_locale",dv="locale",uv="ant_locale";function Go(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Ml(e,t){const n=Go(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function fv(){return Go("em_locale")??Ml(dv,"em_locale")}function Ji(e){try{localStorage.setItem(lv,JSON.stringify(e))}catch{}}function pv(){return Go("em_ant_locale")??Ml(uv,"em_ant_locale")}function hv(e,t){try{localStorage.setItem(cv,JSON.stringify({id:e,data:t}))}catch{}}var mv=8e3;function gv(e,t){const n=e,r=t,o=Object.keys(n).filter(i=>i!=="");return o.length!==Object.keys(r).filter(i=>i!=="").length?!1:o.every(i=>JSON.stringify(n[i])===JSON.stringify(r[i]))}function vv(e){const t=fv(),n=pv();let r={ready:!1},o;const i=Ee(r);let s=0;const a=y=>{r={...r,...y},i.set(r)},l=()=>{r.ready||a({ready:!0})},c=setTimeout(l,e.unlockAfterMs??mv),d=y=>y!==s;let m;async function b(y,S){if(n?.id===y&&n.data&&a({antd:n.data}),!m)return;const A=await m(y).catch(()=>{});!A||d(S)||(a({antd:A}),hv(y,A))}async function v(y,S){const A=await e.askHost(y).catch(()=>null);if(d(S))return!0;if(A==null)return!1;const B=await xl(A);return d(S)||(B&&a({catalog:B}),l()),!0}async function w(y,S){const A=await e.readList();if(d(S))return;if("error"in A){a({failure:{kind:"GET_LOCALES_ERROR",error:A.error}}),l();return}const B=A.data.find(P=>P.locale===y);if(!B){nv("em_locale")&&a({catalog:void 0}),l();return}if(Yi(t,B)&&(!o||o.catalog===t?.data)){l();return}if(o?.entry&&r.catalog===o.catalog&&Yi(o.entry,B)){Ji(o.entry),l();return}const k=await e.readCatalog(y);if(!d(S)){if("error"in k){a({failure:{kind:"GET_LOCALE_ERROR",error:k.error}}),l();return}k.data&&(o?.id===y&&r.catalog===o.catalog&&gv(o.catalog,k.data)||a({catalog:k.data}),Ji({id:y,time:B.updatedAt||Math.floor(Date.now()/1e3),hash:B.contentHash,data:k.data})),l()}}async function C(y,S){if(!await v(y,S)){if(!d(S)&&(o?.id===y&&r.catalog===o.catalog||y==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await w(y,S)}}return{set(y){if(!y||y===r.id)return;const S=s+=1;a({id:y,failure:void 0});const A=o?.id===y&&r.catalog===o.catalog;(o&&!A&&r.catalog===o.catalog||y==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===y&&t.data&&(a({catalog:t.data}),l()),b(y,S),C(y,S)},prime(y,S,A){r.id&&r.id!==y||r.catalog||!S||(o=t?.id===y&&t.data&&(!A||t.time>=A.time)?{id:y,catalog:t.data}:{id:y,catalog:S,entry:A?{id:y,time:A.time,hash:A.hash,data:S}:void 0},a({catalog:o.catalog}))},useAntdLoader(y){m=y,r.id&&b(r.id,s)},state:i,snapshot:()=>r,dispose:()=>clearTimeout(c)}}var bv=class{http;constructor(e){this.http=e}jsonList=({locale:e},t={})=>this.http.request({path:`/translations/${e}.json`,method:"GET",format:"json",...t});getTranslations=({locale:e},t={})=>this.http.request({path:`/translations/${e}.po`,method:"GET",...t});localesList=(e={})=>this.http.request({path:"/translations/locales",method:"GET",format:"json",...e})},Qi=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),yv=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:o,format:i,baseUrl:s,cancelToken:a,...l})=>{const c=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},d=this.mergeRequestParams(l,c),m=o&&this.toQueryString(o),b=this.contentFormatters[r||"application/json"],v=i||d.format;return this.customFetch(`${s||this.baseUrl||""}${n}${m?`?${m}`:""}`,{...d,headers:{...d.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):d.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async w=>{const C=w;C.data=null,C.error=null;const y=v?w.clone():w,S=v?await y[v]().then(A=>(C.ok?C.data=A:C.error=A,C)).catch(A=>(C.error=A,C)):C;return a&&this.abortControllers.delete(a),S})}},Ev=H("rest.v2.transport"),Zi=Symbol("rest.v2.secureRequest");function _v(e){return e.getOrCreateInstance(Ev,()=>{const t=e.getInstance(Sd)?.execute||fetch;return new yv({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[Zi]:!0}),customFetch:(n,r={})=>{const{[Zi]:o,...i}=r;return t(n,{...i,[Lc]:o!==!0})}})})}function Ll(e,t){const n=_v(e);return Object.assign({},...t.map(r=>new r(n)))}function es(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Wn(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:es(n.details,"wp_code")??n.code,message:es(n.details,"wp_message")??n.message,details:n.details}}:t&&typeof t=="object"?{status:e.status,data:t}:{status:e.status,data:{message:e.statusText||"request failed"}}}function Nl(e){return!e.ok||!!e.error}function Fl(){return va(Ln.em_translations_v2)??!0}function wv(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Sv(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Iv(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],o=r[0];return typeof o=="string"&&o!==""&&t.push({locale:o,updatedAt:wv(r[1])}),t},[]):[]}function Cv(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Sv(n.updated_at),contentHash:n.content_hash}),t),[])}function Bl(e){return Ll(e,[bv])}function Pn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Kr(e){return!e.ok||e.error!=null}function Yr(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function dr(e){return{data:await xl(e)??null}}async function Tv(e){if(Fl())try{const n=await Bl(e).localesList();return Nl(n)?{error:Wn(n)}:{data:Cv(n.data)}}catch(n){return Pn(n)}const t=Ys(e,[ra]);try{const n=await t.get_translations2({file:"react_app"});return Kr(n)?Yr(n):{data:Iv(n.data)}}catch(n){return Pn(n)}}async function Av(e,t){if(Fl())try{const r=await Bl(e).jsonList({locale:t});return Nl(r)?{error:Wn(r)}:dr(r.data)}catch(r){return Pn(r)}const n=Ys(e,[ra]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Kr(r)?Yr(r):dr(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Kr(r)?Yr(r):dr(r.data)}catch(r){return Pn(r)}}}var dn=new WeakMap;function Rv(e){const t=dn.get(e);if(t!==void 0)return t;const n=Tv(e).then(r=>("error"in r&&dn.delete(e),r),r=>{throw dn.delete(e),r});return dn.set(e,n),n}var yt=H("locale.service");function Pv(e){if(e.getInstance(yt))return;const t=vv({readList:()=>Rv(e),readCatalog:n=>Av(e,n),askHost:async n=>(await pe(e,$.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Me)});e.inject(yt,t),e.getInstance(W)?.addDispose(()=>t.dispose())}function Ov(e){const t=e.getInstance(ve);if(!t)return;const n=e.getInstance(yt);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"ru_RU"));e.getInstance(W)?.addDisposable(r)}var Dv="user_id",kv="project_id",ts=H("rest.identityHeadersProvided");function xv(e){if(e.getInstance(ts))return;e.inject(ts,!0);let t;e.getInstance(be)?.watch(n=>{t=n}),e.addService(Mn,{execute(n,r){if(r?.public)return;const o=t?.user?.id??qa(e).profile?.id;o!=null&&o!==""&&n.headers.set(Dv,String(o));const i=t?.project;i!=null&&i!==""&&n.headers.set(kv,String(i))}})}function Mv(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function Lv(e){return e.id??Mv(e.catalog)}function Nv(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function Fv(e){return Nv(e||"en_US")}var Bv="Accept-Language",ns=H("rest.localeHeaderProvided");function jv(e){e.getInstance(ns)||(e.inject(ns,!0),e.addService(Mn,{execute(t){const n=e.getInstance(yt)?.snapshot();t.headers.set(Bv,Fv(n&&Lv(n)))}}))}function Uv(e){if(!e)return!1;try{return e.getInstance(Me)!==void 0}catch{return!1}}var Hv="Invalid standaloneKey.",Ww=H("StandaloneMockGuard");function $v(){const e=new Error(Hv);return e.name="InvalidStandaloneKeyError",e}function Vv(e){e.addService(Mn,{execute:()=>{if(Uv(e))throw $v()}})}function qv(e){Vc(e),Vv(e)}function Gv(e){const t=new cl;e.inject(Pe,t);const n=e.getInstance(be)?.watch(o=>{if(!o)return;const i=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...i!==void 0?{signal:i}:{}})}),r=e.getInstance(W);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var jl=Xt("plugin.dataSource.blocks"),Wv=Xt("plugin.dataSource.blockRevisions"),zv=Xt("plugin.dataSource.comments"),Kv=Vn(),Yv=Vn(),Ul=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1004
+ `));return{html:gh(t.html),hasBrowserExtensionArtifacts:t.found}}function jt(e){return e?.getContent()??""}function al(e,t){e?.mutate({content:To(t)},{source:"remote"})}function Vn(e){return H(e)}function pe(e,t){return e.getOrCreateInstance(t,()=>new Ue)}function te(e,t){return e.getOrCreateInstance(t,()=>new Ue).event}function An(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var vh=class extends Error{label;timeoutMs;constructor(e){super(`[sandbox:ready] iframe handshake timed out after ${e}ms`),this.name="SandboxReadyTimeoutError",this.label="sandbox:ready",this.timeoutMs=e}};function bh(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.isInited=="function"&&typeof t.getTarget=="function"&&typeof t.onInit=="function"}function yh(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(ne(n),new Promise((r,o)=>{let i=!1,s,a;const l=d=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",c),d())},c=()=>{l(()=>o(_e(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>o(new vh(t)))},t)),n?.addEventListener("abort",c)}))}var Eh=class extends Error{label;timeoutMs;constructor(e,t){super(`[${e}] timed out after ${t}ms`),this.name="OperationTimeoutError",this.label=e,this.timeoutMs=t}};function _h(e,t,n){return t<=0?e:new Promise((r,o)=>{let i=!1,s;const a=l=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{a(()=>o(new Eh(n,t)))},t),e.then(l=>{a(()=>r(l))},l=>{a(()=>o(l))})})}var wh=2,At=Symbol("sandbox:frame-replaced");function Ri(e){return e===At}function Xe(e,t,n,r,o,i,s){const a=`sandbox:${t}`,l=i?.getSandboxTimeoutMs(t)??So[t],c=()=>{let w=_h(e.sendAsync(n,r),l,a);return w=En(w,i?.signal),Je(a,w,o)};if(t==="INIT_START"&&bh(e)){const w=i?.getSandboxReadyTimeoutMs()??2e4,C=e,y=S=>{const A=yh(C,w,i?.signal);return Je("sandbox:INIT_START:ready-wait",A,o).then(()=>{if(!s||S<=0)return c();const B=s.getGeneration();let k;const P=new Promise((x,R)=>{k=s.onChange(()=>{s.getGeneration()!==B&&R(At)})}),T=c();return T.catch(()=>{}),Promise.race([T,P]).finally(()=>k?.()).catch(x=>{if(x!==At)throw x;return{...o},y(S-1)})})};return y(wh)}if(!s)return c();const d=s.getGeneration();let m;const b=new Promise((w,C)=>{m=s.onChange(()=>{s.getGeneration()!==d&&C(At)})}),v=c();return v.catch(()=>{}),Promise.race([v,b]).finally(()=>m?.()).catch(w=>{throw w===At&&{...o},w})}var ll="self-init:";function Sh(e){return e.startsWith(ll)}function No(e,t){const n=e.getActiveShowRequest();return Sh(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Ih(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let i="",s;const a=w=>{s={target:e.readTarget?.(),docId:w}},l=()=>e.readDocument()?jt(e.readDocument()):i,c=()=>Ve(e.container).editorPolicy,d=()=>e.readEmail(),m=()=>{const w=d();return{...w,id:e.isTemplate()||w.isNew?void 0:w.id,html:l()}};let b=!1;const v={readContent:l,publicEmail:m,sendInitStart:()=>Xe(n,"INIT_START",W.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>Xe(n,"INITED",W.SANDBOX_INITED,{guid:d().renderGuid},void 0,r(),o()),async sendContent(){const w=d(),{html:C,hasBrowserExtensionArtifacts:y}=sl(w?.html||"");y&&e.events.browserExtensionDetected(),al(e.readDocument(),C),i=C,a(w.renderGuid),await Xe(n,"SET_ENTITY",W.SANDBOX_SET_ENTITY,An(l(),w.renderGuid,c(),e.readDocument()?.get().version),{guid:w.renderGuid,emailId:w.id??null},r(),o())},refreshContent:()=>(a(d().renderGuid),Xe(n,"SET_ENTITY",W.SANDBOX_SET_ENTITY,An(l(),d().renderGuid,c(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const w=d();if(w.preheader!==void 0)return Xe(n,"PREHEADER",W.SANDBOX_PREHEADER_UPDATE,{value:w.preheader,guid:w.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const w=d();if(w.subject!==void 0)return Xe(n,"SUBJECT",W.SANDBOX_SUBJECT_UPDATE,{value:w.subject,guid:w.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:w=>e.showFilled?.(w),noteFilled:(w,C)=>e.noteFilled?.(w,C),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(m()),fireInit(w,C){if(!No(t(),w)){t().getActiveShowRequest()?.showId;return}const y=d();y.id,y.renderGuid,t().completeShow(w);const S=e.readDocument();gt(S,{is_inited:!0},{source:"system"});const A=()=>{const k=m();C&&(k.reset=!0);const P=e.events.inited(k);return C||(b&&v.fireEmailChanged(),b=!0),P};if(!S||S.isReady())return A();const{docId:B}=S.get();return S.whenReady().then(()=>e.readDocument()?.get().docId===B?A():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(m())},fireContentChanged(){e.events.contentChanged(l())}};return v}var Ch=class extends Error{showId;constructor(e,t){super(`[emailmaker] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},Th=class{_activeRequest=null;_pending=new Map;_listeners=new Set;getActiveShowRequest(){return this._activeRequest}onShowRequested(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}requestShow(e,t,n){return this._rejectPending(_e("Superseded by newer show()")),n.aborted?Promise.reject(_e(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const i=setTimeout(()=>{this._settle(e.showId,()=>{o(new Ch(e.showId,t))})},t);i.unref?.();const s=()=>{this._settle(e.showId,()=>{o(_e(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(i),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:i,dispose:a});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Ah(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Rh(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=da(e),n=ua(e),r=iu(e.sandbox);t<n+r}var cl=class{_controller=new AbortController;_externalSignalDisposable=new ge;_sessionChangeListeners=new Set;_showRegistry=new Th;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return da(this._timeouts)}getSandboxTimeoutMs(e){return ca(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return ua(this._timeouts)}bumpGeneration(){this._generation+=1}getActiveShowRequest(){return this._showRegistry.getActiveShowRequest()}onShowRequested(e){return this._showRegistry.onShowRequested(e)}requestShow(e){return this._showRegistry.requestShow(e,this.contentReadyTimeoutMs,this._controller.signal)}completeShow(e){this._showRegistry.completeShow(e)}hasPendingShow(e){return this._showRegistry.hasPendingShow(e)}failShow(e,t){this._showRegistry.failShow(e,t)}rejectAllPendingShows(e){this._showRegistry.rejectAll(e)}onSessionReplaced(e){return this._sessionChangeListeners.add(e),()=>{this._sessionChangeListeners.delete(e)}}configure(e){e.timeouts!==void 0&&(this._timeouts=Ah(this._timeouts,e.timeouts),Rh(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ge,this._linkExternalSignal(e)}abort(e){const t=e??_e("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ge}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ge,this._showRegistry.rejectAll(_e("Init session replaced")),this._controller.signal.aborted||this._controller.abort(_e("Init session replaced")),this._controller=new AbortController,this._emitSessionReplaced()}_emitSessionReplaced(){for(const e of this._sessionChangeListeners)e()}_linkExternalSignal(e){if(!e)return;if(e.aborted){this._controller.signal.aborted||(this._controller.abort(e.reason??_e()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??_e()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Fo=(()=>{const e=new cl;return e.configure({}),e})();function ot(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function Ge(e){return!e||e==="none"}function Ph(e){const t=e.contain??"",n=e.willChange??"";return!Ge(e.transform)||!Ge(e.perspective)||!Ge(e.filter)||!Ge(e.backdropFilter)||!Ge(e.translate)||!Ge(e.rotate)||!Ge(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Pi(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function Oh(e){const t=[],n=document.documentElement,r=Pi(getComputedStyle(n)),o=r.x||r.y;let i="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(i=s);for(let a=ot(e);a&&a!==n;a=ot(a)){const l=getComputedStyle(a),c=i==="none"||Ph(l)||i==="absolute"&&!!l.position&&l.position!=="static",d=a===document.body&&!o;if(c){i="none";const m=d?{x:!1,y:!1}:Pi(l);(m.x||m.y)&&t.push({node:a,...m})}(l.position==="absolute"||l.position==="fixed")&&(i==="none"||l.position==="fixed")&&(i=l.position==="fixed"?"fixed":"absolute")}return t}function dl(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function on(e){return Number.parseFloat(e)||0}function jr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=dl(e),o=on(n.borderLeftWidth),i=on(n.borderTopWidth),s=on(n.borderRightWidth),a=on(n.borderBottomWidth),l=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-s):0,c=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-i-a):0;return{left:t.left+o*r.x,top:t.top+i*r.y,right:t.right-(s+l)*r.x,bottom:t.bottom-(a+c)*r.y}}function Dh(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(i,s,a)=>{s&&(r.left=Math.max(r.left,i.left),r.right=Math.min(r.right,i.right)),a&&(r.top=Math.max(r.top,i.top),r.bottom=Math.min(r.bottom,i.bottom))};return t.forEach(i=>o(jr(i.node),i.x,i.y)),n&&o(jr(n),!0,!0),r}var Ur={originX:0,originY:0,scaleX:1,scaleY:1};function Rn(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function ul(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,o=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*o,scaleX:r,scaleY:o}}function fl(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var kh=1e3;function xh(e){const{slot:t,own:n}=e;let r,o=0,i=!1;const s=()=>{if(r=void 0,!i){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(s))}},a=()=>{!i&&r===void 0&&(r=window.requestAnimationFrame(s))},l=()=>{o=performance.now()+kh,a()},c=[window],d=[document.documentElement];for(let y=t;y;y=ot(y)){const S=y.getRootNode();S instanceof ShadowRoot&&!c.includes(S)&&(c.push(S),d.push(S))}const m=[["scroll",a],["load",a],["transitionrun",l],["transitionend",a],["transitioncancel",a],["animationstart",l],["animationend",a],["animationcancel",a]];c.forEach(y=>m.forEach(([S,A])=>y.addEventListener(S,A,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const b=typeof MutationObserver=="function"?new MutationObserver(y=>{y.some(S=>!n.contains(S.target))&&a()}):void 0;d.forEach(y=>b?.observe(y,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let v;try{if(typeof ResizeObserver=="function"){const y=new ResizeObserver(a);typeof y.observe=="function"&&(v=y)}}catch{v=void 0}let w=[];return{schedule:a,observe:y=>{!v||y.length===w.length&&y.every((S,A)=>S===w[A])||(v.disconnect(),w=y,y.forEach(S=>v?.observe(S)))},dispose(){i=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),c.forEach(y=>m.forEach(([S,A])=>y.removeEventListener(S,A,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),b?.disconnect(),v?.disconnect()}}}var Mh="pluginZoom",Lh=/^(?:ant|vscode|monaco|docs)-/;function Nh(e){return Lh.test(e)}function Fh(){const e="em".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var Bh=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function jh(){return Bh}var Uh=new Set;function Hh(e,t,n=Uh){return e.startsWith(`${t}-`)?!1:!Nh(e)&&!n.has(e)}function $h(e,t){return`--${t}-${e}`}function pl(e){const t=Fh();return Hh(e,t,jh())?$h(e,t):`--${e}`}function Vh(e,t){const n=pl(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function hl(e,t){return Vh(e,t)}var ml=300,Oi=15e3,qh=5e3,Di="em-canvas-busy-style";function Gh(){if(document.getElementById(Di))return;const e=document.createElement("style");e.id=Di,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var zh="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function Wh(e){const t=hl("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(pl("colorPrimary")).trim()||t}function gl(e){Gh();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",zh),n.appendChild(r);const o=document.createElement("span");return o.setAttribute("role","img"),o.setAttribute("aria-label","loading"),o.setAttribute("style",`display:inline-flex;color:${Wh(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function Kh(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),i=Math.min(r.right,e.right,n.width),s=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return i<=o||a<=s?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+i)/2-e.left,y:(s+a)/2-e.top}}function Yh(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const o={left:n.left,top:n.top,right:n.right,bottom:n.bottom},i=r.getBoundingClientRect();if(i.width>0&&!fl({left:i.left,top:i.top,width:i.width,height:i.height},o)){const s=Rn(o,ul(i,Rn(o,Ur),Ur));Object.assign(r.style,{left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const s=Kh(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${s.x}px`,top:`${s.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(gl(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function sr(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(gl(e))},ml);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var Xh=8e3;function Jh(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function Qh(e,t){for(let n=ot(e);n;n=ot(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",i=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>at(s)>0);if(o&&i)return n;if(n===t)return null}return null}function at(e){return Number.parseFloat(e)||0}function sn(e,t){return Math.abs(e-t)<=1}function Zh(e){const t=getComputedStyle(e),n=at(t.borderTopWidth),r=at(t.borderRightWidth),o=at(t.borderBottomWidth),i=at(t.borderLeftWidth),s=(a,l,c)=>Math.max(0,at(a)-Math.max(l,c));return{...jr(e),radii:[s(t.borderTopLeftRadius,n,i),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,o,r),s(t.borderBottomLeftRadius,o,i)]}}function em(e,t){const n=sn(t.top,e.top),r=sn(t.bottom,e.bottom),o=sn(t.left,e.left),i=sn(t.right,e.right),s=[n&&o?e.radii[0]:0,n&&i?e.radii[1]:0,r&&i?e.radii[2]:0,r&&o?e.radii[3]:0];return s.every(a=>a===0)?"":s.map(a=>`${a}px`).join(" ")}function tm(e,t,n,r,o,i){const s=n.readyTimeoutMs??Xh,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden",a.style.setProperty("zoom",hl(Mh,"1"));const l=n.resolveSrc(e),c=document.createElement("iframe");c.setAttribute("sandbox",n.resolveSandbox(l)),c.setAttribute("allow","clipboard-read; clipboard-write"),c.setAttribute("title","Email content"),c.style.width="100%",c.style.border="0",c.style.display="block",c.style.minHeight="600px",c.src=l,a.appendChild(c),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(c);const d=new ge;let m=!1,b,v=!1,w,C,y,S;const A=()=>{clearTimeout(S),S=setTimeout(()=>{v||(v=!0,C?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},B=()=>m?(y=Promise.resolve(),v=!0,y):(v=!1,y=new Promise((p,E)=>{w=p,C=E}),A(),y),k=()=>{if(clearTimeout(S),m=!0,v){y=Promise.resolve();return}v=!0,n.mark?.("loaded"),w?.()};c.addEventListener("load",k),d.addDispose(()=>{clearTimeout(S),c.removeEventListener("load",k)});let P;const T=()=>{P??=n.bindResizer?.(c)},x=()=>{P?.dispose(),P=void 0};let R=null,h=null,f,u=Ur,g="",O="",M=0;const _=p=>{const E=JSON.stringify(p);return E===g?!1:(g=E,a.style.visibility=p.visibility,a.style.left=`${p.css.left}px`,a.style.top=`${p.css.top}px`,a.style.width=`${p.css.width}px`,a.style.height=`${p.css.height}px`,a.style.borderRadius=p.radius,c.style.width=p.elementWidth>0?`${p.elementWidth}px`:"100%",c.style.transform=p.shiftX!==0?`translate(${p.shiftX}px, ${p.shiftY}px)`:`translateY(${p.shiftY}px)`,!0)};let I=!1;const F=()=>{if(!R)return g="",a.style.visibility="hidden",c.removeAttribute("id"),!1;n.elementId&&(c.id=n.elementId);const p=R.getBoundingClientRect(),E=Oh(R),D=h?.isConnected?h:null;f?.observe([R,c,...E.map(le=>le.node),...D?[D]:[]]);const N=Dh(p,E,D),U=Math.max(0,N.right-N.left),Y=Math.max(0,N.bottom-N.top),q=getComputedStyle(R).visibility==="visible",G=U<=0||Y<=0,ee=G?{left:N.left,top:N.top,right:N.left,bottom:N.top}:N,L=G?null:Qh(R,D??E[0]?.node??null),Q=L?em(Zh(L),ee):"",Z=le=>_({visibility:q&&!I?"":"hidden",css:Rn(ee,le),elementWidth:p.width/le.scaleX,shiftX:(p.left-ee.left)/le.scaleX,shiftY:(p.top-ee.top)/le.scaleY,radius:Q});let re=Z(u);if(!G){const le=a.getBoundingClientRect();le.width>0&&!fl({left:le.left,top:le.top,width:le.width,height:le.height},ee)&&(u=ul(le,Rn(ee,u),u),re=Z(u)||re)}return re},j=()=>{if(!R)return!1;let p=F();const E=c.getBoundingClientRect().height;E>0&&E!==M&&(M=E,R.style.height=`${E/dl(R).y}px`,p=!0);const D=getComputedStyle(R).pointerEvents;return D!==O&&(O=D,a.style.pointerEvents=D),p},K=()=>{f?.dispose(),f=void 0},de=p=>{f=xh({slot:p,own:a,measure:j,onDetached:K})};let se=[];const X=(p,E)=>{if(h=E,p&&se.length>0){const D=se;se=[],D.forEach(N=>N())}if(p===R){p&&!f&&de(p),j();return}if(K(),R&&R.style.removeProperty("height"),g="",M=0,O="",R=p,!p){F(),x();return}n.onShown?.(c),de(p),j(),T()};d.addDispose(K);const J=p=>{m=!1,b=void 0,i?.(),p&&n.onReload?.(c);let E;v||y===void 0?E=B():(A(),E=y);try{c.contentWindow?.location.reload()}catch{c.src=l}return E};return{element:c,ready(){return y??B()},reload:()=>J(!0),reloadQuietly:()=>J(!1),followReload:()=>{b=void 0,i?.(),n.onReload?.(c)},moveTo(p){if(a.parentNode===p)return y??B();m=!1,b=void 0,i?.();let E;return v||y===void 0?E=B():(A(),E=y),p.appendChild(a),n.onReload?.(c),g="",f?.schedule(),E},get shown(){return R!==null},get slot(){return R},whenShown(){return R!==null?Promise.resolve():new Promise(p=>{se.push(p)})},get filled(){return b},noteFilled(p){b=p},alignTo(p,E){X(p,E??null)},hold(p){I!==p&&(I=p,F())},scrollBy(p,E){let D=p,N=E;for(let U=R?ot(R):null;U;U=ot(U)){if(Math.abs(D)<1&&Math.abs(N)<1)return;const Y=getComputedStyle(U);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&U.scrollHeight>U.clientHeight){const q=U.scrollTop,G=U.scrollLeft;U.scrollBy({left:D,top:N,behavior:"instant"}),D-=U.scrollLeft-G,N-=U.scrollTop-q}}(Math.abs(D)>=1||Math.abs(N)>=1)&&window.scrollBy({left:D,top:N,behavior:"instant"})},resize(){P?.resize()},dispose(){X(null,null),x(),d.dispose(),a.remove()}}}function nm(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(u,g)=>u==="email"?`email:${g??n}`:u,i=new Map;let s,a=[],l=!1,c,d,m=!1,b,v,w="shown",C=0,y,S,A;const B=u=>d!==void 0&&u.filled!==void 0&&u.filled!==d,k=()=>{y=void 0;const u=b;!m||!u||d===void 0||S===d||!B(u)||(S=d,e.onForeignDocument?.({wanted:d,filled:u.filled,role:w,heldMs:Date.now()-C}))},P=()=>{m=!1,b=void 0,v=void 0,clearTimeout(y),y=void 0},T=(u,g)=>{const O=i.get("email"),M=O?.slot??null;return u&&M&&B(u)?(u.alignTo(null),m||(m=!0,C=Date.now(),y=setTimeout(k,qh)),w=g,b=u,!(s!==void 0||l)&&v!==u&&(v=u,e.onShown?.(u.element)),!c&&!s&&(c=sr(M)),!1):(m&&(P(),c?.remove(),c=void 0),u?.alignTo(M,O?.clip??null),!0)},x=()=>{m&&!l&&T(t.get(o("email")),"shown")},R=()=>{a.forEach(u=>clearTimeout(u)),a=[],s?.remove(),s=void 0,c?.remove(),c=void 0,(l||m)&&(l=!1,T(t.get(o("email")),"shown"))},h=(u,g,O)=>{const M=o(u,g),_=t.get(M);if(_)return _;const I=e.resolveMount();if(!I)return Jh();const F=tm(u,I,e,u==="email"?g??n:void 0,O,u==="email"?()=>x():void 0);return t.set(M,F),F},f={get:u=>h(u),current:u=>h(u),peek:u=>t.get(o(u)),spare:()=>t.get(o("email",r())),ensureSpare:()=>h("email",r(),!0),promote(){const u=t.get(o("email",r()));if(!u)return;const g=t.get(o("email"));n=r(),A=void 0,T(u,"spare"),g?.alignTo(null)},alignSurface(u,g,O){const M=i.get(u);if(i.set(u,{slot:g,clip:O??null}),u==="email"&&l){c?.remove(),c=g?sr(g):void 0;return}const _=g?h(u):t.get(o(u));if(u!=="email"){_?.alignTo(g,O??null);return}if(!g){A=M?.slot&&_?.shown?{slot:M.slot,handle:_}:void 0,m&&(P(),c?.remove(),c=void 0),_?.alignTo(null);return}const I=A?.slot===g&&A.handle===_;if(A=void 0,M?.slot===g&&_?.shown||I){_?.alignTo(g,O??null);return}T(_,"shown")},want(u){d=u,u!==void 0&&x()},noteFilled(u,g){const O=f.byWindow(u);O&&(O.noteFilled(g),O===t.get(o("email"))&&x())},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const g of t.values())if(g.element.contentWindow===u)return g}},busy(u){if(R(),!u)return;if(!f.visible()){l=!0,c?.remove(),c=void 0;const M=i.get("email");M?.slot&&(c=sr(M.slot)),a=[setTimeout(R,Oi)];return}const g=e.resolveMount();if(!g)return;const O=Yh(g,()=>f.visible()?.element.parentElement?.getBoundingClientRect()??null);s=O,a=[setTimeout(()=>O.showSpinner(),ml),setTimeout(R,Oi)]},remount(u){R();const g=o("email");t.forEach((O,M)=>{if(M===g){O.moveTo(u).catch(()=>{});return}O.dispose(),t.delete(M)})},dispose(){d=void 0,l=!1,P(),A=void 0,R(),t.forEach(u=>u.dispose()),t.clear(),i.clear(),n="a",d=void 0,S=void 0}};return f}var rm=H("canvas.resizerBinder"),Hr=H("canvas.service"),om={created:me.canvasCreated,loaded:me.canvasLoaded},vl=new WeakMap;function $r(e){return vl.get(e)??0}function im(e,t){if(e.getInstance(Hr))return;const n=nm({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:zp,elementId:t.elementId,bindResizer:o=>e.getInstance(rm)?.(o),onCreated:o=>Mt(e,o,"fresh"),onReload:o=>{vl.set(o,$r(o)+1),Mt(e,o,"fresh")},onShown:o=>{const i=n.byWindow(fe(e).getTarget());i&&i.element!==o&&ki(i.element)===ki(o)||Mt(e,o,"switch")},mark:o=>t.mark?.(om[o]),onForeignDocument:o=>{({...o},Eu("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:o.role},contexts:{canvasIdentity:{...o,path:window.location.pathname}}}))}}),r=fe(e).addListener(W.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(Hr,n),e.getInstance(z)?.addDispose(()=>{r.dispose(),n.dispose()})}function ki(e){return e.parentElement?.dataset.canvasHost}function Mt(e,t,n){const r=fe(e),o=t.contentWindow;if(!o)return;const i=r.getTarget()===o;i&&n==="switch"||(n==="fresh"&&(r.forget(o),i&&r.setTarget(void 0)),r.setTarget(o),cu(r))}function sm(e,t){Mt(e,t,"promote")}function am(e,t){Mt(e,t,"switch")}function lm(e,t){const n=t.contentWindow;n&&fe(e).greet(n)}function bl(e,t){const n=t.contentWindow;n&&fe(e).forget(n)}function cm(e,t){const n=ue(e)?.byWindow(t)?.element;if(!n)return;const r=$r(n);return()=>$r(n)!==r}function ue(e){return e.getInstance(Hr)}function yl({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:i}){if(!r)return;const s={id:o??void 0,renderGuid:n,showId:i?.id,isNew:o==null,showToken:i?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function qn(e){return{...yl({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function mn(e){const t=he(e),n=t.current();if(!n||!oe(t.sessionKey()))return;const r=qn(n),o=n.isDirty();pe(e,$.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function dm(e){const t=he(e);return!t.current()||!oe(t.sessionKey())?!1:(mn(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function um(e){const t=he(e),n=fe(e),r=()=>e.getInstance(Pe)??Fo;let o,i,s=!1,a=!1,l,c;const d=O=>qn(O),m=()=>{const O=B(),M=O?.get().docId;if(!O||!M||M!==l||s)return;const _=O.get().version;_!==c&&(c=_,pe(e,$.ON_BLOCK_CHANGED_ID).fire(d(O)))};let b;const v=O=>{const M=t.showFacts();!M||M.id===b||!No(O,M.id)||(b=M.id,O.completeShow(M.id))},w=async(O,M,_)=>{const I=_.generation,F=()=>_.generation!==I||_.signal.aborted||t.current()!==O||a,j=we(n);let K;const de=new Promise(X=>{K=_n(n,()=>X("regenerated"))}),se=async(...X)=>await Promise.race([Xe(...X).then(()=>"sent"),de])==="sent";s=!0;try{if(!await se(n,"INIT_START",W.SANDBOX_INIT_START,{guid:M},void 0,_)||F())return;const{html:X,hasBrowserExtensionArtifacts:J}=sl(jt(O));if(J&&pe(e,$.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),al(O,X),!await se(n,"SET_ENTITY",W.SANDBOX_SET_ENTITY,An(jt(O),M,Ve(e).editorPolicy,O.get().version),void 0,_)||F()||!await se(n,"INITED",W.SANDBOX_INITED,{guid:M},void 0,_)||F())return;o=M,i=j,k(),c=O.get().version,l!==M&&(l=M,pe(e,$.ON_BLOCK_INIT_ID).fire(d(O))),v(_)}finally{K?.(),s=!1,we(n)!==j&&x()}};let C,y,S;const A=()=>{const O=ue(e)?.peek("block");return O?.reload?(O.reload().catch(()=>{}),!0):!1},B=()=>oe(t.sessionKey())?t.current():void 0,k=()=>{const O=B()?.get().docId,M=!O||S===O||o===O&&i===we(n);ue(e)?.peek("block")?.hold(!M)},P=()=>{if(a||(k(),m(),s))return;const O=B(),M=O?.get().docId;if(!O||!M)return;if(o===M&&i===we(n)){v(r());return}if(!O.isReady())return;const _=r();_.signal.aborted||o!==void 0&&o!==M&&C!==M&&(C=M,A())||w(O,M,_).catch(()=>{if(!(a||t.current()!==O)){if(y!==M){y=M,A();return}S=M,k()}})};let T=!1;const x=()=>{T||a||(T=!0,queueMicrotask(()=>{T=!1,P()}))};let R,h;const f=()=>{const O=B(),M=O?.get().docId;M!==h&&(R?.(),h=M,R=O?.subscribe(x)),k(),x()},u=t.subscribe(f),g=_n(n,()=>{k(),x()});f(),e.getInstance(z)?.addDispose(()=>{a=!0,g(),R?.(),u()})}function fm(e){const t=he(e);let n="email";const r=()=>{if(!t.current())return;const i=oe(t.sessionKey())?"block":"email",s=ue(e);if(i===n||!s)return;n=i;const a=s.peek(i);if(a){am(e,a.element);return}s.get(i)},o=t.subscribe(r);e.getInstance(z)?.addDispose(o)}var pm=200;function hm({startVersion:e,limit:t=pm}){let n=[],r=e;const o=i=>{n=n.filter(s=>s.version>i),r=Math.max(r,i)};return{record(i){!i.changes?.length&&!i.contentReplaced||(n.push(i),n.length>t&&o(n[n.length-t-1].version))},rebase(i,s){if(s<r)return null;const a=n.filter(c=>c.version>s);o(s);let l=i;for(const c of a){if(c.contentReplaced||!c.changes)return null;const d=c.changes,m=[];for(const b of l){if(c.fromCanvas&&d.some(w=>b.range.start<=w.oldEnd&&b.range.end>=w.oldPosition))return null;const v=Pu(b.range,d,"after");if(!v)return null;m.push({range:v,text:b.text})}l=m}return l}}}function mm(e,t){let n=0;return e.map(({start:r,end:o,text:i})=>{const s=new Re(r,t.slice(r,o),r+n,i);return n+=i.length-(o-r),s})}function gm(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return mm(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function vm(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var bm=32;function ym(e=bm){const t=new Map;return{find(n,r){const o=t.get(n);return o&&xr(o.scope,r)?o.echo:void 0},remember(n,r,o){t.delete(n),t.set(n,{scope:r,echo:o}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>xr(r.scope,n)).map(r=>r.echo)}}}function Em(e,t){const n=Kc(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var Bo=H("canvas.sandboxFill");function El(e){return e.getInstance(Bo)?.pipeline.isEventsLocked()===!0}var _m=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,wm=/<\/?[a-zA-Z]/g;function xi(e){return e.match(wm)?.length??0}function Mi(e){return[...e.matchAll(_m)].map(t=>[t.index,t.index+t[0].length])}function ar(e,t,n){let r=0,o=0;for(const[i,s]of n){for(;o<t.length&&t[o][1]<=i;)o++;let a=i;for(let l=o;l<t.length&&t[l][0]<s;l++)r+=xi(e.substring(a,Math.max(a,t[l][0]))),a=Math.max(a,t[l][1]);r+=xi(e.substring(Math.min(a,s),s))}return r}function Sm(e,t){const n=[...t].sort((l,c)=>l.oldPosition-c.oldPosition||l.oldEnd-c.oldEnd),r=[],o=[],i=[];let s=0,a=0;for(const l of n){const c=e.substring(s,l.oldPosition);r.push(c,l.newText),a+=c.length,o.push([l.oldPosition,l.oldEnd]),i.push([a,a+l.newText.length]),a+=l.newText.length,s=l.oldEnd}return r.push(e.substring(s)),{next:r.join(""),removed:o,inserted:i}}function Im(e,t){if(e.reduce((s,a)=>s+a.oldLength,0)<=200)return null;const n=Mi(t),r=Sm(t,e),o=ar(t,n,r.removed)-ar(r.next,Mi(r.next),r.inserted),i=ar(t,n,[[0,t.length]]);return o>100&&o>i*.2?{removed:o,total:i}:null}function ze(e){Bt(e,{origin:"canvas-channel"})}var Cm=100;function Tm(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===W.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function Am(e){const t=he(e),n=fe(e);let r;const o=(l,c)=>{const d=l.get().docId;let m=!1,b=null,v=null,w;const C=hm({startVersion:l.get().version});let y=l.getContent();const S=ym(),A=ma(e),B=A.open(d,()=>l.get().version);let k=!1;const P=E=>({generation:we(n),originId:E});let T=P(null),x=!0;const R=(E,D)=>{!x||t.current()!==l||(Bt(D,{origin:"canvas-channel"}),v?.splice(0,v.length),n.sendAsync(W.SANDBOX_SET_ENTITY,An(jt(l),d,Ve(e).editorPolicy,l.get().version)).catch(ze))},h=E=>{const D=E[E.length-1],N=[...E].reverse().find(q=>q.answer?.actionId!==void 0)?.answer?.actionId,U=D.answer?.selection,Y=N!==void 0||U?{...N!==void 0?{actionId:N}:{},...U?{selection:U}:{}}:void 0;return{edits:E.map(q=>q.edits),guid:d,rev:D.rev,...Y?{historyAnswer:Y}:{}}},f=()=>{const E=c.activeMove(),D=E&&w?.action===E.kind?w:void 0;if(D&&(w=void 0),!(!D&&!E?.selection))return{...D?{actionId:D.actionId}:{},...E?.selection?{selection:E.selection}:{}}},u=E=>{g({edits:[],rev:l.get().version,answer:{actionId:E.actionId}}).catch(ze)},g=async E=>{if(v){v.push(E);return}v=[E];try{do await n.sendAsync(W.SANDBOX_UPDATE_ENTITY,h(v.splice(0,v.length)));while(v.length)}catch(D){R("app edits failed to reach the canvas",D)}finally{v=null}},O=E=>{E.length&&n.sendAsync(W.SANDBOX_UPDATE_ENTITY,h(E)).catch(ze)},M=(E,D)=>{k=!0,O(v?.splice(0,v.length)??[]);const N={edits:[E],guid:d,rev:l.get().version,...D!==null?{changeId:D}:{}};D!==null&&S.remember(D,T,N),n.sendAsync(W.SANDBOX_UPDATE_ENTITY,N).catch(ze)},_=new Set,I=(E,D,N)=>{M([],N);const{length:U,hash:Y}=Qn(JSON.stringify(D.map(ee=>[ee.oldText,ee.newText]))),q=`${U}:${Y}`;if(_.has(q))return;_.add(q);const G=new Error(`canvas service batch removes ${E.removed} of ${E.total} tags`);R("canvas service batch removes a large part of the email",G)},F=({changeId:E,baseRev:D})=>{!k&&(E!==null||D!==null)&&M([],E)},j=E=>{if(E.guid!==d)return;const D=$u(E);k=!1,T=P(D.originId);try{K(E,D)}catch(N){F(D),R("canvas batch failed to apply",N)}finally{F(D),D.changeId!==null&&A.note(D.changeId,T)}},K=(E,D)=>{const{pushUndoStop:N}=E,U=D.changeId!==null?S.find(D.changeId,T):void 0;if(U){k=!0,n.sendAsync(W.SANDBOX_UPDATE_ENTITY,U).catch(ze);return}let{edits:Y,selection:q}=E;if(D.baseRev!==null){const G=C.rebase(Y,D.baseRev);if(!G){Bt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),M([],D.changeId);return}G!==Y&&(q=void 0),Y=G}try{m=!0,b=D.changeId;const G=gm(Y,l.getContent());if(N===!1){const ee=Im(G,l.getContent());if(ee){I(ee,G,D.changeId);return}c.applyWithoutHistory(G)}else c.recordAt(E.typedAt,()=>l.mutate({changes:G},{source:El(e)?"system":"user"}),q),E.closesStep&&c.closeGroup()}finally{m=!1,b=null}},de=l.subscribe(({changes:E,version:D})=>{const N=l.getContent(),U=!E?.length&&N!==y;if(y=N,C.record({version:D,changes:E,contentReplaced:U,fromCanvas:m}),!E?.length)return;const Y=vm(E);m?M(Y,b):g({edits:Y,rev:D,answer:f()}).catch(ze)}),se=n.addListener(W.APPLICATION_UPDATE_ENTITY,j),X=n.addListenerAsyncPipe(cd,(E,D)=>{w=Tm(E);try{return D?.(E)}finally{const N=w;w=void 0,N&&u(N)}},Cm),J=(E,D,{reportId:N,dropsCovered:U})=>{const Y=v?.splice(0,v.length)??[];n.sendAsync(W.SANDBOX_UPDATE_ENTITY,{edits:[Em(E,D)],guid:d,rev:l.get().version,resync:{textFingerprint:Qn(D),reportId:N}}).catch(q=>R("canvas resync edit failed to reach the canvas",q)),U&&O(Y)},p=n.addListener(W.APPLICATION_SYNC_DRIFT,E=>{if(!((E.reason==="echo-timeout"||E.reason==="resync-failed")&&E.guid!==void 0&&E.guid!==d)){if(E.reason==="resync-failed"){R("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(E.reason==="echo-timeout"){const{textFingerprint:D}=E,N=jt(l),U=Qn(N);if(D?.length===U.length&&D.hash===U.hash){S.echoes(P(E.originId??null)).forEach(q=>{n.sendAsync(W.SANDBOX_UPDATE_ENTITY,q).catch(ze)}),E.reportId!==void 0&&J(N,N,E);return}const Y=new Error(`canvas echo timeout, ${E.unsent??0} edits unsent`);if(E.canvasText===void 0){R("canvas lost the echo of its batch",Y);return}J(E.canvasText,N,E)}}});return()=>{x=!1,B(),de(),se.dispose(),X.dispose(),p.dispose()}};let i;const s=()=>{const l=t.current(),c=t.history(),d=l?.get().docId;d!==i&&(r?.(),r=void 0,i=d,l&&c&&(r=o(l,c)))},a=t.subscribe(s);s(),e.getInstance(z)?.addDispose(()=>{r?.(),a()})}function Rm(e){const t=fe(e),n=()=>ue(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(W.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(W.RELOAD,a=>{const l=ue(e)?.byWindow(a);l&&bl(e,l.element)}),i=t.addListener(a=>{a.data?.operation===W.SANDBOX_RESIZED&&n()?.resize()}),s=te(e,$.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(z)?.addDispose(()=>{r.dispose(),o.dispose(),i.dispose(),s.dispose()})}function Li(){const e=document.createElement("div");return e.dataset.canvasOffscreen="true",e.style.position="absolute",e.style.left="-10000px",e.style.top="-10000px",e.style.width="1600px",e.style.height="1000px",document.body.appendChild(e),e}function Pm(e){const t=e.getInstance(be);let n,r;e.getInstance(z)?.addDispose(()=>{r?.remove(),r=void 0}),im(e,{resolveMount:()=>n,resolveSrc:i=>nl(i==="block"),elementId:"email_iframe",mark:i=>ie(i)}),t?.watch(i=>{const s=i?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,ue(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(i!==void 0){n=r??=Li(),ue(e)?.alignSurface("email",r,r);return}else return;ue(e)?.get("email")}});let o;e.getInstance(z)?.addDispose(()=>{o?.remove(),o=void 0}),ap(e).watch(i=>{const s=ue(e);if(s){if(i){o??=Li(),s.alignSurface("email",o,o);return}o&&(s.alignSurface("email",null),o.remove(),o=void 0)}})}var jo=H("canvas.headerFlow"),Ni=["subject","preheader"],Fi=3e3,Om=3,Dm={subject:W.SANDBOX_SUBJECT_UPDATE,preheader:W.SANDBOX_PREHEADER_UPDATE};function km(e){const t=he(e),n=fe(e),r=P=>P?"remote":El(e)?"system":"user",o=(P,{guid:T,value:x,forced:R})=>{const h=dt(t);if(!h||typeof x!="string"||T&&T!==h.get().docId)return;const f=t.forcedHeaders();if(f?.[P]!==void 0&&!R&&x!==f[P])return;const u=h.get().attributes[P];if(!R&&v(P,x,u))return;const g=!R&&m.delete(P);R&&(y.delete(P),y.size===0&&t.endForcedHeaders()),l=!0;try{gt(h,{[P]:x},{source:g?"system":r(R)})}finally{l=!1}i[P]=x};let i={},s,a,l=!1,c=Promise.resolve();const d={},m=new Map,b=(P,T)=>{i[P]=T;const x={};m.set(P,x);const R=()=>{m.get(P)===x&&m.delete(P)};w(P,T,{force:!0}).then(R),setTimeout(R,Fi)},v=(P,T,x)=>{const R=t.showFill();if(!R||typeof x!="string")return!1;const h=d[P]?.showId===R.showId?d[P]:void 0;return T===x?(d[P]=h??{showId:R.showId,codeEdits:R.codeEdits,corrections:0},!1):h&&R.codeEdits>h.codeEdits&&T!==h.stale?!1:((!h||T===h.stale&&h.corrections<Om)&&(d[P]={showId:R.showId,stale:T,codeEdits:R.codeEdits,corrections:(h?.corrections??0)+1},b(P,x)),!0)},w=(P,T,{force:x=!1,echo:R=!1,undoStep:h=!1})=>(c=n.sendAsync(Dm[P],{value:T,guid:dt(t)?.get().docId,...x?{force:!0}:{},...R?{echo:!0}:{},...h?{undoStep:!0}:{}}).catch(f=>{}),c);let C;const y=new Set;e.inject(jo,{whenDelivered:async()=>{await c},reassert:P=>{const T=dt(t),x=Ni.filter(R=>typeof P[R]=="string");if(!(!T||x.length===0)){l=!0;try{gt(T,Object.fromEntries(x.map(R=>[R,P[R]])),{source:"system"})}finally{l=!1}t.beginForcedHeaders(Object.fromEntries(x.map(R=>[R,P[R]]))),clearTimeout(C),C=setTimeout(()=>{y.clear(),t.endForcedHeaders()},Fi),y.clear();for(const R of x)y.add(R);for(const R of x)i[R]=P[R],w(R,P[R],{force:!0,echo:!0})}}});const S=()=>{s?.(),s=void 0;const P=dt(t);if(P!==a&&m.clear(),a=P,!P){i={};return}const T=P.get().attributes;i={subject:T.subject,preheader:T.preheader},s=P.subscribe(({source:x})=>{if(l)return;const R=P.get().attributes,h=t.forcedHeaders();for(const f of Ni){const u=R[f];if(u===i[f])continue;i[f]=u,m.delete(f);const g=x==="system"&&h?.[f]!==void 0;w(f,u??"",{force:g,echo:g,undoStep:x==="user"})}})};S();const A=t.subscribe(S),B=n.addListenerAsync(W.APPLICATION_SUBJECT_UPDATE,P=>o("subject",P)),k=n.addListenerAsync(W.APPLICATION_PREHEADER_UPDATE,P=>o("preheader",P));e.getInstance(z)?.addDispose(()=>{B.dispose(),k.dispose(),A(),s?.(),clearTimeout(C)})}function xm(e){const t=he(e);let n={document:void 0,seq:0};const r=()=>{const i=t.recoveryFacts(),s=dt(t);if(!i?.applied||!s||String(i.emailId)!==String(s.get().serverId)||(n.document!==s&&(n={document:s,seq:0}),i.applied.seq<=n.seq))return;n={document:s,seq:i.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(jo)?.reassert(a)},o=t.subscribe(r);e.getInstance(z)?.addDispose(o)}function Mm(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?sd:hd}function Lm(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function Nm(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Bi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Vr(e,t){const n={...e};for(const r of Object.keys(t)){const o=t[r],i=e[r];Bi(o)&&Bi(i)?n[r]=Vr(i,o):o!==void 0&&(n[r]=o)}return n}function Fm(e,t){const n=go;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const o=JSON.parse(r);if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0)return Vr(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Vr(n,t):n}var Bm=Ee(void 0),ji=Bm,_l=H("CodeMode");function wl(){let e;try{const t=window.localStorage?.getItem(Ln.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function jm(e){try{window.localStorage?.setItem(Ln.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function Uo(e){return e.getOrCreateInstance(_l,()=>{const t=Ee(wl());return t.watch(jm),t})}function Sl(e){return e?.getInstance(_l)?.get()??wl()}function qr(e,t){const n=Uo(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function Um(e,t){const n=Uo(e);n.set({...n.get(),direction:t})}var Hm=H("DefaultCommonStyles");function Il(e){return e.getOrCreateInstance(Hm,()=>Ee(void 0))}function $m(e,t){Il(e).set(t)}var Vm=H("CanvasViewport"),qm=H("CanvasPreviewPage");function Be(e,t,n){let r,o;const i=()=>{if(!r||!e.isInited())return;const l=r.value===void 0?"undefined":JSON.stringify(r.value);l!==o&&(o=l,e.send(t,r.value))},s=n.watch(l=>{r={value:l},i()}),a=e.onInit(()=>{o=void 0,i()});return{dispose(){s.dispose(),a.dispose()}}}function an(e){const t=Ee(e());return{source:t,refresh:()=>t.set(e())}}function Gm(e){const t=fe(e),n=e.getInstance(ve),r=e.getInstance(be),o=he(e),i=Uo(e),s=matchMedia(td),a=()=>n?.get()??{};let l;const c=an(()=>Mm(ji.get()??a().theme,s.matches)),d=an(()=>Lm(a(),oe(o.sessionKey()))),m=an(()=>a().lockEditor),b=an(()=>Fm(o.current()?.get().attributes?.common_styles,l)),v=e.getOrCreateInstance(Vm,()=>Ee()),w=e.getOrCreateInstance(qm,()=>Ee()),C=[Be(t,Fe.theme,c.source),Be(t,Fe.flags,d.source),Be(t,Fe.lockEditor,m.source),Be(t,Fe.commonStyles,b.source),Be(t,Fe.codeMode,i.select(Nm)),Be(t,Fe.appName,Ee("emailmaker")),Be(t,Fe.previewPage,w),Be(t,Fe.viewport,v)],y=()=>{c.refresh(),d.refresh(),m.refresh()},S=n?.watch(y),A=Il(e).watch(h=>{l=h,b.refresh()}),B=r?.watch(h=>{h&&"commonStyles"in h&&(l=h.commonStyles),b.refresh()});let k;const P=()=>{k?.(),k=o.current()?.subscribe(()=>b.refresh()),b.refresh(),d.refresh()};P();const T=o.subscribe(P),x=()=>c.refresh();s.addEventListener("change",x);const R=ji.watch(()=>c.refresh());e.getInstance(z)?.addDispose(()=>{C.forEach(h=>h.dispose()),S?.dispose(),A.dispose(),B?.dispose(),k?.(),T(),s.removeEventListener("change",x),R.dispose()})}var Gr;(function(e){function t(o,i,s=(a,l)=>a===l){if(o===i)return!0;if(o.length!==i.length)return!1;for(let a=0;a<o.length;a++)if(!s(o[a],i[a]))return!1;return!0}e.isEqual=t;function n(o,i=s=>s){const s=new Set;return o.filter(a=>{const l=i(a);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(o=[],i=[],s=(a,l)=>a===l){const a=[],l=[],c=[];for(const d of o){const m=i.find(b=>s(d,b));m?c.push({prev:d,next:m}):l.push(d)}for(const d of i)o.find(m=>s(d,m))||a.push(d);return{added:a,removed:l,exists:c}}e.diff=r})(Gr||(Gr={}));function zm(e,t){return e.type===t.type&&e.key===t.key}function Wm(e){const t=fe(e),n=()=>e.getServices(lt)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(W.SANDBOX_ADD_EXTENSIONS,r)}),i=Qc(lt),s=e.onInject(a=>{if(a!==i)return;const l=n();if(!t.isInited()){r=l;return}const{added:c,removed:d}=Gr.diff(r,l,zm);if(r=l,d.length){if(d.some(m=>m.type==="script")){t.send(W.RELOAD);return}t.send(W.SANDBOX_REMOVE_EXTENSIONS,d.map(m=>m.key))}c.length&&t.send(W.SANDBOX_ADD_EXTENSIONS,c)});e.getInstance(z)?.addDispose(()=>{o.dispose(),s?.dispose()})}var Km=new Set([...Object.values(W).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(bo)]);function Ym(e){return e.length>0&&!e.startsWith("em:")&&!Km.has(e)}function Xm(e){const t=fe(e),n=new Map;let r=!1,o=-1,i=new Set;const s=c=>(c!==o&&(o=c,i=new Set),i),a=t.observeOutgoing((c,d)=>{if(!r||!Ym(c))return;const m=we(t);n.set(c,{data:d,generation:m,scripts:new Set(s(m))})}),l=t.addListener(bo,c=>{if(c.phase!=="ready"||c.status!=="success")return;r=!0;const d=we(t),m=s(d);m.add(c.key);for(const[b,v]of n)v.generation===d||![...v.scripts].every(w=>m.has(w))||(v.generation=d,t.send(Qs(b),v.data))});e.getInstance(z)?.addDispose(()=>{a.dispose(),l.dispose()})}var Jm=H("prewarm.editorVisible");function Qm(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Zm(e={}){const t=e.paint??Qm;let n=!1,r=!1,o=!1,i=!1,s=!1;const a=[],l=()=>{s||i||!n||!r||!o||(i=!0,t(()=>{s=!0,ie(me.editorVisible);for(const c of a.splice(0))c()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){o=!0,l()},whenVisible(c){if(s){c();return}a.push(c)},contentShown:()=>o}}function eg(e){return e.getOrCreateInstance(Jm,()=>Zm())}var tg=500,ng=500,rg=5e3;function og(e){const t=e.quietMs??tg,n=e.floorMs??ng,r=e.ceilingMs??rg;let o,i,s=0;const a=()=>{clearTimeout(o),clearTimeout(i),o=void 0,i=void 0},l=()=>{a(),e.run()},c=()=>{clearTimeout(o);const d=n-(Date.now()-s);o=setTimeout(l,Math.max(t,d))};return{start(){a(),s=Date.now(),i=setTimeout(l,r),c()},notify(){o!==void 0&&c()},cancel:a}}var ig=2;function Ui(){return new Error("[sandbox] document reloaded during fill")}function sg(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function lr(e){try{e()}catch{}}function ag(e){let t;return lr(()=>{t=e()}),{stage:n=>lr(()=>t?.stage(n)),end:(n,r)=>lr(()=>t?.end(n,r))}}function lg(e){const t=()=>e.initPipeline();let n=!1,r,o,i,s=0,a,l;const c=()=>{const T=e.readTarget?.(),x=e.readSandboxGeneration?.();return T===void 0||x===void 0?void 0:{target:T,generation:x}},d=()=>{const T=c();return T&&{...T,canvasReplaced:e.trackDocument?.(T.target)}},m=T=>{if(T?.canvasReplaced?.())return!0;const x=c();return T!==void 0&&x?.target===T.target&&x.generation!==T.generation},v=Ih({...e,waitScope:()=>({getSandboxTimeoutMs:T=>t().getSandboxTimeoutMs(T),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const T=l;if(!(!T||!e.onSandboxGenerationChange))return{getGeneration:()=>c()?.generation??T.generation,onChange:x=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===T.target||T.canvasReplaced?.())&&x()})??(()=>{})}}});let w;const C=(T,x)=>{if(w===T)return;w=T;const R=s;setTimeout(()=>{s!==R||t().signal.aborted||B(T,x).catch(()=>{})},0)},y=()=>{a?.abort(),a=void 0};let S;const A=()=>{const T=t().signal;T!==S&&(S?.removeEventListener("abort",y),S=T,T.addEventListener("abort",y))};async function B(T,x,R=0){const h=++s;y(),a=new AbortController,l=void 0,A();const f=()=>s!==h,u=v.readTarget(),g=t().generation,O=()=>g===t().generation&&!t().signal.aborted,M=x?"init:reset-":"init:",_=ag(()=>e.observeShow?.(sg(T,x,e.readEmail())));if(!x){const X=v.publicEmail();X?.id,X?.renderGuid,X?.preheader}let I=!1,F=!1,j,K=!1;const de=()=>{if(m(j))throw Ui()},se=()=>{if(f())throw _e("Fill superseded")};try{n=!0,await v.sendInitStart(),se(),j=d(),l=j,R===0&&v.fireWillInit(),await(x||R>0?v.refreshContent():v.sendContent()),I=!0,se(),de();const X=v.contentSent();v.noteFilled(X?.target,X?.docId),_.stage("content"),x||v.publicEmail()?.id;try{await v.sendPreheader()}catch(J){if(Ri(J)||f())throw J;`${M}`,String(J)}se();try{await v.sendSubject()}catch(J){if(Ri(J)||f())throw J;`${M}`,String(J)}if(se(),de(),v.showFilled(u),await v.sendInited(),se(),de(),F=!0,o===T){const J=e.readSandboxGeneration?.()??i;J!==void 0&&(r=J)}_.stage("reveal"),await v.revealFilled(),de(),_.end("revealed")}catch(X){const J=!f()&&O()&&m(j),p=J?Ui():void 0,E=p??X,D=J&&R<ig?P(T,x,R+1):void 0;K=J&&D===void 0;const N=f()?void 0:{showId:T,contentApplied:I,sandboxInitedAcked:F,superseded:!1,...e.describeSurface?.(),error:String(p??X)};N&&(`${M}`,void 0);const U=!f()&&e.recoverFailedFill?.(u)===!0;if(_.end(f()?"superseded":U?"recovered":uo(E)||!O()?"aborted":"failed",N),!U&&!f()&&No(t(),T)&&t().failShow(T,E),D!==void 0)return D;throw E}finally{k(T,x,M,{superseded:f(),sessionGeneration:g,contentApplied:I,sandboxInitedAcked:F&&!K,retry:!K,commit:O()})}}function k(T,x,R,h){const{superseded:f,contentApplied:u,sandboxInitedAcked:g}=h;if(f){`${R}`;return}g&&h.commit?v.fireInit(T,x||void 0):g?(`${R}`,h.sessionGeneration,t().generation,t().signal.aborted,void 0):u?(`${R}`,void 0):(`${R}`,void 0),n=!1,a=void 0,!g&&o===T&&(o=void 0,r===i&&(r=void 0)),!g&&u&&h.retry&&C(T,x)}function P(T,x,R){return B(T,x,R)}return{channel:v,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:T=>{r=T},lastCorrelation:()=>o,markCorrelation:T=>{o=T},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:T=>{i=T},fill:T=>B(T,!1),refill:T=>B(T,!0),stop:()=>{s+=1,y(),n=!1,S?.removeEventListener("abort",y),S=void 0}}}function cg(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const r=t.emailId??t.navId;return r!=null&&String(e.id??"")!==String(r)?!1:Cl(e,n)}function Cl(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function dg(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:i}=e,s=d=>{const m=n(),b=o();if(!cg(m,d,b)){d.showId,d.navId,d.emailId,m?.id,m?.showId,m?.renderGuid;return}d.showId,m?.id,m?.renderGuid,t.markFilled(i()),t.markCorrelation(d.showId),t.fill(d.showId).catch(()=>{})};return{showRequested:d=>{s(d)},showRequestIdentityChanged:()=>{const d=e.initPipeline().getActiveShowRequest();d&&s(d)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const d=i();if(t.filledGeneration()===d)return;const m=n(),b=o();if(!m?.renderGuid||!Cl(m,b))return;const v=`${ll}${m.renderGuid}`;t.markFilled(d),t.markCorrelation(v);const w=r()?.isReady()===!0;m.id,m.renderGuid,(w?C=>t.refill(C):C=>t.fill(C))(v).catch(()=>{t.lastCorrelation()===v&&t.markFilled(void 0)})},saasChanged:()=>{const d=n();d?.renderGuid,d?.showToken,d?.id,r()}}}var ug=H("canvas.health");function fg(e){return e??""}function pg(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Hi(e){return e.length>0}function hg(e){const t=he(e),n=fe(e),r=()=>oe(t.sessionKey())?void 0:t.current(),o=()=>{const L=r();return yl({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},i=()=>e.getInstance(Pe)??Fo;let s={},a=!1;const l=e.getInstance(be)?.watch(L=>{a=!!L?.element});let c=!1,d=!1,m=!1,b=0;const v=()=>{const L=ue(e);if(!L)return;const Q=++b,Z=L.spare();return Z&&bl(e,Z.element),(Z?Z.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(Q!==b)return;c=!0;const re=L.spare();re&&lm(e,re.element),m&&(m=!1,g(),J())})},w=og({run:()=>{m||v()?.catch(()=>{})}}),C=()=>{eg(e).noteContentShown(),!c&&!m&&w.start()};let y=!1;const S=L=>{const Q=ue(e),Z=Q?.spare()?.element.contentWindow;d&&Q&&Z&&L===Z&&(d=!1,Q.promote(),Q.busy(!1),y=!0)};let A=!1;const P=lg({container:e,messageService:n,initPipeline:i,readDocument:r,readEmail:o,revealFilled:()=>{const L=ue(e);return y&&L&&(y=!1,w.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:S,noteFilled:(L,Q)=>ue(e)?.noteFilled(L,Q),recoverFailedFill:L=>{const Q=ue(e),Z=Q?.spare()?.element.contentWindow;return!d||!Q||!Z||L!==Z?!1:(d=!1,c=!1,f="reload",Q.busy(!1),Q.peek("email")?.reload(),A=!0,J(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>we(n),onSandboxGenerationChange:L=>_n(n,L),trackDocument:L=>cm(e,L),observeShow:L=>e.getInstance(ug)?.begin(L),describeSurface:()=>({canvasPath:f,promoted:d,spareClean:c,handshake:n.isInited(),generation:we(n)}),events:{willInit:L=>{pe(e,$.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{C(),pe(e,$.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{pe(e,$.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{pe(e,$.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{pe(e,$.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),T=dg({pipeline:P,initPipeline:i,readEmail:o,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>we(n)});let x="",R="",h="",f="none";const u=()=>{const L=ue(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:W.SANDBOX_LOCK_EDIT,data:!0})},g=()=>{const L=ue(e)?.spare();L&&(u(),c=!1,d=!0,sm(e,L.element))},O=(L,Q)=>{const Z=ue(e);if(!Z)return!0;const re=Z.spare(),le=re&&c?"spare":"prepare";if(f=le,Z.busy(!0),re&&c)return g(),!0;w.cancel(),u();const qe=v();if(qe===void 0)return f="reload",Z.busy(!1),Z.peek("email")?.reload(),!0;m=!0;const Ne=b;return qe.catch(()=>{!m||Ne!==b||(m=!1,f="reload",Z.busy(!1),Z.peek("email")?.reload())}),!1},M=()=>{if(oe(t.sessionKey()))return;Y(),P.noteSandboxGeneration(we(n));const L=o(),Q=pg(L?.renderGuid,L?.showId,L?.id,s.emailId),Z=fg(L?.renderGuid);if(Z!==R){const qe=R;R=Z;const Ne=ue(e)?.peek("email")?.filled,Dc=Ne!==void 0&&Ne!==Z;Hi(Z)&&(Hi(qe)||Dc)&&O(qe||(Ne??""),Z)}if(m)return;(Q!==x||A)&&(A=!1,x=Q,T.showRequestIdentityChanged());const re=r(),le=`${Q}|${re?.get().docId??""}|${we(n)}`;le!==h&&re?.isReady()===!0&&(h=le,T.selfInitChanged()),T.saasChanged(),se()};let _=!1,I="",F="",j=!1,K=!1;const de=L=>{L.source==="user"?K=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(j=!0),J()},se=()=>{const L=o();if(!L?.renderGuid)return;const Q=P.channel.readContent(),Z=JSON.stringify([L.preheader,L.common_styles,L.meta,L.subject,L.utm_parameters?.utm_campaign??"",L.utm_parameters?.utm_content??"",L.utm_parameters?.utm_medium??"",L.utm_parameters?.utm_source??"",L.utm_parameters?.utm_term??""]),re=_&&Q!==F,le=_&&Z!==I;_=!0,F=Q,I=Z;const qe=j&&!K;if(j=!1,K=!1,P.isEventsLocked()||qe)return;const Ne={...L,id:s.isTemplate||L.isNew?void 0:L.id,html:Q};if(re){pe(e,$.ON_CONTENT_CHANGED_ID).fire(Q),pe(e,$.ON_EMAIL_CHANGED_ID).fire(Ne);return}le&&L.is_inited&&pe(e,$.ON_EMAIL_CHANGED_ID).fire(Ne)};let X=!1;const J=()=>{X||(X=!0,queueMicrotask(()=>{X=!1,M()}))};e.inject(Bo,{pipeline:P,setRoute:L=>{L.emailId===s.emailId&&!!L.isTemplate==!!s.isTemplate||(s=L,J())}});let p,E;const D=()=>{const L=r()?.get().docId;L!==E&&(p?.(),E=L,p=r()?.subscribe(de)),J()};let N,U;const Y=()=>{const L=e.getInstance(Pe);!L||L===N||(U?.(),N=L,U=L.onShowRequested(Q=>T.showRequested(Q)))},q=n.addListener(L=>{L.data?.operation===W.SANDBOX_RESIZED&&w.notify()}),G=t.subscribe(D),ee=_n(n,J);D(),e.getInstance(z)?.addDispose(()=>{l?.dispose(),U?.(),ee(),G(),p?.(),q.dispose(),w.cancel(),P.stop()})}function mg(){return _d!=="emailmaker"}var gg={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Tl={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},$i=Tl,vg=["pro"],zr={};function bg(e){zr=e}var Al=e=>vg.includes(e)?$i:zr[e]??zr.editor??$i,Wr={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},yg={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Eg={...Wr,config:{...Wr.config,imageCenterFileManagerView:!1}};bg({pro:Tl,editor:yg,simple:mg()?Wr:Eg,blocks:gg});function _g(e,t,n=e.getInstance(ve)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Sl(e).isCodeMode&&qr(e,!1)}function wg(e){e.getInstance(wd)||e.inject(Me,void 0)}function Gn(e){return String(e.standaloneKey||"").trim()||void 0}function Sg(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function Ho(e){return Sg(e)?!!Gn(e):!1}function Yt(e){return!!Gn(e)&&!Ho(e)}var Ig=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Vi(e){return e==="server"?"serverSide":e}function Cg({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=Ee();let i={kind:"pending"},s;const a=new Promise(b=>{s=b}),l=n===void 0?void 0:setTimeout(()=>{d({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function c(){i.kind!=="pending"&&o.set(ir(r,e))}function d(b){if(i.kind!=="pending")return;clearTimeout(l),i=b;const v=ir(r,e);o.set(v),s(v)}function m(b,v){r[Vi(b)]=v,b==="server"&&i.kind==="pending"?d({kind:"applied"}):c()}return{watch:b=>o.watch(b),select:b=>o.select(b),get:()=>o.get(),ready:()=>a,state:()=>i,layers:()=>({...r}),bootstrap(){const b=ir(r,e);return Object.fromEntries(Ig.map(v=>[v,b[v]]))},merge(b,v){m(v,{...r[Vi(v)],...b})},replace(b,v){m(v,b)},setMode(b){r.user={...r.user,mode:b},c()},setAdvancedConfigs(b){r.advancedConfigs=b,c()},serverAbsent(b){d({kind:"absent",reason:b})},applyServerResponse(b){i.kind==="pending"&&m("server",{...r.serverSide,...b})},dispose(){clearTimeout(l)}}}var Tg=5e3;function Ag(){return{...Al("pro")?.config,mergeTags:void 0}}function Rg(e,t){e.getInstance(be)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},o=t.layers().user.mode;t.replace(r.mode===void 0&&o!==void 0?{...r,mode:o}:r,"user")})}function Pg(e,t){let n;xo(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const i={};r?.theme&&(i.theme=r.theme),r?.locale&&(i.locale=r.locale),t.replace(i,"profile")})}function Og(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Dg(e,t){let n,r=!1,o;const i=a=>{o??=Hn(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&_g(e,a,t)},s=xo(e).watch(({profile:a})=>{const l=a?.email_builder_config,c=Og(l);if(c===void 0||l===n)return;const d=n===void 0;n=l,!(d&&r)&&i(c)});e.getInstance(z)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const l=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",l),r=n===void 0,i(l)})}var qi="замкнутый контур: app_init не выполняется";function kg(e,t){if(e.getInstance(Me)){t.serverAbsent(qi);return}const n=e.getInstance(be)?.watch(r=>{Yt(r)&&t.serverAbsent(qi)});n&&e.getInstance(z)?.addDisposable(n)}async function xg(e,t){if(e.getInstance(_o)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(He);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function Mg(e){e.injectFactory(ve,(t,n)=>{if(n)return n;const r=Cg({base:Ag(),env:{modeDefaults:o=>Al(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Tg});return Rg(e,r),Pg(e,r),Dg(e,r),kg(e,r),xg(e,r),e.getInstance(z)?.addDisposable(r),r},!0)}var pt=class extends ge{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function V(e,t,n){const r=Gc(e);return(o,i,s)=>{const a=r(async l=>{const c=t?t(l):l;s&&o.bind(s);const d=await o(c);return n?n(d):d},i,s);return()=>a.dispose()}}var Lg=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Or;this.handleDestroy=V(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new pt(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},$o=H("DestroyableService");function Ng(e){e.injectFactory($o,(t,n)=>{if(n)return n;const r=e.getInstance(z);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Lg({lifetime:r,options:e.getInstance(be),getInstance:()=>e.getInstance(Nn),release:()=>Wc(e.getInstance(Nc)??e)})},!0)}function Fg(e){const t=e.getInstance($o);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var Bg=1e3;function Rl(e,t,n=Bg,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const s of o)if(!Rl(e[s],t[s],n,r+1))return!1;return!0}return!1}function Lt(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const o=t[r],i=e[r];Rl(o,i)||(n[r]=o)}return n}var jg=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function Ug(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function Hg({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??Wt();let i;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,l)=>{i=setTimeout(()=>{const c=new Fn(o);n.value.id,Qu(c,Ug(s,r)),l(c)},o)})])}catch(s){throw Ca(s),s}finally{i!==void 0&&clearTimeout(i)}}function $g(e){const{emails:t}=e,n=async(r,o)=>{const i=jg(o),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...i}:i,l=s?Lt(s,i):i,c=d=>{const m=String(d.id??r??Ce()),b=d.id===void 0?{...d,id:m}:d;return t.cache.addOrUpdate(m,()=>b)};return await c(await Hg(e,{prev:s,patch:l,value:a,source:o.source??""},c))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const o=await n(void 0,r);return o?.renderGuid?o:{...o,renderGuid:Ce()}},async updateEmail(r,o){return await n(r,o)}}}var cr=20;function Vg(e){const t=qg(e);return e.saveTimeoutMs?Gg(t,e.saveTimeoutMs):t}function qg({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:i}){const s=async(a,l)=>(t.clear(),await t.get(a,{page:l}),(await e.cache.values()??[]).filter(c=>String(c?.parent)===String(a)));return{async readRevisions(a,l=1){const c=await s(a,l);return{revisions:c.slice(cr*(l-1),cr*l),page:l,hasMore:c.length>cr*l}},async readAutosave(a){const l=await r?.(a)??NaN,c=Number.isFinite(l)?l:void 0,d=await n?.(a);if(!d?.asked)return af(await s(a,1),c);if(!d.revision)return vi([],c);const m={...d.revision,parent:a,isAutosave:!0};return vi([m],c,await s(a,1))},async saveAutosave(a,l){const c=await o?.(a),d=i?.();return await e.create({...pf(l),...c!==void 0?{author:c}:{},...d!==void 0?{project:d}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Gg(e,t,n){return{...e,async saveAutosave(r,o){const i=t();if(i===void 0)return e.saveAutosave(r,o);let s;try{return await Promise.race([e.saveAutosave(r,o),new Promise((a,l)=>{s=setTimeout(()=>l(new pa(i,n)),i)})])}catch(a){throw Ca(a),a}finally{s!==void 0&&clearTimeout(s)}}}}var zg=class extends fd{async execute([e],t){for(const n of t){const r=await n(e);r&&(r.id===void 0&&(r.id=e.value.id),e.value=r)}return e.value}},Wg=class extends Ue{};var Gi=class extends ge{_items=new Map;_onChangeEmitter=new ud;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const o=await t(n);return xe(n,o)||this._onChangeEmitter.fire(),o}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([o,i])=>o)),r=(await this.entries()).filter(([o,i])=>!n.has(o));for(const[o,i]of e)t.push(this.addOrUpdate(o,()=>i)),n.add(o);for(const[o]of r)t.push(this.remove(o));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function Kg(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:i=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(c=>{for(const d of l){const m=c[d],b=t[d];return d==="id"||typeof m!="string"?m===b:typeof b=="string"&&m.startsWith(b)}return!0}),a=e.length}return r&&(e=e.sort((l,c)=>(l[r]>c[r]?1:c[r]>l[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(i*(o-1),i*o)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/i)}}function Yg(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const o=t.get(r.id)||{};t.set(r.id,{...o,...r})}return[...t].map(([n,r])=>r)}function Xg(e,t){return zi(e)&&zi(t)?String(e)===String(t):e===t}function zi(e){return typeof e=="string"||typeof e=="number"}var Jg=class extends ge{_cache=new Gi;_readEmitter=new Ue;_saveEmitter=this.addDisposable(new zg);_removeEmitter=this.addDisposable(new Wg);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ge);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Gi),o=n.addDisposable(new Ue);t=this._foreignCache[e]={get:async(i,s={})=>{await r.getOrCreate(i,async()=>{try{const l=Yg(await o.fire(i))||[];for(const c of l)c[e]=i,await this._cache.add(c.id,c);return l}catch{return[]}});const a=(await this._cache.values()||[]).filter(l=>{const c=l[e];return c==null||Xg(c,i)});return Kg(a,s)},first(i,s={}){return t.get(i,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:o.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=Ce()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async o=>{const i=o?{...o,...t}:t;if(!r)return t=o?Lt(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:i,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Xt(e){const t=H(e);return n=>n.getOrCreateInstance(t,()=>new Jg)}function Pl(e){const t=e.getInstance(z);if(!t)throw new Error("Failed");return t}function Wi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function ln(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function Qg(e,t,n){return e&&!Wi(t)&&Wi(e)?{...n,meta:e.meta}:n}var Zg=H("CurrentProject"),ev={};function Jt(e){return e?.getInstance(Zg)?.get()??ev}function Vo(e){const t=Jt(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Ol=Xt("plugin.dataSource.emails"),Dl=Xt("plugin.dataSource.emailRevisions"),kl=Vn("plugin.readEmailAutosave"),Ki=H("emailDocuments.provided");function tv(e){const t=Ol(e),n=Dl(e),r=n.byForeignKey("parent");if(e.getInstance(Ki))return{emails:t,emailRevisions:n};e.inject(Ki,!0);const o=()=>Wt(e.getInstance(Pe)?.contentReadyTimeoutMs),i=$g({emails:t,saveTimeoutMs:o}),s=new Map,a=(l,c)=>d=>{const m=d?.id??c;return(typeof m=="string"||typeof m=="number")&&s.set(String(m),l),d};return Bf(e,{...i,createEmail:l=>i.createEmail(l).then(a(Date.now())),updateEmail:(l,c)=>i.updateEmail(l,c).then(a(Date.now(),l))}),$f(e,Vg({revisions:n,revisionsByEmail:r,readAutosave:async l=>{const c=await pe(e,kl).fire(l);return c.length===0?{asked:!1}:{asked:!0,revision:c[0]??null}},savedAt:async l=>{const c=of((await t.cache.getIfPresent(l))?.modified),d=s.get(String(l))??NaN;return Number.isFinite(d)&&!(c>=d)?d:c},emailAuthor:async l=>(await t.cache.getIfPresent(l))?.author,saveTimeoutMs:o,integratorProject:()=>Jt(e).requested})),Pl(e).addDisposable(t.onSave(({prev:l,patch:c,value:d})=>Qg(l,c,d),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Yi(e,t){return!e?.data||!t||e.id!==t.locale?!1:t.contentHash?e.hash===t.contentHash:t.updatedAt>0&&t.updatedAt<=e.time}function nv(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var rv="po",cn=null;function ov(){const e=typeof window.__emailmaker__<"u"?window.__emailmaker__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([rv],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function iv(){return cn===null&&(cn=ov().catch(e=>{throw cn=null,e})),cn}async function xl(e){if(typeof e=="object")return qo(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?sv(t):av(t)}function qo(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function sv(e){try{return qo(JSON.parse(e))}catch{return}}var Xi=!1;async function av(e){try{return qo((await iv()).parsePoCatalog(e))}catch{Xi||(Xi=!0);return}}var lv="em_locale",cv="em_ant_locale",dv="locale",uv="ant_locale";function Go(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Ml(e,t){const n=Go(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function fv(){return Go("em_locale")??Ml(dv,"em_locale")}function Ji(e){try{localStorage.setItem(lv,JSON.stringify(e))}catch{}}function pv(){return Go("em_ant_locale")??Ml(uv,"em_ant_locale")}function hv(e,t){try{localStorage.setItem(cv,JSON.stringify({id:e,data:t}))}catch{}}var mv=8e3;function gv(e,t){const n=e,r=t,o=Object.keys(n).filter(i=>i!=="");return o.length!==Object.keys(r).filter(i=>i!=="").length?!1:o.every(i=>JSON.stringify(n[i])===JSON.stringify(r[i]))}function vv(e){const t=fv(),n=pv();let r={ready:!1},o;const i=Ee(r);let s=0;const a=y=>{r={...r,...y},i.set(r)},l=()=>{r.ready||a({ready:!0})},c=setTimeout(l,e.unlockAfterMs??mv),d=y=>y!==s;let m;async function b(y,S){if(n?.id===y&&n.data&&a({antd:n.data}),!m)return;const A=await m(y).catch(()=>{});!A||d(S)||(a({antd:A}),hv(y,A))}async function v(y,S){const A=await e.askHost(y).catch(()=>null);if(d(S))return!0;if(A==null)return!1;const B=await xl(A);return d(S)||(B&&a({catalog:B}),l()),!0}async function w(y,S){const A=await e.readList();if(d(S))return;if("error"in A){a({failure:{kind:"GET_LOCALES_ERROR",error:A.error}}),l();return}const B=A.data.find(P=>P.locale===y);if(!B){nv("em_locale")&&a({catalog:void 0}),l();return}if(Yi(t,B)&&(!o||o.catalog===t?.data)){l();return}if(o?.entry&&r.catalog===o.catalog&&Yi(o.entry,B)){Ji(o.entry),l();return}const k=await e.readCatalog(y);if(!d(S)){if("error"in k){a({failure:{kind:"GET_LOCALE_ERROR",error:k.error}}),l();return}k.data&&(o?.id===y&&r.catalog===o.catalog&&gv(o.catalog,k.data)||a({catalog:k.data}),Ji({id:y,time:B.updatedAt||Math.floor(Date.now()/1e3),hash:B.contentHash,data:k.data})),l()}}async function C(y,S){if(!await v(y,S)){if(!d(S)&&(o?.id===y&&r.catalog===o.catalog||y==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await w(y,S)}}return{set(y){if(!y||y===r.id)return;const S=s+=1;a({id:y,failure:void 0});const A=o?.id===y&&r.catalog===o.catalog;(o&&!A&&r.catalog===o.catalog||y==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===y&&t.data&&(a({catalog:t.data}),l()),b(y,S),C(y,S)},prime(y,S,A){r.id&&r.id!==y||r.catalog||!S||(o=t?.id===y&&t.data&&(!A||t.time>=A.time)?{id:y,catalog:t.data}:{id:y,catalog:S,entry:A?{id:y,time:A.time,hash:A.hash,data:S}:void 0},a({catalog:o.catalog}))},useAntdLoader(y){m=y,r.id&&b(r.id,s)},state:i,snapshot:()=>r,dispose:()=>clearTimeout(c)}}var bv=class{http;constructor(e){this.http=e}jsonList=({locale:e},t={})=>this.http.request({path:`/translations/${e}.json`,method:"GET",format:"json",...t});getTranslations=({locale:e},t={})=>this.http.request({path:`/translations/${e}.po`,method:"GET",...t});localesList=(e={})=>this.http.request({path:"/translations/locales",method:"GET",format:"json",...e})},Qi=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),yv=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:o,format:i,baseUrl:s,cancelToken:a,...l})=>{const c=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},d=this.mergeRequestParams(l,c),m=o&&this.toQueryString(o),b=this.contentFormatters[r||"application/json"],v=i||d.format;return this.customFetch(`${s||this.baseUrl||""}${n}${m?`?${m}`:""}`,{...d,headers:{...d.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):d.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async w=>{const C=w;C.data=null,C.error=null;const y=v?w.clone():w,S=v?await y[v]().then(A=>(C.ok?C.data=A:C.error=A,C)).catch(A=>(C.error=A,C)):C;return a&&this.abortControllers.delete(a),S})}},Ev=H("rest.v2.transport"),Zi=Symbol("rest.v2.secureRequest");function _v(e){return e.getOrCreateInstance(Ev,()=>{const t=e.getInstance(Sd)?.execute||fetch;return new yv({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[Zi]:!0}),customFetch:(n,r={})=>{const{[Zi]:o,...i}=r;return t(n,{...i,[Lc]:o!==!0})}})})}function Ll(e,t){const n=_v(e);return Object.assign({},...t.map(r=>new r(n)))}function es(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function zn(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:es(n.details,"wp_code")??n.code,message:es(n.details,"wp_message")??n.message,details:n.details}}:t&&typeof t=="object"?{status:e.status,data:t}:{status:e.status,data:{message:e.statusText||"request failed"}}}function Nl(e){return!e.ok||!!e.error}function Fl(){return va(Ln.em_translations_v2)??!0}function wv(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Sv(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Iv(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],o=r[0];return typeof o=="string"&&o!==""&&t.push({locale:o,updatedAt:wv(r[1])}),t},[]):[]}function Cv(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Sv(n.updated_at),contentHash:n.content_hash}),t),[])}function Bl(e){return Ll(e,[bv])}function Pn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Kr(e){return!e.ok||e.error!=null}function Yr(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function dr(e){return{data:await xl(e)??null}}async function Tv(e){if(Fl())try{const n=await Bl(e).localesList();return Nl(n)?{error:zn(n)}:{data:Cv(n.data)}}catch(n){return Pn(n)}const t=Ys(e,[ra]);try{const n=await t.get_translations2({file:"react_app"});return Kr(n)?Yr(n):{data:Iv(n.data)}}catch(n){return Pn(n)}}async function Av(e,t){if(Fl())try{const r=await Bl(e).jsonList({locale:t});return Nl(r)?{error:zn(r)}:dr(r.data)}catch(r){return Pn(r)}const n=Ys(e,[ra]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Kr(r)?Yr(r):dr(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Kr(r)?Yr(r):dr(r.data)}catch(r){return Pn(r)}}}var dn=new WeakMap;function Rv(e){const t=dn.get(e);if(t!==void 0)return t;const n=Tv(e).then(r=>("error"in r&&dn.delete(e),r),r=>{throw dn.delete(e),r});return dn.set(e,n),n}var yt=H("locale.service");function Pv(e){if(e.getInstance(yt))return;const t=vv({readList:()=>Rv(e),readCatalog:n=>Av(e,n),askHost:async n=>(await pe(e,$.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Me)});e.inject(yt,t),e.getInstance(z)?.addDispose(()=>t.dispose())}function Ov(e){const t=e.getInstance(ve);if(!t)return;const n=e.getInstance(yt);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"ru_RU"));e.getInstance(z)?.addDisposable(r)}var Dv="user_id",kv="project_id",ts=H("rest.identityHeadersProvided");function xv(e){if(e.getInstance(ts))return;e.inject(ts,!0);let t;e.getInstance(be)?.watch(n=>{t=n}),e.addService(Mn,{execute(n,r){if(r?.public)return;const o=t?.user?.id??qa(e).profile?.id;o!=null&&o!==""&&n.headers.set(Dv,String(o));const i=t?.project;i!=null&&i!==""&&n.headers.set(kv,String(i))}})}function Mv(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function Lv(e){return e.id??Mv(e.catalog)}function Nv(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function Fv(e){return Nv(e||"en_US")}var Bv="Accept-Language",ns=H("rest.localeHeaderProvided");function jv(e){e.getInstance(ns)||(e.inject(ns,!0),e.addService(Mn,{execute(t){const n=e.getInstance(yt)?.snapshot();t.headers.set(Bv,Fv(n&&Lv(n)))}}))}function Uv(e){if(!e)return!1;try{return e.getInstance(Me)!==void 0}catch{return!1}}var Hv="Invalid standaloneKey.",zw=H("StandaloneMockGuard");function $v(){const e=new Error(Hv);return e.name="InvalidStandaloneKeyError",e}function Vv(e){e.addService(Mn,{execute:()=>{if(Uv(e))throw $v()}})}function qv(e){Vc(e),Vv(e)}function Gv(e){const t=new cl;e.inject(Pe,t);const n=e.getInstance(be)?.watch(o=>{if(!o)return;const i=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...i!==void 0?{signal:i}:{}})}),r=e.getInstance(z);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var jl=Xt("plugin.dataSource.blocks"),zv=Xt("plugin.dataSource.blockRevisions"),Wv=Xt("plugin.dataSource.comments"),Kv=Vn(),Yv=Vn(),Ul=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1005
1005
  <html>
1006
1006
  <head>
1007
1007
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -1042,10 +1042,10 @@ import{n as Ws,r as kc}from"./static/esm/971f1b2c.js";import{$ as xc,A as Mc,At
1042
1042
  </tr>
1043
1043
  </table>
1044
1044
  </body>
1045
- </html>`;function Xv(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:Ul,project:e?.id,project_title:e?.title??"",utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var Hl=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Jv(e){return!Object.keys(e).some(t=>Hl.has(t))}function Qv(e){const t={},n={};for(const[r,o]of Object.entries(e))Hl.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function rs(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function zn(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function Zv(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function Qt(e){return{emails:Ol(e),blocks:jl(e),emailRevisions:Dl(e),blocksRevision:Wv(e),comments:zv(e)}}function eb(e){const t=Object.values(Qt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Kn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Jv(e))return{email:rs(e)};{const{showOptions:n,misplacedEmailFields:r}=Qv(e),o=Object.keys(r);t&&o.length>0&&void 0;const i=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:rs({...r,...i})}}}function Wo(e){const t=nt(e);return t&&oe(t.sessionKey())?t.suspendedDocument():t?.current()}function gn(e){return Wo(e)?.getContent()}function $l(e,t){const n=t??Xv(),r=Wo(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:gn(e)??n.html}:n}async function Rt(e){return(await e.getInstanceAsync(He))?.project}async function Vl(e){return Vo(e)??await Rt(e)}async function os(e,t){const n=jl(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(o=>o!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await Vl(e),{filter:{id:t}})}function is(e){if(!e)return;if(zn(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=Kn(e,!1).email.id;return t==null?void 0:String(t)}function tb(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function nb(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}async function rb(e,t,n){const r=zt(e.getInstance(Pe)?.contentReadyTimeoutMs);let o;try{return await Promise.race([t,new Promise((i,s)=>{o=setTimeout(()=>{t.then(n,()=>{}),s(new Fn(r,"handleSaveBlock","block"))},r)})])}finally{clearTimeout(o)}}function Et({code:e,project:t,...n},r){const o=Le(n),i=Vo(r),s=Ve(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:s.toEditorForm(e)}:{},...i===void 0?{}:{project:i},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function Se({html:e,renderGuid:t,showToken:n,showId:r,...o},i){const{requested:s}=Jt(i),a=za(i);return Le({...o,code:Ve(i).toOutputForm(e),project:s===void 0?o.project:s,utm_parameters:a.UTMEnabled?o.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0,secretHash:void 0})}function Xr(e){return e==null?"":e.replaceAll(`\r
1045
+ </html>`;function Xv(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:Ul,project:e?.id,project_title:e?.title??"",utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var Hl=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Jv(e){return!Object.keys(e).some(t=>Hl.has(t))}function Qv(e){const t={},n={};for(const[r,o]of Object.entries(e))Hl.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function rs(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function Wn(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function Zv(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function Qt(e){return{emails:Ol(e),blocks:jl(e),emailRevisions:Dl(e),blocksRevision:zv(e),comments:Wv(e)}}function eb(e){const t=Object.values(Qt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Kn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Jv(e))return{email:rs(e)};{const{showOptions:n,misplacedEmailFields:r}=Qv(e),o=Object.keys(r);t&&o.length>0&&void 0;const i=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:rs({...r,...i})}}}function zo(e){const t=nt(e);return t&&oe(t.sessionKey())?t.suspendedDocument():t?.current()}function gn(e){return zo(e)?.getContent()}function $l(e,t){const n=t??Xv(),r=zo(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:gn(e)??n.html}:n}async function Rt(e){return(await e.getInstanceAsync(He))?.project}async function Vl(e){return Vo(e)??await Rt(e)}async function os(e,t){const n=jl(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(o=>o!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await Vl(e),{filter:{id:t}})}function is(e){if(!e)return;if(Wn(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=Kn(e,!1).email.id;return t==null?void 0:String(t)}function tb(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function nb(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}async function rb(e,t,n){const r=Wt(e.getInstance(Pe)?.contentReadyTimeoutMs);let o;try{return await Promise.race([t,new Promise((i,s)=>{o=setTimeout(()=>{t.then(n,()=>{}),s(new Fn(r,"handleSaveBlock","block"))},r)})])}finally{clearTimeout(o)}}function Et({code:e,project:t,...n},r){const o=Le(n),i=Vo(r),s=Ve(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:s.toEditorForm(e)}:{},...i===void 0?{}:{project:i},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function Se({html:e,renderGuid:t,showToken:n,showId:r,...o},i){const{requested:s}=Jt(i),a=Wa(i);return Le({...o,code:Ve(i).toOutputForm(e),project:s===void 0?o.project:s,utm_parameters:a.UTMEnabled?o.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0,secretHash:void 0})}function Xr(e){return e==null?"":e.replaceAll(`\r
1046
1046
  `,`
1047
- `)}function ss(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function ob(e,t,n,r){const o=ib(e,t,n,r);return o===void 0}function ib(e,t,n,r){if(zn(t))return"block";const{email:o}=Kn(t,!1),i=Et(o,e),s=i.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=nt(e)?.current();if(!a)return"no-session";const l=a.get(),c=l.attributes;if(l.serverId!==s)return"document-id";if(c.is_inited!==!0)return"not-inited";const d=ss(Xr(n??a.getContent()));if(i.html!==void 0&&ss(Xr(i.html))!==d)return"html";if(i.subject!==void 0&&i.subject!==c.subject)return"subject";if(i.preheader!==void 0&&i.preheader!==c.preheader)return"preheader";if(i.common_styles!==void 0&&i.common_styles!==c.common_styles)return"common_styles"}function as(e,t){if(zn(t))return;const{email:n}=Kn(t,!1),r=Et(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:Xr(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function sb(e){return Array.isArray(e)?e.some(t=>Lr(t)):Lr(e)}function ab(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])sb(t[n])&&delete t[n];return t}function lb(e,t){const n={...e};return delete n.id,{...n,...t}}function cb(e){return e.html?e:{...e,html:Ul}}function Qe({code:e,project:t,...n},r,o){const i=o??Vo(r);return{...n,...e?{html:Ve(r).toEditorForm(e)}:{},renderGuid:Ce(),...i===void 0?{}:{project:i}}}function ye({html:e,renderGuid:t,...n},r){const{requested:o}=Jt(r);return Le({...n,code:Ve(r).toOutputForm(e),project:o===void 0?n.project:o,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function ql(e){return nt(e)?.current()?.get().serverId??void 0}function Jr(e,t,n){return n===void 0&&(n=e.post===void 0?ql(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function Pt(e,t){return Le({...e,link:void 0,comment_status:void 0})}function vn({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?ql(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||mf(n.slug),parent:o}}function Qr({html:e,isAutosave:t,...n},r){return Le({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:Le({html:e,ampHtml:e&&""})})}function bn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function ls({html:e,isAutosave:t,...n}){return Le({...n,autosave:t?!0:void 0,code:e,guid:void 0})}function db(e){return String(e).replace(/"/g,"&quot;")}function ub(e=new Date){const t=n=>String(n).padStart(2,"0");return String(e.getFullYear())+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function Gl(e){const t=/<(table|tr|div)(\s[^>]*)>/gi;let n;for(;(n=t.exec(e))!==null;){const r=n[2]??"";if(/\bem\s*=\s*["']block["']/i.test(r))return{full:n[0],index:n.index}}return null}function cs(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),o=db(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function ds(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function Wl(e){if(!e?.trim())return{};const t=Gl(e);return t?{emBlockId:ds(t.full,"em-block-id"),emBlockVersion:ds(t.full,"em-block-version")}:{}}function zl(e,t,n){if(!e?.trim()||!t)return e;const r=Gl(e);if(!r)return e;const o=String(t),i=ub(n??new Date);let{full:s,index:a}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=cs(s,"em-block-id",o)),s=cs(s,"em-block-version",i),e.slice(0,a)+s+e.slice(a+l)}function fb(e,t){const{emBlockId:n,emBlockVersion:r}=Wl(e);return n&&r?e:zl(e,t)}var ht=H("NotificationService"),pb=H("emailTemplate.reads");async function hb(e,t){try{const n=rt(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,gb(e,t,n);return}}var mb=H("emailTemplate.notifiedFailures");function gb(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(mb,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(ht).then(()=>{qt(e,$.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function vb(e,t){const n=e.getOrCreateInstance(pb,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=hb(e,t).then(i=>(i===void 0&&n.delete(t),i));return n.set(t,o),o}var bb=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Qi.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Qi.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},zw=H("projects.v2IdByWpId"),Kw=H("projects.wpIdByV2Id"),Yw=H("emails.v2SavedAtOnOpen"),Xw=H("emails.v2OpeningReads"),Zr=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function yb(e,t){if(!t)throw new Zr(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new Zr(e,Wn(t))}function Eb(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var _b=/^[A-Za-z0-9_-]{1,128}$/,wb=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),us=new Set;function Sb(e){return _b.test(e)?!0:(us.has(e)||us.add(e),!1)}function Ib(e){return e&&!e.ok?String(Wn(e).data.code??""):""}var Kl=()=>({isAutosave:!1});function fs(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function Cb(e,t){const n=new AbortController,r=zt(e.getInstance(Pe)?.contentReadyTimeoutMs);let o;const i=new Promise((s,a)=>{o=setTimeout(()=>{n.abort(),a(new Zr("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),i])}finally{clearTimeout(o)}}function Tb(e,t){return ga(t,e==="block")}async function Ab(e,t,n,r,o){if(!Sb(n))return Kl();const i=vt(e),s=Kt(e),a=Tb(t,n);try{const l=await Rb(e,t,n,r,o);return l.id&&(i.set(a,l.id),s.delete(a)),l}catch(l){throw tp(s,a,r.html??""),l}}async function Rb(e,t,n,r,o){const i=Ll(e,[bb]),s={entityId:n,...o?{autosave:!0}:{}},a=await Cb(e,l=>t==="email"?i.emailsRevisionsCreate(s,fs(t,r),{signal:l}):i.blocksRevisionsCreate(s,fs(t,r),{signal:l}));return wb.has(Ib(a))?Kl():(yb("обновление",a),Eb(a.data??{}))}function Pb(e,t,n,r){return Ab(e,t,n,r,!1)}async function Ob(e,t,n){if(t==null||t===""||n===void 0||!wt(e))return ps;const r=Date.now(),o=Io(String(t));return Ua(o,{html:n},r,ko(vt(e),o,Kt(e),n)),await Pb(e,"block",String(t),{html:n}),Tn(o,r,vt(e).get(o)??void 0),()=>Co(o,r)}function ps(){}var ur="EXTERNAL",hs=Symbol("supersededShow");function Db(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var kb="email_id";function fr(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var xb=class extends ge{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=Xs();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=Qt(t),this._eventLock=eb(t);const n=te(e,$.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(te(e,$.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(Mn,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(kb,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Pe)??Fo}_throwIfDestroyed(){if(this.isDisposed())throw je()}async getTemplateEmail(e){const t=await vb(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,ab(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Rt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Qe(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,vn(o,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,Jr(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const i=this._dataSources.emails,s=i.cache,a=await Rt(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let c=Et(e,this._container);const d=c.id;let m=d;if(d!==void 0){const b=await i.get(d);c={...b??{},...c,utm_parameters:c.utm_parameters??b?.utm_parameters??{},renderGuid:b?.renderGuid??Ce(),...l>0?{showToken:l}:{},...o?{showId:o}:{},project:a}}else{m=n??Ce();const b=await i.get(m);c={...c,utm_parameters:c.utm_parameters??{},renderGuid:b?.renderGuid??Ce(),...l>0?{showToken:l}:{},...o?{showId:o}:{},project:a},delete c.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(c=lb(b,c))}return d===void 0&&(c=cb(c)),await s.setAll([[m,c]]),c}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==as(this._container,e))return!1;const n=gn(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=as(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:gn(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&tb({ticket:t,emailId:is(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,hs;if(!e)return;const n=this._getInitPipeline();if(ne(n.signal),zn(e))return this._showBlock(e,n);const r=oe(he(this._container).sessionKey()),o=nb(e);if(!r&&!o&&ob(this._container,e,gn(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const i=Kn(e);i.email.id,this._prevCommand?.id;let s,a="",l=0,c=!1,d,m=Promise.resolve(),b,v=!1;try{this._eventLock.suspendChange();const{email:w,blocks:C,autosaves:y,comments:S,templateId:A,reload:B}=i;s=w.id;const k=Et(w,this._container),P=k.id,T=P??Ce(),x=await Je("getProject",Rt(this._container));ne(n.signal),a=Ce();const R={isNew:P===void 0,id:String(T),project:x},h=B===!0&&P!==void 0;h&&(await this._dataSources.emails.remove(String(P),{silent:!0}),String(P)),l=++this._showToken,String(T);const f=[];f.push(this.setBlocks(C)),w.id!==void 0&&(f.push(this.setComments(S)),f.push(this.setEmailRevisions(y,String(w.id)))),f.push(this.setEmail(w,Lr(A)?A:Number(A),P===void 0?String(T):void 0,l,a)),await Je("setEmail+blocks+revisions",Promise.all(f),{emailId:P??String(T),showId:a,targetShowToken:l}),ne(n.signal);const u=await this._dataSources.emails.get(String(T)),g=he(this._container),O={id:a,token:l};if(r){mn(this._container);const I=g.suspendedDocument()?.get().serverId;!h&&P!==void 0&&I!=null&&String(I)===String(P)&&g.resumeSuspended()}P===void 0?b=g.startNewDraft(u??k,{patch:k,show:O}):h?b=g.reload(P,{email:u??k,patch:k,show:O}):g.sessionKey()===st(P)?b=g.show(k,O):b=g.open(P,{email:u??k,patch:k,show:O}),g.beginShowFill(a);const M=!!this._prevCommand&&xe(this._prevCommand,R);R.id,!this._prevCommand||xe(this._prevCommand,R),this._prevCommand?.id,this._rememberShow(R),m=n.requestShow({showId:a,navId:String(T),emailId:P,isNew:P===void 0}),v=!0;const _=()=>g.endShowFill(a);Promise.allSettled([m,b.whenReady()]).then(_),String(T),c=!0}catch(w){d=w,v&&a&&n.failShow(a,w),a&&nt(this._container)?.endShowFill(a),uo(w)||(fa(w),void 0)}finally{this._eventLock.resumeChange()}if(!c)throw d instanceof Error?d:new Error(`[emailmaker] show() setup failed: ${String(d??"unknown error")}`);return Je("show-init-deferred",Promise.all([m,b?.whenReady().catch(w=>{if(w instanceof tt){const C=Do(w);throw C?new Error(`[emailmaker] show(): email open failed (${C})`,{cause:w}):w}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:i,reload:s}=Zv(e),a=Ce();let l=!1;try{await this.setBlocks(o),ne(t.signal),s&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const c=n.id!==void 0&&n.id!==""?String(n.id):void 0,d=he(this._container);if(!s&&c!==void 0&&d.sessionKey()===Sn(c)){const A=fr(n)?await this._storeShownBlock(n):void 0,B={id:a,token:++this._showToken},k=d.show(A,B),P=t.requestShow({showId:a,navId:c,emailId:void 0,isNew:!1});l=!0,await Je("show-block-init",Promise.all([P,k?.whenReady().catch(()=>{})]),{showId:a});return}const m=r||s?await os(this._container,String(n.id)):void 0,b=m&&(s||fr(n))?await this._storeShownBlock({...ye(m,this._container),...n}):r||s?m:await this._storeShownBlock(n);if(ne(t.signal),!b)throw new Error(`[emailmaker] show(): block ${String(n.id)} not found`);i!==void 0&&b.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(i.filter(A=>A.id!==void 0).map(A=>[A.id,bn(A,String(b.id))])),this._prevCommand=void 0,this._lastShow=void 0;const v=b.id!==void 0?String(b.id):Ce(),w={id:a,token:++this._showToken};mn(this._container);const C=s?d.reloadBlock(v,b,w):d.openBlock(v,b,w);b.id;const y=t.requestShow({showId:a,navId:v,emailId:void 0,isNew:b.id===void 0});l=!0;const S=C.whenReady().catch(A=>{if(A instanceof tt)throw A});await Je("show-block-init",Promise.all([y,S]),{showId:a})}catch(c){throw l&&t.failShow(a,c),c}}async _storeShownBlock(e){const t=Qe(e,this._container,await Rt(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();ne(e.signal);const t=he(this._container);if(oe(t.sessionKey())&&!t.hasSuspended())throw new Error("[emailmaker] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:ur,fallbackTitle:Qa(this._container)});if(ne(e.signal),!n)throw Db(t.emailSaveState().error);return Se($l(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=he(this._container),t=e.current();if(!t||!oe(e.sessionKey()))throw new Error("[emailmaker] saveBlock(): no open block");return Gu(t,async()=>{await t.whenReady();const n=qn(t),r=t.get().version,o=t.get().serverId,i=typeof n.global_block=="boolean"?n.global_block:o!=null&&Wl(n.html??"").emBlockId===String(o),s=o!=null&&i?zl(n.html,String(o),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:s,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},l=this._dataSources.blocks,c=await Ob(this._container,t.get().serverId,a.html),d=t.get().serverId==null?l.create(a,{source:ur}):l.update(String(t.get().serverId),a,{source:ur}),m=await rb(this._container,d,b=>{b&&c(),b&&he(this._container).current()===t&&t.get().serverId==null&&b.id!==void 0&&t.markSaved(r,String(b.id))});if(!m)throw new Error("[emailmaker] save(): block was not saved");return c(),t.markSaved(r,m.id!==void 0?String(m.id):void 0),ye(m,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=is(e);const n=this._queuedShow(e,t).then(r=>r===hs?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),ne(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=he(this._container);if(n!==void 0&&r.sessionKey()===Sn(n))return;const o=t.code===void 0&&n!==void 0?await os(this._container,n):void 0,i=o&&fr(t)?await this._storeShownBlock({...ye(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!i)throw new Error(`[emailmaker] openBlock(): block ${String(n)} not found`);mn(this._container);const s=r.openBlockOver(i.id!==void 0?String(i.id):Ce(),i);i.id,r.hasSuspended(),pe(this._container,$.ON_BLOCK_OPEN_ID).fire({block:i}),await s.whenReady().catch(a=>{if(a instanceof tt)throw r.current()===s&&(pe(this._container,$.ON_BLOCK_CLOSE_ID).fire({block:i,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),dm(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function Mb(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function Lb(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),o=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:o,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Mb(e)}}function pr(e,t){return t?Lb(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Yl=["title","slug","type","tags","blocktags","modified","author","lock","subject","description","excerpt","status","is_template","link","renderGuid","date","date_gmt","modified_gmt","comment_status","ping_status","template","related_email","project_title","project_author","isAmp","meta"],Nb=[...Yl,"html","id","project","password"],Jw=new Set(["html",...Yl,"global_block","project"]);function Fb(e){if(!e||typeof e!="object")return{};const t={};e.id!=null&&e.id!==""&&(t.id=String(e.id)),e.title!=null&&e.title!==""&&(t.title=e.title),e.slug!=null&&e.slug!==""&&(t.slug=e.slug),e.type!=null&&e.type!==""&&(t.type=e.type),e.tags!=null&&(t.tags=e.tags),e.blocktags!=null&&(t.blocktags=e.blocktags),e.modified!=null&&e.modified!==""&&(t.modified=e.modified),e.author!=null&&e.author!==""&&(t.author=String(e.author)),e.lock!=null&&(t.lock=e.lock),e.subject!=null&&e.subject!==""&&(t.subject=e.subject),e.description!=null&&e.description!==""&&(t.description=e.description),e.excerpt!=null&&e.excerpt!==""&&(t.excerpt=e.excerpt),e.status!=null&&e.status!==""&&(t.status=e.status),e.is_template!=null&&(t.is_template=e.is_template),e.link!=null&&e.link!==""&&(t.link=e.link),e.renderGuid!=null&&e.renderGuid!==""&&(t.renderGuid=e.renderGuid),e.date!=null&&e.date!==""&&(t.date=e.date),e.date_gmt!=null&&e.date_gmt!==""&&(t.date_gmt=e.date_gmt),e.modified_gmt!=null&&e.modified_gmt!==""&&(t.modified_gmt=e.modified_gmt),e.comment_status!=null&&e.comment_status!==""&&(t.comment_status=e.comment_status),e.ping_status!=null&&e.ping_status!==""&&(t.ping_status=e.ping_status),e.template!=null&&e.template!==""&&(t.template=e.template),e.related_email!=null&&e.related_email!==""&&(t.related_email=e.related_email),e.project_title!=null&&e.project_title!==""&&(t.project_title=e.project_title),e.project_author!=null&&e.project_author!==""&&(t.project_author=e.project_author),e.isAmp!=null&&(t.isAmp=e.isAmp),e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object"&&(t.meta=e.meta);const n=new Set(Nb),r={};for(const o of Object.keys(e))n.has(o)||(r[o]=e[o]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Bb(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Fb(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var eo=new WeakMap;function jb(e){let t=eo.get(e);return t||(t={byId:new Map,fallback:[]},eo.set(e,t)),t}function Ub(e){eo.delete(e)}function Hb(e,t){const{byId:n,fallback:r}=jb(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const i=r.indexOf(o);return i>=0&&r.splice(i,1),o}return}for(let o=r.length-1;o>=0;o--){const i=r[o],s=e.name!=null&&e.name!==""&&i.name!=null&&i.name!==""&&i.name===e.name,a=e.type!=null&&e.type!==""&&i.insertFrom===e.type;if(s&&a)return r.splice(o,1),i.id!=null&&i.id!==""&&n.delete(String(i.id)),i}}async function $b(e,t){const{blocks:n}=Qt(e);return await n.cache.getIfPresent(t)??void 0}async function Vb(e,t){if(!t.blockId)return;const n=await $b(e,t.blockId);if(n)return Bb(n,t)}async function qb(e,t){const n=Hb(e,t);if(n)return pr(e,n);const r=await Vb(t,e);return r?pr(e,r):pr(e,void 0)}var Gb=Qs("application_block_inserted"),Wb=-1e3,ms=new WeakSet;function zb(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.type=="string"||typeof t.name=="string"||typeof t.blockId=="string"||typeof t.project=="string"||typeof t.project=="number"}function Kb(e){if(!e||ms.has(e))return;ms.add(e);const t=new ge,n=fe(e);return t.addDisposable(n.addListenerAsyncPipe(Gb,async(r,o)=>{const i=zb(r)?await qb(r,e):r;return o?o(i):i},Wb)),t.addDisposable({dispose:()=>{Ub(e)}}),t}var Yb=Vn("plugin.readBlockAutosave"),Qw=H("blockDocuments.provided"),Xl=H("plugin.earlyWindow");function Xb(e){return e.getOrCreateInstance(Xl,()=>({depth:0}))}function Jb(e){const t=Xb(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function Jl(e){return(e?.getInstance(Xl)?.depth??0)>0}function Ql(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,i,s)=>{const a=e(o,i,s);if(r&&Jl(t)){const l=n;queueMicrotask(()=>{o.call(s,l)})}return a}}var hr=100,Qb=class extends ge{_container;_events;constructor(e){super(),this._container=e;const t=Kb(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:i}=Qt(e),s=te(e,$.ON_SHARE_ID),a=te(e,$.ON_SHOW_PREVIEW_ID),l=te(e,$.ON_EMAIL_CLONE_ID),c=te(e,$.ON_BLOCK_OPEN_ID),d=te(e,$.ON_BLOCK_CLOSE_ID),m=te(e,$.ON_BLOCK_CLONE_ID),b=te(e,$.ON_BLOCK_INIT_ID),v=te(e,$.ON_BLOCK_CHANGED_ID),w=te(e,$.ON_CODE_VALIDATE_ID),C=te(e,$.ON_IMPORT_VALIDATE_ID),y=te(e,$.ON_SUBJECT_CHANGED_ID),S=te(e,$.ON_EMAIL_CHANGED_ID),A=te(e,$.ON_PREHEADER_CHANGED_ID),B=te(e,$.ON_SAVEBUTTON_CLICK_ID),k=te(e,$.ON_BLOCK_SAVEBUTTON_CLICK_ID),P=te(e,$.ON_NEXTBUTTON_CLICK_ID),T=te(e,$.ON_SEND_LIVEPREVIEW_ID),x=te(e,$.ON_SEND_TESTEMAIL_ID),R=te(e,Yv),h=te(e,$.ON_CONTENT_CHANGED_ID),f=te(e,Kv),u=te(e,$.ON_PREVIOUSBUTTON_CLICK_ID),g=te(e,$.ON_SEND_EMAIL_MODAL_ID),O=$c(te(e,$.ON_EMAIL_INIT_ID),_=>!_.reset),M=te(e,$.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:V(A),handleSubjectChanged:V(y),handleValidate:V(w),handleImportValidate:V(C),handleReadEmail:V(n.handlerRead,_=>_,_=>_&&Et(_,e)),handleSaveEmail:V(n.onSave,function({prev:_,patch:I,value:F,source:j}){const K=_?Se(_,e):void 0;return{prev:K,patch:Lt(K,Se(I,e)),value:Se(F,e),source:j}},_=>_?Et(_,e):void 0),handleRemoveEmail:V(n.onRemove,({value:_,source:I})=>({value:Se(_,e),source:I}),()=>{}),handleReadCommonBlocks:V(R,_=>_.project,_=>_?.map(I=>Qe(I,e))),handleReadTemplateBlocks:V(f,_=>_,_=>_?.map(I=>Qe(I,e))),handleReadBlocks:V(t.byForeignKey("project").handleRead,_=>Jt(e).requested||String(_),_=>_?.map(I=>Qe(I,e))),handleReadBlock:V(t.handlerRead,_=>_,_=>_?Qe(_,e):void 0),handleOpenBlock:V(c,({block:_})=>({block:ye(_,e)})),handleCloseBlock:V(d,({block:_,hasUnsavedChanges:I})=>({block:ye(_,e),hasUnsavedChanges:I})),handleCloneBlock:V(m,_=>ye(_,e)),handleSaveBlock:V(t.onSave,function({prev:_,patch:I,value:F,source:j}){const K=F.global_block===!0&&F.id&&typeof F.html=="string"?{...F,html:fb(F.html,String(F.id))}:F,de=_?ye(_,e):void 0;return{prev:de,patch:Lt(de,ye(I,e)),value:ye(K,e),source:j}},_=>_?Qe(_,e):void 0),handleRemoveBlock:V(t.onRemove,({value:_,source:I})=>({value:ye(_,e),source:I}),()=>{}),handleReadComments:V(r.byForeignKey("post").handleRead,_=>_,_=>_?.map(I=>Jr(I,e))),handleSaveComment:V(r.onSave,function({prev:_,patch:I,value:F,source:j}){const K=_?Pt(_,e):void 0;return{prev:K,patch:Lt(K,Pt(I,e)),value:Pt(F,e),source:j}},_=>_?Jr(_,e):void 0),handleRemoveComment:V(r.onRemove,({value:_,source:I})=>({value:Pt(_,e),source:I}),()=>{}),handleReadEmailRevisions:V(o.byForeignKey("parent").handleRead,_=>_,_=>_?.map(I=>vn(I,e))),handleReadEmailAutosave:V(te(e,kl),_=>_,_=>_?vn(_,e):null),handleEmailAutosave:V(o.onSave,function({prev:_,patch:I,value:F,source:j}){return{value:Qr(F,e),source:j}},_=>_?vn(_,e):void 0),handleRemoveEmailAutoSave:V(o.onRemove,({value:_,source:I})=>({value:Qr(_,e),source:I}),()=>{}),handleReadBlockRevisions:V(i.byForeignKey("parent").handleRead,_=>_,_=>_?.map(I=>bn(I))),handleReadBlockAutosave:V(te(e,Yb),_=>_,_=>_?bn(_):null),handleBlockAutosave:V(i.onSave,({value:_,source:I})=>({value:ls(_),source:I}),_=>_?bn(_):void 0),handleRemoveBlockAutoSave:V(i.onRemove,({value:_,source:I})=>({value:ls(_),source:I}),()=>{}),handleBlockInit:V(b,_=>ye(_,e)),handleBlockChanged:V(Zn(v,hr),_=>ye(_,e)),handleEmailChanged:V(Zn(S,hr),_=>Se(_,e)),handleEmailInit:Ql(V(O,_=>Se(_,e)),e),handlePreviousButtonClick:V(u,_=>Se(_,e)),handleNextButtonClick:V(P,_=>Se(_,e)),handleSaveButtonClick:V(B,_=>Se(_,e)),handleSaveBlockButtonClick:V(k,_=>ye(_,e)),handleHtmlChanged:V(Zn(h,hr)),handleTestEmailSend:V(x,({html:_,...I})=>({...I,code:_,compiled:{html:_,ampHtml:""}})),handleTestEmailModal:V(g,_=>Se(_,e)),handleCloneEmail:V(l,_=>Se(_,e)),handleShareEmail:V(s),handlePreviewEmail:V(a),handleLivePreviewEmail:V(T),handleAnalyticsEvent:V(M)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new pt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Zb=H("DataController"),ey=H("DataEvents");function Zl(e){return e.getOrCreateInstance(Zb,()=>{const t=new xb(e);return e.getInstance(W)?.addDisposable(t),t})}function ec(e){return e.getOrCreateInstance(ey,()=>new Qb(e))}var ty=H("plugin.pluginStart");function tc(e){return e.getOrCreateInstance(ty,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(W)?.addDispose(()=>t()),{done:n,finish:t}})}function ny(e){return tc(e).done}function ry(e){const t=tc(e);return t.run===void 0&&(t.run=(e.getInstance(mo)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var oy=H("plugin.startupShow");function iy(e){const t=Zl(e),n=ec(e),r=e.getInstance(be),o=e.getInstance(W),i={current:Promise.resolve()};e.inject(oy,i);let s=!1;const a=r?.watch(c=>{c&&n.setOptions(c),s=(c?.plugins?.length??0)>0,i.current=i.current.catch(()=>{})}),l=r?.select(c=>c?.content).watch(c=>{if(c===void 0)return;const d=()=>(ie(me.showStart),t.show(c).finally(()=>ie(me.showEnd))),m=s?ny(e).then(d):d();m.catch(()=>{}),i.current=m});a&&o?.addDisposable(a),l&&o?.addDisposable(l)}function sy(e){const t=Zl(e);return{...ec(e).get(),show(n){return ie(me.showStart),t.show(n).finally(()=>ie(me.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return ie(me.showStart),t.showBlock(n,r).finally(()=>ie(me.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function nc(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Yn(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let i=t;i<e.length;i++){const s=e[i];if(o){o=!1;continue}if(s==="\\"){o=!0;continue}if(r){s===r&&(r="");continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n++;continue}if(s===")"&&(n--,n<0))return!1}return n===0}function ay(e){return(t,n,r)=>Yn(t)?e(t,n,r):!1}function ly(e){return t=>Yn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function cy(e){return(t,n,r)=>Yn(t)?nc(t)?e(t,n,r):t:!1}function dy(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Yn(n)?nc(n)?e(t):t:!1}}function uy(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function zo(e,t){const n=e.length;for(let r=0;r<n;r++){const o=e.charCodeAt(r);if(o===0||t==='"'&&o===34||t==="'"&&o===39||t===""&&(o===32||o===9||o===10||o===13||o===12||o===34||o===39||o===60||o===62||o===61||o===96))return!1}return!0}function fy(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let i=0;i<e;i++){const s=r[i]%62;o+=t.charAt(s)}return o}var py=8,hy=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=fy(py),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Xn=new hy;function gs(e,t){return t!==void 0&&!zo(e,t)?`%|{${Xn.getOrCreateByKey(e)}}|%`:e}function my(e){const t=Xn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function ce(e,t,n){return t!==void 0?zo(e,t)?e:`%|{${Xn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function gy(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ae(e){return e.startsWith("<!--")&&e.endsWith("-->")?gy(e.slice(4,-3)):e}function vy(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const o=e.match(/\[%\s*([^%]*?)\s*%\]/);o&&(r=o[1]);const i=r.trim();return t.test(i)||n.test(i)}function by(e,t,n){return t!==void 0?zo(e,t)?e:`%|{${Xn.getOrCreateByKey(e)}}|%`:n||uy(e)||vy(e)?`<!--${e}-->`:e}var ze=ay(ce),Ke=ly(ae),yy=cy(ce),Ey=dy(ae),rc=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",my),e.escape("@{","}",ce,!0).unescape("<!--@{","}-->",ae,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",gs,!0),e.escape("{{","}}",gs,!0),e.createSyntax("brace-percent").escape("{%","%}",ce).unescape("<!--{%","%}-->",ae),e.createSyntax("brace-hash").escape("{#","#}",ce).unescape("<!--{#","#}-->",ae),e.createSyntax("proscript").escape("[%","%]",by,!0).unescape("<!--[%","%]-->",ae,!0),e.createSyntax("getresponse").escape("[[IF","]]",ce).escape("[[if","]]",ce).escape("[[ELSE]]","",ce).escape("[[else]]","",ce).escape("[[ENDIF]]","",ce).escape("[[endif]]","",ce).unescape("<!--[[IF","]]-->",ae).unescape("<!--[[if","]]-->",ae).unescape("<!--[[ELSE]]","-->",ae).unescape("<!--[[else]]","-->",ae).unescape("<!--[[ENDIF]]","-->",ae).unescape("<!--[[endif]]","-->",ae),e.createSyntax("expert-sender").escape("<if",">",ce).escape("</if",">",ce).escape("<else",">",ce).escape("</else",">",ce).escape("<var ",">",ce,!0).unescape("<!--<if ",">-->",ae).unescape("<!--</if",">-->",ae).unescape("<!--<else ",">-->",ae).unescape("<!--</else",">-->",ae).unescape("<!--<var",">-->",ae,!0),e.createSyntax("velocity").escape("#if",")",ze).escape("#elseif",")",ze).escape("#else","",ce).escape("#foreach",")",ze).escape("#macro",")",ze).escape("#set",")",yy,!0).escape("#parse",")",ze).escape("#include",")",ze).escape("#evaluate",")",ze).escape("#end","",ce).escape("#break","",ce).escape("#stop","",ce).unescape("<!--#macro","-->",Ke).unescape("<!--#if","-->",Ke).unescape("<!--#elseif","-->",Ke).unescape("<!--#else","-->",ae).unescape("<!--#foreach","-->",Ke).unescape("<!--#parse","-->",Ke).unescape("<!--#include","-->",Ke).unescape("<!--#evaluate","-->",Ke).unescape("<!--#end","-->",ae).unescape("<!--#break","-->",ae).unescape("<!--#stop","-->",ae).unescape("<!--#set","-->",Ey,!0),e.createSyntax("mailchimp").escape("*|","|*",ce).unescape("<!--*|","|*-->",ae)},to="bare",_y=new Map;function wy(e){return e?_y.get(e)??to:to}var oc=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function vs(e){return oc.includes(e)}function Ct(e){return e==="bare"||e==="html-comment"}function mr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Sy(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!Ct(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[c,d]of[["output",r.output],["editor",r.editor]])if(d!==void 0&&!Ct(d))return t(`templateDirectives.${c}: unknown form "${String(d)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!mr(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[c,d]of Object.entries(r.syntaxes))if(!(!vs(c)||d===void 0||Ct(d))){if(!mr(d))return t(`templateDirectives.syntaxes.${c}: expected a form or an object, configuration ignored.`),n;for(const m of["output","editor"]){const b=d[m];if(b!==void 0&&!Ct(b))return t(`templateDirectives.syntaxes.${c}.${m}: unknown form "${String(b)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??to;let i=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),i=void 0);const s=[];if(r.syntaxes)for(const c of Object.keys(r.syntaxes)){if(!vs(c)){t(`templateDirectives.syntaxes: unknown syntax id "${c}", entry ignored.`);continue}s.push(c)}else s.push(...oc);const a={},l={};for(const c of s){const d=r.syntaxes?.[c],m=mr(d)?d:void 0,b=(Ct(d)?d:m?.output)??o;let v=m?.editor??i??b;b==="bare"&&v==="html-comment"&&(t(`templateDirectives.syntaxes.${c}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),v="bare"),a[c]=b,l[c]=v}return{output:a,editor:l}}function ic(e,t,n,r){for(let o=t;o<n;o++){const i=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?i===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(i)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):i==="<"?r.insideTag=!0:i===">"?r.insideTag=!1:r.insideTag&&(i==='"'||i==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=i,r.unquotedAttr=!1):r.insideTag&&/\S/.test(i)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(i)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function Ot(e,t){return e.start<t.end&&t.start<e.end}function bs(e,t,n,r,o=[]){if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return[];const i=t.flatMap(d=>d.match(e).flatMap(m=>!Number.isInteger(m.start)||!Number.isInteger(m.end)||m.start<0||m.end>e.length||m.start>=m.end?[]:[{range:m,mapFn:d.mapFn,overrideBuiltins:d.overrideBuiltins,syntax:d.syntax,isVariable:d.isVariable}])).sort((d,m)=>d.range.start-m.range.start||d.range.end-m.range.end),s=[],a=o.slice().sort((d,m)=>d.start-m.start),l={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(const{range:d,mapFn:m,overrideBuiltins:b,syntax:v,isVariable:w}of i){if(r?(l.insideAttributeValue=!0,l.attributeQuoteChar='"'):ic(e,c,d.start,l),c=d.end,a.some(A=>Ot(A,d)))continue;const C=l.insideAttributeValue?l.attributeQuoteChar??"":void 0,y=e.substring(d.start,d.end),S=m(y,C,l.insideTag);S!==!1&&S!==y&&(s.push({range:d,text:S,overrideBuiltins:b,syntax:v,isVariable:w}),a.push(d))}return s.sort((d,m)=>d.range.start-m.range.start||d.range.end-m.range.end)}function Iy(e,t){const n=t.reduce((a,{mapFn:l,start:c,end:d,syntax:m,isVariable:b})=>(a[c]||(a[c]=[]),a[c].push({value:d,mapFn:l,syntax:m,isVariable:b}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),i=[];let s;for(;(s=o.exec(e))!==null;){const a=s[0];i.push({start:s.index,startToken:a,endTokens:n[a]})}return i}function gr(e,t,n,r,o=!1){const i=[];if(n&&(t=t.filter(c=>c.isVariable)),!t.length)return i;const s=Iy(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(let c=0;c<s.length;c++){const{start:d,startToken:m,endTokens:b}=s[c];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):ic(e,l,d,a),l=d;const v=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let w=!1;for(const{mapFn:C,value:y,syntax:S,isVariable:A}of b){let B=d+m.length,k=e.indexOf(y,B);for(;k!==-1;){let P=k,T=d+m.length,x=0;for(;P!==-1;){const g=e.indexOf(m,T);if(g!==-1&&g<P)x++,T=g+m.length,P=e.indexOf(y,T);else if(x>0)x--,T=P+y.length,P=e.indexOf(y,T);else break}if(P<0)break;const R=P+y.length,h=e.substring(d,R),f=C(h,v,a.insideTag);if(f===!1){B=k+Math.max(y.length,1),k=e.indexOf(y,B);continue}(o||f!==h)&&i.push({range:{start:d,end:R},text:o?h:f,syntax:S,isVariable:A});const u=s.findIndex(({start:g})=>g>=R);u>c?c=u-1:c=s.length,w=!0;break}if(w)break}}return i}function un(e,t){if(!t.length)return e;const n=t.slice().sort((o,i)=>i.range.start-o.range.start);let r=e;for(const{text:o,range:i}of n)r=r.slice(0,i.start)+o+r.slice(i.end);return r}var Cy=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=rc){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,i,s){return t.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this},unescape(r,o,i,s){return n.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let o=!1;const i={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(s=>s!==n),this._unescapeMatchers=this._unescapeMatchers.filter(s=>s!==r))}};return this.addDisposable(i),i}_collectMappings(e,t,n){const r=gr(e,this._escapes,t,n),o=bs(e,this._escapeMatchers,t,n),i=o.filter(l=>l.overrideBuiltins).map(l=>l.range),s=r.filter(l=>!i.some(c=>Ot(c,l.range))),a=o.filter(l=>l.overrideBuiltins||!s.some(c=>Ot(l.range,c.range)));return[...s,...a].sort((l,c)=>l.range.start-c.range.start||l.range.end-c.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=gr(e,this._unescapes,t),r=bs(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),i=n.filter(a=>!o.some(l=>Ot(l,a.range))),s=r.filter(a=>a.overrideBuiltins||!i.some(l=>Ot(a.range,l.range)));return[...i,...s].sort((a,l)=>a.range.start-l.range.start||a.range.end-l.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>wy(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return gr(e,this._escapes,t,n,!0)}getEscapedText(e,t){return un(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return un(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=i=>i===void 0?void 0:t[i],r=Object.values(t);let o=e;return r.includes("bare")&&(o=un(o,this._collectRevertMappings(o).filter(i=>n(i.syntax)==="bare"))),r.includes("html-comment")&&(o=un(o,this._collectMappings(o).filter(i=>!i.isVariable&&n(i.syntax)==="html-comment"&&i.text.startsWith("<!--")&&i.text.endsWith("-->")))),o}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}},sc="em___script",Dt=`<${sc}`,no=`</${sc}>`;function ys(e){return e.replace("<script",Dt).replace("<\/script>",no)}var Es=new Cy(e=>{e.escape("<script","<\/script>",t=>ys(t)).unescape(Dt,no,t=>t.replace(Dt,"<script").replace(no,"<\/script>")),e.escape("<script","/>",t=>ys(t)).unescape(Dt,"/>",t=>t.replace(Dt,"<script")),rc(e)});function Ty(e){const t=Sy(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return Ea();const n=new Set(Object.keys(t.output).filter(o=>t.output[o]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:o=>Es.normalizeToPolicy(o,t.editor),toOutputForm:o=>Es.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:ya(r)}}function Ay(e){let t;e.injectFactory(fo,()=>{const n=e.getInstance(ve)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:Ty(n)}),t.policy})}var Ry=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function Py(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function Oy(e,t){const n=[];for(const r of e.awaits?.services??[])for(const o of t.get(r)??[])o!==e&&n.push(o);return n}function ac(e){const t=Py(e),n=[],r=new Set,o=[],i=new Set,s=a=>{if(!r.has(a)){if(i.has(a)){const l=o.indexOf(a);throw new Ry([...o.slice(l),a].map(c=>c.name))}i.add(a),o.push(a);for(const l of Oy(a,t))s(l);o.pop(),i.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var Dy=[{name:"rest.client",setup:qv},{name:"auth.oauth",setup:Ed},{name:"rest.identityHeaders",setup:xv},{name:"rest.localeHeader",setup:jv},{name:"lifetime.destroyable",provides:[$o],setup:Ng},{name:"appInit",provides:[He,_o],setup:eu},{name:"config",provides:[ve],setup:Mg},{name:"templateDirectives",provides:[fo],setup:Ay},{name:"email.documents",setup:tv},{name:"show.initPipeline",provides:[Pe],setup:Gv},{name:"show",setup:iy},{name:"locale.service",provides:[yt],setup:Pv},{name:"locale.fromConfig",awaits:{services:[ve,yt]},setup:Ov},{name:"canvas.early",setup:Pm},{name:"canvas.previewSettings",setup:Gm},{name:"canvas.sandboxExtensions",setup:zm},{name:"canvas.sandboxScriptRelay",setup:Xm},{name:"canvas.headerSync",provides:[jo],setup:km},{name:"canvas.headersAfterRecovery",setup:xm},{name:"canvas.ampSync",setup:Rp},{name:"canvas.moduleBridge",setup:ih},{name:"canvas.port",setup:Bp},{name:"canvas.images",setup:Np},{name:"canvas.edits",setup:Am},{name:"canvas.surfaceFollowsSession",setup:fm},{name:"canvas.blockContent",setup:um},{name:"canvas.sandboxFill",provides:[Bo],setup:hg},{name:"canvas.reactions",setup:Rm}],_s;function Ko(e){const t=e.getInstance(be);if(t)return t;e.getInstance(W)||e.inject(W,new ge);const n=Ee();e.inject(be,n),_s??=ac(Dy);for(const r of _s)r.setup(e);return n}function ky(e){}var xy=[{name:"save.previewFollow",setup:ky}],ws=H("plugin.lateUnitsInstalled");function My(e){if(!e.getInstance(ws)){e.inject(ws,!0);for(const t of ac(xy))t.setup(e)}}function Ly(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function Ny(e){if(!e)return;const t=ho(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(r=>typeof r=="string"?r.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(r=>/^project_\d+$/.test(r))?.replace(/^project_/,"")||void 0}var Fy=_t(e=>{let t,n,r;return{async setOptions(o){const i=r!==o.getAuthToken,s=!xe(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(Me)||!o.getAuthToken)&&!(!i&&!s&&!a))try{const l=await o.getAuthToken(o.user,o.project);e.inject(rd,Promise.resolve(l||""));const c=Ny(l);if(!c)return;e.inject(Yc,c);const d=e.getInstance(He),m=d?await d.catch(()=>{}):void 0;e.inject(He,Promise.resolve(Ly(c,m)))}catch{}}}});function By(e,t){if(e.getInstance(oi))return;e.inject(oi,!0);const n=Ie(e,$.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var jy=_t(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!Yt(r)){t&&(wg(e),Ho(r)),t=void 0;return}const i=Gn(r);if(!i||t===i&&e.getInstance(Me))return;t=i,e.inject(Me,i);const s=e.getInstance(W);s&&By(e,s)}}}),Uy=_t(e=>{const t=e.getInstance(W),n=Ie(e,Js),r=V(n),o=t.addDisposable(new pt(r));return{setOptions({handleLoad:i}){o.setListener(i)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function lc(e,t,n=!0){const r=e,o=t;for(const i of Object.keys(o)){const s=o[i];s!=null&&(n&&typeof s=="object"?r[i]=lc(r[i]||{},s,!0):r[i]=s)}return e}async function Hy(e){const t=(await Cd(()=>import("./static/esm/2490dab8.js").then(n=>kc(n.default)),[],import.meta.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var cc=H("EditorOptions"),ro=ad;function $y(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function Vy(e){return e.getOrCreateInstance(cc,()=>{const t=Ee(ro);let n=ro.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(Hy(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function qy(e){return e?.getInstance(cc)?.get()??ro}function Gy(e,t={}){const n=Vy(e);n.set(lc({...n.get()},$y(t)))}function Wy(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function zy(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var Ky=H("plugin.publicConfig");function oo(e){return e.getInstance(ve)?.get()??{}}function Ss(e){return e.getInstance(ve)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Is(e){const t=Sl(e),n=oo(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:zy(qy(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Cs(e){return e.getInstance(ve)?.get()!==void 0}function Yy(e){const t=Xs(),n=pe(e,Zs);let r,o,i=!1;const s=async()=>{try{return e.getInstance(He)===void 0?{}:(await e.getInstanceAsync(He))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:m=!1}={})=>{await e.getInstance(ve)?.ready(),oa(e).set(oo(e).revisionService===!0);const{codeModeDirection:b,editor:v}=oo(e);v&&Gy(e,Wy(v)),b!==void 0&&!(m&&b===o)&&(o=b,b==="none"?qr(e,!1):(qr(e,!0),Um(e,b)))},l=async()=>{if(!Cs(e))return;const m=Is(e),b=JSON.stringify(m);b!==r&&(r=b,await n.fire(m))},c=async m=>{const b=e.getInstance(ve),v={advancedConfigs:Ss(e).advancedConfigs,serverSide:await s(),user:m};b?.setAdvancedConfigs({...v.advancedConfigs,...v.user?.advancedConfigs});const w=b?.layers().user.mode;b?.replace(v.user?.mode===void 0&&w!==void 0?{...v.user,mode:w}:v.user,"user"),b?.replace(v.serverSide,"server"),await a(),await l()},d=m=>{const{commonStyles:b,...v}=m;return"commonStyles"in m&&$m(e,b===void 0?void 0:b),v};return{queue:t,reactToConfig:a,emitConfigChanged:l,resolveServerSideConfig:s,getConfig:()=>Cs(e)?Is(e):{},setConfig:t.decorate(async m=>{await c(d(m))}),updateConfig:t.decorate(async m=>{const b=d(m);await c({...Ss(e).user,...b})}),announceAssembled(){i||(i=!0,e.getInstance(ve)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await l()})))}}}function dc(e){return e.getOrCreateInstance(Ky,()=>Yy(e))}function Xy(e){const t=dc(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Jy=_t(e=>{const t=e.getInstance(W),n=t.addDisposable(new Ue),r=t.addDisposable(new Ue),o=qt(e,Zs),i=V(n.event),s=V(r.event),a=Ql(V(o.event),e),l=t.addDisposable(new pt(i)),c=t.addDisposable(new pt(s)),d=t.addDisposable(new pt(a));return{instance:{handleSetOptions:i,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(m){l.setListener(m.handleSetOptions),c.setListener(m.handleOptionsChanged),d.setListener(m.handleConfigChanged),dc(e).announceAssembled(),await n.fire(m),await r.fire(m)},dispose(){}}}),vr,uc="core";function Qy(){const e=window.__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([uc],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Zy(e){const t=window.__emailmaker__?.require?.warm;return typeof t!="function"?Zt().then(()=>{}):t([uc],e)}function Zt(){return vr===void 0&&(vr=Qy().then(e=>(Ft()&&e.installDiagnostics().catch(t=>{}),e))),vr}var br=null,yr=null;async function eE(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Yo(){return br||(br=Zt().then(()=>{})),br}function fc(e){return yr||(yr=eE(e)),yr}function tE(){return fc(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}function nE(){const e=typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function rE(e){return Promise.all([Yo(),fc(e)]).then(()=>{})}function oE(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Ts(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Zy(t?{priority:t}:void 0)).then(()=>(Lo(t?{priority:t}:void 0),n?Yo():void 0)).catch(()=>{})}function iE(e){const t=oE(e);if(t==="eager")Ts(e);else if(t==="idle"){const n=()=>Ts(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var pc="PluginRegistry";function sE(e=Xc()){return e.getOrCreateInstance(pc,()=>new xd)}var aE=new Md(()=>sE()),lE=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],cE=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],On=new Map([...lE.map(e=>[e,"event"]),...cE.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),dE=new Map([["use","use `useAsync()` or await `ready` first"]]);function uE(e){return dE.get(e)??"await `ready` first"}var fE=new Set(["async","queued"]),pE=Symbol.for("emailmaker.earlyCtxPlaceholder");function As(e){return e[pE]=!0,e}function hE(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${uE(e)}).`)}function mE(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function gE(e){return[...On].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function vE(e,t){for(const n of gE(e)){const r=On.get(n);if(r!==void 0&&fE.has(r)){const o=async(...i)=>{await t;const s=e[n];if(typeof s!="function"||s===o)throw mE(n);return s.apply(e,i)};e[n]=As(o);continue}e[n]=As(()=>{throw hE(n)})}}function bE(e,t,n){e.getInstanceAsync(ht).then(()=>{qt(e,$.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function yE(e,t){e.getInstanceAsync(ht).then(()=>{qt(e,$.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var EE=_t(e=>{let t;function n(){return new Promise(o=>{const i=e.getOrCreateInstance(vo,()=>new Set),s=()=>{i.delete(s),o()};i.add(s)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const i=e.getInstance(Nn),s=e.getInstance(pc);if(!t){t=new kd(i,s,{ensureHostRuntimeReady:tE,explainScriptFailure:nE,openEarlyWindow:()=>Jb(e),reportLoadFailure:c=>yE(e,c)}),e.inject(mo,t);const l=t.onLifecycle(c=>{c.type==="create:error"&&bE(e,c.name,c.error)});e.getInstance(W)?.addDisposable(l)}const a=o?.plugins||[];i&&(Wa(e),a.length>0&&vE(i,n()),await t.setPlugins(a))},instance:{use(o){return typeof o=="function"?r().useByCtor(o):r().useByKey(o)},useAsync(o){return r().useAsync(o)},waitPlugin(o){return r().waitFor(o)}},dispose(){t?.dispose(),t=void 0}}}),hc=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const o=this._listeners.indexOf(r);o>=0&&this._listeners.splice(o,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},_E=H("ELEMENT_INSERT_HTML_PIPELINE"),wE=H("BLOCK_INSERT_HTML_PIPELINE"),SE="application_block_inserted",IE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(wE,()=>new hc).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Gt,()=>new Wt),o=n?e.bind(n):e;return r.addListener(SE,o,t)}},Xo=H("ComponentRegistry"),CE=H("ComponentRegistryGate");function Jo(){return mt.getOrCreateInstance(CE,()=>({pending:[]}))}function TE(e=Xo){return Jo().factory!==void 0||mt.getInstance(e)!==void 0}function io(e,t,n=Xo){if(TE(n)){t(Dn(e,n));return}Jo().pending.push(()=>t(Dn(e,n)))}function Dn(e,t=Xo){const n=mt.getInstance(t);if(n)return n;const r=Jo().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return mt.getOrCreateInstance(t,r)}var AE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=i=>{if(!n){n=!0;for(const s of t)s.dispose();e(i)}};t.push(this._container.addService(en,{execute:i=>{r(i.value.map(s=>({name:s.name,html:s.html})))}}));const o=this._container.getInstance(Zc)?.watch(i=>{i&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(en,{execute:r=>{const o=Dn(n),i=r.value.find(s=>s.name===e);if(i){const{icon:s,title:a,fallbackTooltip:l,...c}=t;s&&(i.icon=o.getReactNode(s)),a&&(i.title=o.getReactNode(a)),l&&(i.fallbackTooltip=o.getReactNode(l)),Object.assign(i,c)}}})}delete(e){this._container.addService(en,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService(en,{execute:r=>{const o=Dn(n);r.value.splice(t??r.value.length,0,{...e,title:o.getReactNode(e.title),icon:o.getReactNode(e.icon),fallbackTooltip:o.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(_E,()=>new hc).add(e,t??0,n)}handleInject(e,t,n){return ft(this._container,ed).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},RE=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Gt,()=>new Wt)}send(e,t,n){this._messageService.send(e,t,n)}sendAsync(e,t,n=!0){return this._messageService.sendAsync(e,t,n)}addListener(e,t,n){return this._messageService.addListener(e,t,n)}addListenerAsync(e,t,n=0){return this._messageService.addListenerAsync(e,t,n)}onInit(e,t=!0,n=0){return this._messageService.onInit(e,t,n)}isInited(){return this._messageService.isInited()}};function PE(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Rs(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var OE=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=ft(t,xc),this._closeModalEmitter=ft(t,Wc),this._updateModalEmitter=ft(t,id)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return io(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Rs(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;io(this._container,r=>{this._updateModalEmitter.fire(PE({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:Rs(r,n)}))})}};function fn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var DE=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=o=>{this._loadedSettled||(this._loadedSettled=!0,r(o))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=o=>{this._readySettled||(this._readySettled=!0,r(o))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},kE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Gt,()=>new Wt)}_createScriptHandle(e,t){const n=this._messageService.addListener(bo,o=>{if(o.key===e){if(o.phase==="load"&&o.status==="success"){r.resolveLoaded();return}if(o.phase==="ready"&&o.status==="success"){r.resolveReady();return}if(o.phase==="load"){r.rejectLoad(new Error(o.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(o.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new DE(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(lt,{...fn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(lt,{...fn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(lt,{...fn(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(lt,{...fn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},xE=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function so(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&xE.has(t)}function mc(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}return`nohwcrypto-${Date.now()}`}function Er(){return`__settingsPanel:${mc()}`}function _r(e,t){return{type:e,props:t}}function ME(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!so(e)}function Ps(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(so(t)){const r=Er();return n(e.add(r,t)),_r(r,{})}if(typeof t=="function"){const r=Er();return n(e.add(r,t)),_r(r,{})}if(ME(t)){const r=t.type;if(typeof r=="string")return t;if(so(r)||typeof r=="function"){const o=Er();return n(e.add(o,r)),_r(o,t.props)}return t}return t}var LE=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??mc();io(this._container,n=>{const r=s=>this._trackRegistration(s),o=Ps(n,e.content,r),i=e.advancedTabs?.map(s=>({...s,content:Ps(n,s.content,r)}));ft(this._container,ri).fire({...e,content:o,advancedTabs:i,instanceKey:t,type:vd})})}closeSettingsPanel(){this._clearPanelRegistrations(),ft(this._container,ri).fire(null)}},gc={SandboxScriptApi:kE,ElementsApi:AE,BlocksApi:IE,MessageService:RE,SettingsPanelApi:LE,ModalApi:OE};function wr(e,t,n,r={}){const o=Object.assign({},e);for(const[i,s]of Object.entries(t))if(s!==void 0)if(n.includes(i)&&typeof s=="object"&&s!==null){const a=o[i],l=r[i]??{};o[i]=Object.assign({},typeof a=="object"&&a!==null?a:l,s)}else o[i]=s;return o}var Ae={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},NE={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},Sr={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:24,fontSizeDim:"px",lineHeight:32,lineHeightDim:"px",color:"#333333",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},Os={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},it={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:Ae.border,borderRadius:Ae.borderRadius,textAlign:"center",padding:Ae.padding},Ds={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Ae.padding},Ir={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Ae.border,borderRadius:Ae.borderRadiusCards};function FE(e){return{...NE,...e}}function BE(e){return{...Sr,...e,bold:e?.bold??Sr.bold,italic:e?.italic??Sr.italic}}function jE(e){return{...Os,...e,underline:e?.underline??Os.underline}}function UE(e){return{...it,...e,bold:e?.bold??it.bold,italic:e?.italic??it.italic,border:{...it.border,...e?.border},borderRadius:{...it.borderRadius,...e?.borderRadius},padding:{...it.padding,...e?.padding}}}function HE(e){return{...Ds,...e,padding:{...Ds.padding,...e?.padding}}}function $E(e){return{...Ir,...e,border:{...Ir.border,...e?.border},borderRadius:{...Ir.borderRadius,...e?.borderRadius}}}function Cr(e={}){return{backgroundColor:e.backgroundColor||"",backgroundImage:(e.backgroundImage||[]).map(t=>({type:"url",value:t?.value||""})),backgroundPositionX:e.backgroundPositionX||"",backgroundPositionY:e.backgroundPositionY||"",backgroundRepeat:e.backgroundRepeat||"",backgroundSize:e.backgroundSize||"",backgroundColorContent:e.backgroundColorContent||"",textStrong:e.textStrong||!1,textItalic:e.textItalic||!1,textUnderline:e.textUnderline||!1,width:e.width,responsive:e.responsive}}function ks(e){let t={...go};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Tr(e){return{text:FE(e.text),headings:BE(e.headings),links:jE(e.links),buttons:UE(e.buttons),block:HE(e.block),cards:$E(e.cards)}}var xs=H("EmailSettingsPort"),VE=1e4,vc=class{_editor;_layoutSettingsChanged=new Or;_contentStylesChanged=new Or;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!Jl(this._editor.container)||!ct(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(xs);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Cr(this._settings().read())}_getCurrentContentStyles(){const e=ct(this._editor.container)?.current()?.get().attributes.common_styles;return Tr(ks(e))}_getLayoutSnapshot(e){return JSON.stringify(e)}_getContentSnapshot(e){return JSON.stringify(e)}async _ensureMessageSubscription(){if(!this._messageSubscription){if(this._messageSubscriptionPromise)return this._messageSubscriptionPromise;this._messageSubscriptionPromise=(async()=>{if(await this._editor.container.getInstanceAsync(xs),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Gt,()=>new Wt),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const o=r?.data,i=o?.operation;if(i===z.APPLICATION_EMAIL_SETTINGS_SET){const l=Cr(o?.settings),c=this._getLayoutSnapshot(l);c!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=c,this._layoutSettingsChanged.fire(l));return}if(i!==z.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Tr(r.data?.settings?.commonStyles??{...go}),a=this._getContentSnapshot(s);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=Cr(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=VE){const t=ct(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,o=Ie(r,$.ON_EMAIL_INIT_ID);return new Promise(i=>{let s=!1,a;const l=()=>{a&&(clearTimeout(a),a=void 0)},c=o(()=>{s||(s=!0,l(),c.dispose(),i())});a=setTimeout(()=>{s||(s=!0,c.dispose(),i())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=ct(this._editor.container)?.current();if(!t)return;const n=ks(t.get().attributes.common_styles);e.text!==void 0&&(n.text={...n.text||{},...e.text}),e.headings!==void 0&&(n.headings={...n.headings||{},...e.headings}),e.links!==void 0&&(n.links={...n.links||{},...e.links}),e.buttons!==void 0&&(n.buttons=wr(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Ae.border,borderRadius:Ae.borderRadius,padding:Ae.padding})),e.block!==void 0&&(n.block=wr(n.block||{},e.block,["padding"],{padding:Ae.padding})),e.cards!==void 0&&(n.cards=wr(n.cards||{},e.cards,["border","borderRadius"],{border:Ae.border,borderRadius:Ae.borderRadiusCards}));const r=JSON.stringify(n);gt(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=Tr(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},qE={...gc,EmailSettingsApi:vc},GE={...gc},Zw={...GE,EmailSettingsApi:vc},WE={...qE};function zE(){aE.addAll(WE)}var KE=[_t(()=>{zE()}),Uy,Jy,jy,ld,Fy,bd];async function YE(){return(await Zt()).asyncMixins}var XE=EE,JE=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await YE()}catch(s){throw e.failPendingWaits(s),s}t=o(e);const i=await e.getInstanceAsync(Nn);Object.assign(i,t.instance||{});for(const s of e.getInstance(vo)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},QE=gd([...KE]);function Ar(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const i of r.values())i();r.clear()}return{event(i,s,a){const l=Symbol("subscription");return t||(n.set(l,{listener:i,priority:s,thisArg:a}),e&&r.set(l,e(i,s,a))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(i){o(),e=i;for(const[s,{listener:a,priority:l,thisArg:c}]of n)r.set(s,i(a,l,c))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function ZE(e){const t=Ar(),n=Ar(),r=Ar();return e.getInstance(W)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(ht).then(o=>{t.attach(o.onNotify),n.attach(o.onError),r.attach(o.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(o){const i=e.getInstance(ht);if(i){i.notify(o);return}e.getInstanceAsync(ht).then(s=>s.notify(o),()=>{})}}}var bc=H("CodeErrors"),e_=[];function t_(e){return e?.getInstance(bc)?.get()??e_}function n_(e){return e?.getInstance(bc)!==void 0}var r_=class extends ge{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=Qt(e),this.addDisposable(Ie(e,$.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){const e=nt(this._container);if(e&&oe(e.sessionKey())&&!e.hasSuspended())throw new Error("[emailmaker] no open email: only a block is shown");return $l(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>ye(t,this._container))}async _readProjectBlocks(){const e=await Vl(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>Pt(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>Qr(n,this._container))}async getEmailSnapshot(){return Se(this.openEmail(),this._container)}async getBlockSnapshot(){const e=nt(this._container),t=e?.current();return!e||!t||!oe(e.sessionKey())?null:(await t.whenReady(),ye(qn(t),this._container))}setEmailMeta(e){const t=Wo(this._container);if(!t)return;const n=t.get().attributes.meta;gt(t,{meta:ln({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&ln(o,e))}setBlockMeta(e,t){const n=nt(this._container);if(n?.sessionKey()===Sn(e)){const o=n.current();o&&gt(o,{meta:ln({meta:o.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,i=>i&&ln(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return n_(this._container)?t_(this._container):void 0}},o_=H("EmailDataController");function i_(e){return e.getOrCreateInstance(o_,()=>{const t=new r_(e);return e.getInstance(W)?.addDisposable(t),t})}function s_(e){const t=i_(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function a_(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function l_(e){let t;const n=Pl(e),r=Ie(e,$.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:i})=>{t=i}));const o=()=>t?a_(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:i=>o()?.getPast(i)??[],getFuture:i=>o()?.getFuture(i)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:i=>o()?.restoreSnapshot(i)}}}var c_=H("plugin.mountElement");function d_(e){const t=e.getInstance(be)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function u_(e){return e.getOrCreateInstance(c_,()=>{let t=!1,n;return{get:()=>t?n:d_(e),set(r){t=!0,n=r}}})}function f_(e){const t=u_(e);return{getElement:()=>t.get()}}function p_(e){return{handleLoadImage:V(Ie(e,$.UPLOAD_EVENT_ID)),handleFileProxy:V(Ie(e,$.FILE_PROXY_EVENT_ID)),handleUrlProxy:V(Ie(e,$.PROXY_URL_EVENT_ID)),handleAITextRequest:V(Ie(e,$.AI_TEXT_REQUEST_ID)),handleAIImageRequest:V(Ie(e,$.AI_IMAGE_REQUEST_ID)),handleReadLocale:V(Ie(e,$.READ_LOCALE)),handleLimitUsage:V(Ie(e,$.ON_LIMIT_ID)),handleTranslate:V(Ie(e,$.ON_TRANSLATE_ID))}}var h_=[Fg,sy,ZE,Xy,s_,l_,f_,p_];function m_(e,t=h_){const n=Ko(e);My(e);const r=QE(e),o=XE(e),i=JE(e),s={...r.instance,...o.instance,...i.instance};for(const l of t)Object.assign(s,l(e));let a=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const c=a&&n.get()===l;a=!1,c||n.set(l),await o.setOptions(l),await i.setOptions(l)}}}function g_(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var v_=class{_storage=Object.create(null);get(e){const t=this._storage[e];return t&&(!t.expires||t.expires<Date.now())?t.value:""}set(e,t,n){this._storage[e]={value:t,expires:n.expires?n.expires*1e3+Date.now():void 0}}remove(e){delete this._storage[e]}},b_="editor-runtime.react.copies",Rr=8;function Ut(e){return e&&typeof e=="object"?e:void 0}function Ms(e){const t=Ut(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Ut(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function y_(e){const t=Ut(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Ut(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function E_(e,t,n){return e.package===t&&e.version===n}function __({ourReact:e,entries:t,packageName:n,version:r}){const o=Ms(e);if(!o||!Array.isArray(t))return[];const i=[],s=new Set;for(const a of t){const l=Ut(a);if(!l||!E_(l,n,r))continue;const c=Ms(l.react);!c||c===o||s.has(c)||(s.add(c),i.push({package:n,version:r,reactVersion:y_(l.react),react:l.react}))}return i}function w_({packageName:e,copies:t}){const n=[`[${e}] A second copy of React is on this page (singleton invariant broken).`,`The editor runs on its own React, the plugin got another one from ${e}/runtime/react.`,`This shows up as "Cannot read properties of null (reading 'useState')" and takes down the whole`,"editor, not just the plugin panel: plugin components render inside the editor tree.","","Found:"];for(const r of t.slice(0,Rr))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Rr&&n.push(` …and ${t.length-Rr} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
1048
- `)}var Ls=new Set;function S_({packageName:e="@emailmaker/emailmaker",version:t="1.3.2",log:n=r=>{}}={}){const r=o=>{try{const i=globalThis[Symbol.for(b_)],s=__({ourReact:o,entries:i,packageName:e,version:t}).filter(a=>!Ls.has(a.react));if(!s.length)return;s.forEach(a=>Ls.add(a.react)),n(w_({packageName:e,copies:s}))}catch{}};try{const o=Eo()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function I_(e,t,n){ne(e.signal);const r=t??mt.createChild();Ko(r);const o=r.getInstance(W);let i;async function s(){r.inject(zs,g_(new v_)),S_();const a=m_(r),l={...a.instance,container:r,get ready(){return i??Promise.resolve(l)},async reset(c){if(ne(c.signal),o.isDisposed())throw je();return await a.setOptions(c),l}};r.inject(Nn,l);try{if(n?.onInstance?.(l),await a.setOptions(e),ne(e.signal),o.isDisposed()||await ry(r),e.devTools)try{const c=r.getInstance(mo);c&&await(await Zt()).initDevTools(r,c)}catch{}return ne(e.signal),qt(r,Js).fire(l),l}catch(c){throw o.dispose(),c}}try{return i=En(s(),e.signal),i.catch(()=>{}),await i}catch(a){throw o.isDisposed()||o.dispose(),a}}var Ht=new WeakMap;function C_(e){return e?Ht.get(e):void 0}function yc(e){try{e.getInstance(W)?.dispose()}catch{}try{e.dispose()}catch{}}function T_(e,t){if(!e)return;const n=Ht.get(e);n&&n!==t&&yc(n),Ht.set(e,t)}function A_(e,t){e&&Ht.get(e)===t&&Ht.delete(e)}function R_(e){const t=mt.createChild();return Yt(e)&&t.inject(Me,Gn(e)),t}var Nt=new WeakMap,P_="data-emailmaker-config-styles";function O_(e){return typeof e=="string"?e.trim():""}function Ns(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function D_(e,t,n){if(!e||typeof document>"u")return null;const r=O_(t),o=Nt.get(e),i=n||e;if(!r)return o&&(o.remove(),Nt.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==i||o!==i.firstChild)&&Ns(i,o),o;const s=document.createElement("style");return s.setAttribute(P_,"true"),s.textContent=r,Ns(i,s),Nt.set(e,s),s}function k_(e){if(!e)return;const t=Nt.get(e);t&&(t.remove(),Nt.delete(e))}function Ec(){return!1}var x_=`
1047
+ `)}function ss(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function ob(e,t,n,r){const o=ib(e,t,n,r);return o===void 0}function ib(e,t,n,r){if(Wn(t))return"block";const{email:o}=Kn(t,!1),i=Et(o,e),s=i.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=nt(e)?.current();if(!a)return"no-session";const l=a.get(),c=l.attributes;if(l.serverId!==s)return"document-id";if(c.is_inited!==!0)return"not-inited";const d=ss(Xr(n??a.getContent()));if(i.html!==void 0&&ss(Xr(i.html))!==d)return"html";if(i.subject!==void 0&&i.subject!==c.subject)return"subject";if(i.preheader!==void 0&&i.preheader!==c.preheader)return"preheader";if(i.common_styles!==void 0&&i.common_styles!==c.common_styles)return"common_styles"}function as(e,t){if(Wn(t))return;const{email:n}=Kn(t,!1),r=Et(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:Xr(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function sb(e){return Array.isArray(e)?e.some(t=>Lr(t)):Lr(e)}function ab(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])sb(t[n])&&delete t[n];return t}function lb(e,t){const n={...e};return delete n.id,{...n,...t}}function cb(e){return e.html?e:{...e,html:Ul}}function Qe({code:e,project:t,...n},r,o){const i=o??Vo(r);return{...n,...e?{html:Ve(r).toEditorForm(e)}:{},renderGuid:Ce(),...i===void 0?{}:{project:i}}}function ye({html:e,renderGuid:t,...n},r){const{requested:o}=Jt(r);return Le({...n,code:Ve(r).toOutputForm(e),project:o===void 0?n.project:o,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function ql(e){return nt(e)?.current()?.get().serverId??void 0}function Jr(e,t,n){return n===void 0&&(n=e.post===void 0?ql(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function Pt(e,t){return Le({...e,link:void 0,comment_status:void 0})}function vn({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?ql(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||mf(n.slug),parent:o}}function Qr({html:e,isAutosave:t,...n},r){return Le({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:Le({html:e,ampHtml:e&&""})})}function bn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function ls({html:e,isAutosave:t,...n}){return Le({...n,autosave:t?!0:void 0,code:e,guid:void 0})}function db(e){return String(e).replace(/"/g,"&quot;")}function ub(e=new Date){const t=n=>String(n).padStart(2,"0");return String(e.getFullYear())+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function Gl(e){const t=/<(table|tr|div)(\s[^>]*)>/gi;let n;for(;(n=t.exec(e))!==null;){const r=n[2]??"";if(/\bem\s*=\s*["']block["']/i.test(r))return{full:n[0],index:n.index}}return null}function cs(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),o=db(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function ds(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function zl(e){if(!e?.trim())return{};const t=Gl(e);return t?{emBlockId:ds(t.full,"em-block-id"),emBlockVersion:ds(t.full,"em-block-version")}:{}}function Wl(e,t,n){if(!e?.trim()||!t)return e;const r=Gl(e);if(!r)return e;const o=String(t),i=ub(n??new Date);let{full:s,index:a}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=cs(s,"em-block-id",o)),s=cs(s,"em-block-version",i),e.slice(0,a)+s+e.slice(a+l)}function fb(e,t){const{emBlockId:n,emBlockVersion:r}=zl(e);return n&&r?e:Wl(e,t)}var ht=H("NotificationService"),pb=H("emailTemplate.reads");async function hb(e,t){try{const n=rt(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,gb(e,t,n);return}}var mb=H("emailTemplate.notifiedFailures");function gb(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(mb,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(ht).then(()=>{qt(e,$.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function vb(e,t){const n=e.getOrCreateInstance(pb,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=hb(e,t).then(i=>(i===void 0&&n.delete(t),i));return n.set(t,o),o}var bb=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Qi.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Qi.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},Ww=H("projects.v2IdByWpId"),Kw=H("projects.wpIdByV2Id"),Yw=H("emails.v2SavedAtOnOpen"),Xw=H("emails.v2OpeningReads"),Zr=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function yb(e,t){if(!t)throw new Zr(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new Zr(e,zn(t))}function Eb(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var _b=/^[A-Za-z0-9_-]{1,128}$/,wb=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),us=new Set;function Sb(e){return _b.test(e)?!0:(us.has(e)||us.add(e),!1)}function Ib(e){return e&&!e.ok?String(zn(e).data.code??""):""}var Kl=()=>({isAutosave:!1});function fs(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function Cb(e,t){const n=new AbortController,r=Wt(e.getInstance(Pe)?.contentReadyTimeoutMs);let o;const i=new Promise((s,a)=>{o=setTimeout(()=>{n.abort(),a(new Zr("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),i])}finally{clearTimeout(o)}}function Tb(e,t){return ga(t,e==="block")}async function Ab(e,t,n,r,o){if(!Sb(n))return Kl();const i=vt(e),s=Kt(e),a=Tb(t,n);try{const l=await Rb(e,t,n,r,o);return l.id&&(i.set(a,l.id),s.delete(a)),l}catch(l){throw tp(s,a,r.html??""),l}}async function Rb(e,t,n,r,o){const i=Ll(e,[bb]),s={entityId:n,...o?{autosave:!0}:{}},a=await Cb(e,l=>t==="email"?i.emailsRevisionsCreate(s,fs(t,r),{signal:l}):i.blocksRevisionsCreate(s,fs(t,r),{signal:l}));return wb.has(Ib(a))?Kl():(yb("обновление",a),Eb(a.data??{}))}function Pb(e,t,n,r){return Ab(e,t,n,r,!1)}async function Ob(e,t,n){if(t==null||t===""||n===void 0||!wt(e))return ps;const r=Date.now(),o=Io(String(t));return Ua(o,{html:n},r,ko(vt(e),o,Kt(e),n)),await Pb(e,"block",String(t),{html:n}),Tn(o,r,vt(e).get(o)??void 0),()=>Co(o,r)}function ps(){}var ur="EXTERNAL",hs=Symbol("supersededShow");function Db(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var kb="email_id";function fr(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var xb=class extends ge{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=Xs();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=Qt(t),this._eventLock=eb(t);const n=te(e,$.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(te(e,$.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(Mn,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(kb,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Pe)??Fo}_throwIfDestroyed(){if(this.isDisposed())throw je()}async getTemplateEmail(e){const t=await vb(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,ab(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Rt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Qe(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,vn(o,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,Jr(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const i=this._dataSources.emails,s=i.cache,a=await Rt(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let c=Et(e,this._container);const d=c.id;let m=d;if(d!==void 0){const b=await i.get(d);c={...b??{},...c,utm_parameters:c.utm_parameters??b?.utm_parameters??{},renderGuid:b?.renderGuid??Ce(),...l>0?{showToken:l}:{},...o?{showId:o}:{},project:a}}else{m=n??Ce();const b=await i.get(m);c={...c,utm_parameters:c.utm_parameters??{},renderGuid:b?.renderGuid??Ce(),...l>0?{showToken:l}:{},...o?{showId:o}:{},project:a},delete c.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(c=lb(b,c))}return d===void 0&&(c=cb(c)),await s.setAll([[m,c]]),c}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==as(this._container,e))return!1;const n=gn(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=as(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:gn(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&tb({ticket:t,emailId:is(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,hs;if(!e)return;const n=this._getInitPipeline();if(ne(n.signal),Wn(e))return this._showBlock(e,n);const r=oe(he(this._container).sessionKey()),o=nb(e);if(!r&&!o&&ob(this._container,e,gn(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const i=Kn(e);i.email.id,this._prevCommand?.id;let s,a="",l=0,c=!1,d,m=Promise.resolve(),b,v=!1;try{this._eventLock.suspendChange();const{email:w,blocks:C,autosaves:y,comments:S,templateId:A,reload:B}=i;s=w.id;const k=Et(w,this._container),P=k.id,T=P??Ce(),x=await Je("getProject",Rt(this._container));ne(n.signal),a=Ce();const R={isNew:P===void 0,id:String(T),project:x},h=B===!0&&P!==void 0;h&&(await this._dataSources.emails.remove(String(P),{silent:!0}),String(P)),l=++this._showToken,String(T);const f=[];f.push(this.setBlocks(C)),w.id!==void 0&&(f.push(this.setComments(S)),f.push(this.setEmailRevisions(y,String(w.id)))),f.push(this.setEmail(w,Lr(A)?A:Number(A),P===void 0?String(T):void 0,l,a)),await Je("setEmail+blocks+revisions",Promise.all(f),{emailId:P??String(T),showId:a,targetShowToken:l}),ne(n.signal);const u=await this._dataSources.emails.get(String(T)),g=he(this._container),O={id:a,token:l};if(r){mn(this._container);const I=g.suspendedDocument()?.get().serverId;!h&&P!==void 0&&I!=null&&String(I)===String(P)&&g.resumeSuspended()}P===void 0?b=g.startNewDraft(u??k,{patch:k,show:O}):h?b=g.reload(P,{email:u??k,patch:k,show:O}):g.sessionKey()===st(P)?b=g.show(k,O):b=g.open(P,{email:u??k,patch:k,show:O}),g.beginShowFill(a);const M=!!this._prevCommand&&xe(this._prevCommand,R);R.id,!this._prevCommand||xe(this._prevCommand,R),this._prevCommand?.id,this._rememberShow(R),m=n.requestShow({showId:a,navId:String(T),emailId:P,isNew:P===void 0}),v=!0;const _=()=>g.endShowFill(a);Promise.allSettled([m,b.whenReady()]).then(_),String(T),c=!0}catch(w){d=w,v&&a&&n.failShow(a,w),a&&nt(this._container)?.endShowFill(a),uo(w)||(fa(w),void 0)}finally{this._eventLock.resumeChange()}if(!c)throw d instanceof Error?d:new Error(`[emailmaker] show() setup failed: ${String(d??"unknown error")}`);return Je("show-init-deferred",Promise.all([m,b?.whenReady().catch(w=>{if(w instanceof tt){const C=Do(w);throw C?new Error(`[emailmaker] show(): email open failed (${C})`,{cause:w}):w}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:i,reload:s}=Zv(e),a=Ce();let l=!1;try{await this.setBlocks(o),ne(t.signal),s&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const c=n.id!==void 0&&n.id!==""?String(n.id):void 0,d=he(this._container);if(!s&&c!==void 0&&d.sessionKey()===Sn(c)){const A=fr(n)?await this._storeShownBlock(n):void 0,B={id:a,token:++this._showToken},k=d.show(A,B),P=t.requestShow({showId:a,navId:c,emailId:void 0,isNew:!1});l=!0,await Je("show-block-init",Promise.all([P,k?.whenReady().catch(()=>{})]),{showId:a});return}const m=r||s?await os(this._container,String(n.id)):void 0,b=m&&(s||fr(n))?await this._storeShownBlock({...ye(m,this._container),...n}):r||s?m:await this._storeShownBlock(n);if(ne(t.signal),!b)throw new Error(`[emailmaker] show(): block ${String(n.id)} not found`);i!==void 0&&b.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(i.filter(A=>A.id!==void 0).map(A=>[A.id,bn(A,String(b.id))])),this._prevCommand=void 0,this._lastShow=void 0;const v=b.id!==void 0?String(b.id):Ce(),w={id:a,token:++this._showToken};mn(this._container);const C=s?d.reloadBlock(v,b,w):d.openBlock(v,b,w);b.id;const y=t.requestShow({showId:a,navId:v,emailId:void 0,isNew:b.id===void 0});l=!0;const S=C.whenReady().catch(A=>{if(A instanceof tt)throw A});await Je("show-block-init",Promise.all([y,S]),{showId:a})}catch(c){throw l&&t.failShow(a,c),c}}async _storeShownBlock(e){const t=Qe(e,this._container,await Rt(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();ne(e.signal);const t=he(this._container);if(oe(t.sessionKey())&&!t.hasSuspended())throw new Error("[emailmaker] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:ur,fallbackTitle:Qa(this._container)});if(ne(e.signal),!n)throw Db(t.emailSaveState().error);return Se($l(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=he(this._container),t=e.current();if(!t||!oe(e.sessionKey()))throw new Error("[emailmaker] saveBlock(): no open block");return Gu(t,async()=>{await t.whenReady();const n=qn(t),r=t.get().version,o=t.get().serverId,i=typeof n.global_block=="boolean"?n.global_block:o!=null&&zl(n.html??"").emBlockId===String(o),s=o!=null&&i?Wl(n.html,String(o),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:s,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},l=this._dataSources.blocks,c=await Ob(this._container,t.get().serverId,a.html),d=t.get().serverId==null?l.create(a,{source:ur}):l.update(String(t.get().serverId),a,{source:ur}),m=await rb(this._container,d,b=>{b&&c(),b&&he(this._container).current()===t&&t.get().serverId==null&&b.id!==void 0&&t.markSaved(r,String(b.id))});if(!m)throw new Error("[emailmaker] save(): block was not saved");return c(),t.markSaved(r,m.id!==void 0?String(m.id):void 0),ye(m,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=is(e);const n=this._queuedShow(e,t).then(r=>r===hs?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),ne(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=he(this._container);if(n!==void 0&&r.sessionKey()===Sn(n))return;const o=t.code===void 0&&n!==void 0?await os(this._container,n):void 0,i=o&&fr(t)?await this._storeShownBlock({...ye(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!i)throw new Error(`[emailmaker] openBlock(): block ${String(n)} not found`);mn(this._container);const s=r.openBlockOver(i.id!==void 0?String(i.id):Ce(),i);i.id,r.hasSuspended(),pe(this._container,$.ON_BLOCK_OPEN_ID).fire({block:i}),await s.whenReady().catch(a=>{if(a instanceof tt)throw r.current()===s&&(pe(this._container,$.ON_BLOCK_CLOSE_ID).fire({block:i,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),dm(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function Mb(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function Lb(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),o=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:o,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Mb(e)}}function pr(e,t){return t?Lb(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Yl=["title","slug","type","tags","blocktags","modified","author","lock","subject","description","excerpt","status","is_template","link","renderGuid","date","date_gmt","modified_gmt","comment_status","ping_status","template","related_email","project_title","project_author","isAmp","meta"],Nb=[...Yl,"html","id","project","password"],Jw=new Set(["html",...Yl,"global_block","project"]);function Fb(e){if(!e||typeof e!="object")return{};const t={};e.id!=null&&e.id!==""&&(t.id=String(e.id)),e.title!=null&&e.title!==""&&(t.title=e.title),e.slug!=null&&e.slug!==""&&(t.slug=e.slug),e.type!=null&&e.type!==""&&(t.type=e.type),e.tags!=null&&(t.tags=e.tags),e.blocktags!=null&&(t.blocktags=e.blocktags),e.modified!=null&&e.modified!==""&&(t.modified=e.modified),e.author!=null&&e.author!==""&&(t.author=String(e.author)),e.lock!=null&&(t.lock=e.lock),e.subject!=null&&e.subject!==""&&(t.subject=e.subject),e.description!=null&&e.description!==""&&(t.description=e.description),e.excerpt!=null&&e.excerpt!==""&&(t.excerpt=e.excerpt),e.status!=null&&e.status!==""&&(t.status=e.status),e.is_template!=null&&(t.is_template=e.is_template),e.link!=null&&e.link!==""&&(t.link=e.link),e.renderGuid!=null&&e.renderGuid!==""&&(t.renderGuid=e.renderGuid),e.date!=null&&e.date!==""&&(t.date=e.date),e.date_gmt!=null&&e.date_gmt!==""&&(t.date_gmt=e.date_gmt),e.modified_gmt!=null&&e.modified_gmt!==""&&(t.modified_gmt=e.modified_gmt),e.comment_status!=null&&e.comment_status!==""&&(t.comment_status=e.comment_status),e.ping_status!=null&&e.ping_status!==""&&(t.ping_status=e.ping_status),e.template!=null&&e.template!==""&&(t.template=e.template),e.related_email!=null&&e.related_email!==""&&(t.related_email=e.related_email),e.project_title!=null&&e.project_title!==""&&(t.project_title=e.project_title),e.project_author!=null&&e.project_author!==""&&(t.project_author=e.project_author),e.isAmp!=null&&(t.isAmp=e.isAmp),e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object"&&(t.meta=e.meta);const n=new Set(Nb),r={};for(const o of Object.keys(e))n.has(o)||(r[o]=e[o]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Bb(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Fb(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var eo=new WeakMap;function jb(e){let t=eo.get(e);return t||(t={byId:new Map,fallback:[]},eo.set(e,t)),t}function Ub(e){eo.delete(e)}function Hb(e,t){const{byId:n,fallback:r}=jb(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const i=r.indexOf(o);return i>=0&&r.splice(i,1),o}return}for(let o=r.length-1;o>=0;o--){const i=r[o],s=e.name!=null&&e.name!==""&&i.name!=null&&i.name!==""&&i.name===e.name,a=e.type!=null&&e.type!==""&&i.insertFrom===e.type;if(s&&a)return r.splice(o,1),i.id!=null&&i.id!==""&&n.delete(String(i.id)),i}}async function $b(e,t){const{blocks:n}=Qt(e);return await n.cache.getIfPresent(t)??void 0}async function Vb(e,t){if(!t.blockId)return;const n=await $b(e,t.blockId);if(n)return Bb(n,t)}async function qb(e,t){const n=Hb(e,t);if(n)return pr(e,n);const r=await Vb(t,e);return r?pr(e,r):pr(e,void 0)}var Gb=Qs("application_block_inserted"),zb=-1e3,ms=new WeakSet;function Wb(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.type=="string"||typeof t.name=="string"||typeof t.blockId=="string"||typeof t.project=="string"||typeof t.project=="number"}function Kb(e){if(!e||ms.has(e))return;ms.add(e);const t=new ge,n=fe(e);return t.addDisposable(n.addListenerAsyncPipe(Gb,async(r,o)=>{const i=Wb(r)?await qb(r,e):r;return o?o(i):i},zb)),t.addDisposable({dispose:()=>{Ub(e)}}),t}var Yb=Vn("plugin.readBlockAutosave"),Qw=H("blockDocuments.provided"),Xl=H("plugin.earlyWindow");function Xb(e){return e.getOrCreateInstance(Xl,()=>({depth:0}))}function Jb(e){const t=Xb(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function Jl(e){return(e?.getInstance(Xl)?.depth??0)>0}function Ql(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,i,s)=>{const a=e(o,i,s);if(r&&Jl(t)){const l=n;queueMicrotask(()=>{o.call(s,l)})}return a}}var hr=100,Qb=class extends ge{_container;_events;constructor(e){super(),this._container=e;const t=Kb(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:i}=Qt(e),s=te(e,$.ON_SHARE_ID),a=te(e,$.ON_SHOW_PREVIEW_ID),l=te(e,$.ON_EMAIL_CLONE_ID),c=te(e,$.ON_BLOCK_OPEN_ID),d=te(e,$.ON_BLOCK_CLOSE_ID),m=te(e,$.ON_BLOCK_CLONE_ID),b=te(e,$.ON_BLOCK_INIT_ID),v=te(e,$.ON_BLOCK_CHANGED_ID),w=te(e,$.ON_CODE_VALIDATE_ID),C=te(e,$.ON_IMPORT_VALIDATE_ID),y=te(e,$.ON_SUBJECT_CHANGED_ID),S=te(e,$.ON_EMAIL_CHANGED_ID),A=te(e,$.ON_PREHEADER_CHANGED_ID),B=te(e,$.ON_SAVEBUTTON_CLICK_ID),k=te(e,$.ON_BLOCK_SAVEBUTTON_CLICK_ID),P=te(e,$.ON_NEXTBUTTON_CLICK_ID),T=te(e,$.ON_SEND_LIVEPREVIEW_ID),x=te(e,$.ON_SEND_TESTEMAIL_ID),R=te(e,Yv),h=te(e,$.ON_CONTENT_CHANGED_ID),f=te(e,Kv),u=te(e,$.ON_PREVIOUSBUTTON_CLICK_ID),g=te(e,$.ON_SEND_EMAIL_MODAL_ID),O=$c(te(e,$.ON_EMAIL_INIT_ID),_=>!_.reset),M=te(e,$.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:V(A),handleSubjectChanged:V(y),handleValidate:V(w),handleImportValidate:V(C),handleReadEmail:V(n.handlerRead,_=>_,_=>_&&Et(_,e)),handleSaveEmail:V(n.onSave,function({prev:_,patch:I,value:F,source:j}){const K=_?Se(_,e):void 0;return{prev:K,patch:Lt(K,Se(I,e)),value:Se(F,e),source:j}},_=>_?Et(_,e):void 0),handleRemoveEmail:V(n.onRemove,({value:_,source:I})=>({value:Se(_,e),source:I}),()=>{}),handleReadCommonBlocks:V(R,_=>_.project,_=>_?.map(I=>Qe(I,e))),handleReadTemplateBlocks:V(f,_=>_,_=>_?.map(I=>Qe(I,e))),handleReadBlocks:V(t.byForeignKey("project").handleRead,_=>Jt(e).requested||String(_),_=>_?.map(I=>Qe(I,e))),handleReadBlock:V(t.handlerRead,_=>_,_=>_?Qe(_,e):void 0),handleOpenBlock:V(c,({block:_})=>({block:ye(_,e)})),handleCloseBlock:V(d,({block:_,hasUnsavedChanges:I})=>({block:ye(_,e),hasUnsavedChanges:I})),handleCloneBlock:V(m,_=>ye(_,e)),handleSaveBlock:V(t.onSave,function({prev:_,patch:I,value:F,source:j}){const K=F.global_block===!0&&F.id&&typeof F.html=="string"?{...F,html:fb(F.html,String(F.id))}:F,de=_?ye(_,e):void 0;return{prev:de,patch:Lt(de,ye(I,e)),value:ye(K,e),source:j}},_=>_?Qe(_,e):void 0),handleRemoveBlock:V(t.onRemove,({value:_,source:I})=>({value:ye(_,e),source:I}),()=>{}),handleReadComments:V(r.byForeignKey("post").handleRead,_=>_,_=>_?.map(I=>Jr(I,e))),handleSaveComment:V(r.onSave,function({prev:_,patch:I,value:F,source:j}){const K=_?Pt(_,e):void 0;return{prev:K,patch:Lt(K,Pt(I,e)),value:Pt(F,e),source:j}},_=>_?Jr(_,e):void 0),handleRemoveComment:V(r.onRemove,({value:_,source:I})=>({value:Pt(_,e),source:I}),()=>{}),handleReadEmailRevisions:V(o.byForeignKey("parent").handleRead,_=>_,_=>_?.map(I=>vn(I,e))),handleReadEmailAutosave:V(te(e,kl),_=>_,_=>_?vn(_,e):null),handleEmailAutosave:V(o.onSave,function({prev:_,patch:I,value:F,source:j}){return{value:Qr(F,e),source:j}},_=>_?vn(_,e):void 0),handleRemoveEmailAutoSave:V(o.onRemove,({value:_,source:I})=>({value:Qr(_,e),source:I}),()=>{}),handleReadBlockRevisions:V(i.byForeignKey("parent").handleRead,_=>_,_=>_?.map(I=>bn(I))),handleReadBlockAutosave:V(te(e,Yb),_=>_,_=>_?bn(_):null),handleBlockAutosave:V(i.onSave,({value:_,source:I})=>({value:ls(_),source:I}),_=>_?bn(_):void 0),handleRemoveBlockAutoSave:V(i.onRemove,({value:_,source:I})=>({value:ls(_),source:I}),()=>{}),handleBlockInit:V(b,_=>ye(_,e)),handleBlockChanged:V(Zn(v,hr),_=>ye(_,e)),handleEmailChanged:V(Zn(S,hr),_=>Se(_,e)),handleEmailInit:Ql(V(O,_=>Se(_,e)),e),handlePreviousButtonClick:V(u,_=>Se(_,e)),handleNextButtonClick:V(P,_=>Se(_,e)),handleSaveButtonClick:V(B,_=>Se(_,e)),handleSaveBlockButtonClick:V(k,_=>ye(_,e)),handleHtmlChanged:V(Zn(h,hr)),handleTestEmailSend:V(x,({html:_,...I})=>({...I,code:_,compiled:{html:_,ampHtml:""}})),handleTestEmailModal:V(g,_=>Se(_,e)),handleCloneEmail:V(l,_=>Se(_,e)),handleShareEmail:V(s),handlePreviewEmail:V(a),handleLivePreviewEmail:V(T),handleAnalyticsEvent:V(M)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new pt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Zb=H("DataController"),ey=H("DataEvents");function Zl(e){return e.getOrCreateInstance(Zb,()=>{const t=new xb(e);return e.getInstance(z)?.addDisposable(t),t})}function ec(e){return e.getOrCreateInstance(ey,()=>new Qb(e))}var ty=H("plugin.pluginStart");function tc(e){return e.getOrCreateInstance(ty,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(z)?.addDispose(()=>t()),{done:n,finish:t}})}function ny(e){return tc(e).done}function ry(e){const t=tc(e);return t.run===void 0&&(t.run=(e.getInstance(mo)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var oy=H("plugin.startupShow");function iy(e){const t=Zl(e),n=ec(e),r=e.getInstance(be),o=e.getInstance(z),i={current:Promise.resolve()};e.inject(oy,i);let s=!1;const a=r?.watch(c=>{c&&n.setOptions(c),s=(c?.plugins?.length??0)>0,i.current=i.current.catch(()=>{})}),l=r?.select(c=>c?.content).watch(c=>{if(c===void 0)return;const d=()=>(ie(me.showStart),t.show(c).finally(()=>ie(me.showEnd))),m=s?ny(e).then(d):d();m.catch(()=>{}),i.current=m});a&&o?.addDisposable(a),l&&o?.addDisposable(l)}function sy(e){const t=Zl(e);return{...ec(e).get(),show(n){return ie(me.showStart),t.show(n).finally(()=>ie(me.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return ie(me.showStart),t.showBlock(n,r).finally(()=>ie(me.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function nc(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Yn(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let i=t;i<e.length;i++){const s=e[i];if(o){o=!1;continue}if(s==="\\"){o=!0;continue}if(r){s===r&&(r="");continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n++;continue}if(s===")"&&(n--,n<0))return!1}return n===0}function ay(e){return(t,n,r)=>Yn(t)?e(t,n,r):!1}function ly(e){return t=>Yn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function cy(e){return(t,n,r)=>Yn(t)?nc(t)?e(t,n,r):t:!1}function dy(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Yn(n)?nc(n)?e(t):t:!1}}function uy(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function Wo(e,t){const n=e.length;for(let r=0;r<n;r++){const o=e.charCodeAt(r);if(o===0||t==='"'&&o===34||t==="'"&&o===39||t===""&&(o===32||o===9||o===10||o===13||o===12||o===34||o===39||o===60||o===62||o===61||o===96))return!1}return!0}function fy(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let i=0;i<e;i++){const s=r[i]%62;o+=t.charAt(s)}return o}var py=8,hy=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=fy(py),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Xn=new hy;function gs(e,t){return t!==void 0&&!Wo(e,t)?`%|{${Xn.getOrCreateByKey(e)}}|%`:e}function my(e){const t=Xn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function ce(e,t,n){return t!==void 0?Wo(e,t)?e:`%|{${Xn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function gy(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ae(e){return e.startsWith("<!--")&&e.endsWith("-->")?gy(e.slice(4,-3)):e}function vy(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const o=e.match(/\[%\s*([^%]*?)\s*%\]/);o&&(r=o[1]);const i=r.trim();return t.test(i)||n.test(i)}function by(e,t,n){return t!==void 0?Wo(e,t)?e:`%|{${Xn.getOrCreateByKey(e)}}|%`:n||uy(e)||vy(e)?`<!--${e}-->`:e}var We=ay(ce),Ke=ly(ae),yy=cy(ce),Ey=dy(ae),rc=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",my),e.escape("@{","}",ce,!0).unescape("<!--@{","}-->",ae,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",gs,!0),e.escape("{{","}}",gs,!0),e.createSyntax("brace-percent").escape("{%","%}",ce).unescape("<!--{%","%}-->",ae),e.createSyntax("brace-hash").escape("{#","#}",ce).unescape("<!--{#","#}-->",ae),e.createSyntax("proscript").escape("[%","%]",by,!0).unescape("<!--[%","%]-->",ae,!0),e.createSyntax("getresponse").escape("[[IF","]]",ce).escape("[[if","]]",ce).escape("[[ELSE]]","",ce).escape("[[else]]","",ce).escape("[[ENDIF]]","",ce).escape("[[endif]]","",ce).unescape("<!--[[IF","]]-->",ae).unescape("<!--[[if","]]-->",ae).unescape("<!--[[ELSE]]","-->",ae).unescape("<!--[[else]]","-->",ae).unescape("<!--[[ENDIF]]","-->",ae).unescape("<!--[[endif]]","-->",ae),e.createSyntax("expert-sender").escape("<if",">",ce).escape("</if",">",ce).escape("<else",">",ce).escape("</else",">",ce).escape("<var ",">",ce,!0).unescape("<!--<if ",">-->",ae).unescape("<!--</if",">-->",ae).unescape("<!--<else ",">-->",ae).unescape("<!--</else",">-->",ae).unescape("<!--<var",">-->",ae,!0),e.createSyntax("velocity").escape("#if",")",We).escape("#elseif",")",We).escape("#else","",ce).escape("#foreach",")",We).escape("#macro",")",We).escape("#set",")",yy,!0).escape("#parse",")",We).escape("#include",")",We).escape("#evaluate",")",We).escape("#end","",ce).escape("#break","",ce).escape("#stop","",ce).unescape("<!--#macro","-->",Ke).unescape("<!--#if","-->",Ke).unescape("<!--#elseif","-->",Ke).unescape("<!--#else","-->",ae).unescape("<!--#foreach","-->",Ke).unescape("<!--#parse","-->",Ke).unescape("<!--#include","-->",Ke).unescape("<!--#evaluate","-->",Ke).unescape("<!--#end","-->",ae).unescape("<!--#break","-->",ae).unescape("<!--#stop","-->",ae).unescape("<!--#set","-->",Ey,!0),e.createSyntax("mailchimp").escape("*|","|*",ce).unescape("<!--*|","|*-->",ae)},to="bare",_y=new Map;function wy(e){return e?_y.get(e)??to:to}var oc=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function vs(e){return oc.includes(e)}function Ct(e){return e==="bare"||e==="html-comment"}function mr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Sy(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!Ct(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[c,d]of[["output",r.output],["editor",r.editor]])if(d!==void 0&&!Ct(d))return t(`templateDirectives.${c}: unknown form "${String(d)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!mr(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[c,d]of Object.entries(r.syntaxes))if(!(!vs(c)||d===void 0||Ct(d))){if(!mr(d))return t(`templateDirectives.syntaxes.${c}: expected a form or an object, configuration ignored.`),n;for(const m of["output","editor"]){const b=d[m];if(b!==void 0&&!Ct(b))return t(`templateDirectives.syntaxes.${c}.${m}: unknown form "${String(b)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??to;let i=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),i=void 0);const s=[];if(r.syntaxes)for(const c of Object.keys(r.syntaxes)){if(!vs(c)){t(`templateDirectives.syntaxes: unknown syntax id "${c}", entry ignored.`);continue}s.push(c)}else s.push(...oc);const a={},l={};for(const c of s){const d=r.syntaxes?.[c],m=mr(d)?d:void 0,b=(Ct(d)?d:m?.output)??o;let v=m?.editor??i??b;b==="bare"&&v==="html-comment"&&(t(`templateDirectives.syntaxes.${c}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),v="bare"),a[c]=b,l[c]=v}return{output:a,editor:l}}function ic(e,t,n,r){for(let o=t;o<n;o++){const i=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?i===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(i)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):i==="<"?r.insideTag=!0:i===">"?r.insideTag=!1:r.insideTag&&(i==='"'||i==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=i,r.unquotedAttr=!1):r.insideTag&&/\S/.test(i)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(i)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function Ot(e,t){return e.start<t.end&&t.start<e.end}function bs(e,t,n,r,o=[]){if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return[];const i=t.flatMap(d=>d.match(e).flatMap(m=>!Number.isInteger(m.start)||!Number.isInteger(m.end)||m.start<0||m.end>e.length||m.start>=m.end?[]:[{range:m,mapFn:d.mapFn,overrideBuiltins:d.overrideBuiltins,syntax:d.syntax,isVariable:d.isVariable}])).sort((d,m)=>d.range.start-m.range.start||d.range.end-m.range.end),s=[],a=o.slice().sort((d,m)=>d.start-m.start),l={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(const{range:d,mapFn:m,overrideBuiltins:b,syntax:v,isVariable:w}of i){if(r?(l.insideAttributeValue=!0,l.attributeQuoteChar='"'):ic(e,c,d.start,l),c=d.end,a.some(A=>Ot(A,d)))continue;const C=l.insideAttributeValue?l.attributeQuoteChar??"":void 0,y=e.substring(d.start,d.end),S=m(y,C,l.insideTag);S!==!1&&S!==y&&(s.push({range:d,text:S,overrideBuiltins:b,syntax:v,isVariable:w}),a.push(d))}return s.sort((d,m)=>d.range.start-m.range.start||d.range.end-m.range.end)}function Iy(e,t){const n=t.reduce((a,{mapFn:l,start:c,end:d,syntax:m,isVariable:b})=>(a[c]||(a[c]=[]),a[c].push({value:d,mapFn:l,syntax:m,isVariable:b}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),i=[];let s;for(;(s=o.exec(e))!==null;){const a=s[0];i.push({start:s.index,startToken:a,endTokens:n[a]})}return i}function gr(e,t,n,r,o=!1){const i=[];if(n&&(t=t.filter(c=>c.isVariable)),!t.length)return i;const s=Iy(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(let c=0;c<s.length;c++){const{start:d,startToken:m,endTokens:b}=s[c];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):ic(e,l,d,a),l=d;const v=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let w=!1;for(const{mapFn:C,value:y,syntax:S,isVariable:A}of b){let B=d+m.length,k=e.indexOf(y,B);for(;k!==-1;){let P=k,T=d+m.length,x=0;for(;P!==-1;){const g=e.indexOf(m,T);if(g!==-1&&g<P)x++,T=g+m.length,P=e.indexOf(y,T);else if(x>0)x--,T=P+y.length,P=e.indexOf(y,T);else break}if(P<0)break;const R=P+y.length,h=e.substring(d,R),f=C(h,v,a.insideTag);if(f===!1){B=k+Math.max(y.length,1),k=e.indexOf(y,B);continue}(o||f!==h)&&i.push({range:{start:d,end:R},text:o?h:f,syntax:S,isVariable:A});const u=s.findIndex(({start:g})=>g>=R);u>c?c=u-1:c=s.length,w=!0;break}if(w)break}}return i}function un(e,t){if(!t.length)return e;const n=t.slice().sort((o,i)=>i.range.start-o.range.start);let r=e;for(const{text:o,range:i}of n)r=r.slice(0,i.start)+o+r.slice(i.end);return r}var Cy=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=rc){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,i,s){return t.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this},unescape(r,o,i,s){return n.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let o=!1;const i={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(s=>s!==n),this._unescapeMatchers=this._unescapeMatchers.filter(s=>s!==r))}};return this.addDisposable(i),i}_collectMappings(e,t,n){const r=gr(e,this._escapes,t,n),o=bs(e,this._escapeMatchers,t,n),i=o.filter(l=>l.overrideBuiltins).map(l=>l.range),s=r.filter(l=>!i.some(c=>Ot(c,l.range))),a=o.filter(l=>l.overrideBuiltins||!s.some(c=>Ot(l.range,c.range)));return[...s,...a].sort((l,c)=>l.range.start-c.range.start||l.range.end-c.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=gr(e,this._unescapes,t),r=bs(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),i=n.filter(a=>!o.some(l=>Ot(l,a.range))),s=r.filter(a=>a.overrideBuiltins||!i.some(l=>Ot(a.range,l.range)));return[...i,...s].sort((a,l)=>a.range.start-l.range.start||a.range.end-l.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>wy(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return gr(e,this._escapes,t,n,!0)}getEscapedText(e,t){return un(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return un(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=i=>i===void 0?void 0:t[i],r=Object.values(t);let o=e;return r.includes("bare")&&(o=un(o,this._collectRevertMappings(o).filter(i=>n(i.syntax)==="bare"))),r.includes("html-comment")&&(o=un(o,this._collectMappings(o).filter(i=>!i.isVariable&&n(i.syntax)==="html-comment"&&i.text.startsWith("<!--")&&i.text.endsWith("-->")))),o}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}},sc="em___script",Dt=`<${sc}`,no=`</${sc}>`;function ys(e){return e.replace("<script",Dt).replace("<\/script>",no)}var Es=new Cy(e=>{e.escape("<script","<\/script>",t=>ys(t)).unescape(Dt,no,t=>t.replace(Dt,"<script").replace(no,"<\/script>")),e.escape("<script","/>",t=>ys(t)).unescape(Dt,"/>",t=>t.replace(Dt,"<script")),rc(e)});function Ty(e){const t=Sy(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return Ea();const n=new Set(Object.keys(t.output).filter(o=>t.output[o]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:o=>Es.normalizeToPolicy(o,t.editor),toOutputForm:o=>Es.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:ya(r)}}function Ay(e){let t;e.injectFactory(fo,()=>{const n=e.getInstance(ve)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:Ty(n)}),t.policy})}var Ry=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function Py(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function Oy(e,t){const n=[];for(const r of e.awaits?.services??[])for(const o of t.get(r)??[])o!==e&&n.push(o);return n}function ac(e){const t=Py(e),n=[],r=new Set,o=[],i=new Set,s=a=>{if(!r.has(a)){if(i.has(a)){const l=o.indexOf(a);throw new Ry([...o.slice(l),a].map(c=>c.name))}i.add(a),o.push(a);for(const l of Oy(a,t))s(l);o.pop(),i.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var Dy=[{name:"rest.client",setup:qv},{name:"auth.oauth",setup:Ed},{name:"rest.identityHeaders",setup:xv},{name:"rest.localeHeader",setup:jv},{name:"lifetime.destroyable",provides:[$o],setup:Ng},{name:"appInit",provides:[He,_o],setup:eu},{name:"config",provides:[ve],setup:Mg},{name:"templateDirectives",provides:[fo],setup:Ay},{name:"email.documents",setup:tv},{name:"show.initPipeline",provides:[Pe],setup:Gv},{name:"show",setup:iy},{name:"locale.service",provides:[yt],setup:Pv},{name:"locale.fromConfig",awaits:{services:[ve,yt]},setup:Ov},{name:"canvas.early",setup:Pm},{name:"canvas.previewSettings",setup:Gm},{name:"canvas.sandboxExtensions",setup:Wm},{name:"canvas.sandboxScriptRelay",setup:Xm},{name:"canvas.headerSync",provides:[jo],setup:km},{name:"canvas.headersAfterRecovery",setup:xm},{name:"canvas.ampSync",setup:Rp},{name:"canvas.moduleBridge",setup:ih},{name:"canvas.port",setup:Bp},{name:"canvas.images",setup:Np},{name:"canvas.edits",setup:Am},{name:"canvas.surfaceFollowsSession",setup:fm},{name:"canvas.blockContent",setup:um},{name:"canvas.sandboxFill",provides:[Bo],setup:hg},{name:"canvas.reactions",setup:Rm}],_s;function Ko(e){const t=e.getInstance(be);if(t)return t;e.getInstance(z)||e.inject(z,new ge);const n=Ee();e.inject(be,n),_s??=ac(Dy);for(const r of _s)r.setup(e);return n}function ky(e){}var xy=[{name:"save.previewFollow",setup:ky}],ws=H("plugin.lateUnitsInstalled");function My(e){if(!e.getInstance(ws)){e.inject(ws,!0);for(const t of ac(xy))t.setup(e)}}function Ly(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function Ny(e){if(!e)return;const t=ho(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(r=>typeof r=="string"?r.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(r=>/^project_\d+$/.test(r))?.replace(/^project_/,"")||void 0}var Fy=_t(e=>{let t,n,r;return{async setOptions(o){const i=r!==o.getAuthToken,s=!xe(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(Me)||!o.getAuthToken)&&!(!i&&!s&&!a))try{const l=await o.getAuthToken(o.user,o.project);e.inject(rd,Promise.resolve(l||""));const c=Ny(l);if(!c)return;e.inject(Yc,c);const d=e.getInstance(He),m=d?await d.catch(()=>{}):void 0;e.inject(He,Promise.resolve(Ly(c,m)))}catch{}}}});function By(e,t){if(e.getInstance(oi))return;e.inject(oi,!0);const n=Ie(e,$.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var jy=_t(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!Yt(r)){t&&(wg(e),Ho(r)),t=void 0;return}const i=Gn(r);if(!i||t===i&&e.getInstance(Me))return;t=i,e.inject(Me,i);const s=e.getInstance(z);s&&By(e,s)}}}),Uy=_t(e=>{const t=e.getInstance(z),n=Ie(e,Js),r=V(n),o=t.addDisposable(new pt(r));return{setOptions({handleLoad:i}){o.setListener(i)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function lc(e,t,n=!0){const r=e,o=t;for(const i of Object.keys(o)){const s=o[i];s!=null&&(n&&typeof s=="object"?r[i]=lc(r[i]||{},s,!0):r[i]=s)}return e}async function Hy(e){const t=(await Cd(()=>import("./static/esm/2490dab8.js").then(n=>kc(n.default)),[],import.meta.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var cc=H("EditorOptions"),ro=ad;function $y(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function Vy(e){return e.getOrCreateInstance(cc,()=>{const t=Ee(ro);let n=ro.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(Hy(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function qy(e){return e?.getInstance(cc)?.get()??ro}function Gy(e,t={}){const n=Vy(e);n.set(lc({...n.get()},$y(t)))}function zy(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function Wy(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var Ky=H("plugin.publicConfig");function oo(e){return e.getInstance(ve)?.get()??{}}function Ss(e){return e.getInstance(ve)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Is(e){const t=Sl(e),n=oo(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:Wy(qy(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Cs(e){return e.getInstance(ve)?.get()!==void 0}function Yy(e){const t=Xs(),n=pe(e,Zs);let r,o,i=!1;const s=async()=>{try{return e.getInstance(He)===void 0?{}:(await e.getInstanceAsync(He))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:m=!1}={})=>{await e.getInstance(ve)?.ready(),oa(e).set(oo(e).revisionService===!0);const{codeModeDirection:b,editor:v}=oo(e);v&&Gy(e,zy(v)),b!==void 0&&!(m&&b===o)&&(o=b,b==="none"?qr(e,!1):(qr(e,!0),Um(e,b)))},l=async()=>{if(!Cs(e))return;const m=Is(e),b=JSON.stringify(m);b!==r&&(r=b,await n.fire(m))},c=async m=>{const b=e.getInstance(ve),v={advancedConfigs:Ss(e).advancedConfigs,serverSide:await s(),user:m};b?.setAdvancedConfigs({...v.advancedConfigs,...v.user?.advancedConfigs});const w=b?.layers().user.mode;b?.replace(v.user?.mode===void 0&&w!==void 0?{...v.user,mode:w}:v.user,"user"),b?.replace(v.serverSide,"server"),await a(),await l()},d=m=>{const{commonStyles:b,...v}=m;return"commonStyles"in m&&$m(e,b===void 0?void 0:b),v};return{queue:t,reactToConfig:a,emitConfigChanged:l,resolveServerSideConfig:s,getConfig:()=>Cs(e)?Is(e):{},setConfig:t.decorate(async m=>{await c(d(m))}),updateConfig:t.decorate(async m=>{const b=d(m);await c({...Ss(e).user,...b})}),announceAssembled(){i||(i=!0,e.getInstance(ve)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await l()})))}}}function dc(e){return e.getOrCreateInstance(Ky,()=>Yy(e))}function Xy(e){const t=dc(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Jy=_t(e=>{const t=e.getInstance(z),n=t.addDisposable(new Ue),r=t.addDisposable(new Ue),o=qt(e,Zs),i=V(n.event),s=V(r.event),a=Ql(V(o.event),e),l=t.addDisposable(new pt(i)),c=t.addDisposable(new pt(s)),d=t.addDisposable(new pt(a));return{instance:{handleSetOptions:i,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(m){l.setListener(m.handleSetOptions),c.setListener(m.handleOptionsChanged),d.setListener(m.handleConfigChanged),dc(e).announceAssembled(),await n.fire(m),await r.fire(m)},dispose(){}}}),vr,uc="core";function Qy(){const e=window.__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([uc],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Zy(e){const t=window.__emailmaker__?.require?.warm;return typeof t!="function"?Zt().then(()=>{}):t([uc],e)}function Zt(){return vr===void 0&&(vr=Qy().then(e=>(Ft()&&e.installDiagnostics().catch(t=>{}),e))),vr}var br=null,yr=null;async function eE(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Yo(){return br||(br=Zt().then(()=>{})),br}function fc(e){return yr||(yr=eE(e)),yr}function tE(){return fc(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}function nE(){const e=typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function rE(e){return Promise.all([Yo(),fc(e)]).then(()=>{})}function oE(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Ts(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Zy(t?{priority:t}:void 0)).then(()=>(Lo(t?{priority:t}:void 0),n?Yo():void 0)).catch(()=>{})}function iE(e){const t=oE(e);if(t==="eager")Ts(e);else if(t==="idle"){const n=()=>Ts(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var pc="PluginRegistry";function sE(e=Xc()){return e.getOrCreateInstance(pc,()=>new xd)}var aE=new Md(()=>sE()),lE=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],cE=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],On=new Map([...lE.map(e=>[e,"event"]),...cE.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),dE=new Map([["use","use `useAsync()` or await `ready` first"]]);function uE(e){return dE.get(e)??"await `ready` first"}var fE=new Set(["async","queued"]),pE=Symbol.for("emailmaker.earlyCtxPlaceholder");function As(e){return e[pE]=!0,e}function hE(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${uE(e)}).`)}function mE(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function gE(e){return[...On].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function vE(e,t){for(const n of gE(e)){const r=On.get(n);if(r!==void 0&&fE.has(r)){const o=async(...i)=>{await t;const s=e[n];if(typeof s!="function"||s===o)throw mE(n);return s.apply(e,i)};e[n]=As(o);continue}e[n]=As(()=>{throw hE(n)})}}function bE(e,t,n){e.getInstanceAsync(ht).then(()=>{qt(e,$.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function yE(e,t){e.getInstanceAsync(ht).then(()=>{qt(e,$.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var EE=_t(e=>{let t;function n(){return new Promise(o=>{const i=e.getOrCreateInstance(vo,()=>new Set),s=()=>{i.delete(s),o()};i.add(s)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const i=e.getInstance(Nn),s=e.getInstance(pc);if(!t){t=new kd(i,s,{ensureHostRuntimeReady:tE,explainScriptFailure:nE,openEarlyWindow:()=>Jb(e),reportLoadFailure:c=>yE(e,c)}),e.inject(mo,t);const l=t.onLifecycle(c=>{c.type==="create:error"&&bE(e,c.name,c.error)});e.getInstance(z)?.addDisposable(l)}const a=o?.plugins||[];i&&(za(e),a.length>0&&vE(i,n()),await t.setPlugins(a))},instance:{use(o){return typeof o=="function"?r().useByCtor(o):r().useByKey(o)},useAsync(o){return r().useAsync(o)},waitPlugin(o){return r().waitFor(o)}},dispose(){t?.dispose(),t=void 0}}}),hc=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const o=this._listeners.indexOf(r);o>=0&&this._listeners.splice(o,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},_E=H("ELEMENT_INSERT_HTML_PIPELINE"),wE=H("BLOCK_INSERT_HTML_PIPELINE"),SE="application_block_inserted",IE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(wE,()=>new hc).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Gt,()=>new zt),o=n?e.bind(n):e;return r.addListener(SE,o,t)}},Xo=H("ComponentRegistry"),CE=H("ComponentRegistryGate");function Jo(){return mt.getOrCreateInstance(CE,()=>({pending:[]}))}function TE(e=Xo){return Jo().factory!==void 0||mt.getInstance(e)!==void 0}function io(e,t,n=Xo){if(TE(n)){t(Dn(e,n));return}Jo().pending.push(()=>t(Dn(e,n)))}function Dn(e,t=Xo){const n=mt.getInstance(t);if(n)return n;const r=Jo().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return mt.getOrCreateInstance(t,r)}var AE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=i=>{if(!n){n=!0;for(const s of t)s.dispose();e(i)}};t.push(this._container.addService(en,{execute:i=>{r(i.value.map(s=>({name:s.name,html:s.html})))}}));const o=this._container.getInstance(Zc)?.watch(i=>{i&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(en,{execute:r=>{const o=Dn(n),i=r.value.find(s=>s.name===e);if(i){const{icon:s,title:a,fallbackTooltip:l,...c}=t;s&&(i.icon=o.getReactNode(s)),a&&(i.title=o.getReactNode(a)),l&&(i.fallbackTooltip=o.getReactNode(l)),Object.assign(i,c)}}})}delete(e){this._container.addService(en,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService(en,{execute:r=>{const o=Dn(n);r.value.splice(t??r.value.length,0,{...e,title:o.getReactNode(e.title),icon:o.getReactNode(e.icon),fallbackTooltip:o.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(_E,()=>new hc).add(e,t??0,n)}handleInject(e,t,n){return ft(this._container,ed).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},RE=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Gt,()=>new zt)}send(e,t,n){this._messageService.send(e,t,n)}sendAsync(e,t,n=!0){return this._messageService.sendAsync(e,t,n)}addListener(e,t,n){return this._messageService.addListener(e,t,n)}addListenerAsync(e,t,n=0){return this._messageService.addListenerAsync(e,t,n)}onInit(e,t=!0,n=0){return this._messageService.onInit(e,t,n)}isInited(){return this._messageService.isInited()}};function PE(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Rs(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var OE=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=ft(t,xc),this._closeModalEmitter=ft(t,zc),this._updateModalEmitter=ft(t,id)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return io(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Rs(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;io(this._container,r=>{this._updateModalEmitter.fire(PE({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:Rs(r,n)}))})}};function fn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var DE=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=o=>{this._loadedSettled||(this._loadedSettled=!0,r(o))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=o=>{this._readySettled||(this._readySettled=!0,r(o))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},kE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Gt,()=>new zt)}_createScriptHandle(e,t){const n=this._messageService.addListener(bo,o=>{if(o.key===e){if(o.phase==="load"&&o.status==="success"){r.resolveLoaded();return}if(o.phase==="ready"&&o.status==="success"){r.resolveReady();return}if(o.phase==="load"){r.rejectLoad(new Error(o.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(o.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new DE(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(lt,{...fn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(lt,{...fn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(lt,{...fn(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(lt,{...fn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},xE=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function so(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&xE.has(t)}function mc(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}return`nohwcrypto-${Date.now()}`}function Er(){return`__settingsPanel:${mc()}`}function _r(e,t){return{type:e,props:t}}function ME(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!so(e)}function Ps(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(so(t)){const r=Er();return n(e.add(r,t)),_r(r,{})}if(typeof t=="function"){const r=Er();return n(e.add(r,t)),_r(r,{})}if(ME(t)){const r=t.type;if(typeof r=="string")return t;if(so(r)||typeof r=="function"){const o=Er();return n(e.add(o,r)),_r(o,t.props)}return t}return t}var LE=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??mc();io(this._container,n=>{const r=s=>this._trackRegistration(s),o=Ps(n,e.content,r),i=e.advancedTabs?.map(s=>({...s,content:Ps(n,s.content,r)}));ft(this._container,ri).fire({...e,content:o,advancedTabs:i,instanceKey:t,type:vd})})}closeSettingsPanel(){this._clearPanelRegistrations(),ft(this._container,ri).fire(null)}},gc={SandboxScriptApi:kE,ElementsApi:AE,BlocksApi:IE,MessageService:RE,SettingsPanelApi:LE,ModalApi:OE};function wr(e,t,n,r={}){const o=Object.assign({},e);for(const[i,s]of Object.entries(t))if(s!==void 0)if(n.includes(i)&&typeof s=="object"&&s!==null){const a=o[i],l=r[i]??{};o[i]=Object.assign({},typeof a=="object"&&a!==null?a:l,s)}else o[i]=s;return o}var Ae={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},NE={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},Sr={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:24,fontSizeDim:"px",lineHeight:32,lineHeightDim:"px",color:"#333333",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},Os={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},it={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:Ae.border,borderRadius:Ae.borderRadius,textAlign:"center",padding:Ae.padding},Ds={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Ae.padding},Ir={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Ae.border,borderRadius:Ae.borderRadiusCards};function FE(e){return{...NE,...e}}function BE(e){return{...Sr,...e,bold:e?.bold??Sr.bold,italic:e?.italic??Sr.italic}}function jE(e){return{...Os,...e,underline:e?.underline??Os.underline}}function UE(e){return{...it,...e,bold:e?.bold??it.bold,italic:e?.italic??it.italic,border:{...it.border,...e?.border},borderRadius:{...it.borderRadius,...e?.borderRadius},padding:{...it.padding,...e?.padding}}}function HE(e){return{...Ds,...e,padding:{...Ds.padding,...e?.padding}}}function $E(e){return{...Ir,...e,border:{...Ir.border,...e?.border},borderRadius:{...Ir.borderRadius,...e?.borderRadius}}}function Cr(e={}){return{backgroundColor:e.backgroundColor||"",backgroundImage:(e.backgroundImage||[]).map(t=>({type:"url",value:t?.value||""})),backgroundPositionX:e.backgroundPositionX||"",backgroundPositionY:e.backgroundPositionY||"",backgroundRepeat:e.backgroundRepeat||"",backgroundSize:e.backgroundSize||"",backgroundColorContent:e.backgroundColorContent||"",textStrong:e.textStrong||!1,textItalic:e.textItalic||!1,textUnderline:e.textUnderline||!1,width:e.width,responsive:e.responsive}}function ks(e){let t={...go};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Tr(e){return{text:FE(e.text),headings:BE(e.headings),links:jE(e.links),buttons:UE(e.buttons),block:HE(e.block),cards:$E(e.cards)}}var xs=H("EmailSettingsPort"),VE=1e4,vc=class{_editor;_layoutSettingsChanged=new Or;_contentStylesChanged=new Or;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!Jl(this._editor.container)||!ct(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(xs);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Cr(this._settings().read())}_getCurrentContentStyles(){const e=ct(this._editor.container)?.current()?.get().attributes.common_styles;return Tr(ks(e))}_getLayoutSnapshot(e){return JSON.stringify(e)}_getContentSnapshot(e){return JSON.stringify(e)}async _ensureMessageSubscription(){if(!this._messageSubscription){if(this._messageSubscriptionPromise)return this._messageSubscriptionPromise;this._messageSubscriptionPromise=(async()=>{if(await this._editor.container.getInstanceAsync(xs),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Gt,()=>new zt),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const o=r?.data,i=o?.operation;if(i===W.APPLICATION_EMAIL_SETTINGS_SET){const l=Cr(o?.settings),c=this._getLayoutSnapshot(l);c!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=c,this._layoutSettingsChanged.fire(l));return}if(i!==W.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Tr(r.data?.settings?.commonStyles??{...go}),a=this._getContentSnapshot(s);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=Cr(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=VE){const t=ct(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,o=Ie(r,$.ON_EMAIL_INIT_ID);return new Promise(i=>{let s=!1,a;const l=()=>{a&&(clearTimeout(a),a=void 0)},c=o(()=>{s||(s=!0,l(),c.dispose(),i())});a=setTimeout(()=>{s||(s=!0,c.dispose(),i())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=ct(this._editor.container)?.current();if(!t)return;const n=ks(t.get().attributes.common_styles);e.text!==void 0&&(n.text={...n.text||{},...e.text}),e.headings!==void 0&&(n.headings={...n.headings||{},...e.headings}),e.links!==void 0&&(n.links={...n.links||{},...e.links}),e.buttons!==void 0&&(n.buttons=wr(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Ae.border,borderRadius:Ae.borderRadius,padding:Ae.padding})),e.block!==void 0&&(n.block=wr(n.block||{},e.block,["padding"],{padding:Ae.padding})),e.cards!==void 0&&(n.cards=wr(n.cards||{},e.cards,["border","borderRadius"],{border:Ae.border,borderRadius:Ae.borderRadiusCards}));const r=JSON.stringify(n);gt(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=Tr(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},qE={...gc,EmailSettingsApi:vc},GE={...gc},Zw={...GE,EmailSettingsApi:vc},zE={...qE};function WE(){aE.addAll(zE)}var KE=[_t(()=>{WE()}),Uy,Jy,jy,ld,Fy,bd];async function YE(){return(await Zt()).asyncMixins}var XE=EE,JE=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await YE()}catch(s){throw e.failPendingWaits(s),s}t=o(e);const i=await e.getInstanceAsync(Nn);Object.assign(i,t.instance||{});for(const s of e.getInstance(vo)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},QE=gd([...KE]);function Ar(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const i of r.values())i();r.clear()}return{event(i,s,a){const l=Symbol("subscription");return t||(n.set(l,{listener:i,priority:s,thisArg:a}),e&&r.set(l,e(i,s,a))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(i){o(),e=i;for(const[s,{listener:a,priority:l,thisArg:c}]of n)r.set(s,i(a,l,c))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function ZE(e){const t=Ar(),n=Ar(),r=Ar();return e.getInstance(z)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(ht).then(o=>{t.attach(o.onNotify),n.attach(o.onError),r.attach(o.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(o){const i=e.getInstance(ht);if(i){i.notify(o);return}e.getInstanceAsync(ht).then(s=>s.notify(o),()=>{})}}}var bc=H("CodeErrors"),e_=[];function t_(e){return e?.getInstance(bc)?.get()??e_}function n_(e){return e?.getInstance(bc)!==void 0}var r_=class extends ge{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=Qt(e),this.addDisposable(Ie(e,$.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){const e=nt(this._container);if(e&&oe(e.sessionKey())&&!e.hasSuspended())throw new Error("[emailmaker] no open email: only a block is shown");return $l(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>ye(t,this._container))}async _readProjectBlocks(){const e=await Vl(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>Pt(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>Qr(n,this._container))}async getEmailSnapshot(){return Se(this.openEmail(),this._container)}async getBlockSnapshot(){const e=nt(this._container),t=e?.current();return!e||!t||!oe(e.sessionKey())?null:(await t.whenReady(),ye(qn(t),this._container))}setEmailMeta(e){const t=zo(this._container);if(!t)return;const n=t.get().attributes.meta;gt(t,{meta:ln({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&ln(o,e))}setBlockMeta(e,t){const n=nt(this._container);if(n?.sessionKey()===Sn(e)){const o=n.current();o&&gt(o,{meta:ln({meta:o.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,i=>i&&ln(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return n_(this._container)?t_(this._container):void 0}},o_=H("EmailDataController");function i_(e){return e.getOrCreateInstance(o_,()=>{const t=new r_(e);return e.getInstance(z)?.addDisposable(t),t})}function s_(e){const t=i_(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function a_(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function l_(e){let t;const n=Pl(e),r=Ie(e,$.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:i})=>{t=i}));const o=()=>t?a_(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:i=>o()?.getPast(i)??[],getFuture:i=>o()?.getFuture(i)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:i=>o()?.restoreSnapshot(i)}}}var c_=H("plugin.mountElement");function d_(e){const t=e.getInstance(be)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function u_(e){return e.getOrCreateInstance(c_,()=>{let t=!1,n;return{get:()=>t?n:d_(e),set(r){t=!0,n=r}}})}function f_(e){const t=u_(e);return{getElement:()=>t.get()}}function p_(e){return{handleLoadImage:V(Ie(e,$.UPLOAD_EVENT_ID)),handleFileProxy:V(Ie(e,$.FILE_PROXY_EVENT_ID)),handleUrlProxy:V(Ie(e,$.PROXY_URL_EVENT_ID)),handleAITextRequest:V(Ie(e,$.AI_TEXT_REQUEST_ID)),handleAIImageRequest:V(Ie(e,$.AI_IMAGE_REQUEST_ID)),handleReadLocale:V(Ie(e,$.READ_LOCALE)),handleLimitUsage:V(Ie(e,$.ON_LIMIT_ID)),handleTranslate:V(Ie(e,$.ON_TRANSLATE_ID))}}var h_=[Fg,sy,ZE,Xy,s_,l_,f_,p_];function m_(e,t=h_){const n=Ko(e);My(e);const r=QE(e),o=XE(e),i=JE(e),s={...r.instance,...o.instance,...i.instance};for(const l of t)Object.assign(s,l(e));let a=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const c=a&&n.get()===l;a=!1,c||n.set(l),await o.setOptions(l),await i.setOptions(l)}}}function g_(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var v_=class{_storage=Object.create(null);get(e){const t=this._storage[e];return t&&(!t.expires||t.expires<Date.now())?t.value:""}set(e,t,n){this._storage[e]={value:t,expires:n.expires?n.expires*1e3+Date.now():void 0}}remove(e){delete this._storage[e]}},b_="editor-runtime.react.copies",Rr=8;function Ut(e){return e&&typeof e=="object"?e:void 0}function Ms(e){const t=Ut(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Ut(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function y_(e){const t=Ut(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Ut(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function E_(e,t,n){return e.package===t&&e.version===n}function __({ourReact:e,entries:t,packageName:n,version:r}){const o=Ms(e);if(!o||!Array.isArray(t))return[];const i=[],s=new Set;for(const a of t){const l=Ut(a);if(!l||!E_(l,n,r))continue;const c=Ms(l.react);!c||c===o||s.has(c)||(s.add(c),i.push({package:n,version:r,reactVersion:y_(l.react),react:l.react}))}return i}function w_({packageName:e,copies:t}){const n=[`[${e}] A second copy of React is on this page (singleton invariant broken).`,`The editor runs on its own React, the plugin got another one from ${e}/runtime/react.`,`This shows up as "Cannot read properties of null (reading 'useState')" and takes down the whole`,"editor, not just the plugin panel: plugin components render inside the editor tree.","","Found:"];for(const r of t.slice(0,Rr))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Rr&&n.push(` …and ${t.length-Rr} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
1048
+ `)}var Ls=new Set;function S_({packageName:e="@emailmaker/emailmaker",version:t="1.3.3",log:n=r=>{}}={}){const r=o=>{try{const i=globalThis[Symbol.for(b_)],s=__({ourReact:o,entries:i,packageName:e,version:t}).filter(a=>!Ls.has(a.react));if(!s.length)return;s.forEach(a=>Ls.add(a.react)),n(w_({packageName:e,copies:s}))}catch{}};try{const o=Eo()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function I_(e,t,n){ne(e.signal);const r=t??mt.createChild();Ko(r);const o=r.getInstance(z);let i;async function s(){r.inject(Ws,g_(new v_)),S_();const a=m_(r),l={...a.instance,container:r,get ready(){return i??Promise.resolve(l)},async reset(c){if(ne(c.signal),o.isDisposed())throw je();return await a.setOptions(c),l}};r.inject(Nn,l);try{if(n?.onInstance?.(l),await a.setOptions(e),ne(e.signal),o.isDisposed()||await ry(r),e.devTools)try{const c=r.getInstance(mo);c&&await(await Zt()).initDevTools(r,c)}catch{}return ne(e.signal),qt(r,Js).fire(l),l}catch(c){throw o.dispose(),c}}try{return i=En(s(),e.signal),i.catch(()=>{}),await i}catch(a){throw o.isDisposed()||o.dispose(),a}}var Ht=new WeakMap;function C_(e){return e?Ht.get(e):void 0}function yc(e){try{e.getInstance(z)?.dispose()}catch{}try{e.dispose()}catch{}}function T_(e,t){if(!e)return;const n=Ht.get(e);n&&n!==t&&yc(n),Ht.set(e,t)}function A_(e,t){e&&Ht.get(e)===t&&Ht.delete(e)}function R_(e){const t=mt.createChild();return Yt(e)&&t.inject(Me,Gn(e)),t}var Nt=new WeakMap,P_="data-emailmaker-config-styles";function O_(e){return typeof e=="string"?e.trim():""}function Ns(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function D_(e,t,n){if(!e||typeof document>"u")return null;const r=O_(t),o=Nt.get(e),i=n||e;if(!r)return o&&(o.remove(),Nt.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==i||o!==i.firstChild)&&Ns(i,o),o;const s=document.createElement("style");return s.setAttribute(P_,"true"),s.textContent=r,Ns(i,s),Nt.set(e,s),s}function k_(e){if(!e)return;const t=Nt.get(e);t&&(t.remove(),Nt.delete(e))}function Ec(){return!1}var x_=`
1049
1049
  .blocks-app-initial-spinner-wrapper {
1050
1050
  width: 100%;
1051
1051
  height: 100%;
@@ -1074,7 +1074,7 @@ import{n as Ws,r as kc}from"./static/esm/971f1b2c.js";import{$ as xc,A as Mc,At
1074
1074
  100% {
1075
1075
  transform: rotate(360deg);
1076
1076
  }
1077
- }`;function M_(){return()=>{}}function L_(e,t){if(!Ec()||!e||typeof document>"u")return M_();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const o=document.createElement("style");o.setAttribute(t,"true"),o.textContent=x_,document.head?.appendChild(o),e.appendChild(n);let i=!1;return()=>{i||(i=!0,n.remove(),o.remove())}}function N_(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function F_({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,i){const s=t.get(o);if(s!==void 0)return s;const a=i().catch(l=>{throw n.has(o)||(n.add(o),r(l)),N_(l)||t.delete(o),l});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var Qo=F_();function _c(){Qo.clear()}dd(()=>Qo.clear());var Fs=new WeakMap;function Zo(e){return Mc(e)}function B_(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function j_(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function U_(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}var ei=new WeakMap;function Pr(e,t){ei.set(e,t)}function H_(e){return ei.get(e)}function $_(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&ei.get(r)||e,i=Zo(n);if(!i)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await U_(o);if(o.getAuthToken&&!a)throw j_();a&&s.set("authorization",a);const l=await nd("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},i,{attemptTimeout:Ho(o)||void 0});if(!l.ok)throw B_(l.status,l.statusText);return await l.json()}}function V_(e){return JSON.stringify({baseUrl:Zo(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function q_(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function G_(e){return t=>Qo.run(V_(t),()=>(ie("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>ie("appInit:end",{kind:"network"}))))}function W_(e,t){if(Yt(e)||!e.appInit&&!Zo(e.baseUrl)||!q_(e))return e;const n=e.appInit??$_(e,t);let r=Fs.get(n);return r||(r=G_(n),Fs.set(n,r)),{...e,appInit:r}}var wc=0;function z_(){return wc}function K_(){wc+=1,_c()}var Bs=new WeakMap,js=new WeakMap,Y_=3e4;function X_(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function J_(e,t){try{const n=ho(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+Y_}function Q_(e){const t=new Map,n=new Map;return async(r,o,i)=>{const s=X_(r,o);if(i)return n.delete(s),t.delete(s),_c(),e(r,o,i);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let l=t.get(s);return l===void 0&&(ie("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,o,i)).then(c=>{const d=String(c||"").trim();return d&&n.set(s,{token:c,expiresAtMs:J_(d,Date.now())}),c}).finally(()=>{ie("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function Z_(e){if(Yt(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Bs.get(t);const r=z_();return(!n||js.get(t)!==r)&&(n=Q_(t),Bs.set(t,n),js.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var ew="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function tw(e){const t=new Error(ew,{cause:e});return t.name="EditorStartFailedError",t}var nw={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function Us(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Sc=["handleLoad","handleDestroy"];function Ic(e,t){let n=e;for(const r of Sc){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(i,...s)=>o(t,...s)})}return n}function rw(e){let t,n="pending",r,o,i,s;const a=new Set,l=[],c=new Set;let d,m;const b=new Promise((I,F)=>{d=I,m=F});b.catch(()=>{});const v={},w=I=>t?.[I],C=()=>r??je(),y=(I,F)=>{const j=w(I);if(typeof j!="function")throw Us(I);return j.apply(t,F)},S=(I,F)=>{try{return Promise.resolve(y(I,F))}catch(j){return Promise.reject(j)}},A=()=>{const I=t?.container?.getInstance?.(W);if(!(n!=="ready"||I?.isDisposed()||typeof w("getConfig")!="function"))try{s=y("getConfig",[])}catch{}},B=()=>n==="dead"?Promise.reject(C()):n==="ready"?Promise.resolve():b,k=()=>{for(const[I,F]of On)F==="field"&&(v[I]=w(I))},P=I=>{const F=w(I.name);I.dispose||typeof F!="function"||n==="dead"||(I.dispose=F.apply(t,I.args))},T=()=>a.forEach(P),x=()=>{for(const I of a){try{I.dispose?.()}catch{}I.dispose=void 0}},R=()=>{k(),T()},h=()=>{i?.delete(R),i=void 0},f=(I,F)=>{const[j,...K]=F;return!Sc.includes(I)||typeof j!="function"?F:[(de,...se)=>j(v,...se),...K]},u=(I,F)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof w(I)!="function")throw Us(I);const j={name:I,args:f(I,F)};return a.add(j),P(j),()=>{a.delete(j),j.dispose?.(),j.dispose=void 0}},g=()=>t?.container?.getInstance(be)?.get()?.content,O=()=>{const I=e.element();return I!==void 0&&typeof I!="string"?I:void 0},M=(I,F)=>{switch(F){case"event":return(...j)=>u(I,j);case"async":return(...j)=>(I==="show"&&j[0]!==void 0&&e.shown?.(j[0]),n!=="dead"&&typeof w(I)=="function"?S(I,j):B().then(()=>y(I,j)));case"queued":return(...j)=>{if(n==="dead"){if(I==="notify")return;throw C()}if(n==="pending"){l.push({name:I,args:j});return}return y(I,j)};case"sync":return(...j)=>{if(n==="dead"){if(I==="getConfig")return s;throw C()}if(typeof w(I)!="function")throw new Error(`[emailmaker] \`${I}\` is not available before the editor is ready: ${nw[I]??"await `ready` first"}`);const K=y(I,j);return I==="getConfig"&&(s=K),K};case"element":return()=>{if(typeof w(I)!="function")return O();try{return y(I,[])}catch{return O()}};case"codeErrors":return()=>n==="ready"&&typeof w(I)=="function"?y(I,[]):[];case"field":return}};for(const[I,F]of On)v[I]=M(I,F);v.reset=I=>(I?.content!==void 0&&e.shown?.(I.content),B().then(async()=>{const F=I?.content!==void 0&&xe(I.content,g());await y("reset",[Ic(I,_)]),F&&await y("show",[I.content])}).then(()=>v)),v.destroy=()=>{if(n==="dead")return;const I=_e("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),c.forEach(F=>F(I)),A(),e.destroy()},Object.defineProperty(v,"ready",{get:()=>o,enumerable:!0,configurable:!0});const _=v;return{object:_,get state(){return n},get editor(){return t},bind:I=>{n==="dead"||t===I||(x(),h(),t=I,k(),T(),n==="pending"&&(i=I.container.getOrCreateInstance(vo,()=>new Set),i.add(R)))},settle:()=>{if(n==="pending"){n="ready",h(),k(),T();for(const I of l.splice(0))try{y(I.name,I.args)}catch(F){queueMicrotask(()=>{throw F})}d()}},kill:(I,F)=>{n!=="dead"&&(A(),n="dead",r=I,l.length=0,c.forEach(j=>j(I)),h(),F?.keepSubscriptions||(x(),a.clear()),m(I))},detach:()=>{x(),a.clear()},setReady:I=>{o=I},trackCall:I=>(c.add(I),()=>c.delete(I)),hasCalls:()=>c.size>0}}var Cc="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function ow(){return _e(Cc)}function iw(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Cc}function sw(e,t,n){if(typeof document>"u")return;let r=!1,o;const i=()=>{r=!0,o?.disconnect(),o=void 0},s=()=>{r||(i(),t())};if(n.addDispose(i),!e.isConnected){queueMicrotask(s);return}o=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function aw(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const i=new AbortController;return sw(n,()=>{n.id,i.abort(ow())},o),po(r,i.signal)}var Tc="Superseded by newer init() on the same mount element";function Hs(){return _e(Tc)}function lw(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Tc}var Tt=new Map,$s=new WeakMap,pn=new WeakMap;function cw(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function dw(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=cw(e);(n?Tt.get(n):void 0)?.forEach(d=>{d.element!==e&&d.controller.abort(Hs())});const r=$s.get(e)??new Set;t&&r.forEach(d=>{d.supersedable&&d.controller.abort(Hs())});const o=pn.get(e)??Promise.resolve();let i;const s=new Promise(d=>{i=d}),a=o.then(()=>s);pn.set(e,a),a.then(()=>{pn.get(e)===a&&pn.delete(e)});const l=new AbortController,c={element:e,controller:l,supersedable:t};if(r.add(c),$s.set(e,r),n){const d=Tt.get(n)??new Set;d.add(c),Tt.set(n,d)}return{signal:l.signal,previous:o,release:()=>{i(),r.delete(c);const d=n?Tt.get(n):void 0;n&&d?.delete(c)&&d.size===0&&Tt.delete(n)}}}var $t=new WeakMap;function ti(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function ao(e){return Object.entries(e).filter(([t,n])=>ti(t,n)).map(([t])=>t).sort()}function Vs(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!ti(n,r)&&(t[n]=r);return t}function lo(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:$t.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},$t.set(e,r));const{current:o,trampolines:i}=r;o.clear();const s={...t};for(const a of ao(t)){o.set(a,t[a]);let l=i.get(a);l||(l=(...c)=>o.get(a)?.(...c),i.set(a,l)),s[a]=l}return r.lastOptions=t,s}function Ac(e,t){const n=e?$t.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];ti(r,o)?n.current.set(r,o):n.current.delete(r)}}function uw(e){const t=e?$t.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,i)=>t.current.set(i,o)),t.lastOptions=r}}function fw(e,t,n){const r=e?$t.get(e):void 0;if(!r||!n)return!1;const o=ao(t),i=xe(o,ao(r.lastOptions)),s=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!i||!s||!xe(Vs(t),Vs(r.lastOptions))?!1:(lo(e,t),!0)}var Oe=new WeakMap;function Jn(e){let t=Oe.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},Oe.set(e,t)),t}var $e=e=>e!==void 0&&e.state!=="dead";function pw(e){const t=Oe.get(e)?.shared;return $e(t)?t:void 0}function hw(e,t){Jn(e).shared=t}function mw(e,t){!($e(e.shared)&&[...e.counted].some($e))||e.warned||!t.devTools||(e.warned=!0)}function gw(e,t,n,r){const o=Jn(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(i=>i.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(i=>i!==t&&$e(i)),t],mw(o,r),o.latestCall}function vw(e,t){return Oe.get(e)?.latestCall===t}function bw(e){const t=Oe.get(e);if(t)return t.order=t.order.filter($e),t.order.at(-1)?.object}function Vt(e,t){const n=Oe.get(e);return n?$e(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&$e(r)):!1}function yw(e,t){const n=Oe.get(e),r=n?.order.filter(o=>o!==t&&$e(o)).at(-1);return r?n?.options.get(r):void 0}function Rc(e,t){Jn(e).content={value:t}}function Ew(e){return Oe.get(e)?.content}function _w(e,t,n,r){const o=Jn(e);if(o.counted.delete(t),o.options.delete(t),Vt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),Pc(e,r)}function Pc(e,t){const n=Oe.get(e);!n||Vt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Vt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function ww(e,t){const n=Oe.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);Oe.delete(e)}}var eS=Ws({FileManagerApiError:()=>Sw,IntegratorSaveTimeoutError:()=>Fn,SaveRefusedError:()=>et}),Sw=class Oc extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,o){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=o,Error.captureStackTrace&&Error.captureStackTrace(this,Oc)}},tS=Ws({mapHttpStatusToErrorCode:()=>Id});function Iw(e,t){return{...e,element:t}}function co(){return()=>{}}function Cw(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?co():(D_(t,e.config?.styles,t),()=>{k_(t)})}function Tw(e){if(!Ec()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:co()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:co()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=L_(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function Aw(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function kn(e){try{e.destroy()}catch{}}function yn(e,...t){const n=Te.get(e);t.some(r=>r!==void 0&&r===n)&&Te.delete(e)}var nS="1.3.2";async function rS(e){Lo(),await rE(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}async function oS(e){return kw(e).ready}function Rw(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function Pw(e){const t=Te.get(e);return t&&!(t instanceof Promise)?t:void 0}function xn(e,t,n){const r=t??Pw(e);r&&(yn(e,r),kn(r)),ww(e,n)}function Ow(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const s=t.editor;Dw(s),t.kill(je());return}if(n==="single"){xn(o,t.editor,je());return}const i=yw(o,t);_w(o,t,je(),()=>xn(o,t.editor,je())),i&&Vt(o)&&Ac(o,i)}function Dw(e){e&&kn(e)}function kw(e){ie(me.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=po(e.signal,n.signal),o=t==="single"?Rw(e.element):void 0,i=o?pw(o):void 0;let s;if(i)s={control:i,mode:t,ref:{host:o}};else{const d={},m=rw({element:()=>d.host??e.element,destroy:()=>Ow(s),shown:b=>{d.host&&Rc(d.host,b)}});s={control:m,mode:t,ref:d},o&&hw(o,m)}const{control:a}=s,l=a.trackCall(d=>n.abort(d)),c=Fw(Ic({...e,signal:r},a.object),s).then(()=>(l(),ie(me.initEnd),a.settle(),a.object),d=>{l(),a.state==="pending"&&!a.hasCalls()&&a.kill(d);const m=s.ref.host;throw m&&Pc(m,()=>xn(m,void 0,je())),d});return a.setReady(c),a.object}function iS(e){const t=typeof e=="string"?document.querySelector(e):e;return t?bw(t):void 0}function xw(e){let t,n,r=!1;try{t=e.container.getInstance(be)?.get(),n=e.container.getInstance(Pe)?.externalSignal;const o=ct(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:Mw(e),dirty:r}}async function Mw(e){try{return await e.getEmailSnapshot()}catch{return}}function Lw(e){const t=ct(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function qs(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Vt(e,n)}async function Nw(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),lw(o)||iw(o))return;const i=()=>xn(t,e,tw(o)),{options:s}=n;if(!s||!qs(t,r)){i();return}const a=await n.email,l=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,c=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:l?{...c,email:l}:s.content}),n.dirty&&l&&Lw(e),qs(t,r)?Te.set(t,e):i()}catch{i()}}async function Fw(e,t){ne(e.signal);const n=new ge;let r,o,i,s,a=0;try{const l=await md(e.element,n,e.signal);l&&(s=l,t.ref.host=l,a=gw(l,t.control,t.mode,e));const c=aw({hostElementOption:e.element,resolvedElement:l,externalSignal:e.signal,disposable:n}),d=dw(l,{supersede:t.mode==="single"});r=d.release;const m=po(c,d.signal);ne(m),i=uw(l),Ac(l,e),await En(d.previous,m),o=Bw(e,l,t,m,i);const b=await En(o,m);return l&&e.content!==void 0&&Rc(l,e.content),b}catch(l){throw s&&i&&vw(s,a)&&i(),l}finally{const l=r;o!==void 0&&l?o.then(l,l):l?.(),n.dispose()}}async function Gs(e,t,n,r){const o=Ew(t);n===void 0||r||!o||xe(n,o.value)||await e.show(n)}async function Bw(e,t,n,r,o){const{control:i}=n,s=C=>i.bind(C);ne(r);let a;const l=C=>{K_();const y=Z_(Iw(C,t)),S=W_(y,()=>a);return{preparedOptions:S,preparedOptionsWithSignal:r!=null?{...S,signal:r}:S}};let c;if(t){const C=Te.get(t);if(C){let y;try{y=await C,ne(r)}catch{ne(r),yn(t,C),y=void 0}if(y)if(y.getElement()===t){const S=C_(t);a=S;const A=y.container.getInstance(be)?.get();if(fw(t,e,A))return s(y),r&&y.container.getInstance(Pe)?.relinkExternalSignal(r),Te.set(t,y),await Gs(y,t,e.content,!1),y;const B=!xe(e.content,A?.content);c=l(lo(t,e));const{preparedOptions:k,preparedOptionsWithSignal:P}=c,T=S&&H_(S),x=xw(y);try{S&&Pr(S,k),s(y);const R=await y.reset(Aw(e,P));return ne(r),Te.set(t,y),await Gs(y,t,e.content,B),R}catch(R){if(S&&T&&Pr(S,T),!Yd(R))throw o(),await Nw(y,t,x,n,R),R;yn(t,C,y),kn(y),ne(r)}}else yn(t,C,y),kn(y)}}ne(r),c??=l(lo(t,e,{fresh:!0}));const{preparedOptions:d}=c,m=Cw(d),b=Tw(d),v=r!=null?{...b.options,signal:r}:b.options;let w;try{a=R_(v),T_(t,a),Pr(a,d),Ko(a).set(v),await Yo(),ie(me.coreReady),ne(r),ne(r),w=I_(v,a,{onInstance:s}),t&&Te.set(t,w);const C=await w;if(r?.aborted&&(C.destroy(),ne(r)),t)if(Te.get(t)===w)Te.set(t,C);else throw C.destroy(),ne(r),_e(r?.reason);return C}catch(C){throw m(),b.cleanup(),a&&(yc(a),A_(t,a)),t&&w&&Te.get(t)===w&&Te.delete(t),C}}async function sS(e){return(await Zt()).parseAMP(e)}typeof window<"u"&&(Ft()&&zd(),iE(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0));export{Cc as ELEMENT_DETACHED_ABORT_MESSAGE,Tc as SUPERSEDED_INIT_ABORT_MESSAGE,kw as create,eS as errors,iS as getInstance,tS as helpers,oS as init,iw as isElementDetachedError,lw as isSupersededInitError,sS as parseAMP,aE as pluginRegistry,rS as preload,nS as version};
1077
+ }`;function M_(){return()=>{}}function L_(e,t){if(!Ec()||!e||typeof document>"u")return M_();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const o=document.createElement("style");o.setAttribute(t,"true"),o.textContent=x_,document.head?.appendChild(o),e.appendChild(n);let i=!1;return()=>{i||(i=!0,n.remove(),o.remove())}}function N_(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function F_({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,i){const s=t.get(o);if(s!==void 0)return s;const a=i().catch(l=>{throw n.has(o)||(n.add(o),r(l)),N_(l)||t.delete(o),l});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var Qo=F_();function _c(){Qo.clear()}dd(()=>Qo.clear());var Fs=new WeakMap;function Zo(e){return Mc(e)}function B_(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function j_(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function U_(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}var ei=new WeakMap;function Pr(e,t){ei.set(e,t)}function H_(e){return ei.get(e)}function $_(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&ei.get(r)||e,i=Zo(n);if(!i)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await U_(o);if(o.getAuthToken&&!a)throw j_();a&&s.set("authorization",a);const l=await nd("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},i,{attemptTimeout:Ho(o)||void 0});if(!l.ok)throw B_(l.status,l.statusText);return await l.json()}}function V_(e){return JSON.stringify({baseUrl:Zo(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function q_(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function G_(e){return t=>Qo.run(V_(t),()=>(ie("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>ie("appInit:end",{kind:"network"}))))}function z_(e,t){if(Yt(e)||!e.appInit&&!Zo(e.baseUrl)||!q_(e))return e;const n=e.appInit??$_(e,t);let r=Fs.get(n);return r||(r=G_(n),Fs.set(n,r)),{...e,appInit:r}}var wc=0;function W_(){return wc}function K_(){wc+=1,_c()}var Bs=new WeakMap,js=new WeakMap,Y_=3e4;function X_(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function J_(e,t){try{const n=ho(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+Y_}function Q_(e){const t=new Map,n=new Map;return async(r,o,i)=>{const s=X_(r,o);if(i)return n.delete(s),t.delete(s),_c(),e(r,o,i);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let l=t.get(s);return l===void 0&&(ie("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,o,i)).then(c=>{const d=String(c||"").trim();return d&&n.set(s,{token:c,expiresAtMs:J_(d,Date.now())}),c}).finally(()=>{ie("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function Z_(e){if(Yt(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Bs.get(t);const r=W_();return(!n||js.get(t)!==r)&&(n=Q_(t),Bs.set(t,n),js.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var ew="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function tw(e){const t=new Error(ew,{cause:e});return t.name="EditorStartFailedError",t}var nw={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function Us(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Sc=["handleLoad","handleDestroy"];function Ic(e,t){let n=e;for(const r of Sc){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(i,...s)=>o(t,...s)})}return n}function rw(e){let t,n="pending",r,o,i,s;const a=new Set,l=[],c=new Set;let d,m;const b=new Promise((I,F)=>{d=I,m=F});b.catch(()=>{});const v={},w=I=>t?.[I],C=()=>r??je(),y=(I,F)=>{const j=w(I);if(typeof j!="function")throw Us(I);return j.apply(t,F)},S=(I,F)=>{try{return Promise.resolve(y(I,F))}catch(j){return Promise.reject(j)}},A=()=>{const I=t?.container?.getInstance?.(z);if(!(n!=="ready"||I?.isDisposed()||typeof w("getConfig")!="function"))try{s=y("getConfig",[])}catch{}},B=()=>n==="dead"?Promise.reject(C()):n==="ready"?Promise.resolve():b,k=()=>{for(const[I,F]of On)F==="field"&&(v[I]=w(I))},P=I=>{const F=w(I.name);I.dispose||typeof F!="function"||n==="dead"||(I.dispose=F.apply(t,I.args))},T=()=>a.forEach(P),x=()=>{for(const I of a){try{I.dispose?.()}catch{}I.dispose=void 0}},R=()=>{k(),T()},h=()=>{i?.delete(R),i=void 0},f=(I,F)=>{const[j,...K]=F;return!Sc.includes(I)||typeof j!="function"?F:[(de,...se)=>j(v,...se),...K]},u=(I,F)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof w(I)!="function")throw Us(I);const j={name:I,args:f(I,F)};return a.add(j),P(j),()=>{a.delete(j),j.dispose?.(),j.dispose=void 0}},g=()=>t?.container?.getInstance(be)?.get()?.content,O=()=>{const I=e.element();return I!==void 0&&typeof I!="string"?I:void 0},M=(I,F)=>{switch(F){case"event":return(...j)=>u(I,j);case"async":return(...j)=>(I==="show"&&j[0]!==void 0&&e.shown?.(j[0]),n!=="dead"&&typeof w(I)=="function"?S(I,j):B().then(()=>y(I,j)));case"queued":return(...j)=>{if(n==="dead"){if(I==="notify")return;throw C()}if(n==="pending"){l.push({name:I,args:j});return}return y(I,j)};case"sync":return(...j)=>{if(n==="dead"){if(I==="getConfig")return s;throw C()}if(typeof w(I)!="function")throw new Error(`[emailmaker] \`${I}\` is not available before the editor is ready: ${nw[I]??"await `ready` first"}`);const K=y(I,j);return I==="getConfig"&&(s=K),K};case"element":return()=>{if(typeof w(I)!="function")return O();try{return y(I,[])}catch{return O()}};case"codeErrors":return()=>n==="ready"&&typeof w(I)=="function"?y(I,[]):[];case"field":return}};for(const[I,F]of On)v[I]=M(I,F);v.reset=I=>(I?.content!==void 0&&e.shown?.(I.content),B().then(async()=>{const F=I?.content!==void 0&&xe(I.content,g());await y("reset",[Ic(I,_)]),F&&await y("show",[I.content])}).then(()=>v)),v.destroy=()=>{if(n==="dead")return;const I=_e("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),c.forEach(F=>F(I)),A(),e.destroy()},Object.defineProperty(v,"ready",{get:()=>o,enumerable:!0,configurable:!0});const _=v;return{object:_,get state(){return n},get editor(){return t},bind:I=>{n==="dead"||t===I||(x(),h(),t=I,k(),T(),n==="pending"&&(i=I.container.getOrCreateInstance(vo,()=>new Set),i.add(R)))},settle:()=>{if(n==="pending"){n="ready",h(),k(),T();for(const I of l.splice(0))try{y(I.name,I.args)}catch(F){queueMicrotask(()=>{throw F})}d()}},kill:(I,F)=>{n!=="dead"&&(A(),n="dead",r=I,l.length=0,c.forEach(j=>j(I)),h(),F?.keepSubscriptions||(x(),a.clear()),m(I))},detach:()=>{x(),a.clear()},setReady:I=>{o=I},trackCall:I=>(c.add(I),()=>c.delete(I)),hasCalls:()=>c.size>0}}var Cc="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function ow(){return _e(Cc)}function iw(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Cc}function sw(e,t,n){if(typeof document>"u")return;let r=!1,o;const i=()=>{r=!0,o?.disconnect(),o=void 0},s=()=>{r||(i(),t())};if(n.addDispose(i),!e.isConnected){queueMicrotask(s);return}o=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function aw(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const i=new AbortController;return sw(n,()=>{n.id,i.abort(ow())},o),po(r,i.signal)}var Tc="Superseded by newer init() on the same mount element";function Hs(){return _e(Tc)}function lw(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Tc}var Tt=new Map,$s=new WeakMap,pn=new WeakMap;function cw(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function dw(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=cw(e);(n?Tt.get(n):void 0)?.forEach(d=>{d.element!==e&&d.controller.abort(Hs())});const r=$s.get(e)??new Set;t&&r.forEach(d=>{d.supersedable&&d.controller.abort(Hs())});const o=pn.get(e)??Promise.resolve();let i;const s=new Promise(d=>{i=d}),a=o.then(()=>s);pn.set(e,a),a.then(()=>{pn.get(e)===a&&pn.delete(e)});const l=new AbortController,c={element:e,controller:l,supersedable:t};if(r.add(c),$s.set(e,r),n){const d=Tt.get(n)??new Set;d.add(c),Tt.set(n,d)}return{signal:l.signal,previous:o,release:()=>{i(),r.delete(c);const d=n?Tt.get(n):void 0;n&&d?.delete(c)&&d.size===0&&Tt.delete(n)}}}var $t=new WeakMap;function ti(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function ao(e){return Object.entries(e).filter(([t,n])=>ti(t,n)).map(([t])=>t).sort()}function Vs(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!ti(n,r)&&(t[n]=r);return t}function lo(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:$t.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},$t.set(e,r));const{current:o,trampolines:i}=r;o.clear();const s={...t};for(const a of ao(t)){o.set(a,t[a]);let l=i.get(a);l||(l=(...c)=>o.get(a)?.(...c),i.set(a,l)),s[a]=l}return r.lastOptions=t,s}function Ac(e,t){const n=e?$t.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];ti(r,o)?n.current.set(r,o):n.current.delete(r)}}function uw(e){const t=e?$t.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,i)=>t.current.set(i,o)),t.lastOptions=r}}function fw(e,t,n){const r=e?$t.get(e):void 0;if(!r||!n)return!1;const o=ao(t),i=xe(o,ao(r.lastOptions)),s=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!i||!s||!xe(Vs(t),Vs(r.lastOptions))?!1:(lo(e,t),!0)}var Oe=new WeakMap;function Jn(e){let t=Oe.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},Oe.set(e,t)),t}var $e=e=>e!==void 0&&e.state!=="dead";function pw(e){const t=Oe.get(e)?.shared;return $e(t)?t:void 0}function hw(e,t){Jn(e).shared=t}function mw(e,t){!($e(e.shared)&&[...e.counted].some($e))||e.warned||!t.devTools||(e.warned=!0)}function gw(e,t,n,r){const o=Jn(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(i=>i.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(i=>i!==t&&$e(i)),t],mw(o,r),o.latestCall}function vw(e,t){return Oe.get(e)?.latestCall===t}function bw(e){const t=Oe.get(e);if(t)return t.order=t.order.filter($e),t.order.at(-1)?.object}function Vt(e,t){const n=Oe.get(e);return n?$e(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&$e(r)):!1}function yw(e,t){const n=Oe.get(e),r=n?.order.filter(o=>o!==t&&$e(o)).at(-1);return r?n?.options.get(r):void 0}function Rc(e,t){Jn(e).content={value:t}}function Ew(e){return Oe.get(e)?.content}function _w(e,t,n,r){const o=Jn(e);if(o.counted.delete(t),o.options.delete(t),Vt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),Pc(e,r)}function Pc(e,t){const n=Oe.get(e);!n||Vt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Vt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function ww(e,t){const n=Oe.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);Oe.delete(e)}}var eS=zs({FileManagerApiError:()=>Sw,IntegratorSaveTimeoutError:()=>Fn,SaveRefusedError:()=>et}),Sw=class Oc extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,o){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=o,Error.captureStackTrace&&Error.captureStackTrace(this,Oc)}},tS=zs({mapHttpStatusToErrorCode:()=>Id});function Iw(e,t){return{...e,element:t}}function co(){return()=>{}}function Cw(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?co():(D_(t,e.config?.styles,t),()=>{k_(t)})}function Tw(e){if(!Ec()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:co()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:co()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=L_(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function Aw(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function kn(e){try{e.destroy()}catch{}}function yn(e,...t){const n=Te.get(e);t.some(r=>r!==void 0&&r===n)&&Te.delete(e)}var nS="1.3.3";async function rS(e){Lo(),await rE(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}async function oS(e){return kw(e).ready}function Rw(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function Pw(e){const t=Te.get(e);return t&&!(t instanceof Promise)?t:void 0}function xn(e,t,n){const r=t??Pw(e);r&&(yn(e,r),kn(r)),ww(e,n)}function Ow(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const s=t.editor;Dw(s),t.kill(je());return}if(n==="single"){xn(o,t.editor,je());return}const i=yw(o,t);_w(o,t,je(),()=>xn(o,t.editor,je())),i&&Vt(o)&&Ac(o,i)}function Dw(e){e&&kn(e)}function kw(e){ie(me.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=po(e.signal,n.signal),o=t==="single"?Rw(e.element):void 0,i=o?pw(o):void 0;let s;if(i)s={control:i,mode:t,ref:{host:o}};else{const d={},m=rw({element:()=>d.host??e.element,destroy:()=>Ow(s),shown:b=>{d.host&&Rc(d.host,b)}});s={control:m,mode:t,ref:d},o&&hw(o,m)}const{control:a}=s,l=a.trackCall(d=>n.abort(d)),c=Fw(Ic({...e,signal:r},a.object),s).then(()=>(l(),ie(me.initEnd),a.settle(),a.object),d=>{l(),a.state==="pending"&&!a.hasCalls()&&a.kill(d);const m=s.ref.host;throw m&&Pc(m,()=>xn(m,void 0,je())),d});return a.setReady(c),a.object}function iS(e){const t=typeof e=="string"?document.querySelector(e):e;return t?bw(t):void 0}function xw(e){let t,n,r=!1;try{t=e.container.getInstance(be)?.get(),n=e.container.getInstance(Pe)?.externalSignal;const o=ct(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:Mw(e),dirty:r}}async function Mw(e){try{return await e.getEmailSnapshot()}catch{return}}function Lw(e){const t=ct(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function qs(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Vt(e,n)}async function Nw(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),lw(o)||iw(o))return;const i=()=>xn(t,e,tw(o)),{options:s}=n;if(!s||!qs(t,r)){i();return}const a=await n.email,l=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,c=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:l?{...c,email:l}:s.content}),n.dirty&&l&&Lw(e),qs(t,r)?Te.set(t,e):i()}catch{i()}}async function Fw(e,t){ne(e.signal);const n=new ge;let r,o,i,s,a=0;try{const l=await md(e.element,n,e.signal);l&&(s=l,t.ref.host=l,a=gw(l,t.control,t.mode,e));const c=aw({hostElementOption:e.element,resolvedElement:l,externalSignal:e.signal,disposable:n}),d=dw(l,{supersede:t.mode==="single"});r=d.release;const m=po(c,d.signal);ne(m),i=uw(l),Ac(l,e),await En(d.previous,m),o=Bw(e,l,t,m,i);const b=await En(o,m);return l&&e.content!==void 0&&Rc(l,e.content),b}catch(l){throw s&&i&&vw(s,a)&&i(),l}finally{const l=r;o!==void 0&&l?o.then(l,l):l?.(),n.dispose()}}async function Gs(e,t,n,r){const o=Ew(t);n===void 0||r||!o||xe(n,o.value)||await e.show(n)}async function Bw(e,t,n,r,o){const{control:i}=n,s=C=>i.bind(C);ne(r);let a;const l=C=>{K_();const y=Z_(Iw(C,t)),S=z_(y,()=>a);return{preparedOptions:S,preparedOptionsWithSignal:r!=null?{...S,signal:r}:S}};let c;if(t){const C=Te.get(t);if(C){let y;try{y=await C,ne(r)}catch{ne(r),yn(t,C),y=void 0}if(y)if(y.getElement()===t){const S=C_(t);a=S;const A=y.container.getInstance(be)?.get();if(fw(t,e,A))return s(y),r&&y.container.getInstance(Pe)?.relinkExternalSignal(r),Te.set(t,y),await Gs(y,t,e.content,!1),y;const B=!xe(e.content,A?.content);c=l(lo(t,e));const{preparedOptions:k,preparedOptionsWithSignal:P}=c,T=S&&H_(S),x=xw(y);try{S&&Pr(S,k),s(y);const R=await y.reset(Aw(e,P));return ne(r),Te.set(t,y),await Gs(y,t,e.content,B),R}catch(R){if(S&&T&&Pr(S,T),!Yd(R))throw o(),await Nw(y,t,x,n,R),R;yn(t,C,y),kn(y),ne(r)}}else yn(t,C,y),kn(y)}}ne(r),c??=l(lo(t,e,{fresh:!0}));const{preparedOptions:d}=c,m=Cw(d),b=Tw(d),v=r!=null?{...b.options,signal:r}:b.options;let w;try{a=R_(v),T_(t,a),Pr(a,d),Ko(a).set(v),await Yo(),ie(me.coreReady),ne(r),ne(r),w=I_(v,a,{onInstance:s}),t&&Te.set(t,w);const C=await w;if(r?.aborted&&(C.destroy(),ne(r)),t)if(Te.get(t)===w)Te.set(t,C);else throw C.destroy(),ne(r),_e(r?.reason);return C}catch(C){throw m(),b.cleanup(),a&&(yc(a),A_(t,a)),t&&w&&Te.get(t)===w&&Te.delete(t),C}}async function sS(e){return(await Zt()).parseAMP(e)}typeof window<"u"&&(Ft()&&Wd(),iE(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0));export{Cc as ELEMENT_DETACHED_ABORT_MESSAGE,Tc as SUPERSEDED_INIT_ABORT_MESSAGE,kw as create,eS as errors,iS as getInstance,tS as helpers,oS as init,iw as isElementDetachedError,lw as isSupersededInitError,sS as parseAMP,aE as pluginRegistry,rS as preload,nS as version};
1078
1078
 
1079
1079
 
1080
- window.__emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/15ea858c.js":[],"static/core/1922419a.js":[],"static/core/253d6f68.js":["static/core/d0d2525d.js","__delivery__/libs"],"static/core/32a14159.js":[],"static/core/370f04c3.js":[],"static/core/3a876cdd.js":[],"static/core/40574d12.js":[],"static/core/43a8b244.js":[],"static/core/4797d4f7.js":[],"static/core/4f63baad.js":["static/core/370f04c3.js","__delivery__/libs","monaco"],"static/core/4fef179c.js":["static/core/85accd9c.js"],"static/core/5e13bbc1.js":["static/core/3a876cdd.js"],"static/core/6319e32c.js":[],"static/core/66a5de32.js":[],"static/core/6933d533.js":[],"static/core/69842511.js":["static/core/d0d2525d.js","static/core/253d6f68.js","static/core/aea50cd5.js","static/core/cd715a88.js","__delivery__/libs"],"static/core/7452d34b.js":[],"static/core/76d1f317.js":[],"static/core/7a9faff8.js":[],"static/core/85accd9c.js":[],"static/core/86e5503b.js":["static/core/d0d2525d.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/89fb48c9.js":[],"static/core/8a5b1c18.js":[],"static/core/8bf56b5b.js":[],"static/core/8fdd9471.js":["static/core/85accd9c.js"],"static/core/9f6b8cdd.js":[],"static/core/9f7f5230.js":["static/core/e6f6edff.js"],"static/core/a6518f19.js":[],"static/core/a8cb6e27.js":[],"static/core/a9d62c49.js":[],"static/core/aea50cd5.js":["static/core/d0d2525d.js","__delivery__/libs"],"static/core/bb58b8a1.js":["static/core/c266ad76.js","__delivery__/libs"],"static/core/c266ad76.js":["__delivery__/libs"],"static/core/cd715a88.js":["static/core/bb58b8a1.js","__delivery__/libs"],"static/core/d0b845c8.js":[],"static/core/d0d2525d.js":["static/core/a8cb6e27.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/d402573d.js":["static/core/3a876cdd.js","static/core/85accd9c.js","static/core/4fef179c.js"],"static/core/e2694475.js":["static/core/253d6f68.js","static/core/bb58b8a1.js","__delivery__/libs","static/core/d0d2525d.js"],"static/core/e6f6edff.js":[],"static/core/e8edbf21.js":["static/core/c266ad76.js","__delivery__/libs"],"static/core/f85176c7.js":[],"static/core/fa6f5198.js":[],"static/monaco/editor.api-DqgksfDR.js":[],"monaco":["static/monaco/editor.api-DqgksfDR.js","static/monaco/lspLanguageFeatures-BnvITcKb.js"],"static/monaco/lspLanguageFeatures-BnvITcKb.js":["static/monaco/editor.api-DqgksfDR.js"],"compat-globals.js":["static/esm/971f1b2c.js"],"emailmaker-esm.js":["static/esm/971f1b2c.js","static/esm/74f083c2.js","static/esm/f76c9d9d.js"],"static/esm/delivery-libs.js":[],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/74f083c2.js":[],"static/esm/971f1b2c.js":[],"static/esm/f76c9d9d.js":[]},"bundles":{"static/core/bb58b8a1.js":["static/core/bb03ea6d.js","static/core/29af64b8.js","static/core/bc15a359.js"],"static/core/5e13bbc1.js":["static/core/a54d9b28.js"],"static/core/86e5503b.js":["static/core/be880f91.js"],"static/core/cd715a88.js":["static/core/61378c9e.js"],"static/core/e2694475.js":["static/core/66a13e30.js"],"core":["static/core/5dc34752.js","static/core/ee980948.js","static/core/5c3dd765.js","static/core/21b044e5.js","static/core/f6b71452.js"]}});
1080
+ window.__emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/0c2b284d.js":["__delivery__/libs"],"static/core/15ea858c.js":[],"static/core/1708db7c.js":[],"static/core/1922419a.js":[],"static/core/1c5fcd3e.js":[],"static/core/1d705ef4.js":[],"static/core/2f2b6a03.js":["static/core/c16f27f8.js","static/core/a4d994c7.js","__delivery__/libs","static/core/e123b734.js"],"static/core/32a14159.js":[],"static/core/370f04c3.js":[],"static/core/43a8b244.js":[],"static/core/44ad0bec.js":[],"static/core/462ebf44.js":[],"static/core/4797d4f7.js":[],"static/core/5b124cab.js":["static/core/e123b734.js","__delivery__/libs"],"static/core/5c396b20.js":["static/core/64c240c3.js"],"static/core/64c240c3.js":[],"static/core/6933d533.js":[],"static/core/6dfc3524.js":["static/core/9c4c7364.js","static/core/64c240c3.js","static/core/762d0d48.js"],"static/core/7452d34b.js":[],"static/core/762d0d48.js":["static/core/64c240c3.js"],"static/core/76d1e927.js":[],"static/core/76d1f317.js":[],"static/core/7c519fb4.js":["static/core/9c4c7364.js"],"static/core/8608a2b9.js":["static/core/e123b734.js","static/core/c16f27f8.js","static/core/5b124cab.js","static/core/892bb74e.js","__delivery__/libs"],"static/core/892bb74e.js":["static/core/a4d994c7.js","__delivery__/libs"],"static/core/8a5b1c18.js":[],"static/core/8bf56b5b.js":[],"static/core/9c4c7364.js":[],"static/core/9f7f5230.js":["static/core/e6f6edff.js"],"static/core/a30b0fae.js":["static/core/e123b734.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/a4d994c7.js":["static/core/0c2b284d.js","__delivery__/libs"],"static/core/a8cb6e27.js":[],"static/core/aa75c19b.js":["static/core/0c2b284d.js","__delivery__/libs"],"static/core/b0c57adf.js":[],"static/core/b9f59067.js":[],"static/core/c16f27f8.js":["static/core/e123b734.js","__delivery__/libs"],"static/core/cd998f60.js":["static/core/370f04c3.js","__delivery__/libs","monaco"],"static/core/d0b845c8.js":[],"static/core/e123b734.js":["static/core/a8cb6e27.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/e6f6edff.js":[],"static/core/e70683db.js":[],"static/core/ec552634.js":[],"static/monaco/editor.api-DqgksfDR.js":[],"monaco":["static/monaco/editor.api-DqgksfDR.js","static/monaco/lspLanguageFeatures-BnvITcKb.js"],"static/monaco/lspLanguageFeatures-BnvITcKb.js":["static/monaco/editor.api-DqgksfDR.js"],"compat-globals.js":["static/esm/971f1b2c.js"],"emailmaker-esm.js":["static/esm/971f1b2c.js","static/esm/74f083c2.js","static/esm/f76c9d9d.js"],"static/esm/delivery-libs.js":[],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/74f083c2.js":[],"static/esm/971f1b2c.js":[],"static/esm/f76c9d9d.js":[]},"bundles":{"static/core/a4d994c7.js":["static/core/66cfac3d.js","static/core/86f3e5f8.js","static/core/a6f666b3.js"],"static/core/7c519fb4.js":["static/core/a54d9b28.js"],"static/core/a30b0fae.js":["static/core/be880f91.js"],"static/core/892bb74e.js":["static/core/61378c9e.js"],"static/core/2f2b6a03.js":["static/core/2ffe45f5.js"],"core":["static/core/5dc34752.js","static/core/ee980948.js","static/core/dd7229b2.js","static/core/b0a1816d.js","static/core/52afb633.js"]}});