useblocks 1.1.85-dev.7 → 1.1.85-dev.8

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 (79) hide show
  1. package/README.md +6 -4
  2. package/iframe/.vite/manifest.json +4 -4
  3. package/iframe/js/{discussHandlers.C5qc-xPl.js → discussHandlers.BuuVtU3Y.js} +5 -5
  4. package/iframe/js/iframe-eblock.body.js +1 -1
  5. package/iframe/js/iframe-eblock.js +1 -1
  6. package/iframe/js/iframe.body.js +2 -2
  7. package/iframe/js/iframe.js +1 -1
  8. package/node_modules/useblocks-ui-kit/es/components/Custom/FormPanel/FormSection/index.js +1 -1
  9. package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/ColorPickerInput/index.js +1 -1
  10. package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/ControlFontFamily/index.js +1 -1
  11. package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/InputSelect/index.js +34 -31
  12. package/node_modules/useblocks-ui-kit/es/components/Custom/PanelForm/index.js +1 -1
  13. package/node_modules/useblocks-ui-kit/es/components/DataDisplay/Card/index.js +1 -1
  14. package/node_modules/useblocks-ui-kit/es/components/DataDisplay/Skeleton/index.js +1 -1
  15. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Cascader/index.js +1 -1
  16. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Checkbox/index.js +1 -1
  17. package/node_modules/useblocks-ui-kit/es/components/DataEntry/ColorPicker/index.js +1 -1
  18. package/node_modules/useblocks-ui-kit/es/components/DataEntry/DatePicker/index.js +1 -1
  19. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Form/index.js +1 -1
  20. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Input/index.js +1 -1
  21. package/node_modules/useblocks-ui-kit/es/components/DataEntry/InputNumber/index.js +1 -1
  22. package/node_modules/useblocks-ui-kit/es/components/DataEntry/InputOTP/index.js +1 -1
  23. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Password/index.js +1 -1
  24. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Radio/index.js +1 -1
  25. package/node_modules/useblocks-ui-kit/es/components/DataEntry/SearchInput/index.js +1 -1
  26. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Switch/index.js +2 -2
  27. package/node_modules/useblocks-ui-kit/es/components/DataEntry/TextArea/index.js +1 -1
  28. package/node_modules/useblocks-ui-kit/es/components/Feedback/Alert/index.js +1 -1
  29. package/node_modules/useblocks-ui-kit/es/components/Feedback/Popconfirm/index.js +1 -1
  30. package/node_modules/useblocks-ui-kit/es/components/Feedback/Spin/index.js +1 -1
  31. package/node_modules/useblocks-ui-kit/es/components/Feedback/Tooltip/index.js +1 -1
  32. package/node_modules/useblocks-ui-kit/es/components/General/Button/index.js +1 -1
  33. package/node_modules/useblocks-ui-kit/es/components/Layout/Divider/index.js +1 -1
  34. package/node_modules/useblocks-ui-kit/es/components/Layout/Row/index.js +1 -1
  35. package/node_modules/useblocks-ui-kit/es/components/Layout/Space/index.js +1 -1
  36. package/node_modules/useblocks-ui-kit/es/components/Navigation/FloatButton/index.js +1 -1
  37. package/node_modules/useblocks-ui-kit/es/components/Navigation/Segmented/index.js +1 -1
  38. package/node_modules/useblocks-ui-kit/es/components/Navigation/Tabs/index.js +1 -1
  39. package/node_modules/useblocks-ui-kit/package.json +1 -1
  40. package/package.json +2 -2
  41. package/runtime/react/index.js +1 -1
  42. package/static/core/{b49f995f.js → 06d19668.js} +3 -3
  43. package/static/core/{51a46897.js → 13c7b13a.js} +1 -1
  44. package/static/core/{fdfb1e94.js → 1afe0f9c.js} +1 -1
  45. package/static/core/{8035d07f.js → 28160edc.js} +1 -1
  46. package/static/core/{6a939bac.js → 3d7934fb.js} +1 -1
  47. package/static/core/{53bcd609.js → 3df10afa.js} +8 -8
  48. package/static/core/{e2699a48.js → 41028939.js} +1 -1
  49. package/static/core/{7f91ed03.js → 45eb9af1.js} +1 -1
  50. package/static/core/{60f7aa8d.js → 48a8ba9d.js} +1 -1
  51. package/static/core/{740a4f32.js → 49a8dc9c.js} +1 -1
  52. package/static/core/{284b592e.js → 59cfe4a0.js} +1 -1
  53. package/static/core/{ec4827f1.js → 778aee63.js} +1 -1
  54. package/static/core/{c28968c1.js → 799f4d8e.js} +1 -1
  55. package/static/core/{77d63e01.js → 7c047ede.js} +1 -1
  56. package/static/core/{9ea82ab5.js → 982730aa.js} +1 -1
  57. package/static/core/{23f020c5.js → a46eae76.js} +1 -1
  58. package/static/core/{fc390885.js → b165db74.js} +1 -1
  59. package/static/core/{991b35ff.js → cb42ad65.js} +1 -1
  60. package/static/core/{7d627bff.js → db82c42b.js} +1 -1
  61. package/static/core/{1bdeb37f.js → df189a9d.js} +1 -1
  62. package/static/core/{74c1d64b.js → f1478faf.js} +1 -1
  63. package/static/core/{6ff64eea.js → f1498d3c.js} +1 -1
  64. package/static/core/{ea93d0cd.js → f8d889a1.js} +2 -2
  65. package/static/core/{78b1e678.js → fa60c7fb.js} +1 -1
  66. package/static/core/{d2bb1c0d.js → ff43365e.js} +1 -1
  67. package/static/esm/349f9e2c.js +1 -0
  68. package/static/umd-runtime/runtime.js +1 -1
  69. package/static/umd-runtime/ui-kit.js +2 -2
  70. package/{useblocks-core.46f9d75a.js → useblocks-core.ee20cf1c.js} +15 -15
  71. package/useblocks-esm.js +10 -10
  72. package/{useblocks-po.46f9d75a.js → useblocks-po.ee20cf1c.js} +1 -1
  73. package/useblocks.d.ts +9 -2
  74. package/useblocks.js +12 -12
  75. package/vite/index.cjs +38 -0
  76. package/vite/index.js +38 -0
  77. package/static/esm/ff1698e6.js +0 -1
  78. /package/iframe/{iframe-eblock.46f9d75a.html → iframe-eblock.ee20cf1c.html} +0 -0
  79. /package/iframe/{iframe.46f9d75a.html → iframe.ee20cf1c.html} +0 -0
package/useblocks-esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import{t as si}from"./static/esm/50fbfdf6.js";import{$ as Jo,A as Qo,At as le,B as Zo,C as es,Ct as ts,D as ns,Dt as rs,E as is,Et as $,F as Ye,G as ai,H as Xe,I as os,J as ss,K as as,L as ls,M as ds,Mt as cs,N as et,Nt as Z,O as li,Ot as pt,P as us,Q as di,R as fs,S as ps,St as hs,T as ms,Tt as ht,V as Wn,W as gs,X as vs,Y as ci,Z as Pe,_ as mt,_t as pe,a as bs,at as oe,b as ys,bt as Es,c as _s,ct as ws,d as Et,dt as Ss,et as we,f as Is,ft as Ts,g as ui,gt as Ce,h as As,ht as wn,i as Cs,it as fi,j as Rs,jt as Ps,k as Ds,kt as L,l as N,lt as Os,m as Sn,mt as In,n as xs,nt as De,o as Me,ot as Zt,p as Ls,pt as j,q as Tn,r as Ms,rt as _t,s as ks,st as he,t as ce,tt as F,u as Ns,ut as Yn,v as Fs,vt as js,w as An,wt as Q,x as Xn,xt as Jn,y as Bs,yt as en,z as Te}from"./static/esm/ff1698e6.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var h=(function(){if(typeof document<"u"&&document.querySelector)try{var _=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(_&&_.src)return _.src.substring(0,_.src.lastIndexOf("/")+1)}catch{}try{var T=import.meta.url;if(T)return T.substring(0,T.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var c=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(c)||c.indexOf("//")===0)return c.charAt(c.length-1)==="/"?c:c+"/";var a=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",p=a?new URL(c,a).href:c;return p.charAt(p.length-1)==="/"?p:p+"/"}catch{var m=String(h);return m.charAt(m.length-1)==="/"?m:m+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var c=h==null?"":String(h);c||(c="./");try{var a=String(c);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a)||a.indexOf("//")===0)return a.charAt(a.length-1)==="/"?a:a+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",m=p?new URL(a,p).href:a;return m.charAt(m.length-1)==="/"?m:m+"/"}catch{var _=String(c);return _.charAt(_.length-1)==="/"?_:_+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var c="";try{if(typeof window<"u"){for(var a in window)if(!(a==="__useblocks__"||!/^__[^_].*__$/.test(a))){var p;try{p=window[a]}catch{continue}if(p&&typeof p=="object"&&p.publicPath){c=" Another product namespace ("+a+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function c(D){try{var R=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return R?new URL(String(D||""),R).href:String(D||"")}catch{return String(D||"")}}var a=String(h||"");if(!a)return"";if(/^(?:data:|blob:)/.test(a))return a;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a)||a.indexOf("//")===0||a.charAt(0)==="/")return c(a);var p=a.replace(/^\.\/+/,"").replace(/^\/+/,""),m="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),_=m&&p.indexOf(m+"/")!==0?m+"/"+p:p,T=e.publicPath||"./";try{return new URL(_,T).href}catch{return T.slice(-1)!=="/"&&(T+="/"),c(T+_)}}),e.version||(e.version="1.1.85-dev.7");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
1
+ import{t as fi}from"./static/esm/50fbfdf6.js";import{$ as os,A as ss,At as L,B as as,C as ls,Ct as ds,D as cs,Dt as $,E as us,Et as pt,F as Ye,G as pi,H as Xe,I as fs,J as ps,K as hs,L as ms,M as gs,Mt as vs,N as tt,Nt as bs,O as hi,Ot as Es,P as ys,Pt as ee,Q as mi,R as _s,S as ws,St as Ss,T as Is,Tt as An,V as er,W as Ts,X as As,Y as gi,Z as Pe,_ as ht,_t as pe,a as Cs,at as se,b as Rs,bt as Ps,c as Ds,ct as Os,d as yt,dt as xs,et as we,f as Ls,ft as Ms,g as vi,gt as Ce,h as ks,ht as Cn,i as Ns,it as bi,j as Fs,jt as ce,k as js,kt as mt,l as F,lt as Bs,m as Rn,mt as Pn,n as Us,nt as De,o as Le,ot as tn,p as Hs,pt as B,q as Dn,r as Gs,rt as _t,s as qs,st as he,t as le,tt as j,u as $s,ut as tr,v as zs,vt as Vs,w as On,wt as Z,x as nr,xt as rr,y as Ks,yt as nn,z as Te}from"./static/esm/349f9e2c.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var h=(function(){if(typeof document<"u"&&document.querySelector)try{var w=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(w&&w.src)return w.src.substring(0,w.src.lastIndexOf("/")+1)}catch{}try{var T=import.meta.url;if(T)return T.substring(0,T.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var c=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(c)||c.indexOf("//")===0)return c.charAt(c.length-1)==="/"?c:c+"/";var l=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",p=l?new URL(c,l).href:c;return p.charAt(p.length-1)==="/"?p:p+"/"}catch{var m=String(h);return m.charAt(m.length-1)==="/"?m:m+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var c=h==null?"":String(h);c||(c="./");try{var l=String(c);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(l)||l.indexOf("//")===0)return l.charAt(l.length-1)==="/"?l:l+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",m=p?new URL(l,p).href:l;return m.charAt(m.length-1)==="/"?m:m+"/"}catch{var w=String(c);return w.charAt(w.length-1)==="/"?w:w+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var c="";try{if(typeof window<"u"){for(var l in window)if(!(l==="__useblocks__"||!/^__[^_].*__$/.test(l))){var p;try{p=window[l]}catch{continue}if(p&&typeof p=="object"&&p.publicPath){c=" Another product namespace ("+l+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function c(O){try{var k=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return k?new URL(String(O||""),k).href:String(O||"")}catch{return String(O||"")}}var l=String(h||"");if(!l)return"";if(/^(?:data:|blob:)/.test(l))return l;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(l)||l.indexOf("//")===0||l.charAt(0)==="/")return c(l);var p=l.replace(/^\.\/+/,"").replace(/^\/+/,""),m="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),w=m&&p.indexOf(m+"/")!==0?m+"/"+p:p,T=e.publicPath||"./";try{return new URL(w,T).href}catch{return T.slice(-1)!=="/"&&(T+="/"),c(T+w)}}),e.version||(e.version="1.1.85-dev.8");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,14 +993,14 @@ import{t as si}from"./static/esm/50fbfdf6.js";import{$ as Jo,A as Qo,At as le,B
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:"useblocks-core.46f9d75a.js",po:"useblocks-po.46f9d75a.js",monaco:"static/monaco/index.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(h){var c,a=function(){return c||(c=Promise.resolve().then(h))};return{then:function(p,m){return a().then(p,m)},catch:function(p){return a().catch(p)},finally:function(p){return a().finally(p)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=i(function(){return o.then(function(h){return h.React})}),t.ReactDom=i(function(){return o.then(function(h){return h.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(h){return h.Classnames})}),t.Dayjs=i(function(){return o.then(function(h){return h.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(h){var c=h[0]||Object.create(null),a=Object.create(null);for(var p in c)Object.prototype.hasOwnProperty.call(c,p)&&(a[p]=c[p]);for(var m in a)Object.prototype.hasOwnProperty.call(a,m)&&(t[m]=a[m]);return a})}),d={},l={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/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 'useblocks/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."},f={Antd:"[runtime] `antd` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",AntDesignIcons:"[runtime] `@ant-design/icons` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated."},u=Object.create(null);if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var c in h)Object.prototype.hasOwnProperty.call(h,c)&&(u[c]=h[c])},e.__compatPending){for(var v=0;v<e.__compatPending.length;v+=1)e.registerCompat(e.__compatPending[v]);e.__compatPending=void 0}for(var b in l)Object.prototype.hasOwnProperty.call(l,b)&&(function(h,c,a){var p=!1,m=function(){if(!(h in u))throw new Error(c);return u[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var _=m();return p||(p=!0),_},set:function(_){u[h]=_}}),Object.defineProperty(d,h,{configurable:!0,enumerable:!0,get:m,set:function(_){u[h]=_}})})(b,l[b],f[b]);var y=t;for(var I in d)Object.prototype.hasOwnProperty.call(d,I)&&(y===t&&(y=Object.create(t)),Object.defineProperty(y,I,Object.getOwnPropertyDescriptor(d,I)));var g=s,E=[],w=function(){for(var h=[],c=0;c<E.length;c+=1)(function(a){var p=t[a];p&&typeof p.then=="function"&&h.push(Promise.resolve(p).then(function(m){t[a]=m}))})(E[c]);return Promise.all(h)},S=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(w).then(function(){if(typeof S=="function")return S.call(e)})},typeof e.define=="function"){let h=function(c){if(!c||typeof c!="object"&&typeof c!="function"||c.__esModule)return c;if(A){var a=A.get(c);if(a)return a}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var m=Reflect.ownKeys(c),_=0;_<m.length;_++){var T=m[_];if(T!=="__esModule"){var D=Object.getOwnPropertyDescriptor(c,T);D&&Object.defineProperty(p,T,D)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:c,writable:!1}),A&&A.set(c,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var c=y.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.React;return h(p)})}),e.define("useblocks/runtime/react",[],function(){var c=y.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.React;return h(p)})}),e.define("react-dom",[],function(){var c=y.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("useblocks/runtime/react-dom",[],function(){var c=y.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("react-dom/client",[],function(){var c=y.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var c=y.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("react/jsx-runtime",[],function(){var c=y.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var c=y.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("react/jsx-dev-runtime",[],function(){var c=y.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var c=y.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("antd",[],function(){var c=y.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Antd;return h(p)})}),e.define("useblocks/runtime/antd",[],function(){var c=y.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Antd;return h(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var c=y.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var c=y.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("@ant-design/icons",[],function(){var c=y.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var c=y.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("@ant-design/cssinjs",[],function(){var c=y.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var c=y.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("classnames",[],function(){var c=y.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Classnames;return h(p)})}),e.define("useblocks/runtime/classnames",[],function(){var c=y.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Classnames;return h(p)})}),e.define("dayjs",[],function(){var c=y.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks/runtime/dayjs",[],function(){var c=y.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks-ui-kit",[],function(){var c=y.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit",[],function(){var c=y.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit/icons",[],function(){var c=y.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKitIcons;return h(p)})}),e.define("useblocks-ui-kit/icons",[],function(){var c=y.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKitIcons;return h(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Us=new Function("url","return import(url)");function Hs(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Gs(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function qs(e){return e.type==="umd"||e.resolve==="registry"}var $s=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(Gs(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(qs(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Us(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,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}initSync(e){const t=[];for(const n of e){const r=this._getOrCreate(n,void 0);t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const{ctor:i,options:o}=await this._resolveEntry(r),s=this._getOrCreate(i,o);n.has(s)||(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const d=await this._resolveEntry(s);t.add(d.ctor),n.push(d)}const r=[];this._map.forEach((s,d)=>{t.has(d)||r.push({key:d,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:d,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(d),this._optionsMap.delete(d),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const f=this._creationOrder.indexOf(l);f>=0&&this._creationOrder.splice(f,1)}const i=[],o=new Set;for(const{ctor:s,options:d}of n){const l=this._getOrCreate(s,d);o.has(l)||(o.add(l),i.push(l))}this._activated&&await this._startPluginsBatch(i)}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,i)=>{let o,s=!1;const d=()=>{s||(s=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,d),r())};this._pluginRegistry.on(e,d),n!==void 0&&n>0&&(o=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,d),i(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),i=this._createPluginInstance(e,r),o=i.constructor.name;this._emitLifecycle({type:"created",plugin:i,name:o}),i.required?.(),this._map.set(n,i),this._creationOrder.push(i),this._setupReadyPromise(i)}return this._map.get(n)}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);try{return Hs(e)?new e(this._context,t):e(this._context,t)||{}}finally{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 i of t){if(this._initializedPlugins.has(i))continue;const o=this._initializingPlugins.get(i);if(o){n.add(o);continue}r.push(i)}if(r.length>0){const i=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,i);n.add(i),i.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===i&&this._initializingPlugins.delete(o)})}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});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})}}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(i){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:i})}}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)}))}},zs=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 i of n)try{i.callback(t)}catch{}const r=n.filter(i=>!i.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(i=>(t.ctor=i,t.loading=void 0,this._notifyListeners(e,i),i));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 i={callback:t,once:!1};return r.push(i),{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 i={callback:t,once:!0};return r.push(i),{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(i=>i.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)}}}},Vs=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()}},Qn=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 Ks(e,t){return t+e}function Ws(){return typeof performance>"u"?Date.now():Ks(performance.now(),performance.timeOrigin)}var Ys="emailmaker:diagnostics",Xs="diagnostics",Js="diagnostics";function Zn(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Js}=1`:e}var Rt;function Qs(){try{const e=new URLSearchParams(window.location.search).get(Xs);return e===null?void 0:e!=="0"}catch{return}}function Zs(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function ea(){try{const e=window.localStorage.getItem(Ys);return e===null?void 0:e==="1"}catch{return}}function $e(){return Rt===void 0&&(Rt=typeof window>"u"?!1:Qs()??Zs()??ea()??!1),Rt}function ta(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var J={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"},Im=Object.values(J),Tm=[J.canvasPainted,J.canvasSettled,J.appVisible,J.editorVisible],na=5e3,ra=3e3,er="diagnosticsStore",tt,Fe;function tr(){return{marks:new Qn(na),resources:new Qn(ra)}}function pi(){if(Fe)return Fe;const e=Cn();return e?(Fe=e[er]??tt??tr(),e[er]=Fe,tt=void 0,Fe):(tt??=tr(),tt)}function z(e,t){$e()&&pi().marks.push({phase:e,at:Ws(),...t})}function Cn(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[ta()];return e!==null&&typeof e=="object"?e:void 0}function ia(e){const t=e.length,n=pi();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function oa(){const e=Cn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:ia(e.diagnosticsBuffer)}var sa="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Rn(){const e=new Error(sa);return e.name="DestroyedInstanceError",e}function tn(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 o=e,s=t;return o.length===s.length&&o.every((d,l)=>tn(d,s[l]))}const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&tn(e[o],t[o]))}function hi(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const d=t(s);o&&tn(i,d)||(i=d,o=!0,r(d))})},select(r){return hi(n,r)}};return n}function ke(...e){let t=e[0],n=e.length>0;const r=new Set,i={get(){return n?t:void 0},set(o){t=o,n=!0;for(const s of Array.from(r))s(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return hi(i,o)}};return i}var mi=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:vs.UrlEncoded,...t})},gi=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 aa(e){return String(e||"").trim()||void 0}var la=class extends Z{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=aa(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)}},Pn=L("AppInitService");function da(e){return async()=>{const t=await e();return(await new mi(t).app_init_create({})).data}}function ca(e){e.injectFactory(Pn,()=>{const t=new la({options:e.getInstance(oe),isStandalone:()=>!!e.getInstance(he),resolveRestBaseUrl:n=>n?Xn(n):Xn()||void 0,setRestBaseUrl:n=>{e.getInstance(Fs)?.setOptions(n?{baseUrl:n}:{})},fallbackAppInit:da(()=>e.getInstanceAsync(ss)),publish:n=>{e.inject(Pe,n)}});return e.getInstance(F)?.addDisposable(t),t},!0)}var Dn=L("documentSession.emailDocuments");function Pt(e){return e?.getInstance(Dn)}var ua=L("RevisionServiceFlag");function fa(e){return e.getOrCreateInstance(ua,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function vi(e){return fa(e).isEnabled()}var pa=L("EmailRightsResolver");function ha(e,t){const n=e.getInstance(pa);return n?n(t):!0}var bi=L("EmailHistoryAvailabilityResolver");function ma(e){return e.getInstance(bi)!==void 0}async function ga(e){const t=e.getInstance(bi);if(!t)return!0;try{return await t()}catch{return!1}}var On={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},yi=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Ei=2e4,va=yi.reduce((e,t)=>e+On[t],0),_i=Ei+va+3e3;function ba(e){return yi.reduce((t,n)=>t+wi(n,e),0)}function wi(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:On[e]}function Si(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:_i}function Ii(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Ei}function Ti(e=_i){return e+3e3}var ya=()=>Ti();function Ea(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function _a(e){return t=>Ea(e.getOrCreateInstance(j.BEFORE_SAVE_EMAIL,()=>new pe).fire(t),ya())}function wa(e){return e!=null&&e!==""}var Sa;function wt(e,t){return Sa?.capture(e,t)}function Ia(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function nt(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} "${nt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${nt(this.oldText)}")`:`(replace@${this.oldPosition} "${nt(this.oldText)}" with "${nt(this.newText)}")`}};function nr(e,t){return e===null||e.length===0?t:new Ta(e,t).compress()}var Ta=class se{_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),i=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(i===null)break;this._acceptCurr(i),i=this._getCurr(++n);continue}if(i===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldEnd<=r.newPosition){this._acceptCurr(i),i=this._getCurr(++n);continue}if(r.newEnd<=i.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldPosition<r.newPosition){const[l,f]=se._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(l),i=f;continue}if(r.newPosition<i.oldPosition){const[l,f]=se._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(l),r=f;continue}let s,d;if(i.oldEnd===r.newEnd)s=r,d=i,r=this._getPrev(++t),i=this._getCurr(++n);else if(i.oldEnd<r.newEnd){const[l,f]=se._splitPrev(r,i.oldLength);s=l,d=i,r=f,i=this._getCurr(++n)}else{const[l,f]=se._splitCurr(i,r.newLength);s=r,d=l,r=this._getPrev(++t),i=f}this._result[this._resultLen++]=new re(s.oldPosition,s.oldText,d.newPosition,d.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=d.newLength-d.oldLength}const o=se._merge(this._result);return se._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=se._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++]=se._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),i=t.newText.substr(n);return[new re(t.oldPosition,t.oldText,t.newPosition,r),new re(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new re(t.oldPosition,r,t.newPosition,t.newText),new re(t.oldPosition+n,i,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,i=t[0];for(let o=1;o<t.length;o++){const s=t[o];i.oldEnd===s.oldPosition?i=new re(i.oldPosition,i.oldText+s.oldText,i.newPosition,i.newText+s.newText):(n[r++]=i,i=s)}return n[r++]=i,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o.oldText!==o.newText&&(n[r++]=o)}return n}};function Aa(e){return new re(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Ca(e){return e.map(Aa)}function rr(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Ra(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const i=t[r];n=n.slice(0,i.oldPosition)+i.newText+n.slice(i.oldEnd)}return n}function Pa(e,t,n){let r=0;const i=e.start===e.end;for(const o of t){const s=o.newLength-o.oldLength;if(o.oldLength===0){const d=o.oldPosition;if(i&&d===e.start)r+=n==="after"?s:0;else{if(e.start<d&&d<e.end)return null;d<=e.start&&(r+=s)}continue}if(i){if(e.start>=o.oldEnd)r+=s;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=s;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var gt=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},ir=0,Da=Math.random().toString(36).slice(2,8);function Oa(){return ir+=1,`doc-${Da}-${ir}`}function xa(e){const t=e.createBuffer(),n=e.docId??Oa();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const d=new Set;let l=!1,f=!1,u;const v=new Set;let b=null;const y=()=>(b?.version!==i&&(b={version:i,value:t.read()}),b.value),I=g=>Object.entries(g).some(([E,w])=>s[E]!==w);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:y,mutate(g,{source:E}){if(l)return i;const w=g.changes?.length?g.changes:void 0,S=w?Ra(y(),w):g.content!==void 0?g.content:void 0,A=S!==void 0&&S!==y(),h=g.attributes!==void 0&&I(g.attributes);if(!A&&!h)return i;const c=!(i>(o??-1));return A&&t.write(S),h&&(s={...s,...g.attributes}),i+=1,E!=="user"&&c&&(o=i),d.forEach(a=>a({source:E,version:i,changes:w})),i},markSaved(g,E){const w={serverId:r,savedVersion:o};E!==void 0&&(r=E),(o===null||g>o)&&(o=g),(w.serverId!==r||w.savedVersion!==o)&&d.forEach(S=>S({source:"system",version:i}))},markReady(){f||u!==void 0||(f=!0,v.forEach(g=>g.resolve()),v.clear(),d.forEach(g=>g({source:"system",version:i})))},isReady:()=>f,markFailed(g){f||u!==void 0||l||(u=g,v.forEach(E=>E.reject(new gt(g))),v.clear(),d.forEach(E=>E({source:"system",version:i})))},failure:()=>u,whenReady(){return f?Promise.resolve():u!==void 0?Promise.reject(new gt(u)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((g,E)=>{v.add({resolve:g,reject:E})})},subscribe(g){return d.add(g),()=>d.delete(g)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>l,dispose(){l=!0,v.forEach(g=>g.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),v.clear(),d.clear(),t.dispose()}}}var La=500,Ma=100,Dt=0;function ka(e,t={}){const n=t.groupIntervalMs??La,r=t.maxSteps??Ma,i=t.now??(()=>0);let o=[],s=0,d=Dt+=1,l=null,f=!1,u=!1,v=!1;const b=new Set,y=()=>b.forEach(a=>a()),I=(a,p)=>{if(a.length){u=!0;try{e.mutate({changes:a},{source:p})}finally{u=!1}}},g=a=>I(a,"user"),E=a=>{const p=i();f&&l!==null&&p-l<n?o[s-1]=nr(o[s-1],a):(o=o.slice(0,s),o.push(a),s=o.length,f=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,d=Dt+=1)),l=p,y()},w=()=>{f=!1,l=null},S=a=>{if(!a.length)return;const p=o.length>s;p&&(o=o.slice(0,s)),s>0&&(o[s-1]=nr(o[s-1],a)),w(),p&&y()},A=e.subscribe(({source:a,changes:p})=>{if(!(v||u||!p?.length)){if(a==="remote"){h();return}if(a!=="user"){S(p);return}E(p)}}),h=()=>{o=[],s=0,w(),d=Dt+=1,y()},c=()=>{if(s===0)return!1;const a=Ca(o[s-1]);return rr(e.getContent(),a)?(g(a),s-=1,w(),!0):(o=o.slice(0,s-1),s=o.length,w(),y(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){c()&&y()},redo(){if(!(s>=o.length)){if(!rr(e.getContent(),o[s])){o=o.slice(0,s),w(),y();return}g(o[s]),s+=1,w(),y()}},clear:h,applyWithoutHistory(a){const p=e.get().version;if(I(a,"system"),e.get().version===p){w();return}S(a)},getPast:a=>o.slice(0,s).reverse().slice(0,a),getFuture:a=>o.slice(s).reverse().slice(0,a),createSnapshot:()=>({stackId:d,index:s}),restoreSnapshot(a){if(a.stackId!==d||a.index>s)return!1;for(;s>a.index;)if(!c())return y(),!1;return y(),!0},subscribe(a){return b.add(a),()=>b.delete(a)},dispose(){v=!0,A(),b.clear(),o=[],s=0}}}var Na=["edit","move","resize","insert"];function Ot(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Fa(e){return typeof e=="string"?e:null}function ja(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Ba(e){return Na.includes(e)?e:null}function Ua(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Fa(t.originId),changeId:Ot(t.changeId),rev:Ot(t.rev),baseRev:Ot(t.baseRev),expected:ja(t.expected),intent:Ba(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var or=class extends Error{reason;constructor(e){super(`сохранение не состоялось: ${e}`),this.name="SaveRefusedError",this.reason=e}},Ai="draft";function je(e){return e==null||e===""?Ai:String(e)}function Ha(e){return e==null||e===""?`${nn}${Ai}`:`${nn}${String(e)}`}var nn="block:";function me(e){return e?.startsWith(nn)===!0}function Be(e){return me(e.sessionKey())?void 0:e.current()}function He(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return z(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(z(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw`${e}`,{error:String(i),...n},i})}function Ci(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Ri(e,{freshSince:t}={}){return!(!e?.slug?.includes("autosave")||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Ga(e,t={}){const n=Ci((e??[]).filter(r=>r?.html?.trim()));return Ri(n,t)?n:null}function qa(e){const t=Date.parse(Ci(e)?.modified??"");return{autosave:Ga(e),...Number.isFinite(t)?{latestAt:t}:{}}}function $a({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Pi=e=>e.replace(/\r\n?/g,`
997
- `),sr=["recovery","plugin","rest"],za=["subject","preheader"];function Va(e){let t={},n;for(let i=sr.length-1;i>=0;i--){const o=e.get(sr[i]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const i of za){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Di(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Pi(t.content):void 0,i=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...i?{changes:[new re(0,n,0,r)]}:{}},{source:"remote"})}var ar=e=>typeof e=="string"?e.trim():"";function Ka(e,t,n){const{version:r,attributes:i}=e.get(),o=i,s=ar(o.title)||ar(o.subject);return{version:r,payload:{html:e.getContent(),title:s,subject:o.subject,preheader:o.preheader,description:o.description,common_styles:o.common_styles||"",meta:o.meta,utm_parameters:o.utm_parameters,parent_email:o.parent_email,is_template:o.is_template||!1,is_inited:o.is_inited,tags:o.tags,emailtags:o.emailtags,group:o.group,renderGuid:e.get().docId,project:t.project??o.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source}}}async function Wa(e,t,n,r,i){if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(i);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,i):t.saveAutosave(r,i)}function ge(e,t=!1){const n={};for(const r of Object.keys(e)){let i=e[r];i!==void 0&&!(typeof i=="number"&&Number.isNaN(i))&&(t&&typeof i=="object"&&i!==null&&(i=ge(i)),n[r]=i)}return n}var Ya=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Oi(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Ya.has(t))):{}}function vt(e,t,n={}){e&&e.mutate({attributes:Xa(e.get().attributes,t)},{source:n.source??"user"})}function Xa(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function xn(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Ja(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function xi(e){if(!e)return null;const t=Oi(e);return e.common_styles!==void 0&&(t.common_styles=Ja(e.common_styles)),xn(e.html,t)}function Li(e){return e?xn(e.html,ge(Oi(e))):null}var Qa=["common_styles","subject","preheader","meta"];function lr(e){if(!e?.html?.trim())return null;const t={};for(const n of Qa)Za(n,e[n])&&(t[n]=e[n]);return xn(e.html,t)}function Za(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 el=10,tl=(e,t)=>e.key===t.key&&nl(e.serverId,t.serverId),nl=(e,t)=>e==null||e===t;function rl(e){return typeof e?.then=="function"}var dr=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Mi=e=>{e.request.serverId!=null&&e.document.markSaved(e.document.get().version)},il=e=>{Di(e.document,Va(e.reports)),Mi(e)},xt=(e,t)=>{if(!e.ready){il(e);return}Di(e.document,t)},ol=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 sl(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:d,onAdapterError:l,onTimeout:f}=e;let u;const v=new Set,b=new Set,y=()=>v.forEach(m=>m()),I=(m,_)=>{if(!(m.closed||m.ready)){if(m.error!==void 0){m.document.markFailed(m.error),m.document.get().docId;return}Mi(m),m.ready=!0,m.document.markReady(),m.document.get().docId,[...m.reports.keys()]}},g=(m,_,T)=>{l?.(_.id,T),!(!_.required||m.closed)&&(m.error=T,m.document.get().docId,_.id,y())},E=(m,_)=>{const T=new Set(_.map(C=>C.id));_.forEach(C=>{C.watch&&m.watchers.push(C.watch(x=>m.closed?!1:m.ready&&x?.content!==void 0&&$a({hasUnsavedUserEdit:m.document.isDirty()})==="skip"?(m.document.get().docId,C.id,!1):(x&&m.reports.set(C.id,x),xt(m,x),!0)))});const D=(C,x)=>{m.closed||(x&&m.reports.set(C.id,x),xt(m,x))},R=()=>{T.size>0||m.closed||(dr(m),I(m,[]))},O=[];if(_.forEach(C=>{let x;try{x=C.load()}catch(B){g(m,C,B),T.delete(C.id);return}if(rl(x)){O.push({id:C.id,required:C.required,load:()=>x});return}D(C,x),T.delete(C.id)}),O.length===0){R();return}m.timer=setTimeout(()=>{m.timer=void 0,f?.([...T]),m.document.get().docId,[...T],I(m,[...T])},n),m.timer.unref?.(),O.forEach(C=>{C.load().then(x=>D(C,x)).catch(x=>{g(m,C,x)}).finally(()=>{T.delete(C.id),R()})})},w=async(m,_,T)=>{if(T==="snapshot"||T==="anchor")return;const D=o?.();if(D)return D.resolve({project:_.project??m.project,tags:(m.tags??[]).map(R=>({name:R}))})},S=m=>{if(m.lock===!0&&s?.(m)===!1)return new or("locked");const _=m.tags?.length??0,T=m.emailtags?.length??0;if(Math.max(_,T)>el)return new or("too-many-tags")},A=async(m,_,T)=>{try{await m.document.whenReady()}catch(x){return m.saveError=x,m.saveFailures+=1,m.saveFailures,!1}if(m.closed)return!1;const D=S(m.document.get().attributes);if(D)return m.saveError=D,m.saveFailures+=1,D.reason,y(),!1;if(d&&(await d(ol(m)).catch(()=>{}),m.closed))return!1;let R;try{R=await w(m.document.get().attributes,T,_)}catch(x){return m.saveError=x,m.saveFailures+=1,m.saveFailures,y(),!1}if(m.closed)return!1;const{payload:O,version:C}=Ka(m.document,T,R);m.document.get().docId;try{const x=m.document.get().serverId!=null,B=await Wa(r(),i(m.request.key),_,m.document.get().serverId,O);if(m.closed)return!0;let U;if(_==="snapshot"||_==="anchor"){const M=B?.modified!=null?Date.parse(B.modified):NaN;U=Number.isFinite(M)?M:Date.now(),m.snapshotVersion=C,m.lastRevisionAt=U}else m.document.markSaved(C,B?.id!=null?String(B.id):void 0);const W=m.document.get().serverId;!x&&W!=null&&(m.recoveryFacts={emailId:W,historyLoaded:!0,isRecovering:!1}),m.saveError=void 0,m.saveFailures=0,m.document.get().serverId,y();const de={intent:_,serverId:m.document.get().serverId,created:!x,...U!==void 0?{revisionAt:U}:{}};return b.forEach(M=>M(de)),!0}catch(x){return m.saveError=x,m.saveFailures+=1,m.saveFailures,y(),!1}},h=()=>{u&&(u.closed=!0,u.watchers.forEach(m=>m()),u.watchers=[],dr(u),u.history.dispose(),u.document.dispose(),u=void 0)},c=(m,_,T)=>{let D=!1;_.show&&(m.show?.id!==_.show.id||m.show.token!==_.show.token)&&(m.show=_.show,D=!0,{docId:m.document.get().docId,..._.show});const R=T==="show"?Li(_.patch):null;R&&(m.reports.set("plugin",R),xt(m,R)),D&&y()},a=(m,_={})=>{const T=u;return!T||T.closed?Promise.resolve(!1):T.saving?m==="snapshot"?Promise.resolve(!1):(T.inFlight??Promise.resolve(!1)).then(()=>a(m,_)):(T.saving=!0,T.inFlight=A(T,m,_).finally(()=>{T.saving=!1,T.inFlight=void 0}),T.inFlight)},p=(m,_="open")=>{if(u&&!u.closed&&_!=="new"&&tl(u.request,m))return c(u,m,_),u.document;h();const T=xa({createBuffer:()=>Ia(""),serverId:m.serverId??null}),D={request:m,show:m.show,document:T,history:ka(T,{now:Date.now}),watchers:[],saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return u=D,T.get().docId,m.serverId,E(D,t(m,{publishRecoveryFacts(R){D.closed||(D.recoveryFacts=R,y())},readShownContent:()=>D.closed?null:D.document.getContent()})),y(),T};return{openWith:p,open:(m,_={})=>p({key:je(m),serverId:m,email:_.email,patch:_.patch,show:_.show},"open"),openDraft:(m,_={})=>p({key:je(void 0),serverId:null,email:m,patch:_.patch,show:_.show},"open"),startNewDraft:(m,_={})=>p({key:je(void 0),serverId:null,email:m,patch:_.patch,show:_.show},"new"),reload:(m,_={})=>p({key:je(m),serverId:m,email:_.email,patch:_.patch,show:_.show},"new"),openBlock:(m,_)=>p({key:me(m)?m:Ha(m),serverId:_?.id!=null?String(_.id):null,email:_},"open"),show:(m,_)=>{const T=u;if(!(!T||T.closed))return p({...T.request,patch:m,show:_},"show")},current:()=>u?.document,save:a,saveState:()=>({error:u?.saveError,failures:u?.saveFailures??0,saving:u?.saving===!0}),revisionFacts(){if(!u)return;const m=u.revisionFactsSnapshot;return m&&m.snapshotVersion===u.snapshotVersion&&m.lastRevisionAt===u.lastRevisionAt?m:(u.revisionFactsSnapshot={snapshotVersion:u.snapshotVersion,lastRevisionAt:u.lastRevisionAt},u.revisionFactsSnapshot)},recoveryFacts:()=>u?.recoveryFacts,history:()=>u?.history,forcedHeaders:()=>u?.forcedHeaders,beginForcedHeaders(m){u&&!u.closed&&(u.forcedHeaders=m)},endForcedHeaders(){u&&(u.forcedHeaders=void 0)},onSaved(m){return b.add(m),()=>b.delete(m)},showFacts:()=>u?.show,sessionKey:()=>u?.request.key,openError:()=>u?.error,subscribe(m){return v.add(m),()=>v.delete(m)},close(){u&&(h(),y())}}}var ki=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Ni(e){if(e instanceof ki)return e.reason;if(e instanceof gt)return Ni(e.reason)}function al(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new ki("not-found");return xi(n)}}}var Fi=L("EmailPort");function ll(e){return e.getInstance(Fi)}function dl(e,t){e.inject(Fi,t)}var ji=L("documentSession.restEmailPortFactories");function Bi(e){return e.getInstance(ji)!==void 0}function Se(e){const t=e.getInstance(ji);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var cl=L("EmailTermsResolver");function ul(e){return e.getInstance(cl)}var Ui=L("EmailHistoryPort"),fl=L("BlockHistoryPort");function Hi(e){return e.getInstance(fl)}function Gi(e){return e.getInstance(Ui)}function pl(e,t){e.inject(Ui,t)}var hl="em_autosave_pending";function bt(e){return`${hl}_${e}`}function ml(e,t){try{sessionStorage.setItem(bt(e),JSON.stringify(t))}catch{}}function gl(e){try{const t=sessionStorage.getItem(bt(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(bt(e)),null):n}catch{return null}}function rt(e){try{sessionStorage.removeItem(bt(e))}catch{}}var vl=2e3,bl=5e3,yl=5,El=5e3,_l=4;function wl(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Sl(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:"useblocks-core.ee20cf1c.js",po:"useblocks-po.ee20cf1c.js",monaco:"static/monaco/index.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(h){var c,l=function(){return c||(c=Promise.resolve().then(h))};return{then:function(p,m){return l().then(p,m)},catch:function(p){return l().catch(p)},finally:function(p){return l().finally(p)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=i(function(){return o.then(function(h){return h.React})}),t.ReactDom=i(function(){return o.then(function(h){return h.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(h){return h.Classnames})}),t.Dayjs=i(function(){return o.then(function(h){return h.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(h){var c=h[0]||Object.create(null),l=Object.create(null);for(var p in c)Object.prototype.hasOwnProperty.call(c,p)&&(l[p]=c[p]);for(var m in l)Object.prototype.hasOwnProperty.call(l,m)&&(t[m]=l[m]);return l})}),d={},a={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/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 'useblocks/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."},f={Antd:"[runtime] `antd` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",AntDesignIcons:"[runtime] `@ant-design/icons` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated."},u=Object.create(null);if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var c in h)Object.prototype.hasOwnProperty.call(h,c)&&(u[c]=h[c])},e.__compatPending){for(var v=0;v<e.__compatPending.length;v+=1)e.registerCompat(e.__compatPending[v]);e.__compatPending=void 0}for(var b in a)Object.prototype.hasOwnProperty.call(a,b)&&(function(h,c,l){var p=!1,m=function(){if(!(h in u))throw new Error(c);return u[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var w=m();return p||(p=!0),w},set:function(w){u[h]=w}}),Object.defineProperty(d,h,{configurable:!0,enumerable:!0,get:m,set:function(w){u[h]=w}})})(b,a[b],f[b]);var E=t;for(var I in d)Object.prototype.hasOwnProperty.call(d,I)&&(E===t&&(E=Object.create(t)),Object.defineProperty(E,I,Object.getOwnPropertyDescriptor(d,I)));var g=s,y=[],_=function(){for(var h=[],c=0;c<y.length;c+=1)(function(l){var p=t[l];p&&typeof p.then=="function"&&h.push(Promise.resolve(p).then(function(m){t[l]=m}))})(y[c]);return Promise.all(h)},S=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(_).then(function(){if(typeof S=="function")return S.call(e)})},typeof e.define=="function"){let h=function(c){if(!c||typeof c!="object"&&typeof c!="function"||c.__esModule)return c;if(A){var l=A.get(c);if(l)return l}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var m=Reflect.ownKeys(c),w=0;w<m.length;w++){var T=m[w];if(T!=="__esModule"){var O=Object.getOwnPropertyDescriptor(c,T);O&&Object.defineProperty(p,T,O)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:c,writable:!1}),A&&A.set(c,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var c=E.React;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.React)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.React;return h(p)})}),e.define("useblocks/runtime/react",[],function(){var c=E.React;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.React)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.React;return h(p)})}),e.define("react-dom",[],function(){var c=E.ReactDom;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.ReactDom)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.ReactDom;return h(p)})}),e.define("useblocks/runtime/react-dom",[],function(){var c=E.ReactDom;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.ReactDom)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.ReactDom;return h(p)})}),e.define("react-dom/client",[],function(){var c=E.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.ReactDomClient)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.ReactDomClient;return h(p)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var c=E.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.ReactDomClient)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.ReactDomClient;return h(p)})}),e.define("react/jsx-runtime",[],function(){var c=E.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.ReactJsxRuntime)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.ReactJsxRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var c=E.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.ReactJsxRuntime)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.ReactJsxRuntime;return h(p)})}),e.define("react/jsx-dev-runtime",[],function(){var c=E.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.ReactJsxDevRuntime)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.ReactJsxDevRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var c=E.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.ReactJsxDevRuntime)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.ReactJsxDevRuntime;return h(p)})}),e.define("antd",[],function(){var c=E.Antd;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.Antd)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.Antd;return h(p)})}),e.define("useblocks/runtime/antd",[],function(){var c=E.Antd;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.Antd)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.Antd;return h(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var c=E.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.AntDesignIconBase)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.AntDesignIconBase;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var c=E.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.AntDesignIconBase)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.AntDesignIconBase;return h(p)})}),e.define("@ant-design/icons",[],function(){var c=E.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.AntDesignIcons)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.AntDesignIcons;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var c=E.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.AntDesignIcons)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.AntDesignIcons;return h(p)})}),e.define("@ant-design/cssinjs",[],function(){var c=E.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.AntDesignCssinjs)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.AntDesignCssinjs;return h(p)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var c=E.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.AntDesignCssinjs)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.AntDesignCssinjs;return h(p)})}),e.define("classnames",[],function(){var c=E.Classnames;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.Classnames)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.Classnames;return h(p)})}),e.define("useblocks/runtime/classnames",[],function(){var c=E.Classnames;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.Classnames)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.Classnames;return h(p)})}),e.define("dayjs",[],function(){var c=E.Dayjs;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.Dayjs)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.Dayjs;return h(p)})}),e.define("useblocks/runtime/dayjs",[],function(){var c=E.Dayjs;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.Dayjs)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.Dayjs;return h(p)})}),e.define("useblocks-ui-kit",[],function(){var c=E.UiKit;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.UiKit)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.UiKit;return h(p)})}),e.define("useblocks/ui-kit",[],function(){var c=E.UiKit;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.UiKit)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.UiKit;return h(p)})}),e.define("useblocks/ui-kit/icons",[],function(){var c=E.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.UiKitIcons)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.UiKitIcons;return h(p)})}),e.define("useblocks-ui-kit/icons",[],function(){var c=E.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(l){return l===void 0?g.then(function(p){return h(p.UiKitIcons)}):h(l)}):c!==void 0?h(c):g.then(function(l){var p=l.UiKitIcons;return h(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Ws=new Function("url","return import(url)");function Ys(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Xs(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Js(e){return e.type==="umd"||e.resolve==="registry"}var Qs=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(Xs(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(Js(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Ws(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,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}initSync(e){const t=[];for(const n of e){const r=this._getOrCreate(n,void 0);t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const{ctor:i,options:o}=await this._resolveEntry(r),s=this._getOrCreate(i,o);n.has(s)||(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const d=await this._resolveEntry(s);t.add(d.ctor),n.push(d)}const r=[];this._map.forEach((s,d)=>{t.has(d)||r.push({key:d,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:d,plugin:a}=r[s];await this._initializingPlugins.get(a),await this._disposePlugin(a,a.constructor.name),this._map.delete(d),this._optionsMap.delete(d),this._readyMap.delete(a),this._resolveMap.delete(a),this._initializingPlugins.delete(a),this._initializedPlugins.delete(a);const f=this._creationOrder.indexOf(a);f>=0&&this._creationOrder.splice(f,1)}const i=[],o=new Set;for(const{ctor:s,options:d}of n){const a=this._getOrCreate(s,d);o.has(a)||(o.add(a),i.push(a))}this._activated&&await this._startPluginsBatch(i)}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,i)=>{let o,s=!1;const d=()=>{s||(s=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,d),r())};this._pluginRegistry.on(e,d),n!==void 0&&n>0&&(o=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,d),i(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),i=this._createPluginInstance(e,r),o=i.constructor.name;this._emitLifecycle({type:"created",plugin:i,name:o}),i.required?.(),this._map.set(n,i),this._creationOrder.push(i),this._setupReadyPromise(i)}return this._map.get(n)}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);try{return Ys(e)?new e(this._context,t):e(this._context,t)||{}}finally{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 i of t){if(this._initializedPlugins.has(i))continue;const o=this._initializingPlugins.get(i);if(o){n.add(o);continue}r.push(i)}if(r.length>0){const i=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,i);n.add(i),i.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===i&&this._initializingPlugins.delete(o)})}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});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})}}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(i){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:i})}}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)}))}},Zs=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 i of n)try{i.callback(t)}catch{}const r=n.filter(i=>!i.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(i=>(t.ctor=i,t.loading=void 0,this._notifyListeners(e,i),i));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 i={callback:t,once:!1};return r.push(i),{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 i={callback:t,once:!0};return r.push(i),{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(i=>i.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)}}}},ea=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()}},ir=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 ta(e,t){return t+e}function na(){return typeof performance>"u"?Date.now():ta(performance.now(),performance.timeOrigin)}var ra="emailmaker:diagnostics",ia="diagnostics",oa="diagnostics";function or(e,t){return t?`${e}${e.includes("?")?"&":"?"}${oa}=1`:e}var Rt;function sa(){try{const e=new URLSearchParams(window.location.search).get(ia);return e===null?void 0:e!=="0"}catch{return}}function aa(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function la(){try{const e=window.localStorage.getItem(ra);return e===null?void 0:e==="1"}catch{return}}function $e(){return Rt===void 0&&(Rt=typeof window>"u"?!1:sa()??aa()??la()??!1),Rt}function da(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var Q={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"},Mm=Object.values(Q),km=[Q.canvasPainted,Q.canvasSettled,Q.appVisible,Q.editorVisible],ca=5e3,ua=3e3,sr="diagnosticsStore",nt,Ne;function ar(){return{marks:new ir(ca),resources:new ir(ua)}}function Ei(){if(Ne)return Ne;const e=xn();return e?(Ne=e[sr]??nt??ar(),e[sr]=Ne,nt=void 0,Ne):(nt??=ar(),nt)}function z(e,t){$e()&&Ei().marks.push({phase:e,at:na(),...t})}function xn(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[da()];return e!==null&&typeof e=="object"?e:void 0}function fa(e){const t=e.length,n=Ei();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function pa(){const e=xn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:fa(e.diagnosticsBuffer)}var ha="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Ln(){const e=new Error(ha);return e.name="DestroyedInstanceError",e}function rn(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 o=e,s=t;return o.length===s.length&&o.every((d,a)=>rn(d,s[a]))}const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&rn(e[o],t[o]))}function yi(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const d=t(s);o&&rn(i,d)||(i=d,o=!0,r(d))})},select(r){return yi(n,r)}};return n}function Me(...e){let t=e[0],n=e.length>0;const r=new Set,i={get(){return n?t:void 0},set(o){t=o,n=!0;for(const s of Array.from(r))s(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return yi(i,o)}};return i}var _i=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:As.UrlEncoded,...t})},wi=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 ma(e){return String(e||"").trim()||void 0}var ga=class extends ee{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=ma(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)}},Mn=L("AppInitService");function va(e){return async()=>{const t=await e();return(await new _i(t).app_init_create({})).data}}function ba(e){e.injectFactory(Mn,()=>{const t=new ga({options:e.getInstance(se),isStandalone:()=>!!e.getInstance(he),resolveRestBaseUrl:n=>n?nr(n):nr()||void 0,setRestBaseUrl:n=>{e.getInstance(zs)?.setOptions(n?{baseUrl:n}:{})},fallbackAppInit:va(()=>e.getInstanceAsync(ps)),publish:n=>{e.inject(Pe,n)}});return e.getInstance(j)?.addDisposable(t),t},!0)}var kn=L("documentSession.emailDocuments");function Pt(e){return e?.getInstance(kn)}var Ea=L("RevisionServiceFlag");function ya(e){return e.getOrCreateInstance(Ea,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Si(e){return ya(e).isEnabled()}var _a=L("EmailRightsResolver");function wa(e,t){const n=e.getInstance(_a);return n?n(t):!0}var Ii=L("EmailHistoryAvailabilityResolver");function Sa(e){return e.getInstance(Ii)!==void 0}async function Ia(e){const t=e.getInstance(Ii);if(!t)return!0;try{return await t()}catch{return!1}}var Nn={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Ti=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Ai=2e4,Ta=Ti.reduce((e,t)=>e+Nn[t],0),Ci=Ai+Ta+3e3;function Aa(e){return Ti.reduce((t,n)=>t+Ri(n,e),0)}function Ri(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:Nn[e]}function Pi(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Ci}function Di(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Ai}function Oi(e=Ci){return e+3e3}function xi(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var Ca=()=>Oi();function Ra(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function Pa(e){return t=>Ra(e.getOrCreateInstance(B.BEFORE_SAVE_EMAIL,()=>new pe).fire(t),Ca())}function Da(e){return e!=null&&e!==""}var Oa;function wt(e,t){return Oa?.capture(e,t)}function xa(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function rt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var ie=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} "${rt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${rt(this.oldText)}")`:`(replace@${this.oldPosition} "${rt(this.oldText)}" with "${rt(this.newText)}")`}};function lr(e,t){return e===null||e.length===0?t:new La(e,t).compress()}var La=class ae{_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),i=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(i===null)break;this._acceptCurr(i),i=this._getCurr(++n);continue}if(i===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldEnd<=r.newPosition){this._acceptCurr(i),i=this._getCurr(++n);continue}if(r.newEnd<=i.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldPosition<r.newPosition){const[a,f]=ae._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(a),i=f;continue}if(r.newPosition<i.oldPosition){const[a,f]=ae._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(a),r=f;continue}let s,d;if(i.oldEnd===r.newEnd)s=r,d=i,r=this._getPrev(++t),i=this._getCurr(++n);else if(i.oldEnd<r.newEnd){const[a,f]=ae._splitPrev(r,i.oldLength);s=a,d=i,r=f,i=this._getCurr(++n)}else{const[a,f]=ae._splitCurr(i,r.newLength);s=r,d=a,r=this._getPrev(++t),i=f}this._result[this._resultLen++]=new ie(s.oldPosition,s.oldText,d.newPosition,d.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=d.newLength-d.oldLength}const o=ae._merge(this._result);return ae._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=ae._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++]=ae._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 ie(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new ie(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),i=t.newText.substr(n);return[new ie(t.oldPosition,t.oldText,t.newPosition,r),new ie(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new ie(t.oldPosition,r,t.newPosition,t.newText),new ie(t.oldPosition+n,i,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,i=t[0];for(let o=1;o<t.length;o++){const s=t[o];i.oldEnd===s.oldPosition?i=new ie(i.oldPosition,i.oldText+s.oldText,i.newPosition,i.newText+s.newText):(n[r++]=i,i=s)}return n[r++]=i,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o.oldText!==o.newText&&(n[r++]=o)}return n}};function Ma(e){return new ie(e.newPosition,e.newText,e.oldPosition,e.oldText)}function ka(e){return e.map(Ma)}function dr(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Na(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const i=t[r];n=n.slice(0,i.oldPosition)+i.newText+n.slice(i.oldEnd)}return n}function Fa(e,t,n){let r=0;const i=e.start===e.end;for(const o of t){const s=o.newLength-o.oldLength;if(o.oldLength===0){const d=o.oldPosition;if(i&&d===e.start)r+=n==="after"?s:0;else{if(e.start<d&&d<e.end)return null;d<=e.start&&(r+=s)}continue}if(i){if(e.start>=o.oldEnd)r+=s;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=s;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var gt=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},cr=0,ja=Math.random().toString(36).slice(2,8);function Ba(){return cr+=1,`doc-${ja}-${cr}`}function Ua(e){const t=e.createBuffer(),n=e.docId??Ba();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const d=new Set;let a=!1,f=!1,u;const v=new Set;let b=null;const E=()=>(b?.version!==i&&(b={version:i,value:t.read()}),b.value),I=g=>Object.entries(g).some(([y,_])=>s[y]!==_);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:E,mutate(g,{source:y}){if(a)return i;const _=g.changes?.length?g.changes:void 0,S=_?Na(E(),_):g.content!==void 0?g.content:void 0,A=S!==void 0&&S!==E(),h=g.attributes!==void 0&&I(g.attributes);if(!A&&!h)return i;const c=!(i>(o??-1));return A&&t.write(S),h&&(s={...s,...g.attributes}),i+=1,y!=="user"&&c&&(o=i),d.forEach(l=>l({source:y,version:i,changes:_})),i},markSaved(g,y){const _={serverId:r,savedVersion:o};y!==void 0&&(r=y),(o===null||g>o)&&(o=g),(_.serverId!==r||_.savedVersion!==o)&&d.forEach(S=>S({source:"system",version:i}))},markReady(){f||u!==void 0||(f=!0,v.forEach(g=>g.resolve()),v.clear(),d.forEach(g=>g({source:"system",version:i})))},isReady:()=>f,markFailed(g){f||u!==void 0||a||(u=g,v.forEach(y=>y.reject(new gt(g))),v.clear(),d.forEach(y=>y({source:"system",version:i})))},failure:()=>u,whenReady(){return f?Promise.resolve():u!==void 0?Promise.reject(new gt(u)):a?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((g,y)=>{v.add({resolve:g,reject:y})})},subscribe(g){return d.add(g),()=>d.delete(g)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>a,dispose(){a=!0,v.forEach(g=>g.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),v.clear(),d.clear(),t.dispose()}}}var Ha=500,Ga=100,Dt=0;function qa(e,t={}){const n=t.groupIntervalMs??Ha,r=t.maxSteps??Ga,i=t.now??(()=>0);let o=[],s=0,d=Dt+=1,a=null,f=!1,u=!1,v=!1;const b=new Set,E=()=>b.forEach(l=>l()),I=(l,p)=>{if(l.length){u=!0;try{e.mutate({changes:l},{source:p})}finally{u=!1}}},g=l=>I(l,"user"),y=l=>{const p=i();f&&a!==null&&p-a<n?o[s-1]=lr(o[s-1],l):(o=o.slice(0,s),o.push(l),s=o.length,f=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,d=Dt+=1)),a=p,E()},_=()=>{f=!1,a=null},S=l=>{if(!l.length)return;const p=o.length>s;p&&(o=o.slice(0,s)),s>0&&(o[s-1]=lr(o[s-1],l)),_(),p&&E()},A=e.subscribe(({source:l,changes:p})=>{if(!(v||u||!p?.length)){if(l==="remote"){h();return}if(l!=="user"){S(p);return}y(p)}}),h=()=>{o=[],s=0,_(),d=Dt+=1,E()},c=()=>{if(s===0)return!1;const l=ka(o[s-1]);return dr(e.getContent(),l)?(g(l),s-=1,_(),!0):(o=o.slice(0,s-1),s=o.length,_(),E(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){c()&&E()},redo(){if(!(s>=o.length)){if(!dr(e.getContent(),o[s])){o=o.slice(0,s),_(),E();return}g(o[s]),s+=1,_(),E()}},clear:h,applyWithoutHistory(l){const p=e.get().version;if(I(l,"system"),e.get().version===p){_();return}S(l)},getPast:l=>o.slice(0,s).reverse().slice(0,l),getFuture:l=>o.slice(s).reverse().slice(0,l),createSnapshot:()=>({stackId:d,index:s}),restoreSnapshot(l){if(l.stackId!==d||l.index>s)return!1;for(;s>l.index;)if(!c())return E(),!1;return E(),!0},subscribe(l){return b.add(l),()=>b.delete(l)},dispose(){v=!0,A(),b.clear(),o=[],s=0}}}var $a=["edit","move","resize","insert"];function Ot(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function za(e){return typeof e=="string"?e:null}function Va(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Ka(e){return $a.includes(e)?e:null}function Wa(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:za(t.originId),changeId:Ot(t.changeId),rev:Ot(t.rev),baseRev:Ot(t.baseRev),expected:Va(t.expected),intent:Ka(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var ur=class extends Error{reason;constructor(e){super(`сохранение не состоялось: ${e}`),this.name="SaveRefusedError",this.reason=e}},Li="draft";function je(e){return e==null||e===""?Li:String(e)}function Ya(e){return e==null||e===""?`${on}${Li}`:`${on}${String(e)}`}var on="block:";function me(e){return e?.startsWith(on)===!0}function Be(e){return me(e.sessionKey())?void 0:e.current()}function He(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return z(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(z(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw An(i)?(`${e}`,{...n}):(`${e}`,{error:xi(i),...n},void 0),i})}function Mi(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function ki(e,{freshSince:t}={}){return!(!e?.slug?.includes("autosave")||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Xa(e,t={}){const n=Mi((e??[]).filter(r=>r?.html?.trim()));return ki(n,t)?n:null}function Ja(e){const t=Date.parse(Mi(e)?.modified??"");return{autosave:Xa(e),...Number.isFinite(t)?{latestAt:t}:{}}}function Qa({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Ni=e=>e.replace(/\r\n?/g,`
997
+ `),fr=["recovery","plugin","rest"],Za=["subject","preheader"];function el(e){let t={},n;for(let i=fr.length-1;i>=0;i--){const o=e.get(fr[i]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const i of Za){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Fi(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Ni(t.content):void 0,i=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...i?{changes:[new ie(0,n,0,r)]}:{}},{source:"remote"})}var pr=e=>typeof e=="string"?e.trim():"";function tl(e,t,n){const{version:r,attributes:i}=e.get(),o=i,s=pr(o.title)||pr(o.subject);return{version:r,payload:{html:e.getContent(),title:s,subject:o.subject,preheader:o.preheader,description:o.description,common_styles:o.common_styles||"",meta:o.meta,utm_parameters:o.utm_parameters,parent_email:o.parent_email,is_template:o.is_template||!1,is_inited:o.is_inited,tags:o.tags,emailtags:o.emailtags,group:o.group,renderGuid:e.get().docId,project:t.project??o.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source}}}async function nl(e,t,n,r,i){if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(i);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,i):t.saveAutosave(r,i)}function ge(e,t=!1){const n={};for(const r of Object.keys(e)){let i=e[r];i!==void 0&&!(typeof i=="number"&&Number.isNaN(i))&&(t&&typeof i=="object"&&i!==null&&(i=ge(i)),n[r]=i)}return n}var rl=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function ji(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!rl.has(t))):{}}function vt(e,t,n={}){e&&e.mutate({attributes:il(e.get().attributes,t)},{source:n.source??"user"})}function il(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Fn(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function ol(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Bi(e){if(!e)return null;const t=ji(e);return e.common_styles!==void 0&&(t.common_styles=ol(e.common_styles)),Fn(e.html,t)}function Ui(e){return e?Fn(e.html,ge(ji(e))):null}var sl=["common_styles","subject","preheader","meta"];function hr(e){if(!e?.html?.trim())return null;const t={};for(const n of sl)al(n,e[n])&&(t[n]=e[n]);return Fn(e.html,t)}function al(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 ll=10,dl=(e,t)=>e.key===t.key&&cl(e.serverId,t.serverId),cl=(e,t)=>e==null||e===t;function ul(e){return typeof e?.then=="function"}var mr=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Hi=e=>{e.request.serverId!=null&&e.document.markSaved(e.document.get().version)},fl=e=>{Fi(e.document,el(e.reports)),Hi(e)},xt=(e,t)=>{if(!e.ready){fl(e);return}Fi(e.document,t)},pl=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 hl(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:d,onAdapterError:a,onTimeout:f}=e;let u;const v=new Set,b=new Set,E=()=>v.forEach(m=>m()),I=(m,w)=>{if(!(m.closed||m.ready)){if(m.error!==void 0){m.document.markFailed(m.error),m.document.get().docId;return}Hi(m),m.ready=!0,m.document.markReady(),m.document.get().docId,[...m.reports.keys()]}},g=(m,w,T)=>{a?.(w.id,T),!(!w.required||m.closed)&&(m.error=T,m.document.get().docId,w.id,E())},y=(m,w)=>{const T=new Set(w.map(R=>R.id));w.forEach(R=>{R.watch&&m.watchers.push(R.watch(C=>m.closed?!1:m.ready&&C?.content!==void 0&&Qa({hasUnsavedUserEdit:m.document.isDirty()})==="skip"?(m.document.get().docId,R.id,!1):(C&&m.reports.set(R.id,C),xt(m,C),!0)))});const O=(R,C)=>{m.closed||(C&&m.reports.set(R.id,C),xt(m,C))},k=()=>{T.size>0||m.closed||(mr(m),I(m,[]))},W=[];if(w.forEach(R=>{let C;try{C=R.load()}catch(D){g(m,R,D),T.delete(R.id);return}if(ul(C)){W.push({id:R.id,required:R.required,load:()=>C});return}O(R,C),T.delete(R.id)}),W.length===0){k();return}m.timer=setTimeout(()=>{m.timer=void 0,f?.([...T]),m.document.get().docId,[...T],I(m,[...T])},n),m.timer.unref?.(),W.forEach(R=>{R.load().then(C=>O(R,C)).catch(C=>{g(m,R,C)}).finally(()=>{T.delete(R.id),k()})})},_=async(m,w,T)=>{if(T==="snapshot"||T==="anchor")return;const O=o?.();if(O)return O.resolve({project:w.project??m.project,tags:(m.tags??[]).map(k=>({name:k}))})},S=m=>{if(m.lock===!0&&s?.(m)===!1)return new ur("locked");const w=m.tags?.length??0,T=m.emailtags?.length??0;if(Math.max(w,T)>ll)return new ur("too-many-tags")},A=async(m,w,T)=>{try{await m.document.whenReady()}catch(C){return m.saveError=C,m.saveFailures+=1,m.saveFailures,!1}if(m.closed)return!1;const O=S(m.document.get().attributes);if(O)return m.saveError=O,m.saveFailures+=1,O.reason,E(),!1;if(d&&(await d(pl(m)).catch(()=>{}),m.closed))return!1;let k;try{k=await _(m.document.get().attributes,T,w)}catch(C){return m.saveError=C,m.saveFailures+=1,m.saveFailures,E(),!1}if(m.closed)return!1;const{payload:W,version:R}=tl(m.document,T,k);m.document.get().docId;try{const C=m.document.get().serverId!=null,D=await nl(r(),i(m.request.key),w,m.document.get().serverId,W);if(m.closed)return!0;let x;if(w==="snapshot"||w==="anchor"){const M=D?.modified!=null?Date.parse(D.modified):NaN;x=Number.isFinite(M)?M:Date.now(),m.snapshotVersion=R,m.lastRevisionAt=x}else m.document.markSaved(R,D?.id!=null?String(D.id):void 0);const U=m.document.get().serverId;!C&&U!=null&&(m.recoveryFacts={emailId:U,historyLoaded:!0,isRecovering:!1}),m.saveError=void 0,m.saveFailures=0,m.document.get().serverId,E();const J={intent:w,serverId:m.document.get().serverId,created:!C,...x!==void 0?{revisionAt:x}:{}};return b.forEach(M=>M(J)),!0}catch(C){return m.saveError=C,m.saveFailures+=1,m.saveFailures,E(),!1}},h=()=>{u&&(u.closed=!0,u.watchers.forEach(m=>m()),u.watchers=[],mr(u),u.history.dispose(),u.document.dispose(),u=void 0)},c=(m,w,T)=>{let O=!1;w.show&&(m.show?.id!==w.show.id||m.show.token!==w.show.token)&&(m.show=w.show,O=!0,{docId:m.document.get().docId,...w.show});const k=T==="show"?Ui(w.patch):null;k&&(m.reports.set("plugin",k),xt(m,k)),O&&E()},l=(m,w={})=>{const T=u;return!T||T.closed?Promise.resolve(!1):T.saving?m==="snapshot"?Promise.resolve(!1):(T.inFlight??Promise.resolve(!1)).then(()=>l(m,w)):(T.saving=!0,T.inFlight=A(T,m,w).finally(()=>{T.saving=!1,T.inFlight=void 0}),T.inFlight)},p=(m,w="open")=>{if(u&&!u.closed&&w!=="new"&&dl(u.request,m))return c(u,m,w),u.document;h();const T=Ua({createBuffer:()=>xa(""),serverId:m.serverId??null}),O={request:m,show:m.show,document:T,history:qa(T,{now:Date.now}),watchers:[],saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return u=O,T.get().docId,m.serverId,y(O,t(m,{publishRecoveryFacts(k){O.closed||(O.recoveryFacts=k,E())},readShownContent:()=>O.closed?null:O.document.getContent()})),E(),T};return{openWith:p,open:(m,w={})=>p({key:je(m),serverId:m,email:w.email,patch:w.patch,show:w.show},"open"),openDraft:(m,w={})=>p({key:je(void 0),serverId:null,email:m,patch:w.patch,show:w.show},"open"),startNewDraft:(m,w={})=>p({key:je(void 0),serverId:null,email:m,patch:w.patch,show:w.show},"new"),reload:(m,w={})=>p({key:je(m),serverId:m,email:w.email,patch:w.patch,show:w.show},"new"),openBlock:(m,w)=>p({key:me(m)?m:Ya(m),serverId:w?.id!=null?String(w.id):null,email:w},"open"),show:(m,w)=>{const T=u;if(!(!T||T.closed))return p({...T.request,patch:m,show:w},"show")},current:()=>u?.document,save:l,saveState:()=>({error:u?.saveError,failures:u?.saveFailures??0,saving:u?.saving===!0}),revisionFacts(){if(!u)return;const m=u.revisionFactsSnapshot;return m&&m.snapshotVersion===u.snapshotVersion&&m.lastRevisionAt===u.lastRevisionAt?m:(u.revisionFactsSnapshot={snapshotVersion:u.snapshotVersion,lastRevisionAt:u.lastRevisionAt},u.revisionFactsSnapshot)},recoveryFacts:()=>u?.recoveryFacts,history:()=>u?.history,forcedHeaders:()=>u?.forcedHeaders,beginForcedHeaders(m){u&&!u.closed&&(u.forcedHeaders=m)},endForcedHeaders(){u&&(u.forcedHeaders=void 0)},onSaved(m){return b.add(m),()=>b.delete(m)},showFacts:()=>u?.show,sessionKey:()=>u?.request.key,openError:()=>u?.error,subscribe(m){return v.add(m),()=>v.delete(m)},close(){u&&(h(),E())}}}var Gi=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function qi(e){if(e instanceof Gi)return e.reason;if(e instanceof gt)return qi(e.reason)}function ml(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Gi("not-found");return Bi(n)}}}var $i=L("EmailPort");function gl(e){return e.getInstance($i)}function vl(e,t){e.inject($i,t)}var zi=L("documentSession.restEmailPortFactories");function Vi(e){return e.getInstance(zi)!==void 0}function Se(e){const t=e.getInstance(zi);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var bl=L("EmailTermsResolver");function El(e){return e.getInstance(bl)}var Ki=L("EmailHistoryPort"),yl=L("BlockHistoryPort");function Wi(e){return e.getInstance(yl)}function Yi(e){return e.getInstance(Ki)}function _l(e,t){e.inject(Ki,t)}var wl="em_autosave_pending";function bt(e){return`${wl}_${e}`}function Sl(e,t){try{sessionStorage.setItem(bt(e),JSON.stringify(t))}catch{}}function Il(e){try{const t=sessionStorage.getItem(bt(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(bt(e)),null):n}catch{return null}}function it(e){try{sessionStorage.removeItem(bt(e))}catch{}}var Tl=2e3,Al=5e3,Cl=5,Rl=5e3,Pl=4;function Dl(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Ol(e,t){return e==null||t==null?!1:e.replaceAll(`\r
998
998
  `,`
999
999
  `)===t.replaceAll(`\r
1000
1000
  `,`
1001
- `)}function Il({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:d,pageLoadTs:l=wl()}){let f=null,u=!1,v=!1,b=0,y={emailId:e,historyLoaded:!1,isRecovering:!1},I=null;const g=new Promise(C=>{I=C}),E=C=>{y={...y,...C},o(y)},w=C=>{b+=1,E({applied:{phase:C,seq:b}})},S=()=>{f?.timer&&clearTimeout(f.timer),f=null},A=C=>{if(!v){if(I){const x=I;I=null,x(C),C.revision&&w(C.phase);return}s(C)&&C.revision&&w(C.phase)}},h=()=>{if(!f||v)return;const C=f.phase==="fast",x=C?vl:El,B=C?yl:_l;f.timer=setTimeout(()=>{const U=f;if(!(!U||v)){if(U.attempts+=1,_(),C&&U.attempts>=B){const{pending:W}=U;rt(e),E({isRecovering:!1}),A({revision:{html:W.html,common_styles:W.common_styles,subject:W.subject,preheader:W.preheader},phase:"timeout"}),u=!0,U.phase="bg",U.attempts=0,h();return}if(!C&&U.attempts>=B){rt(e),S(),E({isRecovering:!1}),u=!0;return}h()}},x),f.timer.unref?.()},c=C=>{f={phase:"fast",attempts:0,pending:C,timer:null},E({isRecovering:!0}),h()},a=(C,x)=>Ri(C.autosave,x===void 0?{}:{freshSince:x})?C.autosave:null,p=C=>{if(v)return;if(E({historyLoaded:!0,latestRevisionAt:C.latestAt!==void 0&&Number.isFinite(C.latestAt)?C.latestAt:void 0}),n&&f){const U=a(C,f.pending.sentAt);if(!U)return;const W=f.phase==="fast"?"found":"bg";rt(e),S(),E({isRecovering:!1}),u=!0,A({revision:U,phase:W});return}if(u)return;const x=n?gl(e):null,B=x&&(x.sentAt<l||!Sl(x.html,i()))?x:null;if(B){const U=a(C,B.sentAt);if(U){rt(e),u=!0,A({revision:U,phase:"found"});return}c(B);return}u=!0,A({revision:a(C),phase:"normal"})},m=C=>{v||(d?.(C),y.historyLoaded||(E({historyLoaded:!1,latestRevisionAt:void 0}),R()),!f&&A({revision:null,phase:"normal"}))},_=()=>t(e).then(p).catch(m);let T,D=!1;const R=()=>{D||f||v||(D=!0,T=setTimeout(()=>{T=void 0,!v&&!y.historyLoaded&&_()},bl))},O=()=>{v||(E({historyLoaded:!1,latestRevisionAt:void 0}),A({revision:null,phase:"normal"}))};return r?r().then(C=>C?_():O()):_(),{verdict:()=>g,dispose(){v=!0,T!==void 0&&(clearTimeout(T),T=void 0),S()}}}function Tl({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const d=Il({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:l,phase:f})=>{const u=lr(l);return s?.(u)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:l})=>lr(l)),watch(l){return s=l,()=>{s=null,d.dispose()}}}}function qi(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){ml(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function Al(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=await t.updateEmail(n,r);return await e.updateEmail(n,r),i}}}var $i=L("CurrentUser"),zi={};function Vi(e){return e.getOrCreateInstance($i,()=>ke(zi))}function Ki(e){return e?.getInstance($i)?.get()??zi}function Wi(e){return e?.getInstance(we)?.get()??{}}var Cl=1.5;function Rl(e){return!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=Cl*e.autosaveTimeoutMs?"none":"revision"}var Pl=4;function Dl(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=()=>n().autosaveTimeoutMs*2**Math.min(o(),Pl),d=()=>{const w=t();if(!w||w.isDisposed())return"none";const{latestRevisionAt:S,snapshotVersion:A,...h}=n();return Rl({...h,isDirty:w.isDirty(),isNew:w.isNew(),isReady:w.isReady(),latestRevisionAgeMs:S!=null?Date.now()-S:void 0,isSnapshotSent:A!=null&&A===w.get().version})},l=()=>{const w=t();if(!w||w.isDisposed())return!1;if(!w.isDirty())return w.isNew();const{snapshotVersion:S}=n();return!(S!=null&&S===w.get().version)};let f,u,v,b,y=!1;const I=()=>{u=void 0;const w=t();if(!w||w.isDisposed())return;if(w.get().docId!==f){g();return}const S=d();S==="create"?r():S==="revision"?i():l()&&(f=w.get().docId,u=setTimeout(I,s()))},g=()=>{const w=t();y||!w||u!==void 0||d()==="none"&&!l()||(f=w.get().docId,u=setTimeout(I,s()))},E=()=>{const w=t();w!==v&&(b?.(),v=w,b=w?.subscribe(g),u!==void 0&&(clearTimeout(u),u=void 0))};return E(),g(),{refresh:()=>{y||(E(),g())},stop:()=>{y=!0,b?.(),b=void 0,v=void 0,u!==void 0&&(clearTimeout(u),u=void 0)}}}var Yi=L("documentSession.autosaveUiFacts"),Xi={isUserBusy:!1,saveContext:{}};function Ol(e){return e.getOrCreateInstance(Yi,()=>ke(Xi))}function cr(e){return e?.getInstance(Yi)?.get()??Xi}var xl=1e4;function Ll(e,t){const n=()=>{const l=t.current(),f=l?.get().serverId??void 0,u=me(t.sessionKey()),v=t.recoveryFacts(),b=v?.emailId===f?v:void 0,y=t.revisionFacts(),I=b?.latestRevisionAt,g=y?.lastRevisionAt,E=Ki(e).profile;return{isInited:u||l?.get().attributes.is_inited===!0,isEnabled:!!E?.autosaves,isHistoryLoaded:b?.historyLoaded===!0,isUserBusy:cr(e).isUserBusy,autosaveTimeoutMs:Wi(e).autosaveTimeout||xl,latestRevisionAt:I!==void 0||g!==void 0?Math.max(I??0,g??0):void 0,snapshotVersion:y?.snapshotVersion}},r=()=>{const l=cr(e).saveContext;return{...l,project:l.project??t.current()?.get().attributes.project}},i=Dl({readDocument:()=>t.current(),readEnvironment:n,readFailures:()=>t.saveState().failures,onCreate:()=>{me(t.sessionKey())||t.save("materialize",r())},onRevision:()=>{t.save("snapshot",{project:r().project})}}),o=t.subscribe(i.refresh),s=Vi(e).watch(()=>i.refresh()),d=Ol(e).watch(()=>i.refresh());return()=>{o(),s.dispose(),d.dispose(),i.stop()}}var ur=12e3;function ve(e){return e.getOrCreateInstance(Dn,()=>{const t=sl({resolveAdapters:(r,i)=>Nl(r,e,i),resolveWritePort:()=>Ji(e),resolveHistoryPort:r=>me(r)?Zi(e):Qi(e),resolveTerms:()=>ul(e),canEdit:r=>ha(e,r),notifyBeforeSave:_a(e),timeoutMs:ur,onAdapterError:(r,i)=>{i instanceof Error&&i.message,wt(i,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=Ll(e,t);return e.getInstance(F)?.addDispose(n),t})}function Ln(e){return e?.getInstance(Dn)}function Ji(e){const t=ll(e);return t?Mn(e)?Al(t,Se(e).email(e)):t:Se(e).email(e)}function Ml(e){return Gi(e)!==void 0||Bi(e)}function Qi(e){const t=Gi(e);return t?Mn(e)?(z("port:history:server-backed"),qi(t,Se(e).history(e))):(z("port:history:integrator"),t):(z("port:history:rest (порт не зарегистрирован)"),Se(e).history(e))}function Zi(e){const t=Hi(e);return t?Mn(e)?(z("port:block-history:server-backed"),qi(t,Se(e).blockHistory(e))):(z("port:block-history:integrator"),t):(z("port:block-history:rest (порт не зарегистрирован)"),Se(e).blockHistory(e))}function kl(e){return Hi(e)!==void 0||Bi(e)}function Mn(e){return vi(e)}function Nl({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>xi(e),required:!0}):n&&s.push(al(Ji(i),n)),t&&s.push({id:"plugin",load:()=>Li(t)});const d=me(r);return wa(n)&&(d?kl(i):Ml(i))&&s.push(Tl({port:d?Zi(i):Qi(i),revisionServiceEnabled:vi(i),...!d&&ma(i)?{isHistoryAvailable:()=>ga(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),s}function X(e){return e.getOrCreateInstance(Ye,()=>new Xe)}var eo=new WeakMap,rn=new WeakMap;function ue(e){return eo.get(e)??0}function to(e,t){let n=rn.get(e);return n||(n=new Set,rn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Fl(e){eo.set(e,ue(e)+1),rn.get(e)?.forEach(t=>t())}function jl(e){const t=ve(e),n=X(e).addListener(N.APPLICATION_HAS_AMP,r=>{Be(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(F)?.addDispose(()=>n.dispose())}function Bl(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Ul(e){const t=e.fetchImpl??((o,s)=>fetch(o,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,i=o=>{try{const s=new URL(o,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:i,async load(o){if(!i(o))return;const s=!r.has(o);r.add(o);try{const d=await t(o,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!d.ok)return;const l=await d.blob();return Bl(l)?l:void 0}catch{return}}}}var _e={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Hl(e){const t={maxBytes:e.maxBytes??_e.maxBytes,maxImageBytes:e.maxImageBytes??_e.maxImageBytes,ttlMs:e.ttlMs??_e.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const d=v=>{const b=r.get(v);b&&(s-=b.bytes,r.delete(v))},l=v=>t.ttlMs<=0||n()-v.storedAt<t.ttlMs,f=()=>{if(s<=t.maxBytes)return;const v=[...r.entries()].sort((b,y)=>b[1].usedAt-y[1].usedAt);for(const[b]of v){if(s<=t.maxBytes)return;d(b)}},u=(v,b)=>{b.size>t.maxImageBytes||(r.set(v,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,f())};return{async get(v){const b=r.get(v);if(b&&l(b))return b.usedAt=n(),o.hits+=1,b.blob;b&&d(v);const y=i.get(v);if(y!==void 0)return y;o.loads+=1;const I=(async()=>{try{const g=await e.load(v);return g?u(v,g):o.failures+=1,g}catch{o.failures+=1;return}finally{i.delete(v)}})();return i.set(v,I),I},forget(v){d(v),i.delete(v)},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var Gl=["emcdn.ru","scr.emcdn.ru"];function ql(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 $l(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const d=ql(s);d&&o.add(d)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function fr(e){const t=e??{},n=t.isPlugin!==!0?Gl:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],..._e};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:$l(i.sourceHosts,n),maxBytes:i.maxBytes??_e.maxBytes,maxImageBytes:i.maxImageBytes??_e.maxImageBytes,ttlMs:i.ttlMs??_e.ttlMs}}function zl(e){const t=X(e),n=e.getInstance(we);let r=fr(n?.get());const i=Ul({sourceHosts:()=>r.sourceHosts}),o=Hl({load:I=>i.load(I),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),s=()=>{t.send(N.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},d=t.onInit(()=>s()),l=n?.watch(()=>{const I=fr(n.get()),g=JSON.stringify(I)!==JSON.stringify(r);r=I,I.enabled||o.clear(),g&&t.isInited()&&s()}),f={asked:0,served:0,refused:0},u=[],v=(I,g)=>(f.refused+=1,u.push({url:I,reason:g}),u.length>20&&u.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...f},refusals:[...u],store:o.stats()})}),y=t.addListenerAsync(N.APPLICATION_CANVAS_IMAGE_GET,async I=>{const g=I?.url??"";if(f.asked+=1,!r.enabled||!g)return v(g,"disabled");if(!i.accepts(g))return v(g,"host");I.fresh&&o.forget(g);const E=await o.get(g);return E?(f.served+=1,{blob:E}):v(g,"load-failed")});e.getInstance(F)?.addDispose(()=>{d.dispose(),l?.dispose(),y.dispose(),o.clear(),delete b.__emmCanvasImages__})}var Vl=2e3;function Kl(e){const t=X(e),n=new Set,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;const d=new MessageChannel;let l=!1;const f=v=>{v.data?.operationId==="em:port-ready"&&(l=!0,d.port1.removeEventListener("message",f),t.drainWindow(s))};d.port1.addEventListener("message",f),t.sendPort(s,d.port2),t.usePort(d.port1,!1,s);const u=setTimeout(()=>{n.delete(u),!l&&(wt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d.port1.removeEventListener("message",f),t.useWindow(s))},Vl);n.add(u)},i=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),o=t.onInit(()=>r());e.getInstance(F)?.addDispose(()=>{for(const s of n)clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var Wl=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Yl(e){return Wl.test(e)||e.indexOf("//")===0}function it(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Xl(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function pr(e,t){const n=e==null||e===""?"./":String(e);if(Yl(n))return it(n);const r=t??Xl();if(!r)return it(n);try{return it(new URL(n,r).href)}catch{return it(n)}}function Jl(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?pr(window.__useblocks__.publicPath):pr("/")}var Ql=()=>"",Zl=()=>"46f9d75a";function no(e){const t=e?"iframe-eblock":"iframe",n=Ql();if(n){const o=n.replace(/\/?$/,"/");return Zn(`${o}${t}.html`,$e())}const r=Zl(),i=`${Jl().replace(/\/?$/,"/")}iframe/`;return Zn(`${i}${t}${r?`.${r}`:""}.html`,$e())}var hr="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function on(e){return/^file:/i.test(String(e||"").trim())}function ed(e){return on(e)?`${hr} allow-same-origin`:hr}var td="em:module-body-ack";function nd(e,t,n){try{const r=new URL("./",new URL(t,n)).href,i=new URL(e,r).href;return i.startsWith(r)?i:void 0}catch{return}}function kn(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.[0-9a-f]{6,})?\.html$/.exec(t);return n?`js/${n[1]}.body.js`:void 0}function rd(e,t){const n=kn(t)?.replace(/^js\/|\.body\.js$/g,""),r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function id(e,t){const n=kn(t)?.replace(/\.body\.js$/,".js");if(!n||!(n in e))return[];const r=new Set([n]),i=[n],o=[];for(;i.length>0;)for(const s of e[i.shift()]??[])r.has(s)||(r.add(s),o.push(s),i.push(s));return o}async function od(e){try{const t=await fetch(e);return t.ok?await t.blob():void 0}catch{return}}function sd(e){const t=new Map,n=r=>{const i=nd(r,e.canvasSrc,e.origin);if(!i)return;const o=t.get(i);if(o!==void 0)return o;const s=e.fetchBody(i);return t.set(i,s),s};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r){for(const i of r)n(i)},reset(){t.clear()},get size(){return t.size}}}async function ad(e,t,n){try{const r=new URL(".vite/manifest.json",new URL("./",new URL(e,t))).href,i=await fetch(r);if(!i.ok)return;const o=await i.json();n(rd(o,e))}catch{}}function ld(e){try{return on(new URL(e,window.location.href).href)}catch{return on(window.location.href)}}function dd(e){X(e);const t=no(!1);if(ld(t))return;const n=sd({canvasSrc:t,origin:window.location.href,fetchBody:od}),r=kn(t);r&&n.warm([r]);const i={"js/iframe-eblock.js":["js/discussHandlers.C5qc-xPl.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.C5qc-xPl.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.C5qc-xPl.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};i?n.warm(id(i,t)):ad(t,window.location.href,s=>n.warm(s));const o=s=>{const d=s.data;if(!d||d.operationId!=="em:module-body"||!d.result)return;const l=s.source;l&&(l.postMessage({operationId:td,for:d.result},"*"),n.take(d.data?.url??"").then(f=>{l.postMessage({operationId:d.result,data:f??null},"*")}))};window.addEventListener("message",o),e.getInstance(F)?.addDispose(()=>{window.removeEventListener("message",o),n.reset()})}var Ae=/<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,cd=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Oe=/<style\b[^>]*>[\s\S]*?<\/style>/gi,mr=/display:\s*none\s*!important/gi,ud=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,fd=/\s*height\s*:\s*100%\s*!important\s*;?/gi,pd=/height\s*:\s*100%\s*!important/i,hd=[".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 md(e){return mr.lastIndex=0,(e.match(mr)||[]).length}function ro(e){const t=e.trim(),n=md(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=hd.filter(i=>t.includes(i)).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 gd(e){Oe.lastIndex=0;for(const t of e.matchAll(Oe))if(ro(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function vd(e){let t=!1;return Oe.lastIndex=0,{html:e.replace(Oe,n=>ro(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function bd(e){return Ae.lastIndex=0,Ae.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||gd(e)}function yd(e){if(!bd(e))return{html:e,found:!1};let t=!1,n=e;Ae.lastIndex=0,Ae.test(n)&&(Ae.lastIndex=0,n=n.replace(Ae,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(cd,""),t=!0);const r=vd(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Ed(e){return!e||!pd.test(e)?e:(Oe.lastIndex=0,e.replace(Oe,t=>t.replace(ud,(n,r,i,o)=>`${r}${i.replace(fd,"")}${o}`)))}function io(e){const t=yd(e.replaceAll(`\r
1001
+ `)}function xl({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:d,pageLoadTs:a=Dl()}){let f=null,u=!1,v=!1,b=0,E={emailId:e,historyLoaded:!1,isRecovering:!1},I=null;const g=new Promise(R=>{I=R}),y=R=>{E={...E,...R},o(E)},_=R=>{b+=1,y({applied:{phase:R,seq:b}})},S=()=>{f?.timer&&clearTimeout(f.timer),f=null},A=R=>{if(!v){if(I){const C=I;I=null,C(R),R.revision&&_(R.phase);return}s(R)&&R.revision&&_(R.phase)}},h=()=>{if(!f||v)return;const R=f.phase==="fast",C=R?Tl:Rl,D=R?Cl:Pl;f.timer=setTimeout(()=>{const x=f;if(!(!x||v)){if(x.attempts+=1,w(),R&&x.attempts>=D){const{pending:U}=x;it(e),y({isRecovering:!1}),A({revision:{html:U.html,common_styles:U.common_styles,subject:U.subject,preheader:U.preheader},phase:"timeout"}),u=!0,x.phase="bg",x.attempts=0,h();return}if(!R&&x.attempts>=D){it(e),S(),y({isRecovering:!1}),u=!0;return}h()}},C),f.timer.unref?.()},c=R=>{f={phase:"fast",attempts:0,pending:R,timer:null},y({isRecovering:!0}),h()},l=(R,C)=>ki(R.autosave,C===void 0?{}:{freshSince:C})?R.autosave:null,p=R=>{if(v)return;if(y({historyLoaded:!0,latestRevisionAt:R.latestAt!==void 0&&Number.isFinite(R.latestAt)?R.latestAt:void 0}),n&&f){const x=l(R,f.pending.sentAt);if(!x)return;const U=f.phase==="fast"?"found":"bg";it(e),S(),y({isRecovering:!1}),u=!0,A({revision:x,phase:U});return}if(u)return;const C=n?Il(e):null,D=C&&(C.sentAt<a||!Ol(C.html,i()))?C:null;if(D){const x=l(R,D.sentAt);if(x){it(e),u=!0,A({revision:x,phase:"found"});return}c(D);return}u=!0,A({revision:l(R),phase:"normal"})},m=R=>{v||(d?.(R),E.historyLoaded||(y({historyLoaded:!1,latestRevisionAt:void 0}),k()),!f&&A({revision:null,phase:"normal"}))},w=()=>t(e).then(p).catch(m);let T,O=!1;const k=()=>{O||f||v||(O=!0,T=setTimeout(()=>{T=void 0,!v&&!E.historyLoaded&&w()},Al))},W=()=>{v||(y({historyLoaded:!1,latestRevisionAt:void 0}),A({revision:null,phase:"normal"}))};return r?r().then(R=>R?w():W()):w(),{verdict:()=>g,dispose(){v=!0,T!==void 0&&(clearTimeout(T),T=void 0),S()}}}function Ll({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const d=xl({emailId:r,readAutosave:a=>e.readAutosave(a),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:a,phase:f})=>{const u=hr(a);return s?.(u)??!1},onError:a=>{a instanceof Error&&a.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:a})=>hr(a)),watch(a){return s=a,()=>{s=null,d.dispose()}}}}function Xi(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){Sl(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function Ml(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=await t.updateEmail(n,r);return await e.updateEmail(n,r),i}}}var Ji=L("CurrentUser"),Qi={};function Zi(e){return e.getOrCreateInstance(Ji,()=>Me(Qi))}function eo(e){return e?.getInstance(Ji)?.get()??Qi}function to(e){return e?.getInstance(we)?.get()??{}}var kl=1.5;function Nl(e){return!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=kl*e.autosaveTimeoutMs?"none":"revision"}var Fl=4;function jl(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=()=>n().autosaveTimeoutMs*2**Math.min(o(),Fl),d=()=>{const _=t();if(!_||_.isDisposed())return"none";const{latestRevisionAt:S,snapshotVersion:A,...h}=n();return Nl({...h,isDirty:_.isDirty(),isNew:_.isNew(),isReady:_.isReady(),latestRevisionAgeMs:S!=null?Date.now()-S:void 0,isSnapshotSent:A!=null&&A===_.get().version})},a=()=>{const _=t();if(!_||_.isDisposed())return!1;if(!_.isDirty())return _.isNew();const{snapshotVersion:S}=n();return!(S!=null&&S===_.get().version)};let f,u,v,b,E=!1;const I=()=>{u=void 0;const _=t();if(!_||_.isDisposed())return;if(_.get().docId!==f){g();return}const S=d();S==="create"?r():S==="revision"?i():a()&&(f=_.get().docId,u=setTimeout(I,s()))},g=()=>{const _=t();E||!_||u!==void 0||d()==="none"&&!a()||(f=_.get().docId,u=setTimeout(I,s()))},y=()=>{const _=t();_!==v&&(b?.(),v=_,b=_?.subscribe(g),u!==void 0&&(clearTimeout(u),u=void 0))};return y(),g(),{refresh:()=>{E||(y(),g())},stop:()=>{E=!0,b?.(),b=void 0,v=void 0,u!==void 0&&(clearTimeout(u),u=void 0)}}}var no=L("documentSession.autosaveUiFacts"),ro={isUserBusy:!1,saveContext:{}};function Bl(e){return e.getOrCreateInstance(no,()=>Me(ro))}function gr(e){return e?.getInstance(no)?.get()??ro}var Ul=1e4;function Hl(e,t){const n=()=>{const a=t.current(),f=a?.get().serverId??void 0,u=me(t.sessionKey()),v=t.recoveryFacts(),b=v?.emailId===f?v:void 0,E=t.revisionFacts(),I=b?.latestRevisionAt,g=E?.lastRevisionAt,y=eo(e).profile;return{isInited:u||a?.get().attributes.is_inited===!0,isEnabled:!!y?.autosaves,isHistoryLoaded:b?.historyLoaded===!0,isUserBusy:gr(e).isUserBusy,autosaveTimeoutMs:to(e).autosaveTimeout||Ul,latestRevisionAt:I!==void 0||g!==void 0?Math.max(I??0,g??0):void 0,snapshotVersion:E?.snapshotVersion}},r=()=>{const a=gr(e).saveContext;return{...a,project:a.project??t.current()?.get().attributes.project}},i=jl({readDocument:()=>t.current(),readEnvironment:n,readFailures:()=>t.saveState().failures,onCreate:()=>{me(t.sessionKey())||t.save("materialize",r())},onRevision:()=>{t.save("snapshot",{project:r().project})}}),o=t.subscribe(i.refresh),s=Zi(e).watch(()=>i.refresh()),d=Bl(e).watch(()=>i.refresh());return()=>{o(),s.dispose(),d.dispose(),i.stop()}}var vr=12e3;function ve(e){return e.getOrCreateInstance(kn,()=>{const t=hl({resolveAdapters:(r,i)=>$l(r,e,i),resolveWritePort:()=>io(e),resolveHistoryPort:r=>me(r)?so(e):oo(e),resolveTerms:()=>El(e),canEdit:r=>wa(e,r),notifyBeforeSave:Pa(e),timeoutMs:vr,onAdapterError:(r,i)=>{i instanceof Error&&i.message,wt(i,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=Hl(e,t);return e.getInstance(j)?.addDispose(n),t})}function jn(e){return e?.getInstance(kn)}function io(e){const t=gl(e);return t?Bn(e)?Ml(t,Se(e).email(e)):t:Se(e).email(e)}function Gl(e){return Yi(e)!==void 0||Vi(e)}function oo(e){const t=Yi(e);return t?Bn(e)?(z("port:history:server-backed"),Xi(t,Se(e).history(e))):(z("port:history:integrator"),t):(z("port:history:rest (порт не зарегистрирован)"),Se(e).history(e))}function so(e){const t=Wi(e);return t?Bn(e)?(z("port:block-history:server-backed"),Xi(t,Se(e).blockHistory(e))):(z("port:block-history:integrator"),t):(z("port:block-history:rest (порт не зарегистрирован)"),Se(e).blockHistory(e))}function ql(e){return Wi(e)!==void 0||Vi(e)}function Bn(e){return Si(e)}function $l({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>Bi(e),required:!0}):n&&s.push(ml(io(i),n)),t&&s.push({id:"plugin",load:()=>Ui(t)});const d=me(r);return Da(n)&&(d?ql(i):Gl(i))&&s.push(Ll({port:d?so(i):oo(i),revisionServiceEnabled:Si(i),...!d&&Sa(i)?{isHistoryAvailable:()=>Ia(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:a=>o.publishRecoveryFacts(a)})),s}function X(e){return e.getOrCreateInstance(Ye,()=>new Xe)}var ao=new WeakMap,sn=new WeakMap;function ue(e){return ao.get(e)??0}function lo(e,t){let n=sn.get(e);return n||(n=new Set,sn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function zl(e){ao.set(e,ue(e)+1),sn.get(e)?.forEach(t=>t())}function Vl(e){const t=ve(e),n=X(e).addListener(F.APPLICATION_HAS_AMP,r=>{Be(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(j)?.addDispose(()=>n.dispose())}function Kl(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Wl(e){const t=e.fetchImpl??((o,s)=>fetch(o,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,i=o=>{try{const s=new URL(o,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:i,async load(o){if(!i(o))return;const s=!r.has(o);r.add(o);try{const d=await t(o,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!d.ok)return;const a=await d.blob();return Kl(a)?a:void 0}catch{return}}}}var _e={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Yl(e){const t={maxBytes:e.maxBytes??_e.maxBytes,maxImageBytes:e.maxImageBytes??_e.maxImageBytes,ttlMs:e.ttlMs??_e.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const d=v=>{const b=r.get(v);b&&(s-=b.bytes,r.delete(v))},a=v=>t.ttlMs<=0||n()-v.storedAt<t.ttlMs,f=()=>{if(s<=t.maxBytes)return;const v=[...r.entries()].sort((b,E)=>b[1].usedAt-E[1].usedAt);for(const[b]of v){if(s<=t.maxBytes)return;d(b)}},u=(v,b)=>{b.size>t.maxImageBytes||(r.set(v,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,f())};return{async get(v){const b=r.get(v);if(b&&a(b))return b.usedAt=n(),o.hits+=1,b.blob;b&&d(v);const E=i.get(v);if(E!==void 0)return E;o.loads+=1;const I=(async()=>{try{const g=await e.load(v);return g?u(v,g):o.failures+=1,g}catch{o.failures+=1;return}finally{i.delete(v)}})();return i.set(v,I),I},forget(v){d(v),i.delete(v)},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var Xl=["emcdn.ru","scr.emcdn.ru"];function Jl(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 Ql(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const d=Jl(s);d&&o.add(d)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function br(e){const t=e??{},n=t.isPlugin!==!0?Xl:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],..._e};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:Ql(i.sourceHosts,n),maxBytes:i.maxBytes??_e.maxBytes,maxImageBytes:i.maxImageBytes??_e.maxImageBytes,ttlMs:i.ttlMs??_e.ttlMs}}function Zl(e){const t=X(e),n=e.getInstance(we);let r=br(n?.get());const i=Wl({sourceHosts:()=>r.sourceHosts}),o=Yl({load:I=>i.load(I),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),s=()=>{t.send(F.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},d=t.onInit(()=>s()),a=n?.watch(()=>{const I=br(n.get()),g=JSON.stringify(I)!==JSON.stringify(r);r=I,I.enabled||o.clear(),g&&t.isInited()&&s()}),f={asked:0,served:0,refused:0},u=[],v=(I,g)=>(f.refused+=1,u.push({url:I,reason:g}),u.length>20&&u.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...f},refusals:[...u],store:o.stats()})}),E=t.addListenerAsync(F.APPLICATION_CANVAS_IMAGE_GET,async I=>{const g=I?.url??"";if(f.asked+=1,!r.enabled||!g)return v(g,"disabled");if(!i.accepts(g))return v(g,"host");I.fresh&&o.forget(g);const y=await o.get(g);return y?(f.served+=1,{blob:y}):v(g,"load-failed")});e.getInstance(j)?.addDispose(()=>{d.dispose(),a?.dispose(),E.dispose(),o.clear(),delete b.__emmCanvasImages__})}var ed=2e3;function td(e){const t=X(e),n=new Set,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;const d=new MessageChannel;let a=!1;const f=v=>{v.data?.operationId==="em:port-ready"&&(a=!0,d.port1.removeEventListener("message",f),t.drainWindow(s))};d.port1.addEventListener("message",f),t.sendPort(s,d.port2),t.usePort(d.port1,!1,s);const u=setTimeout(()=>{n.delete(u),!a&&(wt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d.port1.removeEventListener("message",f),t.useWindow(s))},ed);n.add(u)},i=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),o=t.onInit(()=>r());e.getInstance(j)?.addDispose(()=>{for(const s of n)clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var nd=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function rd(e){return nd.test(e)||e.indexOf("//")===0}function ot(e){return e&&(e.endsWith("/")?e:`${e}/`)}function id(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Er(e,t){const n=e==null||e===""?"./":String(e);if(rd(n))return ot(n);const r=t??id();if(!r)return ot(n);try{return ot(new URL(n,r).href)}catch{return ot(n)}}function od(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?Er(window.__useblocks__.publicPath):Er("/")}var sd=()=>"",ad=()=>"ee20cf1c";function co(e){const t=e?"iframe-eblock":"iframe",n=sd();if(n){const o=n.replace(/\/?$/,"/");return or(`${o}${t}.html`,$e())}const r=ad(),i=`${od().replace(/\/?$/,"/")}iframe/`;return or(`${i}${t}${r?`.${r}`:""}.html`,$e())}var yr="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function an(e){return/^file:/i.test(String(e||"").trim())}function ld(e){return an(e)?`${yr} allow-same-origin`:yr}var dd="em:module-body-ack";function cd(e,t,n){try{const r=new URL("./",new URL(t,n)).href,i=new URL(e,r).href;return i.startsWith(r)?i:void 0}catch{return}}function Un(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.[0-9a-f]{6,})?\.html$/.exec(t);return n?`js/${n[1]}.body.js`:void 0}function ud(e,t){const n=Un(t)?.replace(/^js\/|\.body\.js$/g,""),r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function fd(e,t){const n=Un(t)?.replace(/\.body\.js$/,".js");if(!n||!(n in e))return[];const r=new Set([n]),i=[n],o=[];for(;i.length>0;)for(const s of e[i.shift()]??[])r.has(s)||(r.add(s),o.push(s),i.push(s));return o}async function pd(e){try{const t=await fetch(e);return t.ok?await t.blob():void 0}catch{return}}function hd(e){const t=new Map,n=r=>{const i=cd(r,e.canvasSrc,e.origin);if(!i)return;const o=t.get(i);if(o!==void 0)return o;const s=e.fetchBody(i);return t.set(i,s),s};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r){for(const i of r)n(i)},reset(){t.clear()},get size(){return t.size}}}async function md(e,t,n){try{const r=new URL(".vite/manifest.json",new URL("./",new URL(e,t))).href,i=await fetch(r);if(!i.ok)return;const o=await i.json();n(ud(o,e))}catch{}}function gd(e){try{return an(new URL(e,window.location.href).href)}catch{return an(window.location.href)}}function vd(e){X(e);const t=co(!1);if(gd(t))return;const n=hd({canvasSrc:t,origin:window.location.href,fetchBody:pd}),r=Un(t);r&&n.warm([r]);const i={"js/iframe-eblock.js":["js/discussHandlers.BuuVtU3Y.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.BuuVtU3Y.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.BuuVtU3Y.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};i?n.warm(fd(i,t)):md(t,window.location.href,s=>n.warm(s));const o=s=>{const d=s.data;if(!d||d.operationId!=="em:module-body"||!d.result)return;const a=s.source;a&&(a.postMessage({operationId:dd,for:d.result},"*"),n.take(d.data?.url??"").then(f=>{a.postMessage({operationId:d.result,data:f??null},"*")}))};window.addEventListener("message",o),e.getInstance(j)?.addDispose(()=>{window.removeEventListener("message",o),n.reset()})}var Ae=/<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,bd=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Oe=/<style\b[^>]*>[\s\S]*?<\/style>/gi,_r=/display:\s*none\s*!important/gi,Ed=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,yd=/\s*height\s*:\s*100%\s*!important\s*;?/gi,_d=/height\s*:\s*100%\s*!important/i,wd=[".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 Sd(e){return _r.lastIndex=0,(e.match(_r)||[]).length}function uo(e){const t=e.trim(),n=Sd(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=wd.filter(i=>t.includes(i)).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 Id(e){Oe.lastIndex=0;for(const t of e.matchAll(Oe))if(uo(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Td(e){let t=!1;return Oe.lastIndex=0,{html:e.replace(Oe,n=>uo(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Ad(e){return Ae.lastIndex=0,Ae.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Id(e)}function Cd(e){if(!Ad(e))return{html:e,found:!1};let t=!1,n=e;Ae.lastIndex=0,Ae.test(n)&&(Ae.lastIndex=0,n=n.replace(Ae,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(bd,""),t=!0);const r=Td(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Rd(e){return!e||!_d.test(e)?e:(Oe.lastIndex=0,e.replace(Oe,t=>t.replace(Ed,(n,r,i,o)=>`${r}${i.replace(yd,"")}${o}`)))}function fo(e){const t=Cd(e.replaceAll(`\r
1002
1002
  `,`
1003
- `));return{html:Ed(t.html),hasBrowserExtensionArtifacts:t.found}}function sn(e){return e?.getContent()??""}function oo(e,t){e?.mutate({content:Pi(t)},{source:"remote"})}function so(e){return L(e)}function ie(e,t){return e.getOrCreateInstance(t,()=>new pe)}function K(e,t){return e.getOrCreateInstance(t,()=>new pe).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 _d=class extends Error{showId;constructor(e,t){super(`[useblocks] 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}},wd=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(Q("Superseded by newer show()")),n.aborted?Promise.reject(Q(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new _d(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(Q(n.reason))})};n.addEventListener("abort",s,{once:!0});const d=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:d});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 Sd(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Id(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Si(e),n=Ii(e),r=ba(e.sandbox);t<n+r}var ao=class{_controller=new AbortController;_externalSignalDisposable=new Z;_sessionChangeListeners=new Set;_showRegistry=new wd;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Si(this._timeouts)}getSandboxTimeoutMs(e){return wi(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Ii(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=Sd(this._timeouts,e.timeouts),Id(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}abort(e){const t=e??Q("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Z}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Z,this._showRegistry.rejectAll(Q("Init session replaced")),this._controller.signal.aborted||this._controller.abort(Q("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??Q()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??Q()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Nn=(()=>{const e=new ao;return e.configure({}),e})(),Td=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 Ad(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 Cd(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():($(n),new Promise((r,i)=>{let o=!1,s,d;const l=u=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),d?.dispose(),n?.removeEventListener("abort",f),u())},f=()=>{l(()=>i(Q(n?.reason)))};if(d=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>i(new Td(t)))},t)),n?.addEventListener("abort",f)}))}var Rd=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 Pd(e,t,n){return t<=0?e:new Promise((r,i)=>{let o=!1,s;const d=l=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{d(()=>i(new Rd(n,t)))},t),e.then(l=>{d(()=>r(l))},l=>{d(()=>i(l))})})}var Dd=2,ot=Symbol("sandbox:frame-replaced");function ae(e,t,n,r,i,o,s){const d=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??On[t],f=()=>{let I=Pd(e.sendAsync(n,r),l,d);return I=ht(I,o?.signal),He(d,I,i)};if(t==="INIT_START"&&Ad(e)){const I=o?.getSandboxReadyTimeoutMs()??2e4,g=e,E=w=>{const S=Cd(g,I,o?.signal);return He("sandbox:INIT_START:ready-wait",S,i).then(()=>{if(!s||w<=0)return f();const A=s.getGeneration();let h;const c=new Promise((p,m)=>{h=s.onChange(()=>{s.getGeneration()!==A&&m(ot)})}),a=f();return a.catch(()=>{}),Promise.race([a,c]).finally(()=>h?.()).catch(p=>{if(p!==ot)throw p;return{...i},E(w-1)})})};return E(Dd)}if(!s)return f();const u=s.getGeneration();let v;const b=new Promise((I,g)=>{v=s.onChange(()=>{s.getGeneration()!==u&&g(ot)})}),y=f();return y.catch(()=>{}),Promise.race([y,b]).finally(()=>v?.()).catch(I=>{throw I===ot&&{...i},I})}var Od=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],xd=200;function Ld(e=new Set){const t=new Set;return(n,r)=>{if(!Od.some(([o,s])=>!e.has(o)&&s.test(n)))return;const i=r??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=xd&&t.clear(),t.add(i))}}function Md(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Ld()}}var kd=Md();function Ne(e){return e?.getInstance(Rs)??kd}function Nd(e){const t=ve(e),n=X(e),r=()=>e.getInstance(De)??Nn;let i,o,s=!1,d=!1;const l=async(S,A,h)=>{const c=h.generation,a=()=>h.generation!==c||h.signal.aborted||t.current()!==S||d,p=ue(n);s=!0;try{if(await ae(n,"INIT_START",N.SANDBOX_INIT_START,{guid:A},void 0,h),a())return;const{html:m,hasBrowserExtensionArtifacts:_}=io(sn(S));if(_&&ie(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),oo(S,m),await ae(n,"SET_ENTITY",N.SANDBOX_SET_ENTITY,an(sn(S),A,Ne(e).editorPolicy,S.get().version),void 0,h),a())return;await ae(n,"INITED",N.SANDBOX_INITED,{guid:A},void 0,h),i=A,o=p}finally{s=!1}},f=()=>me(t.sessionKey())?t.current():void 0,u=()=>{if(d||s)return;const S=f(),A=S?.get().docId;if(!S||!A||i===A&&o===ue(n)||!S.isReady())return;const h=r();h.signal.aborted||l(S,A,h).catch(()=>{})};let v=!1;const b=()=>{v||d||(v=!0,queueMicrotask(()=>{v=!1,u()}))};let y,I;const g=()=>{const S=f(),A=S?.get().docId;A!==I&&(y?.(),I=A,y=S?.subscribe(b)),b()},E=t.subscribe(g),w=to(n,b);g(),e.getInstance(F)?.addDispose(()=>{d=!0,w(),y?.(),E()})}var Fd=200;function jd({startVersion:e,limit:t=Fd}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const d=n.filter(f=>f.version>s);i(s);let l=o;for(const f of d){if(f.fromCanvas||f.contentReplaced||!f.changes)return null;const u=f.changes,v=[];for(const b of l){const y=Pa(b.range,u,"after");if(!y)return null;v.push({range:y,text:b.text})}l=v}return l}}}function Bd(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new re(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Ud(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Bd(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Hd(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Fn=L("canvas.sandboxFill");function lo(e){return e.getInstance(Fn)?.pipeline.isEventsLocked()===!0}function Lt(e){wt(e,{origin:"canvas-channel"})}function Gd(e){const t=ve(e),n=X(e);let r;const i=(l,f)=>{const u=l.get().docId;let v=!1,b=null,y=null;const I=jd({startVersion:l.get().version});let g=l.getContent();const E=async(c,a)=>{if(y){y.push({edits:c,rev:a});return}y=[{edits:c,rev:a}];try{do{const p=y.splice(0,y.length);await n.sendAsync(N.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev})}while(y.length)}finally{y=null}},w=(c,a)=>{const p=y?.splice(0,y.length)??[];p.length&&n.sendAsync(N.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev}).catch(Lt),n.sendAsync(N.SANDBOX_UPDATE_ENTITY,{edits:[c],guid:u,rev:l.get().version,...a!==null?{changeId:a}:{}}).catch(Lt)},S=c=>{const{guid:a,pushUndoStop:p}=c;if(a!==u)return;const m=Ua(c);let{edits:_}=c;if(m.baseRev!==null){const D=I.rebase(_,m.baseRev);if(!D){wt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),w([],m.changeId);return}_=D}const T=l.get().version;try{v=!0,b=m.changeId;const D=Ud(_,l.getContent());p===!1?f.applyWithoutHistory(D):l.mutate({changes:D},{source:lo(e)?"system":"user"})}finally{v=!1,b=null}l.get().version===T&&m.baseRev!==null&&w([],m.changeId)},A=l.subscribe(({changes:c,version:a})=>{const p=l.getContent(),m=!c?.length&&p!==g;if(g=p,I.record({version:a,changes:c,contentReplaced:m,fromCanvas:v}),!c?.length)return;const _=Hd(c);v?w(_,b):E(_,a).catch(Lt)}),h=n.addListener(N.APPLICATION_UPDATE_ENTITY,S);return()=>{A(),h.dispose()}};let o;const s=()=>{const l=t.current(),f=t.history(),u=l?.get().docId;u!==o&&(r?.(),r=void 0,o=u,l&&f&&(r=i(l,f)))},d=t.subscribe(s);s(),e.getInstance(F)?.addDispose(()=>{r?.(),d()})}var qd=300,$d=15e3,gr="em-canvas-busy-style";function zd(){if(document.getElementById(gr))return;const e=document.createElement("style");e.id=gr,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function Vd(e){const t=e.getBoundingClientRect(),n=document.createElement("div");return n.setAttribute("aria-busy","true"),Object.assign(n.style,{position:"fixed",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,cursor:"progress",display:"flex",alignItems:"center",justifyContent:"center"}),e.appendChild(n),{showSpinner(){zd(),n.style.background="rgba(128, 128, 128, 0.15)";const r=document.createElement("div");Object.assign(r.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),n.appendChild(r)},remove:()=>n.remove()}}var Kd=8e3;function Wd(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,whenShown:()=>Promise.resolve(),alignTo:()=>{},resize:()=>{},dispose:()=>{}}}var Yd=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="hidden")return t}return null};function Xd(e,t,n,r,i){const o=n.readyTimeoutMs??Kd,s=document.createElement("div");s.dataset.canvasHost=e,r&&(s.dataset.canvasPlace=r),s.style.position="fixed",s.style.overflow="hidden",s.style.visibility="hidden";const d=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(d)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=d,s.appendChild(l),t.appendChild(s),n.mark?.("created"),i||n.onCreated?.(l);const f=new Z;let u=!1,v=!1,b,y,I,g;const E=()=>{clearTimeout(g),g=setTimeout(()=>{v||(v=!0,y?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},w=()=>u?(I=Promise.resolve(),v=!0,I):(v=!1,I=new Promise((M,G)=>{b=M,y=G}),E(),I),S=()=>{if(clearTimeout(g),u=!0,v){I=Promise.resolve();return}v=!0,n.mark?.("loaded"),b?.()};l.addEventListener("load",S),f.addDispose(()=>{clearTimeout(g),l.removeEventListener("load",S)});let A;const h=()=>{A??=n.bindResizer?.(l)};let c=null,a=null,p;const m=()=>{if(!c){s.style.visibility="hidden",l.removeAttribute("id");return}n.elementId&&(l.id=n.elementId);const M=c.getBoundingClientRect(),G=a?.isConnected?a:Yd(c),H=G?G.getBoundingClientRect():null,Y=H?Math.max(M.top,H.top):M.top,be=H?Math.min(M.bottom,H.bottom):M.bottom,Ze=Math.max(0,be-Y);s.style.visibility=Ze>0?"visible":"hidden",s.style.left=`${M.left}px`,s.style.top=`${Y}px`,s.style.width=`${M.width}px`,s.style.height=`${Ze}px`,l.style.transform=`translateY(${M.top-Y}px)`};let _="",T="",D=0,R;const O=()=>{if(!c){R=void 0;return}R=window.requestAnimationFrame(O);const M=c.getBoundingClientRect(),G=a?.isConnected?a.getBoundingClientRect():void 0,H=`${Math.round(M.left)}:${Math.round(M.top)}:${Math.round(M.width)}:${Math.round(M.height)}:${G?`${Math.round(G.top)}:${Math.round(G.height)}`:"-"}`;H!==_&&(_=H,m());const Y=l.getBoundingClientRect().height;Y>0&&Y!==D&&(D=Y,c.style.height=`${Y}px`);const be=getComputedStyle(c).pointerEvents;be!==T&&(T=be,s.style.pointerEvents=be)},C=()=>{R===void 0&&c&&(R=window.requestAnimationFrame(O))},x=()=>{R!==void 0&&(window.cancelAnimationFrame(R),R=void 0)},B=()=>m();let U=[];const W=(M,G)=>{if(a=G,M&&U.length>0){const H=U;U=[],H.forEach(Y=>Y())}if(M===c){m();return}if(p?.disconnect(),p=void 0,c&&c.style.removeProperty("height"),_="",D=0,T="",c=M,!M){x(),m();return}n.onShown?.(l);try{if(typeof ResizeObserver=="function"){const H=new ResizeObserver(m);typeof H.observe=="function"&&(p=H,p.observe(M))}}catch{p=void 0}m(),h(),C()};window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),f.addDispose(()=>{p?.disconnect(),R!==void 0&&window.cancelAnimationFrame(R),window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)});const de=M=>{u=!1,M&&n.onReload?.(l);let G;v||I===void 0?G=w():(E(),G=I);try{l.contentWindow?.location.reload()}catch{l.src=d}return G};return{element:l,ready(){return I??w()},reload:()=>de(!0),reloadQuietly:()=>de(!1),get shown(){return c!==null},whenShown(){return c!==null?Promise.resolve():new Promise(M=>{U.push(M)})},alignTo(M,G){W(M,G??null)},scrollBy(M,G){for(let H=c?.parentElement??null;H;H=H.parentElement){const Y=getComputedStyle(H);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&H.scrollHeight>H.clientHeight){H.scrollBy({left:M,top:G,behavior:"instant"});return}}window.scrollBy({left:M,top:G,behavior:"instant"})},resize(){A?.resize()},dispose(){W(null,null),A?.dispose(),f.dispose(),s.remove()}}}function Jd(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,v)=>u==="email"?`email:${v??n}`:u;let o,s=[];const d=()=>{s.forEach(u=>clearTimeout(u)),s=[],o?.remove(),o=void 0},l=new Map,f=(u,v,b)=>{const y=i(u,v),I=t.get(y);if(I)return I;const g=e.resolveMount();if(!g)return Wd();const E=Xd(u,g,e,u==="email"?v??n:void 0,b);return t.set(y,E),E};return{get:u=>f(u),current:u=>f(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>f("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const v=t.get(i("email"));n=r();const b=l.get("email");u.alignTo(b?.slot??null,b?.clip??null),v?.alignTo(null)},alignSurface(u,v,b){l.set(u,{slot:v,clip:b??null}),(v?f(u):t.get(i(u)))?.alignTo(v,b??null)},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const v of t.values())if(v.element.contentWindow===u)return v}},busy(u){d();const v=u?e.resolveMount():void 0;if(!v)return;const b=Vd(v);o=b,s=[setTimeout(()=>b.showSpinner(),qd),setTimeout(d,$d)]},dispose(){d(),t.forEach(u=>u.dispose()),t.clear(),l.clear(),n="a"}}}var Qd=L("canvas.resizerBinder"),ln=L("canvas.service"),Zd={created:J.canvasCreated,loaded:J.canvasLoaded};function ec(e,t){if(e.getInstance(ln))return;const n=Jd({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:ed,elementId:t.elementId,bindResizer:i=>e.getInstance(Qd)?.(i),onCreated:i=>ut(e,i,"fresh"),onReload:i=>ut(e,i,"fresh"),onShown:i=>ut(e,i,"switch"),mark:i=>t.mark?.(Zd[i])}),r=X(e).addListener(N.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(ln,n),e.getInstance(F)?.addDispose(()=>{r.dispose(),n.dispose()})}function ut(e,t,n){const r=X(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),Fl(r))}function tc(e,t){ut(e,t,"promote")}function nc(e,t){const n=t.contentWindow;n&&X(e).greet(n)}function rc(e,t){const n=t.contentWindow;n&&X(e).forget(n)}function fe(e){return e.getInstance(ln)}function ic(e){const t=X(e),n=()=>fe(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(N.RELOAD,async()=>{await n()?.reload()}),i=t.addListener(s=>{s.data?.operation===N.SANDBOX_RESIZED&&n()?.resize()}),o=K(e,j.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(F)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose()})}var Am=L("HeadlessMode"),oc=L("HiddenMount");function sc(e){return e.getOrCreateInstance(oc,()=>ke(!1))}function vr(){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 ac(e){const t=e.getInstance(oe);let n,r;e.getInstance(F)?.addDispose(()=>{r?.remove(),r=void 0}),ec(e,{resolveMount:()=>n,resolveSrc:o=>no(o==="block"),elementId:"email_iframe",mark:o=>z(o)}),t?.watch(o=>{if(n)return;const s=o?.element;if(s instanceof HTMLElement)n=s;else if(o!==void 0)n=r??=vr();else return;fe(e)?.get("email")});let i;e.getInstance(F)?.addDispose(()=>{i?.remove(),i=void 0}),sc(e).watch(o=>{const s=fe(e);if(s){if(o){i??=vr(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var co=L("canvas.headerFlow"),br=["subject","preheader"],lc=3e3,dc={subject:N.SANDBOX_SUBJECT_UPDATE,preheader:N.SANDBOX_PREHEADER_UPDATE};function cc(e){const t=ve(e),n=X(e),r=g=>g?"remote":lo(e)?"system":"user",i=(g,{guid:E,value:w,forced:S})=>{const A=Be(t);if(!A||typeof w!="string"||E&&E!==A.get().docId)return;const h=t.forcedHeaders();if(h?.[g]&&!S&&w!==h[g])return;S&&t.endForcedHeaders();const c=A.get().attributes[g]??"";d=!0;try{vt(A,{[g]:w},{source:r(S)})}finally{d=!1}o[g]=w,ie(e,j.ON_HEADER_APPLIED_ID).fire({field:g,value:w,forced:!!S,isGenerated:w!==c&&!!w})};let o={},s,d=!1,l=Promise.resolve();const f=(g,E,w)=>{l=n.sendAsync(dc[g],{value:E,guid:Be(t)?.get().docId,...w?{force:!0,echo:!0}:{}}).catch(S=>{})};let u;e.inject(co,{whenDelivered:async()=>{await l},reassert:g=>{const E=Be(t),w=br.filter(S=>g[S]);if(!(!E||w.length===0)){d=!0;try{vt(E,Object.fromEntries(w.map(S=>[S,g[S]])),{source:"system"})}finally{d=!1}t.beginForcedHeaders({subject:g.subject??"",preheader:g.preheader??""}),clearTimeout(u),u=setTimeout(()=>t.endForcedHeaders(),lc);for(const S of w)o[S]=g[S],f(S,g[S],!0)}}});const v=()=>{s?.(),s=void 0;const g=Be(t);if(!g){o={};return}const E=g.get().attributes;o={subject:E.subject,preheader:E.preheader},s=g.subscribe(({source:w})=>{if(d)return;const S=g.get().attributes,A=t.forcedHeaders();for(const h of br){const c=S[h];c!==o[h]&&(o[h]=c,f(h,c??"",w==="system"&&A?.[h]!==void 0))}})};v();const b=t.subscribe(v),y=n.addListenerAsync(N.APPLICATION_SUBJECT_UPDATE,g=>i("subject",g)),I=n.addListenerAsync(N.APPLICATION_PREHEADER_UPDATE,g=>i("preheader",g));e.getInstance(F)?.addDispose(()=>{y.dispose(),I.dispose(),b(),s?.(),clearTimeout(u)})}function yr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function dn(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];yr(i)&&yr(o)?n[r]=dn(o,i):i!==void 0&&(n[r]=i)}return n}function uc(e,t){const n=Sn;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const i=JSON.parse(r);if(i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length>0)return dn(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?dn(n,t):n}function fc(){const e=window.localStorage.getItem(Et.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?_s:Ns;return e&&e!=="system"?e:t}function pc(){const e=window.localStorage.getItem(Et.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function hc(e){const{config:t}=e;return{operation:N.UPDATE_PREVIEW,theme:e.theme,commonStyles:uc(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}function mc(e){const t=X(e),n=e.getInstance(we),r=e.getInstance(oe),i=ve(e);let o,s="";const d=()=>{const w=n?.get()??{},S=hc({config:w,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:fc(),codeMode:pc(),appName:"useblocks"}),A=JSON.stringify(S);A!==s&&(s=A,t.send(S))},l=t.onInit(()=>{s="",d()}),f=()=>{t.isInited()&&d()},u=n?.watch(f),v=r?.watch(w=>{o=w?.commonStyles,f()});let b;const y=()=>{b?.(),b=i.current()?.subscribe(f),f()};y();const I=i.subscribe(y),g=matchMedia(Is),E=()=>f();g.addEventListener("change",E),e.getInstance(F)?.addDispose(()=>{l.dispose(),u?.dispose(),v?.dispose(),b?.(),I(),g.removeEventListener("change",E)})}var cn;(function(e){function t(i,o,s=(d,l)=>d===l){if(i===o)return!0;if(i.length!==o.length)return!1;for(let d=0;d<i.length;d++)if(!s(i[d],o[d]))return!1;return!0}e.isEqual=t;function n(i,o=s=>s){const s=new Set;return i.filter(d=>{const l=o(d);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(i=[],o=[],s=(d,l)=>d===l){const d=[],l=[],f=[];for(const u of i){const v=o.find(b=>s(u,b));v?f.push({prev:u,next:v}):l.push(u)}for(const u of o)i.find(v=>s(u,v))||d.push(u);return{added:d,removed:l,exists:f}}e.diff=r})(cn||(cn={}));function gc(e,t){return e.type===t.type&&e.key===t.key}function vc(e){const t=X(e),n=()=>e.getServices(Te)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(N.SANDBOX_ADD_EXTENSIONS,r)}),o=cs(Te),s=e.onInject(d=>{if(d!==o)return;const l=n();if(!t.isInited()){r=l;return}const{added:f,removed:u}=cn.diff(r,l,gc);if(r=l,u.length){if(u.some(v=>v.type==="script")){t.send(N.RELOAD);return}t.send(N.SANDBOX_REMOVE_EXTENSIONS,u.map(v=>v.key))}f.length&&t.send(N.SANDBOX_ADD_EXTENSIONS,f)});e.getInstance(F)?.addDispose(()=>{i.dispose(),s?.dispose()})}var bc=L("prewarm.editorVisible");function yc(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Ec(e={}){const t=e.paint??yc;let n=!1,r=!1,i=!1,o=!1,s=!1;const d=[],l=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,z(J.editorVisible);for(const f of d.splice(0))f()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){i=!0,l()},whenVisible(f){if(s){f();return}d.push(f)},contentShown:()=>i}}function _c(e){return e.getOrCreateInstance(bc,()=>Ec())}var wc=500,Sc=500,Ic=5e3;function Tc(e){const t=e.quietMs??wc,n=e.floorMs??Sc,r=e.ceilingMs??Ic;let i,o,s=0;const d=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},l=()=>{d(),e.run()},f=()=>{clearTimeout(i);const u=n-(Date.now()-s);i=setTimeout(l,Math.max(t,u))};return{start(){d(),s=Date.now(),o=setTimeout(l,r),f()},notify(){i!==void 0&&f()},cancel:d}}function Ac({attributes:e,readContent:t,docId:n,hasSession:r,serverId:i,show:o}){if(!r)return;const s={id:i??void 0,renderGuid:n,showId:o?.id,isNew:i==null,showToken:o?.token},d={...e,...s};return Object.defineProperty(d,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),d}var uo="self-init:";function Cc(e){return e.startsWith(uo)}function fo(e,t){const n=e.getActiveShowRequest();return Cc(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Rc(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t();let i="";const o=()=>e.readDocument()?sn(e.readDocument()):i,s=()=>Ne(e.container).editorPolicy,d=()=>e.readEmail(),l=()=>{const f=d();return{...f,id:e.isTemplate()||f.isNew?void 0:f.id,html:o()}};return{readContent:o,publicEmail:l,sendInitStart:()=>ae(n,"INIT_START",N.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>ae(n,"INITED",N.SANDBOX_INITED,{guid:d().renderGuid},void 0,r()),async sendContent(){const f=d(),{html:u,hasBrowserExtensionArtifacts:v}=io(f?.html||"");v&&e.events.browserExtensionDetected(),oo(e.readDocument(),u),i=u,await ae(n,"SET_ENTITY",N.SANDBOX_SET_ENTITY,an(o(),f.renderGuid,s(),e.readDocument()?.get().version),{guid:f.renderGuid,emailId:f.id??null},r())},refreshContent:()=>ae(n,"SET_ENTITY",N.SANDBOX_SET_ENTITY,an(o(),d().renderGuid,s(),e.readDocument()?.get().version),void 0,r()),sendPreheader:async()=>{const f=d();if(f.preheader!==void 0)return ae(n,"PREHEADER",N.SANDBOX_PREHEADER_UPDATE,{value:f.preheader,guid:f.renderGuid,force:!0},void 0,r())},sendSubject:async()=>{const f=d();if(f.subject!==void 0)return ae(n,"SUBJECT",N.SANDBOX_SUBJECT_UPDATE,{value:f.subject,guid:f.renderGuid,force:!0},void 0,r())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:f=>e.showFilled?.(f),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(l()),fireInit(f,u){if(!fo(t(),f)){t().getActiveShowRequest()?.showId;return}const v=d();v.id,v.renderGuid,t().completeShow(f),vt(e.readDocument(),{is_inited:!0},{source:"system"});const b=l();return u&&(b.reset=!0),e.events.inited(b)},fireEmailChanged(){e.events.emailChanged(l())},fireContentChanged(){e.events.contentChanged(o())}}}function Pc(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,d;const l=Rc({...e,waitScope:()=>({getSandboxTimeoutMs:E=>t().getSandboxTimeoutMs(E),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:d?.signal??t().signal})});let f;const u=(E,w)=>{if(f===E)return;f=E;const S=s;setTimeout(()=>{s!==S||t().signal.aborted||I(E,w).catch(()=>{})},0)},v=()=>{d?.abort(),d=void 0};let b;const y=()=>{const E=t().signal;E!==b&&(b?.removeEventListener("abort",v),b=E,E.addEventListener("abort",v))};async function I(E,w){const S=++s;v(),d=new AbortController,y();const A=()=>s!==S,h=l.readTarget(),c=t().generation,a=()=>c===t().generation&&!t().signal.aborted,p=w?"init:reset-":"init:";if(!w){const T=l.publicEmail();T?.id,T?.renderGuid,T?.preheader}let m=!1,_=!1;try{n=!0,await l.sendInitStart(),l.fireWillInit(),await(w?l.refreshContent():l.sendContent()),m=!0,w||l.publicEmail()?.id;try{await l.sendPreheader()}catch(T){`${p}`,String(T)}try{await l.sendSubject()}catch(T){`${p}`,String(T)}if(A()||l.showFilled(h),await l.sendInited(),_=!0,i===E){const T=e.readSandboxGeneration?.()??o;T!==void 0&&(r=T)}await l.revealFilled()}catch(T){throw A()||(`${p}`,{...e.describeSurface?.(),error:String(T)},void 0),!A()&&fo(t(),E)&&t().failShow(E,T),T}finally{g(E,w,p,{superseded:A(),sessionGeneration:c,contentApplied:m,sandboxInitedAcked:_,commit:a()})}}function g(E,w,S,A){const{superseded:h,contentApplied:c,sandboxInitedAcked:a}=A;if(h){`${S}`;return}a&&A.commit?l.fireInit(E,w||void 0):a?(`${S}`,A.sessionGeneration,t().generation,t().signal.aborted,void 0):c?(`${S}`,void 0):(`${S}`,void 0),n=!1,d=void 0,!a&&i===E&&(i=void 0,r===o&&(r=void 0)),!a&&c&&u(E,w)}return{channel:l,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:E=>{r=E},lastCorrelation:()=>i,markCorrelation:E=>{i=E},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:E=>{o=E},fill:E=>I(E,!1),refill:E=>I(E,!0),stop:()=>{s+=1,v(),n=!1,b?.removeEventListener("abort",v),b=void 0}}}function Dc(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:po(e,n)}function po(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Oc(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=u=>{const v=n(),b=i();if(!Dc(v,u,b)){u.showId,u.navId,u.emailId,v?.id,v?.showId,v?.renderGuid;return}u.showId,v?.id,v?.renderGuid,t.markFilled(o()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{s(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&s(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=o();if(t.filledGeneration()===u)return;const v=n(),b=i();if(!v?.renderGuid||!po(v,b))return;const y=`${uo}${v.renderGuid}`;t.markFilled(u),t.markCorrelation(y);const I=r()?.isReady()===!0;v.id,v.renderGuid,(I?g=>t.refill(g):g=>t.fill(g))(y).catch(()=>{t.lastCorrelation()===y&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id}}}function xc(e){return e??""}function Lc(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Mc(e){const t=ve(e),n=X(e),r=()=>me(t.sessionKey())?void 0:t.current(),i=()=>{const P=r();return Ac({attributes:P?.get().attributes??{},readContent:()=>P?.getContent(),docId:P?.get().docId,hasSession:!!P,serverId:P?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(De)??Nn;let s={},d=!1;const l=e.getInstance(oe)?.watch(P=>{d=!!P?.element});let f=!1,u=!1,v=!1,b=0;const y=()=>{const P=fe(e);if(!P)return;const V=++b,q=P.spare();return q&&rc(e,q.element),(q?q.reloadQuietly():P.ensureSpare()?.ready())?.then(()=>{if(V!==b)return;f=!0;const ne=P.spare();ne&&nc(e,ne.element),v&&(v=!1,T(),W())})},I=Tc({run:()=>{v||y()?.catch(()=>{})}}),g=()=>{_c(e).noteContentShown(),!f&&!v&&I.start()};let E=!1;const A=Pc({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const P=fe(e);return E&&P&&(E=!1,I.start()),d?P?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:P=>{const V=fe(e),q=V?.spare()?.element.contentWindow;u&&V&&q&&P===q&&(u=!1,V.promote(),V.busy(!1),E=!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>ue(n),describeSurface:()=>({canvasPath:_,promoted:u,spareClean:f,handshake:n.isInited(),generation:ue(n)}),events:{willInit:P=>{ie(e,j.WILL_EMAIL_INIT_ID).fire(P)},inited:P=>{g(),ie(e,j.ON_EMAIL_INIT_ID).fire(P)},contentChanged:P=>{ie(e,j.ON_CONTENT_CHANGED_ID).fire(P)},emailChanged:P=>{ie(e,j.ON_EMAIL_CHANGED_ID).fire(P)},browserExtensionDetected:()=>{ie(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),h=Oc({pipeline:A,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>ue(n)});let c="",a="",p="";const m=P=>P.length>0;let _="none";const T=()=>{const P=fe(e)?.spare();P&&(n.send({operation:N.SANDBOX_LOCK_EDIT,data:!0}),f=!1,u=!0,tc(e,P.element))},D=(P,V)=>{const q=fe(e);if(!q)return!0;const ne=q.spare(),ye=ne&&f?"spare":"prepare";if(_=ye,q.busy(!0),ne&&f)return T(),!0;I.cancel(),n.send({operation:N.SANDBOX_LOCK_EDIT,data:!0});const Ee=y();if(Ee===void 0)return _="reload",q.busy(!1),q.peek("email")?.reload(),!0;v=!0;const Ct=b;return Ee.catch(()=>{!v||Ct!==b||(v=!1,_="reload",q.busy(!1),q.peek("email")?.reload())}),!1},R=()=>{be(),A.noteSandboxGeneration(ue(n));const P=i(),V=Lc(P?.renderGuid,P?.showId,P?.id,s.emailId),q=xc(P?.renderGuid);if(q!==a){const Ee=m(a),Ct=a;a=q,Ee&&D(Ct,q)}if(v)return;V!==c&&(c=V,h.showRequestIdentityChanged());const ne=r(),ye=`${V}|${ne?.get().docId??""}|${ue(n)}`;ye!==p&&ne?.isReady()===!0&&(p=ye,h.selfInitChanged()),h.saasChanged(),B()};let O=!1,C="",x="";const B=()=>{const P=i();if(!P?.renderGuid)return;const V=A.channel.readContent(),q=JSON.stringify([P.preheader,P.common_styles,P.meta,P.subject,P.utm_parameters?.utm_campaign??"",P.utm_parameters?.utm_content??"",P.utm_parameters?.utm_medium??"",P.utm_parameters?.utm_source??"",P.utm_parameters?.utm_term??""]),ne=O&&V!==x,ye=O&&q!==C;if(O=!0,x=V,C=q,A.isEventsLocked())return;const Ee={...P,id:s.isTemplate||P.isNew?void 0:P.id,html:V};if(ne){ie(e,j.ON_CONTENT_CHANGED_ID).fire(V),ie(e,j.ON_EMAIL_CHANGED_ID).fire(Ee);return}ye&&P.is_inited&&ie(e,j.ON_EMAIL_CHANGED_ID).fire(Ee)};let U=!1;const W=()=>{U||(U=!0,queueMicrotask(()=>{U=!1,R()}))};e.inject(Fn,{pipeline:A,setRoute:P=>{P.emailId===s.emailId&&!!P.isTemplate==!!s.isTemplate||(s=P,W())}});let de,M;const G=()=>{const P=r()?.get().docId;P!==M&&(de?.(),M=P,de=r()?.subscribe(W)),W()};let H,Y;const be=()=>{const P=e.getInstance(De);!P||P===H||(Y?.(),H=P,Y=P.onShowRequested(V=>h.showRequested(V)))},Ze=n.addListener(P=>{P.data?.operation===N.SANDBOX_RESIZED&&I.notify()}),Yo=t.subscribe(G),Xo=to(n,W);G(),e.getInstance(F)?.addDispose(()=>{l?.dispose(),Y?.(),Xo(),Yo(),de?.(),Ze.dispose(),I.cancel(),A.stop()})}function kc(){return Ls!=="useblocks"}var un={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:"",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},Nc={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:"",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}},Er=un,Fc=["freeUserBlocks","blocks"],ho={};function jc(e){ho=e}var mo=e=>Fc.includes(e)?Er:ho[e]??Er,fn={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:"",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},Bc={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:"",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},Uc={...fn,config:{...fn.config,imageCenterFileManagerView:!1}};jc({pro:Nc,editor:Bc,simple:kc()?fn:Uc,freeUserBlocks:un,blocks:un});var _r=new Set;function Hc(){return window.localStorage.getItem(Et.em_color_scheme)??void 0}function Gc(e){return _r.add(e),e(Hc()),{dispose(){_r.delete(e)}}}function jn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function qc(e,t){return t.modeDefaults(jn(e,t.fallbackMode))}function $c(e,t){const n=jn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function zc(e,t){const n=jn(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Vc(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Kc(e){return is(e.map(t=>t?.resourceProxy))}function Wc(e){return ns(e.map(t=>t?.resourceProxyPolicy))}function Yc(e){return ms(e.map(t=>t?.backendProxy))}function Xc(e){return li(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Jc(e,t){return[e.base,qc(e,t),e.profile,e.serverSide,$c(e,t.fallbackMode),e.user,zc(e,t.fallbackMode),e.local]}function Mt(e,t){const n=Jc(e,t),r=li(n),i=Vc(n);i!==void 0&&(r.fileManager=i);const o=Kc(n);o!==void 0&&(r.resourceProxy=o);const s=Wc(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const d=Yc(n);d!==void 0&&(r.backendProxy=d);const l=Xc(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}var Qc=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function wr(e){return e==="server"?"serverSide":e}function Zc({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=ke();let o={kind:"pending"},s;const d=new Promise(b=>{s=b}),l=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function f(){o.kind!=="pending"&&i.set(Mt(r,e))}function u(b){if(o.kind!=="pending")return;clearTimeout(l),o=b;const y=Mt(r,e);i.set(y),s(y)}function v(b,y){r[wr(b)]=y,b==="server"&&o.kind==="pending"?u({kind:"applied"}):f()}return{watch:b=>i.watch(b),select:b=>i.select(b),get:()=>i.get(),ready:()=>d,state:()=>o,layers:()=>({...r}),bootstrap(){const b=Mt(r,e);return Object.fromEntries(Qc.map(y=>[y,b[y]]))},merge(b,y){v(y,{...r[wr(y)],...b})},replace(b,y){v(y,b)},setMode(b){r.user={...r.user,mode:b},f()},setAdvancedConfigs(b){r.advancedConfigs=b,f()},serverAbsent(b){u({kind:"absent",reason:b})},applyServerResponse(b){o.kind==="pending"&&v("server",{...r.serverSide,...b})},dispose(){clearTimeout(l)}}}var eu=5e3,tu="blocks";function nu(){return{...mo(tu)?.config,mergeTags:void 0}}function ru(e,t){e.getInstance(oe)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function iu(e,t){let n;Vi(e).watch(({profile:r})=>{const i=`${r?.theme??""}|${r?.locale??""}`;if(i===n)return;n=i;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function ou(e,t){let n=null;const r=Gc(i=>{const o=typeof i=="string"&&i?i:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(F)?.addDisposable(r)}async function su(e,t){if(e.getInstance(Pn)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Pe);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function au(e){e.injectFactory(we,(t,n)=>{if(n)return n;const r=Zc({base:nu(),env:{modeDefaults:i=>mo(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:eu});return ru(e,r),iu(e,r),ou(e,r),su(e,r),e.getInstance(F)?.addDisposable(r),r},!0)}var Re=class extends Z{_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 k(e,t,n){const r=ts(e);return(i,o,s)=>{const d=r(async l=>{const f=t?t(l):l;s&&i.bind(s);const u=await i(f);return n?n(u):u},o,s);return()=>d.dispose()}}var lu=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new en;this.handleDestroy=k(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Re(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{}}},Bn=L("DestroyableService");function du(e){e.injectFactory(Bn,()=>{const t=e.getInstance(F);if(!t)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new lu({lifetime:t,options:e.getInstance(oe),getInstance:()=>e.getInstance(_t),release:()=>Ds(e.getInstance(Ts)??e)})},!0)}function cu(e){const t=e.getInstance(Bn);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var uu=1e3;function go(e,t,n=uu,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 i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const s of i)if(!go(e[s],t[s],n,r+1))return!1;return!0}return!1}function Ge(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 i=t[r],o=e[r];go(i,o)||(n[r]=i)}return n}var fu=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail не ответил за ${e}ms — письмо не сохранено`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},pu=({source:e,emailtags:t,group:n,tags:r,...i})=>i,hu=()=>Ti();async function mu({emails:e},t){const n=hu();let r;try{return await Promise.race([e.notifySave(t),new Promise((i,o)=>{r=setTimeout(()=>{const s=new fu(n);t.value.id,o(s)},n)})])}finally{r!==void 0&&clearTimeout(r)}}function gu(e){const{emails:t}=e,n=async(r,i)=>{const o=pu(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),d=s?{...s,...o}:o,l=await mu(e,{prev:s,patch:s?Ge(s,o):o,value:d,source:i.source??""}),f=String(l.id??r??le()),u=l.id===void 0?{...l,id:f}:l;return await t.cache.addOrUpdate(f,()=>u)};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const i=await n(void 0,r);return i?.renderGuid?i:{...i,renderGuid:le()}},async updateEmail(r,i){return await n(r,i)}}}var kt=20,vu=({source:e,emailtags:t,group:n,tags:r,...i})=>i;function bu({revisions:e,revisionsByEmail:t}){const n=async(r,i)=>(t.clear(),await t.get(r,{page:i}),(await e.cache.values()??[]).filter(o=>String(o?.parent)===String(r)));return{async readRevisions(r,i=1){const o=await n(r,i);return{revisions:o.slice(kt*(i-1),kt*i),page:i,hasMore:o.length>kt*i}},async readAutosave(r){return qa(await n(r,1))},async saveAutosave(r,i){const o=vu(i);return await e.create({...o,parent:r,modified:new Date().toString()})}}}var yu=class extends js{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}},Eu=class extends pe{};var Sr=class extends Z{_items=new Map;_onChangeEmitter=new Es;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 i=await t(n);return mt(n,i)||this._onChangeEmitter.fire(),i}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(([i,o])=>i)),r=(await this.entries()).filter(([i,o])=>!n.has(i));for(const[i,o]of e)t.push(this.addOrUpdate(i,()=>o)),n.add(i);for(const[i]of r)t.push(this.remove(i));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 _u(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let d=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(f=>{for(const u of l){const v=f[u],b=t[u];return u==="id"||typeof v!="string"?v===b:typeof b=="string"&&v.startsWith(b)}return!0}),d=e.length}return r&&(e=e.sort((l,f)=>(l[r]>f[r]?1:f[r]>l[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:d,total:s,totalPages:Math.ceil(d/o)}}function wu(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 i=t.get(r.id)||{};t.set(r.id,{...i,...r})}return[...t].map(([n,r])=>r)}function Su(e,t){return Ir(e)&&Ir(t)?String(e)===String(t):e===t}function Ir(e){return typeof e=="string"||typeof e=="number"}var Iu=class extends Z{_cache=new Sr;_readEmitter=new pe;_saveEmitter=this.addDisposable(new yu);_removeEmitter=this.addDisposable(new Eu);_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)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new Z);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Sr),i=n.addDisposable(new pe);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const l=wu(await i.fire(o))||[];for(const f of l)f[e]=o,await this._cache.add(f.id,f);return l}catch{return[]}});const d=(await this._cache.values()||[]).filter(l=>{const f=l[e];return f==null||Su(f,o)});return _u(d,s)},first(o,s={}){return t.get(o,{...s,page:1,pageSize:1}).then(({data:d})=>d[0])},handleRead:i.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=le()),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 i=>{const o=i?{...i,...t}:t;if(!r)return t=i?Ge(i,t):t,await this._saveEmitter.fire({prev:i,patch:t,value:o,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 Je(e){const t=L(e);return n=>n.getOrCreateInstance(t,()=>new Iu)}function Tu(e){const t=e.getInstance(F);if(!t)throw new Error("Failed");return t}function Tr(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Au(e,t,n){return e&&!Tr(t)&&Tr(e)?{...n,meta:e.meta}:n}var vo=Je("plugin.dataSource.emails"),bo=Je("plugin.dataSource.emailRevisions"),Ar=L("emailDocuments.provided");function Cu(e){const t=vo(e),n=bo(e),r=n.byForeignKey("parent");return e.getInstance(Ar)?{emails:t,emailRevisions:n}:(e.inject(Ar,!0),dl(e,gu({emails:t})),pl(e,bu({revisions:n,revisionsByEmail:r})),Tu(e).addDisposable(t.onSave(({prev:i,patch:o,value:s})=>Au(i,o,s),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function Cr(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 Ru(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Pu="po",st=null;function Du(){const e=typeof window.__useblocks__<"u"?window.__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([Pu],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Ou(){return st===null&&(st=Du().catch(e=>{throw st=null,e})),st}async function yo(e){if(typeof e=="object")return Un(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?xu(t):Lu(t)}function Un(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function xu(e){try{return Un(JSON.parse(e))}catch{return}}var Rr=!1;async function Lu(e){try{return Un((await Ou()).parsePoCatalog(e))}catch{Rr||(Rr=!0);return}}var Mu="em_locale",ku="em_ant_locale",Nu="locale",Fu="ant_locale";function Hn(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Eo(e,t){const n=Hn(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function ju(){return Hn("em_locale")??Eo(Nu,"em_locale")}function Pr(e){try{localStorage.setItem(Mu,JSON.stringify(e))}catch{}}function Bu(){return Hn("em_ant_locale")??Eo(Fu,"em_ant_locale")}function Uu(e,t){try{localStorage.setItem(ku,JSON.stringify({id:e,data:t}))}catch{}}var Hu=8e3;function Gu(e,t){const n=e,r=t,i=Object.keys(n).filter(o=>o!=="");return i.length!==Object.keys(r).filter(o=>o!=="").length?!1:i.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function qu(e){const t=ju(),n=Bu();let r={ready:!1},i;const o=ke(r);let s=0;const d=E=>{r={...r,...E},o.set(r)},l=()=>{r.ready||d({ready:!0})},f=setTimeout(l,e.unlockAfterMs??Hu),u=E=>E!==s;let v;async function b(E,w){if(n?.id===E&&n.data&&d({antd:n.data}),!v)return;const S=await v(E).catch(()=>{});!S||u(w)||(d({antd:S}),Uu(E,S))}async function y(E,w){const S=await e.askHost(E).catch(()=>null);if(u(w))return!0;if(S==null)return!1;const A=await yo(S);return u(w)||(A&&d({catalog:A}),l()),!0}async function I(E,w){const S=await e.readList();if(u(w))return;if("error"in S){d({failure:{kind:"GET_LOCALES_ERROR",error:S.error}}),l();return}const A=S.data.find(c=>c.locale===E);if(!A){Ru("em_locale")&&d({catalog:void 0}),l();return}if(Cr(t,A)&&(!i||i.catalog===t?.data)){l();return}if(i?.entry&&r.catalog===i.catalog&&Cr(i.entry,A)){Pr(i.entry),l();return}const h=await e.readCatalog(E);if(!u(w)){if("error"in h){d({failure:{kind:"GET_LOCALE_ERROR",error:h.error}}),l();return}h.data&&(i?.id===E&&r.catalog===i.catalog&&Gu(i.catalog,h.data)||d({catalog:h.data}),Pr({id:E,time:A.updatedAt||Math.floor(Date.now()/1e3),hash:A.contentHash,data:h.data})),l()}}async function g(E,w){if(!await y(E,w)){if(!u(w)&&(i?.id===E&&r.catalog===i.catalog||E==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await I(E,w)}}return{set(E){if(!E||E===r.id)return;const w=s+=1;d({id:E,failure:void 0});const S=i?.id===E&&r.catalog===i.catalog;(i&&!S&&r.catalog===i.catalog||E==="en_US"&&r.catalog)&&d({catalog:void 0}),t?.id===E&&t.data&&(d({catalog:t.data}),l()),b(E,w),g(E,w)},prime(E,w,S){r.id||r.catalog||!w||(i=t?.id===E&&t.data&&(!S||t.time>=S.time)?{id:E,catalog:t.data}:{id:E,catalog:w,entry:S?{id:E,time:S.time,hash:S.hash,data:w}:void 0},d({catalog:i.catalog}))},useAntdLoader(E){v=E,r.id&&b(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(f)}}var $u=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})},zu=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:i,format:o,baseUrl:s,cancelToken:d,...l})=>{const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(l,f),v=i&&this.toQueryString(i),b=this.contentFormatters[r||"application/json"],y=o||u.format;return this.customFetch(`${s||this.baseUrl||""}${n}${v?`?${v}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(d?this.createAbortSignal(d):u.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async I=>{const g=I;g.data=null,g.error=null;const E=y?I.clone():I,w=y?await E[y]().then(S=>(g.ok?g.data=S:g.error=S,g)).catch(S=>(g.error=S,g)):g;return d&&this.abortControllers.delete(d),w})}},Vu=L("rest.v2.transport"),Dr=Symbol("rest.v2.secureRequest");function Ku(e){return e.getOrCreateInstance(Vu,()=>{const t=e.getInstance(ai)?.execute||fetch;return new zu({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[Dr]:!0}),customFetch:(n,r={})=>{const{[Dr]:i,...o}=r;return t(n,{...o,[as]:i!==!0})}})})}function Wu(e,t){const n=Ku(e);return Object.assign({},...t.map(r=>new r(n)))}function Or(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function _o(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Or(n.details,"wp_code")??n.code,message:Or(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 wo(e){return!e.ok||!!e.error}function Yu(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function So(){return Yu(Et.em_translations_v2)??!0}function Xu(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Ju(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Qu(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],i=r[0];return typeof i=="string"&&i!==""&&t.push({locale:i,updatedAt:Xu(r[1])}),t},[]):[]}function Zu(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Ju(n.updated_at),contentHash:n.content_hash}),t),[])}function Io(e){return Wu(e,[$u])}function yt(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function pn(e){return!e.ok||e.error!=null}function hn(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Nt(e){return{data:await yo(e)??null}}async function ef(e){if(So())try{const n=await Io(e).localesList();return wo(n)?{error:_o(n)}:{data:Zu(n.data)}}catch(n){return yt(n)}const t=ci(e,[gi]);try{const n=await t.get_translations2({file:"react_app"});return pn(n)?hn(n):{data:Qu(n.data)}}catch(n){return yt(n)}}async function tf(e,t){if(So())try{const r=await Io(e).jsonList({locale:t});return wo(r)?{error:_o(r)}:Nt(r.data)}catch(r){return yt(r)}const n=ci(e,[gi]);try{const r=await n.get_translations3({id:t,file:"react_app"});return pn(r)?hn(r):Nt(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return pn(r)?hn(r):Nt(r.data)}catch(r){return yt(r)}}}var ze=L("locale.service");function nf(e){if(e.getInstance(ze))return;const t=qu({readList:()=>ef(e),readCatalog:n=>tf(e,n),askHost:async n=>(await ie(e,j.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(he)});e.inject(ze,t),e.getInstance(F)?.addDispose(()=>t.dispose())}function rf(e){const t=e.getInstance(we);if(!t)return;const n=e.getInstance(ze);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i));e.getInstance(F)?.addDisposable(r)}var of="user_id",sf="project_id",xr=L("rest.identityHeadersProvided");function af(e){if(e.getInstance(xr))return;e.inject(xr,!0);let t;e.getInstance(oe)?.watch(n=>{t=n}),e.addService(Tn,{execute(n,r){if(r?.public)return;const i=t?.user?.id??Ki(e).profile?.id;i!=null&&i!==""&&n.headers.set(of,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(sf,String(o))}})}function lf(e){if(!e)return!1;try{return e.getInstance(he)!==void 0}catch{return!1}}var df="Invalid standaloneKey.",Cm=L("StandaloneMockGuard");function cf(){const e=new Error(df);return e.name="InvalidStandaloneKeyError",e}function uf(e){e.addService(Tn,{execute:()=>{if(lf(e))throw cf()}})}function ff(e){ys(e),uf(e)}function pf(e){const t=new ao;e.inject(De,t);let n;const r=e.getInstance(oe)?.watch(o=>{o&&(o.signal!==void 0&&(n=o.signal),t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...n!==void 0?{signal:n}:{}}))}),i=e.getInstance(F);r&&i?.addDisposable(r),i?.addDispose(()=>{t.abort()})}var hf=Je("plugin.dataSource.blocks"),mf=Je("plugin.dataSource.blockRevisions"),gf=Je("plugin.dataSource.comments"),vf=so(),bf=so(),To=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1003
+ `));return{html:Rd(t.html),hasBrowserExtensionArtifacts:t.found}}function ln(e){return e?.getContent()??""}function po(e,t){e?.mutate({content:Ni(t)},{source:"remote"})}function ho(e){return L(e)}function oe(e,t){return e.getOrCreateInstance(t,()=>new pe)}function K(e,t){return e.getOrCreateInstance(t,()=>new pe).event}function dn(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Pd=class extends Error{showId;constructor(e,t){super(`[useblocks] 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}},Dd=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(Z("Superseded by newer show()")),n.aborted?Promise.reject(Z(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new Pd(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(Z(n.reason))})};n.addEventListener("abort",s,{once:!0});const d=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:d});for(const a of this._listeners)a(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 Od(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function xd(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Pi(e),n=Di(e),r=Aa(e.sandbox);t<n+r}var mo=class{_controller=new AbortController;_externalSignalDisposable=new ee;_sessionChangeListeners=new Set;_showRegistry=new Dd;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Pi(this._timeouts)}getSandboxTimeoutMs(e){return Ri(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Di(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=Od(this._timeouts,e.timeouts),xd(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}abort(e){const t=e??Z("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ee}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ee,this._showRegistry.rejectAll(Z("Init session replaced")),this._controller.signal.aborted||this._controller.abort(Z("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??Z()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??Z()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Hn=(()=>{const e=new mo;return e.configure({}),e})(),Ld=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 Md(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 kd(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():($(n),new Promise((r,i)=>{let o=!1,s,d;const a=u=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),d?.dispose(),n?.removeEventListener("abort",f),u())},f=()=>{a(()=>i(Z(n?.reason)))};if(d=e.onInit(()=>{e.isInited()&&e.getTarget()&&a(()=>r())}),e.isInited()&&e.getTarget()){a(()=>r());return}t>0&&(s=setTimeout(()=>{a(()=>i(new Ld(t)))},t)),n?.addEventListener("abort",f)}))}var Nd=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 Fd(e,t,n){return t<=0?e:new Promise((r,i)=>{let o=!1,s;const d=a=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),a())};s=setTimeout(()=>{d(()=>i(new Nd(n,t)))},t),e.then(a=>{d(()=>r(a))},a=>{d(()=>i(a))})})}var jd=2,st=Symbol("sandbox:frame-replaced");function de(e,t,n,r,i,o,s){const d=`sandbox:${t}`,a=o?.getSandboxTimeoutMs(t)??Nn[t],f=()=>{let I=Fd(e.sendAsync(n,r),a,d);return I=pt(I,o?.signal),He(d,I,i)};if(t==="INIT_START"&&Md(e)){const I=o?.getSandboxReadyTimeoutMs()??2e4,g=e,y=_=>{const S=kd(g,I,o?.signal);return He("sandbox:INIT_START:ready-wait",S,i).then(()=>{if(!s||_<=0)return f();const A=s.getGeneration();let h;const c=new Promise((p,m)=>{h=s.onChange(()=>{s.getGeneration()!==A&&m(st)})}),l=f();return l.catch(()=>{}),Promise.race([l,c]).finally(()=>h?.()).catch(p=>{if(p!==st)throw p;return{...i},y(_-1)})})};return y(jd)}if(!s)return f();const u=s.getGeneration();let v;const b=new Promise((I,g)=>{v=s.onChange(()=>{s.getGeneration()!==u&&g(st)})}),E=f();return E.catch(()=>{}),Promise.race([E,b]).finally(()=>v?.()).catch(I=>{throw I===st&&{...i},I})}var Bd=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Ud=200;function Hd(e=new Set){const t=new Set;return(n,r)=>{if(!Bd.some(([o,s])=>!e.has(o)&&s.test(n)))return;const i=r??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=Ud&&t.clear(),t.add(i))}}function Gd(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Hd()}}var qd=Gd();function ke(e){return e?.getInstance(Fs)??qd}function $d(e){const t=ve(e),n=X(e),r=()=>e.getInstance(De)??Hn;let i,o,s=!1,d=!1;const a=async(S,A,h)=>{const c=h.generation,l=()=>h.generation!==c||h.signal.aborted||t.current()!==S||d,p=ue(n);s=!0;try{if(await de(n,"INIT_START",F.SANDBOX_INIT_START,{guid:A},void 0,h),l())return;const{html:m,hasBrowserExtensionArtifacts:w}=fo(ln(S));if(w&&oe(e,B.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),po(S,m),await de(n,"SET_ENTITY",F.SANDBOX_SET_ENTITY,dn(ln(S),A,ke(e).editorPolicy,S.get().version),void 0,h),l())return;await de(n,"INITED",F.SANDBOX_INITED,{guid:A},void 0,h),i=A,o=p}finally{s=!1}},f=()=>me(t.sessionKey())?t.current():void 0,u=()=>{if(d||s)return;const S=f(),A=S?.get().docId;if(!S||!A||i===A&&o===ue(n)||!S.isReady())return;const h=r();h.signal.aborted||a(S,A,h).catch(()=>{})};let v=!1;const b=()=>{v||d||(v=!0,queueMicrotask(()=>{v=!1,u()}))};let E,I;const g=()=>{const S=f(),A=S?.get().docId;A!==I&&(E?.(),I=A,E=S?.subscribe(b)),b()},y=t.subscribe(g),_=lo(n,b);g(),e.getInstance(j)?.addDispose(()=>{d=!0,_(),E?.(),y()})}var zd=200;function Vd({startVersion:e,limit:t=zd}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const d=n.filter(f=>f.version>s);i(s);let a=o;for(const f of d){if(f.fromCanvas||f.contentReplaced||!f.changes)return null;const u=f.changes,v=[];for(const b of a){const E=Fa(b.range,u,"after");if(!E)return null;v.push({range:E,text:b.text})}a=v}return a}}}function Kd(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new ie(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Wd(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Kd(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Yd(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Gn=L("canvas.sandboxFill");function go(e){return e.getInstance(Gn)?.pipeline.isEventsLocked()===!0}function Lt(e){wt(e,{origin:"canvas-channel"})}function Xd(e){const t=ve(e),n=X(e);let r;const i=(a,f)=>{const u=a.get().docId;let v=!1,b=null,E=null;const I=Vd({startVersion:a.get().version});let g=a.getContent();const y=async(c,l)=>{if(E){E.push({edits:c,rev:l});return}E=[{edits:c,rev:l}];try{do{const p=E.splice(0,E.length);await n.sendAsync(F.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev})}while(E.length)}finally{E=null}},_=(c,l)=>{const p=E?.splice(0,E.length)??[];p.length&&n.sendAsync(F.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev}).catch(Lt),n.sendAsync(F.SANDBOX_UPDATE_ENTITY,{edits:[c],guid:u,rev:a.get().version,...l!==null?{changeId:l}:{}}).catch(Lt)},S=c=>{const{guid:l,pushUndoStop:p}=c;if(l!==u)return;const m=Wa(c);let{edits:w}=c;if(m.baseRev!==null){const O=I.rebase(w,m.baseRev);if(!O){wt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),_([],m.changeId);return}w=O}const T=a.get().version;try{v=!0,b=m.changeId;const O=Wd(w,a.getContent());p===!1?f.applyWithoutHistory(O):a.mutate({changes:O},{source:go(e)?"system":"user"})}finally{v=!1,b=null}a.get().version===T&&m.baseRev!==null&&_([],m.changeId)},A=a.subscribe(({changes:c,version:l})=>{const p=a.getContent(),m=!c?.length&&p!==g;if(g=p,I.record({version:l,changes:c,contentReplaced:m,fromCanvas:v}),!c?.length)return;const w=Yd(c);v?_(w,b):y(w,l).catch(Lt)}),h=n.addListener(F.APPLICATION_UPDATE_ENTITY,S);return()=>{A(),h.dispose()}};let o;const s=()=>{const a=t.current(),f=t.history(),u=a?.get().docId;u!==o&&(r?.(),r=void 0,o=u,a&&f&&(r=i(a,f)))},d=t.subscribe(s);s(),e.getInstance(j)?.addDispose(()=>{r?.(),d()})}var Jd=300,Qd=15e3,wr="em-canvas-busy-style";function Zd(){if(document.getElementById(wr))return;const e=document.createElement("style");e.id=wr,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function ec(e){const t=e.getBoundingClientRect(),n=document.createElement("div");return n.setAttribute("aria-busy","true"),Object.assign(n.style,{position:"fixed",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,cursor:"progress",display:"flex",alignItems:"center",justifyContent:"center"}),e.appendChild(n),{showSpinner(){Zd(),n.style.background="rgba(128, 128, 128, 0.15)";const r=document.createElement("div");Object.assign(r.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),n.appendChild(r)},remove:()=>n.remove()}}var tc=8e3;function nc(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,whenShown:()=>Promise.resolve(),alignTo:()=>{},resize:()=>{},dispose:()=>{}}}var rc=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="hidden")return t}return null};function ic(e,t,n,r,i){const o=n.readyTimeoutMs??tc,s=document.createElement("div");s.dataset.canvasHost=e,r&&(s.dataset.canvasPlace=r),s.style.position="fixed",s.style.overflow="hidden",s.style.visibility="hidden";const d=n.resolveSrc(e),a=document.createElement("iframe");a.setAttribute("sandbox",n.resolveSandbox(d)),a.setAttribute("allow","clipboard-read; clipboard-write"),a.setAttribute("title","Email content"),a.style.width="100%",a.style.border="0",a.style.display="block",a.style.minHeight="600px",a.src=d,s.appendChild(a),t.appendChild(s),n.mark?.("created"),i||n.onCreated?.(a);const f=new ee;let u=!1,v=!1,b,E,I,g;const y=()=>{clearTimeout(g),g=setTimeout(()=>{v||(v=!0,E?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},_=()=>u?(I=Promise.resolve(),v=!0,I):(v=!1,I=new Promise((M,G)=>{b=M,E=G}),y(),I),S=()=>{if(clearTimeout(g),u=!0,v){I=Promise.resolve();return}v=!0,n.mark?.("loaded"),b?.()};a.addEventListener("load",S),f.addDispose(()=>{clearTimeout(g),a.removeEventListener("load",S)});let A;const h=()=>{A??=n.bindResizer?.(a)};let c=null,l=null,p;const m=()=>{if(!c){s.style.visibility="hidden",a.removeAttribute("id");return}n.elementId&&(a.id=n.elementId);const M=c.getBoundingClientRect(),G=l?.isConnected?l:rc(c),H=G?G.getBoundingClientRect():null,Y=H?Math.max(M.top,H.top):M.top,be=H?Math.min(M.bottom,H.bottom):M.bottom,et=Math.max(0,be-Y);s.style.visibility=et>0?"visible":"hidden",s.style.left=`${M.left}px`,s.style.top=`${Y}px`,s.style.width=`${M.width}px`,s.style.height=`${et}px`,a.style.transform=`translateY(${M.top-Y}px)`};let w="",T="",O=0,k;const W=()=>{if(!c){k=void 0;return}k=window.requestAnimationFrame(W);const M=c.getBoundingClientRect(),G=l?.isConnected?l.getBoundingClientRect():void 0,H=`${Math.round(M.left)}:${Math.round(M.top)}:${Math.round(M.width)}:${Math.round(M.height)}:${G?`${Math.round(G.top)}:${Math.round(G.height)}`:"-"}`;H!==w&&(w=H,m());const Y=a.getBoundingClientRect().height;Y>0&&Y!==O&&(O=Y,c.style.height=`${Y}px`);const be=getComputedStyle(c).pointerEvents;be!==T&&(T=be,s.style.pointerEvents=be)},R=()=>{k===void 0&&c&&(k=window.requestAnimationFrame(W))},C=()=>{k!==void 0&&(window.cancelAnimationFrame(k),k=void 0)},D=()=>m();let x=[];const U=(M,G)=>{if(l=G,M&&x.length>0){const H=x;x=[],H.forEach(Y=>Y())}if(M===c){m();return}if(p?.disconnect(),p=void 0,c&&c.style.removeProperty("height"),w="",O=0,T="",c=M,!M){C(),m();return}n.onShown?.(a);try{if(typeof ResizeObserver=="function"){const H=new ResizeObserver(m);typeof H.observe=="function"&&(p=H,p.observe(M))}}catch{p=void 0}m(),h(),R()};window.addEventListener("scroll",D,!0),window.addEventListener("resize",D),f.addDispose(()=>{p?.disconnect(),k!==void 0&&window.cancelAnimationFrame(k),window.removeEventListener("scroll",D,!0),window.removeEventListener("resize",D)});const J=M=>{u=!1,M&&n.onReload?.(a);let G;v||I===void 0?G=_():(y(),G=I);try{a.contentWindow?.location.reload()}catch{a.src=d}return G};return{element:a,ready(){return I??_()},reload:()=>J(!0),reloadQuietly:()=>J(!1),get shown(){return c!==null},whenShown(){return c!==null?Promise.resolve():new Promise(M=>{x.push(M)})},alignTo(M,G){U(M,G??null)},scrollBy(M,G){for(let H=c?.parentElement??null;H;H=H.parentElement){const Y=getComputedStyle(H);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&H.scrollHeight>H.clientHeight){H.scrollBy({left:M,top:G,behavior:"instant"});return}}window.scrollBy({left:M,top:G,behavior:"instant"})},resize(){A?.resize()},dispose(){U(null,null),A?.dispose(),f.dispose(),s.remove()}}}function oc(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,v)=>u==="email"?`email:${v??n}`:u;let o,s=[];const d=()=>{s.forEach(u=>clearTimeout(u)),s=[],o?.remove(),o=void 0},a=new Map,f=(u,v,b)=>{const E=i(u,v),I=t.get(E);if(I)return I;const g=e.resolveMount();if(!g)return nc();const y=ic(u,g,e,u==="email"?v??n:void 0,b);return t.set(E,y),y};return{get:u=>f(u),current:u=>f(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>f("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const v=t.get(i("email"));n=r();const b=a.get("email");u.alignTo(b?.slot??null,b?.clip??null),v?.alignTo(null)},alignSurface(u,v,b){a.set(u,{slot:v,clip:b??null}),(v?f(u):t.get(i(u)))?.alignTo(v,b??null)},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const v of t.values())if(v.element.contentWindow===u)return v}},busy(u){d();const v=u?e.resolveMount():void 0;if(!v)return;const b=ec(v);o=b,s=[setTimeout(()=>b.showSpinner(),Jd),setTimeout(d,Qd)]},dispose(){d(),t.forEach(u=>u.dispose()),t.clear(),a.clear(),n="a"}}}var sc=L("canvas.resizerBinder"),cn=L("canvas.service"),ac={created:Q.canvasCreated,loaded:Q.canvasLoaded};function lc(e,t){if(e.getInstance(cn))return;const n=oc({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:ld,elementId:t.elementId,bindResizer:i=>e.getInstance(sc)?.(i),onCreated:i=>ut(e,i,"fresh"),onReload:i=>ut(e,i,"fresh"),onShown:i=>ut(e,i,"switch"),mark:i=>t.mark?.(ac[i])}),r=X(e).addListener(F.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(cn,n),e.getInstance(j)?.addDispose(()=>{r.dispose(),n.dispose()})}function ut(e,t,n){const r=X(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),zl(r))}function dc(e,t){ut(e,t,"promote")}function cc(e,t){const n=t.contentWindow;n&&X(e).greet(n)}function uc(e,t){const n=t.contentWindow;n&&X(e).forget(n)}function fe(e){return e.getInstance(cn)}function fc(e){const t=X(e),n=()=>fe(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(F.RELOAD,async()=>{await n()?.reload()}),i=t.addListener(s=>{s.data?.operation===F.SANDBOX_RESIZED&&n()?.resize()}),o=K(e,B.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(j)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose()})}var Nm=L("HeadlessMode"),pc=L("HiddenMount");function hc(e){return e.getOrCreateInstance(pc,()=>Me(!1))}function Sr(){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 mc(e){const t=e.getInstance(se);let n,r;e.getInstance(j)?.addDispose(()=>{r?.remove(),r=void 0}),lc(e,{resolveMount:()=>n,resolveSrc:o=>co(o==="block"),elementId:"email_iframe",mark:o=>z(o)}),t?.watch(o=>{if(n)return;const s=o?.element;if(s instanceof HTMLElement)n=s;else if(o!==void 0)n=r??=Sr();else return;fe(e)?.get("email")});let i;e.getInstance(j)?.addDispose(()=>{i?.remove(),i=void 0}),hc(e).watch(o=>{const s=fe(e);if(s){if(o){i??=Sr(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var vo=L("canvas.headerFlow"),Ir=["subject","preheader"],gc=3e3,vc={subject:F.SANDBOX_SUBJECT_UPDATE,preheader:F.SANDBOX_PREHEADER_UPDATE};function bc(e){const t=ve(e),n=X(e),r=g=>g?"remote":go(e)?"system":"user",i=(g,{guid:y,value:_,forced:S})=>{const A=Be(t);if(!A||typeof _!="string"||y&&y!==A.get().docId)return;const h=t.forcedHeaders();if(h?.[g]&&!S&&_!==h[g])return;S&&t.endForcedHeaders();const c=A.get().attributes[g]??"";d=!0;try{vt(A,{[g]:_},{source:r(S)})}finally{d=!1}o[g]=_,oe(e,B.ON_HEADER_APPLIED_ID).fire({field:g,value:_,forced:!!S,isGenerated:_!==c&&!!_})};let o={},s,d=!1,a=Promise.resolve();const f=(g,y,_)=>{a=n.sendAsync(vc[g],{value:y,guid:Be(t)?.get().docId,..._?{force:!0,echo:!0}:{}}).catch(S=>{})};let u;e.inject(vo,{whenDelivered:async()=>{await a},reassert:g=>{const y=Be(t),_=Ir.filter(S=>g[S]);if(!(!y||_.length===0)){d=!0;try{vt(y,Object.fromEntries(_.map(S=>[S,g[S]])),{source:"system"})}finally{d=!1}t.beginForcedHeaders({subject:g.subject??"",preheader:g.preheader??""}),clearTimeout(u),u=setTimeout(()=>t.endForcedHeaders(),gc);for(const S of _)o[S]=g[S],f(S,g[S],!0)}}});const v=()=>{s?.(),s=void 0;const g=Be(t);if(!g){o={};return}const y=g.get().attributes;o={subject:y.subject,preheader:y.preheader},s=g.subscribe(({source:_})=>{if(d)return;const S=g.get().attributes,A=t.forcedHeaders();for(const h of Ir){const c=S[h];c!==o[h]&&(o[h]=c,f(h,c??"",_==="system"&&A?.[h]!==void 0))}})};v();const b=t.subscribe(v),E=n.addListenerAsync(F.APPLICATION_SUBJECT_UPDATE,g=>i("subject",g)),I=n.addListenerAsync(F.APPLICATION_PREHEADER_UPDATE,g=>i("preheader",g));e.getInstance(j)?.addDispose(()=>{E.dispose(),I.dispose(),b(),s?.(),clearTimeout(u)})}function Tr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function un(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];Tr(i)&&Tr(o)?n[r]=un(o,i):i!==void 0&&(n[r]=i)}return n}function Ec(e,t){const n=Rn;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const i=JSON.parse(r);if(i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length>0)return un(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?un(n,t):n}function yc(){const e=window.localStorage.getItem(yt.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?Ds:$s;return e&&e!=="system"?e:t}function _c(){const e=window.localStorage.getItem(yt.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function wc(e){const{config:t}=e;return{operation:F.UPDATE_PREVIEW,theme:e.theme,commonStyles:Ec(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}function Sc(e){const t=X(e),n=e.getInstance(we),r=e.getInstance(se),i=ve(e);let o,s="";const d=()=>{const _=n?.get()??{},S=wc({config:_,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:yc(),codeMode:_c(),appName:"useblocks"}),A=JSON.stringify(S);A!==s&&(s=A,t.send(S))},a=t.onInit(()=>{s="",d()}),f=()=>{t.isInited()&&d()},u=n?.watch(f),v=r?.watch(_=>{o=_?.commonStyles,f()});let b;const E=()=>{b?.(),b=i.current()?.subscribe(f),f()};E();const I=i.subscribe(E),g=matchMedia(Ls),y=()=>f();g.addEventListener("change",y),e.getInstance(j)?.addDispose(()=>{a.dispose(),u?.dispose(),v?.dispose(),b?.(),I(),g.removeEventListener("change",y)})}var fn;(function(e){function t(i,o,s=(d,a)=>d===a){if(i===o)return!0;if(i.length!==o.length)return!1;for(let d=0;d<i.length;d++)if(!s(i[d],o[d]))return!1;return!0}e.isEqual=t;function n(i,o=s=>s){const s=new Set;return i.filter(d=>{const a=o(d);return s.has(a)?!1:(s.add(a),!0)})}e.unique=n;function r(i=[],o=[],s=(d,a)=>d===a){const d=[],a=[],f=[];for(const u of i){const v=o.find(b=>s(u,b));v?f.push({prev:u,next:v}):a.push(u)}for(const u of o)i.find(v=>s(u,v))||d.push(u);return{added:d,removed:a,exists:f}}e.diff=r})(fn||(fn={}));function Ic(e,t){return e.type===t.type&&e.key===t.key}function Tc(e){const t=X(e),n=()=>e.getServices(Te)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(F.SANDBOX_ADD_EXTENSIONS,r)}),o=bs(Te),s=e.onInject(d=>{if(d!==o)return;const a=n();if(!t.isInited()){r=a;return}const{added:f,removed:u}=fn.diff(r,a,Ic);if(r=a,u.length){if(u.some(v=>v.type==="script")){t.send(F.RELOAD);return}t.send(F.SANDBOX_REMOVE_EXTENSIONS,u.map(v=>v.key))}f.length&&t.send(F.SANDBOX_ADD_EXTENSIONS,f)});e.getInstance(j)?.addDispose(()=>{i.dispose(),s?.dispose()})}var Ac=L("prewarm.editorVisible");function Cc(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Rc(e={}){const t=e.paint??Cc;let n=!1,r=!1,i=!1,o=!1,s=!1;const d=[],a=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,z(Q.editorVisible);for(const f of d.splice(0))f()}))};return{noteShellVisible(){n=!0,a()},notePagePainted(){r=!0,a()},noteContentShown(){i=!0,a()},whenVisible(f){if(s){f();return}d.push(f)},contentShown:()=>i}}function Pc(e){return e.getOrCreateInstance(Ac,()=>Rc())}var Dc=500,Oc=500,xc=5e3;function Lc(e){const t=e.quietMs??Dc,n=e.floorMs??Oc,r=e.ceilingMs??xc;let i,o,s=0;const d=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},a=()=>{d(),e.run()},f=()=>{clearTimeout(i);const u=n-(Date.now()-s);i=setTimeout(a,Math.max(t,u))};return{start(){d(),s=Date.now(),o=setTimeout(a,r),f()},notify(){i!==void 0&&f()},cancel:d}}function Mc({attributes:e,readContent:t,docId:n,hasSession:r,serverId:i,show:o}){if(!r)return;const s={id:i??void 0,renderGuid:n,showId:o?.id,isNew:i==null,showToken:o?.token},d={...e,...s};return Object.defineProperty(d,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),d}var bo="self-init:";function kc(e){return e.startsWith(bo)}function Eo(e,t){const n=e.getActiveShowRequest();return kc(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Nc(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t();let i="";const o=()=>e.readDocument()?ln(e.readDocument()):i,s=()=>ke(e.container).editorPolicy,d=()=>e.readEmail(),a=()=>{const f=d();return{...f,id:e.isTemplate()||f.isNew?void 0:f.id,html:o()}};return{readContent:o,publicEmail:a,sendInitStart:()=>de(n,"INIT_START",F.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>de(n,"INITED",F.SANDBOX_INITED,{guid:d().renderGuid},void 0,r()),async sendContent(){const f=d(),{html:u,hasBrowserExtensionArtifacts:v}=fo(f?.html||"");v&&e.events.browserExtensionDetected(),po(e.readDocument(),u),i=u,await de(n,"SET_ENTITY",F.SANDBOX_SET_ENTITY,dn(o(),f.renderGuid,s(),e.readDocument()?.get().version),{guid:f.renderGuid,emailId:f.id??null},r())},refreshContent:()=>de(n,"SET_ENTITY",F.SANDBOX_SET_ENTITY,dn(o(),d().renderGuid,s(),e.readDocument()?.get().version),void 0,r()),sendPreheader:async()=>{const f=d();if(f.preheader!==void 0)return de(n,"PREHEADER",F.SANDBOX_PREHEADER_UPDATE,{value:f.preheader,guid:f.renderGuid,force:!0},void 0,r())},sendSubject:async()=>{const f=d();if(f.subject!==void 0)return de(n,"SUBJECT",F.SANDBOX_SUBJECT_UPDATE,{value:f.subject,guid:f.renderGuid,force:!0},void 0,r())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:f=>e.showFilled?.(f),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(a()),fireInit(f,u){if(!Eo(t(),f)){t().getActiveShowRequest()?.showId;return}const v=d();v.id,v.renderGuid,t().completeShow(f),vt(e.readDocument(),{is_inited:!0},{source:"system"});const b=a();return u&&(b.reset=!0),e.events.inited(b)},fireEmailChanged(){e.events.emailChanged(a())},fireContentChanged(){e.events.contentChanged(o())}}}function Fc(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,d;const a=Nc({...e,waitScope:()=>({getSandboxTimeoutMs:y=>t().getSandboxTimeoutMs(y),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:d?.signal??t().signal})});let f;const u=(y,_)=>{if(f===y)return;f=y;const S=s;setTimeout(()=>{s!==S||t().signal.aborted||I(y,_).catch(()=>{})},0)},v=()=>{d?.abort(),d=void 0};let b;const E=()=>{const y=t().signal;y!==b&&(b?.removeEventListener("abort",v),b=y,y.addEventListener("abort",v))};async function I(y,_){const S=++s;v(),d=new AbortController,E();const A=()=>s!==S,h=a.readTarget(),c=t().generation,l=()=>c===t().generation&&!t().signal.aborted,p=_?"init:reset-":"init:";if(!_){const T=a.publicEmail();T?.id,T?.renderGuid,T?.preheader}let m=!1,w=!1;try{n=!0,await a.sendInitStart(),a.fireWillInit(),await(_?a.refreshContent():a.sendContent()),m=!0,_||a.publicEmail()?.id;try{await a.sendPreheader()}catch(T){`${p}`,String(T)}try{await a.sendSubject()}catch(T){`${p}`,String(T)}if(A()||a.showFilled(h),await a.sendInited(),w=!0,i===y){const T=e.readSandboxGeneration?.()??o;T!==void 0&&(r=T)}await a.revealFilled()}catch(T){throw A()||(`${p}`,{...e.describeSurface?.(),error:String(T)},void 0),!A()&&Eo(t(),y)&&t().failShow(y,T),T}finally{g(y,_,p,{superseded:A(),sessionGeneration:c,contentApplied:m,sandboxInitedAcked:w,commit:l()})}}function g(y,_,S,A){const{superseded:h,contentApplied:c,sandboxInitedAcked:l}=A;if(h){`${S}`;return}l&&A.commit?a.fireInit(y,_||void 0):l?(`${S}`,A.sessionGeneration,t().generation,t().signal.aborted,void 0):c?(`${S}`,void 0):(`${S}`,void 0),n=!1,d=void 0,!l&&i===y&&(i=void 0,r===o&&(r=void 0)),!l&&c&&u(y,_)}return{channel:a,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:y=>{r=y},lastCorrelation:()=>i,markCorrelation:y=>{i=y},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:y=>{o=y},fill:y=>I(y,!1),refill:y=>I(y,!0),stop:()=>{s+=1,v(),n=!1,b?.removeEventListener("abort",v),b=void 0}}}function jc(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:yo(e,n)}function yo(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Bc(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=u=>{const v=n(),b=i();if(!jc(v,u,b)){u.showId,u.navId,u.emailId,v?.id,v?.showId,v?.renderGuid;return}u.showId,v?.id,v?.renderGuid,t.markFilled(o()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{s(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&s(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=o();if(t.filledGeneration()===u)return;const v=n(),b=i();if(!v?.renderGuid||!yo(v,b))return;const E=`${bo}${v.renderGuid}`;t.markFilled(u),t.markCorrelation(E);const I=r()?.isReady()===!0;v.id,v.renderGuid,(I?g=>t.refill(g):g=>t.fill(g))(E).catch(()=>{t.lastCorrelation()===E&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id}}}function Uc(e){return e??""}function Hc(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Gc(e){const t=ve(e),n=X(e),r=()=>me(t.sessionKey())?void 0:t.current(),i=()=>{const P=r();return Mc({attributes:P?.get().attributes??{},readContent:()=>P?.getContent(),docId:P?.get().docId,hasSession:!!P,serverId:P?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(De)??Hn;let s={},d=!1;const a=e.getInstance(se)?.watch(P=>{d=!!P?.element});let f=!1,u=!1,v=!1,b=0;const E=()=>{const P=fe(e);if(!P)return;const V=++b,q=P.spare();return q&&uc(e,q.element),(q?q.reloadQuietly():P.ensureSpare()?.ready())?.then(()=>{if(V!==b)return;f=!0;const re=P.spare();re&&cc(e,re.element),v&&(v=!1,T(),U())})},I=Lc({run:()=>{v||E()?.catch(()=>{})}}),g=()=>{Pc(e).noteContentShown(),!f&&!v&&I.start()};let y=!1;const A=Fc({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const P=fe(e);return y&&P&&(y=!1,I.start()),d?P?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:P=>{const V=fe(e),q=V?.spare()?.element.contentWindow;u&&V&&q&&P===q&&(u=!1,V.promote(),V.busy(!1),y=!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>ue(n),describeSurface:()=>({canvasPath:w,promoted:u,spareClean:f,handshake:n.isInited(),generation:ue(n)}),events:{willInit:P=>{oe(e,B.WILL_EMAIL_INIT_ID).fire(P)},inited:P=>{g(),oe(e,B.ON_EMAIL_INIT_ID).fire(P)},contentChanged:P=>{oe(e,B.ON_CONTENT_CHANGED_ID).fire(P)},emailChanged:P=>{oe(e,B.ON_EMAIL_CHANGED_ID).fire(P)},browserExtensionDetected:()=>{oe(e,B.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),h=Bc({pipeline:A,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>ue(n)});let c="",l="",p="";const m=P=>P.length>0;let w="none";const T=()=>{const P=fe(e)?.spare();P&&(n.sendNow({operation:F.SANDBOX_LOCK_EDIT,data:!0}),f=!1,u=!0,dc(e,P.element))},O=(P,V)=>{const q=fe(e);if(!q)return!0;const re=q.spare(),Ee=re&&f?"spare":"prepare";if(w=Ee,q.busy(!0),re&&f)return T(),!0;I.cancel(),n.sendNow({operation:F.SANDBOX_LOCK_EDIT,data:!0});const ye=E();if(ye===void 0)return w="reload",q.busy(!1),q.peek("email")?.reload(),!0;v=!0;const Ct=b;return ye.catch(()=>{!v||Ct!==b||(v=!1,w="reload",q.busy(!1),q.peek("email")?.reload())}),!1},k=()=>{be(),A.noteSandboxGeneration(ue(n));const P=i(),V=Hc(P?.renderGuid,P?.showId,P?.id,s.emailId),q=Uc(P?.renderGuid);if(q!==l){const ye=m(l),Ct=l;l=q,ye&&O(Ct,q)}if(v)return;V!==c&&(c=V,h.showRequestIdentityChanged());const re=r(),Ee=`${V}|${re?.get().docId??""}|${ue(n)}`;Ee!==p&&re?.isReady()===!0&&(p=Ee,h.selfInitChanged()),h.saasChanged(),D()};let W=!1,R="",C="";const D=()=>{const P=i();if(!P?.renderGuid)return;const V=A.channel.readContent(),q=JSON.stringify([P.preheader,P.common_styles,P.meta,P.subject,P.utm_parameters?.utm_campaign??"",P.utm_parameters?.utm_content??"",P.utm_parameters?.utm_medium??"",P.utm_parameters?.utm_source??"",P.utm_parameters?.utm_term??""]),re=W&&V!==C,Ee=W&&q!==R;if(W=!0,C=V,R=q,A.isEventsLocked())return;const ye={...P,id:s.isTemplate||P.isNew?void 0:P.id,html:V};if(re){oe(e,B.ON_CONTENT_CHANGED_ID).fire(V),oe(e,B.ON_EMAIL_CHANGED_ID).fire(ye);return}Ee&&P.is_inited&&oe(e,B.ON_EMAIL_CHANGED_ID).fire(ye)};let x=!1;const U=()=>{x||(x=!0,queueMicrotask(()=>{x=!1,k()}))};e.inject(Gn,{pipeline:A,setRoute:P=>{P.emailId===s.emailId&&!!P.isTemplate==!!s.isTemplate||(s=P,U())}});let J,M;const G=()=>{const P=r()?.get().docId;P!==M&&(J?.(),M=P,J=r()?.subscribe(U)),U()};let H,Y;const be=()=>{const P=e.getInstance(De);!P||P===H||(Y?.(),H=P,Y=P.onShowRequested(V=>h.showRequested(V)))},et=n.addListener(P=>{P.data?.operation===F.SANDBOX_RESIZED&&I.notify()}),rs=t.subscribe(G),is=lo(n,U);G(),e.getInstance(j)?.addDispose(()=>{a?.dispose(),Y?.(),is(),rs(),J?.(),et.dispose(),I.cancel(),A.stop()})}function qc(){return Hs!=="useblocks"}var pn={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:"",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},$c={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:"",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}},Ar=pn,zc=["freeUserBlocks","blocks"],_o={};function Vc(e){_o=e}var wo=e=>zc.includes(e)?Ar:_o[e]??Ar,hn={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:"",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},Kc={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:"",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},Wc={...hn,config:{...hn.config,imageCenterFileManagerView:!1}};Vc({pro:$c,editor:Kc,simple:qc()?hn:Wc,freeUserBlocks:pn,blocks:pn});var Cr=new Set;function Yc(){return window.localStorage.getItem(yt.em_color_scheme)??void 0}function Xc(e){return Cr.add(e),e(Yc()),{dispose(){Cr.delete(e)}}}function qn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Jc(e,t){return t.modeDefaults(qn(e,t.fallbackMode))}function Qc(e,t){const n=qn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Zc(e,t){const n=qn(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function eu(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function tu(e){return us(e.map(t=>t?.resourceProxy))}function nu(e){return cs(e.map(t=>t?.resourceProxyPolicy))}function ru(e){return Is(e.map(t=>t?.backendProxy))}function iu(e){return hi(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function ou(e,t){return[e.base,Jc(e,t),e.profile,e.serverSide,Qc(e,t.fallbackMode),e.user,Zc(e,t.fallbackMode),e.local]}function Mt(e,t){const n=ou(e,t),r=hi(n),i=eu(n);i!==void 0&&(r.fileManager=i);const o=tu(n);o!==void 0&&(r.resourceProxy=o);const s=nu(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const d=ru(n);d!==void 0&&(r.backendProxy=d);const a=iu(n);return a&&Object.keys(a).length>0&&(r.backendProxyPolicy=a),r}var su=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Rr(e){return e==="server"?"serverSide":e}function au({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=Me();let o={kind:"pending"},s;const d=new Promise(b=>{s=b}),a=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function f(){o.kind!=="pending"&&i.set(Mt(r,e))}function u(b){if(o.kind!=="pending")return;clearTimeout(a),o=b;const E=Mt(r,e);i.set(E),s(E)}function v(b,E){r[Rr(b)]=E,b==="server"&&o.kind==="pending"?u({kind:"applied"}):f()}return{watch:b=>i.watch(b),select:b=>i.select(b),get:()=>i.get(),ready:()=>d,state:()=>o,layers:()=>({...r}),bootstrap(){const b=Mt(r,e);return Object.fromEntries(su.map(E=>[E,b[E]]))},merge(b,E){v(E,{...r[Rr(E)],...b})},replace(b,E){v(E,b)},setMode(b){r.user={...r.user,mode:b},f()},setAdvancedConfigs(b){r.advancedConfigs=b,f()},serverAbsent(b){u({kind:"absent",reason:b})},applyServerResponse(b){o.kind==="pending"&&v("server",{...r.serverSide,...b})},dispose(){clearTimeout(a)}}}var lu=5e3,du="blocks";function cu(){return{...wo(du)?.config,mergeTags:void 0}}function uu(e,t){e.getInstance(se)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function fu(e,t){let n;Zi(e).watch(({profile:r})=>{const i=`${r?.theme??""}|${r?.locale??""}`;if(i===n)return;n=i;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function pu(e,t){let n=null;const r=Xc(i=>{const o=typeof i=="string"&&i?i:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(j)?.addDisposable(r)}async function hu(e,t){if(e.getInstance(Mn)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Pe);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function mu(e){e.injectFactory(we,(t,n)=>{if(n)return n;const r=au({base:cu(),env:{modeDefaults:i=>wo(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:lu});return uu(e,r),fu(e,r),pu(e,r),hu(e,r),e.getInstance(j)?.addDisposable(r),r},!0)}var Re=class extends ee{_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 N(e,t,n){const r=ds(e);return(i,o,s)=>{const d=r(async a=>{const f=t?t(a):a;s&&i.bind(s);const u=await i(f);return n?n(u):u},o,s);return()=>d.dispose()}}var gu=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new nn;this.handleDestroy=N(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Re(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{}}},$n=L("DestroyableService");function vu(e){e.injectFactory($n,()=>{const t=e.getInstance(j);if(!t)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new gu({lifetime:t,options:e.getInstance(se),getInstance:()=>e.getInstance(_t),release:()=>js(e.getInstance(Ms)??e)})},!0)}function bu(e){const t=e.getInstance($n);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var Eu=1e3;function So(e,t,n=Eu,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 i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const s of i)if(!So(e[s],t[s],n,r+1))return!1;return!0}return!1}function Ge(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 i=t[r],o=e[r];So(i,o)||(n[r]=i)}return n}var yu=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail не ответил за ${e}ms — письмо не сохранено`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},_u=({source:e,emailtags:t,group:n,tags:r,...i})=>i,wu=()=>Oi();async function Su({emails:e},t){const n=wu();let r;try{return await Promise.race([e.notifySave(t),new Promise((i,o)=>{r=setTimeout(()=>{const s=new yu(n);t.value.id,o(s)},n)})])}finally{r!==void 0&&clearTimeout(r)}}function Iu(e){const{emails:t}=e,n=async(r,i)=>{const o=_u(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),d=s?{...s,...o}:o,a=await Su(e,{prev:s,patch:s?Ge(s,o):o,value:d,source:i.source??""}),f=String(a.id??r??ce()),u=a.id===void 0?{...a,id:f}:a;return await t.cache.addOrUpdate(f,()=>u)};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const i=await n(void 0,r);return i?.renderGuid?i:{...i,renderGuid:ce()}},async updateEmail(r,i){return await n(r,i)}}}var kt=20,Tu=({source:e,emailtags:t,group:n,tags:r,...i})=>i;function Au({revisions:e,revisionsByEmail:t}){const n=async(r,i)=>(t.clear(),await t.get(r,{page:i}),(await e.cache.values()??[]).filter(o=>String(o?.parent)===String(r)));return{async readRevisions(r,i=1){const o=await n(r,i);return{revisions:o.slice(kt*(i-1),kt*i),page:i,hasMore:o.length>kt*i}},async readAutosave(r){return Ja(await n(r,1))},async saveAutosave(r,i){const o=Tu(i);return await e.create({...o,parent:r,modified:new Date().toString()})}}}var Cu=class extends Vs{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}},Ru=class extends pe{};var Pr=class extends ee{_items=new Map;_onChangeEmitter=new Ps;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 i=await t(n);return ht(n,i)||this._onChangeEmitter.fire(),i}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(([i,o])=>i)),r=(await this.entries()).filter(([i,o])=>!n.has(i));for(const[i,o]of e)t.push(this.addOrUpdate(i,()=>o)),n.add(i);for(const[i]of r)t.push(this.remove(i));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 Pu(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let d=e.length;if(t!==void 0){const a=Object.keys(t);e=e.filter(f=>{for(const u of a){const v=f[u],b=t[u];return u==="id"||typeof v!="string"?v===b:typeof b=="string"&&v.startsWith(b)}return!0}),d=e.length}return r&&(e=e.sort((a,f)=>(a[r]>f[r]?1:f[r]>a[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:d,total:s,totalPages:Math.ceil(d/o)}}function Du(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 i=t.get(r.id)||{};t.set(r.id,{...i,...r})}return[...t].map(([n,r])=>r)}function Ou(e,t){return Dr(e)&&Dr(t)?String(e)===String(t):e===t}function Dr(e){return typeof e=="string"||typeof e=="number"}var xu=class extends ee{_cache=new Pr;_readEmitter=new pe;_saveEmitter=this.addDisposable(new Cu);_removeEmitter=this.addDisposable(new Ru);_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)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ee);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Pr),i=n.addDisposable(new pe);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const a=Du(await i.fire(o))||[];for(const f of a)f[e]=o,await this._cache.add(f.id,f);return a}catch{return[]}});const d=(await this._cache.values()||[]).filter(a=>{const f=a[e];return f==null||Ou(f,o)});return Pu(d,s)},first(o,s={}){return t.get(o,{...s,page:1,pageSize:1}).then(({data:d})=>d[0])},handleRead:i.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 i=>{const o=i?{...i,...t}:t;if(!r)return t=i?Ge(i,t):t,await this._saveEmitter.fire({prev:i,patch:t,value:o,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 Je(e){const t=L(e);return n=>n.getOrCreateInstance(t,()=>new xu)}function Lu(e){const t=e.getInstance(j);if(!t)throw new Error("Failed");return t}function Or(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Mu(e,t,n){return e&&!Or(t)&&Or(e)?{...n,meta:e.meta}:n}var Io=Je("plugin.dataSource.emails"),To=Je("plugin.dataSource.emailRevisions"),xr=L("emailDocuments.provided");function ku(e){const t=Io(e),n=To(e),r=n.byForeignKey("parent");return e.getInstance(xr)?{emails:t,emailRevisions:n}:(e.inject(xr,!0),vl(e,Iu({emails:t})),_l(e,Au({revisions:n,revisionsByEmail:r})),Lu(e).addDisposable(t.onSave(({prev:i,patch:o,value:s})=>Mu(i,o,s),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function Lr(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 Nu(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Fu="po",at=null;function ju(){const e=typeof window.__useblocks__<"u"?window.__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([Fu],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Bu(){return at===null&&(at=ju().catch(e=>{throw at=null,e})),at}async function Ao(e){if(typeof e=="object")return zn(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Uu(t):Hu(t)}function zn(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Uu(e){try{return zn(JSON.parse(e))}catch{return}}var Mr=!1;async function Hu(e){try{return zn((await Bu()).parsePoCatalog(e))}catch{Mr||(Mr=!0);return}}var Gu="em_locale",qu="em_ant_locale",$u="locale",zu="ant_locale";function Vn(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Co(e,t){const n=Vn(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Vu(){return Vn("em_locale")??Co($u,"em_locale")}function kr(e){try{localStorage.setItem(Gu,JSON.stringify(e))}catch{}}function Ku(){return Vn("em_ant_locale")??Co(zu,"em_ant_locale")}function Wu(e,t){try{localStorage.setItem(qu,JSON.stringify({id:e,data:t}))}catch{}}var Yu=8e3;function Xu(e,t){const n=e,r=t,i=Object.keys(n).filter(o=>o!=="");return i.length!==Object.keys(r).filter(o=>o!=="").length?!1:i.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function Ju(e){const t=Vu(),n=Ku();let r={ready:!1},i;const o=Me(r);let s=0;const d=y=>{r={...r,...y},o.set(r)},a=()=>{r.ready||d({ready:!0})},f=setTimeout(a,e.unlockAfterMs??Yu),u=y=>y!==s;let v;async function b(y,_){if(n?.id===y&&n.data&&d({antd:n.data}),!v)return;const S=await v(y).catch(()=>{});!S||u(_)||(d({antd:S}),Wu(y,S))}async function E(y,_){const S=await e.askHost(y).catch(()=>null);if(u(_))return!0;if(S==null)return!1;const A=await Ao(S);return u(_)||(A&&d({catalog:A}),a()),!0}async function I(y,_){const S=await e.readList();if(u(_))return;if("error"in S){d({failure:{kind:"GET_LOCALES_ERROR",error:S.error}}),a();return}const A=S.data.find(c=>c.locale===y);if(!A){Nu("em_locale")&&d({catalog:void 0}),a();return}if(Lr(t,A)&&(!i||i.catalog===t?.data)){a();return}if(i?.entry&&r.catalog===i.catalog&&Lr(i.entry,A)){kr(i.entry),a();return}const h=await e.readCatalog(y);if(!u(_)){if("error"in h){d({failure:{kind:"GET_LOCALE_ERROR",error:h.error}}),a();return}h.data&&(i?.id===y&&r.catalog===i.catalog&&Xu(i.catalog,h.data)||d({catalog:h.data}),kr({id:y,time:A.updatedAt||Math.floor(Date.now()/1e3),hash:A.contentHash,data:h.data})),a()}}async function g(y,_){if(!await E(y,_)){if(!u(_)&&(i?.id===y&&r.catalog===i.catalog||y==="en_US")&&a(),e.canUseNetwork&&!e.canUseNetwork()){a();return}await I(y,_)}}return{set(y){if(!y||y===r.id)return;const _=s+=1;d({id:y,failure:void 0});const S=i?.id===y&&r.catalog===i.catalog;(i&&!S&&r.catalog===i.catalog||y==="en_US"&&r.catalog)&&d({catalog:void 0}),t?.id===y&&t.data&&(d({catalog:t.data}),a()),b(y,_),g(y,_)},prime(y,_,S){r.id||r.catalog||!_||(i=t?.id===y&&t.data&&(!S||t.time>=S.time)?{id:y,catalog:t.data}:{id:y,catalog:_,entry:S?{id:y,time:S.time,hash:S.hash,data:_}:void 0},d({catalog:i.catalog}))},useAntdLoader(y){v=y,r.id&&b(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(f)}}var Qu=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})},Zu=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:i,format:o,baseUrl:s,cancelToken:d,...a})=>{const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(a,f),v=i&&this.toQueryString(i),b=this.contentFormatters[r||"application/json"],E=o||u.format;return this.customFetch(`${s||this.baseUrl||""}${n}${v?`?${v}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(d?this.createAbortSignal(d):u.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async I=>{const g=I;g.data=null,g.error=null;const y=E?I.clone():I,_=E?await y[E]().then(S=>(g.ok?g.data=S:g.error=S,g)).catch(S=>(g.error=S,g)):g;return d&&this.abortControllers.delete(d),_})}},ef=L("rest.v2.transport"),Nr=Symbol("rest.v2.secureRequest");function tf(e){return e.getOrCreateInstance(ef,()=>{const t=e.getInstance(pi)?.execute||fetch;return new Zu({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[Nr]:!0}),customFetch:(n,r={})=>{const{[Nr]:i,...o}=r;return t(n,{...o,[hs]:i!==!0})}})})}function nf(e,t){const n=tf(e);return Object.assign({},...t.map(r=>new r(n)))}function Fr(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Ro(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Fr(n.details,"wp_code")??n.code,message:Fr(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 Po(e){return!e.ok||!!e.error}function rf(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Do(){return rf(yt.em_translations_v2)??!0}function of(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function sf(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function af(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],i=r[0];return typeof i=="string"&&i!==""&&t.push({locale:i,updatedAt:of(r[1])}),t},[]):[]}function lf(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:sf(n.updated_at),contentHash:n.content_hash}),t),[])}function Oo(e){return nf(e,[Qu])}function Et(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function mn(e){return!e.ok||e.error!=null}function gn(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Nt(e){return{data:await Ao(e)??null}}async function df(e){if(Do())try{const n=await Oo(e).localesList();return Po(n)?{error:Ro(n)}:{data:lf(n.data)}}catch(n){return Et(n)}const t=gi(e,[wi]);try{const n=await t.get_translations2({file:"react_app"});return mn(n)?gn(n):{data:af(n.data)}}catch(n){return Et(n)}}async function cf(e,t){if(Do())try{const r=await Oo(e).jsonList({locale:t});return Po(r)?{error:Ro(r)}:Nt(r.data)}catch(r){return Et(r)}const n=gi(e,[wi]);try{const r=await n.get_translations3({id:t,file:"react_app"});return mn(r)?gn(r):Nt(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return mn(r)?gn(r):Nt(r.data)}catch(r){return Et(r)}}}var ze=L("locale.service");function uf(e){if(e.getInstance(ze))return;const t=Ju({readList:()=>df(e),readCatalog:n=>cf(e,n),askHost:async n=>(await oe(e,B.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(he)});e.inject(ze,t),e.getInstance(j)?.addDispose(()=>t.dispose())}function ff(e){const t=e.getInstance(we);if(!t)return;const n=e.getInstance(ze);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i));e.getInstance(j)?.addDisposable(r)}var pf="user_id",hf="project_id",jr=L("rest.identityHeadersProvided");function mf(e){if(e.getInstance(jr))return;e.inject(jr,!0);let t;e.getInstance(se)?.watch(n=>{t=n}),e.addService(Dn,{execute(n,r){if(r?.public)return;const i=t?.user?.id??eo(e).profile?.id;i!=null&&i!==""&&n.headers.set(pf,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(hf,String(o))}})}function gf(e){if(!e)return!1;try{return e.getInstance(he)!==void 0}catch{return!1}}var vf="Invalid standaloneKey.",Fm=L("StandaloneMockGuard");function bf(){const e=new Error(vf);return e.name="InvalidStandaloneKeyError",e}function Ef(e){e.addService(Dn,{execute:()=>{if(gf(e))throw bf()}})}function yf(e){Rs(e),Ef(e)}function _f(e){const t=new mo;e.inject(De,t);let n;const r=e.getInstance(se)?.watch(o=>{o&&(o.signal!==void 0&&(n=o.signal),t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...n!==void 0?{signal:n}:{}}))}),i=e.getInstance(j);r&&i?.addDisposable(r),i?.addDispose(()=>{t.abort()})}var wf=Je("plugin.dataSource.blocks"),Sf=Je("plugin.dataSource.blockRevisions"),If=Je("plugin.dataSource.comments"),Tf=ho(),Af=ho(),xo=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1004
1004
  <html>
1005
1005
  <head>
1006
1006
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -1041,10 +1041,10 @@ import{t as si}from"./static/esm/50fbfdf6.js";import{$ as Jo,A as Qo,At as le,B
1041
1041
  </tr>
1042
1042
  </table>
1043
1043
  </body>
1044
- </html>`;function yf(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:To,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var Ef=L("CurrentProject"),_f={};function St(e){return e?.getInstance(Ef)?.get()??_f}function Ao(e){const t=St(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Co=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function wf(e){return!Object.keys(e).some(t=>Co.has(t))}function Sf(e){const t={},n={};for(const[r,i]of Object.entries(e))Co.has(r)?t[r]=i:n[r]=i;return{showOptions:t,misplacedEmailFields:n}}function Lr(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function It(e){return{emails:vo(e),blocks:hf(e),emailRevisions:bo(e),blocksRevision:mf(e),comments:gf(e)}}function If(e){const t=Object.values(It(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Gn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(wf(e))return{email:Lr(e)};{const{showOptions:n,misplacedEmailFields:r}=Sf(e),i=Object.keys(r);t&&i.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Lr({...r,...o})}}}function Ro(e){return Ln(e)?.current()}function ft(e){return Ro(e)?.getContent()}function Tf(e,t){const n=t??yf(),r=Ro(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:ft(e)??n.html}:n}async function Ft(e){return(await e.getInstanceAsync(Pe))?.project}function xe({code:e,project:t,...n},r){const i=ge(n),o=Ao(r),s=Ne(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...i,...e?{html:s.toEditorForm(e)}:{},...o===void 0?{}:{project:o},utm_parameters:i.utm_parameters||{},_embedded:void 0}}function ee({html:e,renderGuid:t,showToken:n,showId:r,...i},o){const{requested:s}=St(o),d=Wi(o);return ge({...i,code:Ne(o).toOutputForm(e),project:s===void 0?i.project:s,utm_parameters:d.UTMEnabled?i.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})}function mn(e){return e==null?"":e.replaceAll(`\r
1044
+ </html>`;function Cf(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:xo,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var Rf=L("CurrentProject"),Pf={};function St(e){return e?.getInstance(Rf)?.get()??Pf}function Lo(e){const t=St(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Mo=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Df(e){return!Object.keys(e).some(t=>Mo.has(t))}function Of(e){const t={},n={};for(const[r,i]of Object.entries(e))Mo.has(r)?t[r]=i:n[r]=i;return{showOptions:t,misplacedEmailFields:n}}function Br(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function It(e){return{emails:Io(e),blocks:wf(e),emailRevisions:To(e),blocksRevision:Sf(e),comments:If(e)}}function xf(e){const t=Object.values(It(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(Df(e))return{email:Br(e)};{const{showOptions:n,misplacedEmailFields:r}=Of(e),i=Object.keys(r);t&&i.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Br({...r,...o})}}}function ko(e){return jn(e)?.current()}function ft(e){return ko(e)?.getContent()}function Lf(e,t){const n=t??Cf(),r=ko(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:ft(e)??n.html}:n}async function Ft(e){return(await e.getInstanceAsync(Pe))?.project}function xe({code:e,project:t,...n},r){const i=ge(n),o=Lo(r),s=ke(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...i,...e?{html:s.toEditorForm(e)}:{},...o===void 0?{}:{project:o},utm_parameters:i.utm_parameters||{},_embedded:void 0}}function te({html:e,renderGuid:t,showToken:n,showId:r,...i},o){const{requested:s}=St(o),d=to(o);return ge({...i,code:ke(o).toOutputForm(e),project:s===void 0?i.project:s,utm_parameters:d.UTMEnabled?i.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})}function vn(e){return e==null?"":e.replaceAll(`\r
1045
1045
  `,`
1046
- `)}function Mr(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Af(e,t,n,r){const i=Cf(e,t,n,r);return i===void 0}function Cf(e,t,n,r){const{email:i}=Gn(t,!1),o=xe(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const d=Ln(e)?.current();if(!d)return"no-session";const l=d.get(),f=l.attributes;if(l.serverId!==s)return"document-id";if(f.is_inited!==!0)return"not-inited";const u=Mr(mn(n??d.getContent()));if(o.html!==void 0&&Mr(mn(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==f.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==f.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==f.common_styles)return"common_styles"}function kr(e,t){const{email:n}=Gn(t,!1),r=xe(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:mn(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Rf(e,t){const n={...e};return delete n.id,{...n,...t}}function Pf(e){return e.html?e:{...e,html:To}}function Ue({code:e,project:t,...n},r,i){const o=i??Ao(r);return{...n,...e?{html:Ne(r).toEditorForm(e)}:{},renderGuid:le(),...o===void 0?{}:{project:o}}}function at({html:e,renderGuid:t,...n},r){const{requested:i}=St(r);return ge({...n,code:Ne(r).toOutputForm(e),project:i===void 0?n.project:i,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 Po(e){return Ln(e)?.current()?.get().serverId??void 0}function gn(e,t,n){return n===void 0&&(n=e.post===void 0?Po(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function lt(e,t){return ge({...e,link:void 0,comment_status:void 0})}function vn({code:e,...t},n,r){return r===void 0&&(r=t.parent===void 0?Po(n):t.parent),{...t,...e?{html:e}:{},parent:r}}function Nr({html:e,...t},n){return ge({...t,code:e,guid:void 0,compiled:ge({html:e,ampHtml:e&&""})})}var bn=L("NotificationService"),Df=L("emailTemplate.reads");async function Of(e,t){try{return await Se(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,xf(e,t,n);return}}function xf(e,t,n){e.getInstanceAsync(bn).then(()=>{In(e,j.ON_NOTIFICATION).fire({type:"error",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{})}function Lf(e,t){const n=e.getOrCreateInstance(Df,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=Of(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var Mf="EXTERNAL";function kf(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"сохранение не состоялось")}var Nf="email_id",Ff=class extends Z{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_dataSources;_eventLock;_queue=ks();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=It(t),this._eventLock=If(t);const n=K(e,j.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(Tn,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Nf,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(De)??Nn}_throwIfDestroyed(){if(this.isDisposed())throw Rn()}async getTemplateEmail(e){const t=await Lf(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Ft(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Ue(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,vn(i,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,gn(i,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,i){const o=this._dataSources.emails,s=o.cache,d=await Ft(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let f=xe(e,this._container);const u=f.id;let v=u;if(u!==void 0){const b=await o.get(u);f={...b??{},...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d}}else{v=n??le();const b=await o.get(v);f={...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d},delete f.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(f=Rf(b,f))}return u===void 0&&(f=Pf(f)),await s.addOrUpdate(v,()=>f),f}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==kr(this._container,e))return!1;const n=ft(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=kr(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:ft(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&t!==this._showRequests){this._showRequests;return}if(!e)return;const n=this._getInitPipeline();if($(n.signal),Af(this._container,e,ft(this._container),this._prevCommand?.id)||this._isRepeatOfLastShow(e))return;const r=Gn(e);r.email.id,this._prevCommand?.id;let i,o="",s=0,d=!1,l,f=Promise.resolve(),u,v=!1;try{this._eventLock.suspendChange();const{email:b,blocks:y,autosaves:I,comments:g,templateId:E,reload:w}=r;i=b.id;const S=xe(b,this._container),A=S.id,h=A??le(),c=await He("getProject",Ft(this._container));$(n.signal),o=le();const a={isNew:A===void 0,id:String(h),project:c},p=w===!0&&A!==void 0;p&&(await this._dataSources.emails.remove(String(A),{silent:!0}),String(A)),s=++this._showToken,String(h);const m=[];m.push(this.setBlocks(y)),b.id!==void 0&&(m.push(this.setComments(g)),m.push(this.setEmailRevisions(I,String(b.id)))),m.push(this.setEmail(b,Number(E),A===void 0?String(h):void 0,s,o)),await He("setEmail+blocks+revisions",Promise.all(m),{emailId:A??String(h),showId:o,targetShowToken:s}),$(n.signal);const _=await this._dataSources.emails.get(String(h)),T=ve(this._container),D={id:o,token:s};A===void 0?u=T.startNewDraft(_??S,{patch:S,show:D}):p?u=T.reload(A,{email:_??S,patch:S,show:D}):T.sessionKey()===je(A)?u=T.show(S,D):u=T.open(A,{email:_??S,patch:S,show:D});const R=!!this._prevCommand&&mt(this._prevCommand,a);a.id,!this._prevCommand||mt(this._prevCommand,a),this._prevCommand?.id,this._rememberShow(a),f=n.requestShow({showId:o,navId:String(h),emailId:A,isNew:A===void 0}),v=!0,String(h),d=!0}catch(b){l=b,v&&o&&n.failShow(o,b),String(b)}finally{this._eventLock.resumeChange()}if(!d)throw l instanceof Error?l:new Error(`[useblocks] show() setup failed: ${String(l??"unknown error")}`);return He("show-init-deferred",Promise.all([f,u?.whenReady().catch(b=>{if(b instanceof gt){const y=Ni(b);throw y?new Error(`[useblocks] show(): email open failed (${y})`,{cause:b}):b}})??Promise.resolve()]).then(()=>{}),{showId:o,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();$(e.signal);const t=ve(this._container),n=await t.save("publish",{source:Mf});if($(e.signal),!n)throw kf(t.saveState().error);return ee(Tf(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function jf(e){return String(e).replace(/"/g,"&quot;")}function Bf(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 Uf(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 Fr(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=jf(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function Hf(e,t,n){if(!e?.trim()||!t)return e;const r=Uf(e);if(!r)return e;const i=String(t),o=Bf(n??new Date);let{full:s,index:d}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=Fr(s,"em-block-id",i)),s=Fr(s,"em-block-version",o),e.slice(0,d)+s+e.slice(d+l)}function Gf(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 qf(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=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:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Gf(e)}}function jt(e,t){return t?qf(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Do=["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"],$f=[...Do,"html","id","project","password"],Rm=new Set(["html",...Do,"global_block","project"]);function zf(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($f),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Vf(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...zf(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 yn=new WeakMap;function Kf(e){let t=yn.get(e);return t||(t={byId:new Map,fallback:[]},yn.set(e,t)),t}function Wf(e){yn.delete(e)}function Yf(e,t){const{byId:n,fallback:r}=Kf(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,d=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&d)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function Xf(e,t){const{blocks:n}=It(e);return await n.cache.getIfPresent(t)??void 0}async function Jf(e,t){if(!t.blockId)return;const n=await Xf(e,t.blockId);if(n)return Vf(n,t)}async function Qf(e,t){const n=Yf(e,t);if(n)return jt(e,n);const r=await Jf(t,e);return r?jt(e,r):jt(e,void 0)}var Zf=gs("application_block_inserted"),ep=-1e3,jr=new WeakSet;function tp(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 np(e){if(!e||jr.has(e))return;jr.add(e);const t=new Z,n=X(e);return t.addDisposable(n.addListenerAsyncPipe(Zf,async(r,i)=>{const o=tp(r)?await Qf(r,e):r;return i?i(o):o},ep)),t.addDisposable({dispose:()=>{Wf(e)}}),t}var Br=100,rp=class extends Z{_container;_events;constructor(e){super(),this._container=e;const t=np(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=It(e),o=K(e,j.ON_SHARE_ID),s=K(e,j.ON_SHOW_PREVIEW_ID),d=K(e,j.ON_EMAIL_CLONE_ID),l=K(e,j.ON_CODE_VALIDATE_ID),f=K(e,j.ON_SUBJECT_CHANGED_ID),u=K(e,j.ON_EMAIL_CHANGED_ID),v=K(e,j.ON_PREHEADER_CHANGED_ID),b=K(e,j.ON_SAVEBUTTON_CLICK_ID),y=K(e,j.ON_NEXTBUTTON_CLICK_ID),I=K(e,j.ON_SEND_LIVEPREVIEW_ID),g=K(e,j.ON_SEND_TESTEMAIL_ID),E=K(e,bf),w=K(e,j.ON_CONTENT_CHANGED_ID),S=K(e,vf),A=K(e,j.ON_PREVIOUSBUTTON_CLICK_ID),h=K(e,j.ON_SEND_EMAIL_MODAL_ID),c=hs(K(e,j.ON_EMAIL_INIT_ID),a=>!a.reset);return{handlePreheaderChanged:k(v),handleSubjectChanged:k(f),handleValidate:k(l),handleReadEmail:k(n.handlerRead,a=>a,a=>a&&xe(a,e)),handleSaveEmail:k(n.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?ee(a,e):void 0;return{prev:T,patch:Ge(T,ee(p,e)),value:ee(m,e),source:_}},a=>a?xe(a,e):void 0),handleRemoveEmail:k(n.onRemove,({value:a,source:p})=>({value:ee(a,e),source:p}),()=>{}),handleReadCommonBlocks:k(E,a=>a.project,a=>a?.map(p=>Ue(p,e))),handleReadTemplateBlocks:k(S,a=>a,a=>a?.map(p=>Ue(p,e))),handleReadBlocks:k(t.byForeignKey("project").handleRead,a=>St(e).requested||String(a),a=>a?.map(p=>Ue(p,e))),handleSaveBlock:k(t.onSave,function({prev:a,patch:p,value:m,source:_}){const T=m.global_block===!0&&m.id&&typeof m.html=="string"?{...m,html:Hf(m.html,String(m.id))}:m,D=a?at(a,e):void 0;return{prev:D,patch:Ge(D,at(p,e)),value:at(T,e),source:_}},a=>a?Ue(a,e):void 0),handleRemoveBlock:k(t.onRemove,({value:a,source:p})=>({value:at(a,e),source:p}),()=>{}),handleReadComments:k(r.byForeignKey("post").handleRead,a=>a,a=>a?.map(p=>gn(p,e))),handleSaveComment:k(r.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?lt(a,e):void 0;return{prev:T,patch:Ge(T,lt(p,e)),value:lt(m,e),source:_}},a=>a?gn(a,e):void 0),handleRemoveComment:k(r.onRemove,({value:a,source:p})=>({value:lt(a,e),source:p}),()=>{}),handleReadEmailRevisions:k(i.byForeignKey("parent").handleRead,a=>a,a=>a?.map(p=>vn(p,e))),handleEmailAutosave:k(i.onSave,function({prev:a,patch:p,value:m,source:_}){return{value:Nr(m,e),source:_}},a=>a?vn(a,e):void 0),handleRemoveEmailAutoSave:k(i.onRemove,({value:a,source:p})=>({value:Nr(a,e),source:p}),()=>{}),handleEmailChanged:k(Jn(u,Br),a=>ee(a,e)),handleEmailInit:k(c,a=>ee(a,e)),handlePreviousButtonClick:k(A,a=>ee(a,e)),handleNextButtonClick:k(y,a=>ee(a,e)),handleSaveButtonClick:k(b,a=>ee(a,e)),handleHtmlChanged:k(Jn(w,Br)),handleTestEmailSend:k(g,({html:a,...p})=>({...p,code:a,compiled:{html:a,ampHtml:""}})),handleTestEmailModal:k(h,a=>ee(a,e)),handleCloneEmail:k(d,a=>ee(a,e)),handleShareEmail:k(o),handlePreviewEmail:k(s),handleLivePreviewEmail:k(I)}}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 Re(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},ip=L("DataController"),op=L("DataEvents");function Oo(e){return e.getOrCreateInstance(ip,()=>{const t=new Ff(e);return e.getInstance(F)?.addDisposable(t),t})}function xo(e){return e.getOrCreateInstance(op,()=>new rp(e))}var sp=L("plugin.startupShow");function ap(e){const t=Oo(e),n=xo(e),r=e.getInstance(oe),i=e.getInstance(F),o={current:Promise.resolve()};e.inject(sp,o);const s=r?.watch(l=>{l&&n.setOptions(l)}),d=r?.select(l=>l?.content).watch(l=>{l!==void 0&&(z(J.showStart),o.current=(async()=>{try{await t.show(l)}catch{}finally{z(J.showEnd)}})())});s&&i?.addDisposable(s),d&&i?.addDisposable(d)}function lp(e){const t=Oo(e);return{...xo(e).get(),show(n){return z(J.showStart),t.show(n).finally(()=>z(J.showEnd))},save(){return t.save()}}}var dp=[{name:"rest.client",setup:ff},{name:"auth.oauth",setup:As},{name:"rest.identityHeaders",setup:af},{name:"lifetime.destroyable",provides:[Bn],setup:du},{name:"appInit",provides:[Pe,Pn],setup:ca},{name:"config",provides:[we],setup:au},{name:"email.documents",setup:Cu},{name:"show.initPipeline",provides:[De],setup:pf},{name:"show",setup:ap},{name:"locale.service",provides:[ze],setup:nf},{name:"locale.fromConfig",awaits:{services:[we,ze]},setup:rf},{name:"canvas.early",setup:ac},{name:"canvas.previewSettings",setup:mc},{name:"canvas.sandboxExtensions",setup:vc},{name:"canvas.headerSync",provides:[co],setup:cc},{name:"canvas.ampSync",setup:jl},{name:"canvas.moduleBridge",setup:dd},{name:"canvas.port",setup:Kl},{name:"canvas.images",setup:zl},{name:"canvas.edits",setup:Gd},{name:"canvas.blockContent",setup:Nd},{name:"canvas.sandboxFill",provides:[Fn],setup:Mc},{name:"canvas.reactions",setup:ic}],cp=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function up(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function fp(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function Lo(e){const t=up(e),n=[],r=new Set,i=[],o=new Set,s=d=>{if(!r.has(d)){if(o.has(d)){const l=i.indexOf(d);throw new cp([...i.slice(l),d].map(f=>f.name))}o.add(d),i.push(d);for(const l of fp(d,t))s(l);i.pop(),o.delete(d),r.add(d),n.push(d)}};for(const d of e)s(d);return n}var Ur;function qn(e){const t=e.getInstance(oe);if(t)return t;e.getInstance(F)||e.inject(F,new Z);const n=ke();e.inject(oe,n),Ur??=Lo(dp);for(const r of Ur)r.setup(e);return n}function pp(e){}var hp=[{name:"save.previewFollow",setup:pp}],Hr=L("plugin.lateUnitsInstalled");function mp(e){if(!e.getInstance(Hr)){e.inject(Hr,!0);for(const t of Lo(hp))t.setup(e)}}function gp(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function vp(e){if(!e)return;const t=ui(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 bp=Me(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!mt(t,i.user),d=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(he)||!i.getAuthToken)&&!(!o&&!s&&!d))try{const l=await i.getAuthToken(i.user,i.project);e.inject(Os,Promise.resolve(l||""));const f=vp(l);if(!f)return;e.inject(Ss,f);const u=e.getInstance(Pe),v=u?await u.catch(()=>{}):void 0;e.inject(Pe,Promise.resolve(gp(f,v)))}catch{}}}});function yp(e,t){if(e.getInstance(Yn))return;e.inject(Yn,!0);const n=wn(e,j.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function Ep(e){e.getInstance(ws)||e.inject(he,void 0)}function Tt(e){return String(e.standaloneKey||"").trim()||void 0}function _p(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function $n(e){return _p(e)?!!Tt(e):!1}function At(e){return!!Tt(e)&&!$n(e)}var wp=Me(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!At(r)){t&&(Ep(e),$n(r)),t=void 0;return}const o=Tt(r);if(!o||t===o&&e.getInstance(he))return;t=o,e.inject(he,o);const s=e.getInstance(F);s&&yp(e,s)}}}),Sp=Me(e=>{const t=e.getInstance(F),n=wn(e,di),r=k(n),i=t.addDisposable(new Re(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),Ip=Me(e=>{const t=e.getInstance(F),n=t.addDisposable(new pe),r=t.addDisposable(new pe),i=In(e,Jo),o=k(n.event),s=k(r.event),d=k(i.event),l=t.addDisposable(new Re(o)),f=t.addDisposable(new Re(s)),u=t.addDisposable(new Re(d));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:d},async setOptions(v){l.setListener(v.handleSetOptions),f.setListener(v.handleOptionsChanged),u.setListener(v.handleConfigChanged),await n.fire(v),await r.fire(v)},dispose(){}}}),Bt,Mo="core";function Tp(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Mo],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Ap(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Qe().then(()=>{}):t([Mo],e)}function Qe(){return Bt===void 0&&(Bt=Tp().then(e=>($e()&&e.installDiagnostics().catch(t=>{}),e))),Bt}var Ut=null,Ht=null;async function Cp(e){typeof e?.prefetch=="function"&&await e.prefetch()}function zn(){return Ut||(Ut=Qe().then(()=>{})),Ut}function ko(e){return Ht||(Ht=Cp(e)),Ht}function Rp(){return ko(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Pp(e){return Promise.all([zn(),ko(e)]).then(()=>{})}function Dp(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Gr(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Ap(t?{priority:t}:void 0)).then(()=>n?zn():void 0).catch(()=>{})}function Op(e){const t=Dp(e);if(t==="eager")Gr(e);else if(t==="idle"){const n=()=>Gr(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var No="PluginRegistry";function xp(e=Ps()){return e.getOrCreateInstance(No,()=>new zs)}var Lp=new Vs(()=>xp()),Mp=Me(e=>{let t;function n(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(r){const i=e.getInstance(_t),o=e.getInstance(No);t||(t=new $s(i,o,{ensureHostRuntimeReady:Rp}),e.inject(Zt,t));const s=r?.plugins||[];i&&await t.setPlugins(s)},instance:{use(r){return typeof r=="function"?n().useByCtor(r):n().useByKey(r)},useAsync(r){return n().useAsync(r)},waitPlugin(r){return n().waitFor(r)}},dispose(){t?.dispose(),t=void 0}}}),Fo=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,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}},kp=L("ELEMENT_INSERT_HTML_PIPELINE"),Np=L("BLOCK_INSERT_HTML_PIPELINE"),Fp="application_block_inserted",jp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Np,()=>new Fo).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Ye,()=>new Xe),i=n?e.bind(n):e;return r.addListener(Fp,i,t)}},Bp=L("ComponentRegistry"),qr;function Ve(e,t=Bp){const n=pt.getInstance(t);if(n)return n;if(!qr)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return pt.getOrCreateInstance(t,qr)}var Up=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(et,{execute:n=>{t.dispose(),e(n.value.map(r=>({name:r.name,html:r.html})))}})})}update(e,t){const n=this._container,r=Ve(n);return n.addService(et,{execute:i=>{const o=i.value.find(s=>s.name===e);if(o){const{icon:s,title:d,fallbackTooltip:l,...f}=t;s&&(o.icon=r.getReactNode(s)),d&&(o.title=r.getReactNode(d)),l&&(o.fallbackTooltip=r.getReactNode(l)),Object.assign(o,f)}}})}delete(e){this._container.addService(et,{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,r=Ve(n);return n.addService(et,{execute:i=>{i.value.splice(t??i.value.length,0,{...e,title:r.getReactNode(e.title),icon:r.getReactNode(e.icon),fallbackTooltip:r.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(kp,()=>new Fo).add(e,t??0,n)}handleInject(e,t,n){return Ce(this._container,us).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Hp=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Ye,()=>new Xe)}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 Gp(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var qp=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ce(t,ls),this._closeModalEmitter=Ce(t,os),this._updateModalEmitter=Ce(t,fs)}get _container(){return this._context.container}show(e){const t=Ve(this._container),n=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r=e.modalProps;return this._showModalEmitter.fire({...e,content:t.getReactNode(e.content),title:t.getReactNode(e.title),id:n,modalProps:r?{...r,footer:t.getReactNode(r.footer),okText:t.getReactNode(r.okText),cancelText:t.getReactNode(r.cancelText),closeIcon:t.getReactNode(r.closeIcon)}:void 0}),n}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=Ve(this._container),r=t.modalProps;this._updateModalEmitter.fire(Gp({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},$p=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),n())},s=d=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),r(d))};this._resolveLoaded=o,this._rejectLoaded=s}),this.ready=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),n())},s=d=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),r(d))};this._resolveReady=o,this._rejectReady=s})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},zp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Ye,()=>new Xe)}_createScriptHandle(e,t){const n=this._messageService.addListener(Zo,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new $p(t,n);return r}registerSandboxCSS(e){return this._container.addService(Te,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Te,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},Vp=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function En(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Vp.has(t)}function jo(){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 Gt(){return`__settingsPanel:${jo()}`}function qt(e,t){return{type:e,props:t}}function Kp(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!En(e)}function $r(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(En(t)){const r=Gt();return n(e.add(r,t)),qt(r,{})}if(typeof t=="function"){const r=Gt();return n(e.add(r,t)),qt(r,{})}if(Kp(t)){const r=t.type;if(typeof r=="string")return t;if(En(r)||typeof r=="function"){const i=Gt();return n(e.add(i,r)),qt(i,t.props)}return t}return t}var Wp=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=Ve(this._container),n=s=>this._trackRegistration(s),r=$r(t,e.content,n),i=e.advancedTabs?.map(s=>({...s,content:$r(t,s.content,n)})),o=e.instanceKey??jo();Ce(this._container,Wn).fire({...e,content:r,advancedTabs:i,instanceKey:o,type:ds})}closeSettingsPanel(){this._clearPanelRegistrations(),Ce(this._container,Wn).fire(null)}},Bo={SandboxScriptApi:zp,ElementsApi:Up,BlocksApi:jp,MessageService:Hp,SettingsPanelApi:Wp,ModalApi:qp};function $t(e,t,n,r={}){const i=Object.assign({},e);for(const[o,s]of Object.entries(t))if(s!==void 0)if(n.includes(o)&&typeof s=="object"&&s!==null){const d=i[o],l=r[o]??{};i[o]=Object.assign({},typeof d=="object"&&d!==null?d:l,s)}else i[o]=s;return i}var te={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}},Yp={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"},zt={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},zr={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Ie={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:te.border,borderRadius:te.borderRadius,textAlign:"center",padding:te.padding},Vr={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:te.padding},Vt={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:te.border,borderRadius:te.borderRadiusCards};function Xp(e){return{...Yp,...e}}function Jp(e){return{...zt,...e,bold:e?.bold??zt.bold,italic:e?.italic??zt.italic}}function Qp(e){return{...zr,...e,underline:e?.underline??zr.underline}}function Zp(e){return{...Ie,...e,bold:e?.bold??Ie.bold,italic:e?.italic??Ie.italic,border:{...Ie.border,...e?.border},borderRadius:{...Ie.borderRadius,...e?.borderRadius},padding:{...Ie.padding,...e?.padding}}}function eh(e){return{...Vr,...e,padding:{...Vr.padding,...e?.padding}}}function th(e){return{...Vt,...e,border:{...Vt.border,...e?.border},borderRadius:{...Vt.borderRadius,...e?.borderRadius}}}function Kt(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 Kr(e){let t={...Sn};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Wt(e){return{text:Xp(e.text),headings:Jp(e.headings),links:Qp(e.links),buttons:Zp(e.buttons),block:eh(e.block),cards:th(e.cards)}}var Wr=L("EmailSettingsPort"),nh=1e4,Uo=class{_editor;_layoutSettingsChanged=new en;_contentStylesChanged=new en;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(Wr);if(!t)throw new Error("[extensions] настройки письма ещё не загружены — работа с UI начинается с init()");return t}_getCurrentLayoutSettings(){return Kt(this._settings().read())}_getCurrentContentStyles(){const e=Pt(this._editor.container)?.current()?.get().attributes.common_styles;return Wt(Kr(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(Wr),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Ye,()=>new Xe),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const i=r?.data,o=i?.operation;if(o===N.APPLICATION_EMAIL_SETTINGS_SET){const l=Kt(i?.settings),f=this._getLayoutSnapshot(l);f!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=f,this._layoutSettingsChanged.fire(l));return}if(o!==N.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Wt(r.data?.settings?.commonStyles??{...Sn}),d=this._getContentSnapshot(s);d!==this._prevContentSnapshot&&(this._prevContentSnapshot=d,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=Kt(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=nh){const t=Pt(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,i=wn(r,j.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,d;const l=()=>{d&&(clearTimeout(d),d=void 0)},f=i(()=>{s||(s=!0,l(),f.dispose(),o())});d=setTimeout(()=>{s||(s=!0,f.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Pt(this._editor.container)?.current();if(!t)return;const n=Kr(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=$t(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:te.border,borderRadius:te.borderRadius,padding:te.padding})),e.block!==void 0&&(n.block=$t(n.block||{},e.block,["padding"],{padding:te.padding})),e.cards!==void 0&&(n.cards=$t(n.cards||{},e.cards,["border","borderRadius"],{border:te.border,borderRadius:te.borderRadiusCards}));const r=JSON.stringify(n);vt(t,{common_styles:r}),this._settings().markAppearanceChanged();const i=Wt(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},rh={...Bo,EmailSettingsApi:Uo},ih={...Bo},Pm={...ih,EmailSettingsApi:Uo},oh={...rh};function sh(){Lp.addAll(oh)}var ah=[Me(()=>{sh()}),Sp,Ip,wp,Cs,bp,Ms];async function lh(){return(await Qe()).asyncMixins}var dh=Mp,ch=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await lh()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(_t);Object.assign(o,t.instance||{});for(const s of e.getInstance(fi)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},uh=bs([...ah]);function Yt(){let e,t=!1;const n=new Map,r=new Map;function i(){for(const o of r.values())o();r.clear()}return{event(o,s,d){const l=Symbol("subscription");return t||(n.set(l,{listener:o,priority:s,thisArg:d}),e&&r.set(l,e(o,s,d))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(o){i(),e=o;for(const[s,{listener:d,priority:l,thisArg:f}]of n)r.set(s,o(d,l,f))},dispose(){t=!0,i(),n.clear(),e=void 0}}}function fh(e){const t=Yt(),n=Yt(),r=Yt();return e.getInstance(F)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(bn).then(i=>{t.attach(i.onNotify),n.attach(i.onError),r.attach(i.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(i){const o=e.getInstance(bn);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(i)}}}var ph=[cu,lp,fh];function hh(e,t=ph){const n=qn(e);mp(e);const r=uh(e),i=dh(e),o=ch(e),s={...r.instance,...i.instance,...o.instance};for(const l of t)Object.assign(s,l(e));let d=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const f=d&&n.get()===l;d=!1,f||n.set(l),await i.setOptions(l),await o.setOptions(l)}}}var mh=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]}},gh="editor-runtime.react.copies",Xt=8;function Ke(e){return e&&typeof e=="object"?e:void 0}function Yr(e){const t=Ke(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Ke(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function vh(e){const t=Ke(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Ke(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function bh(e,t,n){return e.package===t&&e.version===n}function yh({ourReact:e,entries:t,packageName:n,version:r}){const i=Yr(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const d of t){const l=Ke(d);if(!l||!bh(l,n,r))continue;const f=Yr(l.react);!f||f===i||s.has(f)||(s.add(f),o.push({package:n,version:r,reactVersion:vh(l.react),react:l.react}))}return o}function Eh({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,Xt))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Xt&&n.push(` …and ${t.length-Xt} 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(`
1047
- `)}var Xr=new Set;function _h({packageName:e="useblocks",version:t="1.1.85-dev.7",log:n=r=>{}}={}){const r=i=>{try{const o=globalThis[Symbol.for(gh)],s=yh({ourReact:i,entries:o,packageName:e,version:t}).filter(d=>!Xr.has(d.react));if(!s.length)return;s.forEach(d=>Xr.add(d.react)),n(Eh({packageName:e,copies:s}))}catch{}};try{const i=Cn()?.modules?.React;if(i&&typeof i.then=="function"){i.then(r,()=>{});return}r(i)}catch{}}async function wh(e,t,n){$(e.signal);const r=t??pt.createChild();qn(r);const i=r.getInstance(F);async function o(){r.inject(Qo,new mh),_h();const s=hh(r),d={...s.instance,container:r,async reset(l){if($(l.signal),i.isDisposed())throw Rn();return await s.setOptions(l),d}};r.inject(_t,d);try{if(n?.onInstance?.(d),await s.setOptions(e),$(e.signal),i.isDisposed()||await r.getInstance(Zt)?.activate(),e.devTools)try{const l=r.getInstance(Zt);l&&await(await Qe()).initDevTools(r,l)}catch{}return $(e.signal),In(r,di).fire(d),d}catch(l){throw i.dispose(),l}}try{return await ht(o(),e.signal)}catch(s){throw i.isDisposed()||i.dispose(),s}}var We=new WeakMap;function Sh(e){return e?We.get(e):void 0}function Ho(e){try{e.getInstance(F)?.dispose()}catch{}try{e.dispose()}catch{}}function Ih(e,t){if(!e)return;const n=We.get(e);n&&n!==t&&Ho(n),We.set(e,t)}function Th(e,t){e&&We.get(e)===t&&We.delete(e)}function Ah(e){const t=pt.createChild();return At(e)&&t.inject(he,Tt(e)),t}var qe=new WeakMap,Ch="data-useblocks-config-styles";function Rh(e){return typeof e=="string"?e.trim():""}function Jr(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Ph(e,t,n){if(!e||typeof document>"u")return null;const r=Rh(t),i=qe.get(e),o=n||e;if(!r)return i&&(i.remove(),qe.delete(e)),null;if(i)return i.textContent!==r&&(i.textContent=r),(i.parentNode!==o||i!==o.firstChild)&&Jr(o,i),i;const s=document.createElement("style");return s.setAttribute(Ch,"true"),s.textContent=r,Jr(o,s),qe.set(e,s),s}function Dh(e){if(!e)return;const t=qe.get(e);t&&(t.remove(),qe.delete(e))}function Go(){return!1}var Oh=`
1046
+ `)}function Ur(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Mf(e,t,n,r){const i=kf(e,t,n,r);return i===void 0}function kf(e,t,n,r){const{email:i}=Kn(t,!1),o=xe(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const d=jn(e)?.current();if(!d)return"no-session";const a=d.get(),f=a.attributes;if(a.serverId!==s)return"document-id";if(f.is_inited!==!0)return"not-inited";const u=Ur(vn(n??d.getContent()));if(o.html!==void 0&&Ur(vn(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==f.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==f.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==f.common_styles)return"common_styles"}function Hr(e,t){const{email:n}=Kn(t,!1),r=xe(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:vn(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Nf(e,t){const n={...e};return delete n.id,{...n,...t}}function Ff(e){return e.html?e:{...e,html:xo}}function Ue({code:e,project:t,...n},r,i){const o=i??Lo(r);return{...n,...e?{html:ke(r).toEditorForm(e)}:{},renderGuid:ce(),...o===void 0?{}:{project:o}}}function lt({html:e,renderGuid:t,...n},r){const{requested:i}=St(r);return ge({...n,code:ke(r).toOutputForm(e),project:i===void 0?n.project:i,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 No(e){return jn(e)?.current()?.get().serverId??void 0}function bn(e,t,n){return n===void 0&&(n=e.post===void 0?No(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function dt(e,t){return ge({...e,link:void 0,comment_status:void 0})}function En({code:e,...t},n,r){return r===void 0&&(r=t.parent===void 0?No(n):t.parent),{...t,...e?{html:e}:{},parent:r}}function Gr({html:e,...t},n){return ge({...t,code:e,guid:void 0,compiled:ge({html:e,ampHtml:e&&""})})}var yn=L("NotificationService"),jf=L("emailTemplate.reads");async function Bf(e,t){try{return await Se(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,Hf(e,t,n);return}}var Uf=L("emailTemplate.notifiedFailures");function Hf(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(Uf,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(yn).then(()=>{Pn(e,B.ON_NOTIFICATION).fire({type:"error",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function Gf(e,t){const n=e.getOrCreateInstance(jf,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=Bf(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var qf="EXTERNAL";function $f(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"сохранение не состоялось")}var zf="email_id",Vf=class extends ee{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_dataSources;_eventLock;_queue=qs();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=It(t),this._eventLock=xf(t);const n=K(e,B.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(Dn,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(zf,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(De)??Hn}_throwIfDestroyed(){if(this.isDisposed())throw Ln()}async getTemplateEmail(e){const t=await Gf(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Ft(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Ue(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,En(i,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,bn(i,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,i){const o=this._dataSources.emails,s=o.cache,d=await Ft(this._container),a=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let f=xe(e,this._container);const u=f.id;let v=u;if(u!==void 0){const b=await o.get(u);f={...b??{},...f,renderGuid:b?.renderGuid??ce(),...a>0?{showToken:a}:{},...i?{showId:i}:{},project:d}}else{v=n??ce();const b=await o.get(v);f={...f,renderGuid:b?.renderGuid??ce(),...a>0?{showToken:a}:{},...i?{showId:i}:{},project:d},delete f.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(f=Nf(b,f))}return u===void 0&&(f=Ff(f)),await s.addOrUpdate(v,()=>f),f}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Hr(this._container,e))return!1;const n=ft(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Hr(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:ft(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&t!==this._showRequests){this._showRequests;return}if(!e)return;const n=this._getInitPipeline();if($(n.signal),Mf(this._container,e,ft(this._container),this._prevCommand?.id)||this._isRepeatOfLastShow(e))return;const r=Kn(e);r.email.id,this._prevCommand?.id;let i,o="",s=0,d=!1,a,f=Promise.resolve(),u,v=!1;try{this._eventLock.suspendChange();const{email:b,blocks:E,autosaves:I,comments:g,templateId:y,reload:_}=r;i=b.id;const S=xe(b,this._container),A=S.id,h=A??ce(),c=await He("getProject",Ft(this._container));$(n.signal),o=ce();const l={isNew:A===void 0,id:String(h),project:c},p=_===!0&&A!==void 0;p&&(await this._dataSources.emails.remove(String(A),{silent:!0}),String(A)),s=++this._showToken,String(h);const m=[];m.push(this.setBlocks(E)),b.id!==void 0&&(m.push(this.setComments(g)),m.push(this.setEmailRevisions(I,String(b.id)))),m.push(this.setEmail(b,Number(y),A===void 0?String(h):void 0,s,o)),await He("setEmail+blocks+revisions",Promise.all(m),{emailId:A??String(h),showId:o,targetShowToken:s}),$(n.signal);const w=await this._dataSources.emails.get(String(h)),T=ve(this._container),O={id:o,token:s};A===void 0?u=T.startNewDraft(w??S,{patch:S,show:O}):p?u=T.reload(A,{email:w??S,patch:S,show:O}):T.sessionKey()===je(A)?u=T.show(S,O):u=T.open(A,{email:w??S,patch:S,show:O});const k=!!this._prevCommand&&ht(this._prevCommand,l);l.id,!this._prevCommand||ht(this._prevCommand,l),this._prevCommand?.id,this._rememberShow(l),f=n.requestShow({showId:o,navId:String(h),emailId:A,isNew:A===void 0}),v=!0,String(h),d=!0}catch(b){a=b,v&&o&&n.failShow(o,b),An(b)||(xi(b),void 0)}finally{this._eventLock.resumeChange()}if(!d)throw a instanceof Error?a:new Error(`[useblocks] show() setup failed: ${String(a??"unknown error")}`);return He("show-init-deferred",Promise.all([f,u?.whenReady().catch(b=>{if(b instanceof gt){const E=qi(b);throw E?new Error(`[useblocks] show(): email open failed (${E})`,{cause:b}):b}})??Promise.resolve()]).then(()=>{}),{showId:o,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();$(e.signal);const t=ve(this._container),n=await t.save("publish",{source:qf});if($(e.signal),!n)throw $f(t.saveState().error);return te(Lf(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function Kf(e){return String(e).replace(/"/g,"&quot;")}function Wf(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 Yf(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 qr(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=Kf(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function Xf(e,t,n){if(!e?.trim()||!t)return e;const r=Yf(e);if(!r)return e;const i=String(t),o=Wf(n??new Date);let{full:s,index:d}=r;const a=s.length;return/\bem-block-id\s*=/.test(s)||(s=qr(s,"em-block-id",i)),s=qr(s,"em-block-version",o),e.slice(0,d)+s+e.slice(d+a)}function Jf(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 Qf(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=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:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Jf(e)}}function jt(e,t){return t?Qf(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Fo=["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"],Zf=[...Fo,"html","id","project","password"],jm=new Set(["html",...Fo,"global_block","project"]);function ep(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(Zf),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function tp(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...ep(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 _n=new WeakMap;function np(e){let t=_n.get(e);return t||(t={byId:new Map,fallback:[]},_n.set(e,t)),t}function rp(e){_n.delete(e)}function ip(e,t){const{byId:n,fallback:r}=np(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,d=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&d)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function op(e,t){const{blocks:n}=It(e);return await n.cache.getIfPresent(t)??void 0}async function sp(e,t){if(!t.blockId)return;const n=await op(e,t.blockId);if(n)return tp(n,t)}async function ap(e,t){const n=ip(e,t);if(n)return jt(e,n);const r=await sp(t,e);return r?jt(e,r):jt(e,void 0)}var lp=Ts("application_block_inserted"),dp=-1e3,$r=new WeakSet;function cp(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 up(e){if(!e||$r.has(e))return;$r.add(e);const t=new ee,n=X(e);return t.addDisposable(n.addListenerAsyncPipe(lp,async(r,i)=>{const o=cp(r)?await ap(r,e):r;return i?i(o):o},dp)),t.addDisposable({dispose:()=>{rp(e)}}),t}var zr=100,fp=class extends ee{_container;_events;constructor(e){super(),this._container=e;const t=up(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=It(e),o=K(e,B.ON_SHARE_ID),s=K(e,B.ON_SHOW_PREVIEW_ID),d=K(e,B.ON_EMAIL_CLONE_ID),a=K(e,B.ON_CODE_VALIDATE_ID),f=K(e,B.ON_SUBJECT_CHANGED_ID),u=K(e,B.ON_EMAIL_CHANGED_ID),v=K(e,B.ON_PREHEADER_CHANGED_ID),b=K(e,B.ON_SAVEBUTTON_CLICK_ID),E=K(e,B.ON_NEXTBUTTON_CLICK_ID),I=K(e,B.ON_SEND_LIVEPREVIEW_ID),g=K(e,B.ON_SEND_TESTEMAIL_ID),y=K(e,Af),_=K(e,B.ON_CONTENT_CHANGED_ID),S=K(e,Tf),A=K(e,B.ON_PREVIOUSBUTTON_CLICK_ID),h=K(e,B.ON_SEND_EMAIL_MODAL_ID),c=Ss(K(e,B.ON_EMAIL_INIT_ID),l=>!l.reset);return{handlePreheaderChanged:N(v),handleSubjectChanged:N(f),handleValidate:N(a),handleReadEmail:N(n.handlerRead,l=>l,l=>l&&xe(l,e)),handleSaveEmail:N(n.onSave,function({prev:l,patch:p,value:m,source:w}){const T=l?te(l,e):void 0;return{prev:T,patch:Ge(T,te(p,e)),value:te(m,e),source:w}},l=>l?xe(l,e):void 0),handleRemoveEmail:N(n.onRemove,({value:l,source:p})=>({value:te(l,e),source:p}),()=>{}),handleReadCommonBlocks:N(y,l=>l.project,l=>l?.map(p=>Ue(p,e))),handleReadTemplateBlocks:N(S,l=>l,l=>l?.map(p=>Ue(p,e))),handleReadBlocks:N(t.byForeignKey("project").handleRead,l=>St(e).requested||String(l),l=>l?.map(p=>Ue(p,e))),handleSaveBlock:N(t.onSave,function({prev:l,patch:p,value:m,source:w}){const T=m.global_block===!0&&m.id&&typeof m.html=="string"?{...m,html:Xf(m.html,String(m.id))}:m,O=l?lt(l,e):void 0;return{prev:O,patch:Ge(O,lt(p,e)),value:lt(T,e),source:w}},l=>l?Ue(l,e):void 0),handleRemoveBlock:N(t.onRemove,({value:l,source:p})=>({value:lt(l,e),source:p}),()=>{}),handleReadComments:N(r.byForeignKey("post").handleRead,l=>l,l=>l?.map(p=>bn(p,e))),handleSaveComment:N(r.onSave,function({prev:l,patch:p,value:m,source:w}){const T=l?dt(l,e):void 0;return{prev:T,patch:Ge(T,dt(p,e)),value:dt(m,e),source:w}},l=>l?bn(l,e):void 0),handleRemoveComment:N(r.onRemove,({value:l,source:p})=>({value:dt(l,e),source:p}),()=>{}),handleReadEmailRevisions:N(i.byForeignKey("parent").handleRead,l=>l,l=>l?.map(p=>En(p,e))),handleEmailAutosave:N(i.onSave,function({prev:l,patch:p,value:m,source:w}){return{value:Gr(m,e),source:w}},l=>l?En(l,e):void 0),handleRemoveEmailAutoSave:N(i.onRemove,({value:l,source:p})=>({value:Gr(l,e),source:p}),()=>{}),handleEmailChanged:N(rr(u,zr),l=>te(l,e)),handleEmailInit:N(c,l=>te(l,e)),handlePreviousButtonClick:N(A,l=>te(l,e)),handleNextButtonClick:N(E,l=>te(l,e)),handleSaveButtonClick:N(b,l=>te(l,e)),handleHtmlChanged:N(rr(_,zr)),handleTestEmailSend:N(g,({html:l,...p})=>({...p,code:l,compiled:{html:l,ampHtml:""}})),handleTestEmailModal:N(h,l=>te(l,e)),handleCloneEmail:N(d,l=>te(l,e)),handleShareEmail:N(o),handlePreviewEmail:N(s),handleLivePreviewEmail:N(I)}}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 Re(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},pp=L("DataController"),hp=L("DataEvents");function jo(e){return e.getOrCreateInstance(pp,()=>{const t=new Vf(e);return e.getInstance(j)?.addDisposable(t),t})}function Bo(e){return e.getOrCreateInstance(hp,()=>new fp(e))}var mp=L("plugin.startupShow");function gp(e){const t=jo(e),n=Bo(e),r=e.getInstance(se),i=e.getInstance(j),o={current:Promise.resolve()};e.inject(mp,o);const s=r?.watch(a=>{a&&n.setOptions(a)}),d=r?.select(a=>a?.content).watch(a=>{a!==void 0&&(z(Q.showStart),o.current=(async()=>{try{await t.show(a)}catch{}finally{z(Q.showEnd)}})())});s&&i?.addDisposable(s),d&&i?.addDisposable(d)}function vp(e){const t=jo(e);return{...Bo(e).get(),show(n){return z(Q.showStart),t.show(n).finally(()=>z(Q.showEnd))},save(){return t.save()}}}var bp=[{name:"rest.client",setup:yf},{name:"auth.oauth",setup:ks},{name:"rest.identityHeaders",setup:mf},{name:"lifetime.destroyable",provides:[$n],setup:vu},{name:"appInit",provides:[Pe,Mn],setup:ba},{name:"config",provides:[we],setup:mu},{name:"email.documents",setup:ku},{name:"show.initPipeline",provides:[De],setup:_f},{name:"show",setup:gp},{name:"locale.service",provides:[ze],setup:uf},{name:"locale.fromConfig",awaits:{services:[we,ze]},setup:ff},{name:"canvas.early",setup:mc},{name:"canvas.previewSettings",setup:Sc},{name:"canvas.sandboxExtensions",setup:Tc},{name:"canvas.headerSync",provides:[vo],setup:bc},{name:"canvas.ampSync",setup:Vl},{name:"canvas.moduleBridge",setup:vd},{name:"canvas.port",setup:td},{name:"canvas.images",setup:Zl},{name:"canvas.edits",setup:Xd},{name:"canvas.blockContent",setup:$d},{name:"canvas.sandboxFill",provides:[Gn],setup:Gc},{name:"canvas.reactions",setup:fc}],Ep=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function yp(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function _p(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function Uo(e){const t=yp(e),n=[],r=new Set,i=[],o=new Set,s=d=>{if(!r.has(d)){if(o.has(d)){const a=i.indexOf(d);throw new Ep([...i.slice(a),d].map(f=>f.name))}o.add(d),i.push(d);for(const a of _p(d,t))s(a);i.pop(),o.delete(d),r.add(d),n.push(d)}};for(const d of e)s(d);return n}var Vr;function Wn(e){const t=e.getInstance(se);if(t)return t;e.getInstance(j)||e.inject(j,new ee);const n=Me();e.inject(se,n),Vr??=Uo(bp);for(const r of Vr)r.setup(e);return n}function wp(e){}var Sp=[{name:"save.previewFollow",setup:wp}],Kr=L("plugin.lateUnitsInstalled");function Ip(e){if(!e.getInstance(Kr)){e.inject(Kr,!0);for(const t of Uo(Sp))t.setup(e)}}function Tp(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function Ap(e){if(!e)return;const t=vi(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 Cp=Le(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!ht(t,i.user),d=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(he)||!i.getAuthToken)&&!(!o&&!s&&!d))try{const a=await i.getAuthToken(i.user,i.project);e.inject(Bs,Promise.resolve(a||""));const f=Ap(a);if(!f)return;e.inject(xs,f);const u=e.getInstance(Pe),v=u?await u.catch(()=>{}):void 0;e.inject(Pe,Promise.resolve(Tp(f,v)))}catch{}}}});function Rp(e,t){if(e.getInstance(tr))return;e.inject(tr,!0);const n=Cn(e,B.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function Pp(e){e.getInstance(Os)||e.inject(he,void 0)}function Tt(e){return String(e.standaloneKey||"").trim()||void 0}function Dp(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function Yn(e){return Dp(e)?!!Tt(e):!1}function At(e){return!!Tt(e)&&!Yn(e)}var Op=Le(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!At(r)){t&&(Pp(e),Yn(r)),t=void 0;return}const o=Tt(r);if(!o||t===o&&e.getInstance(he))return;t=o,e.inject(he,o);const s=e.getInstance(j);s&&Rp(e,s)}}}),xp=Le(e=>{const t=e.getInstance(j),n=Cn(e,mi),r=N(n),i=t.addDisposable(new Re(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),Lp=Le(e=>{const t=e.getInstance(j),n=t.addDisposable(new pe),r=t.addDisposable(new pe),i=Pn(e,os),o=N(n.event),s=N(r.event),d=N(i.event),a=t.addDisposable(new Re(o)),f=t.addDisposable(new Re(s)),u=t.addDisposable(new Re(d));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:d},async setOptions(v){a.setListener(v.handleSetOptions),f.setListener(v.handleOptionsChanged),u.setListener(v.handleConfigChanged),await n.fire(v),await r.fire(v)},dispose(){}}}),Bt,Ho="core";function Mp(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Ho],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function kp(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Qe().then(()=>{}):t([Ho],e)}function Qe(){return Bt===void 0&&(Bt=Mp().then(e=>($e()&&e.installDiagnostics().catch(t=>{}),e))),Bt}var Ut=null,Ht=null;async function Np(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Xn(){return Ut||(Ut=Qe().then(()=>{})),Ut}function Go(e){return Ht||(Ht=Np(e)),Ht}function Fp(){return Go(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function jp(e){return Promise.all([Xn(),Go(e)]).then(()=>{})}function Bp(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Wr(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>kp(t?{priority:t}:void 0)).then(()=>n?Xn():void 0).catch(()=>{})}function Up(e){const t=Bp(e);if(t==="eager")Wr(e);else if(t==="idle"){const n=()=>Wr(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var qo="PluginRegistry";function Hp(e=vs()){return e.getOrCreateInstance(qo,()=>new Zs)}var Gp=new ea(()=>Hp()),qp=Le(e=>{let t;function n(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(r){const i=e.getInstance(_t),o=e.getInstance(qo);t||(t=new Qs(i,o,{ensureHostRuntimeReady:Fp}),e.inject(tn,t));const s=r?.plugins||[];i&&await t.setPlugins(s)},instance:{use(r){return typeof r=="function"?n().useByCtor(r):n().useByKey(r)},useAsync(r){return n().useAsync(r)},waitPlugin(r){return n().waitFor(r)}},dispose(){t?.dispose(),t=void 0}}}),$o=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,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}},$p=L("ELEMENT_INSERT_HTML_PIPELINE"),zp=L("BLOCK_INSERT_HTML_PIPELINE"),Vp="application_block_inserted",Kp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(zp,()=>new $o).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Ye,()=>new Xe),i=n?e.bind(n):e;return r.addListener(Vp,i,t)}},Wp=L("ComponentRegistry"),Yr;function Ve(e,t=Wp){const n=mt.getInstance(t);if(n)return n;if(!Yr)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return mt.getOrCreateInstance(t,Yr)}var Yp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(tt,{execute:n=>{t.dispose(),e(n.value.map(r=>({name:r.name,html:r.html})))}})})}update(e,t){const n=this._container,r=Ve(n);return n.addService(tt,{execute:i=>{const o=i.value.find(s=>s.name===e);if(o){const{icon:s,title:d,fallbackTooltip:a,...f}=t;s&&(o.icon=r.getReactNode(s)),d&&(o.title=r.getReactNode(d)),a&&(o.fallbackTooltip=r.getReactNode(a)),Object.assign(o,f)}}})}delete(e){this._container.addService(tt,{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,r=Ve(n);return n.addService(tt,{execute:i=>{i.value.splice(t??i.value.length,0,{...e,title:r.getReactNode(e.title),icon:r.getReactNode(e.icon),fallbackTooltip:r.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance($p,()=>new $o).add(e,t??0,n)}handleInject(e,t,n){return Ce(this._container,ys).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Xp=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Ye,()=>new Xe)}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 Jp(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var Qp=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ce(t,ms),this._closeModalEmitter=Ce(t,fs),this._updateModalEmitter=Ce(t,_s)}get _container(){return this._context.container}show(e){const t=Ve(this._container),n=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r=e.modalProps;return this._showModalEmitter.fire({...e,content:t.getReactNode(e.content),title:t.getReactNode(e.title),id:n,modalProps:r?{...r,footer:t.getReactNode(r.footer),okText:t.getReactNode(r.okText),cancelText:t.getReactNode(r.cancelText),closeIcon:t.getReactNode(r.closeIcon)}:void 0}),n}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=Ve(this._container),r=t.modalProps;this._updateModalEmitter.fire(Jp({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},Zp=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),n())},s=d=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),r(d))};this._resolveLoaded=o,this._rejectLoaded=s}),this.ready=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),n())},s=d=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),r(d))};this._resolveReady=o,this._rejectReady=s})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},eh=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Ye,()=>new Xe)}_createScriptHandle(e,t){const n=this._messageService.addListener(as,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new Zp(t,n);return r}registerSandboxCSS(e){return this._container.addService(Te,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Te,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},th=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function wn(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&th.has(t)}function zo(){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 Gt(){return`__settingsPanel:${zo()}`}function qt(e,t){return{type:e,props:t}}function nh(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!wn(e)}function Xr(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(wn(t)){const r=Gt();return n(e.add(r,t)),qt(r,{})}if(typeof t=="function"){const r=Gt();return n(e.add(r,t)),qt(r,{})}if(nh(t)){const r=t.type;if(typeof r=="string")return t;if(wn(r)||typeof r=="function"){const i=Gt();return n(e.add(i,r)),qt(i,t.props)}return t}return t}var rh=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=Ve(this._container),n=s=>this._trackRegistration(s),r=Xr(t,e.content,n),i=e.advancedTabs?.map(s=>({...s,content:Xr(t,s.content,n)})),o=e.instanceKey??zo();Ce(this._container,er).fire({...e,content:r,advancedTabs:i,instanceKey:o,type:gs})}closeSettingsPanel(){this._clearPanelRegistrations(),Ce(this._container,er).fire(null)}},Vo={SandboxScriptApi:eh,ElementsApi:Yp,BlocksApi:Kp,MessageService:Xp,SettingsPanelApi:rh,ModalApi:Qp};function $t(e,t,n,r={}){const i=Object.assign({},e);for(const[o,s]of Object.entries(t))if(s!==void 0)if(n.includes(o)&&typeof s=="object"&&s!==null){const d=i[o],a=r[o]??{};i[o]=Object.assign({},typeof d=="object"&&d!==null?d:a,s)}else i[o]=s;return i}var ne={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}},ih={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"},zt={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},Jr={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Ie={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:ne.border,borderRadius:ne.borderRadius,textAlign:"center",padding:ne.padding},Qr={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:ne.padding},Vt={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:ne.border,borderRadius:ne.borderRadiusCards};function oh(e){return{...ih,...e}}function sh(e){return{...zt,...e,bold:e?.bold??zt.bold,italic:e?.italic??zt.italic}}function ah(e){return{...Jr,...e,underline:e?.underline??Jr.underline}}function lh(e){return{...Ie,...e,bold:e?.bold??Ie.bold,italic:e?.italic??Ie.italic,border:{...Ie.border,...e?.border},borderRadius:{...Ie.borderRadius,...e?.borderRadius},padding:{...Ie.padding,...e?.padding}}}function dh(e){return{...Qr,...e,padding:{...Qr.padding,...e?.padding}}}function ch(e){return{...Vt,...e,border:{...Vt.border,...e?.border},borderRadius:{...Vt.borderRadius,...e?.borderRadius}}}function Kt(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 Zr(e){let t={...Rn};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Wt(e){return{text:oh(e.text),headings:sh(e.headings),links:ah(e.links),buttons:lh(e.buttons),block:dh(e.block),cards:ch(e.cards)}}var ei=L("EmailSettingsPort"),uh=1e4,Ko=class{_editor;_layoutSettingsChanged=new nn;_contentStylesChanged=new nn;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(ei);if(!t)throw new Error("[extensions] настройки письма ещё не загружены — работа с UI начинается с init()");return t}_getCurrentLayoutSettings(){return Kt(this._settings().read())}_getCurrentContentStyles(){const e=Pt(this._editor.container)?.current()?.get().attributes.common_styles;return Wt(Zr(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(ei),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Ye,()=>new Xe),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const i=r?.data,o=i?.operation;if(o===F.APPLICATION_EMAIL_SETTINGS_SET){const a=Kt(i?.settings),f=this._getLayoutSnapshot(a);f!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=f,this._layoutSettingsChanged.fire(a));return}if(o!==F.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Wt(r.data?.settings?.commonStyles??{...Rn}),d=this._getContentSnapshot(s);d!==this._prevContentSnapshot&&(this._prevContentSnapshot=d,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=Kt(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=uh){const t=Pt(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,i=Cn(r,B.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,d;const a=()=>{d&&(clearTimeout(d),d=void 0)},f=i(()=>{s||(s=!0,a(),f.dispose(),o())});d=setTimeout(()=>{s||(s=!0,f.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Pt(this._editor.container)?.current();if(!t)return;const n=Zr(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=$t(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:ne.border,borderRadius:ne.borderRadius,padding:ne.padding})),e.block!==void 0&&(n.block=$t(n.block||{},e.block,["padding"],{padding:ne.padding})),e.cards!==void 0&&(n.cards=$t(n.cards||{},e.cards,["border","borderRadius"],{border:ne.border,borderRadius:ne.borderRadiusCards}));const r=JSON.stringify(n);vt(t,{common_styles:r}),this._settings().markAppearanceChanged();const i=Wt(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},fh={...Vo,EmailSettingsApi:Ko},ph={...Vo},Bm={...ph,EmailSettingsApi:Ko},hh={...fh};function mh(){Gp.addAll(hh)}var gh=[Le(()=>{mh()}),xp,Lp,Op,Ns,Cp,Gs];async function vh(){return(await Qe()).asyncMixins}var bh=qp,Eh=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await vh()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(_t);Object.assign(o,t.instance||{});for(const s of e.getInstance(bi)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},yh=Cs([...gh]);function Yt(){let e,t=!1;const n=new Map,r=new Map;function i(){for(const o of r.values())o();r.clear()}return{event(o,s,d){const a=Symbol("subscription");return t||(n.set(a,{listener:o,priority:s,thisArg:d}),e&&r.set(a,e(o,s,d))),()=>{n.delete(a),r.get(a)?.(),r.delete(a)}},attach(o){i(),e=o;for(const[s,{listener:d,priority:a,thisArg:f}]of n)r.set(s,o(d,a,f))},dispose(){t=!0,i(),n.clear(),e=void 0}}}function _h(e){const t=Yt(),n=Yt(),r=Yt();return e.getInstance(j)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(yn).then(i=>{t.attach(i.onNotify),n.attach(i.onError),r.attach(i.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(i){const o=e.getInstance(yn);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(i)}}}var wh=[bu,vp,_h];function Sh(e,t=wh){const n=Wn(e);Ip(e);const r=yh(e),i=bh(e),o=Eh(e),s={...r.instance,...i.instance,...o.instance};for(const a of t)Object.assign(s,a(e));let d=!0;return{instance:s,async setOptions(a){await r.setOptions(a);const f=d&&n.get()===a;d=!1,f||n.set(a),await i.setOptions(a),await o.setOptions(a)}}}var Ih=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]}},Th="editor-runtime.react.copies",Xt=8;function Ke(e){return e&&typeof e=="object"?e:void 0}function ti(e){const t=Ke(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Ke(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function Ah(e){const t=Ke(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Ke(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function Ch(e,t,n){return e.package===t&&e.version===n}function Rh({ourReact:e,entries:t,packageName:n,version:r}){const i=ti(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const d of t){const a=Ke(d);if(!a||!Ch(a,n,r))continue;const f=ti(a.react);!f||f===i||s.has(f)||(s.add(f),o.push({package:n,version:r,reactVersion:Ah(a.react),react:a.react}))}return o}function Ph({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,Xt))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Xt&&n.push(` …and ${t.length-Xt} 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(`
1047
+ `)}var ni=new Set;function Dh({packageName:e="useblocks",version:t="1.1.85-dev.8",log:n=r=>{}}={}){const r=i=>{try{const o=globalThis[Symbol.for(Th)],s=Rh({ourReact:i,entries:o,packageName:e,version:t}).filter(d=>!ni.has(d.react));if(!s.length)return;s.forEach(d=>ni.add(d.react)),n(Ph({packageName:e,copies:s}))}catch{}};try{const i=xn()?.modules?.React;if(i&&typeof i.then=="function"){i.then(r,()=>{});return}r(i)}catch{}}async function Oh(e,t,n){$(e.signal);const r=t??mt.createChild();Wn(r);const i=r.getInstance(j);async function o(){r.inject(ss,new Ih),Dh();const s=Sh(r),d={...s.instance,container:r,async reset(a){if($(a.signal),i.isDisposed())throw Ln();return await s.setOptions(a),d}};r.inject(_t,d);try{if(n?.onInstance?.(d),await s.setOptions(e),$(e.signal),i.isDisposed()||await r.getInstance(tn)?.activate(),e.devTools)try{const a=r.getInstance(tn);a&&await(await Qe()).initDevTools(r,a)}catch{}return $(e.signal),Pn(r,mi).fire(d),d}catch(a){throw i.dispose(),a}}try{return await pt(o(),e.signal)}catch(s){throw i.isDisposed()||i.dispose(),s}}var We=new WeakMap;function xh(e){return e?We.get(e):void 0}function Wo(e){try{e.getInstance(j)?.dispose()}catch{}try{e.dispose()}catch{}}function Lh(e,t){if(!e)return;const n=We.get(e);n&&n!==t&&Wo(n),We.set(e,t)}function Mh(e,t){e&&We.get(e)===t&&We.delete(e)}function kh(e){const t=mt.createChild();return At(e)&&t.inject(he,Tt(e)),t}var qe=new WeakMap,Nh="data-useblocks-config-styles";function Fh(e){return typeof e=="string"?e.trim():""}function ri(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function jh(e,t,n){if(!e||typeof document>"u")return null;const r=Fh(t),i=qe.get(e),o=n||e;if(!r)return i&&(i.remove(),qe.delete(e)),null;if(i)return i.textContent!==r&&(i.textContent=r),(i.parentNode!==o||i!==o.firstChild)&&ri(o,i),i;const s=document.createElement("style");return s.setAttribute(Nh,"true"),s.textContent=r,ri(o,s),qe.set(e,s),s}function Bh(e){if(!e)return;const t=qe.get(e);t&&(t.remove(),qe.delete(e))}function Yo(){return!1}var Uh=`
1048
1048
  .blocks-app-initial-spinner-wrapper {
1049
1049
  width: 100%;
1050
1050
  height: 100%;
@@ -1073,7 +1073,7 @@ import{t as si}from"./static/esm/50fbfdf6.js";import{$ as Jo,A as Qo,At as le,B
1073
1073
  100% {
1074
1074
  transform: rotate(360deg);
1075
1075
  }
1076
- }`;function xh(){return()=>{}}function Lh(e,t){if(!Go()||!e||typeof document>"u")return xh();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 i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=Oh,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function Mh(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function kh({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const d=o().catch(l=>{throw n.has(i)||(n.add(i),r(l)),Mh(l)||t.delete(i),l});return t.set(i,d),d},clear(){t.clear(),n.clear()},size(){return t.size}}}var Vn=kh();function qo(){Vn.clear()}es(()=>Vn.clear());var Qr=new WeakMap,Zr=new WeakMap;function Nh(e,t){let n=Zr.get(t);n||(n=new Map,Zr.set(t,n));const r=n.get(e);if(r!==void 0)return r;const i=t.getInstance(ai),o=Bs({baseUrl:e,customFetch:i?.execute??fetch},t);return n.set(e,o),o}function Kn(e){return ps(e)}function Fh(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function jh(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function Bh(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}function Uh(e,t){return async({baseUrl:n})=>{const r=Kn(n);if(!r)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json"});if(e.getAuthToken&&!await Bh(e))throw jh();const o=t();if(!o)throw new Error("[Loader] appInit requires the instance container");const s=new mi(Nh(r,o)),d={headers:Object.fromEntries(i.entries()),credentials:"same-origin",failoverAttemptTimeout:$n(e)||void 0},l=await s.app_init_create({},d);if(!l.ok)throw Fh(l.status,l.statusText);return l.data}}function Hh(e){return JSON.stringify({baseUrl:Kn(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Gh(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function qh(e){return t=>Vn.run(Hh(t),()=>(z("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>z("appInit:end",{kind:"network"}))))}function $h(e,t){if(At(e)||!e.appInit&&!Kn(e.baseUrl)||!Gh(e))return e;const n=e.appInit??Uh(e,t);let r=Qr.get(n);return r||(r=qh(n),Qr.set(n,r)),{...e,appInit:r}}var $o=0;function zh(){return $o}function Vh(){$o+=1,qo()}var ei=new WeakMap,ti=new WeakMap,Kh=3e4;function Wh(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function Yh(e,t){try{const n=ui(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+Kh}function Xh(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=Wh(r,i);if(o)return n.delete(s),t.delete(s),qo(),e(r,i,o);const d=n.get(s);if(d&&!t.has(s)){if(d.expiresAtMs>Date.now())return d.token;n.delete(s)}let l=t.get(s);return l===void 0&&(z("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,i,o)).then(f=>{const u=String(f||"").trim();return u&&n.set(s,{token:f,expiresAtMs:Yh(u,Date.now())}),f}).finally(()=>{z("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function Jh(e){if(At(e))return e;const t=e.getAuthToken;if(!t)return e;let n=ei.get(t);const r=zh();return(!n||ti.get(t)!==r)&&(n=Xh(t),ei.set(t,n),ti.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var Le=new WeakMap;function Jt(e){const t=(Le.get(e)??0)+1;return Le.set(e,t),t}function Qh(e,t,n){Le.get(e)===t&&Le.set(e,n)}function ni(e,t){return Le.get(e)===t}function Zh(e){return Le.get(e)??0}var em=new Set(["setConfig","updateConfig","show","save","getEmailSnapshot","getEmail","compileEmail","getBlocks","getEmailRevisions","getComments","validateCode","reset","useAsync"]),tm=new Set(["setEmailMeta","setBlockMeta","notify"]),zo=new Map([["getConfig","await `ready` first"],["use","use `useAsync()` or await `ready` first"],["container","await `ready` first"],["undoRedoService","await `ready` first"]]);function ri(e){if(/^handle[A-Z]/.test(e))return"event";if(em.has(e))return"async";if(tm.has(e))return"queued";if(e==="getElement")return"element";if(e==="getCodeErrors")return"codeErrors";if(zo.has(e))return"notReady"}function nm(e){return zo.get(e)??"await `ready` first"}function ii(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}function rm(e,t){let n,r=0,i,o="pending",s,d,l;const f=new Set,u=[];let v,b;const y=new Promise((R,O)=>{v=R,b=O});y.catch(()=>{});const I=R=>n?.[R],g=R=>{const O=I(R.name);R.dispose||typeof O!="function"||(R.dispose=O(...R.args))},E=()=>f.forEach(g),w=()=>{for(const R of f)R.dispose?.(),R.dispose=void 0},S=()=>E(),A=()=>{l?.delete(S),l=void 0},h=()=>{w(),f.clear(),A(),u.length=0,n=void 0},c=()=>o==="failed"?s:Rn(),a=(R,O,C)=>{if(o==="failed"||o==="destroyed")throw c();const x=I(R);if(typeof x!="function")throw ii(R);return x.apply(C,O)},p=()=>o==="ready"?Promise.resolve():o==="pending"?y:Promise.reject(c()),m=(R,O)=>{if(o==="failed"||o==="destroyed")throw c();if(o==="ready"&&typeof I(R)!="function")throw ii(R);const C={name:R,args:O};return f.add(C),g(C),()=>{f.delete(C),C.dispose?.(),C.dispose=void 0}},_=()=>{const R=e.element;return R!==void 0&&typeof R!="string"?R:void 0},T=new Proxy({},{get(R,O,C){if(typeof O!="string"||O==="then")return;const x=ri(O);if(x==="event")return(...B)=>m(O,B);if(n&&O in n)return Reflect.get(n,O,C);switch(x){case"async":return(...B)=>p().then(()=>a(O,B,C));case"queued":return(...B)=>{if(o!=="pending")return a(O,B,C);u.push({name:O,args:B})};case"element":return _;case"codeErrors":return()=>[];case"notReady":throw new Error(`[emailmaker] \`${O}\` is not available before the editor is ready: ${nm(O)}`);default:return O in Object.prototype?Reflect.get(Object.prototype,O,C):void 0}},has(R,O){return typeof O!="string"?!1:n!==void 0&&O in n||ri(O)!==void 0}}),D=Object.create(T);return Object.defineProperty(D,"ready",{get:()=>d,enumerable:!0}),Object.defineProperty(D,"destroy",{enumerable:!0,value:()=>{if(o==="destroyed"||o==="failed")return;if(o==="pending"){const C=i!==void 0&&n!==void 0&&ni(n,r),x=n;o="destroyed",d?.catch(()=>{}),t(Q("[emailmaker] editor was destroyed before it was ready")),C&&(h(),x?.destroy());return}const R=n!==void 0&&ni(n,r),O=n;o="destroyed",h(),R&&O?.destroy()}}),{handle:D,bind:(R,O)=>{O?.adopt&&o==="pending"&&i===void 0?(i=Zh(R),r=Jt(R)):!O?.adopt&&n!==R&&(i=void 0),n!==R&&(w(),A(),n=R,E(),o==="pending"&&(l=R.container.getOrCreateInstance(fi,()=>new Set),l.add(S)))},settle:()=>{const R=n;if(o==="destroyed"){h(),R&&(Jt(R),R.destroy());const O=Q("[emailmaker] editor was destroyed before it was ready");throw s=O,b(O),O}R&&i===void 0&&(r=Jt(R)),o="ready",A();for(const O of u.splice(0))try{a(O.name,O.args,D)}catch(C){queueMicrotask(()=>{throw C})}v()},fail:R=>{o!=="destroyed"&&(o="failed",s=R,n&&i!==void 0&&Qh(n,r,i)),h(),b(R)},setReady:R=>{d=R}}}var Vo="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function im(){return Q(Vo)}function om(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Vo}function sm(e,t,n){if(typeof document>"u")return;let r=!1,i;const o=()=>{r=!0,i?.disconnect(),i=void 0},s=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(s);return}i=new MutationObserver(()=>{e.isConnected||s()});let d=e.parentNode;for(;d;)i.observe(d,{childList:!0}),d=d.parentNode}function am(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:i}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return sm(n,()=>{n.id,o.abort(im())},i),An(r,o.signal)}var Ko="Superseded by newer init() on the same mount element";function lm(){return Q(Ko)}function dm(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ko}var dt=new Map,ct=new WeakMap;function cm(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function um(e){if(!e)return{previous:Promise.resolve(),release:()=>{}};const t=cm(e),n=t?dt.get(t):void 0;n&&n.element!==e&&n.controller.abort(lm());const r=ct.get(e)??Promise.resolve();let i;const o=new Promise(l=>{i=l});ct.set(e,o);const s=new AbortController,d={element:e,controller:s};return t&&dt.set(t,d),{signal:s.signal,previous:r,release:()=>{i(),ct.get(e)===o&&ct.delete(e),t&&dt.get(t)===d&&dt.delete(t)}}}var Dm=si({FileManagerApiError:()=>fm}),fm=class Wo extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,i){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,Wo)}},Om=si({mapHttpStatusToErrorCode:()=>rs});function pm(e,t){return{...e,element:t}}function _n(){return()=>{}}function hm(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?_n():(Ph(t,e.config?.styles,t),()=>{Dh(t)})}function mm(e){if(!Go()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:_n()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:_n()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=Lh(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function gm(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function vm(e){return e instanceof DOMException&&e.name==="AbortError"}function oi(e){try{e.destroy()}catch{}}function Qt(e,...t){const n=ce.get(e);t.some(r=>r!==void 0&&r===n)&&ce.delete(e)}var xm="1.1.85-dev.7";async function Lm(e){await Pp(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function Mm(e){return bm(e).ready}function bm(e){z(J.initStart);const t=new AbortController,n=An(e.signal,t.signal),r=rm(e,o=>t.abort(o)),i=ym({...e,signal:n},r.bind).then(()=>(z(J.initEnd),r.settle(),r.handle),o=>{throw r.fail(o),o});return r.setReady(i),r.handle}async function ym(e,t){$(e.signal);const n=new Z;let r,i;try{const o=await xs(e.element,n,e.signal),s=am({hostElementOption:e.element,resolvedElement:o,externalSignal:e.signal,disposable:n}),d=um(o);r=d.release;const l=An(s,d.signal);return $(l),await ht(d.previous,l),i=Em(e,o,t,l),await ht(i,l)}finally{const o=r;i!==void 0&&o?i.then(o,o):o?.(),n.dispose()}}async function Em(e,t,n,r){$(r),Vh();const i=pm(e,t),o=Jh(i);let s;const d=$h(o,()=>s),l=r!=null?{...d,signal:r}:d;if(t){const y=ce.get(t);if(y){let I;try{I=await y,$(r)}catch{$(r),Qt(t,y),I=void 0}if(I)if(I.getElement()===t)try{return s=Sh(t),n(I,{adopt:!0}),await I.reset(gm(e,l))}catch(g){if($(r),dm(g)||om(g)||vm(g)&&r?.aborted)throw g;Qt(t,y,I),oi(I)}else Qt(t,y,I),oi(I)}}$(r);const f=hm(d),u=mm(d),v=r!=null?{...u.options,signal:r}:u.options;let b;try{s=Ah(v),Ih(t,s),qn(s).set(v),await zn(),z(J.coreReady),$(r),$(r),b=wh(v,s,{onInstance:n}),t&&ce.set(t,b);const y=await b;if(r?.aborted&&(y.destroy(),$(r)),t)if(ce.get(t)===b)ce.set(t,y);else throw y.destroy(),$(r),Q(r?.reason);return y}catch(y){throw f(),u.cleanup(),s&&(Ho(s),Th(t,s)),t&&b&&ce.get(t)===b&&ce.delete(t),y}}async function km(e){return(await Qe()).parseAMP(e)}typeof window<"u"&&($e()&&oa(),Op(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{Vo as ELEMENT_DETACHED_ABORT_MESSAGE,Ko as SUPERSEDED_INIT_ABORT_MESSAGE,bm as create,Dm as errors,Om as helpers,Mm as init,om as isElementDetachedError,dm as isSupersededInitError,km as parseAMP,Lp as pluginRegistry,Lm as preload,xm as version};
1076
+ }`;function Hh(){return()=>{}}function Gh(e,t){if(!Yo()||!e||typeof document>"u")return Hh();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 i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=Uh,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function qh(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function $h({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const d=o().catch(a=>{throw n.has(i)||(n.add(i),r(a)),qh(a)||t.delete(i),a});return t.set(i,d),d},clear(){t.clear(),n.clear()},size(){return t.size}}}var Jn=$h();function Xo(){Jn.clear()}ls(()=>Jn.clear());var ii=new WeakMap,oi=new WeakMap;function zh(e,t){let n=oi.get(t);n||(n=new Map,oi.set(t,n));const r=n.get(e);if(r!==void 0)return r;const i=t.getInstance(pi),o=Ks({baseUrl:e,customFetch:i?.execute??fetch},t);return n.set(e,o),o}function Qn(e){return ws(e)}function Vh(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function Kh(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function Wh(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 Zn=new WeakMap;function Jt(e,t){Zn.set(e,t)}function Yh(e){return Zn.get(e)}function Xh(e,t){return async({baseUrl:n})=>{const r=t();if(!r)throw new Error("[Loader] appInit requires the instance container");const i=Zn.get(r)??e,o=Qn(n);if(!o)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json"});if(i.getAuthToken&&!await Wh(i))throw Kh();const d=new _i(zh(o,r)),a={headers:Object.fromEntries(s.entries()),credentials:"same-origin",failoverAttemptTimeout:Yn(i)||void 0},f=await d.app_init_create({},a);if(!f.ok)throw Vh(f.status,f.statusText);return f.data}}function Jh(e){return JSON.stringify({baseUrl:Qn(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Qh(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function Zh(e){return t=>Jn.run(Jh(t),()=>(z("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>z("appInit:end",{kind:"network"}))))}function em(e,t){if(At(e)||!e.appInit&&!Qn(e.baseUrl)||!Qh(e))return e;const n=e.appInit??Xh(e,t);let r=ii.get(n);return r||(r=Zh(n),ii.set(n,r)),{...e,appInit:r}}var Jo=0;function tm(){return Jo}function nm(){Jo+=1,Xo()}var si=new WeakMap,ai=new WeakMap,rm=3e4;function im(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function om(e,t){try{const n=vi(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+rm}function sm(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=im(r,i);if(o)return n.delete(s),t.delete(s),Xo(),e(r,i,o);const d=n.get(s);if(d&&!t.has(s)){if(d.expiresAtMs>Date.now())return d.token;n.delete(s)}let a=t.get(s);return a===void 0&&(z("authToken:start",{kind:"network"}),a=Promise.resolve(e(r,i,o)).then(f=>{const u=String(f||"").trim();return u&&n.set(s,{token:f,expiresAtMs:om(u,Date.now())}),f}).finally(()=>{z("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,a)),a}}function am(e){if(At(e))return e;const t=e.getAuthToken;if(!t)return e;let n=si.get(t);const r=tm();return(!n||ai.get(t)!==r)&&(n=sm(t),si.set(t,n),ai.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var Ze=new WeakMap,Sn=new WeakMap;function Qo(e,t){Ze.set(e,t),Sn.get(e)?.forEach(n=>n())}function lm(e,t){const n=Sn.get(e)??new Set;return n.add(t),Sn.set(e,n),()=>n.delete(t)}function Qt(e){const t=(Ze.get(e)??0)+1;return Qo(e,t),t}var In=new WeakMap;function dm(e,t){const n=In.get(e)??new Set;n.add(t),In.set(e,n)}function cm(e,t,n){return Ze.get(e)!==t?!0:In.get(e)?.has(n)?!1:(Qo(e,n),!0)}function Zt(e,t){return Ze.get(e)===t}function li(e){return Ze.get(e)??0}var um=new Set(["setConfig","updateConfig","show","save","getEmailSnapshot","getEmail","compileEmail","getBlocks","getEmailRevisions","getComments","validateCode","reset","useAsync"]),fm=new Set(["setEmailMeta","setBlockMeta","notify"]),Zo=new Map([["getConfig","await `ready` first"],["use","use `useAsync()` or await `ready` first"],["container","await `ready` first"],["undoRedoService","await `ready` first"]]);function di(e){if(/^handle[A-Z]/.test(e))return"event";if(um.has(e))return"async";if(fm.has(e))return"queued";if(e==="getElement")return"element";if(e==="getCodeErrors")return"codeErrors";if(Zo.has(e))return"notReady"}function pm(e){return Zo.get(e)??"await `ready` first"}function ci(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}function hm(e,t){let n,r=0,i,o="pending",s,d,a,f;const u=new Set,v=[];let b,E;const I=new Promise((C,D)=>{b=C,E=D});I.catch(()=>{});const g=C=>n?.[C],y=()=>o==="pending"||n!==void 0&&Zt(n,r),_=C=>{const D=g(C.name);C.dispose||typeof D!="function"||!y()||(C.dispose=D(...C.args))},S=()=>u.forEach(_),A=()=>{for(const C of u)C.dispose?.(),C.dispose=void 0},h=()=>S(),c=()=>{o==="ready"&&(y()?S():A())},l=()=>{a?.delete(h),a=void 0},p=()=>{f?.(),f=void 0,A(),u.clear(),l(),v.length=0,n=void 0},m=()=>o==="failed"?s:Ln(),w=(C,D,x)=>{if(o==="failed"||o==="destroyed")throw m();const U=g(C);if(typeof U!="function")throw ci(C);return U.apply(x,D)},T=()=>o==="ready"?Promise.resolve():o==="pending"?I:Promise.reject(m()),O=(C,D)=>{if(o==="failed"||o==="destroyed")throw m();if(o==="ready"&&typeof g(C)!="function")throw ci(C);const x={name:C,args:D};return u.add(x),_(x),()=>{u.delete(x),x.dispose?.(),x.dispose=void 0}},k=()=>{const C=e.element;return C!==void 0&&typeof C!="string"?C:void 0},W=new Proxy({},{get(C,D,x){if(typeof D!="string"||D==="then")return;const U=di(D);if(U==="event")return(...J)=>O(D,J);if(n&&D in n)return Reflect.get(n,D,x);switch(U){case"async":return(...J)=>T().then(()=>w(D,J,x));case"queued":return(...J)=>{if(o!=="pending")return w(D,J,x);v.push({name:D,args:J})};case"element":return k;case"codeErrors":return()=>[];case"notReady":throw new Error(`[emailmaker] \`${D}\` is not available before the editor is ready: ${pm(D)}`);default:return D in Object.prototype?Reflect.get(Object.prototype,D,x):void 0}},has(C,D){return typeof D!="string"?!1:n!==void 0&&D in n||di(D)!==void 0}}),R=Object.create(W);return Object.defineProperty(R,"ready",{get:()=>d,enumerable:!0}),Object.defineProperty(R,"destroy",{enumerable:!0,value:()=>{if(o==="destroyed"||o==="failed")return;if(o==="pending"){const x=i!==void 0&&n!==void 0&&Zt(n,r),U=n;o="destroyed",d?.catch(()=>{}),t(Z("[emailmaker] editor was destroyed before it was ready")),x&&(p(),U?.destroy());return}const C=n!==void 0&&Zt(n,r),D=n;o="destroyed",p(),C?D?.destroy():D&&dm(D,r)}}),{handle:R,bind:(C,D)=>{D?.adopt&&o==="pending"&&i===void 0?(i=li(C),r=Qt(C)):!D?.adopt&&n!==C&&(i=void 0),n!==C&&(A(),l(),n=C,S(),o==="pending"&&(a=C.container.getOrCreateInstance(bi,()=>new Set),a.add(h)))},settle:()=>{const C=n;if(o==="destroyed"){p(),C&&(Qt(C),C.destroy());const D=Z("[emailmaker] editor was destroyed before it was ready");throw s=D,E(D),D}C&&i===void 0&&li(C)===0&&(r=Qt(C)),o="ready",C&&(f=lm(C,c),c()),l();for(const D of v.splice(0))try{w(D.name,D.args,R)}catch(x){queueMicrotask(()=>{throw x})}b()},fail:C=>{o!=="destroyed"&&(o="failed",s=C,n&&i!==void 0&&!cm(n,r,i)&&n.destroy()),p(),E(C)},setReady:C=>{d=C}}}var es="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function mm(){return Z(es)}function gm(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===es}function vm(e,t,n){if(typeof document>"u")return;let r=!1,i;const o=()=>{r=!0,i?.disconnect(),i=void 0},s=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(s);return}i=new MutationObserver(()=>{e.isConnected||s()});let d=e.parentNode;for(;d;)i.observe(d,{childList:!0}),d=d.parentNode}function bm(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:i}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return vm(n,()=>{n.id,o.abort(mm())},i),On(r,o.signal)}var ts="Superseded by newer init() on the same mount element";function Em(){return Z(ts)}function ym(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===ts}var Fe=new Map,ct=new WeakMap;function _m(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function wm(e){if(!e)return{previous:Promise.resolve(),release:()=>{}};const t=_m(e);(t?Fe.get(t):void 0)?.forEach(a=>{a.element!==e&&a.controller.abort(Em())});const n=ct.get(e)??Promise.resolve();let r;const i=new Promise(a=>{r=a}),o=n.then(()=>i);ct.set(e,o),o.then(()=>{ct.get(e)===o&&ct.delete(e)});const s=new AbortController,d={element:e,controller:s};if(t){const a=Fe.get(t)??new Set;a.add(d),Fe.set(t,a)}return{signal:s.signal,previous:n,release:()=>{r();const a=t?Fe.get(t):void 0;t&&a?.delete(d)&&a.size===0&&Fe.delete(t)}}}var Um=fi({FileManagerApiError:()=>Sm}),Sm=class ns extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,i){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,ns)}},Hm=fi({mapHttpStatusToErrorCode:()=>Es});function Im(e,t){return{...e,element:t}}function Tn(){return()=>{}}function Tm(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Tn():(jh(t,e.config?.styles,t),()=>{Bh(t)})}function Am(e){if(!Yo()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Tn()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Tn()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=Gh(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function Cm(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function ui(e){try{e.destroy()}catch{}}function en(e,...t){const n=le.get(e);t.some(r=>r!==void 0&&r===n)&&le.delete(e)}var Gm="1.1.85-dev.8";async function qm(e){await jp(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function $m(e){return Rm(e).ready}function Rm(e){z(Q.initStart);const t=new AbortController,n=On(e.signal,t.signal),r=hm(e,o=>t.abort(o)),i=Pm({...e,signal:n},r.bind).then(()=>(z(Q.initEnd),r.settle(),r.handle),o=>{throw r.fail(o),o});return r.setReady(i),r.handle}async function Pm(e,t){$(e.signal);const n=new ee;let r,i;try{const o=await Us(e.element,n,e.signal),s=bm({hostElementOption:e.element,resolvedElement:o,externalSignal:e.signal,disposable:n}),d=wm(o);r=d.release;const a=On(s,d.signal);return $(a),await pt(d.previous,a),i=Dm(e,o,t,a),await pt(i,a)}finally{const o=r;i!==void 0&&o?i.then(o,o):o?.(),n.dispose()}}async function Dm(e,t,n,r){$(r),nm();const i=Im(e,t),o=am(i);let s;const d=em(o,()=>s),a=r!=null?{...d,signal:r}:d;if(t){const E=le.get(t);if(E){let I;try{I=await E,$(r)}catch{$(r),en(t,E),I=void 0}if(I)if(I.getElement()===t){const g=xh(t);s=g;const y=g&&Yh(g);try{g&&Jt(g,d),n(I,{adopt:!0});const _=await I.reset(Cm(e,a));return le.set(t,I),_}catch(_){if(g&&y&&Jt(g,y),$(r),ym(_)||gm(_)||An(_)&&r?.aborted)throw _;en(t,E,I),ui(I)}}else en(t,E,I),ui(I)}}$(r);const f=Tm(d),u=Am(d),v=r!=null?{...u.options,signal:r}:u.options;let b;try{s=kh(v),Lh(t,s),Jt(s,d),Wn(s).set(v),await Xn(),z(Q.coreReady),$(r),$(r),b=Oh(v,s,{onInstance:n}),t&&le.set(t,b);const E=await b;if(r?.aborted&&(E.destroy(),$(r)),t)if(le.get(t)===b)le.set(t,E);else throw E.destroy(),$(r),Z(r?.reason);return E}catch(E){throw f(),u.cleanup(),s&&(Wo(s),Mh(t,s)),t&&b&&le.get(t)===b&&le.delete(t),E}}async function zm(e){return(await Qe()).parseAMP(e)}typeof window<"u"&&($e()&&pa(),Up(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{es as ELEMENT_DETACHED_ABORT_MESSAGE,ts as SUPERSEDED_INIT_ABORT_MESSAGE,Rm as create,Um as errors,Hm as helpers,$m as init,gm as isElementDetachedError,ym as isSupersededInitError,zm as parseAMP,Gp as pluginRegistry,qm as preload,Gm as version};
1077
1077
 
1078
1078
 
1079
- window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/175b5b0f.js":[],"static/core/1bdeb37f.js":[],"static/core/23f020c5.js":[],"static/core/284b592e.js":[],"static/core/3fd50a29.js":[],"static/core/48da14fd.js":[],"static/core/4c8d0155.js":[],"static/core/51a46897.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/53bcd609.js":["__delivery__/libs"],"static/core/5db1f013.js":["static/core/175b5b0f.js","__delivery__/libs"],"static/core/60aa31a3.js":[],"static/core/60f7aa8d.js":[],"static/core/6561b34a.js":[],"static/core/6a939bac.js":[],"static/core/6ff64eea.js":[],"static/core/740a4f32.js":[],"static/core/74c1d64b.js":["static/core/e2699a48.js"],"static/core/77d63e01.js":["static/core/53bcd609.js","__delivery__/libs"],"static/core/78b1e678.js":["static/core/d2bb1c0d.js","static/core/5db1f013.js","static/core/b49f995f.js","static/core/77d63e01.js","__delivery__/libs"],"static/core/7b850506.js":[],"static/core/7d627bff.js":[],"static/core/7f91ed03.js":["static/core/e2699a48.js","static/core/6a939bac.js","static/core/c28968c1.js"],"static/core/8035d07f.js":[],"static/core/991b35ff.js":[],"static/core/9ea82ab5.js":["static/core/6a939bac.js"],"static/core/a5996860.js":["static/core/175b5b0f.js"],"static/core/ac50dfd1.js":[],"static/core/b49f995f.js":["static/core/5db1f013.js","__delivery__/libs"],"static/core/c28968c1.js":["static/core/6a939bac.js"],"static/core/d2bb1c0d.js":[],"static/core/e2699a48.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/ea93d0cd.js":["static/core/b49f995f.js","static/core/53bcd609.js","__delivery__/libs","static/core/5db1f013.js"],"static/core/ec4827f1.js":[],"static/core/ec93b234.js":["static/core/175b5b0f.js","static/core/5db1f013.js","__delivery__/libs"],"static/core/fb2fe2db.js":[],"static/core/fc390885.js":[],"static/core/fdfb1e94.js":["static/core/d2bb1c0d.js","static/core/5db1f013.js","__delivery__/libs"],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"compat-globals.js":["static/esm/50fbfdf6.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/50fbfdf6.js","static/esm/ff1698e6.js"],"static/esm/50fbfdf6.js":[],"static/esm/ff1698e6.js":[]},"bundles":{"static/core/53bcd609.js":["static/core/9281699f.js","static/core/41a7e33c.js","static/core/52b6b918.js","static/core/a669ca97.js"],"static/core/74c1d64b.js":["static/core/a71c4cd8.js"],"static/core/ec93b234.js":["static/core/4d436d7d.js"],"static/core/77d63e01.js":["static/core/a73da823.js"],"static/core/ea93d0cd.js":["static/core/488a89dc.js"],"core":["static/core/2ff39ddf.js","static/core/8782e9bb.js","static/core/10c6144f.js","static/core/cb7d16ff.js","static/core/68612347.js"]}});
1079
+ window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/06d19668.js":["static/core/5db1f013.js","__delivery__/libs"],"static/core/13c7b13a.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/175b5b0f.js":[],"static/core/1afe0f9c.js":["static/core/ff43365e.js","static/core/5db1f013.js","__delivery__/libs"],"static/core/28160edc.js":[],"static/core/3d7934fb.js":[],"static/core/3df10afa.js":["__delivery__/libs"],"static/core/3fd50a29.js":[],"static/core/41028939.js":[],"static/core/45eb9af1.js":["static/core/41028939.js","static/core/3d7934fb.js","static/core/799f4d8e.js"],"static/core/48a8ba9d.js":[],"static/core/48da14fd.js":[],"static/core/49a8dc9c.js":[],"static/core/4c8d0155.js":[],"static/core/59cfe4a0.js":[],"static/core/5db1f013.js":["static/core/175b5b0f.js","__delivery__/libs"],"static/core/60aa31a3.js":[],"static/core/6561b34a.js":[],"static/core/778aee63.js":[],"static/core/799f4d8e.js":["static/core/3d7934fb.js"],"static/core/7b850506.js":[],"static/core/7c047ede.js":["static/core/3df10afa.js","__delivery__/libs"],"static/core/982730aa.js":["static/core/3d7934fb.js"],"static/core/a46eae76.js":[],"static/core/a5996860.js":["static/core/175b5b0f.js"],"static/core/ac50dfd1.js":[],"static/core/b165db74.js":[],"static/core/cb42ad65.js":[],"static/core/db82c42b.js":[],"static/core/df189a9d.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/ec93b234.js":["static/core/175b5b0f.js","static/core/5db1f013.js","__delivery__/libs"],"static/core/f1478faf.js":["static/core/41028939.js"],"static/core/f1498d3c.js":[],"static/core/f8d889a1.js":["static/core/06d19668.js","static/core/3df10afa.js","__delivery__/libs","static/core/5db1f013.js"],"static/core/fa60c7fb.js":["static/core/ff43365e.js","static/core/5db1f013.js","static/core/06d19668.js","static/core/7c047ede.js","__delivery__/libs"],"static/core/fb2fe2db.js":[],"static/core/ff43365e.js":[],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"compat-globals.js":["static/esm/50fbfdf6.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/50fbfdf6.js","static/esm/349f9e2c.js"],"static/esm/349f9e2c.js":[],"static/esm/50fbfdf6.js":[]},"bundles":{"static/core/3df10afa.js":["static/core/5cf8c192.js","static/core/4cda85e3.js","static/core/b6d27bcf.js","static/core/e02ef34c.js"],"static/core/f1478faf.js":["static/core/a71c4cd8.js"],"static/core/ec93b234.js":["static/core/4d436d7d.js"],"static/core/7c047ede.js":["static/core/a73da823.js"],"static/core/f8d889a1.js":["static/core/94d4ae45.js"],"core":["static/core/2ff39ddf.js","static/core/ca13058e.js","static/core/b2b19022.js","static/core/f72a1b7d.js","static/core/4d23db03.js"]}});