useblocks 1.3.11-dev.3 → 1.3.16

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 (110) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/README.md +1 -1
  3. package/compat-globals.js +1 -1
  4. package/iframe/.vite/manifest.json +4 -4
  5. package/iframe/css/sandbox-dark.css +1 -1
  6. package/iframe/css/sandbox-light.css +1 -1
  7. package/iframe/css/sandbox.css +47 -17
  8. package/iframe/{iframe-eblock.5751e42b.html → iframe-eblock.7594857d.html} +2 -2
  9. package/iframe/{iframe.5751e42b.html → iframe.7594857d.html} +2 -2
  10. package/iframe/js/elMarkupHelper.CsLyPjC1.js +278 -0
  11. package/iframe/js/{iframe-eblock.body.5751e42b.js → iframe-eblock.body.7594857d.js} +1 -1
  12. package/iframe/js/iframe-eblock.js +2 -2
  13. package/iframe/js/iframe.body.7594857d.js +129 -0
  14. package/iframe/js/iframe.js +2 -2
  15. package/package.json +1 -1
  16. package/runtime/react/index.js +1 -1
  17. package/static/core/{5da33486.js → 16612c9f.js} +1 -1
  18. package/static/core/{516f59e7.js → 1e160f23.js} +1 -1
  19. package/static/core/{b5da36e5.js → 23e22cd2.js} +1 -1
  20. package/static/core/25562e5d.js +1 -0
  21. package/static/core/2633e871.js +1 -0
  22. package/static/core/{ef035f6b.js → 2740933f.js} +3 -3
  23. package/static/core/{f1b8515a.js → 2a8b14c0.js} +1 -1
  24. package/static/core/{66113a18.js → 2ae78ac6.js} +1 -1
  25. package/static/core/{3b65bc50.js → 31e587ab.js} +1 -1
  26. package/static/core/3454ca99.js +1 -0
  27. package/static/core/36071466.js +2 -0
  28. package/static/core/{e037a420.js → 3cd95e0a.js} +1 -1
  29. package/static/core/{94f9492b.js → 3e1acefc.js} +1 -1
  30. package/static/core/3e80379e.js +4 -0
  31. package/static/core/{b55ae539.js → 3f3feb86.js} +1 -1
  32. package/static/core/{3d8e2478.js → 4adb5ee9.js} +7 -7
  33. package/static/core/4e07805d.js +19 -0
  34. package/static/core/{c13b3d4f.js → 4f8847e6.js} +1 -1
  35. package/static/core/519dfcc7.js +4 -0
  36. package/static/core/{a6303cb2.js → 53c22855.js} +1 -1
  37. package/static/core/{6172f09a.js → 552f7d30.js} +2 -2
  38. package/static/core/{e698ec22.js → 5de3cd2c.js} +1 -1
  39. package/static/core/{76543cb2.js → 66853555.js} +1 -1
  40. package/static/core/{b1edf5c5.js → 69688fad.js} +6 -6
  41. package/static/core/713de1e1.js +1 -0
  42. package/static/core/{d343e46e.js → 7ae6cf52.js} +7 -7
  43. package/static/core/{bda2d9d5.js → 80907514.js} +1 -1
  44. package/static/core/{513e36bd.js → 86f73ee9.js} +1 -1
  45. package/static/core/{aee84e3d.js → 8b9a4f49.js} +1 -1
  46. package/static/core/9348ac64.js +1 -0
  47. package/static/core/9da6c313.js +1 -0
  48. package/static/core/{62855b97.js → a004861a.js} +1 -1
  49. package/static/core/aeec5659.js +1 -0
  50. package/static/core/b492a9b0.js +93 -0
  51. package/static/core/{11009bdf.js → b6418818.js} +1 -1
  52. package/static/core/{467344d4.js → beebdf4d.js} +1 -1
  53. package/static/core/c03fc17e.js +7 -0
  54. package/static/core/c3344bbc.js +1 -0
  55. package/static/core/{8406bab5.js → c3544cf4.js} +1 -1
  56. package/static/core/{e7e888c1.js → cc4458d8.js} +1 -1
  57. package/static/core/{58dca22f.js → d551e71d.js} +1 -1
  58. package/static/core/{f8585ce6.js → d5be6857.js} +1 -1
  59. package/static/core/{347b0a0b.js → d6c7eb44.js} +1 -1
  60. package/static/core/d9ff5568.js +1 -0
  61. package/static/core/{257745eb.js → e2710fd3.js} +1 -1
  62. package/static/core/{71727873.js → e7c7173a.js} +3 -3
  63. package/static/core/{1c06cdb7.js → e81b521f.js} +3 -3
  64. package/static/core/{d2cf6b4b.js → e94e24b5.js} +1 -1
  65. package/static/core/{1c7a6d45.js → e98b0c61.js} +2 -2
  66. package/static/core/{7e329493.js → ec079650.js} +1 -1
  67. package/static/core/ecc4d431.js +1 -0
  68. package/static/core/f0f20c47.js +1 -0
  69. package/static/core/{d9d5b376.js → f5d42c73.js} +1 -1
  70. package/static/core/{ff7d14e8.js → f674f125.js} +1 -1
  71. package/static/core/{3eeb4445.js → f97efb0a.js} +1 -1
  72. package/static/core/{261a3a42.js → ff0af9ff.js} +1 -1
  73. package/static/esm/1d0ba521.js +1 -0
  74. package/static/esm/delivery-libs.js +1 -1
  75. package/static/umd-runtime/{Cvm7BS4_.js → CyULsN57.js} +31 -31
  76. package/static/umd-runtime/DdK5piwW.js +1 -0
  77. package/static/umd-runtime/delivery-libs.BJHA1QD4.js +1 -0
  78. package/static/umd-runtime/runtime.8gUPr0nE.js +1 -0
  79. package/static/umd-runtime/{ui-kit.CoVNet0I.js → ui-kit.BZ4Y4jr2.js} +2 -2
  80. package/useblocks-core.7594857d.js +875 -0
  81. package/useblocks-esm.js +12 -12
  82. package/{useblocks-po.5751e42b.js → useblocks-po.7594857d.js} +1 -1
  83. package/useblocks.d.ts +1 -1
  84. package/useblocks.js +13 -13
  85. package/vendor/useblocks-ui-kit/es/components/Custom/FormBackgroundSettings/index.js +3 -3
  86. package/vendor/useblocks-ui-kit/es/components/Custom/FormBorderRadiusInputs/index.js +6 -6
  87. package/vendor/useblocks-ui-kit/es/components/Custom/FormBoxShadowInputs/index.js +5 -5
  88. package/vendor/useblocks-ui-kit/es/components/Custom/FormPanel/FormPaddingInputs/index.js +69 -64
  89. package/vendor/useblocks-ui-kit/es/components/Custom/FormPanel/FormSizeInputs/index.js +5 -5
  90. package/vendor/useblocks-ui-kit/es/components/Custom/FormPanel/FormTypographyFields/index.js +5 -5
  91. package/vendor/useblocks-ui-kit/es/components/Custom/Inputs/DraggableInputNumber/index.js +41 -35
  92. package/vendor/useblocks-ui-kit/es/components/Layout/Splitter/index.js +5 -0
  93. package/vendor/useblocks-ui-kit/index.js +12 -11
  94. package/vendor/useblocks-ui-kit/package.json +1 -1
  95. package/iframe/js/elMarkupHelper.BpDXO-hq.js +0 -279
  96. package/iframe/js/iframe.body.5751e42b.js +0 -129
  97. package/static/core/11dadbc0.js +0 -1
  98. package/static/core/1c3a16fc.js +0 -1
  99. package/static/core/2bed6a18.js +0 -7
  100. package/static/core/8845436d.js +0 -4
  101. package/static/core/b59c63d2.js +0 -1
  102. package/static/core/b9f553d7.js +0 -93
  103. package/static/core/c0a3f7d0.js +0 -4
  104. package/static/core/dd008ec2.js +0 -2
  105. package/static/core/ed65b5c3.js +0 -19
  106. package/static/esm/c5372168.js +0 -1
  107. package/static/umd-runtime/B7h7P1Np.js +0 -1
  108. package/static/umd-runtime/delivery-libs.BymXnePv.js +0 -1
  109. package/static/umd-runtime/runtime.Lgfb59e0.js +0 -1
  110. package/useblocks-core.5751e42b.js +0 -875
package/useblocks-esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import{n as wc,r as Sc,t as zd}from"./static/esm/971f1b2c.js";import{$ as Kd,A as Yd,At as Ot,B as Xd,Bt as Qn,C as We,Ct as Jd,D as ri,Dt as H,E as Qd,Et as Ic,F as Zd,Ft as Mr,G as ef,Gt as ke,H as tf,Ht as nf,I as rf,It as of,J as Tc,Jt as sf,K as Ac,Kt as af,L as cf,Lt as lf,M as uf,Mt as df,N as ff,Nt as go,O as Ne,Ot as vn,P as oi,Pt as pf,Q as hf,R as Cc,Rt as Ie,S as ii,St as mf,T as Lr,Tt as gf,U as vf,Ut as xt,V as bf,Vt as se,W as pr,Wt as U,X as _f,Y as si,Yt as ve,Z as Rn,_ as hr,_t as bn,a as yf,at as ai,bt as ci,c as Rc,ct as _n,d as Ef,dt as Xe,et as yn,f as wf,ft as Oc,g as Sf,gt as Fe,h as K,ht as Y,i as If,it as Tt,j as Zi,jt as Je,k as Tf,kt as Pe,l as Af,m as Cf,mt as ge,n as Rf,nt as Of,o as kf,ot as es,p as Pf,pt as kc,q as Df,qt as xf,r as Mf,rt as Lf,s as Bt,st as Nf,t as xe,tt as Ff,u as Bf,ut as Pc,v as jf,vt as li,w as Uf,wt as ts,x as $f,xt as Ve,y as Hf,yt as we,z as Vf,zt as ui}from"./static/esm/c5372168.js";import{t as Gf}from"./static/esm/f76c9d9d.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 N=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(N&&N.src)return N.src.substring(0,N.src.lastIndexOf("/")+1)}catch{}try{var S=import.meta.url;if(S)return S.substring(0,S.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var f=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(f)||f.indexOf("//")===0)return f.charAt(f.length-1)==="/"?f:f+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",b=p?new URL(f,p).href:f;return b.charAt(b.length-1)==="/"?b:b+"/"}catch{var x=String(h);return x.charAt(x.length-1)==="/"?x:x+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var f=h==null?"":String(h);f||(f="./");try{var p=String(f);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(p)||p.indexOf("//")===0)return p.charAt(p.length-1)==="/"?p:p+"/";var b=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",x=b?new URL(p,b).href:p;return x.charAt(x.length-1)==="/"?x:x+"/"}catch{var N=String(f);return N.charAt(N.length-1)==="/"?N:N+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var f="";try{if(typeof window<"u"){for(var p in window)if(!(p==="__useblocks__"||!/^__[^_].*__$/.test(p))){var b;try{b=window[p]}catch{continue}if(b&&typeof b=="object"&&b.publicPath){f=" Another product namespace ("+p+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function f(w){try{var M=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return M?new URL(String(w||""),M).href:String(w||"")}catch{return String(w||"")}}var p=String(h||"");if(!p)return"";if(/^(?:data:|blob:)/.test(p))return p;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(p)||p.indexOf("//")===0||p.charAt(0)==="/")return f(p);var b=p.replace(/^\.\/+/,"").replace(/^\/+/,""),x="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),N=x&&b.indexOf(x+"/")!==0?x+"/"+b:b,S=e.publicPath||"./";try{return new URL(N,S).href}catch{return S.slice(-1)!=="/"&&(S+="/"),f(S+N)}}),e.version||(e.version="1.3.11-dev.3");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
1
+ import{n as ul,r as dl,t as op}from"./static/esm/971f1b2c.js";import{A as sp,B as ip,C as ap,D as ke,E as On,F as cp,G as lp,H as B,I as Te,K as up,L as Es,M as dp,N as Jr,O as Nt,P as fp,R as fr,S as Ai,T as H,U as xe,V as Ge,W as pp,_ as _e,a as hp,b as mp,c as fl,d as K,f as Ue,g as ws,h as xo,i as Ti,j as Lo,k as et,l as pl,m as rn,n as gp,o as Ss,p as Gt,q as de,r as vp,s as Ke,t as Ne,u as he,v as Is,w as hl,x as _p,y as je,z as ie}from"./static/esm/1d0ba521.js";import{t as bp}from"./static/esm/f76c9d9d.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var m=(function(){if(typeof document<"u"&&document.querySelector)try{var F=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(F&&F.src)return F.src.substring(0,F.src.lastIndexOf("/")+1)}catch{}try{var I=import.meta.url;if(I)return I.substring(0,I.lastIndexOf("/")+1)}catch{}return"./"})();m||(m="./");try{var p=String(m);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(p)||p.indexOf("//")===0)return p.charAt(p.length-1)==="/"?p:p+"/";var h=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",b=h?new URL(p,h).href:p;return b.charAt(b.length-1)==="/"?b:b+"/"}catch{var L=String(m);return L.charAt(L.length-1)==="/"?L:L+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(m){return e.publicPath=(function(){var p=m==null?"":String(m);p||(p="./");try{var h=String(p);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(h)||h.indexOf("//")===0)return h.charAt(h.length-1)==="/"?h:h+"/";var b=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",L=b?new URL(h,b).href:h;return L.charAt(L.length-1)==="/"?L:L+"/"}catch{var F=String(p);return F.charAt(F.length-1)==="/"?F:F+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var m=String(e.publicPath||"");if(m.indexOf("file:")!==0&&!(m&&m!=="./")){var p="";try{if(typeof window<"u"){for(var h in window)if(!(h==="__useblocks__"||!/^__[^_].*__$/.test(h))){var b;try{b=window[h]}catch{continue}if(b&&typeof b=="object"&&b.publicPath){p=" Another product namespace ("+h+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(m){function p(S){try{var N=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return N?new URL(String(S||""),N).href:String(S||"")}catch{return String(S||"")}}var h=String(m||"");if(!h)return"";if(/^(?:data:|blob:)/.test(h))return h;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(h)||h.indexOf("//")===0||h.charAt(0)==="/")return p(h);var b=h.replace(/^\.\/+/,"").replace(/^\/+/,""),L="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),F=L&&b.indexOf(L+"/")!==0?L+"/"+b:b,I=e.publicPath||"./";try{return new URL(F,I).href}catch{return I.slice(-1)!=="/"&&(I+="/"),p(I+F)}}),e.version||(e.version="1.3.16");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,22 +993,22 @@ import{n as wc,r as Sc,t as zd}from"./static/esm/971f1b2c.js";import{$ as Kd,A a
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.5751e42b.js",po:"useblocks-po.5751e42b.js",monaco:"static/monaco/index.CO7s5UdA.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var o=function(h){var f,p=function(){return f||(f=Promise.resolve().then(h))};return{then:function(b,x){return p().then(b,x)},catch:function(b){return p().catch(b)},finally:function(b){return p().finally(b)}}},i=o(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=o(function(){return i.then(function(h){return h.React})}),t.ReactDom=o(function(){return i.then(function(h){return h.ReactDom})}),t.ReactDomClient=o(function(){return i.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=o(function(){return i.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=o(function(){return i.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=o(function(){return i.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=o(function(){return i.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=o(function(){return i.then(function(h){return h.Classnames})}),t.Dayjs=o(function(){return i.then(function(h){return h.Dayjs})});var s=o(function(){return Promise.all([i]).then(function(h){var f=h[0]||Object.create(null),p=Object.create(null);for(var b in f)Object.prototype.hasOwnProperty.call(f,b)&&(p[b]=f[b]);for(var x in p)Object.prototype.hasOwnProperty.call(p,x)&&(t[x]=p[x]);return p})}),a={Uuid:"the shared `uuid` package was removed from the editor runtime; bundle `uuid` into the plugin or use `crypto.randomUUID()`"},c=["then","toString","valueOf","constructor","inspect","$$typeof"];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&t[l]===void 0&&(t[l]=(function(h,f){return new Proxy(Object.create(null),{get:function(p,b){if(!(typeof b=="symbol"||c.indexOf(b)!==-1))throw new Error("[shared-runtime] "+h+"."+String(b)+" is not available: "+f+".")}})})(l,a[l]));var u={},d={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.",UiKit:"[runtime] `useblocks-ui-kit` 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.",UiKitIcons:"[runtime] `useblocks-ui-kit/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."},m={Antd:"[runtime] `antd` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",AntDesignIcons:"[runtime] `@ant-design/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKit:"[runtime] `useblocks-ui-kit` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKitIcons:"[runtime] `useblocks-ui-kit/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version."},_=Object.create(null),v=function(h){for(var f=String(h&&h.stack||"").split(`
997
- `),p="",b=0;b<f.length;b+=1){var x=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(f[b]);if(x){if(!p){p=x[1];continue}if(x[1]!==p)return x[1]}}return""},E=function(h){var f=v(new Error(h)),p=f?h+" Requested by: "+f+".":h;return e.__compatMissingReason=p,p};if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var f in h)Object.prototype.hasOwnProperty.call(h,f)&&(_[f]=h[f])},e.__compatPending){for(var y=0;y<e.__compatPending.length;y+=1)e.registerCompat(e.__compatPending[y]);e.__compatPending=void 0}for(var k in d)Object.prototype.hasOwnProperty.call(d,k)&&(function(h,f,p){var b=!1,x=function(){if(!(h in _))throw new Error(E(f));return _[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var N=x();return b||(b=!0),N},set:function(N){_[h]=N}}),Object.defineProperty(u,h,{configurable:!0,enumerable:!0,get:x,set:function(N){_[h]=N}})})(k,d[k],m[k]);var C=t;for(var F in u)Object.prototype.hasOwnProperty.call(u,F)&&(C===t&&(C=Object.create(t)),Object.defineProperty(C,F,Object.getOwnPropertyDescriptor(u,F)));var T=s,R=[],A=function(){for(var h=[],f=0;f<R.length;f+=1)(function(p){var b=t[p];b&&typeof b.then=="function"&&h.push(Promise.resolve(b).then(function(x){t[p]=x}))})(R[f]);return Promise.all(h)},D=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(A).then(function(){if(typeof D=="function")return D.call(e)})},typeof e.define=="function"){let h=function(f){if(!f||typeof f!="object"&&typeof f!="function"||f.__esModule)return f;if(O){var p=O.get(f);if(p)return p}var b=Object.create(null);Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var x=Reflect.ownKeys(f),N=0;N<x.length;N++){var S=x[N];if(S!=="__esModule"){var w=Object.getOwnPropertyDescriptor(f,S);w&&Object.defineProperty(b,S,w)}}return Object.prototype.hasOwnProperty.call(b,"default")||Object.defineProperty(b,"default",{enumerable:!0,value:f,writable:!1}),O&&O.set(f,b),b};var O=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var f=C.React;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.React)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.React;return h(b)})}),e.define("useblocks/runtime/react",[],function(){var f=C.React;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.React)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.React;return h(b)})}),e.define("react-dom",[],function(){var f=C.ReactDom;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactDom)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactDom;return h(b)})}),e.define("useblocks/runtime/react-dom",[],function(){var f=C.ReactDom;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactDom)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactDom;return h(b)})}),e.define("react-dom/client",[],function(){var f=C.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactDomClient)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactDomClient;return h(b)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var f=C.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactDomClient)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactDomClient;return h(b)})}),e.define("react/jsx-runtime",[],function(){var f=C.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactJsxRuntime)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactJsxRuntime;return h(b)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var f=C.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactJsxRuntime)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactJsxRuntime;return h(b)})}),e.define("react/jsx-dev-runtime",[],function(){var f=C.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactJsxDevRuntime)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactJsxDevRuntime;return h(b)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var f=C.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactJsxDevRuntime)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactJsxDevRuntime;return h(b)})}),e.define("antd",[],function(){var f=C.Antd;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Antd)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Antd;return h(b)})}),e.define("useblocks/runtime/antd",[],function(){var f=C.Antd;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Antd)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Antd;return h(b)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var f=C.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignIconBase)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignIconBase;return h(b)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var f=C.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignIconBase)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignIconBase;return h(b)})}),e.define("@ant-design/icons",[],function(){var f=C.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignIcons)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignIcons;return h(b)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var f=C.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignIcons)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignIcons;return h(b)})}),e.define("@ant-design/cssinjs",[],function(){var f=C.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignCssinjs)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignCssinjs;return h(b)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var f=C.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignCssinjs)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignCssinjs;return h(b)})}),e.define("classnames",[],function(){var f=C.Classnames;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Classnames)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Classnames;return h(b)})}),e.define("useblocks/runtime/classnames",[],function(){var f=C.Classnames;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Classnames)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Classnames;return h(b)})}),e.define("dayjs",[],function(){var f=C.Dayjs;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Dayjs)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Dayjs;return h(b)})}),e.define("useblocks/runtime/dayjs",[],function(){var f=C.Dayjs;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Dayjs)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Dayjs;return h(b)})}),e.define("useblocks-ui-kit",[],function(){var f=C.UiKit;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.UiKit)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.UiKit;return h(b)})}),e.define("useblocks/ui-kit",[],function(){var f=C.UiKit;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.UiKit)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.UiKit;return h(b)})}),e.define("useblocks/ui-kit/icons",[],function(){var f=C.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.UiKitIcons)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.UiKitIcons;return h(b)})}),e.define("useblocks-ui-kit/icons",[],function(){var f=C.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.UiKitIcons)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.UiKitIcons;return h(b)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var qf=new Function("url","return import(url)");function Wf(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function di(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Dc(e){return e.type==="umd"||e.resolve==="registry"}var zf="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function Kf(e){const t=Array.isArray(e)?e[0]:e;return di(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Yf(e,t){const n=Kf(e),r=di(e)?e:void 0,o=t instanceof Error?t.message:String(t),i=r&&Dc(r)&&!/compat/iu.test(o)?` ${zf}`:"",s=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${i}`);return s.cause=t,{name:n,url:r?.url,error:s}}function Xf(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var Jf=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(di(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(Dc(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await qf(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let o;const i=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):Xf(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},s=()=>window.removeEventListener("error",i);window.addEventListener("error",i),r.onload=()=>{if(s(),o){n(o);return}t()},r.onerror=()=>{s(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const o=await this._resolveOrSkip(r);if(!o)continue;const i=this._createOrSkip(o.ctor,o.options);i&&!n.has(i)&&(n.add(i),t.push(i))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveOrSkip(s);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:c}=r[s];await this._initializingPlugins.get(c),await this._disposePlugin(c,c.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(c),this._resolveMap.delete(c),this._initializingPlugins.delete(c),this._initializedPlugins.delete(c);const l=this._creationOrder.indexOf(c);l>=0&&this._creationOrder.splice(l,1)}const o=[],i=new Set;for(const{ctor:s,options:a}of n){const c=this._createOrSkip(s,a);c&&!i.has(c)&&(i.add(c),o.push(c))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let i,s=!1;const a=()=>{s||(s=!0,i&&clearTimeout(i),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(i=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),o(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),o=this._createPluginInstance(e,r),i=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:i}),o.required?.(),this._map.set(n,o),this._creationOrder.push(o),this._setupReadyPromise(o)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Yf(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return Wf(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const o of t){if(this._initializedPlugins.has(o))continue;const i=this._initializingPlugins.get(o);if(i){n.add(i);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const i of r)this._initializingPlugins.set(i,o);n.add(o),o.finally(()=>{for(const i of r)this._initializingPlugins.get(i)===o&&this._initializingPlugins.delete(i)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const o=this._options.openEarlyWindow?.();try{await this._callSync(n,r,"init"),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}finally{o?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await this._callSync(n,r,"afterInit"),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(o){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:o})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}_callSync(e,t,n){this._emitLifecycle({type:`${n}:enter`,plugin:e,name:t});try{return e[n]?.()}finally{this._emitLifecycle({type:`${n}:leave`,plugin:e,name:t})}}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)}))}},Qf=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const o of n)try{o.callback(t)}catch{}const r=n.filter(o=>!o.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(o=>(t.ctor=o,t.loading=void 0,this._notifyListeners(e,o),o));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!1};return r.push(o),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!0};return r.push(o),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(o=>o.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Zf=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()}},ns=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 ep(e,t){return t+e}function tp(){return typeof performance>"u"?Date.now():ep(performance.now(),performance.timeOrigin)}var np="emailmaker:diagnostics",rp="diagnostics",op="diagnostics";function rs(e,t){return t?`${e}${e.includes("?")?"&":"?"}${op}=1`:e}var Nr;function ip(){try{const e=new URLSearchParams(window.location.search).get(rp);return e===null?void 0:e!=="0"}catch{return}}function sp(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function ap(){try{const e=window.localStorage.getItem(np);return e===null?void 0:e==="1"}catch{return}}function ln(){return Nr===void 0&&(Nr=typeof window>"u"?!1:ip()??sp()??ap()??!1),Nr}function cp(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var Ee={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"},OC=Object.values(Ee),kC=[Ee.canvasPainted,Ee.canvasSettled,Ee.appVisible,Ee.editorVisible],lp=5e3,up=3e3,os="diagnosticsStore",On,Ht;function is(){return{marks:new ns(lp),resources:new ns(up)}}function xc(){if(Ht)return Ht;const e=fi();return e?(Ht=e[os]??On??is(),e[os]=Ht,On=void 0,Ht):(On??=is(),On)}function ae(e,t){ln()&&xc().marks.push({phase:e,at:tp(),...t})}function fi(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[cp()];return e!==null&&typeof e=="object"?e:void 0}function dp(e){const t=e.length,n=xc();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function fp(){const e=fi();return!e||!Array.isArray(e.diagnosticsBuffer)?0:dp(e.diagnosticsBuffer)}var pp="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Ke(){const e=new Error(pp);return e.name="DestroyedInstanceError",e}function hp(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function vo(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const i=e,s=t;return i.length===s.length&&i.every((a,c)=>vo(a,s[c]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&vo(e[i],t[i]))}function Mc(e,t){const n={watch(r){let o,i=!1;return e.watch(s=>{const a=t(s);i&&vo(o,a)||(o=a,i=!0,r(a))})},select(r){return Mc(n,r)}};return n}function ce(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(i){t=i,n=!0;for(const s of Array.from(r))s(i)},watch(i){return r.add(i),n&&i(t),{dispose:()=>r.delete(i)}},select(i){return Mc(o,i)}};return o}var mp=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:Df.UrlEncoded,...t})},Lc=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 gp(e){return String(e||"").trim()||void 0}var vp=class extends ve{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=gp(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)}},pi=U("AppInitService");function bp(e){return async()=>{const t=await e();return(await new mp(t).app_init_create({})).data}}function _p(e){e.injectFactory(pi,(t,n)=>{if(n)return n;const r=new vp({options:e.getInstance(we),isStandalone:()=>!!e.getInstance(Ve),resolveRestBaseUrl:o=>o?Zi(o):Zi()||void 0,setRestBaseUrl:o=>{e.getInstance(Tf)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:bp(()=>e.getInstanceAsync(ef)),publish:o=>{e.inject(Xe,o)}});return e.getInstance(Y)?.addDisposable(r),r},!0)}var jt=U("documentSession.emailDocuments");function At(e){return e?.getInstance(jt)}var yp=U("RevisionServiceFlag");function Nc(e){return e.getOrCreateInstance(yp,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Fc(e){return Nc(e).isEnabled()}var Bc=U("EmailRightsResolver");function Ep(e,t){return e.onInject(n=>{n===Bc&&t()})}function jc(e,t){const n=e.getInstance(Bc);return n?n(t):!0}var hi={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Uc=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],$c=2e4,wp=Uc.reduce((e,t)=>e+hi[t],0),Hc=$c+wp+3e3;function Sp(e){return Uc.reduce((t,n)=>t+Vc(n,e),0)}function Vc(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:hi[e]}function Gc(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Hc}function qc(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:$c}function En(e=Hc){return e+3e3}function Wc(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var Ip=()=>En();function Tp(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function Ap(e){return t=>Tp(e.getOrCreateInstance(H.BEFORE_SAVE_EMAIL,()=>new Je).fire(t),Ip())}var ss=Symbol.for("emailmaker.saveRefusedError"),as=Symbol.for("emailmaker.integratorSaveTimeoutError");function zc(e,t,n,r){return e!==t?Function.prototype[Symbol.hasInstance].call(e,r):typeof r=="object"&&r!==null&&n in r}var He=class Kc extends Error{reason;detail;static[Symbol.hasInstance](t){return zc(this,Kc,ss,t)}constructor(t,n){super(n?`[emailmaker] save refused: ${t}: ${n}`:`[emailmaker] save refused: ${t}`),this.name="SaveRefusedError",this.reason=t,this.detail=n,Object.defineProperty(this,ss,{value:!0})}},Yc=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[useblocks] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},mr=class Xc extends Error{timeoutMs;static[Symbol.hasInstance](t){return zc(this,Xc,as,t)}constructor(t,n="handleSaveEmail",r="email"){super(`[useblocks] ${n} did not respond within ${t}ms — the ${r} was not saved`),this.timeoutMs=t,this.name="IntegratorSaveTimeoutError",Object.defineProperty(this,as,{value:!0})}};function fe(e){return e.getOrCreateInstance(yn,()=>new _n)}var Jc=new WeakMap,bo=new WeakMap;function Te(e){return Jc.get(e)??0}function un(e,t){let n=bo.get(e);return n||(n=new Set,bo.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Cp(e){Jc.set(e,Te(e)+1),bo.get(e)?.forEach(t=>t())}function _o(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var Rp=U("documentSession.canvasReceipts");function Op(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const o={guid:n,version:r};return e=o,()=>{e===o&&(e=void 0)}},note(n,r){const o=_o(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(o,n)}},read(n){if(!e)return;const{scope:r}=t,o={guid:e.guid,rev:e.version()};return r.originId!==null?{...o,changeId:t.changeId,originId:r.originId}:{...o,changeId:r.generation===n?t.changeId:0}}}}function Qc(e){return e.getOrCreateInstance(Rp,Op)}var kp=2e3,Pp=Bf+Ef+kp;function Dp(e,t=Pp){return async()=>{const n=fe(e);let r;const o=new Promise(i=>{r=setTimeout(()=>i("silent"),t)});try{const i=Qc(e).read(Te(n)),s=await Promise.race([n.sendAsync(K.SANDBOX_CANVAS_SYNCED,i?{applied:i}:void 0,!1),o]);if(s==="silent"||s&&!s.synced)throw s==="silent"||s?.unsent,new He("canvas-not-synced")}finally{clearTimeout(r)}}}var xp="em_autosave_pending";function Zn(e){return`${xp}_${e}`}function yo(e,t){try{return sessionStorage.setItem(Zn(e),JSON.stringify(t)),!0}catch{return!1}}function gr(e){try{const t=sessionStorage.getItem(Zn(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Zn(e)),null):n}catch{return null}}function st(e){try{sessionStorage.removeItem(Zn(e))}catch{}}function mi(e){return`block:${e}`}function Zc(e,t){return t?mi(e):e}function gi(e,t){(gr(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&st(e)}function Mp(e){return e!=null&&e!==""}function el(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var cs;function Lp(){return el(hr.em_revisions_v2)??!0}function Np(){return cs??=Lp(),cs}function Ut(e){return Fc(e)&&Np()}function Fp(){return!1}var tl;function dn(e,t){return tl?.capture(e,t)}function Bp(e,t){return tl?.captureMessage(e,t)}var jp=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Up=200;function nl(e=new Set){const t=new Set;return(n,r)=>{if(!jp.some(([i,s])=>!e.has(i)&&s.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=Up&&t.clear(),t.add(o))}}function rl(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:nl()}}var $p=rl();function Ze(e){return e?.getInstance(si)??$p}function Hp(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function kn(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Me=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} "${kn(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${kn(this.oldText)}")`:`(replace@${this.oldPosition} "${kn(this.oldText)}" with "${kn(this.newText)}")`}};function ls(e,t){return e===null||e.length===0?t:new Vp(e,t).compress()}var Vp=class Ue{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[c,l]=Ue._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(c),o=l;continue}if(r.newPosition<o.oldPosition){const[c,l]=Ue._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(c),r=l;continue}let s,a;if(o.oldEnd===r.newEnd)s=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[c,l]=Ue._splitPrev(r,o.oldLength);s=c,a=o,r=l,o=this._getCurr(++n)}else{const[c,l]=Ue._splitCurr(o,r.newLength);s=r,a=c,r=this._getPrev(++t),o=l}this._result[this._resultLen++]=new Me(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const i=Ue._merge(this._result);return Ue._removeNoOps(i)}_acceptCurr(t){this._result[this._resultLen++]=Ue._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++]=Ue._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 Me(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Me(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),o=t.newText.substr(n);return[new Me(t.oldPosition,t.oldText,t.newPosition,r),new Me(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new Me(t.oldPosition,r,t.newPosition,t.newText),new Me(t.oldPosition+n,o,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,o=t[0];for(let i=1;i<t.length;i++){const s=t[i];o.oldEnd===s.oldPosition?o=new Me(o.oldPosition,o.oldText+s.oldText,o.newPosition,o.newText+s.newText):(n[r++]=o,o=s)}return n[r++]=o,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let o=0;o<t.length;o++){const i=t[o];i.oldText!==i.newText&&(n[r++]=i)}return n}};function Gp(e){return new Me(e.newPosition,e.newText,e.oldPosition,e.oldText)}function qp(e){return e.map(Gp)}function us(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Wp(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const o=t[r];n=n.slice(0,o.oldPosition)+o.newText+n.slice(o.oldEnd)}return n}function ol(e,t,n){let r=0;const o=e.start===e.end;for(const i of t){const s=i.newLength-i.oldLength;if(i.oldLength===0){const a=i.oldPosition;if(o&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(o){if(e.start>=i.oldEnd)r+=s;else if(e.start>i.oldPosition)return null;continue}if(e.start>=i.oldEnd)r+=s;else if(e.end>i.oldPosition)return null}return{start:e.start+r,end:e.end+r}}function ds(e,t,n){if(!t.length)return[...e];const r=[];let o=0;for(const i of e){const s=ol({start:i.oldPosition,end:i.oldEnd},t,n);if(!s)return null;r.push(new Me(s.start,i.oldText,s.start+o,i.newText)),o+=i.newLength-i.oldLength}return r}var dt=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},fs=0,zp=Math.random().toString(36).slice(2,8);function Kp(){return fs+=1,`doc-${zp}-${fs}`}function Yp(e){const t=e.createBuffer(),n=e.docId??Kp();let r=e.serverId??null,o=0,i=null,s=e.attributes??{};const a=new Set;let c=!1,l=!1,u;const d=new Set;let m=null;const _=()=>(m?.version!==o&&(m={version:o,value:t.read()}),m.value),v=E=>Object.entries(E).some(([y,k])=>s[y]!==k);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:i,attributes:s}),getContent:_,mutate(E,{source:y}){if(c)return o;const k=E.changes?.length?E.changes:void 0,C=k?Wp(_(),k):E.content!==void 0?E.content:void 0,F=C!==void 0&&C!==_(),T=E.attributes!==void 0&&v(E.attributes);if(!F&&!T)return o;const R=!(o>(i??-1)),A=T?Object.keys(E.attributes).filter(O=>s[O]!==E.attributes[O]):[];F&&t.write(C),T&&(s={...s,...E.attributes}),o+=1,y!=="user"&&R&&(i=o);const D={source:y,version:o,changes:k,...F?{content:!0}:{},...A.length>0?{attributes:A}:{}};return a.forEach(O=>O(D)),o},markSaved(E,y){const k={serverId:r,savedVersion:i};y!==void 0&&(r=y),(i===null||E>i)&&(i=E),(k.serverId!==r||k.savedVersion!==i)&&a.forEach(C=>C({source:"system",version:o}))},markUnsaved(){c||i===null||i<o||(i=o-1,a.forEach(E=>E({source:"system",version:o})))},markReady(){l||u!==void 0||(l=!0,d.forEach(E=>E.resolve()),d.clear(),a.forEach(E=>E({source:"system",version:o})))},isReady:()=>l,markFailed(E){l||u!==void 0||c||(u=E,d.forEach(y=>y.reject(new dt(E))),d.clear(),a.forEach(y=>y({source:"system",version:o})))},failure:()=>u,whenReady(){return l?Promise.resolve():u!==void 0?Promise.reject(new dt(u)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((E,y)=>{d.add({resolve:E,reject:y})})},subscribe(E){return a.add(E),()=>a.delete(E)},isNew:()=>r===null,isDirty:()=>o>(i??-1),isDisposed:()=>c,dispose(){c=!0,d.forEach(E=>E.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),d.clear(),a.clear(),t.dispose()}}}var Xp=500,Jp=100,Fr=0,ps=0;function Qp(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function il(e,t,n){let r=0;for(const o of t){if(o.oldPosition>e||o.oldPosition===e&&(o.oldLength>0||!n))break;if(o.oldEnd>e)return o.newEnd;r=o.newEnd-o.oldEnd}return e+r}function Eo(e,t){if(!e)return e;if(e.start===e.end){const n=t(e.start,"caret");return{start:n,end:n}}return{start:t(e.start,"start"),end:t(e.end,"end")}}var sl=(e,t)=>t==="old"?e.oldPosition:e.newPosition,al=(e,t)=>t==="old"?e.oldEnd:e.newEnd;function cl(e,t,n,r){const o=t==="start"?["start","end"]:["end","start"];for(const i of o){const s=r.findIndex(a=>(i==="start"?sl(a,n):al(a,n))===e);if(s>=0)return{index:s,edge:i}}}function Zp(e,t,n){if(!e?.after)return e;const r=(o,i)=>{const s=cl(o,i,"new",n);return il(o,t,s?s.edge==="start"&&n[s.index].newLength>0:i==="start")};return{...e,after:Eo(e.after,r)}}function eh(e,t,n,r,o){const i=(s,a)=>(c,l)=>{const u=cl(c,l,s,t);return u?u.edge==="start"?sl(n[u.index],s):al(n[u.index],s):il(c,a,l==="start")};return e&&{before:Eo(e.before,i("old",r)),after:Eo(e.after,i("new",o))}}function th(e,t={}){const n=t.groupIntervalMs??Xp,r=t.maxSteps??Jp,o=t.now??(()=>0);let i=[],s=0,a=Fr+=1,c=null,l,u,d,m=!1,_=!1,v=!1,E=0,y=!1,k=!1;const C=new Set,F=()=>C.forEach(w=>w()),T=(w,M)=>{if(w.length){v=!0;try{e.mutate({changes:w},{source:M})}finally{v=!1}}},R=w=>T(w,"user"),A=w=>{const M=l?.from??o(),B=E>0?y:_&&c!==null&&m===(l!==void 0)&&M>=c&&M-c<n;if(E>0&&(y=!0),B){const W=i[s-1];i[s-1]={...W,changes:ls(W.changes,w),selection:Qp(W.selection,u)}}else i=i.slice(0,s),ps+=1,i.push({id:ps,below:i[s-1]?.id??0,changes:w,selection:u}),s=i.length,_=!0,i.length>r&&(i=i.slice(i.length-r),s=i.length,a=Fr+=1);c=l?.to??M,m=l!==void 0,F()},D=()=>{_=!1,c=null},O=w=>{let M=w;for(let B=s;B<i.length;B+=1){const W=i[B],re=ds(W.changes,M,"after"),oe=re&&ds(M,W.changes,"before");if(!re||!oe)return i=i.slice(0,B),!0;i[B]={...W,changes:re,selection:eh(W.selection,W.changes,re,M,oe)},M=oe}return!1},h=w=>{if(!w.length)return;const M=O(w);if(s>0){const B=i[s-1];i[s-1]={...B,changes:ls(B.changes,w),selection:Zp(B.selection,w,B.changes)}}D(),M&&F()},f=e.subscribe(({source:w,changes:M})=>{if(!(k||v||!M?.length)){if(w==="remote"){p();return}if(w!=="user"){h(M);return}A(M)}}),p=()=>{i=[],s=0,y=!1,D(),a=Fr+=1,F()},b=(w,M)=>{y=!1,d=M;try{R(w)}finally{d=void 0}},x=(w=!1)=>{if(s===0)return!1;const M=i[s-1],B=qp(M.changes);return us(e.getContent(),B)?(b(B,w?{kind:"undo",selection:M.selection?.before}:void 0),s-=1,D(),!0):(i=i.slice(0,s-1),s=i.length,y=!1,D(),F(),!1)},N=()=>{const w=x(!0);return w&&F(),D(),w},S=()=>{if(s>=i.length)return D(),!1;const w=i[s];return us(e.getContent(),w.changes)?(b(w.changes,{kind:"redo",selection:w.selection?.after}),s+=1,D(),F(),!0):(i=i.slice(0,s),D(),F(),!1)};return{recordAt(w,M,B){const W=l,re=u;l=w,u=B;try{return M()}finally{l=W,u=re}},activeMove:()=>d,canUndo:()=>s>0,canRedo:()=>s<i.length,undo(){N()},redo(){S()},tryUndo:N,tryRedo:S,clear:p,closeGroup:D,beginTransaction(){E===0&&(y=!1),E+=1;let w=!1;return()=>{w||(w=!0,E-=1,E===0&&(y=!1,D()))}},applyWithoutHistory(w){const M=e.get().version;if(T(w,"system"),e.get().version===M){D();return}h(w)},getPast:w=>i.slice(0,s).reverse().slice(0,w).map(M=>M.changes),getFuture:w=>i.slice(s).reverse().slice(0,w).map(M=>M.changes),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(w){if(w.stackId!==a||w.index>s)return!1;for(;s>w.index;)if(!x())return F(),!1;return F(),!0},currentStep:()=>({id:i[s-1]?.id??0,below:i[s-1]?.below??0}),subscribe(w){return C.add(w),()=>C.delete(w)},dispose(){k=!0,f(),C.clear(),i=[],s=0}}}var nh=["edit","move","resize","insert"];function Br(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function rh(e){return typeof e=="string"?e:null}function oh(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function ih(e){return nh.includes(e)?e:null}function sh(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:rh(t.originId),changeId:Br(t.changeId),rev:Br(t.rev),baseRev:Br(t.baseRev),expected:oh(t.expected),intent:ih(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}function ah(e){return e instanceof He?e.reason:void 0}var hs={"too-many-tags":"The email has more tags than allowed, so nothing was saved.","canvas-not-synced":"Not all canvas edits reached the document, so nothing was saved; try again in a moment.","plugin-refused":"A plugin refused the save, so nothing was saved."};function ch(e){const t=ah(e);if(t===void 0||t==="locked")return;const{detail:n}=e;return n?`${hs[t]} Its reason: ${n}`:hs[t]}var ms=Symbol.for("emailmaker.blockSaveFlight"),ll=Symbol.for("emailmaker.blockSaveSessionQueue"),wo=new WeakMap;function ul(e,t){return Object.isExtensible(e)||t in e?e[t]:wo.get(e)?.get(t)}function dl(e,t,n){if(t in e||Object.isExtensible(e)){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return}const r=wo.get(e)??new Map;r.set(t,n),wo.set(e,r)}function lh(e,t){dl(e,ll,t)}function uh(e,t){const n=(ul(e,ms)??Promise.resolve()).then(t,t);return dl(e,ms,n.catch(()=>{})),n}function dh(e,t){return ul(e,ll)?.(t)??uh(e,t)}var Vt=new Map,gs=new Map;function fh(e){return Vt.set(e,(Vt.get(e)??0)+1),()=>{const t=(Vt.get(e)??1)-1;if(t>0){Vt.set(e,t);return}Vt.delete(e);const n=gs.get(e);gs.delete(e),n?.forEach(r=>r())}}var vi=e=>e.replace(/\r\n?/g,`
998
- `),ph=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function So(e){return typeof e=="string"&&ph.test(e)}var hh=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function mh(){return typeof navigator<"u"&&navigator.onLine===!1}function gh(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const o=r.data;typeof r.data=="object"&&o.error!=null&&t.push(o.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function fl(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return fl(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function vh(e){return mh()?!0:gh(e).some(fl)}var pl=new WeakSet,hl=new WeakMap;function ml(e){typeof e=="object"&&e!==null&&pl.add(e)}function bh(e,t){typeof e=="object"&&e!==null&&hl.set(e,t)}function _h(e){return typeof e=="object"&&e!==null?hl.get(e):void 0}function yh(e){return e instanceof mr||e instanceof Yc||typeof e=="object"&&e!==null&&pl.has(e)}function Eh(e){return e instanceof He||gl(e)||e instanceof hh||yh(e)}function gl(e){return bi(e)?.v2Error?.data?.code==="blocks.block_locked"}function vs(e){return bi(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function bi(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function wh(e){if(e instanceof He)return e.reason==="canvas-not-synced";if(Eh(e))return!1;const t=bi(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?vs(e):!0}return vh(e)||vs(e)}var vl="draft";function wt(e){return e==null||e===""?vl:String(e)}function er(e){return e==null||e===""?`${Io}${vl}`:`${Io}${String(e)}`}var Io="block:";function ee(e){return e?.startsWith(Io)===!0}function Ct(e){return ee(e.sessionKey())?void 0:e.current()}function ct(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return ae(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(ae(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const i=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw ui(o)?(`${e}`,{...n}):(`${e}`,{error:Wc(o),...n},void 0),o})}var Sh=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function Ih(e){const t=e?.trim()??"";if(!Sh.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function en(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function _i(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Th(e,t={}){const n=en((e??[]).filter(r=>r?.html?.trim()));return _i(n,t)?n:null}function Ah(e,t){const n=Date.parse(en(e)?.modified??""),r=Th(e),o=Date.parse(r?.modified??""),i=t===void 0||Number.isFinite(o)&&o>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:i?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function bs(e,t,n){const r=en((e??[]).filter(c=>c?.html?.trim())),o=Date.parse(r?.modified??""),i=Date.parse(en((n??[]).filter(c=>c?.html?.trim()))?.modified??""),s=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(i>o),a=[Date.parse(en(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:s&&_i(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Ch({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var _s=["recovery","plugin","rest"],Rh=["subject","preheader"];function Oh(e){let t={},n;for(let o=_s.length-1;o>=0;o--){const i=e.get(_s[o]);i&&(i.attributes&&(t={...t,...i.attributes}),i.content!==void 0&&(n=i.content))}const r=e.get("plugin")?.attributes;for(const o of Rh){const i=r?.[o];typeof i=="string"&&i!==""&&(t={...t,[o]:i})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function tr(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?vi(t.content):void 0,o=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...o?{changes:[new Me(0,n,0,r)]}:{}},{source:"remote"})}var jr=e=>typeof e=="string"?e.trim():"";function kh(e,t,n,r){const{version:o,attributes:i}=e.get(),s=i,a=r==="snapshot"||r==="anchor",c=a?s.author:void 0,l=a?s.date_gmt:void 0,u=jr(s.title)||jr(s.subject)||jr(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:u,subject:s.subject,preheader:s.preheader,description:s.description,common_styles:s.common_styles||"",meta:s.meta,utm_parameters:s.utm_parameters,parent_email:s.parent_email,is_template:s.is_template||!1,is_inited:s.is_inited,tags:s.tags,emailtags:s.emailtags,group:s.group,projectCategories:s.projectCategories,renderGuid:e.get().docId,project:t.project??s.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...c!=null&&c!==""?{author:c}:{},...l?{excerpt:l}:{}}}}var Ph=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Dh(e){const t={};for(const n of Ph)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function xh(e,t,n,r,o,i){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(o);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,o):t.saveAutosave(r,o,i==null?void 0:{wpId:i})}function Ge(e,t=!1){const n={};for(const r of Object.keys(e)){let o=e[r];o!==void 0&&!(typeof o=="number"&&Number.isNaN(o))&&(t&&typeof o=="object"&&o!==null&&(o=Ge(o)),n[r]=o)}return n}function Mh(e){return typeof e=="string"&&e.includes("autosave")}var Lh=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function bl(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Lh.has(t))):{}}function Mt(e,t,n={}){e&&e.mutate({attributes:Nh(e.get().attributes,t)},{source:n.source??"user"})}function Nh(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function yi(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Fh(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function _l(e){if(!e)return null;const t=bl(e);return e.common_styles!==void 0&&(t.common_styles=Fh(e.common_styles)),yi(e.html,t)}function yl(e){return e?yi(e.html,Ge(bl(e))):null}var Bh=["common_styles","subject","preheader","meta"];function ys(e){if(!e?.html?.trim())return null;const t={};for(const n of Bh)jh(n,e[n])&&(t[n]=e[n]);return yi(e.html,t)}function jh(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 Uh=["modified","lock","wpId","secretHash"];function Es(e){if(!e)return null;const t={};for(const n of Uh)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var $h=10,Hh=(e,t)=>e.key===t.key&&Vh(e.serverId,t.serverId),Vh=(e,t)=>e==null||e===t;function Gh(e){return typeof e?.then=="function"}var ws=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},El=e=>{e.request.serverId!=null&&!vr(e)&&e.document.markSaved(e.document.get().version)},vr=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Ss=(e,t)=>t?.content!==void 0&&Ch({hasUnsavedUserEdit:vr(e)})==="skip",Is=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},qh=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),Wh=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.userTouched.clear(),e.document.get().docId))},zh=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,i])=>e.attributes[o]!==i)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Kh=e=>{const t=Oh(e.reports),n=zh(e.lastMerged,t);e.lastMerged=t,e.broughtContent=br(t.content)??e.broughtContent,n&&(tr(e.document,n),El(e))},Ur=(e,t)=>{if(!e.ready&&!vr(e)){Kh(e);return}e.broughtContent=br(t?.content)??e.broughtContent,tr(e.document,t)},br=e=>e===void 0?void 0:vi(e),Yh=(e,t)=>t.content===void 0||br(t.content)!==e.broughtContent||!vr(e)?t:{...t,content:void 0},Ts=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 Xh(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:i,canEdit:s,notifyBeforeSave:a,confirmPublish:c,awaitCanvasSynced:l,savedEchoForm:u=g=>g,queuesOutsideWrites:d,onAdapterError:m,onTimeout:_}=e;let v,E;const y=new Set,k=new Set,C=()=>y.forEach(g=>g()),F=(g,I)=>{if(!(g.closed||g.ready)){if(g.error!==void 0){g.document.markFailed(g.error),g.document.get().docId;return}El(g),g.ready=!0,g.document.markReady(),g.document.get().docId,[...g.reports.keys()]}},T=(g,I,P)=>{m?.(I.id,P),!(!I.required||g.closed)&&(g.error=P,g.document.get().docId,I.id,C())},R=(g,I)=>{const P=new Set(I.map(G=>G.id));I.forEach(G=>{G.watch&&g.watchers.push(G.watch(z=>g.closed?!1:g.ready&&(Ss(g,z)||g.contentShown===!0&&z?.content!==void 0)?(g.document.get().docId,G.id,!1):(z&&g.reports.set(G.id,z),Ur(g,z),z?.content!==void 0&&(g.showFill=void 0),!0)))});const j=(G,z)=>{if(!g.closed){if(!G.required&&Ss(g,z)){g.document.get().docId,G.id,G.loaded?.(!1);return}z&&(g.reports.set(G.id,z),G.id==="plugin"&&Is(g,z)),Ur(g,z),G.loaded?.(z!==null)}},q=()=>{P.size>0||g.closed||(ws(g),F(g,[]))},Q=[];if(I.forEach(G=>{let z;try{z=G.load()}catch(L){T(g,G,L),P.delete(G.id);return}if(Gh(z)){Q.push({id:G.id,required:G.required,load:()=>z,...G.loaded?{loaded:L=>G.loaded?.(L)}:{}});return}j(G,z),P.delete(G.id)}),Q.length===0){q();return}g.timer=setTimeout(()=>{g.timer=void 0,_?.([...P]),g.document.get().docId,[...P],F(g,[...P])},n),g.timer.unref?.(),Q.forEach(G=>{G.load().then(z=>j(G,z)).catch(z=>{T(g,G,z)}).finally(()=>{P.delete(G.id),q()})})},A=async(g,I,P)=>{if(P==="snapshot"||P==="anchor")return;const j=i?.();if(j)return j.resolve({project:I.project??g.project,tags:(g.tags??[]).map(q=>({name:q}))})},D=g=>{if(g.lock===!0&&s?.(g)===!1)return new He("locked");const I=g.tags?.length??0,P=g.emailtags?.length??0;if(Math.max(I,P)>$h)return new He("too-many-tags")},O=(g,I)=>{const P=g.document.get().serverId;P!=null&&(g.createKey=void 0),!(I||P==null)&&(g.recoveryFacts={emailId:P,historyLoaded:!0,isRecovering:!1},ee(g.request.key)||(g.request={...g.request,key:wt(P),serverId:P}))},h=(g,I,P)=>{if(g.closed||P?.id==null)return;const j=g.document.get().serverId,q=j!=null;q&&j!==String(P.id)||(g.document.markSaved(I,String(P.id)),O(g,q),g.document.get().serverId,C())},f=(g,I,P)=>{if(!(I==="materialize"||I==="publish"&&g.document.get().serverId==null))return P;const j=g.createKey,q=j&&j.project===P.project?j:{key:ke(),project:P.project};return g.createKey=q,{...P,idempotencyKey:q.key}},p=async(g,I,P)=>{try{await g.document.whenReady()}catch(L){return g.saveError=L,g.saveFailures+=1,g.failedIntent=I,g.saveFailures,!1}if(g.closed)return!1;const j=D(g.document.get().attributes);if(j)return g.saveError=j,g.saveFailures+=1,g.failedIntent=I,j.reason,C(),!1;if(a&&(await a(Ts(g)).catch(()=>{}),g.closed))return!1;if(l){try{await l()}catch(L){return g.saveError=L,g.saveFailures+=1,g.failedIntent=I,g.saveFailures,C(),!1}if(g.closed)return!1}if(c&&I==="publish"){const L=await c(Ts(g),g.request.key).catch(()=>{});if(g.closed)return!1;if(L!==void 0)return g.saveError=new He("plugin-refused",L),g.saveFailures+=1,g.failedIntent=I,C(),!1}let q;try{q=await A(g.document.get().attributes,P,I)}catch(L){return g.saveError=L,g.saveFailures+=1,g.failedIntent=I,g.saveFailures,C(),!1}if(g.closed)return!1;const{payload:Q,version:G}=kh(g.document,P,q,I),z=f(g,I,Q);g.document.get().docId;try{const L=g.document.get().serverId!=null,J=await xh(r(),o(g.request.key),I,g.document.get().serverId,z,g.document.get().attributes.wpId);if(g.closed)return!0;let Z;if(I==="snapshot"||I==="anchor"){const te=J?.modified!=null?Date.parse(J.modified):NaN;Z=Number.isFinite(te)?te:Date.now(),g.snapshotVersion=G,g.lastRevisionAt=Z}else{g.document.markSaved(G,J?.id!=null?String(J.id):void 0);const te=J;tr(g.document,Es(te&&{wpId:te.wpId,secretHash:te.secretHash})),g.broughtContent=br(u(z.html))}O(g,L),g.saveError=void 0,g.saveFailures=0,g.failedIntent=void 0,g.document.get().serverId,C();const be={intent:I,serverId:g.document.get().serverId,created:!L,...Z!==void 0?{revisionAt:Z}:{}};return k.forEach(te=>te(be)),!0}catch(L){return(I==="publish"||I==="materialize")&&_h(L)?.then(J=>h(g,G,J)),g.saveError=L,g.saveFailures+=1,g.failedIntent=I,g.saveFailures,C(),!1}},b=g=>{g.closed=!0,g.watchers.forEach(I=>I()),g.watchers=[],ws(g),g.history.dispose(),g.document.dispose()},x=()=>{v&&(b(v),v=void 0)},N=()=>{E&&(b(E),E=void 0)},S=(g,I,P)=>{let j=!1;I.show&&(g.show?.id!==I.show.id||g.show.token!==I.show.token)&&(g.show=I.show,j=!0,{docId:g.document.get().docId,...I.show});const q=P==="show"?yl(I.patch):null;if(q){g.reports.set("plugin",q),Is(g,q);const Q=Yh(g,q);Ur(g,Q),Wh(g,Q)}j&&C()},w=(g,I={})=>W(v,g,I),M=()=>v&&ee(v.request.key??"")?E:v,B=g=>({error:g?.saveError,failures:g?.saveFailures??0,saving:g?.saving===!0,failedIntent:g?.failedIntent}),W=(g,I,P)=>!g||g.closed||I==="materialize"&&g.document.get().serverId!=null?Promise.resolve(!1):g.saving?I==="snapshot"||I==="materialize"?Promise.resolve(!1):(g.inFlight??Promise.resolve(!1)).then(()=>W(g,I,P)):(g.saving=!0,C(),g.inFlight=p(g,I,P).finally(()=>re(g)),g.inFlight),re=g=>{g.saving=!1,g.inFlight=void 0,v===g&&!g.closed&&C()},oe=(g,I)=>{if(g.closed)return I();if(g.saving)return(g.inFlight??Promise.resolve(!1)).then(()=>oe(g,I));g.saving=!0,C();const P=Promise.resolve().then(I);return g.inFlight=P.then(()=>!0,()=>!1).finally(()=>re(g)),P},ie=(g,I)=>{const P=g.document.get().serverId,j=P==null?void 0:fh(P);return oe(g,I).finally(j)},X=(g,I="open",P=!1)=>{if(v&&!v.closed&&I!=="new"&&Hh(v.request,g))return S(v,g,I),v.document;x(),P||N();const j=Yp({createBuffer:()=>Hp(""),serverId:g.serverId??null}),q={request:g,show:g.show,document:j,history:th(j,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return v=q,lh(j,Q=>d?.(q.request.key)===!0?ie(q,Q):void 0),q.watchers.push(qh(q)),j.get().docId,g.serverId,R(q,t(g,{publishRecoveryFacts(Q){q.closed||(q.recoveryFacts=Q,C())},readShownContent:()=>q.closed?null:q.document.getContent(),readWpId:()=>q.closed?void 0:q.document.get().attributes.wpId})),C(),j},$=(g,I,P)=>({key:ee(g)?g:er(g),serverId:I?.id!=null?String(I.id):null,email:I,show:P});return{openWith:X,open:(g,I={})=>X({key:wt(g),serverId:g,email:I.email,patch:I.patch,show:I.show},"open"),openDraft:(g,I={})=>X({key:wt(void 0),serverId:null,email:g,patch:I.patch,show:I.show},"open"),startNewDraft:(g,I={})=>X({key:wt(void 0),serverId:null,email:g,patch:I.patch,show:I.show},"new"),reload:(g,I={})=>X({key:wt(g),serverId:g,email:I.email,patch:I.patch,show:I.show},"new"),openBlock:(g,I,P)=>X($(g,I,P),"open"),reloadBlock:(g,I,P)=>X($(g,I,P),"new"),openBlockOver:(g,I)=>{const P=$(g,I);return v&&!v.closed&&v.request.key===P.key?v.document:(v&&!v.closed&&!ee(v.request.key)&&(N(),E=v,v=void 0),X(P,"open",!0))},resumeSuspended:()=>{if(E)return x(),v=E,E=void 0,C(),v.document},hasSuspended:()=>!!E,suspendedDocument:()=>E?.document,show:(g,I)=>{const P=v;if(!(!P||P.closed))return X({...P.request,patch:g,show:I},"show")},current:()=>v?.document,noteServerFacts:({serverId:g,block:I},P)=>{const j=v;!j||j.closed||j.request.serverId!==g||ee(j.request.key??"")===I&&tr(j.document,Es(P))},save:w,saveEmail:(g,I={})=>W(M(),g,I),saveState:()=>B(v),emailSaveState:()=>B(M()),revisionFacts(){if(!v)return;const g=v.revisionFactsSnapshot;return g&&g.snapshotVersion===v.snapshotVersion&&g.lastRevisionAt===v.lastRevisionAt?g:(v.revisionFactsSnapshot={snapshotVersion:v.snapshotVersion,lastRevisionAt:v.lastRevisionAt},v.revisionFactsSnapshot)},recoveryFacts:()=>v?.recoveryFacts,history:()=>v?.history,forcedHeaders:()=>v?.forcedHeaders,beginForcedHeaders(g){v&&!v.closed&&(v.forcedHeaders=g)},endForcedHeaders(){for(const g of[v,E])g&&(g.forcedHeaders=void 0)},onSaved(g){return k.add(g),()=>k.delete(g)},showFacts:()=>v?.show,shownHeaders:()=>({...v?.shownHeaders}),showFill:()=>v?.showFill,beginShowFill(g){v&&!v.closed&&(v.showFill={showId:g,codeEdits:0})},noteCodeEdit(){v?.showFill&&(v.showFill.codeEdits+=1)},endShowFill(g){for(const I of[v,E])I?.showFill?.showId===g&&(I.showFill=void 0)},sessionKey:()=>v?.request.key,openError:()=>v?.error,subscribe(g){return y.add(g),()=>y.delete(g)},close(){!v&&!E||(x(),N(),C())}}}var Ei=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function wi(e){if(e instanceof Ei)return e.reason;if(e instanceof dt)return wi(e.reason)}function Jh(e){const t=e instanceof dt?e.reason:e;return t instanceof Ei&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Qh(e){const t=wi(e);return t!==void 0&&t!=="unavailable"}function Zh(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Ei("not-found");return _l(n)}}}var wl=U("EmailPort");function em(e){return e.getInstance(wl)}function tm(e,t){e.inject(wl,t)}var Sl=U("documentSession.restEmailPortFactories");function Il(e){return e.getInstance(Sl)!==void 0}function ft(e){const t=e.getInstance(Sl);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var nm=U("EmailTermsResolver");function rm(e){return e.getInstance(nm)}var Tl=U("EmailHistoryPort"),om=U("BlockHistoryPort");function Al(e){return e.getInstance(om)}function Cl(e){return e.getInstance(Tl)}function im(e,t){e.inject(Tl,t)}var sm=2e3,am=5e3,cm=5,lm=5e3,um=4;function dm(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Wn(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.7594857d.js",po:"useblocks-po.7594857d.js",monaco:"static/monaco/index.CO7s5UdA.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var o=function(m){var p,h=function(){return p||(p=Promise.resolve().then(m))};return{then:function(b,L){return h().then(b,L)},catch:function(b){return h().catch(b)},finally:function(b){return h().finally(b)}}},s=o(function(){return e.require(["__delivery__/libs"]).then(function(m){return m[0]})});t.React=o(function(){return s.then(function(m){return m.React})}),t.ReactDom=o(function(){return s.then(function(m){return m.ReactDom})}),t.ReactDomClient=o(function(){return s.then(function(m){return m.ReactDomClient})}),t.ReactJsxRuntime=o(function(){return s.then(function(m){return m.ReactJsxRuntime})}),t.ReactJsxDevRuntime=o(function(){return s.then(function(m){return m.ReactJsxDevRuntime})}),t.AntDesignIconBase=o(function(){return s.then(function(m){return m.AntDesignIconBase})}),t.AntDesignCssinjs=o(function(){return s.then(function(m){return m.AntDesignCssinjs})}),t.Classnames=o(function(){return s.then(function(m){return m.Classnames})}),t.Dayjs=o(function(){return s.then(function(m){return m.Dayjs})});var i=o(function(){return Promise.all([s]).then(function(m){var p=m[0]||Object.create(null),h=Object.create(null);for(var b in p)Object.prototype.hasOwnProperty.call(p,b)&&(h[b]=p[b]);for(var L in h)Object.prototype.hasOwnProperty.call(h,L)&&(t[L]=h[L]);return h})}),a={Uuid:"the shared `uuid` package was removed from the editor runtime; bundle `uuid` into the plugin or use `crypto.randomUUID()`"},c=["then","toString","valueOf","constructor","inspect","$$typeof"];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&t[l]===void 0&&(t[l]=(function(m,p){return new Proxy(Object.create(null),{get:function(h,b){if(!(typeof b=="symbol"||c.indexOf(b)!==-1))throw new Error("[shared-runtime] "+m+"."+String(b)+" is not available: "+p+".")}})})(l,a[l]));var u={},d={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.",UiKit:"[runtime] `useblocks-ui-kit` 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.",UiKitIcons:"[runtime] `useblocks-ui-kit/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 to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",AntDesignIcons:"[runtime] `@ant-design/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKit:"[runtime] `useblocks-ui-kit` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKitIcons:"[runtime] `useblocks-ui-kit/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version."},v=Object.create(null),g=function(m){for(var p=String(m&&m.stack||"").split(`
997
+ `),h="",b=0;b<p.length;b+=1){var L=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(p[b]);if(L){if(!h){h=L[1];continue}if(L[1]!==h)return L[1]}}return""},y=function(m){var p=g(new Error(m)),h=p?m+" Requested by: "+p+".":m;return e.__compatMissingReason=h,h};if(e.registerCompat=function(m){if(!(!m||typeof m!="object"))for(var p in m)Object.prototype.hasOwnProperty.call(m,p)&&(v[p]=m[p])},e.__compatPending){for(var E=0;E<e.__compatPending.length;E+=1)e.registerCompat(e.__compatPending[E]);e.__compatPending=void 0}for(var P in d)Object.prototype.hasOwnProperty.call(d,P)&&(function(m,p,h){var b=!1,L=function(){if(!(m in v))throw new Error(y(p));return v[m]};Object.defineProperty(t,m,{configurable:!0,enumerable:!0,get:function(){var F=L();return b||(b=!0),F},set:function(F){v[m]=F}}),Object.defineProperty(u,m,{configurable:!0,enumerable:!0,get:L,set:function(F){v[m]=F}})})(P,d[P],f[P]);var O=t;for(var x in u)Object.prototype.hasOwnProperty.call(u,x)&&(O===t&&(O=Object.create(t)),Object.defineProperty(O,x,Object.getOwnPropertyDescriptor(u,x)));var w=i,C=[],T=function(){for(var m=[],p=0;p<C.length;p+=1)(function(h){var b=t[h];b&&typeof b.then=="function"&&m.push(Promise.resolve(b).then(function(L){t[h]=L}))})(C[p]);return Promise.all(m)},D=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return i.then(T).then(function(){if(typeof D=="function")return D.call(e)})},typeof e.define=="function"){let m=function(p){if(!p||typeof p!="object"&&typeof p!="function"||p.__esModule)return p;if(R){var h=R.get(p);if(h)return h}var b=Object.create(null);Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var L=Reflect.ownKeys(p),F=0;F<L.length;F++){var I=L[F];if(I!=="__esModule"){var S=Object.getOwnPropertyDescriptor(p,I);S&&Object.defineProperty(b,I,S)}}return Object.prototype.hasOwnProperty.call(b,"default")||Object.defineProperty(b,"default",{enumerable:!0,value:p,writable:!1}),R&&R.set(p,b),b};var R=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var p=O.React;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.React)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.React;return m(b)})}),e.define("useblocks/runtime/react",[],function(){var p=O.React;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.React)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.React;return m(b)})}),e.define("react-dom",[],function(){var p=O.ReactDom;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.ReactDom)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.ReactDom;return m(b)})}),e.define("useblocks/runtime/react-dom",[],function(){var p=O.ReactDom;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.ReactDom)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.ReactDom;return m(b)})}),e.define("react-dom/client",[],function(){var p=O.ReactDomClient;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.ReactDomClient)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.ReactDomClient;return m(b)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var p=O.ReactDomClient;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.ReactDomClient)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.ReactDomClient;return m(b)})}),e.define("react/jsx-runtime",[],function(){var p=O.ReactJsxRuntime;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.ReactJsxRuntime)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.ReactJsxRuntime;return m(b)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var p=O.ReactJsxRuntime;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.ReactJsxRuntime)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.ReactJsxRuntime;return m(b)})}),e.define("react/jsx-dev-runtime",[],function(){var p=O.ReactJsxDevRuntime;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.ReactJsxDevRuntime)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.ReactJsxDevRuntime;return m(b)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var p=O.ReactJsxDevRuntime;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.ReactJsxDevRuntime)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.ReactJsxDevRuntime;return m(b)})}),e.define("antd",[],function(){var p=O.Antd;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.Antd)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.Antd;return m(b)})}),e.define("useblocks/runtime/antd",[],function(){var p=O.Antd;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.Antd)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.Antd;return m(b)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var p=O.AntDesignIconBase;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.AntDesignIconBase)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.AntDesignIconBase;return m(b)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var p=O.AntDesignIconBase;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.AntDesignIconBase)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.AntDesignIconBase;return m(b)})}),e.define("@ant-design/icons",[],function(){var p=O.AntDesignIcons;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.AntDesignIcons)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.AntDesignIcons;return m(b)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var p=O.AntDesignIcons;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.AntDesignIcons)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.AntDesignIcons;return m(b)})}),e.define("@ant-design/cssinjs",[],function(){var p=O.AntDesignCssinjs;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.AntDesignCssinjs)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.AntDesignCssinjs;return m(b)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var p=O.AntDesignCssinjs;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.AntDesignCssinjs)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.AntDesignCssinjs;return m(b)})}),e.define("classnames",[],function(){var p=O.Classnames;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.Classnames)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.Classnames;return m(b)})}),e.define("useblocks/runtime/classnames",[],function(){var p=O.Classnames;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.Classnames)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.Classnames;return m(b)})}),e.define("dayjs",[],function(){var p=O.Dayjs;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.Dayjs)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.Dayjs;return m(b)})}),e.define("useblocks/runtime/dayjs",[],function(){var p=O.Dayjs;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.Dayjs)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.Dayjs;return m(b)})}),e.define("useblocks-ui-kit",[],function(){var p=O.UiKit;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.UiKit)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.UiKit;return m(b)})}),e.define("useblocks/ui-kit",[],function(){var p=O.UiKit;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.UiKit)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.UiKit;return m(b)})}),e.define("useblocks/ui-kit/icons",[],function(){var p=O.UiKitIcons;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.UiKitIcons)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.UiKitIcons;return m(b)})}),e.define("useblocks-ui-kit/icons",[],function(){var p=O.UiKitIcons;return p&&typeof p.then=="function"?p.then(function(h){return h===void 0?w.then(function(b){return m(b.UiKitIcons)}):m(h)}):p!==void 0?m(p):w.then(function(h){var b=h.UiKitIcons;return m(b)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var yp=new Function("url","return import(url)");function Ep(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function As(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function ml(e){return e.type==="umd"||e.resolve==="registry"}var wp="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function Sp(e){const t=Array.isArray(e)?e[0]:e;return As(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Ip(e,t){const n=Sp(e),r=As(e)?e:void 0,o=t instanceof Error?t.message:String(t),s=r&&ml(r)&&!/compat/iu.test(o)?` ${wp}`:"",i=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${s}`);return i.cause=t,{name:n,url:r?.url,error:i}}function Ap(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var Tp=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(As(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(ml(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await yp(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let o;const s=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):Ap(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},i=()=>window.removeEventListener("error",s);window.addEventListener("error",s),r.onload=()=>{if(i(),o){n(o);return}t()},r.onerror=()=>{i(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const o=await this._resolveOrSkip(r);if(!o)continue;const s=this._createOrSkip(o.ctor,o.options);s&&!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 i of e){const a=await this._resolveOrSkip(i);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((i,a)=>{t.has(a)||r.push({key:a,plugin:i})});for(let i=r.length-1;i>=0;i--){const{key:a,plugin:c}=r[i];await this._initializingPlugins.get(c),await this._disposePlugin(c,c.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(c),this._resolveMap.delete(c),this._initializingPlugins.delete(c),this._initializedPlugins.delete(c);const l=this._creationOrder.indexOf(c);l>=0&&this._creationOrder.splice(l,1)}const o=[],s=new Set;for(const{ctor:i,options:a}of n){const c=this._createOrSkip(i,a);c&&!s.has(c)&&(s.add(c),o.push(c))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let s,i=!1;const a=()=>{i||(i=!0,s&&clearTimeout(s),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(s=setTimeout(()=>{i||(i=!0,this._pluginRegistry.off(e,a),o(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),o=this._createPluginInstance(e,r),s=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:s}),o.required?.(),this._map.set(n,o),this._creationOrder.push(o),this._setupReadyPromise(o)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Ip(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return Ep(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const o of t){if(this._initializedPlugins.has(o))continue;const s=this._initializingPlugins.get(o);if(s){n.add(s);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const s of r)this._initializingPlugins.set(s,o);n.add(o),o.finally(()=>{for(const s of r)this._initializingPlugins.get(s)===o&&this._initializingPlugins.delete(s)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const o=this._options.openEarlyWindow?.();try{await this._callSync(n,r,"init"),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(s){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:s})}finally{o?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await this._callSync(n,r,"afterInit"),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(o){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:o})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}_callSync(e,t,n){this._emitLifecycle({type:`${n}:enter`,plugin:e,name:t});try{return e[n]?.()}finally{this._emitLifecycle({type:`${n}:leave`,plugin:e,name:t})}}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)}))}},Cp=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const o of n)try{o.callback(t)}catch{}const r=n.filter(o=>!o.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(o=>(t.ctor=o,t.loading=void 0,this._notifyListeners(e,o),o));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!1};return r.push(o),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!0};return r.push(o),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(o=>o.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Op=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()}},Ci=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 Pp(e,t){return t+e}function Rp(){return typeof performance>"u"?Date.now():Pp(performance.now(),performance.timeOrigin)}var Dp="emailmaker:diagnostics",kp="diagnostics",xp="diagnostics";function Oi(e,t){return t?`${e}${e.includes("?")?"&":"?"}${xp}=1`:e}var Qr;function Lp(){try{const e=new URLSearchParams(window.location.search).get(kp);return e===null?void 0:e!=="0"}catch{return}}function Np(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Mp(){try{const e=window.localStorage.getItem(Dp);return e===null?void 0:e==="1"}catch{return}}function bn(){return Qr===void 0&&(Qr=typeof window>"u"?!1:Lp()??Np()??Mp()??!1),Qr}function Fp(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var we={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"},N0=Object.values(we),M0=[we.canvasPainted,we.canvasSettled,we.appVisible,we.editorVisible],Bp=5e3,jp=3e3,Pi="diagnosticsStore",Un,Yt;function Ri(){return{marks:new Ci(Bp),resources:new Ci(jp)}}function gl(){if(Yt)return Yt;const e=Ts();return e?(Yt=e[Pi]??Un??Ri(),e[Pi]=Yt,Un=void 0,Yt):(Un??=Ri(),Un)}function ce(e,t){bn()&&gl().marks.push({phase:e,at:Rp(),...t})}function Ts(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[Fp()];return e!==null&&typeof e=="object"?e:void 0}function Up(e){const t=e.length,n=gl();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function $p(){const e=Ts();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Up(e.diagnosticsBuffer)}var Hp="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Be(){const e=new Error(Hp);return e.name="DestroyedInstanceError",e}function Vp(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function No(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 s=e,i=t;return s.length===i.length&&s.every((a,c)=>No(a,i[c]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&No(e[s],t[s]))}function vl(e,t){const n={watch(r){let o,s=!1;return e.watch(i=>{const a=t(i);s&&No(o,a)||(o=a,s=!0,r(a))})},select(r){return vl(n,r)}};return n}function ae(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(s){t=s,n=!0;for(const i of Array.from(r))i(s)},watch(s){return r.add(s),n&&s(t),{dispose:()=>r.delete(s)}},select(s){return vl(o,s)}};return o}function Gp(e,t=window){return{peer:e,send(n){e.postMessage(n,"*")},subscribe(n){const r=o=>{n({data:o.data,source:o.source,ports:o.ports})};return t.addEventListener("message",r),{dispose:()=>t.removeEventListener("message",r)}},close(){}}}function qp(e){let t=!1;return{peer:e,send(n){e.postMessage(n)},subscribe(n){const r=o=>{n({data:o.data,source:e})};return e.addEventListener("message",r),t||(t=!0,e.start()),{dispose:()=>e.removeEventListener("message",r)}},close(){e.close()}}}function Wp(e){return e&&typeof e=="object"}function Di(e,t){return e&&typeof e=="object"&&e.operationId===t}var He="INIT_MESSAGE",zp="em:port-ready",Kp="em:window-drained",sr="";function ki(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var Xp=class extends de{_listeners=Object.create(null);addListenerAsync=(e,t,n=0,r)=>{const o=this._listeners[e]||(this._listeners[e]=[]);r&&typeof t=="function"&&(t=t.bind(r));const s=o.findIndex(([a,c])=>n<=c),i=[t,n];return this.isDisposed()||o.splice(s>=0?s:o.length,0,i),{dispose(){const a=o.indexOf(i);a>=0&&o.splice(a,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const n=this._listeners[e]||(this._listeners[e]=[]);let r;for(let o=0;o<n.length;o++){const s=n[o][0],i=r;r=a=>s(a,i)}if(r)return r(t)}};addListener=(e,t,n=0)=>this.addListenerAsync(e,(r,o)=>{try{t(r)}catch{}return o&&o(r)},n)},Pn=class extends de{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_portSendHeld=new WeakSet;_inited=!1;_emitter=this.addDisposable(new Xp);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;_outgoingObservers=new Set;_offTargetListeners=new Map;constructor(e,t){super(),this._singleton=t,this._transport=Gp({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(He,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(He))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,n=t.data,r=t.source,o=n?.port===!0?t.ports?.[0]:void 0,s=!this._isPortSource(t.source);if(s&&r&&n?.operationId==="em:window-drained"){this._ports.has(r)&&this._drained.add(r);return}if(s&&r&&this._drained.has(r))return;if(r&&r!==this._target&&this._greeted.has(r)&&Di(n,He)){this._greeted.delete(r),this._handshaken.add(r),this._postMessage(r,{operationId:He,data:{}}),o&&this.usePort(o,!0,r);return}const i=t.source===this.target||this._isCurrentPort(t.source);if(i||this._notifyOffTarget(n?.operationId,t.source),Wp(n)&&i||this._singleton&&Di(n,He)){if(o&&i){const u=this._target;Promise.resolve().then(()=>this.usePort(o,!0,u))}const a=this._emitter.fireAsync(n.operationId||sr,n.operationId===void 0?t:n.data),c=n.result,l=n.error;c&&l&&Promise.resolve(a).then(u=>this._sendMessage(c,u),u=>this._sendMessage(l,u))}};setTarget(e){if(this._target!==e){if(this._target=e,!e){this._inited=!1;return}if(this._handshaken.has(e)){this._inited=!0,this._emitter.fireAsync(He,void 0);return}this._inited=!1,this._postMessage(e,{operationId:He,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:He,data:{},port:!0},[t])}observeOutgoing(e){return this._outgoingObservers.add(e),{dispose:()=>{this._outgoingObservers.delete(e)}}}_notifyOutgoing(e,t){for(const n of Array.from(this._outgoingObservers))try{n(e,t)}catch{}}addOffTargetListener(e,t){let n=this._offTargetListeners.get(e);return n||(n=new Set,this._offTargetListeners.set(e,n)),n.add(t),{dispose:()=>{n.delete(t)}}}_notifyOffTarget(e,t){const n=typeof e=="string"?this._offTargetListeners.get(e):void 0,r=n?.size?this._knownPeer(t):void 0;if(!(!n||!r))for(const o of Array.from(n))try{o(r)}catch{}}_knownPeer(e){for(const[n,r]of this._ports)if(r.transport.peer===e)return n;const t=e;return typeof e=="object"&&e!==null&&(this._handshaken.has(t)||this._greeted.has(t))?t:void 0}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}sendNow(e){const t=this._target;return!this._inited||!t?!1:(this._postMessage(t,e),!0)}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:He,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,n=this._target){if(!n||this._ports.has(n))return;const r=qp(e),o=r.subscribe(this._onTransportMessage);this._ports.set(n,{transport:r,subscription:o}),t&&(r.send({operationId:zp,data:{}}),this.drainWindow(n))}holdPort(e=this._target){!e||!this._ports.has(e)||(this._portSendHeld.add(e),this._drained.delete(e))}resumePort(e=this._target){e&&this._portSendHeld.delete(e)}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)&&!this._portSendHeld.has(this._target)}hasPort(e,t){const n=this._ports.get(e);return n!==void 0&&(t===void 0||n.transport.peer===t)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e),this._portSendHeld.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:Kp,data:{}},"*")}isWindowDrained(e){return this._drained.has(e)}_isPortSource(e){for(const t of this._ports.values())if(t.transport.peer===e)return!0;return!1}_isCurrentPort(e){return this._target!==void 0&&this._ports.get(this._target)?.transport.peer===e}getTarget(){return this._target}get target(){return this._target}_postMessage(e,t,n){let r=t;this._outgoingFilter&&!n?.length&&(r="data"in t?{...t,data:this._outgoingFilter(t.data)}:this._outgoingFilter(t));try{const o=this._ports.get(e);if(o&&!this._portSendHeld.has(e)){o.transport.send(r);return}if(n?.length){e.postMessage(r,"*",n);return}e.postMessage(r,"*")}catch(o){if(o?.name==="DataCloneError"){const s=typeof r?.data=="object"&&r?.data!==null?r.data:void 0}throw o}}_sendMessage(e,t,n=!0){if(!n&&!this.isInited())return;e&&this._notifyOutgoing(e,t);const r=this.addDisposable(this.onInit(o=>{const s=e?{operationId:e,data:t}:t;try{this._postMessage(o,{...s})}finally{r.dispose()}}))}send(e,t,n){return typeof e=="string"?this._sendMessage(e,t,n):this._sendMessage(sr,e,t)}sendAsync(e,t,n=!0){if(!n&&!this.isInited())return Promise.resolve();this._notifyOutgoing(e,t);const r=ki(),o=ki();return new Promise((s,i)=>{const a=this.addDisposable(new de);a.addDisposable(this.onInit(c=>{try{this._postMessage(c,{operationId:e,data:t,result:r,error:o})}catch(l){a.dispose(),i(l);return}a.addDisposable(this._onMessage(r,l=>{s(l),a.dispose()})),a.addDisposable(this._onMessage(o,l=>{i(l),a.dispose()}))}))})}_onMessage(e,t,n=0){return this._emitter.addListener(e,t,n)}addListener(e,t,n){return t?this._onMessage(e,t,n):this._onMessage(sr,e)}addListenerAsyncPipe(e,t,n=0){return this._emitter.addListenerAsync(e,t,n)}addListenerAsync(e,t,n=0){return this._emitter.addListenerAsync(e,async(r,o)=>{const s=await t(r);return o?o(r):s},n)}isInited(){return this._inited}get inited(){return this._inited}onInit(e,t=!0,n=0){const r=this.addDisposable(new de);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?r.addDisposable(this.onInit(e,t,n)):e(this._target)}):r.addDisposable(this._onMessage(He,()=>{e(this._target)},n)),r}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function Rn(e){return B(e)}var $n=B("extensions.atomsHandlers"),Yp=Rn("HANDLE_ATOM_INSERT"),Jp=B("HeadlessMode"),Dt=B("extensions.sandboxExtensions"),Cs="SANDBOX_EXTENSION_SCRIPT_STATUS",Dn=B("MESSAGE_SERVICE"),xi=Rn("SETTINGS_PANEL_EVENT"),Qp="advanced",Zp=Rn("MODAL_SHOW_EVENT"),eh=Rn("MODAL_CLOSE_EVENT"),th=Rn("MODAL_UPDATE_EVENT"),F0=B("client"),B0=B("v2_client"),j0=B("ai_client"),_l=B("app.cookieManager"),U0=B("app.storageProvider"),$0=B("image-blob-resolver"),Os=B("template-directives"),nh=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),rh=class{baseUrl="https://api.emailmaker.ru/wp-json";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,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":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))};async request({body:e,secure:t,path:n,type:r,query:o,format:s,baseUrl:i,cancelToken:a,extraQuery:c,proxyHandler:l,...u}){const d=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},f=this.mergeRequestParams(u,d);c&&(o=o?{...o,...c}:c);const v=o&&this.toQueryString(o),g=this.contentFormatters[r||"application/json"],y=s||f.format,E=`${i||this.baseUrl||""}${n}${v?`?${v}`:""}`,P=l?l(E,{body:e,secure:t,path:n,type:r,query:o,format:s,baseUrl:i,cancelToken:a,extraQuery:c,proxyHandler:l,...u}):E,O=new Request(P,{...f,headers:{...f.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):f.signal)||null,body:typeof e>"u"||e===null?null:g(e)});return this.customFetch(O).then(async x=>{const w=x;w.data=null,w.error=null,w.meta={request:O,response:w};const C=y?await x[y]().then(T=>(w.ok?w.data=T:w.error={data:T},w)).catch(T=>(w.error=T,w)):w;return a&&this.abortControllers.delete(a),C})}},oh=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:nh.UrlEncoded,...t})},bl=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})},sh=B("prewarm.networkActivity");function ih(){let e=0;const t=new Set,n=()=>{t.forEach(r=>r())};return{begin(){e+=1,n();let r=!1;return()=>{r||(r=!0,e-=1,n())}},inFlight:()=>e,watch(r){return t.add(r),()=>t.delete(r)}}}function ah(e){return e.getOrCreateInstance(sh,()=>ih())}var yl=Symbol("rest.publicRequest"),wt=B("rest.requestHandler"),ch=B("rest.responseHandler"),Ps=B("rest.customFetch"),lh=(e,t)=>fetch(e,t),Rs=B("rest_transport"),uh=e=>{e.inject(Ps,{execute:async(t,n={})=>{const r=e.getServices(wt),o={public:n[yl]===!0},s=ah(e).begin();try{let i=t instanceof Request?t:new Request(t,n);for(const l of r){const u=await l.execute(i,o);u instanceof Request&&(i=u)}let a=await fetch(i);const c=e.getServices(ch);for(const l of c)a=await l.execute(a,i);return a}finally{s()}}})};function El(e,t){const n=e.getInstance(Rs);if(!n)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(r=>new r(n)))}var wl="INJECTION";function Sl(e){return e.getState}function dh(e){if(Sl(e)){const t=e.getState()[wl];return t&&Ge.getOrCreateInstance(t,()=>Ge.createChild())}else return e}function fh(e){if(!Sl(e)){e.dispose();return}const t=e.getState()[wl];t&&(Ge.getInstance(t)?.dispose(),Ge.remove(t))}function ph(e,t){for(const n of e)if(n&&t in n)return n[t]}function Ds(e){return Object.assign({},...e)}var Il=["generic","stockImages","emFiles","cdn"];function ks(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Li(e){return!ks(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Il.includes(t))}function Al(e){return e.length===0?[]:e.length===1?e[0]:e}function Tl(e){let t=!1,n=[];for(const r of e)if(r!==void 0){if(t=!0,Array.isArray(r)){n=[...r,...n];continue}n=[r,...n]}if(t)return Al(n)}function hh(e){return ks(e)&&("value"in e||"replace"in e)}function Ni(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function mh(e){let t=!1,n=[],r=!1;for(const s of e)if(s!==void 0){if(hh(s)){t=!0,s.replace&&(n=[],r=!0),s.value!==void 0&&(n=Ni(n,s.value),r=!0);continue}n=Ni(n,s),r=!0}const o=r?Al(n):void 0;if(!t)return o;if(o!==void 0)return{value:o}}function gh(e){const t=e.filter(r=>r!==void 0);if(t.length===0)return;if(!t.some(r=>Li(r)))return Tl(t);const n={};for(const r of Il){const o=mh(e.map(s=>{if(s!==void 0)return Li(s)?s[r]:r==="generic"?s:void 0}));o!==void 0&&(n[r]=o)}return Object.keys(n).length>0?n:void 0}function vh(e){return Tl(e)}function _h(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(ks(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function bh(e,t){const n=[...e],r=new Set(n.map(o=>o.toLowerCase()));for(const o of t){const s=o.trim().replace(/:\d+$/,"");if(!s)continue;const i=s.toLowerCase();r.has(i)||(r.add(i),n.push(s))}return n}function yh(e){let t=[],n=!1;for(const r of e){const o=_h(r);o&&(n=!0,o.replace&&(t=[]),t=bh(t,o.hosts))}return n?t:void 0}function Eh(e){const t=e.filter(o=>o!==void 0);if(t.length===0)return;const n=Ds(t.map(({directHosts:o,...s})=>s)),r=yh(t.map(o=>o?.directHosts));return r!==void 0&&(n.directHosts=r),n}function xs(e){return e?.backendProxy}function un(e){return e.replace(/\/$/,"")}function Cl(e){return/^https?:\/\//i.test(e)}function Ol(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function wh(e){const t=new Set;return e.filter(n=>!n.url||t.has(n.url)?!1:(t.add(n.url),!0))}function Sh(e){const t=xs(e);return t?[t]:[]}function Ih(e){return{proxyEmFiles:!0,proxyAi:!1}}function Ah(e,t){const n=Ih(t),r=t?.backendProxyPolicy;switch(e){case"emFiles":return r?.proxyEmFiles??n.proxyEmFiles;case"ai":return r?.proxyAi??n.proxyAi;default:return!0}}var Th={url:".+",url_encoded:".+",origin:"https?:\\/\\/[^\\/?#]+",origin_encoded:".+",proxy_url:"https?:\\/\\/[^\\/?#]+",proxy_url_encoded:".+",path:"[^?#]*",pathname:"[^?#]*",path_with_slash:"\\/[^?#]*",pathname_with_slash:"\\/[^?#]*",query:"[^#]*",search:"\\?[^#]*",hash:"#.*",fragment:".*",pathname_after_wp_json:"[^?#]*",pathname_after_wp_json_with_slash:"\\/[^?#]*",rest_namespace:"[^/?#]*",rest_version:"[^/?#]*",rest_route:"[^?#]*",rest_route_with_slash:"\\/[^?#]*"};function Ch(e){const t=[],n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(r,o)=>(t.push(o),`(${Th[o]||".+"})`));return{regex:new RegExp(`^${n}$`,"i"),tokens:t}}function Oh(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function Ph(e,t){if(Oh(t))return e;try{const n=new URL(e);return`${n.origin}${n.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function Rh(e,t,n){if(n.endsWith("_encoded"))return!0;const r=e.slice(0,t),o=r.lastIndexOf("#"),s=r.lastIndexOf("?"),i=r.lastIndexOf("&"),a=r.lastIndexOf("=");return a>Math.max(s,i)&&a>o}function Dh(e){try{const t=new URL(e),n=t.pathname.replace(/^\/+/,""),r=t.search.replace(/^\?/,""),o=t.hash.replace(/^#/,""),s=n.replace(/^wp-json\/?/i,""),i=s?`/${s}`:"/",a=s.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),c=a?.[1]||"",l=a?.[2]||"",u=a?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:n,pathname:n,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:r,search:t.search,hash:t.hash,fragment:o,pathname_after_wp_json:s,pathname_after_wp_json_with_slash:i,rest_namespace:c,rest_version:l,rest_route:u,rest_route_with_slash:u?`/${u}`:"/"}}catch{return}}function Ls(e,t){if(!e)return{};if(Array.isArray(e)){for(const a of e){const c=Ls(a,t);if(c!==void 0)return c}return}if(e==="*")return{};const n=Ph(t,e),{regex:r,tokens:o}=Ch(e),s=r.exec(n);if(!s)return;const i={};return o.forEach((a,c)=>{i[`matched_${a}`]=s[c+1]||""}),i}function Hn(e,t,n={}){const r=Dh(t);if(!r)return t;const o={...r,...n};let s="",i=0;const a=/\{([a-z_]+)\}/gi;let c;for(;c=a.exec(e);){s+=e.slice(i,c.index);const l=o[c[1]]??"",u=Rh(e,c.index,c[1])?encodeURIComponent(l):l;s+=u,i=c.index+c[0].length}s+=e.slice(i);try{const l=new URL(s),u=new URL(t);return!s.includes("{search}")&&!s.includes("{query}")&&u.search&&u.searchParams.forEach((d,f)=>{l.searchParams.has(f)||l.searchParams.append(f,d)}),!s.includes("{hash}")&&!s.includes("{fragment}")&&u.hash&&!l.hash&&(l.hash=u.hash),l.toString()}catch{return s}}function Mi(e,t){try{const n=new URL(t);return`${un(e)}/${n.pathname.replace(/^\//,"")}${n.search}${n.hash}`}catch{return t}}function Fi(e,t){const n=un(e);return t?Cl(t)?t:t.startsWith("?")||t.startsWith("#")?`${n}${t}`:`${n}${t.startsWith("/")?"":"/"}${t}`:n}function Pl(e,t,n,r){const o=e.match;return o?Array.isArray(o)?o.some(s=>Pl({...e,match:s},t,n,r)):typeof o=="function"?!!o({url:t,method:r,requestType:n}):o==="*"?!0:Ls(o,t)!==void 0:!0}function kh(e,t,n,r="generic"){if(e==null)return[];const o=Array.isArray(e)?e:[e],s=[];return o.forEach((i,a)=>{if(!i)return;if(typeof i=="string"){const d=i.includes("{")&&i.includes("}")?Hn(i,t):Mi(i,t);s.push({key:`backend:${a}`,url:d,source:"resource"});return}if(!Ol(i)||!("rewrite"in i))return;const c=i;if(!Pl(c,t,r,n))return;const l=typeof c.match=="string"||Array.isArray(c.match)?Ls(c.match,t)||{}:{},u=typeof c.proxyBase=="string"&&c.proxyBase.trim()?c.proxyBase.trim():void 0;(Array.isArray(c.rewrite)?c.rewrite:[c.rewrite]).filter(Boolean).forEach((d,f)=>{const v=typeof d=="function"?(()=>{const g=d({url:t,proxyBase:u,method:n,requestType:r,...l}),y=u&&!Cl(g)?Fi(u,g):g;return y.includes("{")&&y.includes("}")?Hn(y,t,l):y})():u?Hn(Fi(u,d),t,l):d.includes("{")&&d.includes("}")?Hn(d,t,l):Mi(d,t);s.push({key:`backend:${c.id||"rule"}:${a}:${f}`,url:v,source:"resource"})})}),wh(s)}function xh(e){try{const t=new URL(e);return/(?:^|\/)wp-json\/em-files\/v\d+(?:\/|$)/i.test(t.pathname)?"emFiles":/(?:^|\/)wp-json\/ai-generator\/v\d+(?:\/|$)/i.test(t.pathname)?"ai":"generic"}catch{return"generic"}}function Lh(e,t=[]){return e==null||(Array.isArray(e)?e:[e]).forEach(n=>{if(n){if(typeof n=="string"){const r=n.split("{")[0]?.trim();r&&t.push(un(r));return}!Ol(n)||!("rewrite"in n)||(typeof n.proxyBase=="string"&&n.proxyBase.trim()&&t.push(un(n.proxyBase.trim())),(Array.isArray(n.rewrite)?n.rewrite:[n.rewrite]).forEach(r=>{if(typeof r!="string")return;const o=r.split("{")[0]?.trim();o&&t.push(un(o))}))}}),t}function Nh(e,t){return Sh(t).flatMap(n=>Lh(n)).filter(Boolean).some(n=>n&&e.startsWith(n))}function Mh(e,t){return!!xs(t)&&Ah(e,t)}function Fh(e,t={}){const n=t.requestType||xh(e);return Mh(n,t.config)?kh(xs(t.config),e,t.method,n):[]}function Bh(e,t={}){return Nh(e,t.config)?[e]:Fh(e,t).map(n=>n.url)}function qt(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function Pr(...e){const t=e.filter(s=>s!=null);if(t.length===0)return;if(t.length===1)return t[0];const n=t.find(s=>s.aborted);if(n)return n;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const r=new AbortController,o=s=>{r.signal.aborted||r.abort(s.reason)};for(const s of t)s.addEventListener("abort",()=>o(s),{once:!0});return r.signal}var Bi=3e5,ji=15e3,Ie=null,Ui=!1;function jh(){return!0}function Uh(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return Bi;const t=Number(e);return Number.isFinite(t)&&t>0?t:Bi}function $h(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return ji;const t=Number(e);return Number.isFinite(t)&&t>0?t:ji}function Hh(){const e="https://app.useblocks.io/api".trim();return e?qt(e):void 0}function Vh(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const n=JSON.parse(t);if(!Array.isArray(n))throw new Error("expected JSON array");return n.map(r=>String(r).trim()).filter(Boolean)}catch{return Ui||(Ui=!0),[]}return t.split(",").map(n=>n.trim()).filter(Boolean)}function Gh(e){const t=new Set,n=[];for(const r of e){const o=qt(r);t.has(o)||(t.add(o),n.push(o))}return n}function Rl(e){const t=String(e||"").trim();return t?qt(t):Hh()}function Dl(e,t=[]){return e?Gh([e,...t]).slice(0,3):[]}function kl(){return Vh(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function qh(e=Date.now()){return Ie?e-Ie.switchedAt>=Uh():!0}function xl(e=Date.now()){Ie&&qh(e)&&(Ie=null)}function Mt(e){if(!jh())return!1;const t=Rl(e);if(!t)return!1;const n=kl();return n.length===0?!1:Dl(t,n).length>1}function kn(e){const t=Rl(e);if(!t)return[];const n=kl();return n.length===0?[t]:Dl(t,n)}function yn(e){const t=kn(e);if(t.length===0)return"";if(xl(),Ie){const n=t.indexOf(Ie.activeUrl);if(n>=0)return t[n]}return t[0]}function Ll(e){const t=kn(e);if(t.length<=1||(xl(),!Ie||!t.includes(Ie.activeUrl)))return t;const n=Ie.activeUrl;return[n,...t.filter(r=>r!==n)]}function Nl(e){return yn(e)||void 0}function Ml(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const n=$h(),r=new AbortController;let o;const s=setTimeout(()=>{o=Wh(n),r.abort(o)},n);return{signal:Pr(t,r.signal),timeoutError:()=>o,done:()=>clearTimeout(s)}}function Wh(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const n=new Error(t);return n.name="TimeoutError",n}function Fl(e){return e===502||e===503||e===504}function Bl(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var jl;function zh(e){jl=e}function pr(e,t){if(!Mt(t))return;const n=kn(t);if(n.length<=1)return;const r=n.indexOf(qt(e));if(r<0)return;const o=r+1;if(o>=n.length)return;const s=n[o],i=Ie?.activeUrl;Ie={activeUrl:s,switchedAt:Date.now()},i!==s&&jl?.()}function Ul(e,t){if(!Mt(t))return;const n=qt(e),r=kn(t);if(r.includes(n)){if(n===r[0]){Ie=null;return}Ie?.activeUrl!==n&&(Ie={activeUrl:n,switchedAt:Date.now()})}}function $l(){Ie=null}var Kh=e=>{const t=new FormData,n=(r,o,s)=>{if(o!=null){if(o instanceof Blob){r.append(s,o);return}if(Array.isArray(o)){o.forEach((i,a)=>{const c=s?`${s}[${a}]`:`${a}`;n(r,i,c)});return}if(typeof o=="object"){Object.keys(o).forEach(i=>{const a=o[i],c=s?`${s}[${i}]`:i;n(r,a,c)});return}r.append(s,String(o))}};return n(t,e),t},Xh={baseUrl:qt("https://app.useblocks.io/api"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},St=new Map;function Yh(e){const t=e?.getInstance(he);return t?t.get()??t.bootstrap():void 0}var Jh=class extends rh{container;constructor(e={},t){super(e),this.container=t}buildRequestUrl(e){const{path:t,baseUrl:n,extraQuery:r}=e;let{query:o}=e;r&&(o=o?{...o,...r}:r);const s=o&&this.toQueryString(o);return`${n||this.baseUrl||""}${t}${s?`?${s}`:""}`}buildRequestKey(e,t){return`${t.toUpperCase()} ${e}`}getBackendProxyCandidates(e,t){const n=Yh(this.container),r=this.container?.getInstance(je)!==void 0,o=Bh(e,{config:n,method:t,standalone:r}),s=o.length>0?o:[e],i=this.buildRequestKey(e,t),a=St.get(i);return!a||!s.includes(a)?s:[a,...s.filter(c=>c!==a)]}shouldRetryResponse(e){return e.status===502||e.status===503||e.status===504}resolveFailoverBaseUrl(){return String(this.baseUrl||"").trim()||void 0}async requestOnOrigin(e,t,n=!1){const r={...e,baseUrl:t},o=this.buildRequestUrl(r),s=r.method||"GET",i=this.buildRequestKey(o,s),a=this.getBackendProxyCandidates(o,s);let c,l;for(const u of a){const d=v=>v===o?u:v,f=n?Ml(e.signal):void 0;try{const v=await super.request({...r,proxyHandler:d,...f?{signal:f.signal}:{}});if(!v.ok&&this.shouldRetryResponse(v)&&u!==a[a.length-1]){l=v,St.get(i)===u&&St.delete(i);continue}return St.set(i,u),v}catch(v){St.get(i)===u&&St.delete(i);const g=f?.timeoutError();if(g)throw g;if(c=v,(v instanceof DOMException||v instanceof Error)&&v.name==="AbortError")throw v}finally{f?.done()}}if(l)return l;throw c instanceof Error?c:new Error("Backend proxy chain failed")}async request(e){const t=String(e.baseUrl||"").trim();if(t)return this.requestOnOrigin(e,t);const n=this.resolveFailoverBaseUrl(),r=Mt(n),o=e.failoverAttemptTimeout??r,s=r?Ll(n):n?[yn(n)]:[this.baseUrl].filter(Boolean);if(s.length===0)return this.requestOnOrigin(e,this.baseUrl);let i,a;for(let c=0;c<s.length;c++){const l=s[c],u=c===s.length-1;try{const d=await this.requestOnOrigin(e,l,o);if(!d.ok&&Fl(d.status)){if(a=d,!u){pr(l,n);continue}break}return d.ok&&Ul(l,n),d}catch(d){if(!Bl(d))throw d;i=d,u||pr(l,n)}}if(r&&$l(),a)return a;throw i instanceof Error?i:new Error("API origin failover chain failed")}};function Qh(e={},t){const n=new Jh({...Xh,...e},t);return n.contentFormatters["multipart/form-data"]=Kh,n}var Hl=B("rest.clientFactory"),Zh=e=>{uh(e);const t=Qh({customFetch:e.getInstance(Ps)?.execute??lh},e);e.inject(Rs,t)},$i;(function(e){const t="https://racs.rest/v3";function n(o,s){const i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(s)};return fetch(`${t}?resource=${o}&dataset=${document.location.hostname}`,i)}e.post=n;async function r(o,s=0){const i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:`{"filter":{},"limit":${s}}`};return await(await fetch(`${t}/get?resource=${o}&dataset=${document.location.hostname}`,i)).json()}e.getAll=r})($i||($i={}));function em(e){return String(e||"").trim()||void 0}var tm=class extends de{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=em(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)}},Ns=B("AppInitService");function nm(e){return async()=>{const t=await e();return(await new oh(t).app_init_create({})).data}}function rm(e){e.injectFactory(Ns,(t,n)=>{if(n)return n;const r=new tm({options:e.getInstance(_e),isStandalone:()=>!!e.getInstance(je),resolveRestBaseUrl:o=>o?yn(o):yn()||void 0,setRestBaseUrl:o=>{e.getInstance(Hl)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:nm(()=>e.getInstanceAsync(Rs)),publish:o=>{e.inject(Ke,o)}});return e.getInstance(K)?.addDisposable(r),r},!0)}function Ae(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e),r=Array.isArray(t);if(n){if(!r)return!1;const a=e.length;if(t.length!==a)return!1;for(let c=0;c<a;c++)if(!Ae(e[c],t[c]))return!1}else if(r)return!1;const o=Object.keys(e),s=Object.keys(t),i=o.length;if(i!==s.length)return!1;for(let a=0;a<i;a++){const c=o[a];if(!t.hasOwnProperty(c)||!Ae(e[c],t[c]))return!1}}return!0}var om=B("plugin.optionsApplications");function sm(){const e=new Error("Options application was superseded by a newer one.");return e.name="AbortError",e}function im(e){const t=new AbortController,n=[],r=new Map;let o,s,i,a=!1,c=!1,l=!1;const u=new Set,d=x=>{for(const w of Array.from(u))w(x);u.clear()},f=x=>{let w=r.get(x);if(!w){let C;w={promise:new Promise(T=>{C=T}),resolve:C,reached:!1,actions:[]},r.set(x,w)}return w},v=async()=>{await Promise.resolve();let x=0;for(;x<n.length;){const w=n.slice(x);x=n.length,await Promise.allSettled(w)}},g=x=>{t.signal.aborted||c||(a=!0,t.abort(x),s?.(x),i?.(x))},y=v(),E=new Promise((x,w)=>{i=w,y.then(()=>{a||x()})});E.catch(()=>{});const P=new Promise((x,w)=>{o=C=>{C.done.then(x,w)},s=w,y.then(()=>{t.signal.aborted||(c=!0,x())})});P.then(()=>e(O),()=>e(O));const O={signal:t.signal,get failed(){return a},done:P,settled:y,outcome:E,hold(x){const w=x.catch(C=>{if(!t.signal.aborted)return Promise.reject(C);l&&d(C)});w.catch(g),n.push(w)},reach(x){const w=f(x);if(w.reached)return;w.reached=!0,w.resolve();const C=w.actions.splice(0);for(const T of C){if(t.signal.aborted)return;try{T()}catch(D){O.hold(Promise.reject(D))}}},isReached(x){return r.get(x)?.reached??!1},reached(x){const w=t.signal.aborted?Promise.reject(t.signal.reason):new Promise((C,T)=>{const D=()=>T(t.signal.reason);t.signal.addEventListener("abort",D,{once:!0}),f(x).promise.then(()=>{t.signal.removeEventListener("abort",D),C()})});return w.catch(()=>{}),w},passed(x){const w=f(x),C=new Promise((T,D)=>{if(t.signal.aborted&&!l){D(t.signal.reason);return}const R=p=>{u.delete(R),D(p)};u.add(R);const m=()=>{l||R(t.signal.reason)};t.signal.addEventListener("abort",m,{once:!0}),w.promise.then(()=>{u.delete(R),t.signal.removeEventListener("abort",m),T()})});return C.catch(()=>{}),C},whenReached(x,w){if(t.signal.aborted)return;const C=f(x);if(!C.reached){C.actions.push(w);return}try{w()}catch(T){O.hold(Promise.reject(T))}}};return{application:O,supersede(x){l=!0,t.abort(sm()),o?.(x)},fail(x){t.abort(x),s?.(x),d(x)}}}function Hi(e,t,n){try{e(t,n)}catch(r){t.hold(Promise.reject(r))}}function Wt(e){return e.getOrCreateInstance(om,()=>{const t=e.getInstance(K);if(!t)throw new Error("[plugin] provideOptionsApplications: время жизни регистрирует bootstrapEarly — раньше него нельзя");let n;const r=new Set;let o,s=!1;const i=new Set,a=c=>{n?.application===c&&(n=void 0)};return t.addDispose(()=>{s=!0;for(const c of Array.from(r))c.fail(Be());r.clear(),n=void 0}),{begin(c){if(s)throw Be();const l=n,u=im(a);r.add(u),u.application.settled.then(()=>r.delete(u)),n=u,o=c,l?.supersede(u.application);for(const d of Array.from(i))Hi(d,u.application,c);return u.application},current(){return n&&!n.application.signal.aborted?n.application:void 0},each(c){i.add(c);const l=n&&!n.application.signal.aborted?n.application:void 0;return l&&o&&Hi(c,l,o),{dispose:()=>i.delete(c)}}}})}var am=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function cm(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function lm(e,t){const n=[];for(const r of e.awaits?.services??[])for(const o of t.get(r)??[])o!==e&&n.push(o);return n}function Ms(e){const t=cm(e),n=[],r=new Set,o=[],s=new Set,i=a=>{if(!r.has(a)){if(s.has(a)){const c=o.indexOf(a);throw new am([...o.slice(c),a].map(l=>l.name))}s.add(a),o.push(a);for(const c of lm(a,t))i(c);o.pop(),s.delete(a),r.add(a),n.push(a)}};for(const a of e)i(a);return n}var Vi=B("auth.oauthProvided"),Rr="auth.bootstrapTokenDecided",Fs="auth.applied",Gi=new WeakMap;function Vl(e,t){const n=Gi.get(e)??{applied:!1};(!n.applied||n.getAuthToken!==t.getAuthToken||!Ae(n.user,t.user)||n.project!==t.project)&&(Gi.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),hp(e,t.getAuthToken,t.user,t.project))}function um(e){if(e.getInstance(Vi))return;e.inject(Vi,!0);let t;e.getInstance(_e)?.watch(n=>{t=n}),e.addService(wt,{execute:async(n,r)=>{if(r?.public||!t?.getAuthToken)return;e.getInstance(Ti)===void 0&&Vl(e,t);const o=await e.getInstanceAsync(Ti);o&&n.headers.set("authorization",`Bearer ${o}`)}})}function dm(e){const t=Wt(e).each((n,r)=>{n.whenReached(Rr,()=>{Vl(e,r),n.reach(Fs)})});e.getInstance(K)?.addDisposable(t)}function fm(e,t){if(e===t)return;let n=0;const r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;let o=e.length,s=t.length;for(;o>n&&s>n&&e[o-1]===t[s-1];)o--,s--;return{start:n,fromEnd:o,toEnd:s}}function Zr(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return{length:e.length,hash:t>>>0}}var Je={theme:"canvas_fact_theme",flags:"canvas_fact_flags",commonStyles:"canvas_fact_common_styles",lockEditor:"canvas_fact_lock_editor",codeMode:"canvas_fact_code_mode",appName:"canvas_fact_app_name",previewPage:"canvas_fact_preview_page",viewport:"canvas_fact_viewport"},Bs={text:{fontFamily:["Google Fonts","Sans Serif","Mulish","Regular"],fontSize:16,fontSizeDim:"px",lineHeight:24,lineHeightDim:"px",color:"#595959",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Google Fonts","Sans Serif","Mulish","Bold"],fontSize:28,fontSizeDim:"px",lineHeight:34,lineHeightDim:"px",color:"#000000",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},links:{color:"#1890ff",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Google Fonts","Sans Serif","Mulish","Medium"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1890ff",bold:!1,italic:!1,backgroundColor:"#1890ff",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:6,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},textAlign:"center",padding:{all:null,top:null,right:null,bottom:null,left:null}},block:{backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1890ff",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1890ff",contrastTextColor:"#ffffff",baseBackgroundColor:"#f8f8f8",baseTextColor:"#333333",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null}}},Gl="ERROR",pm="useblocks",hm={em_token:"em_access_token",em_refresh_token:"em_refresh_token",em_admin_token:"em_admin_access_token",em_admin_refresh_token:"em_admin_refresh_token",em_impersonation:"em_impersonation",em_elements_view:"em_elements_view",em_new_block:"em_new_block",em_new_email:"em_new_email",em_id:"em_id",em_name:"em_name",em_email:"em_email",em_locale:"em_locale",em_carrotquest_hash:"em_carrotquest_hash",em_ducalis_hash:"em_ducalis_hash",em_email_subscription_consent:"em_email_subscription_consent",em_folder:"em_folder",promocode:"promocode",prm_ref_link_id:"_p_rlid",em_active_tab:"em_active_tab"},Dr={em_color_scheme:"em_color_scheme",em_compress_images:"em_compress_images",em_code_mode_pane_sizes:"em_code_mode_pane_sizes",em_preview_pane_sizes:"em_preview_pane_sizes",em_default_sizes:"em_default_sizes",em_pane_sizes:"em_pane_sizes",em_test_emails:"em_test_emails",em_menu_is_locked:"em_menu_is_locked",em_code_mode_settings:"em_code_mode_settings",em_folder_is_open:"em_folder_is_open",em_active_tab:"em_active_tab",em_ai_settings:"em_ai_settings",em_last_active_page:"em_last_active_page",em_layout_convert_never_suggest:"em_layout_convert_never_suggest",em_filemanager_v2:"em_filemanager_v2",em_projects_v2:"em_projects_v2",em_translations_v2:"em_translations_v2",em_emails_v2:"em_emails_v2",em_checks_v2:"em_checks_v2",em_blocks_v2:"em_blocks_v2",em_revisions_v2:"em_revisions_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_billing_v2:"em_billing_v2",em_guest_locale:"em_guest_locale"},mm="light",gm="dark";var vm="(prefers-color-scheme: dark)",_m=8e3,bm=2e3,ym=15e3,Em=3e3,X={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_EDITOR:"update_editor",UPDATE_EDITOR_POSITION:"update_editor_position",UPDATE_SIDE_MENU_EDITOR:"update_side_menu_editor",SAVE_EMAIL:"saveEmail",SANDBOX_ELEMENT_SETTINGS_SET:"sandbox_element_settings_set",SANDBOX_IMAGE_RESET:"sandbox_image_reset",SANDBOX_NATIVE_IMAGE_DROP_CLEAR:"sandbox_native-image-drop-clear",SANDBOX_EMAIL_SETTINGS_SET:"sandbox_email_settings_set",SANDBOX_BLOCK_SETTINGS_SET:"sandbox_block_settings_set",SANDBOX_ELEMENT_PARENT_GET:"sandbox_element_parent_get",SANDBOX_ELEMENT_PARENT_TABLE_GET:"sandbox_element_parent_table_get",SANDBOX_ELEMENT_PREV_GET:"sandbox_element_prev_get",SANDBOX_ELEMENT_NEXT_GET:"sandbox_element_next_get",SANDBOX_ELEMENT_REMOVE:"sandbox_element_remove",SANDBOX_ELEMENT_ACTIVE_RESET:"sandbox_element_active_reset",SANDBOX_ELEMENT_ACTIVE_SET:"sandbox_element_active_set",SANDBOX_ELEMENT_HOVER_SET:"sandbox_element_hover_set",SANDBOX_ELEMENT_IMG_LINK:"sandbox_element_img_link",SANDBOX_ELEMENT_TEXT:"sandbox_element_text",SANDBOX_EMAIL_CONTENT_GET:"sandbox_email_content_get",SANDBOX_SET_POSITION_TO_IMG:"sandbox_set_position_to_img",SANDBOX_SET_POSITION_TO_LINK:"sandbox_set_position_to_link",SANDBOX_ACCORDION_ADD_SECTION:"sandbox_accordion_add_section",SANDBOX_ACCORDION_REMOVE_SECTION:"sandbox_accordion_remove_section",APPLICATION_FOCUS_IN_IFRAME:"application_focus_in_iframe",APPLICATION_EMAIL_SETTINGS_SET:"application_email_settings_set",APPLICATION_BLOCK_SETTINGS_SET:"application_block_settings_set",APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",_APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",APPLICATION_ELEMENT_SETTINGS_CLOSE:"application_element_settings_close",APPLICATION_ACTION:"application_action",APPLICATION_EBLOCK_ADD:"application_eblock_add",SANDBOX_EBLOCK_SET_EM_BLOCK_ID:"sandbox_eblock_set_em_block_id",SANDBOX_EBLOCK_CLEAR_EM_BLOCK_ID:"sandbox_eblock_clear_em_block_id",SANDBOX_GLOBAL_BLOCK_REPLACE:"sandbox_global_block_replace",APPLICATION_SCROLL_TO:"application_scroll-to",APPLICATION_SCROLL_BLOCK_SHOW:"application_scroll-block-show",APPLICATION_SCROLL_BLOCK_HIDE:"application_scroll-block-hide",APPLICATION_DISCUSS_SET_ID:"application_discuss_set_id",APPLICATION_DISCUSS_GET_COMMENT:"application_discuss_get_comment",APPLICATION_DISCUSS_NO_COMMENT:"application_discuss_no_comment",APPLICATION_DISCUSS_SAVE_TARGET:"application_discuss_save_target",APPLICATION_IFRAME_SET_HEIGHT:"application_iframe_set_height",APPLICATION_COMMON_STYLES_UPDATE:"application_commonStyles_update",APPLICATION_EMAIL_CONTENT_GET:"application_email_content_get",APPLICATION_OPEN_IMAGE_AI_POPUP:"application_open-image-ai-popup",APPLICATION_OPEN_IMAGE_UPLOAD_POPUP:"application_open-image-upload-popup",APPLICATION_OPEN_IMAGE_EDIT_POPUP:"application_open-image-edit-popup",APPLICATION_OPEN_IMAGE_GIF_POPUP:"application_open-image-gif-popup",APPLICATION_OPEN_IMAGE_STOCK_POPUP:"application_open-image-stock-popup",APPLICATION_CLOSE_IMAGE_EDIT_POPUP:"application_close-image-edit-popup",APPLICATION_NATIVE_IMAGE_DROP:"application_native-image-drop",APPLICATION_SUBJECT_UPDATE:"application_subject_update",APPLICATION_PREHEADER_UPDATE:"application_preheader_update",APPLICATION_DOMPARSER_ERROR:"application_domparser_error",APPLICATION_SYNC_DRIFT:"application_sync_drift",APPLICATION_UPDATE_ENTITY:"application_update_entity",APPLICATION_IFRAME_DRAG_EVENT:"application_iframe_drag_event",APPLICATION_HAS_AMP:"application_has_amp",APPLICATION_CANVAS_IMAGE_GET:"application_canvas_image_get",APPLICATION_PREVIEW_ALERT_SHOW:"application_preview_alert_show",APPLICATION_ATOM_INSERTED:"application_atom_inserted",APPLICATION_TEMPLATE_NOT_EM_ALERT_SHOW:"application_template_not_em_alert_show",SANDBOX_IFRAME_SETSIZE:"sandbox_iframe-setsize",SANDBOX_BLOCK_INSERT:"sandbox_block-insert",SANDBOX_ATOM_INSERT:"sandbox_atom-insert",SANDBOX_DRAG_CANCEL:"sandbox_drag-cancel",UPDATE_EDITOR_POSITION_FROM_EDITOR:"update_position_from_editor",UPDATE_EDITOR_POSITION_FROM_IFRAME:"update_position_from_iframe",SANDBOX_CHANGE_PREVIEW:"sandbox_change_preview",APPLICATION_CHANGE_PREVIEW:"application_change_preview",SANDBOX_LOCK_EDIT:"sandbox_lock_edit",SANDBOX_FLOATBLOCK_ADD:"sandbox_floatBlock_add",SANDBOX_FLOATBLOCK_REMOVE:"sandbox_floatBlock_remove",SANDBOX_FLOATBLOCK_COPY:"sandbox_floatBlock_copy",SANDBOX_FLOATBLOCK_SWAP:"sandbox_floatBlock_swap",EDITOR_CHANGE_FOCUS:"editor_change_focus",SANDBOX_RESIZED:"sandbox_resized",SANDBOX_LOCK_DISCUSS:"sandbox_lock_discuss",SANDBOX_DISCUSS_SET_TARGET:"sandbox_discuss_set_target",SANDBOX_DISCUSS_REMOVE_TARGET:"sandbox_discuss_remove_target",SANDBOX_DISCUSS_RESET:"sandbox_discuss_reset",SANDBOX_DISCUSS_GET_TARGET:"sandbox_discuss_get_target",SANDBOX_READY:"SANDBOX_READY",SANDBOX_FLOATBLOCK_WRAP:"sandbox_floatblock_wrap",SANDBOX_FLOATBLOCK_DIR:"sandbox_floatblock_dir",SANDBOX_SUBJECT_UPDATE:"sandbox_subject_update",SANDBOX_PREHEADER_UPDATE:"sandbox_preheader_update",SANDBOX_DRAG_EVENT:"sandbox_drag_event",SANDBOX_WHEEL:"sandbox_wheel",SANDBOX_TRANSLATIONS:"sandbox_send_translations",SANDBOX_SET_THEME_VARIABLES:"sandbox_send_theme_variables",SANDBOX_SET_PROJECT_FONTS:"sandbox_set_project_fonts",SANDBOX_CANVAS_IMAGE_CACHE_SETUP:"sandbox_canvas_image_cache_setup",SANDBOX_SET_ENTITY:"sandbox_set_entity",SANDBOX_INIT_START:"sandbox_init_start",SANDBOX_INITED:"sandbox_inited",SANDBOX_UPDATE_ENTITY:"sandbox_update_entity",RELOAD:"reload",SANDBOX_ADD_EXTENSIONS:"sandbox_add_extensions",SANDBOX_REMOVE_EXTENSIONS:"sandbox_remove_extensions",SANDBOX_ADD_SCRIPT:"sandbox_add_script",SANDBOX_IS_EMAIL_EMPTY:"sandbox_is_email_empty",SANDBOX_SWITCH_THEME:"sandbox_switch_theme",SANDBOX_CANVAS_HEALTH:"sandbox_canvas_health",SANDBOX_CANVAS_SYNCED:"sandbox_canvas_synced",SANDBOX_ELEMENT_OPERATION:"sandbox_element_operation"},wm={language:"html",detectIndentation:!1,wordWrap:"on",wrappingIndent:"same",smoothScrolling:!0,automaticLayout:!0,tabSize:2,indentSize:2},zt=B("documentSession.emailDocuments");function kt(e){return e?.getInstance(zt)}var Sm=B("RevisionServiceFlag");function ql(e){return e.getOrCreateInstance(Sm,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Wl(e){return ql(e).isEnabled()}var zl=B("EmailRightsResolver");function Im(e,t){return e.onInject(n=>{n===zl&&t()})}function Kl(e,t){const n=e.getInstance(zl);return n?n(t):!0}var js={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Xl=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Yl=2e4,Am=Xl.reduce((e,t)=>e+js[t],0),Jl=Yl+Am+3e3;function Tm(e){return Xl.reduce((t,n)=>t+Ql(n,e),0)}function Ql(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:js[e]}function Zl(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Jl}function eu(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Yl}function xn(e=Jl){return e+3e3}function tu(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var Cm=()=>xn();function Om(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function Pm(e){return t=>Om(e.getOrCreateInstance(H.BEFORE_SAVE_EMAIL,()=>new et).fire(t),Cm())}var qi=Symbol.for("emailmaker.saveRefusedError"),Wi=Symbol.for("emailmaker.integratorSaveTimeoutError");function nu(e,t,n,r){return e!==t?Function.prototype[Symbol.hasInstance].call(e,r):typeof r=="object"&&r!==null&&n in r}var ze=class ru extends Error{reason;detail;static[Symbol.hasInstance](t){return nu(this,ru,qi,t)}constructor(t,n){super(n?`[emailmaker] save refused: ${t}: ${n}`:`[emailmaker] save refused: ${t}`),this.name="SaveRefusedError",this.reason=t,this.detail=n,Object.defineProperty(this,qi,{value:!0})}},ou=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[useblocks] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},kr=class su extends Error{timeoutMs;static[Symbol.hasInstance](t){return nu(this,su,Wi,t)}constructor(t,n="handleSaveEmail",r="email"){super(`[useblocks] ${n} did not respond within ${t}ms — the ${r} was not saved`),this.timeoutMs=t,this.name="IntegratorSaveTimeoutError",Object.defineProperty(this,Wi,{value:!0})}};function pe(e){return e.getOrCreateInstance(Dn,()=>new Pn)}var iu=new WeakMap,Mo=new WeakMap;function Ce(e){return iu.get(e)??0}function En(e,t){let n=Mo.get(e);return n||(n=new Set,Mo.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Rm(e){iu.set(e,Ce(e)+1),Mo.get(e)?.forEach(t=>t())}function Fo(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var Dm=B("documentSession.canvasReceipts");function km(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const o={guid:n,version:r};return e=o,()=>{e===o&&(e=void 0)}},note(n,r){const o=Fo(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(o,n)}},read(n){if(!e)return;const{scope:r}=t,o={guid:e.guid,rev:e.version()};return r.originId!==null?{...o,changeId:t.changeId,originId:r.originId}:{...o,changeId:r.generation===n?t.changeId:0}}}}function au(e){return e.getOrCreateInstance(Dm,km)}var xm=2e3,Lm=ym+Em+xm;function Nm(e,t=Lm){return async()=>{const n=pe(e);let r;const o=new Promise(s=>{r=setTimeout(()=>s("silent"),t)});try{const s=au(e).read(Ce(n)),i=await Promise.race([n.sendAsync(X.SANDBOX_CANVAS_SYNCED,s?{applied:s}:void 0,!1),o]);if(i==="silent"||i&&!i.synced)throw i==="silent"||i?.unsent,new ze("canvas-not-synced")}finally{clearTimeout(r)}}}var Mm="em_autosave_pending";function hr(e){return`${Mm}_${e}`}function Bo(e,t){try{return sessionStorage.setItem(hr(e),JSON.stringify(t)),!0}catch{return!1}}function xr(e){try{const t=sessionStorage.getItem(hr(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(hr(e)),null):n}catch{return null}}function lt(e){try{sessionStorage.removeItem(hr(e))}catch{}}function Us(e){return`block:${e}`}function cu(e,t){return t?Us(e):e}function $s(e,t){(xr(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&lt(e)}function Fm(e){return e!=null&&e!==""}function lu(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var zi;function Bm(){return lu(Dr.em_revisions_v2)??!0}function jm(){return zi??=Bm(),zi}function Kt(e){return Wl(e)&&jm()}function Um(){return!1}var uu;function wn(e,t){return uu?.capture(e,t)}function $m(e,t){return uu?.captureMessage(e,t)}var Hm=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Vm=200;function du(e=new Set){const t=new Set;return(n,r)=>{if(!Hm.some(([s,i])=>!e.has(s)&&i.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=Vm&&t.clear(),t.add(o))}}function fu(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:du()}}var Gm=fu();function nt(e){return e?.getInstance(Os)??Gm}function qm(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Vn(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Me=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} "${Vn(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Vn(this.oldText)}")`:`(replace@${this.oldPosition} "${Vn(this.oldText)}" with "${Vn(this.newText)}")`}};function Ki(e,t){return e===null||e.length===0?t:new Wm(e,t).compress()}var Wm=class qe{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[c,l]=qe._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(c),o=l;continue}if(r.newPosition<o.oldPosition){const[c,l]=qe._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(c),r=l;continue}let i,a;if(o.oldEnd===r.newEnd)i=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[c,l]=qe._splitPrev(r,o.oldLength);i=c,a=o,r=l,o=this._getCurr(++n)}else{const[c,l]=qe._splitCurr(o,r.newLength);i=r,a=c,r=this._getPrev(++t),o=l}this._result[this._resultLen++]=new Me(i.oldPosition,i.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const s=qe._merge(this._result);return qe._removeNoOps(s)}_acceptCurr(t){this._result[this._resultLen++]=qe._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++]=qe._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 Me(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Me(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),o=t.newText.substr(n);return[new Me(t.oldPosition,t.oldText,t.newPosition,r),new Me(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new Me(t.oldPosition,r,t.newPosition,t.newText),new Me(t.oldPosition+n,o,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,o=t[0];for(let s=1;s<t.length;s++){const i=t[s];o.oldEnd===i.oldPosition?o=new Me(o.oldPosition,o.oldText+i.oldText,o.newPosition,o.newText+i.newText):(n[r++]=o,o=i)}return n[r++]=o,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let o=0;o<t.length;o++){const s=t[o];s.oldText!==s.newText&&(n[r++]=s)}return n}};function zm(e){return new Me(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Km(e){return e.map(zm)}function Xi(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Xm(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const o=t[r];n=n.slice(0,o.oldPosition)+o.newText+n.slice(o.oldEnd)}return n}function pu(e,t,n){let r=0;const o=e.start===e.end;for(const s of t){const i=s.newLength-s.oldLength;if(s.oldLength===0){const a=s.oldPosition;if(o&&a===e.start)r+=n==="after"?i:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=i)}continue}if(o){if(e.start>=s.oldEnd)r+=i;else if(e.start>s.oldPosition)return null;continue}if(e.start>=s.oldEnd)r+=i;else if(e.end>s.oldPosition)return null}return{start:e.start+r,end:e.end+r}}function Yi(e,t,n){if(!t.length)return[...e];const r=[];let o=0;for(const s of e){const i=pu({start:s.oldPosition,end:s.oldEnd},t,n);if(!i)return null;r.push(new Me(i.start,s.oldText,i.start+o,s.newText)),o+=s.newLength-s.oldLength}return r}var ht=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Ji=0,Ym=Math.random().toString(36).slice(2,8);function Jm(){return Ji+=1,`doc-${Ym}-${Ji}`}function Qm(e){const t=e.createBuffer(),n=e.docId??Jm();let r=e.serverId??null,o=0,s=null,i=e.attributes??{};const a=new Set;let c=!1,l=!1,u;const d=new Set;let f=null;const v=()=>(f?.version!==o&&(f={version:o,value:t.read()}),f.value),g=y=>Object.entries(y).some(([E,P])=>i[E]!==P);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:s,attributes:i}),getContent:v,mutate(y,{source:E}){if(c)return o;const P=y.changes?.length?y.changes:void 0,O=P?Xm(v(),P):y.content!==void 0?y.content:void 0,x=O!==void 0&&O!==v(),w=y.attributes!==void 0&&g(y.attributes);if(!x&&!w)return o;const C=!(o>(s??-1)),T=w?Object.keys(y.attributes).filter(R=>i[R]!==y.attributes[R]):[];x&&t.write(O),w&&(i={...i,...y.attributes}),o+=1,E!=="user"&&C&&(s=o);const D={source:E,version:o,changes:P,...x?{content:!0}:{},...T.length>0?{attributes:T}:{}};return a.forEach(R=>R(D)),o},markSaved(y,E){const P={serverId:r,savedVersion:s};E!==void 0&&(r=E),(s===null||y>s)&&(s=y),(P.serverId!==r||P.savedVersion!==s)&&a.forEach(O=>O({source:"system",version:o}))},markUnsaved(){c||s===null||s<o||(s=o-1,a.forEach(y=>y({source:"system",version:o})))},markReady(){l||u!==void 0||(l=!0,d.forEach(y=>y.resolve()),d.clear(),a.forEach(y=>y({source:"system",version:o})))},isReady:()=>l,markFailed(y){l||u!==void 0||c||(u=y,d.forEach(E=>E.reject(new ht(y))),d.clear(),a.forEach(E=>E({source:"system",version:o})))},failure:()=>u,whenReady(){return l?Promise.resolve():u!==void 0?Promise.reject(new ht(u)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((y,E)=>{d.add({resolve:y,reject:E})})},subscribe(y){return a.add(y),()=>a.delete(y)},isNew:()=>r===null,isDirty:()=>o>(s??-1),isDisposed:()=>c,dispose(){c=!0,d.forEach(y=>y.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),d.clear(),a.clear(),t.dispose()}}}var Zm=500,eg=100,eo=0,Qi=0;function tg(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function hu(e,t,n){let r=0;for(const o of t){if(o.oldPosition>e||o.oldPosition===e&&(o.oldLength>0||!n))break;if(o.oldEnd>e)return o.newEnd;r=o.newEnd-o.oldEnd}return e+r}function jo(e,t){if(!e)return e;if(e.start===e.end){const n=t(e.start,"caret");return{start:n,end:n}}return{start:t(e.start,"start"),end:t(e.end,"end")}}var mu=(e,t)=>t==="old"?e.oldPosition:e.newPosition,gu=(e,t)=>t==="old"?e.oldEnd:e.newEnd;function vu(e,t,n,r){const o=t==="start"?["start","end"]:["end","start"];for(const s of o){const i=r.findIndex(a=>(s==="start"?mu(a,n):gu(a,n))===e);if(i>=0)return{index:i,edge:s}}}function ng(e,t,n){if(!e?.after)return e;const r=(o,s)=>{const i=vu(o,s,"new",n);return hu(o,t,i?i.edge==="start"&&n[i.index].newLength>0:s==="start")};return{...e,after:jo(e.after,r)}}function rg(e,t,n,r,o){const s=(i,a)=>(c,l)=>{const u=vu(c,l,i,t);return u?u.edge==="start"?mu(n[u.index],i):gu(n[u.index],i):hu(c,a,l==="start")};return e&&{before:jo(e.before,s("old",r)),after:jo(e.after,s("new",o))}}function og(e,t={}){const n=t.groupIntervalMs??Zm,r=t.maxSteps??eg,o=t.now??(()=>0);let s=[],i=0,a=eo+=1,c=null,l,u,d,f=!1,v=!1,g=!1,y=0,E=!1,P=!1;const O=new Set,x=()=>O.forEach(S=>S()),w=(S,N)=>{if(S.length){g=!0;try{e.mutate({changes:S},{source:N})}finally{g=!1}}},C=S=>w(S,"user"),T=S=>{const N=l?.from??o(),j=y>0?E:v&&c!==null&&f===(l!==void 0)&&N>=c&&N-c<n;if(y>0&&(E=!0),j){const W=s[i-1];s[i-1]={...W,changes:Ki(W.changes,S),selection:tg(W.selection,u)}}else s=s.slice(0,i),Qi+=1,s.push({id:Qi,below:s[i-1]?.id??0,changes:S,selection:u}),i=s.length,v=!0,s.length>r&&(s=s.slice(s.length-r),i=s.length,a=eo+=1);c=l?.to??N,f=l!==void 0,x()},D=()=>{v=!1,c=null},R=S=>{let N=S;for(let j=i;j<s.length;j+=1){const W=s[j],re=Yi(W.changes,N,"after"),oe=re&&Yi(N,W.changes,"before");if(!re||!oe)return s=s.slice(0,j),!0;s[j]={...W,changes:re,selection:rg(W.selection,W.changes,re,N,oe)},N=oe}return!1},m=S=>{if(!S.length)return;const N=R(S);if(i>0){const j=s[i-1];s[i-1]={...j,changes:Ki(j.changes,S),selection:ng(j.selection,S,j.changes)}}D(),N&&x()},p=e.subscribe(({source:S,changes:N})=>{if(!(P||g||!N?.length)){if(S==="remote"){h();return}if(S!=="user"){m(N);return}T(N)}}),h=()=>{s=[],i=0,E=!1,D(),a=eo+=1,x()},b=(S,N)=>{E=!1,d=N;try{C(S)}finally{d=void 0}},L=(S=!1)=>{if(i===0)return!1;const N=s[i-1],j=Km(N.changes);return Xi(e.getContent(),j)?(b(j,S?{kind:"undo",selection:N.selection?.before}:void 0),i-=1,D(),!0):(s=s.slice(0,i-1),i=s.length,E=!1,D(),x(),!1)},F=()=>{const S=L(!0);return S&&x(),D(),S},I=()=>{if(i>=s.length)return D(),!1;const S=s[i];return Xi(e.getContent(),S.changes)?(b(S.changes,{kind:"redo",selection:S.selection?.after}),i+=1,D(),x(),!0):(s=s.slice(0,i),D(),x(),!1)};return{recordAt(S,N,j){const W=l,re=u;l=S,u=j;try{return N()}finally{l=W,u=re}},activeMove:()=>d,canUndo:()=>i>0,canRedo:()=>i<s.length,undo(){F()},redo(){I()},tryUndo:F,tryRedo:I,clear:h,closeGroup:D,beginTransaction(){y===0&&(E=!1),y+=1;let S=!1;return()=>{S||(S=!0,y-=1,y===0&&(E=!1,D()))}},applyWithoutHistory(S){const N=e.get().version;if(w(S,"system"),e.get().version===N){D();return}m(S)},getPast:S=>s.slice(0,i).reverse().slice(0,S).map(N=>N.changes),getFuture:S=>s.slice(i).reverse().slice(0,S).map(N=>N.changes),createSnapshot:()=>({stackId:a,index:i}),restoreSnapshot(S){if(S.stackId!==a||S.index>i)return!1;for(;i>S.index;)if(!L())return x(),!1;return x(),!0},currentStep:()=>({id:s[i-1]?.id??0,below:s[i-1]?.below??0}),subscribe(S){return O.add(S),()=>O.delete(S)},dispose(){P=!0,p(),O.clear(),s=[],i=0}}}var sg=["edit","move","resize","insert"];function to(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ig(e){return typeof e=="string"?e:null}function ag(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function cg(e){return sg.includes(e)?e:null}function lg(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:ig(t.originId),changeId:to(t.changeId),rev:to(t.rev),baseRev:to(t.baseRev),expected:ag(t.expected),intent:cg(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}function ug(e){return e instanceof ze?e.reason:void 0}var Zi={"too-many-tags":"The email has more tags than allowed, so nothing was saved.","canvas-not-synced":"Not all canvas edits reached the document, so nothing was saved; try again in a moment.","plugin-refused":"A plugin refused the save, so nothing was saved."};function dg(e){const t=ug(e);if(t===void 0||t==="locked")return;const{detail:n}=e;return n?`${Zi[t]} Its reason: ${n}`:Zi[t]}var ea=Symbol.for("emailmaker.blockSaveFlight"),_u=Symbol.for("emailmaker.blockSaveSessionQueue"),Uo=new WeakMap;function bu(e,t){return Object.isExtensible(e)||t in e?e[t]:Uo.get(e)?.get(t)}function yu(e,t,n){if(t in e||Object.isExtensible(e)){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return}const r=Uo.get(e)??new Map;r.set(t,n),Uo.set(e,r)}function fg(e,t){yu(e,_u,t)}function pg(e,t){const n=(bu(e,ea)??Promise.resolve()).then(t,t);return yu(e,ea,n.catch(()=>{})),n}function hg(e,t){return bu(e,_u)?.(t)??pg(e,t)}var Jt=new Map,ta=new Map;function mg(e){return Jt.set(e,(Jt.get(e)??0)+1),()=>{const t=(Jt.get(e)??1)-1;if(t>0){Jt.set(e,t);return}Jt.delete(e);const n=ta.get(e);ta.delete(e),n?.forEach(r=>r())}}var Hs=e=>e.replace(/\r\n?/g,`
998
+ `),gg=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function $o(e){return typeof e=="string"&&gg.test(e)}var vg=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function _g(){return typeof navigator<"u"&&navigator.onLine===!1}function bg(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const o=r.data;typeof r.data=="object"&&o.error!=null&&t.push(o.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function Eu(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return Eu(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function yg(e){return _g()?!0:bg(e).some(Eu)}var wu=new WeakSet,Su=new WeakMap;function Iu(e){typeof e=="object"&&e!==null&&wu.add(e)}function Eg(e,t){typeof e=="object"&&e!==null&&Su.set(e,t)}function wg(e){return typeof e=="object"&&e!==null?Su.get(e):void 0}function Sg(e){return e instanceof kr||e instanceof ou||typeof e=="object"&&e!==null&&wu.has(e)}function Ig(e){return e instanceof ze||Au(e)||e instanceof vg||Sg(e)}function Au(e){return Vs(e)?.v2Error?.data?.code==="blocks.block_locked"}function na(e){return Vs(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function Vs(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function Ag(e){if(e instanceof ze)return e.reason==="canvas-not-synced";if(Ig(e))return!1;const t=Vs(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?na(e):!0}return yg(e)||na(e)}var Tu="draft";function Ot(e){return e==null||e===""?Tu:String(e)}function mr(e){return e==null||e===""?`${Ho}${Tu}`:`${Ho}${String(e)}`}var Ho="block:";function ee(e){return e?.startsWith(Ho)===!0}function xt(e){return ee(e.sessionKey())?void 0:e.current()}function dt(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return ce(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(ce(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const s=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw Es(o)?(`${e}`,{...n}):(`${e}`,{error:tu(o),...n},void 0),o})}var Tg=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function Cg(e){const t=e?.trim()??"";if(!Tg.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function dn(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Gs(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Og(e,t={}){const n=dn((e??[]).filter(r=>r?.html?.trim()));return Gs(n,t)?n:null}function Pg(e,t){const n=Date.parse(dn(e)?.modified??""),r=Og(e),o=Date.parse(r?.modified??""),s=t===void 0||Number.isFinite(o)&&o>t,i=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:s?r:null,...i.length?{latestAt:Math.max(...i)}:{}}}function ra(e,t,n){const r=dn((e??[]).filter(c=>c?.html?.trim())),o=Date.parse(r?.modified??""),s=Date.parse(dn((n??[]).filter(c=>c?.html?.trim()))?.modified??""),i=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(s>o),a=[Date.parse(dn(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:i&&Gs(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Rg({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var oa=["recovery","plugin","rest"],Dg=["subject","preheader"];function kg(e){let t={},n;for(let o=oa.length-1;o>=0;o--){const s=e.get(oa[o]);s&&(s.attributes&&(t={...t,...s.attributes}),s.content!==void 0&&(n=s.content))}const r=e.get("plugin")?.attributes;for(const o of Dg){const s=r?.[o];typeof s=="string"&&s!==""&&(t={...t,[o]:s})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function gr(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Hs(t.content):void 0,o=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...o?{changes:[new Me(0,n,0,r)]}:{}},{source:"remote"})}var no=e=>typeof e=="string"?e.trim():"";function xg(e,t,n,r){const{version:o,attributes:s}=e.get(),i=s,a=r==="snapshot"||r==="anchor",c=a?i.author:void 0,l=a?i.date_gmt:void 0,u=no(i.title)||no(i.subject)||no(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:u,subject:i.subject,preheader:i.preheader,description:i.description,common_styles:i.common_styles||"",meta:i.meta,utm_parameters:i.utm_parameters,parent_email:i.parent_email,is_template:i.is_template||!1,is_inited:i.is_inited,tags:i.tags,emailtags:i.emailtags,group:i.group,projectCategories:i.projectCategories,renderGuid:e.get().docId,project:t.project??i.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...c!=null&&c!==""?{author:c}:{},...l?{excerpt:l}:{}}}}var Lg=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Ng(e){const t={};for(const n of Lg)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Mg(e,t,n,r,o,s){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(o);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,o):t.saveAutosave(r,o,s==null?void 0:{wpId:s})}function Xe(e,t=!1){const n={};for(const r of Object.keys(e)){let o=e[r];o!==void 0&&!(typeof o=="number"&&Number.isNaN(o))&&(t&&typeof o=="object"&&o!==null&&(o=Xe(o)),n[r]=o)}return n}function Fg(e){return typeof e=="string"&&e.includes("autosave")}var Bg=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Cu(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Bg.has(t))):{}}function Ut(e,t,n={}){e&&e.mutate({attributes:jg(e.get().attributes,t)},{source:n.source??"user"})}function jg(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function qs(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Ug(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Ou(e){if(!e)return null;const t=Cu(e);return e.common_styles!==void 0&&(t.common_styles=Ug(e.common_styles)),qs(e.html,t)}function Pu(e){return e?qs(e.html,Xe(Cu(e))):null}var $g=["common_styles","subject","preheader","meta"];function sa(e){if(!e?.html?.trim())return null;const t={};for(const n of $g)Hg(n,e[n])&&(t[n]=e[n]);return qs(e.html,t)}function Hg(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 Vg=["modified","lock","wpId","secretHash"];function ia(e){if(!e)return null;const t={};for(const n of Vg)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Gg=10,qg=(e,t)=>e.key===t.key&&Wg(e.serverId,t.serverId),Wg=(e,t)=>e==null||e===t;function zg(e){return typeof e?.then=="function"}var aa=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Ru=e=>{e.request.serverId!=null&&!Lr(e)&&e.document.markSaved(e.document.get().version)},Lr=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),ca=(e,t)=>t?.content!==void 0&&Rg({hasUnsavedUserEdit:Lr(e)})==="skip",la=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},Kg=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),Xg=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.userTouched.clear(),e.document.get().docId))},Yg=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,s])=>e.attributes[o]!==s)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Jg=e=>{const t=kg(e.reports),n=Yg(e.lastMerged,t);e.lastMerged=t,e.broughtContent=Nr(t.content)??e.broughtContent,n&&(gr(e.document,n),Ru(e))},ro=(e,t)=>{if(!e.ready&&!Lr(e)){Jg(e);return}e.broughtContent=Nr(t?.content)??e.broughtContent,gr(e.document,t)},Nr=e=>e===void 0?void 0:Hs(e),Qg=(e,t)=>t.content===void 0||Nr(t.content)!==e.broughtContent||!Lr(e)?t:{...t,content:void 0},ua=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 Zg(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:s,canEdit:i,notifyBeforeSave:a,confirmPublish:c,awaitCanvasSynced:l,savedEchoForm:u=_=>_,queuesOutsideWrites:d,onAdapterError:f,onTimeout:v}=e;let g,y;const E=new Set,P=new Set,O=()=>E.forEach(_=>_()),x=(_,A)=>{if(!(_.closed||_.ready)){if(_.error!==void 0){_.document.markFailed(_.error),_.document.get().docId;return}Ru(_),_.ready=!0,_.document.markReady(),_.document.get().docId,[..._.reports.keys()]}},w=(_,A,k)=>{f?.(A.id,k),!(!A.required||_.closed)&&(_.error=k,_.document.get().docId,A.id,O())},C=(_,A)=>{const k=new Set(A.map(G=>G.id));A.forEach(G=>{G.watch&&_.watchers.push(G.watch(z=>_.closed?!1:_.ready&&(ca(_,z)||_.contentShown===!0&&z?.content!==void 0)?(_.document.get().docId,G.id,!1):(z&&_.reports.set(G.id,z),ro(_,z),z?.content!==void 0&&(_.showFill=void 0),!0)))});const U=(G,z)=>{if(!_.closed){if(!G.required&&ca(_,z)){_.document.get().docId,G.id,G.loaded?.(!1);return}z&&(_.reports.set(G.id,z),G.id==="plugin"&&la(_,z)),ro(_,z),G.loaded?.(z!==null)}},q=()=>{k.size>0||_.closed||(aa(_),x(_,[]))},Q=[];if(A.forEach(G=>{let z;try{z=G.load()}catch(M){w(_,G,M),k.delete(G.id);return}if(zg(z)){Q.push({id:G.id,required:G.required,load:()=>z,...G.loaded?{loaded:M=>G.loaded?.(M)}:{}});return}U(G,z),k.delete(G.id)}),Q.length===0){q();return}_.timer=setTimeout(()=>{_.timer=void 0,v?.([...k]),_.document.get().docId,[...k],x(_,[...k])},n),_.timer.unref?.(),Q.forEach(G=>{G.load().then(z=>U(G,z)).catch(z=>{w(_,G,z)}).finally(()=>{k.delete(G.id),q()})})},T=async(_,A,k)=>{if(k==="snapshot"||k==="anchor")return;const U=s?.();if(U)return U.resolve({project:A.project??_.project,tags:(_.tags??[]).map(q=>({name:q}))})},D=_=>{if(_.lock===!0&&i?.(_)===!1)return new ze("locked");const A=_.tags?.length??0,k=_.emailtags?.length??0;if(Math.max(A,k)>Gg)return new ze("too-many-tags")},R=(_,A)=>{const k=_.document.get().serverId;k!=null&&(_.createKey=void 0),!(A||k==null)&&(_.recoveryFacts={emailId:k,historyLoaded:!0,isRecovering:!1},ee(_.request.key)||(_.request={..._.request,key:Ot(k),serverId:k}))},m=(_,A,k)=>{if(_.closed||k?.id==null)return;const U=_.document.get().serverId,q=U!=null;q&&U!==String(k.id)||(_.document.markSaved(A,String(k.id)),R(_,q),_.document.get().serverId,O())},p=(_,A,k)=>{if(!(A==="materialize"||A==="publish"&&_.document.get().serverId==null))return k;const U=_.createKey,q=U&&U.project===k.project?U:{key:xe(),project:k.project};return _.createKey=q,{...k,idempotencyKey:q.key}},h=async(_,A,k)=>{try{await _.document.whenReady()}catch(M){return _.saveError=M,_.saveFailures+=1,_.failedIntent=A,_.saveFailures,!1}if(_.closed)return!1;const U=D(_.document.get().attributes);if(U)return _.saveError=U,_.saveFailures+=1,_.failedIntent=A,U.reason,O(),!1;if(a&&(await a(ua(_)).catch(()=>{}),_.closed))return!1;if(l){try{await l()}catch(M){return _.saveError=M,_.saveFailures+=1,_.failedIntent=A,_.saveFailures,O(),!1}if(_.closed)return!1}if(c&&A==="publish"){const M=await c(ua(_),_.request.key).catch(()=>{});if(_.closed)return!1;if(M!==void 0)return _.saveError=new ze("plugin-refused",M),_.saveFailures+=1,_.failedIntent=A,O(),!1}let q;try{q=await T(_.document.get().attributes,k,A)}catch(M){return _.saveError=M,_.saveFailures+=1,_.failedIntent=A,_.saveFailures,O(),!1}if(_.closed)return!1;const{payload:Q,version:G}=xg(_.document,k,q,A),z=p(_,A,Q);_.document.get().docId;try{const M=_.document.get().serverId!=null,J=await Mg(r(),o(_.request.key),A,_.document.get().serverId,z,_.document.get().attributes.wpId);if(_.closed)return!0;let Z;if(A==="snapshot"||A==="anchor"){const te=J?.modified!=null?Date.parse(J.modified):NaN;Z=Number.isFinite(te)?te:Date.now(),_.snapshotVersion=G,_.lastRevisionAt=Z}else{_.document.markSaved(G,J?.id!=null?String(J.id):void 0);const te=J;gr(_.document,ia(te&&{wpId:te.wpId,secretHash:te.secretHash})),_.broughtContent=Nr(u(z.html))}R(_,M),_.saveError=void 0,_.saveFailures=0,_.failedIntent=void 0,_.document.get().serverId,O();const be={intent:A,serverId:_.document.get().serverId,created:!M,...Z!==void 0?{revisionAt:Z}:{}};return P.forEach(te=>te(be)),!0}catch(M){return(A==="publish"||A==="materialize")&&wg(M)?.then(J=>m(_,G,J)),_.saveError=M,_.saveFailures+=1,_.failedIntent=A,_.saveFailures,O(),!1}},b=_=>{_.closed=!0,_.watchers.forEach(A=>A()),_.watchers=[],aa(_),_.history.dispose(),_.document.dispose()},L=()=>{g&&(b(g),g=void 0)},F=()=>{y&&(b(y),y=void 0)},I=(_,A,k)=>{let U=!1;A.show&&(_.show?.id!==A.show.id||_.show.token!==A.show.token)&&(_.show=A.show,U=!0,{docId:_.document.get().docId,...A.show});const q=k==="show"?Pu(A.patch):null;if(q){_.reports.set("plugin",q),la(_,q);const Q=Qg(_,q);ro(_,Q),Xg(_,Q)}U&&O()},S=(_,A={})=>W(g,_,A),N=()=>g&&ee(g.request.key??"")?y:g,j=_=>({error:_?.saveError,failures:_?.saveFailures??0,saving:_?.saving===!0,failedIntent:_?.failedIntent}),W=(_,A,k)=>!_||_.closed||A==="materialize"&&_.document.get().serverId!=null?Promise.resolve(!1):_.saving?A==="snapshot"||A==="materialize"?Promise.resolve(!1):(_.inFlight??Promise.resolve(!1)).then(()=>W(_,A,k)):(_.saving=!0,O(),_.inFlight=h(_,A,k).finally(()=>re(_)),_.inFlight),re=_=>{_.saving=!1,_.inFlight=void 0,g===_&&!_.closed&&O()},oe=(_,A)=>{if(_.closed)return A();if(_.saving)return(_.inFlight??Promise.resolve(!1)).then(()=>oe(_,A));_.saving=!0,O();const k=Promise.resolve().then(A);return _.inFlight=k.then(()=>!0,()=>!1).finally(()=>re(_)),k},se=(_,A)=>{const k=_.document.get().serverId,U=k==null?void 0:mg(k);return oe(_,A).finally(U)},Y=(_,A="open",k=!1)=>{if(g&&!g.closed&&A!=="new"&&qg(g.request,_))return I(g,_,A),g.document;L(),k||F();const U=Qm({createBuffer:()=>qm(""),serverId:_.serverId??null}),q={request:_,show:_.show,document:U,history:og(U,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return g=q,fg(U,Q=>d?.(q.request.key)===!0?se(q,Q):void 0),q.watchers.push(Kg(q)),U.get().docId,_.serverId,C(q,t(_,{publishRecoveryFacts(Q){q.closed||(q.recoveryFacts=Q,O())},readShownContent:()=>q.closed?null:q.document.getContent(),readWpId:()=>q.closed?void 0:q.document.get().attributes.wpId})),O(),U},$=(_,A,k)=>({key:ee(_)?_:mr(_),serverId:A?.id!=null?String(A.id):null,email:A,show:k});return{openWith:Y,open:(_,A={})=>Y({key:Ot(_),serverId:_,email:A.email,patch:A.patch,show:A.show},"open"),openDraft:(_,A={})=>Y({key:Ot(void 0),serverId:null,email:_,patch:A.patch,show:A.show},"open"),startNewDraft:(_,A={})=>Y({key:Ot(void 0),serverId:null,email:_,patch:A.patch,show:A.show},"new"),reload:(_,A={})=>Y({key:Ot(_),serverId:_,email:A.email,patch:A.patch,show:A.show},"new"),openBlock:(_,A,k)=>Y($(_,A,k),"open"),reloadBlock:(_,A,k)=>Y($(_,A,k),"new"),openBlockOver:(_,A)=>{const k=$(_,A);return g&&!g.closed&&g.request.key===k.key?g.document:(g&&!g.closed&&!ee(g.request.key)&&(F(),y=g,g=void 0),Y(k,"open",!0))},resumeSuspended:()=>{if(y)return L(),g=y,y=void 0,O(),g.document},hasSuspended:()=>!!y,suspendedDocument:()=>y?.document,show:(_,A)=>{const k=g;if(!(!k||k.closed))return Y({...k.request,patch:_,show:A},"show")},current:()=>g?.document,noteServerFacts:({serverId:_,block:A},k)=>{const U=g;!U||U.closed||U.request.serverId!==_||ee(U.request.key??"")===A&&gr(U.document,ia(k))},save:S,saveEmail:(_,A={})=>W(N(),_,A),saveState:()=>j(g),emailSaveState:()=>j(N()),revisionFacts(){if(!g)return;const _=g.revisionFactsSnapshot;return _&&_.snapshotVersion===g.snapshotVersion&&_.lastRevisionAt===g.lastRevisionAt?_:(g.revisionFactsSnapshot={snapshotVersion:g.snapshotVersion,lastRevisionAt:g.lastRevisionAt},g.revisionFactsSnapshot)},recoveryFacts:()=>g?.recoveryFacts,history:()=>g?.history,forcedHeaders:()=>g?.forcedHeaders,beginForcedHeaders(_){g&&!g.closed&&(g.forcedHeaders=_)},endForcedHeaders(){for(const _ of[g,y])_&&(_.forcedHeaders=void 0)},onSaved(_){return P.add(_),()=>P.delete(_)},showFacts:()=>g?.show,shownHeaders:()=>({...g?.shownHeaders}),showFill:()=>g?.showFill,beginShowFill(_){g&&!g.closed&&(g.showFill={showId:_,codeEdits:0})},noteCodeEdit(){g?.showFill&&(g.showFill.codeEdits+=1)},endShowFill(_){for(const A of[g,y])A?.showFill?.showId===_&&(A.showFill=void 0)},sessionKey:()=>g?.request.key,openError:()=>g?.error,subscribe(_){return E.add(_),()=>E.delete(_)},close(){!g&&!y||(L(),F(),O())}}}var Ws=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function zs(e){if(e instanceof Ws)return e.reason;if(e instanceof ht)return zs(e.reason)}function ev(e){const t=e instanceof ht?e.reason:e;return t instanceof Ws&&t.reason==="unavailable"&&t.cause instanceof TypeError}function tv(e){const t=zs(e);return t!==void 0&&t!=="unavailable"}function nv(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Ws("not-found");return Ou(n)}}}var Du=B("EmailPort");function rv(e){return e.getInstance(Du)}function ov(e,t){e.inject(Du,t)}var ku=B("documentSession.restEmailPortFactories");function xu(e){return e.getInstance(ku)!==void 0}function gt(e){const t=e.getInstance(ku);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var sv=B("EmailTermsResolver");function iv(e){return e.getInstance(sv)}var Lu=B("EmailHistoryPort"),av=B("BlockHistoryPort");function Nu(e){return e.getInstance(av)}function Mu(e){return e.getInstance(Lu)}function cv(e,t){e.inject(Lu,t)}var lv=2e3,uv=5e3,dv=5,fv=5e3,pv=4;function hv(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function ir(e,t){return e==null||t==null?!1:e.replaceAll(`\r
999
999
  `,`
1000
1000
  `)===t.replaceAll(`\r
1001
1001
  `,`
1002
- `)}function nr(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function tn(e,t){return _i(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function fm(e,t,n){const{latest:r}=e,o=Wn(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(i=>Wn(i,r.html))?o?{revision:null,phase:"normal"}:{revision:nr(t),phase:"timeout"}:o?{revision:tn(e),phase:"normal"}:Wn(t.html,r.html)?{revision:nr(t),phase:"found"}:{revision:tn(e),phase:"normal"}}function pm({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:o=!1,readShownContent:i,onFacts:s,onLate:a,onError:c,pageLoadTs:l=dm()}){const u=r??e;let d=null,m=!1,_=!1,v=0,E={emailId:e,historyLoaded:!1,isRecovering:!1},y=null;const k=new Promise(S=>{y=S}),C=S=>{E={...E,...S},s(E)};let F;const T=S=>{v+=1,C({applied:{phase:S,seq:v}})},R=()=>{d?.timer&&clearTimeout(d.timer),d=null},A=S=>{if(!_){if(y){const w=y;y=null,w(S),F=S.revision?S.phase:void 0;return}a(S)&&S.revision&&T(S.phase)}},D=()=>{if(!d||_)return;const S=d.phase==="fast",w=S?sm:lm,M=S?cm:um;d.timer=setTimeout(()=>{const B=d;if(!(!B||_)){if(B.attempts+=1,p(),S&&B.attempts>=M){const{pending:W}=B;st(u),C({isRecovering:!1}),A({revision:nr(W),phase:"timeout"}),m=!0,B.phase="bg",B.attempts=0,D();return}if(!S&&B.attempts>=M){st(u),R(),C({isRecovering:!1}),m=!0;return}D()}},w),d.timer.unref?.()},O=S=>{d={phase:"fast",attempts:0,pending:S,timer:null},C({isRecovering:!0}),D()},h=S=>{if(_)return;if(C({historyLoaded:!0,latestRevisionAt:S.latestAt!==void 0&&Number.isFinite(S.latestAt)?S.latestAt:void 0}),n&&d){const B=tn(S,d.pending.sentAt);if(!B)return;const W=d.phase==="fast"?"found":"bg";st(u),R(),C({isRecovering:!1}),m=!0,A({revision:B,phase:W});return}if(m)return;const w=n?gr(u):null,M=w&&(w.sentAt<l||!Wn(w.html,i()))?w:null;if(M){if(o&&(M.baseRevisionId!==void 0||M.baseOpen)){st(u),m=!0,A(fm(S,M,i()));return}const B=tn(S,M.sentAt);if(B){st(u),m=!0,A({revision:B,phase:"found"});return}if(o){if(st(u),m=!0,S.latestAt!==void 0&&S.latestAt>M.sentAt+5e3){A({revision:null,phase:"normal"});return}A({revision:nr(M),phase:"timeout"});return}O(M);return}m=!0,A({revision:tn(S),phase:"normal"})},f=S=>{_||(c?.(S),E.historyLoaded||(C({historyLoaded:!1,latestRevisionAt:void 0}),N()),!d&&A({revision:null,phase:"normal"}))},p=()=>t(e).then(h).catch(f);let b,x=!1;const N=()=>{x||d||_||(x=!0,b=setTimeout(()=>{b=void 0,!_&&!E.historyLoaded&&p()},am))};return p(),{verdict:()=>k,confirmVerdict(S){const w=F;F=void 0,S&&w!==void 0&&!_&&T(w)},dispose(){_=!0,b!==void 0&&(clearTimeout(b),b=void 0),R()}}}function hm({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:o,wpId:i,readShownContent:s,onFacts:a}){let c=null;const l=pm({emailId:o,readAutosave:u=>i?e.readAutosave(u,{wpId:i()}):e.readAutosave(u),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:s,onFacts:a,onLate:({revision:u,phase:d})=>{const m=ys(u);return c?.(m)??!1},onError:u=>{u instanceof Error&&u.message}});return{id:"recovery",load:()=>l.verdict().then(({revision:u})=>ys(u)),loaded(u){l.confirmVerdict(u)},watch(u){return c=u,()=>{c=null,l.dispose()}}}}var mm=5e3,gm=U("plugin.knownRevisions");function Lt(e){return e.getOrCreateInstance(gm,()=>new Map)}function Si(e,t,n,r){const o=n?.get(t)??[],i=o.filter(s=>s!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...o.length>Rl?{baseOpen:!0}:i.length?{baseHtmls:i}:{}}}var vm=U("plugin.uncertainWrites"),Rl=3;function wn(e){return e.getOrCreateInstance(vm,()=>new Map)}function bm(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>Rl||e.set(t,[...r,n])}function Ol(e,t){yo(e,t)||!t.baseHtmls||yo(e,{...t,baseHtmls:void 0,baseOpen:!0})}function rr(e,t,n,r=!1){const o=gr(e);!n||o?.sentAt!==t||!(r||o.baseOpen||o.baseHtmls)||yo(e,{...o,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function kl(e,t,n,r){(gr(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||Ol(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var _m=/(?:Z|[+-]\d{2}:?\d{2})$/i;function ym(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",o=_m.test(r)?Date.parse(r):NaN;return!Number.isFinite(o)||o>=t-mm}function Pl(e,t,{pendingKey:n=s=>s,knownRevisions:r=new Map,uncertainWrites:o,synchronousHistory:i=!1}={}){return{readRevisions:(s,a,c)=>t.readRevisions(s,a,c),readRevision:(s,a,c)=>t.readRevision?t.readRevision(s,a,c):Promise.resolve(null),readAutosave:(s,a)=>t.readAutosave(s,a),async saveAutosave(s,a,c){const l=n(s),u=Date.now();Ol(l,{sentAt:u,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...Si(r,l,o,a.html??"")});const d=await t.saveAutosave(s,a,c),m=d?.id;return ym(d,u)?rr(l,u,m):m&&i&&(d.isAutosave===!0?gi(l,u):rr(l,u,m,!0)),await e.saveAutosave(s,a),d}}}function Em(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,o){const i=Date.now();n&&kl(r,o,i,Si(n.knownRevisions,r,n.uncertainWrites,o.html??""));const s=await t.updateEmail(r,o);return n&&rr(r,i,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,o),gi(r,i),s&&{...s,id:r}}}}var Dl=Symbol.for("emailmaker.result");function xl(e){return Object.defineProperty(e,Dl,{value:!0})}var pt=(e=>xl({ok:!0,value:e})),ue=((e,t="")=>xl({ok:!1,error:{code:e,message:t}}));function Ml(e){return typeof e=="object"&&e!==null&&e[Dl]===!0}var tt=e=>({optional:!1,...e}),Pn={string:()=>tt({kind:"string"}),number:()=>tt({kind:"number"}),boolean:()=>tt({kind:"boolean"}),enum:(...e)=>tt({kind:"enum",values:e}),element:(...e)=>tt({kind:"element",kinds:e}),array:e=>tt({kind:"array",item:e}),object:e=>tt({kind:"object",shape:e}),optional:e=>({...e,optional:!0})};function Ll(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _r(e,t,n){if(t===void 0)return e.optional?void 0:`"${n}" is required`;switch(e.kind){case"string":case"number":case"boolean":return typeof t===e.kind?void 0:`"${n}" must be a ${e.kind}`;case"enum":return e.values?.includes(t)?void 0:`"${n}" must be one of: ${e.values?.join(", ")}`;case"element":return t!==null&&(typeof t=="object"||typeof t=="string")?void 0:`"${n}" must be an element reference`;case"array":if(!Array.isArray(t))return`"${n}" must be an array`;for(let r=0;r<t.length;r+=1){const o=_r(e.item,t[r],`${n}[${r}]`);if(o)return o}return;case"object":return Ll(t)?Nl(e.shape,t,n):`"${n}" must be an object`}}function Nl(e,t,n){for(const[r,o]of Object.entries(e??{})){const i=_r(o,t[r],n?`${n}.${r}`:r);if(i)return i}}function wm(e,t,n){return e?_r(e,t,n):void 0}function Sm(e,t){if(!e)return;const n=e;return n.kind!=="object"?_r(n,t,"arguments"):t!==void 0&&!Ll(t)?"arguments must be an object":Nl(n.shape,t??{},"")}function Fl(e){const t=e?.["~standard"];return typeof t=="object"&&t!==null&&typeof t.validate=="function"}function Im(e){return(e.path??[]).map(t=>String(typeof t=="object"?t.key:t)).join(".")}function Bl(e,t){if(!Fl(e)){const n=Sm(e,t);return n?{ok:!1,problem:n}:{ok:!0,value:t??{}}}try{const n=e["~standard"].validate(t??{});return n instanceof Promise?n.then(Cs,As):Cs(n)}catch(n){return As(n)}}function As(e){return{ok:!1,problem:`the arguments check failed: ${e instanceof Error?e.message:String(e)}`}}function Cs(e){if(e.issues){const[t]=e.issues,n=t?Im(t):"";return{ok:!1,problem:t?n?`"${n}": ${t.message}`:t.message:"arguments are invalid"}}return{ok:!0,value:e.value}}var Rs="Element reference returned by element.getTree, element.get or the selection.";function To(e){switch(e.kind){case"string":case"number":case"boolean":return{type:e.kind};case"enum":return{type:"string",enum:[...e.values??[]]};case"element":return e.kinds?.length?{type:"string",description:`${Rs} Kinds: ${e.kinds.join(", ")}.`}:{type:"string",description:Rs};case"array":return{type:"array",items:To(e.item)};case"object":{const t=Object.entries(e.shape??{}),n=t.filter(([,r])=>!r.optional).map(([r])=>r);return{type:"object",properties:Object.fromEntries(t.map(([r,o])=>[r,To(o)])),...n.length?{required:n}:{}}}}}var Tm={type:"object",properties:{}};function Am(e){if(!e)return Tm;if(!Fl(e))return To(e);const t=e["~standard"].jsonSchema;if(t&&typeof t.input=="function")return t.input({target:"draft-2020-12"});const n=e.toJSONSchema;if(typeof n=="function")return n.call(e);throw new Error(`The ${e["~standard"].vendor} schema cannot export JSON Schema; use a library version with Standard JSON Schema or Arg.object({...}).`)}function Ae(e,t){try{t()}catch{}}var Cm=Symbol.for("emailmaker.platform.hostError"),or="The editor could not load the code of its commands. Trying again does not help: the user has to reload the page.";function De(e,t){return Object.defineProperty(ue(e,t),Cm,{value:!0})}function jl(e){const t=globalThis,n=Symbol.for(`emailmaker.platform.owner.${e}`);return t[n]??=Object.freeze({name:e})}var ht=jl("core"),Os=jl("unknown"),Ul=Symbol.for("emailmaker.platform.builtInPlugin");function $l(e){return Symbol.for(`emailmaker.platform.builtInKey.${e}`)}function Ii(e){return Object.entries(e).forEach(([t,n])=>{typeof n=="function"&&(Object.defineProperty(n,Ul,{value:!0}),Object.defineProperty(n,$l(t),{value:!0}))}),e}function Hl(e,t){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,$l(t))}function Rm(e){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Ul)}function ks(e){return Rm(e.constructor)}var Om=class{_owners=new WeakMap;_stack=[];_listeners=new Set;current(){return this._stack[this._stack.length-1]??Os}execute(e,t){const n=e===ht?Os:e;this._stack.push(n);try{return t()}finally{this._leave(n)}}onUnload(e){return this._listeners.add(e),{dispose:()=>this._listeners.delete(e)}}handle(e){const{plugin:t}=e;if(t)switch(e.type){case"init:enter":case"afterInit:enter":ks(t)||this._stack.push(this._ownerOf(t,e.name));break;case"init:leave":case"afterInit:leave":ks(t)||this._leave(this._ownerOf(t,e.name));break;case"dispose:start":{const n=this._owners.get(t);n&&(this._leave(n),this._owners.delete(t),Array.from(this._listeners).forEach(r=>r(n)));break}}}_ownerOf(e,t){let n=this._owners.get(e);return n||(n={name:t},this._owners.set(e,n)),n}_leave(e){const t=this._stack.lastIndexOf(e);t>=0&&this._stack.splice(t,1)}};function yr(e){const t={watch:e,select:n=>yr(r=>{let o=!1,i;return t.watch(s=>{const a=n(s);o&&Object.is(i,a)||(o=!0,i=a,r(a))})})};return t}function km(e){return yr(t=>(t(e),{dispose:()=>{}}))}function Pm(e,t){return yr(n=>{let r=!1,o=!1,i;const s=()=>{if(!r)return;const c=t();o&&Object.is(i,c)||(o=!0,i=c,n(c))},a=e.map(c=>c.watch(s));return r=!0,s(),{dispose:()=>a.forEach(c=>c.dispose())}})}function Ce(e){let t;return e.watch(n=>{t=n}).dispose(),t}function kt(e,t,n){return new Promise((r,o)=>{const i=()=>r(void 0),s=setTimeout(i,t),a=()=>{clearTimeout(s),n?.removeEventListener("abort",i)};n?.aborted&&i(),n?.addEventListener("abort",i,{once:!0}),Promise.resolve().then(e).then(c=>{a(),r(c)},c=>{a(),o(c)})})}function he(e,t){return{ok:!1,error:{code:e,message:t}}}function Gt(e){return he("documentChanged",`"${e}" was not run: another email is open now, not the one this work started on. Stop and tell the user; do not repeat the call.`)}function Dm(e){return he("aborted",`"${e}" was not run: this tool became another command while the user was asked. Read the tools again and ask the user anew with a new call.`)}function xm(e,t){return he("invalidArgs",`Call ${e} ("${t}") needs the user's consent, so its input cannot hold a "$result" reference: the consent window has to show the data. Run the earlier calls first, then send this call in a separate batch with the value written out. No call ran.`)}var nn=e=>he("aborted",`The call of "${e}" was cancelled.`),ir=e=>e instanceof Error?e.message:String(e);function Mm(){return Object.assign(new Error(or),{code:"unavailable"})}function Lm(){return{code:"undoConflict",message:"An agent call is still running; undo the answer when it ends."}}var Nm=64,Fm=/[\w-]+(?:\.[\w-]+)+/g;function bt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,Nm)}function Dn(e,t){return(e??[]).some(n=>n.endsWith(".*")?t.startsWith(n.slice(0,-1)):n===t)}function Vl(e,t){const n=new Map(t.map(([r,o])=>[o.id,r]));return e.replace(Fm,r=>n.get(r)??r)}var Bm=3e3,jm=12,Um=e=>typeof e?.label=="string"&&typeof e.value=="string";function $m(e){const{title:t,details:n}=e??{};if(typeof t!="string"||!t)return;const r=(Array.isArray(n)?n:[]).filter(Um).slice(0,jm);return r.length?{title:t,details:r.map(({label:o,value:i})=>({label:o,value:i}))}:{title:t}}async function Hm(e,t,n,r){const o=t.agent?.consent;if(o)try{return $m(await kt(()=>e.asOwner(t.id,()=>o(n,r)),Bm))}catch(i){`${t.id}${ir(i)}`;return}}function Vm(e,t,n,r,o){return{tool:e,command:t.id,title:t.title,description:t.description&&Vl(t.description,o()),input:n,...r?{consent:r}:{},...t.owner===ht?{}:{fromPlugin:!0}}}async function Gm({lifetime:e,ask:t,tool:n,signal:r,question:o}){if(r?.aborted||e.aborted)return nn(n);if(!t)return he("forbidden",`The tool "${n}" needs the user's consent, and there is no one to ask in this editor.`);const i=new AbortController,s=()=>i.abort();r?.addEventListener("abort",s,{once:!0}),e.addEventListener("abort",s,{once:!0});const a=new Promise(l=>{i.signal.addEventListener("abort",()=>l(!1),{once:!0})}),c=async()=>{const l=await o(i.signal);return i.signal.aborted?!1:t({...l,signal:i.signal})};try{const l=await Promise.race([c(),a]);return i.signal.aborted?nn(n):l===!0?void 0:De("declined",`The user declined "${n}". Do not repeat the call unless the user asks for it again.`)}catch(l){const u=ir(l);return`${n}${u}`,he("aborted",`The user was not asked about "${n}": ${u}`)}finally{r?.removeEventListener("abort",s),e.removeEventListener("abort",s),i.abort()}}var Ao=Symbol("bad input");function Ps(e){try{return JSON.stringify(e)}catch{return Ao}}var _t=e=>e===void 0?void 0:JSON.parse(e);function Ds(e){if(e===void 0)return null;try{return JSON.parse(JSON.stringify(e))}catch{return"[a value that cannot be serialized]"}}var St="agent.batch",qm=5e3,Wm=5e3,zm=20,Km=new Set(["ui.openView","ui.closeView",St]),Ym=class{_deps;_confirmHost;_bound;_turnDepth=0;_turnStart;_lastTurn;constructor(e){this._deps=e}setConfirmHost(e){return this._confirmHost=e,{dispose:()=>{this._confirmHost===e&&(this._confirmHost=void 0)}}}get _config(){return Ce(this._deps.config)??{}}get enabled(){return this._config.enabled!==!1}async tools(){const e=await this._describedOpened();return e.map(([t,n])=>({name:t,description:Vl(n.description??n.title,e),inputSchema:n.inputSchema??{type:"object",properties:{}},...this._needsConfirm(n)?{confirm:!0}:{}}))}invoke(e,t,n={}){return this._call(e,t,n)}async openBatch(e,t){const n=this._deps.commands.info(St),r=n!==void 0&&this._needsConfirm(n),o=this._openDocument(),i=new Map,s=new Map;for(const[a,c]of e.entries()){const l=this._find(c.tool);if(!l)continue;const[u,d]=l,m=r||this._needsConfirm(d);if(!m&&!d.agent?.precheck)continue;if(c.deferred){if(m)return{ok:!1,error:xm(a,u).error,index:a};continue}const _=Ps(c.input);if(_===Ao)continue;const v=await this._checkInput(d,_t(_),t);if(!v||v.ok===!1||!this._deps.commands.availableNow(d.id))continue;const E=await this._precheck(u,d,v.value,t);if(E)return{ok:!1,error:E.error,index:a};i.set(a,d),m&&s.set(a,{tool:u,info:d,input:v.value,frozen:_})}if(n&&s.size>0){const a=Ds(e.map(({tool:l,input:u})=>({tool:l,args:u}))),c=await this._ask(bt(St),t,async l=>{const u=Array.from(s.values()),d=await Promise.all(u.slice(0,zm).map(async({tool:_,info:v,input:E,frozen:y})=>this._item(_,v,_t(y),await this._consentOf(v,E,l)))),m=await this._consentOf(n,void 0,l);return{...this._item(bt(St),n,{calls:a},m),batch:{items:d,more:u.length-d.length}}});if(c)return{ok:!1,error:{...c.error,message:`${c.error.message} None of the calls of the batch ran.`}};if(this._openDocument()!==o)return{ok:!1,error:Gt(bt(St)).error}}return{ok:!0,run:(a,c)=>{const l=s.get(a);return this._call(e[a].tool,l?_t(l.frozen):c,{signal:t},{consented:l?.info,prechecked:i.get(a),askAll:r})}}}async _call(e,t,n,r={}){if(!this.enabled)return he("forbidden","The agent is switched off in this editor.");const o=this._find(e);if(!o)return this._deps.commands.info(e)??(Ce(this._deps.commands.commands)??[]).find(v=>bt(v.id)===e)?he("forbidden",`The tool "${e}" is not opened to the agent here.`):he("notInstalled",`There is no tool "${e}" in this editor.`);const[i,s]=o,a=Ps(t);if(a===Ao)return he("invalidArgs",`Tool "${i}": the input must be plain JSON data.`);const c=await this._checkInput(s,_t(a),n.signal);if(!c)return n.signal?.aborted?nn(i):he("unavailable",this._deps.commands.undescribed(s.id)?or:`The input of the tool "${i}" could not be checked; try again.`);if(c.ok===!1)return he("invalidArgs",`Tool "${i}": ${c.problem}.`);const l=this._openDocument();if(this._adoptOpened(l),this._bound&&this._bound.document!==l)return Gt(i);if(!this._deps.commands.availableNow(s.id))return he("unavailable",`The tool "${i}" is not available right now.`);if(r.prechecked!==s&&s.agent?.precheck){const v=await this._precheck(i,s,c.value,n.signal);if(v)return v;if(this._openDocument()!==l)return Gt(i)}let u=r.consented;if(!u&&(r.askAll||this._needsConfirm(s))&&!(s.id===St&&s.owner===ht)){const v=await this._ask(i,n.signal,async E=>this._item(i,s,_t(a),await this._consentOf(s,c.value,E)));if(v)return v;if(this._openDocument()!==l)return Gt(i);u=s}const d=this._deps.commands.prepared(s.id,n.signal);if(d!==!0){if(!await d)return n.signal?.aborted?nn(i):he("unavailable",or);const v=this._openDocument();if(this._adoptOpened(v),l!==void 0&&v!==l)return Gt(i)}if(this._find(i)?.[1]!==(u??s))return Dm(i);const m=()=>this._deps.commands.run(s.id,_t(a),{caller:"agent",signal:n.signal}),_=await(Km.has(s.id)||s.agent?.readOnly?m():this._deps.history.group(m));return _.ok===!1?he(_.error.code,_.error.message||`The tool "${i}" failed: ${_.error.code}.`):{ok:!0,value:Ds(_.value)}}readOnlyTool(e){return this._find(e)?.[1].agent?.readOnly===!0}get answerOpen(){return this._bound!==void 0}async holdDocument(e){const t=this._bound??={document:this._openDocument(),holders:0};t.holders+=1;try{return await e()}finally{t.holders-=1,t.holders===0&&(this._bound=void 0)}}_adoptOpened(e){this._bound&&this._bound.document===void 0&&e!==void 0&&(this._bound.document=e,this._deps.history.reopen(),this._turnDepth>0&&(this._turnStart=this._deps.history.answers?.capture()))}async turn(e){this._turnDepth===0&&(this._turnStart=this._deps.history.answers?.capture()),this._turnDepth+=1;try{return await this.holdDocument(()=>this._deps.history.group(e))}finally{this._turnDepth-=1,this._turnDepth===0&&(this._lastTurn={start:this._turnStart,end:this._deps.history.answers?.capture()})}}async undoTurn(){if(!this.enabled)return he("forbidden","The agent is switched off in this editor.");const e=this._deps.history.answers,t=e?.undoRefusal();if(t)return{ok:!1,error:t};const n=this._lastTurn;if(!e||!n)return he("nothingToUndo","There is no answer to undo.");this._lastTurn=void 0;try{const r=await e.settle()??(this._deps.history.grouping?Lm():e.undo(n.start,n.end));return r?(this._lastTurn??=n,{ok:!1,error:r}):{ok:!0,value:null}}catch(r){this._lastTurn??=n;const o=ir(r);return`${o}`,he("undoConflict",`The answer could not be undone: ${o}`)}}_needsConfirm(e){const{confirm:t}=this._config;return e.agent?.confirm===!0||Dn(t,e.id)||Dn(t,bt(e.id))}_openDocument(){return this._deps.history.answers?.document()}_find(e){return this._opened().find(([t,n])=>t===e||n.id===e)}_opened(){if(!this.enabled)return[];const e=this._config.deny,t=new Map;for(const n of Ce(this._deps.commands.commands)??[]){const r=bt(n.id);if(!n.agent||Dn(e,n.id)||Dn(e,r))continue;const o=t.get(r);if(o){`${o.id}${n.id}${r}`;continue}t.set(r,n)}return Array.from(t.entries())}async _describedOpened(){const{commands:e}=this._deps;let t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id));for(;n.length>0;){if((await Promise.all(n.map(([,r])=>e.described(r.id)))).includes(!1))throw Mm();t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id))}return t}async _checkInput(e,t,n){const{commands:r}=this._deps;if(r.undescribed(e.id)&&!await r.described(e.id,n))return;const o=Bl(this._deps.commands.declarationArgs(e.id),t);return o instanceof Promise?kt(()=>o,Wm,n):o}async _precheck(e,t,n,r){const o=t.agent?.precheck;if(o){try{const i=await kt(()=>this._deps.commands.asOwner(t.id,()=>o(n)),qm,r);if(Ml(i)&&i.ok===!1){const{code:s,message:a}=i.error;return he(s,a||`The tool "${e}" was refused: ${s}.`)}}catch(i){`${t.id}${ir(i)}`}return r?.aborted?nn(e):void 0}}_consentOf(e,t,n){return Hm(this._deps.commands,e,t,n)}_item(e,t,n,r){return Vm(e,t,n,r,()=>this._opened())}_ask(e,t,n){const r=this._config.onConfirm??(Ce(this._deps.facts)?.headless?void 0:this._confirmHost);return Gm({lifetime:this._deps.commands.lifetime,ask:r,tool:e,signal:t,question:n})}},Xm={documentOpen:!1,selection:"none",codeMode:!1,readOnly:!1,headless:!1};function rn(e,t){if(!e)return!0;if("any"in e)return e.any.some(r=>rn(r,t));if("not"in e)return!rn(e.not,t);const n={...Xm,...t};return Object.entries(e).every(([r,o])=>n[r]===o)}var Jm=5e3,xs=3e4;function Gl(e){const{agent:t}=e;if(!t)return;if(t===!0)return{};const{readOnly:n,consent:r,precheck:o}=t;return{confirm:t.confirm===!0,...n===!0?{readOnly:!0}:{},...typeof r=="function"?{consent:r}:{},...typeof o=="function"?{precheck:o}:{}}}function Ms(e,t,n){if(Gl(n))try{return Am(n.args)}catch(r){throw new Error(`Command "${e}" of "${t.name}" is opened to the agent, but its arguments cannot be described for the model: `+(r instanceof Error?r.message:String(r)))}}function Qm(e,t,{agent:n,description:r}){n&&!(typeof r=="string"&&r.trim())&&(`${e}${t.name}`,void 0)}var Zm=class{_facts;_owners;_entries=new Map;_list=ce([]);_disposed=!1;_lifetime=new AbortController;constructor(e,t){this._facts=e,this._owners=t}get commands(){return this._list}has(e){return this._entries.has(e)}register(e,t,n,r={},o={}){if(this._disposed)return`${e.name}`,{dispose:()=>{}};const i=Object.keys(t);for(const l of i){const u=this._entries.get(l);if(u&&!u.yieldable)throw new Error(`Command "${l}" is already registered by "${u.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(typeof n[l]!="function")throw new Error(`Command "${l}" of "${e.name}" has no handler.`)}const s=new Map(i.map(l=>[l,o.details?void 0:Ms(l,e,t[l])]));o.details||i.forEach(l=>Qm(l,e,t[l]));const a=i.map(l=>({id:l,owner:e,declaration:t[l],handler:n[l],enabled:r[l]??km(!0),pending:new Set,agent:Gl(t[l]),inputSchema:s.get(l),yieldable:o.yieldable===!0,details:o.details,prepare:o.prepare}));this._detach(i.flatMap(l=>this._entries.get(l)??[])),a.forEach(l=>this._entries.set(l.id,l)),this._publish();let c=!1;return{dispose:()=>{c||(c=!0,this._remove(a))}}}disposeOwner(e){this._remove(Array.from(this._entries.values()).filter(t=>t.owner===e))}disposeAll(){this._disposed=!0,this._remove(Array.from(this._entries.values())),this._lifetime.abort()}get disposed(){return this._disposed}get lifetime(){return this._lifetime.signal}async run(e,t,n){if(this._disposed)return De("unavailable",`Command "${e}" is not available: the editor was destroyed.`);const r=this._entries.get(e);if(!r)return De("notInstalled",`Command "${e}" is not installed in this host.`);if(n.caller==="agent"&&!r.agent)return De("forbidden",`Command "${e}" is not opened to the agent.`);if(!rn(r.declaration.when,Ce(this._facts)??{})||Ce(r.enabled)===!1)return De("unavailable",`Command "${e}" is not available right now.`);const o=n.signal,i=n.nested&&o?.aborted;if(r.details&&!await this._describe(r,i?void 0:o))return o?.aborted&&!i?ue("aborted",`Command "${e}" was cancelled.`):De("unavailable",or);const s=Bl(r.declaration.args,t),a=s instanceof Promise?await kt(()=>s,Jm,i?void 0:o):s;if(!a)return o?.aborted?ue("aborted",`Command "${e}" was cancelled.`):De("unavailable",`Command "${e}": the check of its arguments did not answer in time.`);if(a.ok===!1)return De("invalidArgs",`Command "${e}": ${a.problem}.`);if(this._disposed||this._entries.get(e)!==r)return De("unavailable",`Command "${e}" was removed while its arguments were checked.`);const c=new AbortController,l=new Promise(m=>{c.signal.addEventListener("abort",()=>m(ue("aborted",`Command "${e}" was cancelled.`)),{once:!0})});if(o?.aborted&&!i)return ue("aborted",`Command "${e}" was cancelled before it started.`);const u=()=>c.abort();o?.addEventListener("abort",u,{once:!0}),r.pending.add(c);const d={signal:c.signal,caller:n.caller,run:(m,_)=>this.run(m,_,{caller:"plugin",signal:c.signal,nested:!0})};try{return await Promise.race([this._execute(r,a.value,d),l])}finally{o?.removeEventListener("abort",u),r.pending.delete(c)}}visible(e){return Pm([this._list,this._facts],()=>{const t=this._entries.get(e);return t!==void 0&&rn(t.declaration.when,Ce(this._facts)??{})})}enabled(e){return yr(t=>{let n,r;const o=s=>{s!==r&&(r=s,t(s))},i=this._list.watch(()=>{n?.dispose();const s=this._entries.get(e);n=s?s.enabled.watch(o):void 0,s||o(!1)});return{dispose:()=>{i.dispose(),n?.dispose()}}})}declarationArgs(e){return this._entries.get(e)?.declaration.args}undescribed(e){return this._entries.get(e)?.details!==void 0}async described(e,t){const n=this._entries.get(e);return n?.details?this._describe(n,t):!0}prepared(e,t){const n=this._entries.get(e);return n?.prepare?this._prepare(n,n.prepare,t):!0}async _prepare(e,t,n){const r=new AbortController,o=()=>r.abort();n?.aborted&&o(),n?.addEventListener("abort",o,{once:!0}),e.pending.add(r);try{return await kt(()=>t().then(()=>!0),xs,r.signal)===!0}catch{return!1}finally{n?.removeEventListener("abort",o),e.pending.delete(r)}}availableNow(e){const t=this._entries.get(e);return!this._disposed&&t!==void 0&&rn(t.declaration.when,Ce(this._facts)??{})&&Ce(t.enabled)!==!1}info(e){const t=this._entries.get(e);return t&&Ls(t)}asOwner(e,t){const n=this._entries.get(e);return n&&this._owners?this._owners.execute(n.owner,t):t()}_describe(e,t){return kt(()=>{const{details:r}=e;return r&&(e.detailsLoading??=this._loadDetails(e,r))},xs,t).then(()=>e.details===void 0,()=>!1)}async _loadDetails(e,t){try{const n=await t(),r={...e.declaration,...n[e.id]};e.inputSchema=Ms(e.id,e.owner,r),e.declaration=r,e.details=void 0}finally{e.detailsLoading=void 0}}async _execute(e,t,n){try{const r=e.handler,o=()=>r(t,n),i=await(this._owners?this._owners.execute(e.owner,o):o());return Ml(i)?i:pt(i)}catch(r){return ue("internal",r instanceof Error?r.message:String(r))}}_remove(e){this._detach(e)&&this._publish()}_detach(e){let t=!1;for(const n of e)this._entries.get(n.id)===n&&(this._entries.delete(n.id),t=!0),n.pending.forEach(r=>r.abort());return t}_publish(){this._list.set(Array.from(this._entries.values()).map(Ls))}};function Ls(e){const{title:t,icon:n}=e.declaration;return e.info??={id:e.id,owner:e.owner,title:t,get description(){return e.declaration.description},icon:n,agent:e.agent,get inputSchema(){return e.inputSchema}}}var Ns=5e3,Fs=Symbol("timedOut"),eg=class{_willSave=[];_changes=[];_selection=ce(null);get selection(){return this._selection}onWillSave(e,t){return this._add(this._willSave,{owner:e,handler:t})}onDidChange(e,t){return this._add(this._changes,{owner:e,handler:t})}async runWillSave(e){for(const{owner:t,handler:n}of this._willSave.slice()){const r=new AbortController;let o;const i=new Promise(s=>{o=setTimeout(()=>s(Fs),Ns)});try{const s=await Promise.race([Promise.resolve().then(()=>n({...e,signal:r.signal})),i]);if(s===Fs){`${t.name}${Ns}`;continue}if(s&&typeof s=="object"&&typeof s.refuse=="string")return{owner:t.name,message:s.refuse}}catch(s){`${t.name}${s instanceof Error?s.message:String(s)}`}finally{clearTimeout(o),r.abort()}}}emitChange(e){for(const{owner:t,handler:n}of this._changes.slice())try{n(e)}catch(r){`${t.name}${r instanceof Error?r.message:String(r)}`}}disposeOwner(e){for(const t of[this._willSave,this._changes])for(let n=t.length-1;n>=0;n-=1)t[n].owner===e&&t.splice(n,1)}_add(e,t){return e.push(t),{dispose:()=>{const n=e.indexOf(t);n>=0&&e.splice(n,1)}}}},tg=Symbol.for("emailmaker.domView");function ng(e){return typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.$$typeof=="symbol"}function rg(e){return typeof e=="object"&&e!==null&&typeof e[tg]=="function"}var qt=["plugins"],og={toolbar:{kind:"item",groups:["view","collaboration","document","plugins","primary"]},"menu:document":{kind:"item",groups:["document","plugins","access","danger"]},"menu:export":{kind:"item",groups:["formats","plugins","platforms"]},"menu:view":{kind:"item",groups:["preview","plugins","share"]},"menu:save":{kind:"item",groups:qt},statusBar:{kind:"item",groups:["selection","document","plugins","collaboration"]},notices:{kind:"item",groups:qt},sidebar:{kind:"view",groups:["content","collaboration","analysis","plugins","settings"]},dialog:{kind:"view",groups:qt},documentSettings:{kind:"view",groups:qt},inspector:{kind:"view",groups:qt}},$r="plugins";function ig(e,t){const n=e.groups.indexOf(t);return n<0?e.groups.length:n}var sg=Symbol.for("emailmaker.viewHost"),Hr={dispose:()=>{}},ag=class{_deps;apiVersion="1.0";_locations=new Map(Object.entries(og));_items=ce([]);_views=ce([]);_opened=ce([]);_viewById=new Map;_seq=0;_openedKey=0;_disposed=!1;constructor(e){this._deps=e,this._registerCoreCommands()}get opened(){return this._opened}registerLocation(e,t){if(this._locations.has(e))throw new Error(`Location "${e}" is already registered.`);return this._locations.set(e,t),{dispose:()=>{this._locations.get(e)===t&&this._locations.delete(e)}}}addItem(e,t){if(this._skipAfterDispose(e))return Hr;const n=this._itemLocation(t.location,"item",e);if(!n)return Hr;const r={seq:this._nextSeq(),owner:e,location:t.location,group:this._groupOf(n,t.group,t.location),order:t.order??0,item:t};return this._items.set([...this._items.get()??[],r]),{dispose:()=>this._removeItems(o=>o===r)}}addViews(e,t,n,r){if(this._skipAfterDispose(e))return Hr;const o=Object.keys(t);for(const s of o){const a=this._viewById.get(s);if(a)throw new Error(`View "${s}" is already registered by "${a.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(!ng(n[s])&&!rg(n[s]))throw new Error(`View "${s}" of "${e.name}" has no component; pass a React component or domView(renderer).`)}const i=[];for(const s of o){const a=t[s],c=this._itemLocation(a.location,"view",e);if(c){const l=this._groupOf(c,a.group,a.location);i.push({seq:this._nextSeq(),id:s,owner:e,location:a.location,group:l,order:a.order??0,declaration:a,renderer:n[s],editor:r})}}return i.forEach(s=>this._viewById.set(s.id,s)),this._views.set([...this._views.get()??[],...i]),{dispose:()=>this._removeViews(s=>i.includes(s))}}open(e,t){if(this._disposed)return Promise.resolve(ue("cancelled",`View "${e}" cannot open: the editor was destroyed.`));if(Ce(this._deps.facts)?.headless)return Promise.resolve(De("unavailable",`View "${e}" cannot open: the editor has no interface.`));const n=this._viewById.get(e);if(!n)return Promise.resolve(De("notInstalled",`View "${e}" is not installed in this host.`));const r=wm(n.declaration.input,t,"input");if(r)return Promise.resolve(De("invalidArgs",`View "${e}": ${r}.`));const o=n.location==="inspector"?this._inspectedElement():void 0;return n.location==="inspector"&&!o?Promise.resolve(De("unavailable",`View "${e}" cannot open: no element is selected.`)):(this.close(e),new Promise(i=>{const s=new AbortController;let a=!1;const c=m=>{if(!a){a=!0;try{this._opened.set((this._opened.get()??[]).filter(_=>_!==d))}finally{o?.dispose(),s.abort(),i(m)}}},l=m=>c(pt(m)),u={input:t,signal:s.signal,close:l};o&&Object.defineProperty(u,"element",{value:o.element,enumerable:!0}),Object.defineProperty(u,sg,{value:this._viewHost(n)});const d={key:this._openedKey+=1,view:e,owner:n.owner,location:n.location,input:t,record:n,renderer:n.renderer,signal:s.signal,context:u,close:l,cancel:()=>c(ue("cancelled",`View "${e}" was closed without a result.`))};this._opened.set([...this._opened.get()??[],d])}))}_inspectedElement(){const e=this._deps.selection,t=e?Ce(e):void 0;if(!e||t==null)return;const n=ce(t),r=e.watch(o=>{o!=null&&n.set(o)});return{element:n,dispose:()=>r.dispose()}}viewLocation(e){return this._viewById.get(e)?.location}close(e){(this._opened.get()??[]).filter(t=>t.view===e).forEach(t=>t.cancel())}items(e){return this._items.select(t=>this._sorted(t,e))}get allViews(){return this._views}views(e){return this._views.select(t=>this._sorted(t,e))}disposeOwner(e){Ae("items",()=>this._removeItems(t=>t.owner===e)),Ae("views",()=>this._removeViews(t=>t.owner===e))}disposeAll(){this._disposed=!0,Ae("items",()=>this._removeItems(()=>!0)),Ae("views",()=>this._removeViews(()=>!0))}supports(e,t){switch(e){case"service":return t==="Commands"||t==="Ui"||t==="Agent"||t==="Document";case"location":return this._locations.has(t);case"command":return this._deps.commands.has(t);case"view":return this._viewById.has(t)}}_sorted(e,t){const n=this._locations.get(t),r=o=>n?ig(n,o.group):0;return e.filter(o=>o.location===t).sort((o,i)=>r(o)-r(i)||o.order-i.order||o.seq-i.seq)}_itemLocation(e,t,n){const r=this._locations.get(e);if(!r)`${n.name}${e}`;else if(r.kind!==t){`${n.name}`,`${e}${r.kind}`;return}return r}_groupOf(e,t,n){return t===void 0?$r:e.groups.includes(t)?t:(`${n}${t}${$r}`,$r)}_nextSeq(){return this._seq+=1,this._seq}_removeItems(e){const t=this._items.get()??[];t.some(e)&&this._items.set(t.filter(n=>!e(n)))}_removeViews(e){const t=this._views.get()??[],n=t.filter(e);if(n.length!==0){n.forEach(r=>this._viewById.delete(r.id));try{this._views.set(t.filter(r=>!e(r)))}finally{(this._opened.get()??[]).filter(r=>n.includes(r.record)).forEach(r=>Ae(`close ${r.view}`,()=>r.cancel()))}}}_skipAfterDispose(e){return this._disposed&&(`${e.name}`,void 0),this._disposed}_viewHost(e){return{run:(t,n)=>this._deps.commands.run(t,n,{caller:"ui"}),editor:e.editor}}_registerCoreCommands(){this._deps.commands.register(ht,{"ui.openView":{title:"Open view",description:"Opens a plugin view by id and waits for its output; a dialog resolves when the user closes it.",args:Pn.object({view:Pn.string()}),agent:!0},"ui.closeView":{title:"Close view",description:"Closes an open view by id.",args:Pn.object({view:Pn.string()}),agent:!0}},{"ui.openView":e=>this.open(e.view,e.input),"ui.closeView":e=>(this.close(e.view),pt())})}};function cg(){return ce({})}function Wt(e,t){const n=e.get()??{};Object.keys(t).some(r=>n[r]!==t[r])&&e.set({...n,...t})}var lg=class{_depth=0;_host;_open;connect(e){return this._host=e,{dispose:()=>{this._host===e&&(this._host=void 0)}}}get grouping(){return this._depth>0}get answers(){return this._host?.answers}async group(e){this._enter();try{return await e()}finally{this._leave()}}reopen(){this._depth>0&&this._open?.begin()}_enter(){this._depth+=1,this._depth===1&&(this._open=this._host,this._open?.begin())}_leave(){if(this._depth-=1,this._depth===0){const e=this._open;this._open=void 0,e?.end()}}},ug=U("platform.ownerTracker"),dg=U("platform.whenFacts"),fg=U("platform.commandRegistry"),pg=U("platform.uiService"),hg=U("platform.editHistory"),mg=U("platform.agentConfig"),gg=U("platform.agentService"),vg=U("platform.documentEvents");function mt(e){return e.getOrCreateInstance(ug,()=>{const t=new Om;return t.onUnload(n=>{Ae("commands",()=>je(e).disposeOwner(n)),Ae("ui",()=>Er(e).disposeOwner(n)),Ae("document",()=>Ye(e).disposeOwner(n))}),t})}function $t(e){return e.getOrCreateInstance(dg,cg)}function Ti(e){return e.getOrCreateInstance(hg,()=>new lg)}function bg(e){const{isDisposed:t}=e;return typeof t=="function"&&t.call(e)}function ql(e){return e.getOrCreateInstance(fg,()=>new Zm($t(e),mt(e)))}function _g(e){return e.getOrCreateInstance(pg,()=>(mt(e),new ag({commands:ql(e),facts:$t(e),selection:Ye(e).selection})))}function Wl(e){const t=ql(e),n=_g(e);return!t.disposed&&bg(e)&&(Ae("ui",()=>n.disposeAll()),Ae("commands",()=>t.disposeAll())),{registry:t,ui:n}}function je(e){return Wl(e).registry}function Er(e){return Wl(e).ui}function zl(e){return e.getOrCreateInstance(mg,()=>ce({}))}function xn(e){return e.getOrCreateInstance(gg,()=>new Ym({commands:je(e),history:Ti(e),config:zl(e),facts:$t(e)}))}function Ye(e){return e.getOrCreateInstance(vg,()=>new eg)}function yg(e){return async(t,n)=>{const r=ee(n)?"block":"email";return(await Ye(e).runWillSave({kind:r,id:t.id==null?null:String(t.id),content:t.html??""}))?.message}}var Kl=U("CurrentUser"),Yl={};function Ai(e){return e.getOrCreateInstance(Kl,()=>ce(Yl))}function Xl(e){return e?.getInstance(Kl)?.get()??Yl}var Jl=U("HeadlessMode");function Ci(e){return e.getOrCreateInstance(Jl,()=>ce(!1))}function Eg(e){return e?.getInstance(Jl)?.get()??!1}var wg=U("HiddenMount");function Sg(e){return e.getOrCreateInstance(wg,()=>ce(!1))}function Ig(e){if(!e)return!1;try{return!!ri(e).data?.act_as}catch{return!1}}function Tg(e){return Ig(e?.getInstance(Tc)?.get(Af.em_token))}var Ag="SAVE_BUTTON",Cg="AUTOSAVE",Rg=Symbol.for("emailmaker.saveNotified"),Og=U("helpers.saveListeners");function kg(e,t="email"){return(e.getInstance(Og)?.[t]??0)>0}function Ql(e){return e?.getInstance(ge)?.get()??{}}function wr(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Pg(e,t){return t.modeDefaults(wr(e,t.fallbackMode))}function Zl(e,t){const n=wr(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function eu(e,t){const n=wr(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function Dg(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function xg(e){return rf(e.map(t=>t?.resourceProxy))}function Mg(e){return cf(e.map(t=>t?.resourceProxyPolicy))}function Lg(e){return Zd(e.map(t=>t?.backendProxy))}function Ng(e){return Cc(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Fg(e,t){return[e.base,Pg(e,t),e.profile,e.serverSide,Zl(e,t.fallbackMode),e.local,e.user,eu(e,t.fallbackMode)]}function Vr(e,t){const n=Fg(e,t),r=Cc(n),o=Dg(n);o!==void 0&&(r.fileManager=o);const i=xg(n);i!==void 0&&(r.resourceProxy=i);const s=Mg(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=Lg(n);a!==void 0&&(r.backendProxy=a);const c=Ng(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function Bg(e,t,n){const r=Zl(e,n),o=eu(e,n);return Vf([o,e.user,r,e.serverSide],t)}var jg=1.5;function Ug(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=jg*e.autosaveTimeoutMs?"none":"revision"}var $g=1e4;function Hg(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,i=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const c=h=>a!==void 0&&a.version===h.get().version?i()-a.failuresAtStart:0,l=h=>{const f=c(h);if(f<=0)return!1;const p=n().retryMaxAttempts??5;return!s()||f>p},u=()=>{const{autosaveTimeoutMs:h,retryIntervalMs:f}=n(),p=t();return p!==void 0&&c(p)>0&&f!==void 0&&f>0?f:p?.isNew()?$g:h},d=h=>h.isNew()&&i()>=3,m=()=>{const h=t();if(!h||h.isDisposed()||l(h))return"none";const{latestRevisionAt:f,snapshotVersion:p,...b}=n(),x=Date.now(),N=Ug({...b,isDirty:h.isDirty(),isNew:h.isNew(),isReady:h.isReady(),latestRevisionAgeMs:f!=null&&f<=x?x-f:void 0,isSnapshotSent:p!=null&&p===h.get().version});return N==="create"&&d(h)?"none":N},_=()=>{const h=t();if(!h||h.isDisposed()||d(h)||l(h)||n().isHeadless)return!1;if(!h.isDirty())return h.isNew();const{snapshotVersion:f}=n();return!(f!=null&&f===h.get().version)};let v,E=0,y=0,k,C,F,T=!1;const R=()=>{k=void 0;const h=t();if(!h||h.isDisposed())return;if(h.get().docId!==v){A();return}const f=m();f!=="none"&&a?.version!==h.get().version&&(a={version:h.get().version,failuresAtStart:i()}),f==="create"?r():f==="revision"?o():_()&&(v=h.get().docId,E=u(),y=i(),k=setTimeout(R,E))},A=()=>{const h=t();if(T||!h)return;const f=a?.version===h.get().version&&y!==i();k!==void 0&&(E!==u()||f)&&(clearTimeout(k),k=void 0),!(k!==void 0||m()==="none"&&!_())&&(v=h.get().docId,E=u(),y=i(),k=setTimeout(R,E))},D=h=>{const f=t();h.source==="user"?a=void 0:a&&f&&(a.version=f.get().version),h.source==="user"&&k!==void 0&&(clearTimeout(k),k=void 0),A()},O=()=>{const h=t();h!==C&&(F?.(),C=h,a=void 0,F=h?.subscribe(D),k!==void 0&&(clearTimeout(k),k=void 0))};return O(),A(),{refresh:()=>{T||(O(),A())},stop:()=>{T=!0,F?.(),F=void 0,C=void 0,k!==void 0&&(clearTimeout(k),k=void 0)}}}var tu=U("documentSession.autosaveUiFacts"),nu={isUserBusy:!1,saveContext:{}};function Vg(e){return e.getOrCreateInstance(tu,()=>ce(nu))}function Co(e){return e?.getInstance(tu)?.get()??nu}function ru(e){return Co(e).saveContext.fallbackTitle||"Untitled email."}var Gg=1e4,qg=3e4;function Wg(e,t){const n=m=>{const _=e.getInstance(ge)?.layers?.(),v=_?Bg(_,m):void 0;return typeof v=="number"&&v>=0?v:void 0};let r;const o=m=>{const{error:_,failures:v}=t.saveState();return gl(_)?(r?.failures!==v&&(r={failures:v,saved:m??null}),r.saved===(m??null)):(r=void 0,!1)},i=()=>{const m=t.current(),_=m?.get().serverId??void 0,v=ee(t.sessionKey()),E=t.recoveryFacts(),y=E?.emailId===_?E:void 0,k=t.revisionFacts(),C=y?.latestRevisionAt,F=k?.lastRevisionAt,T=Xl(e).profile;return{isInited:v||m?.get().attributes.is_inited===!0,isEnabled:!!T?.autosaves&&!Tg(e)&&!o(m?.get().savedVersion),isHistoryLoaded:y?.historyLoaded===!0,isUserBusy:Co(e).isUserBusy,isHeadless:Eg(e),autosaveTimeoutMs:Ql(e).autosaveTimeout||Gg,latestRevisionAt:C!==void 0||F!==void 0?Math.max(C??0,F??0):void 0,snapshotVersion:k?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??qg,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},s=()=>{const m=Co(e).saveContext;return{...m,project:m.project??t.current()?.get().attributes.project,fallbackTitle:ru(e)}},a=Hg({readDocument:()=>t.current(),readEnvironment:i,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>wh(t.saveState().error),onCreate:()=>{ee(t.sessionKey())||t.save("materialize",{...s(),source:Cg})},onRevision:()=>{t.save("snapshot",{project:s().project})}}),c=t.subscribe(()=>{o(t.current()?.get().savedVersion),a.refresh()}),l=Ai(e).watch(()=>a.refresh()),u=Vg(e).watch(()=>a.refresh()),d=Ci(e).watch(()=>a.refresh());return()=>{c(),l.dispose(),u.dispose(),d.dispose(),a.stop()}}var Bs=12e3;function ye(e){return e.getOrCreateInstance(jt,()=>{const t=Xh({resolveAdapters:(r,o)=>Yg(r,e,o),resolveWritePort:()=>ou(e),resolveHistoryPort:r=>ee(r)?su(e):iu(e),resolveTerms:()=>rm(e),canEdit:r=>jc(e,r),notifyBeforeSave:Ap(e),confirmPublish:yg(e),awaitCanvasSynced:Dp(e),savedEchoForm:r=>{const o=Ze(e);return o.toEditorForm(o.toOutputForm(r))},queuesOutsideWrites:r=>ee(r)&&(Fp()||Ut(e)),timeoutMs:Bs,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const i=Qh(o),s=Jh(o);dn(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(i),network_failure:String(s)},level:i||s?"warning":"error"})},onTimeout:r=>{}}),n=Wg(e,t);return e.getInstance(Y)?.addDispose(n),t})}function Re(e){return e?.getInstance(jt)}function ou(e){const t=em(e);return t?Sr(e)?Em(t,ft(e).email(e),Ut(e)?{knownRevisions:Lt(e),uncertainWrites:wn(e)}:void 0):t:ft(e).email(e)}function zg(e){return Cl(e)!==void 0||Il(e)}function iu(e){const t=Cl(e);return t?Sr(e)?(ae("port:history:server-backed"),Pl(t,ft(e).history(e),{knownRevisions:Lt(e),uncertainWrites:wn(e),synchronousHistory:Ut(e)})):(ae("port:history:integrator"),t):(ae("port:history:rest (порт не зарегистрирован)"),ft(e).history(e))}function su(e){const t=Al(e);return t?Sr(e)?(ae("port:block-history:server-backed"),Pl(t,ft(e).blockHistory(e),{pendingKey:mi,knownRevisions:Lt(e),uncertainWrites:wn(e),synchronousHistory:Ut(e)})):(ae("port:block-history:integrator"),t):(ae("port:block-history:rest (порт не зарегистрирован)"),ft(e).blockHistory(e))}function Kg(e){return Al(e)!==void 0||Il(e)}function Sr(e){return Fc(e)}function Yg({email:e,patch:t,serverId:n,key:r},o,i){const s=[];e?s.push({id:"rest",load:()=>_l(e),required:!0}):n&&s.push(Zh(ou(o),n)),t&&s.push({id:"plugin",load:()=>yl(t)});const a=ee(r);return Mp(n)&&(a?Kg(o):zg(o))&&s.push(hm({port:a?su(o):iu(o),revisionServiceEnabled:Sr(o),pendingKey:Zc(n,a),historyIsSynchronous:Ut(o),emailId:n,wpId:()=>i.readWpId(),readShownContent:()=>i.readShownContent(),onFacts:c=>i.publishRecoveryFacts(c)})),s}function Xg(e){const t=ye(e),n=fe(e).addListener(K.APPLICATION_HAS_AMP,r=>{Ct(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(Y)?.addDispose(()=>n.dispose())}function Jg(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Qg(e){const t=e.fetchImpl??((i,s)=>fetch(i,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=i=>{try{const s=new URL(i,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:o,async load(i){if(!o(i))return;const s=!r.has(i);r.add(i);try{const a=await t(i,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return Jg(c)?c:void 0}catch{return}}}}var ut={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Zg(e){const t={maxBytes:e.maxBytes??ut.maxBytes,maxImageBytes:e.maxImageBytes??ut.maxImageBytes,ttlMs:e.ttlMs??ut.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,i={hits:0,loads:0,failures:0};let s=0;const a=d=>{const m=r.get(d);m&&(s-=m.bytes,r.delete(d))},c=d=>t.ttlMs<=0||n()-d.storedAt<t.ttlMs,l=()=>{if(s<=t.maxBytes)return;const d=[...r.entries()].sort((m,_)=>m[1].usedAt-_[1].usedAt);for(const[m]of d){if(s<=t.maxBytes)return;a(m)}},u=(d,m)=>{m.size>t.maxImageBytes||(r.set(d,{blob:m,bytes:m.size,storedAt:n(),usedAt:n()}),s+=m.size,l())};return{async get(d){const m=r.get(d);if(m&&c(m))return m.usedAt=n(),i.hits+=1,m.blob;m&&a(d);const _=o.get(d);if(_!==void 0)return _;i.loads+=1;const v=(async()=>{try{const E=await e.load(d);return E?u(d,E):i.failures+=1,E}catch{i.failures+=1;return}finally{o.delete(d)}})();return o.set(d,v),v},forget(d){a(d),o.delete(d)},configure(d){Object.assign(t,{maxBytes:d.maxBytes??t.maxBytes,maxImageBytes:d.maxImageBytes??t.maxImageBytes,ttlMs:d.ttlMs??t.ttlMs});for(const[m,_]of r)_.bytes>t.maxImageBytes&&a(m);l()},clear(){r.clear(),o.clear(),s=0},stats(){return{entries:r.size,bytes:s,...i}}}}var ev=["emcdn.ru","scr.emcdn.ru"];function tv(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 nv(e,t){const n=(r,o)=>{const i=new Set(o?t:[]);for(const s of r){const a=tv(s);a&&i.add(a)}return[...i]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function rv(e){const t=e??{},n=t.isPlugin!==!0?ev:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...ut};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:nv(o.sourceHosts,n),maxBytes:o.maxBytes??ut.maxBytes,maxImageBytes:o.maxImageBytes??ut.maxImageBytes,ttlMs:o.ttlMs??ut.ttlMs}}function ov(e){const t=fe(e),n=e.getInstance(ge),r=()=>rv({...n?.get(),isPlugin:!0});let o=r();const i=Qg({sourceHosts:()=>o.sourceHosts}),s=Zg({load:E=>i.load(E),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(K.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},c=t.onInit(()=>a()),l=n?.watch(()=>{const E=r(),y=JSON.stringify(E)!==JSON.stringify(o);o=E,s.configure(E),E.enabled||s.clear(),y&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},d=[],m=(E,y)=>(u.refused+=1,d.push({url:E,reason:y}),d.length>20&&d.shift(),{refused:!0}),_=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...u},refusals:[...d],store:s.stats()})}),v=t.addListenerAsync(K.APPLICATION_CANVAS_IMAGE_GET,async E=>{const y=E?.url??"";if(u.asked+=1,!o.enabled||!y)return m(y,"disabled");if(!i.accepts(y))return m(y,"host");E.fresh&&s.forget(y);const k=await s.get(y);return k?(u.served+=1,{blob:k}):m(y,"load-failed")});e.getInstance(Y)?.addDispose(()=>{c.dispose(),l?.dispose(),v.dispose(),s.clear(),delete _.__emmCanvasImages__})}var iv=2e3;function sv(e){const t=fe(e),n=new Map,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;clearTimeout(n.get(s));const a=new MessageChannel;let c=!1,l=!1;const u=m=>{m.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",u),l&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",u),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const d=setTimeout(()=>{n.get(s)===d&&n.delete(s),!(c||!t.hasPort(s,a.port1))&&(dn(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),l=!0,t.holdPort(s))},iv);n.set(s,d)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),i=t.onInit(()=>r());e.getInstance(Y)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);i.dispose(),delete o.__emmCanvasPort__})}var av=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function cv(e){return av.test(e)||e.indexOf("//")===0}function Mn(e){return e&&(e.endsWith("/")?e:`${e}/`)}function lv(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function js(e,t){const n=e==null||e===""?"./":String(e);if(cv(n))return Mn(n);const r=t??lv();if(!r)return Mn(n);try{return Mn(new URL(n,r).href)}catch{return Mn(n)}}function uv(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?js(window.__useblocks__.publicPath):js("/")}var dv=()=>"",fv=()=>"5751e42b";function pv(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function au(e){const t=e?"iframe-eblock":"iframe",n=dv();if(n){const i=pv(n,window.location).replace(/\/?$/,"/");return rs(`${i}${t}.html`,ln())}const r=fv(),o=`${uv().replace(/\/?$/,"/")}iframe/`;return rs(`${o}${t}${r?`.${r}`:""}.html`,ln())}var Us="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Ro(e){return/^file:/i.test(String(e||"").trim())}function hv(e){return Ro(e)?`${Us} allow-same-origin`:Us}var mv="em:module-body-ack";function gv(e,t,n){try{const r=new URL("./",new URL(t,n)).href,o=new URL(e,r).href;return o.startsWith(r)?o:void 0}catch{return}}function Ri(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function vv(e){const t=Ri(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function bv(e,t){const n=Ri(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function _v(e,t){const n=Ri(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),i=[r],s=[];for(;i.length>0;)for(const a of e[i.shift()]??[])o.has(a)||(o.add(a),s.push(a),i.push(a));return s}var yv=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Ev(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&yv.test(t[t.length-2])}async function wv(e,t){const n=Ev(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function Sv(e){const t=new Map,n=(r,o)=>{const i=gv(r,e.canvasSrc,e.origin);if(!i)return;const s=t.get(i);if(s!==void 0)return s;const a=e.fetchBody(i,o);return t.set(i,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const i of r)n(i,o)},reset(){t.clear()},get size(){return t.size}}}var $e;function Iv(e){try{return Ro(new URL(e,window.location.href).href)}catch{return Ro(window.location.href)}}function cu(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__useblocks__<"u"&&window.__useblocks__?.preload?.canvasCrossOrigin===!0}var Tv=()=>Promise.resolve(void 0);function lu(){const e=au(!1);if(!Iv(e)){if(!$e||$e.canvasSrc!==e){const t=cu(e)?wv:Tv;$e={canvasSrc:e,store:Sv({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return $e.store}}async function Av(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const o=await r.json();t(bv(o,e))}catch{}}function Oi(e){const t=lu();if(!t||!$e||$e.warmed||!cu($e.canvasSrc))return;$e.warmed=!0;const{canvasSrc:n}=$e,r=vv(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.BpDXO-hq.js"],"js/iframe.js":["js/elMarkupHelper.BpDXO-hq.js"],"js/darkreader.CyLMh7_H.js":[],"js/elMarkupHelper.BpDXO-hq.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.CGEpDoct.js":[]};o?t.warm(_v(o,n),e):Av(n,i=>t.warm(i,e))}function Cv(e){const t=lu();if(!t)return;Oi();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const i=r.source;i&&(i.postMessage({operationId:mv,for:o.result},"*"),t.take(o.data?.url??"").then(s=>{i.postMessage({operationId:o.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(Y)?.addDispose(()=>{window.removeEventListener("message",n)})}var Rt=/<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,Rv=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Nt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,$s=/display:\s*none\s*!important/gi,Ov="data-darkreader-",kv=/<(script|style)\b[\s\S]*?<\/\1\s*>|<[a-z][^\s<>]*(?:"[^"]*"|'[^']*'|[^<>"'])*?\sdata-darkreader-(?:"[^"]*"|'[^']*'|[^<>"'])*>/gi,Pv=/\sdata-darkreader-[a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?/gi,Dv=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,xv=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Mv=/height\s*:\s*100%\s*!important/i,Lv=[".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 Nv(e){return $s.lastIndex=0,(e.match($s)||[]).length}function uu(e){const t=e.trim(),n=Nv(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=Lv.filter(o=>t.includes(o)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function Fv(e){Nt.lastIndex=0;for(const t of e.matchAll(Nt))if(uu(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Bv(e){let t=!1;return Nt.lastIndex=0,{html:e.replace(Nt,n=>uu(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function jv(e){return Rt.lastIndex=0,Rt.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Fv(e)}function Uv(e){return e.toLowerCase().includes(Ov)?e.replace(kv,(t,n)=>n?t:t.replace(Pv,"")):e}function $v(e){const t=Uv(e);if(!jv(t))return{html:t,found:!1};let n=!1,r=t;Rt.lastIndex=0,Rt.test(r)&&(Rt.lastIndex=0,r=r.replace(Rt,""),n=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(r)||/\sdata-bis-config\s*=/.test(r))&&(r=r.replace(Rv,""),n=!0);const o=Bv(r);return r=o.html,n=n||o.found,{html:r,found:n}}function Hv(e){return!e||!Mv.test(e)?e:(Nt.lastIndex=0,e.replace(Nt,t=>t.replace(Dv,(n,r,o,i)=>`${r}${o.replace(xv,"")}${i}`)))}function du(e){const t=$v(e.replaceAll(`\r
1002
+ `)}function vr(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function fn(e,t){return Gs(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function mv(e,t,n){const{latest:r}=e,o=ir(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(s=>ir(s,r.html))?o?{revision:null,phase:"normal"}:{revision:vr(t),phase:"timeout"}:o?{revision:fn(e),phase:"normal"}:ir(t.html,r.html)?{revision:vr(t),phase:"found"}:{revision:fn(e),phase:"normal"}}function gv({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:o=!1,readShownContent:s,onFacts:i,onLate:a,onError:c,pageLoadTs:l=hv()}){const u=r??e;let d=null,f=!1,v=!1,g=0,y={emailId:e,historyLoaded:!1,isRecovering:!1},E=null;const P=new Promise(I=>{E=I}),O=I=>{y={...y,...I},i(y)};let x;const w=I=>{g+=1,O({applied:{phase:I,seq:g}})},C=()=>{d?.timer&&clearTimeout(d.timer),d=null},T=I=>{if(!v){if(E){const S=E;E=null,S(I),x=I.revision?I.phase:void 0;return}a(I)&&I.revision&&w(I.phase)}},D=()=>{if(!d||v)return;const I=d.phase==="fast",S=I?lv:fv,N=I?dv:pv;d.timer=setTimeout(()=>{const j=d;if(!(!j||v)){if(j.attempts+=1,h(),I&&j.attempts>=N){const{pending:W}=j;lt(u),O({isRecovering:!1}),T({revision:vr(W),phase:"timeout"}),f=!0,j.phase="bg",j.attempts=0,D();return}if(!I&&j.attempts>=N){lt(u),C(),O({isRecovering:!1}),f=!0;return}D()}},S),d.timer.unref?.()},R=I=>{d={phase:"fast",attempts:0,pending:I,timer:null},O({isRecovering:!0}),D()},m=I=>{if(v)return;if(O({historyLoaded:!0,latestRevisionAt:I.latestAt!==void 0&&Number.isFinite(I.latestAt)?I.latestAt:void 0}),n&&d){const j=fn(I,d.pending.sentAt);if(!j)return;const W=d.phase==="fast"?"found":"bg";lt(u),C(),O({isRecovering:!1}),f=!0,T({revision:j,phase:W});return}if(f)return;const S=n?xr(u):null,N=S&&(S.sentAt<l||!ir(S.html,s()))?S:null;if(N){if(o&&(N.baseRevisionId!==void 0||N.baseOpen)){lt(u),f=!0,T(mv(I,N,s()));return}const j=fn(I,N.sentAt);if(j){lt(u),f=!0,T({revision:j,phase:"found"});return}if(o){if(lt(u),f=!0,I.latestAt!==void 0&&I.latestAt>N.sentAt+5e3){T({revision:null,phase:"normal"});return}T({revision:vr(N),phase:"timeout"});return}R(N);return}f=!0,T({revision:fn(I),phase:"normal"})},p=I=>{v||(c?.(I),y.historyLoaded||(O({historyLoaded:!1,latestRevisionAt:void 0}),F()),!d&&T({revision:null,phase:"normal"}))},h=()=>t(e).then(m).catch(p);let b,L=!1;const F=()=>{L||d||v||(L=!0,b=setTimeout(()=>{b=void 0,!v&&!y.historyLoaded&&h()},uv))};return h(),{verdict:()=>P,confirmVerdict(I){const S=x;x=void 0,I&&S!==void 0&&!v&&w(S)},dispose(){v=!0,b!==void 0&&(clearTimeout(b),b=void 0),C()}}}function vv({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:o,wpId:s,readShownContent:i,onFacts:a}){let c=null;const l=gv({emailId:o,readAutosave:u=>s?e.readAutosave(u,{wpId:s()}):e.readAutosave(u),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:i,onFacts:a,onLate:({revision:u,phase:d})=>{const f=sa(u);return c?.(f)??!1},onError:u=>{u instanceof Error&&u.message}});return{id:"recovery",load:()=>l.verdict().then(({revision:u})=>sa(u)),loaded(u){l.confirmVerdict(u)},watch(u){return c=u,()=>{c=null,l.dispose()}}}}var _v=5e3,bv=B("plugin.knownRevisions");function $t(e){return e.getOrCreateInstance(bv,()=>new Map)}function Ks(e,t,n,r){const o=n?.get(t)??[],s=o.filter(i=>i!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...o.length>Fu?{baseOpen:!0}:s.length?{baseHtmls:s}:{}}}var yv=B("plugin.uncertainWrites"),Fu=3;function Ln(e){return e.getOrCreateInstance(yv,()=>new Map)}function Ev(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>Fu||e.set(t,[...r,n])}function Bu(e,t){Bo(e,t)||!t.baseHtmls||Bo(e,{...t,baseHtmls:void 0,baseOpen:!0})}function _r(e,t,n,r=!1){const o=xr(e);!n||o?.sentAt!==t||!(r||o.baseOpen||o.baseHtmls)||Bo(e,{...o,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function ju(e,t,n,r){(xr(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||Bu(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var wv=/(?:Z|[+-]\d{2}:?\d{2})$/i;function Sv(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",o=wv.test(r)?Date.parse(r):NaN;return!Number.isFinite(o)||o>=t-_v}function Uu(e,t,{pendingKey:n=i=>i,knownRevisions:r=new Map,uncertainWrites:o,synchronousHistory:s=!1}={}){return{readRevisions:(i,a,c)=>t.readRevisions(i,a,c),readRevision:(i,a,c)=>t.readRevision?t.readRevision(i,a,c):Promise.resolve(null),readAutosave:(i,a)=>t.readAutosave(i,a),async saveAutosave(i,a,c){const l=n(i),u=Date.now();Bu(l,{sentAt:u,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...Ks(r,l,o,a.html??"")});const d=await t.saveAutosave(i,a,c),f=d?.id;return Sv(d,u)?_r(l,u,f):f&&s&&(d.isAutosave===!0?$s(l,u):_r(l,u,f,!0)),await e.saveAutosave(i,a),d}}}function Iv(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,o){const s=Date.now();n&&ju(r,o,s,Ks(n.knownRevisions,r,n.uncertainWrites,o.html??""));const i=await t.updateEmail(r,o);return n&&_r(r,s,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,o),$s(r,s),i&&{...i,id:r}}}}var $u=Symbol.for("emailmaker.result");function Hu(e){return Object.defineProperty(e,$u,{value:!0})}var vt=(e=>Hu({ok:!0,value:e})),ue=((e,t="")=>Hu({ok:!1,error:{code:e,message:t}}));function Vu(e){return typeof e=="object"&&e!==null&&e[$u]===!0}var ot=e=>({optional:!1,...e}),Gn={string:()=>ot({kind:"string"}),number:()=>ot({kind:"number"}),boolean:()=>ot({kind:"boolean"}),enum:(...e)=>ot({kind:"enum",values:e}),element:(...e)=>ot({kind:"element",kinds:e}),array:e=>ot({kind:"array",item:e}),object:e=>ot({kind:"object",shape:e}),optional:e=>({...e,optional:!0})};function Gu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mr(e,t,n){if(t===void 0)return e.optional?void 0:`"${n}" is required`;switch(e.kind){case"string":case"number":case"boolean":return typeof t===e.kind?void 0:`"${n}" must be a ${e.kind}`;case"enum":return e.values?.includes(t)?void 0:`"${n}" must be one of: ${e.values?.join(", ")}`;case"element":return t!==null&&(typeof t=="object"||typeof t=="string")?void 0:`"${n}" must be an element reference`;case"array":if(!Array.isArray(t))return`"${n}" must be an array`;for(let r=0;r<t.length;r+=1){const o=Mr(e.item,t[r],`${n}[${r}]`);if(o)return o}return;case"object":return Gu(t)?qu(e.shape,t,n):`"${n}" must be an object`}}function qu(e,t,n){for(const[r,o]of Object.entries(e??{})){const s=Mr(o,t[r],n?`${n}.${r}`:r);if(s)return s}}function Av(e,t,n){return e?Mr(e,t,n):void 0}function Tv(e,t){if(!e)return;const n=e;return n.kind!=="object"?Mr(n,t,"arguments"):t!==void 0&&!Gu(t)?"arguments must be an object":qu(n.shape,t??{},"")}function Wu(e){const t=e?.["~standard"];return typeof t=="object"&&t!==null&&typeof t.validate=="function"}function Cv(e){return(e.path??[]).map(t=>String(typeof t=="object"?t.key:t)).join(".")}function zu(e,t){if(!Wu(e)){const n=Tv(e,t);return n?{ok:!1,problem:n}:{ok:!0,value:t??{}}}try{const n=e["~standard"].validate(t??{});return n instanceof Promise?n.then(fa,da):fa(n)}catch(n){return da(n)}}function da(e){return{ok:!1,problem:`the arguments check failed: ${e instanceof Error?e.message:String(e)}`}}function fa(e){if(e.issues){const[t]=e.issues,n=t?Cv(t):"";return{ok:!1,problem:t?n?`"${n}": ${t.message}`:t.message:"arguments are invalid"}}return{ok:!0,value:e.value}}var pa="Element reference returned by element.getTree, element.get or the selection.";function Vo(e){switch(e.kind){case"string":case"number":case"boolean":return{type:e.kind};case"enum":return{type:"string",enum:[...e.values??[]]};case"element":return e.kinds?.length?{type:"string",description:`${pa} Kinds: ${e.kinds.join(", ")}.`}:{type:"string",description:pa};case"array":return{type:"array",items:Vo(e.item)};case"object":{const t=Object.entries(e.shape??{}),n=t.filter(([,r])=>!r.optional).map(([r])=>r);return{type:"object",properties:Object.fromEntries(t.map(([r,o])=>[r,Vo(o)])),...n.length?{required:n}:{}}}}}var Ov={type:"object",properties:{}};function Pv(e){if(!e)return Ov;if(!Wu(e))return Vo(e);const t=e["~standard"].jsonSchema;if(t&&typeof t.input=="function")return t.input({target:"draft-2020-12"});const n=e.toJSONSchema;if(typeof n=="function")return n.call(e);throw new Error(`The ${e["~standard"].vendor} schema cannot export JSON Schema; use a library version with Standard JSON Schema or Arg.object({...}).`)}function Oe(e,t){try{t()}catch{}}var Rv=Symbol.for("emailmaker.platform.hostError"),br="The editor could not load the code of its commands. Trying again does not help: the user has to reload the page.";function Le(e,t){return Object.defineProperty(ue(e,t),Rv,{value:!0})}function Ku(e){const t=globalThis,n=Symbol.for(`emailmaker.platform.owner.${e}`);return t[n]??=Object.freeze({name:e})}var _t=Ku("core"),ha=Ku("unknown"),Xu=Symbol.for("emailmaker.platform.builtInPlugin");function Yu(e){return Symbol.for(`emailmaker.platform.builtInKey.${e}`)}function Xs(e){return Object.entries(e).forEach(([t,n])=>{typeof n=="function"&&(Object.defineProperty(n,Xu,{value:!0}),Object.defineProperty(n,Yu(t),{value:!0}))}),e}function Ju(e,t){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Yu(t))}function Dv(e){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Xu)}function ma(e){return Dv(e.constructor)}var kv=class{_owners=new WeakMap;_stack=[];_listeners=new Set;current(){return this._stack[this._stack.length-1]??ha}execute(e,t){const n=e===_t?ha:e;this._stack.push(n);try{return t()}finally{this._leave(n)}}onUnload(e){return this._listeners.add(e),{dispose:()=>this._listeners.delete(e)}}handle(e){const{plugin:t}=e;if(t)switch(e.type){case"init:enter":case"afterInit:enter":ma(t)||this._stack.push(this._ownerOf(t,e.name));break;case"init:leave":case"afterInit:leave":ma(t)||this._leave(this._ownerOf(t,e.name));break;case"dispose:start":{const n=this._owners.get(t);n&&(this._leave(n),this._owners.delete(t),Array.from(this._listeners).forEach(r=>r(n)));break}}}_ownerOf(e,t){let n=this._owners.get(e);return n||(n={name:t},this._owners.set(e,n)),n}_leave(e){const t=this._stack.lastIndexOf(e);t>=0&&this._stack.splice(t,1)}};function Fr(e){const t={watch:e,select:n=>Fr(r=>{let o=!1,s;return t.watch(i=>{const a=n(i);o&&Object.is(s,a)||(o=!0,s=a,r(a))})})};return t}function xv(e){return Fr(t=>(t(e),{dispose:()=>{}}))}function Lv(e,t){return Fr(n=>{let r=!1,o=!1,s;const i=()=>{if(!r)return;const c=t();o&&Object.is(s,c)||(o=!0,s=c,n(c))},a=e.map(c=>c.watch(i));return r=!0,i(),{dispose:()=>a.forEach(c=>c.dispose())}})}function Pe(e){let t;return e.watch(n=>{t=n}).dispose(),t}function Ft(e,t,n){return new Promise((r,o)=>{const s=()=>r(void 0),i=setTimeout(s,t),a=()=>{clearTimeout(i),n?.removeEventListener("abort",s)};n?.aborted&&s(),n?.addEventListener("abort",s,{once:!0}),Promise.resolve().then(e).then(c=>{a(),r(c)},c=>{a(),o(c)})})}function ge(e,t){return{ok:!1,error:{code:e,message:t}}}function Qt(e){return ge("documentChanged",`"${e}" was not run: another email is open now, not the one this work started on. Stop and tell the user; do not repeat the call.`)}function Nv(e){return ge("aborted",`"${e}" was not run: this tool became another command while the user was asked. Read the tools again and ask the user anew with a new call.`)}function Mv(e,t){return ge("invalidArgs",`Call ${e} ("${t}") needs the user's consent, so its input cannot hold a "$result" reference: the consent window has to show the data. Run the earlier calls first, then send this call in a separate batch with the value written out. No call ran.`)}var pn=e=>ge("aborted",`The call of "${e}" was cancelled.`),yr=e=>e instanceof Error?e.message:String(e);function Fv(){return Object.assign(new Error(br),{code:"unavailable"})}function Bv(){return{code:"undoConflict",message:"An agent call is still running; undo the answer when it ends."}}var jv=64,Uv=/[\w-]+(?:\.[\w-]+)+/g;function It(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,jv)}function qn(e,t){return(e??[]).some(n=>n.endsWith(".*")?t.startsWith(n.slice(0,-1)):n===t)}function Qu(e,t){const n=new Map(t.map(([r,o])=>[o.id,r]));return e.replace(Uv,r=>n.get(r)??r)}var $v=3e3,Hv=12,Vv=e=>typeof e?.label=="string"&&typeof e.value=="string";function Gv(e){const{title:t,details:n}=e??{};if(typeof t!="string"||!t)return;const r=(Array.isArray(n)?n:[]).filter(Vv).slice(0,Hv);return r.length?{title:t,details:r.map(({label:o,value:s})=>({label:o,value:s}))}:{title:t}}async function qv(e,t,n,r){const o=t.agent?.consent;if(o)try{return Gv(await Ft(()=>e.asOwner(t.id,()=>o(n,r)),$v))}catch(s){`${t.id}${yr(s)}`;return}}function Wv(e,t,n,r,o){return{tool:e,command:t.id,title:t.title,description:t.description&&Qu(t.description,o()),input:n,...r?{consent:r}:{},...t.owner===_t?{}:{fromPlugin:!0}}}async function zv({lifetime:e,ask:t,tool:n,signal:r,question:o}){if(r?.aborted||e.aborted)return pn(n);if(!t)return ge("forbidden",`The tool "${n}" needs the user's consent, and there is no one to ask in this editor.`);const s=new AbortController,i=()=>s.abort();r?.addEventListener("abort",i,{once:!0}),e.addEventListener("abort",i,{once:!0});const a=new Promise(l=>{s.signal.addEventListener("abort",()=>l(!1),{once:!0})}),c=async()=>{const l=await o(s.signal);return s.signal.aborted?!1:t({...l,signal:s.signal})};try{const l=await Promise.race([c(),a]);return s.signal.aborted?pn(n):l===!0?void 0:Le("declined",`The user declined "${n}". Do not repeat the call unless the user asks for it again.`)}catch(l){const u=yr(l);return`${n}${u}`,ge("aborted",`The user was not asked about "${n}": ${u}`)}finally{r?.removeEventListener("abort",i),e.removeEventListener("abort",i),s.abort()}}var Go=Symbol("bad input");function ga(e){try{return JSON.stringify(e)}catch{return Go}}var At=e=>e===void 0?void 0:JSON.parse(e);function va(e){if(e===void 0)return null;try{return JSON.parse(JSON.stringify(e))}catch{return"[a value that cannot be serialized]"}}var Pt="agent.batch",Kv=5e3,Xv=5e3,Yv=20,Jv=new Set(["ui.openView","ui.closeView",Pt]),Qv=class{_deps;_confirmHost;_bound;_turnDepth=0;_turnStart;_lastTurn;constructor(e){this._deps=e}setConfirmHost(e){return this._confirmHost=e,{dispose:()=>{this._confirmHost===e&&(this._confirmHost=void 0)}}}get _config(){return Pe(this._deps.config)??{}}get enabled(){return this._config.enabled!==!1}async tools(){const e=await this._describedOpened();return e.map(([t,n])=>({name:t,description:Qu(n.description??n.title,e),inputSchema:n.inputSchema??{type:"object",properties:{}},...this._needsConfirm(n)?{confirm:!0}:{}}))}invoke(e,t,n={}){return this._call(e,t,n)}async openBatch(e,t){const n=this._deps.commands.info(Pt),r=n!==void 0&&this._needsConfirm(n),o=this._openDocument(),s=new Map,i=new Map;for(const[a,c]of e.entries()){const l=this._find(c.tool);if(!l)continue;const[u,d]=l,f=r||this._needsConfirm(d);if(!f&&!d.agent?.precheck)continue;if(c.deferred){if(f)return{ok:!1,error:Mv(a,u).error,index:a};continue}const v=ga(c.input);if(v===Go)continue;const g=await this._checkInput(d,At(v),t);if(!g||g.ok===!1||!this._deps.commands.availableNow(d.id))continue;const y=await this._precheck(u,d,g.value,t);if(y)return{ok:!1,error:y.error,index:a};s.set(a,d),f&&i.set(a,{tool:u,info:d,input:g.value,frozen:v})}if(n&&i.size>0){const a=va(e.map(({tool:l,input:u})=>({tool:l,args:u}))),c=await this._ask(It(Pt),t,async l=>{const u=Array.from(i.values()),d=await Promise.all(u.slice(0,Yv).map(async({tool:v,info:g,input:y,frozen:E})=>this._item(v,g,At(E),await this._consentOf(g,y,l)))),f=await this._consentOf(n,void 0,l);return{...this._item(It(Pt),n,{calls:a},f),batch:{items:d,more:u.length-d.length}}});if(c)return{ok:!1,error:{...c.error,message:`${c.error.message} None of the calls of the batch ran.`}};if(this._openDocument()!==o)return{ok:!1,error:Qt(It(Pt)).error}}return{ok:!0,run:(a,c)=>{const l=i.get(a);return this._call(e[a].tool,l?At(l.frozen):c,{signal:t},{consented:l?.info,prechecked:s.get(a),askAll:r})}}}async _call(e,t,n,r={}){if(!this.enabled)return ge("forbidden","The agent is switched off in this editor.");const o=this._find(e);if(!o)return this._deps.commands.info(e)??(Pe(this._deps.commands.commands)??[]).find(g=>It(g.id)===e)?ge("forbidden",`The tool "${e}" is not opened to the agent here.`):ge("notInstalled",`There is no tool "${e}" in this editor.`);const[s,i]=o,a=ga(t);if(a===Go)return ge("invalidArgs",`Tool "${s}": the input must be plain JSON data.`);const c=await this._checkInput(i,At(a),n.signal);if(!c)return n.signal?.aborted?pn(s):ge("unavailable",this._deps.commands.undescribed(i.id)?br:`The input of the tool "${s}" could not be checked; try again.`);if(c.ok===!1)return ge("invalidArgs",`Tool "${s}": ${c.problem}.`);const l=this._openDocument();if(this._adoptOpened(l),this._bound&&this._bound.document!==l)return Qt(s);if(!this._deps.commands.availableNow(i.id))return ge("unavailable",`The tool "${s}" is not available right now.`);if(r.prechecked!==i&&i.agent?.precheck){const g=await this._precheck(s,i,c.value,n.signal);if(g)return g;if(this._openDocument()!==l)return Qt(s)}let u=r.consented;if(!u&&(r.askAll||this._needsConfirm(i))&&!(i.id===Pt&&i.owner===_t)){const g=await this._ask(s,n.signal,async y=>this._item(s,i,At(a),await this._consentOf(i,c.value,y)));if(g)return g;if(this._openDocument()!==l)return Qt(s);u=i}const d=this._deps.commands.prepared(i.id,n.signal);if(d!==!0){if(!await d)return n.signal?.aborted?pn(s):ge("unavailable",br);const g=this._openDocument();if(this._adoptOpened(g),l!==void 0&&g!==l)return Qt(s)}if(this._find(s)?.[1]!==(u??i))return Nv(s);const f=()=>this._deps.commands.run(i.id,At(a),{caller:"agent",signal:n.signal}),v=await(Jv.has(i.id)||i.agent?.readOnly?f():this._deps.history.group(f));return v.ok===!1?ge(v.error.code,v.error.message||`The tool "${s}" failed: ${v.error.code}.`):{ok:!0,value:va(v.value)}}readOnlyTool(e){return this._find(e)?.[1].agent?.readOnly===!0}get answerOpen(){return this._bound!==void 0}async holdDocument(e){const t=this._bound??={document:this._openDocument(),holders:0};t.holders+=1;try{return await e()}finally{t.holders-=1,t.holders===0&&(this._bound=void 0)}}_adoptOpened(e){this._bound&&this._bound.document===void 0&&e!==void 0&&(this._bound.document=e,this._deps.history.reopen(),this._turnDepth>0&&(this._turnStart=this._deps.history.answers?.capture()))}async turn(e){this._turnDepth===0&&(this._turnStart=this._deps.history.answers?.capture()),this._turnDepth+=1;try{return await this.holdDocument(()=>this._deps.history.group(e))}finally{this._turnDepth-=1,this._turnDepth===0&&(this._lastTurn={start:this._turnStart,end:this._deps.history.answers?.capture()})}}async undoTurn(){if(!this.enabled)return ge("forbidden","The agent is switched off in this editor.");const e=this._deps.history.answers,t=e?.undoRefusal();if(t)return{ok:!1,error:t};const n=this._lastTurn;if(!e||!n)return ge("nothingToUndo","There is no answer to undo.");this._lastTurn=void 0;try{const r=await e.settle()??(this._deps.history.grouping?Bv():e.undo(n.start,n.end));return r?(this._lastTurn??=n,{ok:!1,error:r}):{ok:!0,value:null}}catch(r){this._lastTurn??=n;const o=yr(r);return`${o}`,ge("undoConflict",`The answer could not be undone: ${o}`)}}_needsConfirm(e){const{confirm:t}=this._config;return e.agent?.confirm===!0||qn(t,e.id)||qn(t,It(e.id))}_openDocument(){return this._deps.history.answers?.document()}_find(e){return this._opened().find(([t,n])=>t===e||n.id===e)}_opened(){if(!this.enabled)return[];const e=this._config.deny,t=new Map;for(const n of Pe(this._deps.commands.commands)??[]){const r=It(n.id);if(!n.agent||qn(e,n.id)||qn(e,r))continue;const o=t.get(r);if(o){`${o.id}${n.id}${r}`;continue}t.set(r,n)}return Array.from(t.entries())}async _describedOpened(){const{commands:e}=this._deps;let t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id));for(;n.length>0;){if((await Promise.all(n.map(([,r])=>e.described(r.id)))).includes(!1))throw Fv();t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id))}return t}async _checkInput(e,t,n){const{commands:r}=this._deps;if(r.undescribed(e.id)&&!await r.described(e.id,n))return;const o=zu(this._deps.commands.declarationArgs(e.id),t);return o instanceof Promise?Ft(()=>o,Xv,n):o}async _precheck(e,t,n,r){const o=t.agent?.precheck;if(o){try{const s=await Ft(()=>this._deps.commands.asOwner(t.id,()=>o(n)),Kv,r);if(Vu(s)&&s.ok===!1){const{code:i,message:a}=s.error;return ge(i,a||`The tool "${e}" was refused: ${i}.`)}}catch(s){`${t.id}${yr(s)}`}return r?.aborted?pn(e):void 0}}_consentOf(e,t,n){return qv(this._deps.commands,e,t,n)}_item(e,t,n,r){return Wv(e,t,n,r,()=>this._opened())}_ask(e,t,n){const r=this._config.onConfirm??(Pe(this._deps.facts)?.headless?void 0:this._confirmHost);return zv({lifetime:this._deps.commands.lifetime,ask:r,tool:e,signal:t,question:n})}},Zv={documentOpen:!1,selection:"none",codeMode:!1,readOnly:!1,headless:!1};function hn(e,t){if(!e)return!0;if("any"in e)return e.any.some(r=>hn(r,t));if("not"in e)return!hn(e.not,t);const n={...Zv,...t};return Object.entries(e).every(([r,o])=>n[r]===o)}var e_=5e3,_a=3e4;function Zu(e){const{agent:t}=e;if(!t)return;if(t===!0)return{};const{readOnly:n,consent:r,precheck:o}=t;return{confirm:t.confirm===!0,...n===!0?{readOnly:!0}:{},...typeof r=="function"?{consent:r}:{},...typeof o=="function"?{precheck:o}:{}}}function ba(e,t,n){if(Zu(n))try{return Pv(n.args)}catch(r){throw new Error(`Command "${e}" of "${t.name}" is opened to the agent, but its arguments cannot be described for the model: `+(r instanceof Error?r.message:String(r)))}}function t_(e,t,{agent:n,description:r}){n&&!(typeof r=="string"&&r.trim())&&(`${e}${t.name}`,void 0)}var n_=class{_facts;_owners;_entries=new Map;_list=ae([]);_disposed=!1;_lifetime=new AbortController;constructor(e,t){this._facts=e,this._owners=t}get commands(){return this._list}has(e){return this._entries.has(e)}register(e,t,n,r={},o={}){if(this._disposed)return`${e.name}`,{dispose:()=>{}};const s=Object.keys(t);for(const l of s){const u=this._entries.get(l);if(u&&!u.yieldable)throw new Error(`Command "${l}" is already registered by "${u.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(typeof n[l]!="function")throw new Error(`Command "${l}" of "${e.name}" has no handler.`)}const i=new Map(s.map(l=>[l,o.details?void 0:ba(l,e,t[l])]));o.details||s.forEach(l=>t_(l,e,t[l]));const a=s.map(l=>({id:l,owner:e,declaration:t[l],handler:n[l],enabled:r[l]??xv(!0),pending:new Set,agent:Zu(t[l]),inputSchema:i.get(l),yieldable:o.yieldable===!0,details:o.details,prepare:o.prepare}));this._detach(s.flatMap(l=>this._entries.get(l)??[])),a.forEach(l=>this._entries.set(l.id,l)),this._publish();let c=!1;return{dispose:()=>{c||(c=!0,this._remove(a))}}}disposeOwner(e){this._remove(Array.from(this._entries.values()).filter(t=>t.owner===e))}disposeAll(){this._disposed=!0,this._remove(Array.from(this._entries.values())),this._lifetime.abort()}get disposed(){return this._disposed}get lifetime(){return this._lifetime.signal}async run(e,t,n){if(this._disposed)return Le("unavailable",`Command "${e}" is not available: the editor was destroyed.`);const r=this._entries.get(e);if(!r)return Le("notInstalled",`Command "${e}" is not installed in this host.`);if(n.caller==="agent"&&!r.agent)return Le("forbidden",`Command "${e}" is not opened to the agent.`);if(!hn(r.declaration.when,Pe(this._facts)??{})||Pe(r.enabled)===!1)return Le("unavailable",`Command "${e}" is not available right now.`);const o=n.signal,s=n.nested&&o?.aborted;if(r.details&&!await this._describe(r,s?void 0:o))return o?.aborted&&!s?ue("aborted",`Command "${e}" was cancelled.`):Le("unavailable",br);const i=zu(r.declaration.args,t),a=i instanceof Promise?await Ft(()=>i,e_,s?void 0:o):i;if(!a)return o?.aborted?ue("aborted",`Command "${e}" was cancelled.`):Le("unavailable",`Command "${e}": the check of its arguments did not answer in time.`);if(a.ok===!1)return Le("invalidArgs",`Command "${e}": ${a.problem}.`);if(this._disposed||this._entries.get(e)!==r)return Le("unavailable",`Command "${e}" was removed while its arguments were checked.`);const c=new AbortController,l=new Promise(f=>{c.signal.addEventListener("abort",()=>f(ue("aborted",`Command "${e}" was cancelled.`)),{once:!0})});if(o?.aborted&&!s)return ue("aborted",`Command "${e}" was cancelled before it started.`);const u=()=>c.abort();o?.addEventListener("abort",u,{once:!0}),r.pending.add(c);const d={signal:c.signal,caller:n.caller,run:(f,v)=>this.run(f,v,{caller:"plugin",signal:c.signal,nested:!0})};try{return await Promise.race([this._execute(r,a.value,d),l])}finally{o?.removeEventListener("abort",u),r.pending.delete(c)}}visible(e){return Lv([this._list,this._facts],()=>{const t=this._entries.get(e);return t!==void 0&&hn(t.declaration.when,Pe(this._facts)??{})})}enabled(e){return Fr(t=>{let n,r;const o=i=>{i!==r&&(r=i,t(i))},s=this._list.watch(()=>{n?.dispose();const i=this._entries.get(e);n=i?i.enabled.watch(o):void 0,i||o(!1)});return{dispose:()=>{s.dispose(),n?.dispose()}}})}declarationArgs(e){return this._entries.get(e)?.declaration.args}undescribed(e){return this._entries.get(e)?.details!==void 0}async described(e,t){const n=this._entries.get(e);return n?.details?this._describe(n,t):!0}prepared(e,t){const n=this._entries.get(e);return n?.prepare?this._prepare(n,n.prepare,t):!0}async _prepare(e,t,n){const r=new AbortController,o=()=>r.abort();n?.aborted&&o(),n?.addEventListener("abort",o,{once:!0}),e.pending.add(r);try{return await Ft(()=>t().then(()=>!0),_a,r.signal)===!0}catch{return!1}finally{n?.removeEventListener("abort",o),e.pending.delete(r)}}availableNow(e){const t=this._entries.get(e);return!this._disposed&&t!==void 0&&hn(t.declaration.when,Pe(this._facts)??{})&&Pe(t.enabled)!==!1}info(e){const t=this._entries.get(e);return t&&ya(t)}asOwner(e,t){const n=this._entries.get(e);return n&&this._owners?this._owners.execute(n.owner,t):t()}_describe(e,t){return Ft(()=>{const{details:r}=e;return r&&(e.detailsLoading??=this._loadDetails(e,r))},_a,t).then(()=>e.details===void 0,()=>!1)}async _loadDetails(e,t){try{const n=await t(),r={...e.declaration,...n[e.id]};e.inputSchema=ba(e.id,e.owner,r),e.declaration=r,e.details=void 0}finally{e.detailsLoading=void 0}}async _execute(e,t,n){try{const r=e.handler,o=()=>r(t,n),s=await(this._owners?this._owners.execute(e.owner,o):o());return Vu(s)?s:vt(s)}catch(r){return ue("internal",r instanceof Error?r.message:String(r))}}_remove(e){this._detach(e)&&this._publish()}_detach(e){let t=!1;for(const n of e)this._entries.get(n.id)===n&&(this._entries.delete(n.id),t=!0),n.pending.forEach(r=>r.abort());return t}_publish(){this._list.set(Array.from(this._entries.values()).map(ya))}};function ya(e){const{title:t,icon:n}=e.declaration;return e.info??={id:e.id,owner:e.owner,title:t,get description(){return e.declaration.description},icon:n,agent:e.agent,get inputSchema(){return e.inputSchema}}}var Ea=5e3,wa=Symbol("timedOut"),r_=class{_willSave=[];_changes=[];_selection=ae(null);get selection(){return this._selection}onWillSave(e,t){return this._add(this._willSave,{owner:e,handler:t})}onDidChange(e,t){return this._add(this._changes,{owner:e,handler:t})}async runWillSave(e){for(const{owner:t,handler:n}of this._willSave.slice()){const r=new AbortController;let o;const s=new Promise(i=>{o=setTimeout(()=>i(wa),Ea)});try{const i=await Promise.race([Promise.resolve().then(()=>n({...e,signal:r.signal})),s]);if(i===wa){`${t.name}${Ea}`;continue}if(i&&typeof i=="object"&&typeof i.refuse=="string")return{owner:t.name,message:i.refuse}}catch(i){`${t.name}${i instanceof Error?i.message:String(i)}`}finally{clearTimeout(o),r.abort()}}}emitChange(e){for(const{owner:t,handler:n}of this._changes.slice())try{n(e)}catch(r){`${t.name}${r instanceof Error?r.message:String(r)}`}}disposeOwner(e){for(const t of[this._willSave,this._changes])for(let n=t.length-1;n>=0;n-=1)t[n].owner===e&&t.splice(n,1)}_add(e,t){return e.push(t),{dispose:()=>{const n=e.indexOf(t);n>=0&&e.splice(n,1)}}}},o_=Symbol.for("emailmaker.domView");function s_(e){return typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.$$typeof=="symbol"}function i_(e){return typeof e=="object"&&e!==null&&typeof e[o_]=="function"}var Zt=["plugins"],a_={toolbar:{kind:"item",groups:["view","collaboration","document","plugins","primary"]},"menu:document":{kind:"item",groups:["document","plugins","access","danger"]},"menu:export":{kind:"item",groups:["formats","plugins","platforms"]},"menu:view":{kind:"item",groups:["preview","plugins","share"]},"menu:save":{kind:"item",groups:Zt},statusBar:{kind:"item",groups:["selection","document","plugins","collaboration"]},notices:{kind:"item",groups:Zt},sidebar:{kind:"view",groups:["content","collaboration","analysis","plugins","settings"]},dialog:{kind:"view",groups:Zt},documentSettings:{kind:"view",groups:Zt},inspector:{kind:"view",groups:Zt}},oo="plugins";function c_(e,t){const n=e.groups.indexOf(t);return n<0?e.groups.length:n}var l_=Symbol.for("emailmaker.viewHost"),so={dispose:()=>{}},u_=class{_deps;apiVersion="1.0";_locations=new Map(Object.entries(a_));_items=ae([]);_views=ae([]);_opened=ae([]);_viewById=new Map;_seq=0;_openedKey=0;_disposed=!1;constructor(e){this._deps=e,this._registerCoreCommands()}get opened(){return this._opened}registerLocation(e,t){if(this._locations.has(e))throw new Error(`Location "${e}" is already registered.`);return this._locations.set(e,t),{dispose:()=>{this._locations.get(e)===t&&this._locations.delete(e)}}}addItem(e,t){if(this._skipAfterDispose(e))return so;const n=this._itemLocation(t.location,"item",e);if(!n)return so;const r={seq:this._nextSeq(),owner:e,location:t.location,group:this._groupOf(n,t.group,t.location),order:t.order??0,item:t};return this._items.set([...this._items.get()??[],r]),{dispose:()=>this._removeItems(o=>o===r)}}addViews(e,t,n,r){if(this._skipAfterDispose(e))return so;const o=Object.keys(t);for(const i of o){const a=this._viewById.get(i);if(a)throw new Error(`View "${i}" is already registered by "${a.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(!s_(n[i])&&!i_(n[i]))throw new Error(`View "${i}" of "${e.name}" has no component; pass a React component or domView(renderer).`)}const s=[];for(const i of o){const a=t[i],c=this._itemLocation(a.location,"view",e);if(c){const l=this._groupOf(c,a.group,a.location);s.push({seq:this._nextSeq(),id:i,owner:e,location:a.location,group:l,order:a.order??0,declaration:a,renderer:n[i],editor:r})}}return s.forEach(i=>this._viewById.set(i.id,i)),this._views.set([...this._views.get()??[],...s]),{dispose:()=>this._removeViews(i=>s.includes(i))}}open(e,t){if(this._disposed)return Promise.resolve(ue("cancelled",`View "${e}" cannot open: the editor was destroyed.`));if(Pe(this._deps.facts)?.headless)return Promise.resolve(Le("unavailable",`View "${e}" cannot open: the editor has no interface.`));const n=this._viewById.get(e);if(!n)return Promise.resolve(Le("notInstalled",`View "${e}" is not installed in this host.`));const r=Av(n.declaration.input,t,"input");if(r)return Promise.resolve(Le("invalidArgs",`View "${e}": ${r}.`));const o=n.location==="inspector"?this._inspectedElement():void 0;return n.location==="inspector"&&!o?Promise.resolve(Le("unavailable",`View "${e}" cannot open: no element is selected.`)):(this.close(e),new Promise(s=>{const i=new AbortController;let a=!1;const c=f=>{if(!a){a=!0;try{this._opened.set((this._opened.get()??[]).filter(v=>v!==d))}finally{o?.dispose(),i.abort(),s(f)}}},l=f=>c(vt(f)),u={input:t,signal:i.signal,close:l};o&&Object.defineProperty(u,"element",{value:o.element,enumerable:!0}),Object.defineProperty(u,l_,{value:this._viewHost(n)});const d={key:this._openedKey+=1,view:e,owner:n.owner,location:n.location,input:t,record:n,renderer:n.renderer,signal:i.signal,context:u,close:l,cancel:()=>c(ue("cancelled",`View "${e}" was closed without a result.`))};this._opened.set([...this._opened.get()??[],d])}))}_inspectedElement(){const e=this._deps.selection,t=e?Pe(e):void 0;if(!e||t==null)return;const n=ae(t),r=e.watch(o=>{o!=null&&n.set(o)});return{element:n,dispose:()=>r.dispose()}}viewLocation(e){return this._viewById.get(e)?.location}close(e){(this._opened.get()??[]).filter(t=>t.view===e).forEach(t=>t.cancel())}items(e){return this._items.select(t=>this._sorted(t,e))}get allViews(){return this._views}views(e){return this._views.select(t=>this._sorted(t,e))}disposeOwner(e){Oe("items",()=>this._removeItems(t=>t.owner===e)),Oe("views",()=>this._removeViews(t=>t.owner===e))}disposeAll(){this._disposed=!0,Oe("items",()=>this._removeItems(()=>!0)),Oe("views",()=>this._removeViews(()=>!0))}supports(e,t){switch(e){case"service":return t==="Commands"||t==="Ui"||t==="Agent"||t==="Document";case"location":return this._locations.has(t);case"command":return this._deps.commands.has(t);case"view":return this._viewById.has(t)}}_sorted(e,t){const n=this._locations.get(t),r=o=>n?c_(n,o.group):0;return e.filter(o=>o.location===t).sort((o,s)=>r(o)-r(s)||o.order-s.order||o.seq-s.seq)}_itemLocation(e,t,n){const r=this._locations.get(e);if(!r)`${n.name}${e}`;else if(r.kind!==t){`${n.name}`,`${e}${r.kind}`;return}return r}_groupOf(e,t,n){return t===void 0?oo:e.groups.includes(t)?t:(`${n}${t}${oo}`,oo)}_nextSeq(){return this._seq+=1,this._seq}_removeItems(e){const t=this._items.get()??[];t.some(e)&&this._items.set(t.filter(n=>!e(n)))}_removeViews(e){const t=this._views.get()??[],n=t.filter(e);if(n.length!==0){n.forEach(r=>this._viewById.delete(r.id));try{this._views.set(t.filter(r=>!e(r)))}finally{(this._opened.get()??[]).filter(r=>n.includes(r.record)).forEach(r=>Oe(`close ${r.view}`,()=>r.cancel()))}}}_skipAfterDispose(e){return this._disposed&&(`${e.name}`,void 0),this._disposed}_viewHost(e){return{run:(t,n)=>this._deps.commands.run(t,n,{caller:"ui"}),editor:e.editor}}_registerCoreCommands(){this._deps.commands.register(_t,{"ui.openView":{title:"Open view",description:"Opens a plugin view by id and waits for its output; a dialog resolves when the user closes it.",args:Gn.object({view:Gn.string()}),agent:!0},"ui.closeView":{title:"Close view",description:"Closes an open view by id.",args:Gn.object({view:Gn.string()}),agent:!0}},{"ui.openView":e=>this.open(e.view,e.input),"ui.closeView":e=>(this.close(e.view),vt())})}};function d_(){return ae({})}function en(e,t){const n=e.get()??{};Object.keys(t).some(r=>n[r]!==t[r])&&e.set({...n,...t})}var f_=class{_depth=0;_host;_open;connect(e){return this._host=e,{dispose:()=>{this._host===e&&(this._host=void 0)}}}get grouping(){return this._depth>0}get answers(){return this._host?.answers}async group(e){this._enter();try{return await e()}finally{this._leave()}}reopen(){this._depth>0&&this._open?.begin()}_enter(){this._depth+=1,this._depth===1&&(this._open=this._host,this._open?.begin())}_leave(){if(this._depth-=1,this._depth===0){const e=this._open;this._open=void 0,e?.end()}}},p_=B("platform.ownerTracker"),h_=B("platform.whenFacts"),m_=B("platform.commandRegistry"),g_=B("platform.uiService"),v_=B("platform.editHistory"),__=B("platform.agentConfig"),b_=B("platform.agentService"),y_=B("platform.documentEvents");function bt(e){return e.getOrCreateInstance(p_,()=>{const t=new kv;return t.onUnload(n=>{Oe("commands",()=>Ve(e).disposeOwner(n)),Oe("ui",()=>Br(e).disposeOwner(n)),Oe("document",()=>Ze(e).disposeOwner(n))}),t})}function Xt(e){return e.getOrCreateInstance(h_,d_)}function Ys(e){return e.getOrCreateInstance(v_,()=>new f_)}function E_(e){const{isDisposed:t}=e;return typeof t=="function"&&t.call(e)}function ed(e){return e.getOrCreateInstance(m_,()=>new n_(Xt(e),bt(e)))}function w_(e){return e.getOrCreateInstance(g_,()=>(bt(e),new u_({commands:ed(e),facts:Xt(e),selection:Ze(e).selection})))}function td(e){const t=ed(e),n=w_(e);return!t.disposed&&E_(e)&&(Oe("ui",()=>n.disposeAll()),Oe("commands",()=>t.disposeAll())),{registry:t,ui:n}}function Ve(e){return td(e).registry}function Br(e){return td(e).ui}function nd(e){return e.getOrCreateInstance(__,()=>ae({}))}function Wn(e){return e.getOrCreateInstance(b_,()=>new Qv({commands:Ve(e),history:Ys(e),config:nd(e),facts:Xt(e)}))}function Ze(e){return e.getOrCreateInstance(y_,()=>new r_)}function S_(e){return async(t,n)=>{const r=ee(n)?"block":"email";return(await Ze(e).runWillSave({kind:r,id:t.id==null?null:String(t.id),content:t.html??""}))?.message}}var rd=B("CurrentUser"),od={};function Js(e){return e.getOrCreateInstance(rd,()=>ae(od))}function sd(e){return e?.getInstance(rd)?.get()??od}var id=B("HeadlessMode");function Qs(e){return e.getOrCreateInstance(id,()=>ae(!1))}function I_(e){return e?.getInstance(id)?.get()??!1}var A_=B("HiddenMount");function T_(e){return e.getOrCreateInstance(A_,()=>ae(!1))}function C_(e){if(!e)return!1;try{return!!Ss(e).data?.act_as}catch{return!1}}function O_(e){return C_(e?.getInstance(_l)?.get(hm.em_token))}var P_="SAVE_BUTTON",R_="AUTOSAVE",D_=Symbol.for("emailmaker.saveNotified"),k_=B("helpers.saveListeners");function x_(e,t="email"){return(e.getInstance(k_)?.[t]??0)>0}function ad(e){return e?.getInstance(he)?.get()??{}}function jr(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function L_(e,t){return t.modeDefaults(jr(e,t.fallbackMode))}function cd(e,t){const n=jr(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function ld(e,t){const n=jr(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function N_(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function M_(e){return gh(e.map(t=>t?.resourceProxy))}function F_(e){return Eh(e.map(t=>t?.resourceProxyPolicy))}function B_(e){return vh(e.map(t=>t?.backendProxy))}function j_(e){return Ds(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function U_(e,t){return[e.base,L_(e,t),e.profile,e.serverSide,cd(e,t.fallbackMode),e.local,e.user,ld(e,t.fallbackMode)]}function io(e,t){const n=U_(e,t),r=Ds(n),o=N_(n);o!==void 0&&(r.fileManager=o);const s=M_(n);s!==void 0&&(r.resourceProxy=s);const i=F_(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const a=B_(n);a!==void 0&&(r.backendProxy=a);const c=j_(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function $_(e,t,n){const r=cd(e,n),o=ld(e,n);return ph([o,e.user,r,e.serverSide],t)}var H_=1.5;function V_(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=H_*e.autosaveTimeoutMs?"none":"revision"}var G_=1e4;function q_(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,s=e.readFailures??(()=>0),i=e.readFailureRetryable??(()=>!0);let a;const c=m=>a!==void 0&&a.version===m.get().version?s()-a.failuresAtStart:0,l=m=>{const p=c(m);if(p<=0)return!1;const h=n().retryMaxAttempts??5;return!i()||p>h},u=()=>{const{autosaveTimeoutMs:m,retryIntervalMs:p}=n(),h=t();return h!==void 0&&c(h)>0&&p!==void 0&&p>0?p:h?.isNew()?G_:m},d=m=>m.isNew()&&s()>=3,f=()=>{const m=t();if(!m||m.isDisposed()||l(m))return"none";const{latestRevisionAt:p,snapshotVersion:h,...b}=n(),L=Date.now(),F=V_({...b,isDirty:m.isDirty(),isNew:m.isNew(),isReady:m.isReady(),latestRevisionAgeMs:p!=null&&p<=L?L-p:void 0,isSnapshotSent:h!=null&&h===m.get().version});return F==="create"&&d(m)?"none":F},v=()=>{const m=t();if(!m||m.isDisposed()||d(m)||l(m)||n().isHeadless)return!1;if(!m.isDirty())return m.isNew();const{snapshotVersion:p}=n();return!(p!=null&&p===m.get().version)};let g,y=0,E=0,P,O,x,w=!1;const C=()=>{P=void 0;const m=t();if(!m||m.isDisposed())return;if(m.get().docId!==g){T();return}const p=f();p!=="none"&&a?.version!==m.get().version&&(a={version:m.get().version,failuresAtStart:s()}),p==="create"?r():p==="revision"?o():v()&&(g=m.get().docId,y=u(),E=s(),P=setTimeout(C,y))},T=()=>{const m=t();if(w||!m)return;const p=a?.version===m.get().version&&E!==s();P!==void 0&&(y!==u()||p)&&(clearTimeout(P),P=void 0),!(P!==void 0||f()==="none"&&!v())&&(g=m.get().docId,y=u(),E=s(),P=setTimeout(C,y))},D=m=>{const p=t();m.source==="user"?a=void 0:a&&p&&(a.version=p.get().version),m.source==="user"&&P!==void 0&&(clearTimeout(P),P=void 0),T()},R=()=>{const m=t();m!==O&&(x?.(),O=m,a=void 0,x=m?.subscribe(D),P!==void 0&&(clearTimeout(P),P=void 0))};return R(),T(),{refresh:()=>{w||(R(),T())},stop:()=>{w=!0,x?.(),x=void 0,O=void 0,P!==void 0&&(clearTimeout(P),P=void 0)}}}var ud=B("documentSession.autosaveUiFacts"),dd={isUserBusy:!1,saveContext:{}};function W_(e){return e.getOrCreateInstance(ud,()=>ae(dd))}function qo(e){return e?.getInstance(ud)?.get()??dd}function fd(e){return qo(e).saveContext.fallbackTitle||"Untitled email."}var z_=1e4,K_=3e4;function X_(e,t){const n=f=>{const v=e.getInstance(he)?.layers?.(),g=v?$_(v,f):void 0;return typeof g=="number"&&g>=0?g:void 0};let r;const o=f=>{const{error:v,failures:g}=t.saveState();return Au(v)?(r?.failures!==g&&(r={failures:g,saved:f??null}),r.saved===(f??null)):(r=void 0,!1)},s=()=>{const f=t.current(),v=f?.get().serverId??void 0,g=ee(t.sessionKey()),y=t.recoveryFacts(),E=y?.emailId===v?y:void 0,P=t.revisionFacts(),O=E?.latestRevisionAt,x=P?.lastRevisionAt,w=sd(e).profile;return{isInited:g||f?.get().attributes.is_inited===!0,isEnabled:!!w?.autosaves&&!O_(e)&&!o(f?.get().savedVersion),isHistoryLoaded:E?.historyLoaded===!0,isUserBusy:qo(e).isUserBusy,isHeadless:I_(e),autosaveTimeoutMs:ad(e).autosaveTimeout||z_,latestRevisionAt:O!==void 0||x!==void 0?Math.max(O??0,x??0):void 0,snapshotVersion:P?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??K_,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},i=()=>{const f=qo(e).saveContext;return{...f,project:f.project??t.current()?.get().attributes.project,fallbackTitle:fd(e)}},a=q_({readDocument:()=>t.current(),readEnvironment:s,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>Ag(t.saveState().error),onCreate:()=>{ee(t.sessionKey())||t.save("materialize",{...i(),source:R_})},onRevision:()=>{t.save("snapshot",{project:i().project})}}),c=t.subscribe(()=>{o(t.current()?.get().savedVersion),a.refresh()}),l=Js(e).watch(()=>a.refresh()),u=W_(e).watch(()=>a.refresh()),d=Qs(e).watch(()=>a.refresh());return()=>{c(),l.dispose(),u.dispose(),d.dispose(),a.stop()}}var Sa=12e3;function Ee(e){return e.getOrCreateInstance(zt,()=>{const t=Zg({resolveAdapters:(r,o)=>Q_(r,e,o),resolveWritePort:()=>pd(e),resolveHistoryPort:r=>ee(r)?md(e):hd(e),resolveTerms:()=>iv(e),canEdit:r=>Kl(e,r),notifyBeforeSave:Pm(e),confirmPublish:S_(e),awaitCanvasSynced:Nm(e),savedEchoForm:r=>{const o=nt(e);return o.toEditorForm(o.toOutputForm(r))},queuesOutsideWrites:r=>ee(r)&&(Um()||Kt(e)),timeoutMs:Sa,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const s=tv(o),i=ev(o);wn(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(s),network_failure:String(i)},level:s||i?"warning":"error"})},onTimeout:r=>{}}),n=X_(e,t);return e.getInstance(K)?.addDispose(n),t})}function Re(e){return e?.getInstance(zt)}function pd(e){const t=rv(e);return t?Ur(e)?Iv(t,gt(e).email(e),Kt(e)?{knownRevisions:$t(e),uncertainWrites:Ln(e)}:void 0):t:gt(e).email(e)}function Y_(e){return Mu(e)!==void 0||xu(e)}function hd(e){const t=Mu(e);return t?Ur(e)?(ce("port:history:server-backed"),Uu(t,gt(e).history(e),{knownRevisions:$t(e),uncertainWrites:Ln(e),synchronousHistory:Kt(e)})):(ce("port:history:integrator"),t):(ce("port:history:rest (порт не зарегистрирован)"),gt(e).history(e))}function md(e){const t=Nu(e);return t?Ur(e)?(ce("port:block-history:server-backed"),Uu(t,gt(e).blockHistory(e),{pendingKey:Us,knownRevisions:$t(e),uncertainWrites:Ln(e),synchronousHistory:Kt(e)})):(ce("port:block-history:integrator"),t):(ce("port:block-history:rest (порт не зарегистрирован)"),gt(e).blockHistory(e))}function J_(e){return Nu(e)!==void 0||xu(e)}function Ur(e){return Wl(e)}function Q_({email:e,patch:t,serverId:n,key:r},o,s){const i=[];e?i.push({id:"rest",load:()=>Ou(e),required:!0}):n&&i.push(nv(pd(o),n)),t&&i.push({id:"plugin",load:()=>Pu(t)});const a=ee(r);return Fm(n)&&(a?J_(o):Y_(o))&&i.push(vv({port:a?md(o):hd(o),revisionServiceEnabled:Ur(o),pendingKey:cu(n,a),historyIsSynchronous:Kt(o),emailId:n,wpId:()=>s.readWpId(),readShownContent:()=>s.readShownContent(),onFacts:c=>s.publishRecoveryFacts(c)})),i}function Z_(e){const t=Ee(e),n=pe(e).addListener(X.APPLICATION_HAS_AMP,r=>{xt(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(K)?.addDispose(()=>n.dispose())}function eb(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function tb(e){const t=e.fetchImpl??((s,i)=>fetch(s,i)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=s=>{try{const i=new URL(s,window.location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?!1:i.hostname===n()||e.sourceHosts().includes(i.hostname)}catch{return!1}};return{accepts:o,async load(s){if(!o(s))return;const i=!r.has(s);r.add(s);try{const a=await t(s,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return eb(c)?c:void 0}catch{return}}}}var pt={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function nb(e){const t={maxBytes:e.maxBytes??pt.maxBytes,maxImageBytes:e.maxImageBytes??pt.maxImageBytes,ttlMs:e.ttlMs??pt.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,s={hits:0,loads:0,failures:0};let i=0;const a=d=>{const f=r.get(d);f&&(i-=f.bytes,r.delete(d))},c=d=>t.ttlMs<=0||n()-d.storedAt<t.ttlMs,l=()=>{if(i<=t.maxBytes)return;const d=[...r.entries()].sort((f,v)=>f[1].usedAt-v[1].usedAt);for(const[f]of d){if(i<=t.maxBytes)return;a(f)}},u=(d,f)=>{f.size>t.maxImageBytes||(r.set(d,{blob:f,bytes:f.size,storedAt:n(),usedAt:n()}),i+=f.size,l())};return{async get(d){const f=r.get(d);if(f&&c(f))return f.usedAt=n(),s.hits+=1,f.blob;f&&a(d);const v=o.get(d);if(v!==void 0)return v;s.loads+=1;const g=(async()=>{try{const y=await e.load(d);return y?u(d,y):s.failures+=1,y}catch{s.failures+=1;return}finally{o.delete(d)}})();return o.set(d,g),g},forget(d){a(d),o.delete(d)},configure(d){Object.assign(t,{maxBytes:d.maxBytes??t.maxBytes,maxImageBytes:d.maxImageBytes??t.maxImageBytes,ttlMs:d.ttlMs??t.ttlMs});for(const[f,v]of r)v.bytes>t.maxImageBytes&&a(f);l()},clear(){r.clear(),o.clear(),i=0},stats(){return{entries:r.size,bytes:i,...s}}}}var rb=["emcdn.ru","scr.emcdn.ru"];function ob(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 sb(e,t){const n=(r,o)=>{const s=new Set(o?t:[]);for(const i of r){const a=ob(i);a&&s.add(a)}return[...s]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function ib(e){const t=e??{},n=t.isPlugin!==!0?rb:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...pt};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:sb(o.sourceHosts,n),maxBytes:o.maxBytes??pt.maxBytes,maxImageBytes:o.maxImageBytes??pt.maxImageBytes,ttlMs:o.ttlMs??pt.ttlMs}}function ab(e){const t=pe(e),n=e.getInstance(he),r=()=>ib({...n?.get(),isPlugin:!0});let o=r();const s=tb({sourceHosts:()=>o.sourceHosts}),i=nb({load:y=>s.load(y),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(X.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},c=t.onInit(()=>a()),l=n?.watch(()=>{const y=r(),E=JSON.stringify(y)!==JSON.stringify(o);o=y,i.configure(y),y.enabled||i.clear(),E&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},d=[],f=(y,E)=>(u.refused+=1,d.push({url:y,reason:E}),d.length>20&&d.shift(),{refused:!0}),v=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...u},refusals:[...d],store:i.stats()})}),g=t.addListenerAsync(X.APPLICATION_CANVAS_IMAGE_GET,async y=>{const E=y?.url??"";if(u.asked+=1,!o.enabled||!E)return f(E,"disabled");if(!s.accepts(E))return f(E,"host");y.fresh&&i.forget(E);const P=await i.get(E);return P?(u.served+=1,{blob:P}):f(E,"load-failed")});e.getInstance(K)?.addDispose(()=>{c.dispose(),l?.dispose(),g.dispose(),i.clear(),delete v.__emmCanvasImages__})}var cb=2e3;function lb(e){const t=pe(e),n=new Map,r=()=>{const i=t.getTarget();if(!i||t.hasPort(i))return;clearTimeout(n.get(i));const a=new MessageChannel;let c=!1,l=!1;const u=f=>{f.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",u),l&&t.resumePort(i),t.drainWindow(i))};a.port1.addEventListener("message",u),t.sendPort(i,a.port2),t.usePort(a.port1,!1,i);const d=setTimeout(()=>{n.get(i)===d&&n.delete(i),!(c||!t.hasPort(i,a.port1))&&(wn(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),l=!0,t.holdPort(i))},cb);n.set(i,d)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const i=t.getTarget();return{usesPort:t.usesPort,windowDrained:i?t.isWindowDrained(i):!1}}}),s=t.onInit(()=>r());e.getInstance(K)?.addDispose(()=>{for(const i of n.values())clearTimeout(i);s.dispose(),delete o.__emmCanvasPort__})}var ub=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function db(e){return ub.test(e)||e.indexOf("//")===0}function zn(e){return e&&(e.endsWith("/")?e:`${e}/`)}function fb(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Ia(e,t){const n=e==null||e===""?"./":String(e);if(db(n))return zn(n);const r=t??fb();if(!r)return zn(n);try{return zn(new URL(n,r).href)}catch{return zn(n)}}function pb(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?Ia(window.__useblocks__.publicPath):Ia("/")}var hb=()=>"",mb=()=>"7594857d";function gb(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function gd(e){const t=e?"iframe-eblock":"iframe",n=hb();if(n){const s=gb(n,window.location).replace(/\/?$/,"/");return Oi(`${s}${t}.html`,bn())}const r=mb(),o=`${pb().replace(/\/?$/,"/")}iframe/`;return Oi(`${o}${t}${r?`.${r}`:""}.html`,bn())}var Aa="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Wo(e){return/^file:/i.test(String(e||"").trim())}function vb(e){return Wo(e)?`${Aa} allow-same-origin`:Aa}var _b="em:module-body-ack";function bb(e,t,n){try{const r=new URL("./",new URL(t,n)).href,o=new URL(e,r).href;return o.startsWith(r)?o:void 0}catch{return}}function Zs(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function yb(e){const t=Zs(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function Eb(e,t){const n=Zs(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function wb(e,t){const n=Zs(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),s=[r],i=[];for(;s.length>0;)for(const a of e[s.shift()]??[])o.has(a)||(o.add(a),i.push(a),s.push(a));return i}var Sb=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Ib(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&Sb.test(t[t.length-2])}async function Ab(e,t){const n=Ib(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function Tb(e){const t=new Map,n=(r,o)=>{const s=bb(r,e.canvasSrc,e.origin);if(!s)return;const i=t.get(s);if(i!==void 0)return i;const a=e.fetchBody(s,o);return t.set(s,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const s of r)n(s,o)},reset(){t.clear()},get size(){return t.size}}}var We;function Cb(e){try{return Wo(new URL(e,window.location.href).href)}catch{return Wo(window.location.href)}}function vd(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__useblocks__<"u"&&window.__useblocks__?.preload?.canvasCrossOrigin===!0}var Ob=()=>Promise.resolve(void 0);function _d(){const e=gd(!1);if(!Cb(e)){if(!We||We.canvasSrc!==e){const t=vd(e)?Ab:Ob;We={canvasSrc:e,store:Tb({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return We.store}}async function Pb(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const o=await r.json();t(Eb(o,e))}catch{}}function ei(e){const t=_d();if(!t||!We||We.warmed||!vd(We.canvasSrc))return;We.warmed=!0;const{canvasSrc:n}=We,r=yb(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.CsLyPjC1.js"],"js/iframe.js":["js/elMarkupHelper.CsLyPjC1.js"],"js/darkreader.CyLMh7_H.js":[],"js/elMarkupHelper.CsLyPjC1.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.CGEpDoct.js":[]};o?t.warm(wb(o,n),e):Pb(n,s=>t.warm(s,e))}function Rb(e){const t=_d();if(!t)return;ei();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const s=r.source;s&&(s.postMessage({operationId:_b,for:o.result},"*"),t.take(o.data?.url??"").then(i=>{s.postMessage({operationId:o.result,data:i??null},"*")}))};window.addEventListener("message",n),e.getInstance(K)?.addDispose(()=>{window.removeEventListener("message",n)})}var Lt=/<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,Db=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Ht=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Ta=/display:\s*none\s*!important/gi,kb="data-darkreader-",xb=/<(script|style)\b[\s\S]*?<\/\1\s*>|<[a-z][^\s<>]*(?:"[^"]*"|'[^']*'|[^<>"'])*?\sdata-darkreader-(?:"[^"]*"|'[^']*'|[^<>"'])*>/gi,Lb=/\sdata-darkreader-[a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?/gi,Nb=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,Mb=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Fb=/height\s*:\s*100%\s*!important/i,Bb=[".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 jb(e){return Ta.lastIndex=0,(e.match(Ta)||[]).length}function bd(e){const t=e.trim(),n=jb(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=Bb.filter(o=>t.includes(o)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function Ub(e){Ht.lastIndex=0;for(const t of e.matchAll(Ht))if(bd(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function $b(e){let t=!1;return Ht.lastIndex=0,{html:e.replace(Ht,n=>bd(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Hb(e){return Lt.lastIndex=0,Lt.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Ub(e)}function Vb(e){return e.toLowerCase().includes(kb)?e.replace(xb,(t,n)=>n?t:t.replace(Lb,"")):e}function Gb(e){const t=Vb(e);if(!Hb(t))return{html:t,found:!1};let n=!1,r=t;Lt.lastIndex=0,Lt.test(r)&&(Lt.lastIndex=0,r=r.replace(Lt,""),n=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(r)||/\sdata-bis-config\s*=/.test(r))&&(r=r.replace(Db,""),n=!0);const o=$b(r);return r=o.html,n=n||o.found,{html:r,found:n}}function qb(e){return!e||!Fb.test(e)?e:(Ht.lastIndex=0,e.replace(Ht,t=>t.replace(Nb,(n,r,o,s)=>`${r}${o.replace(Mb,"")}${s}`)))}function yd(e){const t=Gb(e.replaceAll(`\r
1003
1003
  `,`
1004
- `));return{html:Hv(t.html),hasBrowserExtensionArtifacts:t.found}}function fn(e){return e?.getContent()??""}function fu(e,t){e?.mutate({content:vi(t)},{source:"remote"})}function Ir(e){return U(e)}function _e(e,t){return e.getOrCreateInstance(t,()=>new Je)}function ne(e,t){return e.getOrCreateInstance(t,()=>new Je).event}function sr(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Vv=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 Gv(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 qv(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(se(n),new Promise((r,o)=>{let i=!1,s,a;const c=u=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",l),u())},l=()=>{c(()=>o(Ie(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&c(()=>r())}),e.isInited()&&e.getTarget()){c(()=>r());return}t>0&&(s=setTimeout(()=>{c(()=>o(new Vv(t)))},t)),n?.addEventListener("abort",l)}))}var pu=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 hu(e,t,n){return t<=0?e:new Promise((r,o)=>{let i=!1,s;const a=c=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),c())};s=setTimeout(()=>{a(()=>o(new pu(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>o(c))})})}var Wv=2,Yt=Symbol("sandbox:frame-replaced");function Hs(e){return e===Yt}function at(e,t,n,r,o,i,s){const a=`sandbox:${t}`,c=i?.getSandboxTimeoutMs(t)??hi[t],l=()=>{let v=hu(e.sendAsync(n,r),c,a);return v=Qn(v,i?.signal),ct(a,v,o)};if(t==="INIT_START"&&Gv(e)){const v=i?.getSandboxReadyTimeoutMs()??2e4,E=e,y=k=>{const C=qv(E,v,i?.signal);return ct("sandbox:INIT_START:ready-wait",C,o).then(()=>{if(!s||k<=0)return l();const F=s.getGeneration();let T;const R=new Promise((D,O)=>{T=s.onChange(()=>{s.getGeneration()!==F&&O(Yt)})}),A=l();return A.catch(()=>{}),Promise.race([A,R]).finally(()=>T?.()).catch(D=>{if(D!==Yt)throw D;return{...o},y(k-1)})})};return y(Wv)}if(!s)return l();const u=s.getGeneration();let d;const m=new Promise((v,E)=>{d=s.onChange(()=>{s.getGeneration()!==u&&E(Yt)})}),_=l();return _.catch(()=>{}),Promise.race([_,m]).finally(()=>d?.()).catch(v=>{throw v===Yt&&{...o},v})}var mu="self-init:";function zv(e){return e.startsWith(mu)}function ki(e,t){const n=e.getActiveShowRequest();return zv(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Kv(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let i="",s;const a=v=>{s={target:e.readTarget?.(),docId:v}},c=()=>e.readDocument()?fn(e.readDocument()):i,l=()=>Ze(e.container).editorPolicy,u=()=>e.readEmail(),d=()=>{const v=u();return{...v,id:e.isTemplate()||v.isNew?void 0:v.id,html:c()}};let m=!1;const _={readContent:c,publicEmail:d,sendInitStart:()=>at(n,"INIT_START",K.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>at(n,"INITED",K.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),o()),async sendContent(){const v=u(),{html:E,hasBrowserExtensionArtifacts:y}=du(v?.html||"");y&&e.events.browserExtensionDetected(),fu(e.readDocument(),E),i=E,a(v.renderGuid),await at(n,"SET_ENTITY",K.SANDBOX_SET_ENTITY,sr(c(),v.renderGuid,l(),e.readDocument()?.get().version),{guid:v.renderGuid,emailId:v.id??null},r(),o())},refreshContent:()=>(a(u().renderGuid),at(n,"SET_ENTITY",K.SANDBOX_SET_ENTITY,sr(c(),u().renderGuid,l(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const v=u();if(v.preheader!==void 0)return at(n,"PREHEADER",K.SANDBOX_PREHEADER_UPDATE,{value:v.preheader,guid:v.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const v=u();if(v.subject!==void 0)return at(n,"SUBJECT",K.SANDBOX_SUBJECT_UPDATE,{value:v.subject,guid:v.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:v=>e.showFilled?.(v),noteFilled:(v,E)=>e.noteFilled?.(v,E),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(d()),fireInit(v,E){if(!ki(t(),v)){t().getActiveShowRequest()?.showId;return}const y=u();y.id,y.renderGuid,t().completeShow(v);const k=e.readDocument();Mt(k,{is_inited:!0},{source:"system"});const C=()=>{const T=d();E&&(T.reset=!0);const R=e.events.inited(T);return E||(m&&_.fireEmailChanged(),m=!0),R};if(!k||k.isReady())return C();const{docId:F}=k.get();return k.whenReady().then(()=>e.readDocument()?.get().docId===F?C():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(d())},fireContentChanged(){e.events.contentChanged(c())}};return _}var Yv=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}},Xv=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(Ie("Superseded by newer show()")),n.aborted?Promise.reject(Ie(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const i=setTimeout(()=>{this._settle(e.showId,()=>{o(new Yv(e.showId,t))})},t);i.unref?.();const s=()=>{this._settle(e.showId,()=>{o(Ie(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(i),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:i,dispose:a});for(const c of this._listeners)c(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 Jv(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Qv(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Gc(e),n=qc(e),r=Sp(e.sandbox);t<n+r}var gu=class{_controller=new AbortController;_externalSignalDisposable=new ve;_sessionChangeListeners=new Set;_showRegistry=new Xv;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Gc(this._timeouts)}getSandboxTimeoutMs(e){return Vc(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return qc(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=Jv(this._timeouts,e.timeouts),Qv(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ve,this._linkExternalSignal(e)}abort(e){const t=e??Ie("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ve}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ve,this._showRegistry.rejectAll(Ie("Init session replaced")),this._controller.signal.aborted||this._controller.abort(Ie("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??Ie()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??Ie()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Pi=(()=>{const e=new gu;return e.configure({}),e})();function gt(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function nt(e){return!e||e==="none"}function Zv(e){const t=e.contain??"",n=e.willChange??"";return!nt(e.transform)||!nt(e.perspective)||!nt(e.filter)||!nt(e.backdropFilter)||!nt(e.translate)||!nt(e.rotate)||!nt(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Vs(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function eb(e){const t=[],n=document.documentElement,r=Vs(getComputedStyle(n)),o=r.x||r.y;let i="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(i=s);for(let a=gt(e);a&&a!==n;a=gt(a)){const c=getComputedStyle(a),l=i==="none"||Zv(c)||i==="absolute"&&!!c.position&&c.position!=="static",u=a===document.body&&!o;if(l){i="none";const d=u?{x:!1,y:!1}:Vs(c);(d.x||d.y)&&t.push({node:a,...d})}(c.position==="absolute"||c.position==="fixed")&&(i==="none"||c.position==="fixed")&&(i=c.position==="fixed"?"fixed":"absolute")}return t}function vu(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function Ln(e){return Number.parseFloat(e)||0}function Oo(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=vu(e),o=Ln(n.borderLeftWidth),i=Ln(n.borderTopWidth),s=Ln(n.borderRightWidth),a=Ln(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-s):0,l=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-i-a):0;return{left:t.left+o*r.x,top:t.top+i*r.y,right:t.right-(s+c)*r.x,bottom:t.bottom-(a+l)*r.y}}function tb(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(i,s,a)=>{s&&(r.left=Math.max(r.left,i.left),r.right=Math.min(r.right,i.right)),a&&(r.top=Math.max(r.top,i.top),r.bottom=Math.min(r.bottom,i.bottom))};return t.forEach(i=>o(Oo(i.node),i.x,i.y)),n&&o(Oo(n),!0,!0),r}var ko={originX:0,originY:0,scaleX:1,scaleY:1};function ar(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function bu(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,o=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*o,scaleX:r,scaleY:o}}function _u(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var nb=1e3;function rb(e){const{slot:t,own:n}=e;let r,o=0,i=!1;const s=()=>{if(r=void 0,!i){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(s))}},a=()=>{!i&&r===void 0&&(r=window.requestAnimationFrame(s))},c=()=>{o=performance.now()+nb,a()},l=[window],u=[document.documentElement];for(let y=t;y;y=gt(y)){const k=y.getRootNode();k instanceof ShadowRoot&&!l.includes(k)&&(l.push(k),u.push(k))}const d=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];l.forEach(y=>d.forEach(([k,C])=>y.addEventListener(k,C,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const m=typeof MutationObserver=="function"?new MutationObserver(y=>{y.some(k=>!n.contains(k.target))&&a()}):void 0;u.forEach(y=>m?.observe(y,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let _;try{if(typeof ResizeObserver=="function"){const y=new ResizeObserver(a);typeof y.observe=="function"&&(_=y)}}catch{_=void 0}let v=[];return{schedule:a,observe:y=>{!_||y.length===v.length&&y.every((k,C)=>k===v[C])||(_.disconnect(),v=y,y.forEach(k=>_?.observe(k)))},dispose(){i=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),l.forEach(y=>d.forEach(([k,C])=>y.removeEventListener(k,C,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),m?.disconnect(),_?.disconnect()}}}var ob="pluginZoom",ib=/^(?:ant|vscode|monaco|docs)-/;function sb(e){return ib.test(e)}function ab(){const e="ub".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var cb=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function lb(){return cb}var ub=new Set;function db(e,t,n=ub){return e.startsWith(`${t}-`)?!1:!sb(e)&&!n.has(e)}function fb(e,t){return`--${t}-${e}`}function yu(e){const t=ab();return db(e,t,lb())?fb(e,t):`--${e}`}function pb(e,t){const n=yu(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function Eu(e,t){return pb(e,t)}var wu=300,Gs=15e3,hb=5e3,qs="em-canvas-busy-style";function mb(){if(document.getElementById(qs))return;const e=document.createElement("style");e.id=qs,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var gb="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function vb(e){const t=Eu("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(yu("colorPrimary")).trim()||t}function Su(e){mb();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",gb),n.appendChild(r);const o=document.createElement("span");return o.setAttribute("role","img"),o.setAttribute("aria-label","loading"),o.setAttribute("style",`display:inline-flex;color:${vb(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function bb(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),i=Math.min(r.right,e.right,n.width),s=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return i<=o||a<=s?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+i)/2-e.left,y:(s+a)/2-e.top}}function _b(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const o={left:n.left,top:n.top,right:n.right,bottom:n.bottom},i=r.getBoundingClientRect();if(i.width>0&&!_u({left:i.left,top:i.top,width:i.width,height:i.height},o)){const s=ar(o,bu(i,ar(o,ko),ko));Object.assign(r.style,{left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const s=bb(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${s.x}px`,top:`${s.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(Su(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Gr(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(Su(e))},wu);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var yb=8e3;function Eb(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function wb(e,t){for(let n=gt(e);n;n=gt(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",i=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>It(s)>0);if(o&&i)return n;if(n===t)return null}return null}function It(e){return Number.parseFloat(e)||0}function Nn(e,t){return Math.abs(e-t)<=1}function Sb(e){const t=getComputedStyle(e),n=It(t.borderTopWidth),r=It(t.borderRightWidth),o=It(t.borderBottomWidth),i=It(t.borderLeftWidth),s=(a,c,l)=>Math.max(0,It(a)-Math.max(c,l));return{...Oo(e),radii:[s(t.borderTopLeftRadius,n,i),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,o,r),s(t.borderBottomLeftRadius,o,i)]}}function Ib(e,t){const n=Nn(t.top,e.top),r=Nn(t.bottom,e.bottom),o=Nn(t.left,e.left),i=Nn(t.right,e.right),s=[n&&o?e.radii[0]:0,n&&i?e.radii[1]:0,r&&i?e.radii[2]:0,r&&o?e.radii[3]:0];return s.every(a=>a===0)?"":s.map(a=>`${a}px`).join(" ")}function Tb(e,t,n,r,o,i){const s=n.readyTimeoutMs??yb,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden",a.style.setProperty("zoom",Eu(ob,"1"));const c=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(c)),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=c,a.appendChild(l),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(l);const u=new ve;let d=!1,m,_=!1,v,E,y,k;const C=()=>{clearTimeout(k),k=setTimeout(()=>{_||(_=!0,E?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},F=()=>d?(y=Promise.resolve(),_=!0,y):(_=!1,y=new Promise(($,g)=>{v=$,E=g}),C(),y),T=()=>{if(clearTimeout(k),d=!0,_){y=Promise.resolve();return}_=!0,n.mark?.("loaded"),v?.()};l.addEventListener("load",T),u.addDispose(()=>{clearTimeout(k),l.removeEventListener("load",T)});let R;const A=()=>{R??=n.bindResizer?.(l)},D=()=>{R?.dispose(),R=void 0};let O=null,h=null,f,p=ko,b="",x="",N=0;const S=$=>{const g=JSON.stringify($);return g===b?!1:(b=g,a.style.visibility=$.visibility,a.style.left=`${$.css.left}px`,a.style.top=`${$.css.top}px`,a.style.width=`${$.css.width}px`,a.style.height=`${$.css.height}px`,a.style.borderRadius=$.radius,l.style.width=$.elementWidth>0?`${$.elementWidth}px`:"100%",l.style.transform=$.shiftX!==0?`translate(${$.shiftX}px, ${$.shiftY}px)`:`translateY(${$.shiftY}px)`,!0)};let w=!1;const M=()=>{if(!O)return b="",a.style.visibility="hidden",l.removeAttribute("id"),!1;n.elementId&&(l.id=n.elementId);const $=O.getBoundingClientRect(),g=eb(O),I=h?.isConnected?h:null;f?.observe([O,l,...g.map(te=>te.node),...I?[I]:[]]);const P=tb($,g,I),j=Math.max(0,P.right-P.left),q=Math.max(0,P.bottom-P.top),Q=getComputedStyle(O).visibility==="visible",G=j<=0||q<=0,z=G?{left:P.left,top:P.top,right:P.left,bottom:P.top}:P,L=G?null:wb(O,I??g[0]?.node??null),J=L?Ib(Sb(L),z):"",Z=te=>S({visibility:Q&&!w?"":"hidden",css:ar(z,te),elementWidth:$.width/te.scaleX,shiftX:($.left-z.left)/te.scaleX,shiftY:($.top-z.top)/te.scaleY,radius:J});let be=Z(p);if(!G){const te=a.getBoundingClientRect();te.width>0&&!_u({left:te.left,top:te.top,width:te.width,height:te.height},z)&&(p=bu(te,ar(z,p),p),be=Z(p)||be)}return be},B=()=>{if(!O)return!1;let $=M();const g=l.getBoundingClientRect().height;g>0&&g!==N&&(N=g,O.style.height=`${g/vu(O).y}px`,$=!0);const I=getComputedStyle(O).pointerEvents;return I!==x&&(x=I,a.style.pointerEvents=I),$},W=()=>{f?.dispose(),f=void 0},re=$=>{f=rb({slot:$,own:a,measure:B,onDetached:W})};let oe=[];const ie=($,g)=>{if(h=g,$&&oe.length>0){const I=oe;oe=[],I.forEach(P=>P())}if($===O){$&&!f&&re($),B();return}if(W(),O&&O.style.removeProperty("height"),b="",N=0,x="",O=$,!$){M(),D();return}n.onShown?.(l),re($),B(),A()};u.addDispose(W);const X=$=>{d=!1,m=void 0,i?.(),$&&n.onReload?.(l);let g;_||y===void 0?g=F():(C(),g=y);try{l.contentWindow?.location.reload()}catch{l.src=c}return g};return{element:l,ready(){return y??F()},reload:()=>X(!0),reloadQuietly:()=>X(!1),followReload:()=>{m=void 0,i?.(),n.onReload?.(l)},moveTo($){if(a.parentNode===$)return y??F();d=!1,m=void 0,i?.();let g;return _||y===void 0?g=F():(C(),g=y),$.appendChild(a),n.onReload?.(l),b="",f?.schedule(),g},get shown(){return O!==null},get slot(){return O},whenShown(){return O!==null?Promise.resolve():new Promise($=>{oe.push($)})},get filled(){return m},noteFilled($){m=$},alignTo($,g){ie($,g??null)},hold($){w!==$&&(w=$,M())},scrollBy($,g){let I=$,P=g;for(let j=O?gt(O):null;j;j=gt(j)){if(Math.abs(I)<1&&Math.abs(P)<1)return;const q=getComputedStyle(j);if((q.overflowY==="auto"||q.overflowY==="scroll")&&j.scrollHeight>j.clientHeight){const Q=j.scrollTop,G=j.scrollLeft;j.scrollBy({left:I,top:P,behavior:"instant"}),I-=j.scrollLeft-G,P-=j.scrollTop-Q}}(Math.abs(I)>=1||Math.abs(P)>=1)&&window.scrollBy({left:I,top:P,behavior:"instant"})},resize(){R?.resize()},dispose(){ie(null,null),D(),u.dispose(),a.remove()}}}function Ab(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(p,b)=>p==="email"?`email:${b??n}`:p,i=new Map;let s,a=[],c=!1,l,u,d=!1,m,_,v="shown",E=0,y,k,C;const F=p=>u!==void 0&&p.filled!==void 0&&p.filled!==u,T=()=>{y=void 0;const p=m;!d||!p||u===void 0||k===u||!F(p)||(k=u,e.onForeignDocument?.({wanted:u,filled:p.filled,role:v,heldMs:Date.now()-E}))},R=()=>{d=!1,m=void 0,_=void 0,clearTimeout(y),y=void 0},A=(p,b)=>{const x=i.get("email"),N=x?.slot??null;return p&&N&&F(p)?(p.alignTo(null),d||(d=!0,E=Date.now(),y=setTimeout(T,hb)),v=b,m=p,!(s!==void 0||c)&&_!==p&&(_=p,e.onShown?.(p.element)),!l&&!s&&(l=Gr(N)),!1):(d&&(R(),l?.remove(),l=void 0),p?.alignTo(N,x?.clip??null),!0)},D=()=>{d&&!c&&A(t.get(o("email")),"shown")},O=()=>{a.forEach(p=>clearTimeout(p)),a=[],s?.remove(),s=void 0,l?.remove(),l=void 0,(c||d)&&(c=!1,A(t.get(o("email")),"shown"))},h=(p,b,x)=>{const N=o(p,b),S=t.get(N);if(S)return S;const w=e.resolveMount();if(!w)return Eb();const M=Tb(p,w,e,p==="email"?b??n:void 0,x,p==="email"?()=>D():void 0);return t.set(N,M),M},f={get:p=>h(p),current:p=>h(p),peek:p=>t.get(o(p)),spare:()=>t.get(o("email",r())),ensureSpare:()=>h("email",r(),!0),promote(){const p=t.get(o("email",r()));if(!p)return;const b=t.get(o("email"));n=r(),C=void 0,A(p,"spare"),b?.alignTo(null)},alignSurface(p,b,x){const N=i.get(p);if(i.set(p,{slot:b,clip:x??null}),p==="email"&&c){l?.remove(),l=b?Gr(b):void 0;return}const S=b?h(p):t.get(o(p));if(p!=="email"){S?.alignTo(b,x??null);return}if(!b){C=N?.slot&&S?.shown?{slot:N.slot,handle:S}:void 0,d&&(R(),l?.remove(),l=void 0),S?.alignTo(null);return}const w=C?.slot===b&&C.handle===S;if(C=void 0,N?.slot===b&&S?.shown||w){S?.alignTo(b,x??null);return}A(S,"shown")},want(p){u=p,p!==void 0&&D()},noteFilled(p,b){const x=f.byWindow(p);x&&(x.noteFilled(b),x===t.get(o("email"))&&D())},visible(){for(const p of t.values())if(p.shown)return p},byWindow(p){if(p){for(const b of t.values())if(b.element.contentWindow===p)return b}},busy(p){if(O(),!p)return;if(!f.visible()){c=!0,l?.remove(),l=void 0;const N=i.get("email");N?.slot&&(l=Gr(N.slot)),a=[setTimeout(O,Gs)];return}const b=e.resolveMount();if(!b)return;const x=_b(b,()=>f.visible()?.element.parentElement?.getBoundingClientRect()??null);s=x,a=[setTimeout(()=>x.showSpinner(),wu),setTimeout(O,Gs)]},remount(p){O();const b=o("email");t.forEach((x,N)=>{if(N===b){x.moveTo(p).catch(()=>{});return}x.dispose(),t.delete(N)})},dispose(){u=void 0,c=!1,R(),C=void 0,O(),t.forEach(p=>p.dispose()),t.clear(),i.clear(),n="a",u=void 0,k=void 0}};return f}var Cb=U("canvas.resizerBinder"),Po=U("canvas.service"),Rb={created:Ee.canvasCreated,loaded:Ee.canvasLoaded},Iu=new WeakMap;function Do(e){return Iu.get(e)??0}function Ob(e,t){if(e.getInstance(Po))return;const n=Ab({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:hv,elementId:t.elementId,bindResizer:o=>e.getInstance(Cb)?.(o),onCreated:o=>on(e,o,"fresh"),onReload:o=>{Iu.set(o,Do(o)+1),on(e,o,"fresh")},onShown:o=>{const i=n.byWindow(fe(e).getTarget());i&&i.element!==o&&Ws(i.element)===Ws(o)||on(e,o,"switch")},mark:o=>t.mark?.(Rb[o]),onForeignDocument:o=>{({...o},Bp("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:o.role},contexts:{canvasIdentity:{...o,path:window.location.pathname}}}))}}),r=fe(e).addListener(K.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(Po,n),e.getInstance(Y)?.addDispose(()=>{r.dispose(),n.dispose()})}function Ws(e){return e.parentElement?.dataset.canvasHost}function on(e,t,n){const r=fe(e),o=t.contentWindow;if(!o)return;const i=r.getTarget()===o;i&&n==="switch"||(n==="fresh"&&(r.forget(o),i&&r.setTarget(void 0)),r.setTarget(o),Cp(r))}function kb(e,t){on(e,t,"promote")}function Pb(e,t){on(e,t,"switch")}function Db(e,t){const n=t.contentWindow;n&&fe(e).greet(n)}function Tu(e,t){const n=t.contentWindow;n&&fe(e).forget(n)}function xb(e,t){const n=me(e)?.byWindow(t)?.element;if(!n)return;const r=Do(n);return()=>Do(n)!==r}function me(e){return e.getInstance(Po)}function Au({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:i}){if(!r)return;const s={id:o??void 0,renderGuid:n,showId:i?.id,isNew:o==null,showToken:i?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Tr(e){return{...Au({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function zn(e){const t=ye(e),n=t.current();if(!n||!ee(t.sessionKey()))return;const r=Tr(n),o=n.isDirty();_e(e,H.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function Mb(e){const t=ye(e);return!t.current()||!ee(t.sessionKey())?!1:(zn(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Lb(e){const t=ye(e),n=fe(e),r=()=>e.getInstance(Fe)??Pi;let o,i,s=!1,a=!1,c,l;const u=x=>Tr(x),d=()=>{const x=F(),N=x?.get().docId;if(!x||!N||N!==c||s)return;const S=x.get().version;S!==l&&(l=S,_e(e,H.ON_BLOCK_CHANGED_ID).fire(u(x)))};let m;const _=x=>{const N=t.showFacts();!N||N.id===m||!ki(x,N.id)||(m=N.id,x.completeShow(N.id))},v=async(x,N,S)=>{const w=S.generation,M=()=>S.generation!==w||S.signal.aborted||t.current()!==x||a,B=Te(n);let W;const re=new Promise(ie=>{W=un(n,()=>ie("regenerated"))}),oe=async(...ie)=>await Promise.race([at(...ie).then(()=>"sent"),re])==="sent";s=!0;try{if(!await oe(n,"INIT_START",K.SANDBOX_INIT_START,{guid:N},void 0,S)||M())return;const{html:ie,hasBrowserExtensionArtifacts:X}=du(fn(x));if(X&&_e(e,H.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),fu(x,ie),!await oe(n,"SET_ENTITY",K.SANDBOX_SET_ENTITY,sr(fn(x),N,Ze(e).editorPolicy,x.get().version),void 0,S)||M()||!await oe(n,"INITED",K.SANDBOX_INITED,{guid:N},void 0,S)||M())return;o=N,i=B,T(),l=x.get().version,c!==N&&(c=N,_e(e,H.ON_BLOCK_INIT_ID).fire(u(x))),_(S)}finally{W?.(),s=!1,(Te(n)!==B||t.current()!==x)&&D()}};let E,y,k;const C=()=>{const x=me(e)?.peek("block");return x?.reload?(x.reload().catch(()=>{}),!0):!1},F=()=>ee(t.sessionKey())?t.current():void 0,T=()=>{const x=F()?.get().docId,N=!x||k===x||o===x&&i===Te(n);me(e)?.peek("block")?.hold(!N)},R=()=>{if(a||(T(),d(),s))return;const x=F(),N=x?.get().docId;if(!x||!N)return;if(o===N&&i===Te(n)){_(r());return}if(!x.isReady())return;const S=r();S.signal.aborted||o!==void 0&&o!==N&&E!==N&&(E=N,C())||v(x,N,S).catch(()=>{if(!(a||t.current()!==x)){if(y!==N){y=N,C();return}k=N,T()}})};let A=!1;const D=()=>{A||a||(A=!0,queueMicrotask(()=>{A=!1,R()}))};let O,h;const f=()=>{const x=F(),N=x?.get().docId;N!==h&&(O?.(),h=N,O=x?.subscribe(D)),T(),D()},p=t.subscribe(f),b=un(n,()=>{T(),D()});f(),e.getInstance(Y)?.addDispose(()=>{a=!0,b(),O?.(),p()})}function Nb(e){const t=ye(e);let n="email";const r=()=>{if(!t.current())return;const i=ee(t.sessionKey())?"block":"email",s=me(e);if(i===n||!s)return;n=i;const a=s.peek(i);if(a){Pb(e,a.element);return}s.get(i)},o=t.subscribe(r);e.getInstance(Y)?.addDispose(o)}var Fb=200;function Bb({startVersion:e,limit:t=Fb}){let n=[],r=e;const o=i=>{n=n.filter(s=>s.version>i),r=Math.max(r,i)};return{record(i){!i.changes?.length&&!i.contentReplaced||(n.push(i),n.length>t&&o(n[n.length-t-1].version))},rebase(i,s){if(s<r)return null;const a=n.filter(l=>l.version>s);o(s);let c=i;for(const l of a){if(l.contentReplaced||!l.changes)return null;const u=l.changes,d=[];for(const m of c){if(l.fromCanvas&&u.some(v=>m.range.start<=v.oldEnd&&m.range.end>=v.oldPosition))return null;const _=ol(m.range,u,"after");if(!_)return null;d.push({range:_,text:m.text})}c=d}return c}}}function jb(e,t){let n=0;return e.map(({start:r,end:o,text:i})=>{const s=new Me(r,t.slice(r,o),r+n,i);return n+=i.length-(o-r),s})}function Ub(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return jb(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function $b(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Hb=32;function Vb(e=Hb){const t=new Map;return{find(n,r){const o=t.get(n);return o&&_o(o.scope,r)?o.echo:void 0},remember(n,r,o){t.delete(n),t.set(n,{scope:r,echo:o}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>_o(r.scope,n)).map(r=>r.echo)}}}function Gb(e,t){const n=Uf(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var Di=U("canvas.sandboxFill");function Cu(e){return e.getInstance(Di)?.pipeline.isEventsLocked()===!0}var qb=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,Wb=/<\/?[a-zA-Z]/g;function zs(e){return e.match(Wb)?.length??0}function Ks(e){return[...e.matchAll(qb)].map(t=>[t.index,t.index+t[0].length])}function qr(e,t,n){let r=0,o=0;for(const[i,s]of n){for(;o<t.length&&t[o][1]<=i;)o++;let a=i;for(let c=o;c<t.length&&t[c][0]<s;c++)r+=zs(e.substring(a,Math.max(a,t[c][0]))),a=Math.max(a,t[c][1]);r+=zs(e.substring(Math.min(a,s),s))}return r}function Ru(e,t){const n=[...t].sort((c,l)=>c.oldPosition-l.oldPosition||c.oldEnd-l.oldEnd),r=[],o=[],i=[];let s=0,a=0;for(const c of n){const l=e.substring(s,c.oldPosition);r.push(l,c.newText),a+=l.length,o.push([c.oldPosition,c.oldEnd]),i.push([a,a+c.newText.length]),a+=c.newText.length,s=c.oldEnd}return r.push(e.substring(s)),{next:r.join(""),removed:o,inserted:i}}var zb=/<(?:!doctype|html|head|body)\b/i;function Kb(e,t){return e.reduce((n,r)=>n+r.oldLength,0)<t.trim().length?!1:zb.test(t)&&!Ru(t,e).next.trim()}function Yb(e,t){if(e.reduce((s,a)=>s+a.oldLength,0)<=200)return null;const n=Ks(t),r=Ru(t,e),o=qr(t,n,r.removed)-qr(r.next,Ks(r.next),r.inserted),i=qr(t,n,[[0,t.length]]);return o>100&&o>i*.2?{removed:o,total:i}:null}function rt(e){dn(e,{origin:"canvas-channel"})}var Xb=100;function Jb(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===K.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function Qb(e){const t=ye(e),n=fe(e);let r;const o=(c,l)=>{const u=c.get().docId;let d=!1,m=null,_=null,v;const E=Bb({startVersion:c.get().version});let y=c.getContent();const k=Vb(),C=Qc(e),F=C.open(u,()=>c.get().version);let T=!1;const R=I=>({generation:Te(n),originId:I});let A=R(null),D=!0;const O=(I,P)=>{!D||t.current()!==c||(dn(P,{origin:"canvas-channel"}),_?.splice(0,_.length),n.sendAsync(K.SANDBOX_SET_ENTITY,sr(fn(c),u,Ze(e).editorPolicy,c.get().version)).catch(rt))},h=I=>{const P=I[I.length-1],j=[...I].reverse().find(G=>G.answer?.actionId!==void 0)?.answer?.actionId,q=P.answer?.selection,Q=j!==void 0||q?{...j!==void 0?{actionId:j}:{},...q?{selection:q}:{}}:void 0;return{edits:I.map(G=>G.edits),guid:u,rev:P.rev,...Q?{historyAnswer:Q}:{}}},f=()=>{const I=l.activeMove(),P=I&&v?.action===I.kind?v:void 0;if(P&&(v=void 0),!(!P&&!I?.selection))return{...P?{actionId:P.actionId}:{},...I?.selection?{selection:I.selection}:{}}},p=I=>{b({edits:[],rev:c.get().version,answer:{actionId:I.actionId}}).catch(rt)},b=async I=>{if(_){_.push(I);return}_=[I];try{do await n.sendAsync(K.SANDBOX_UPDATE_ENTITY,h(_.splice(0,_.length)));while(_.length)}catch(P){O("app edits failed to reach the canvas",P)}finally{_=null}},x=I=>{I.length&&n.sendAsync(K.SANDBOX_UPDATE_ENTITY,h(I)).catch(rt)},N=(I,P)=>{T=!0,x(_?.splice(0,_.length)??[]);const j={edits:[I],guid:u,rev:c.get().version,...P!==null?{changeId:P}:{}};P!==null&&k.remember(P,A,j),n.sendAsync(K.SANDBOX_UPDATE_ENTITY,j).catch(rt)},S=new Set,w=(I,P,j,q)=>{N([],q);const{length:Q,hash:G}=Lr(JSON.stringify(j.map(L=>[L.oldText,L.newText]))),z=`${Q}:${G}`;S.has(z)||(S.add(z),O(I,P))},M=(I,P,j)=>w("canvas service batch removes a large part of the email",new Error(`canvas service batch removes ${I.removed} of ${I.total} tags`),P,j),B=({changeId:I,baseRev:P})=>{!T&&(I!==null||P!==null)&&N([],I)},W=I=>{if(I.guid!==u)return;const P=sh(I);T=!1,A=R(P.originId);try{re(I,P)}catch(j){B(P),O("canvas batch failed to apply",j)}finally{B(P),P.changeId!==null&&C.note(P.changeId,A)}},re=(I,P)=>{const{pushUndoStop:j}=I,q=P.changeId!==null?k.find(P.changeId,A):void 0;if(q){T=!0,n.sendAsync(K.SANDBOX_UPDATE_ENTITY,q).catch(rt);return}let{edits:Q,selection:G}=I;if(P.baseRev!==null){const z=E.rebase(Q,P.baseRev);if(!z){dn(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),N([],P.changeId);return}z!==Q&&(G=void 0),Q=z}try{d=!0,m=P.changeId;const z=Ub(Q,c.getContent());if(Kb(z,c.getContent())){w("canvas batch erases the whole email",new Error("canvas batch erases the whole email"),z,P.changeId);return}if(j===!1){const L=Yb(z,c.getContent());if(L){M(L,z,P.changeId);return}l.applyWithoutHistory(z)}else l.recordAt(I.typedAt,()=>c.mutate({changes:z},{source:Cu(e)?"system":"user"}),G),I.closesStep&&l.closeGroup()}finally{d=!1,m=null}},oe=c.subscribe(({changes:I,version:P})=>{const j=c.getContent(),q=!I?.length&&j!==y;if(y=j,E.record({version:P,changes:I,contentReplaced:q,fromCanvas:d}),!I?.length)return;const Q=$b(I);d?N(Q,m):b({edits:Q,rev:P,answer:f()}).catch(rt)}),ie=n.addListener(K.APPLICATION_UPDATE_ENTITY,W),X=n.addListenerAsyncPipe(Nf,(I,P)=>{v=Jb(I);try{return P?.(I)}finally{const j=v;v=void 0,j&&p(j)}},Xb),$=(I,P,{reportId:j,dropsCovered:q})=>{const Q=_?.splice(0,_.length)??[];n.sendAsync(K.SANDBOX_UPDATE_ENTITY,{edits:[Gb(I,P)],guid:u,rev:c.get().version,resync:{textFingerprint:Lr(P),reportId:j}}).catch(G=>O("canvas resync edit failed to reach the canvas",G)),q&&x(Q)},g=n.addListener(K.APPLICATION_SYNC_DRIFT,I=>{if(!((I.reason==="echo-timeout"||I.reason==="resync-failed")&&I.guid!==void 0&&I.guid!==u)){if(I.reason==="resync-failed"){O("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(I.reason==="echo-timeout"){const{textFingerprint:P}=I,j=fn(c),q=Lr(j);if(P?.length===q.length&&P.hash===q.hash){k.echoes(R(I.originId??null)).forEach(G=>{n.sendAsync(K.SANDBOX_UPDATE_ENTITY,G).catch(rt)}),I.reportId!==void 0&&$(j,j,I);return}const Q=new Error(`canvas echo timeout, ${I.unsent??0} edits unsent`);if(I.canvasText===void 0){O("canvas lost the echo of its batch",Q);return}$(I.canvasText,j,I)}}});return()=>{D=!1,F(),oe(),ie.dispose(),X.dispose(),g.dispose()}};let i;const s=()=>{const c=t.current(),l=t.history(),u=c?.get().docId;u!==i&&(r?.(),r=void 0,i=u,c&&l&&(r=o(c,l)))},a=t.subscribe(s);s(),e.getInstance(Y)?.addDispose(()=>{r?.(),a()})}function Zb(e){const t=fe(e),n=()=>me(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(K.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(K.RELOAD,a=>{const c=me(e)?.byWindow(a);c&&Tu(e,c.element)}),i=t.addListener(a=>{a.data?.operation===K.SANDBOX_RESIZED&&n()?.resize()}),s=ne(e,H.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(Y)?.addDispose(()=>{r.dispose(),o.dispose(),i.dispose(),s.dispose()})}function Ys(){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 e_(e){const t=e.getInstance(we);let n,r;e.getInstance(Y)?.addDispose(()=>{r?.remove(),r=void 0}),Ob(e,{resolveMount:()=>n,resolveSrc:i=>au(i==="block"),elementId:"email_iframe",mark:i=>ae(i)}),t?.watch(i=>{const s=i?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,me(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(i!==void 0){n=r??=Ys(),me(e)?.alignSurface("email",r,r);return}else return;me(e)?.get("email")}});let o;e.getInstance(Y)?.addDispose(()=>{o?.remove(),o=void 0}),Sg(e).watch(i=>{const s=me(e);if(s){if(i){o??=Ys(),s.alignSurface("email",o,o);return}o&&(s.alignSurface("email",null),o.remove(),o=void 0)}})}var xi=U("canvas.headerFlow"),Xs=["subject","preheader"],Js=3e3,t_=3,n_={subject:K.SANDBOX_SUBJECT_UPDATE,preheader:K.SANDBOX_PREHEADER_UPDATE};function r_(e){const t=ye(e),n=fe(e),r=R=>R?"remote":Cu(e)?"system":"user",o=(R,{guid:A,value:D,forced:O})=>{const h=Ct(t);if(!h||typeof D!="string"||A&&A!==h.get().docId)return;const f=t.forcedHeaders();if(f?.[R]!==void 0&&!O&&D!==f[R])return;const p=h.get().attributes[R];if(!O&&_(R,D,p))return;const b=!O&&d.delete(R);O&&(y.delete(R),y.size===0&&t.endForcedHeaders()),c=!0;try{Mt(h,{[R]:D},{source:b?"system":r(O)})}finally{c=!1}i[R]=D};let i={},s,a,c=!1,l=Promise.resolve();const u={},d=new Map,m=(R,A)=>{i[R]=A;const D={};d.set(R,D);const O=()=>{d.get(R)===D&&d.delete(R)};v(R,A,{force:!0}).then(O),setTimeout(O,Js)},_=(R,A,D)=>{const O=t.showFill();if(!O||typeof D!="string")return!1;const h=u[R]?.showId===O.showId?u[R]:void 0;return A===D?(u[R]=h??{showId:O.showId,codeEdits:O.codeEdits,corrections:0},!1):h&&O.codeEdits>h.codeEdits&&A!==h.stale?!1:((!h||A===h.stale&&h.corrections<t_)&&(u[R]={showId:O.showId,stale:A,codeEdits:O.codeEdits,corrections:(h?.corrections??0)+1},m(R,D)),!0)},v=(R,A,{force:D=!1,echo:O=!1,undoStep:h=!1})=>(l=n.sendAsync(n_[R],{value:A,guid:Ct(t)?.get().docId,...D?{force:!0}:{},...O?{echo:!0}:{},...h?{undoStep:!0}:{}}).catch(f=>{}),l);let E;const y=new Set;e.inject(xi,{whenDelivered:async()=>{await l},reassert:R=>{const A=Ct(t),D=Xs.filter(O=>typeof R[O]=="string");if(!(!A||D.length===0)){c=!0;try{Mt(A,Object.fromEntries(D.map(O=>[O,R[O]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(D.map(O=>[O,R[O]]))),clearTimeout(E),E=setTimeout(()=>{y.clear(),t.endForcedHeaders()},Js),y.clear();for(const O of D)y.add(O);for(const O of D)i[O]=R[O],v(O,R[O],{force:!0,echo:!0})}}});const k=()=>{s?.(),s=void 0;const R=Ct(t);if(R!==a&&d.clear(),a=R,!R){i={};return}const A=R.get().attributes;i={subject:A.subject,preheader:A.preheader},s=R.subscribe(({source:D})=>{if(c)return;const O=R.get().attributes,h=t.forcedHeaders();for(const f of Xs){const p=O[f];if(p===i[f])continue;i[f]=p,d.delete(f);const b=D==="system"&&h?.[f]!==void 0;v(f,p??"",{force:b,echo:b,undoStep:D==="user"})}})};k();const C=t.subscribe(k),F=n.addListenerAsync(K.APPLICATION_SUBJECT_UPDATE,R=>o("subject",R)),T=n.addListenerAsync(K.APPLICATION_PREHEADER_UPDATE,R=>o("preheader",R));e.getInstance(Y)?.addDispose(()=>{F.dispose(),T.dispose(),C(),s?.(),clearTimeout(E)})}function o_(e){const t=ye(e);let n={document:void 0,seq:0};const r=()=>{const i=t.recoveryFacts(),s=Ct(t);if(!i?.applied||!s||String(i.emailId)!==String(s.get().serverId)||(n.document!==s&&(n={document:s,seq:0}),i.applied.seq<=n.seq))return;n={document:s,seq:i.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(xi)?.reassert(a)},o=t.subscribe(r);e.getInstance(Y)?.addDispose(o)}function i_(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?Cf:Sf}function s_(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function a_(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Qs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function xo(e,t){const n={...e};for(const r of Object.keys(t)){const o=t[r],i=e[r];Qs(o)&&Qs(i)?n[r]=xo(i,o):o!==void 0&&(n[r]=o)}return n}function c_(e,t){const n=ii;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const o=JSON.parse(r);if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0)return xo(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?xo(n,t):n}var l_=ce(void 0),Zs=l_,Ou=U("CodeMode");function ku(){let e;try{const t=window.localStorage?.getItem(hr.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function u_(e){try{window.localStorage?.setItem(hr.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function Ar(e){return e.getOrCreateInstance(Ou,()=>{const t=ce(ku());return t.watch(u_),t})}function Pu(e){return e?.getInstance(Ou)?.get()??ku()}function Mo(e,t){const n=Ar(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function d_(e,t){const n=Ar(e);n.set({...n.get(),direction:t})}var f_=U("DefaultCommonStyles");function Du(e){return e.getOrCreateInstance(f_,()=>ce(void 0))}function p_(e,t){Du(e).set(t)}var h_=U("CanvasViewport"),m_=U("CanvasPreviewPage");function ze(e,t,n){let r,o;const i=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==o&&(o=c,e.send(t,r.value))},s=n.watch(c=>{r={value:c},i()}),a=e.onInit(()=>{o=void 0,i()});return{dispose(){s.dispose(),a.dispose()}}}function Fn(e){const t=ce(e());return{source:t,refresh:()=>t.set(e())}}function g_(e){const t=fe(e),n=e.getInstance(ge),r=e.getInstance(we),o=ye(e),i=Ar(e),s=matchMedia(Hf),a=()=>n?.get()??{};let c;const l=Fn(()=>i_(Zs.get()??a().theme,s.matches)),u=Fn(()=>s_(a(),ee(o.sessionKey()))),d=Fn(()=>a().lockEditor),m=Fn(()=>c_(o.current()?.get().attributes?.common_styles,c)),_=e.getOrCreateInstance(h_,()=>ce()),v=e.getOrCreateInstance(m_,()=>ce()),E=[ze(t,We.theme,l.source),ze(t,We.flags,u.source),ze(t,We.lockEditor,d.source),ze(t,We.commonStyles,m.source),ze(t,We.codeMode,i.select(a_)),ze(t,We.appName,ce("useblocks")),ze(t,We.previewPage,v),ze(t,We.viewport,_)],y=()=>{l.refresh(),u.refresh(),d.refresh()},k=n?.watch(y),C=Du(e).watch(h=>{c=h,m.refresh()}),F=r?.watch(h=>{h&&"commonStyles"in h&&(c=h.commonStyles),m.refresh()});let T;const R=()=>{T?.(),T=o.current()?.subscribe(()=>m.refresh()),m.refresh(),u.refresh()};R();const A=o.subscribe(R),D=()=>l.refresh();s.addEventListener("change",D);const O=Zs.watch(()=>l.refresh());e.getInstance(Y)?.addDispose(()=>{E.forEach(h=>h.dispose()),k?.dispose(),C.dispose(),F?.dispose(),T?.(),A(),s.removeEventListener("change",D),O.dispose()})}var Lo;(function(e){function t(o,i,s=(a,c)=>a===c){if(o===i)return!0;if(o.length!==i.length)return!1;for(let a=0;a<o.length;a++)if(!s(o[a],i[a]))return!1;return!0}e.isEqual=t;function n(o,i=s=>s){const s=new Set;return o.filter(a=>{const c=i(a);return s.has(c)?!1:(s.add(c),!0)})}e.unique=n;function r(o=[],i=[],s=(a,c)=>a===c){const a=[],c=[],l=[];for(const u of o){const d=i.find(m=>s(u,m));d?l.push({prev:u,next:d}):c.push(u)}for(const u of i)o.find(d=>s(u,d))||a.push(u);return{added:a,removed:c,exists:l}}e.diff=r})(Lo||(Lo={}));function v_(e,t){return e.type===t.type&&e.key===t.key}function b_(e){const t=fe(e),n=()=>e.getServices(Tt)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(K.SANDBOX_ADD_EXTENSIONS,r)}),i=sf(Tt),s=e.onInject(a=>{if(a!==i)return;const c=n();if(!t.isInited()){r=c;return}const{added:l,removed:u}=Lo.diff(r,c,v_);if(r=c,u.length){if(u.some(d=>d.type==="script")){t.send(K.RELOAD);return}t.send(K.SANDBOX_REMOVE_EXTENSIONS,u.map(d=>d.key))}l.length&&t.send(K.SANDBOX_ADD_EXTENSIONS,l)});e.getInstance(Y)?.addDispose(()=>{o.dispose(),s?.dispose()})}var __=new Set([...Object.values(K).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(ai)]);function y_(e){return e.length>0&&!e.startsWith("em:")&&!__.has(e)}function E_(e){const t=fe(e),n=new Map;let r=!1,o=-1,i=new Set;const s=l=>(l!==o&&(o=l,i=new Set),i),a=t.observeOutgoing((l,u)=>{if(!r||!y_(l))return;const d=Te(t);n.set(l,{data:u,generation:d,scripts:new Set(s(d))})}),c=t.addListener(ai,l=>{if(l.phase!=="ready"||l.status!=="success")return;r=!0;const u=Te(t),d=s(u);d.add(l.key);for(const[m,_]of n)_.generation===u||![..._.scripts].every(v=>d.has(v))||(_.generation=u,t.send(Pc(m),_.data))});e.getInstance(Y)?.addDispose(()=>{a.dispose(),c.dispose()})}var w_=U("prewarm.editorVisible");function S_(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function I_(e={}){const t=e.paint??S_;let n=!1,r=!1,o=!1,i=!1,s=!1;const a=[],c=()=>{s||i||!n||!r||!o||(i=!0,t(()=>{s=!0,ae(Ee.editorVisible);for(const l of a.splice(0))l()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){o=!0,c()},whenVisible(l){if(s){l();return}a.push(l)},contentShown:()=>o}}function T_(e){return e.getOrCreateInstance(w_,()=>I_())}var A_=500,C_=500,R_=5e3;function O_(e){const t=e.quietMs??A_,n=e.floorMs??C_,r=e.ceilingMs??R_;let o,i,s=0;const a=()=>{clearTimeout(o),clearTimeout(i),o=void 0,i=void 0},c=()=>{a(),e.run()},l=()=>{clearTimeout(o);const u=n-(Date.now()-s);o=setTimeout(c,Math.max(t,u))};return{start(){a(),s=Date.now(),i=setTimeout(c,r),l()},notify(){o!==void 0&&l()},cancel:a}}var k_=2;function ea(){return new Error("[sandbox] document reloaded during fill")}function P_(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Wr(e){try{e()}catch{}}function D_(e){let t;return Wr(()=>{t=e()}),{stage:n=>Wr(()=>t?.stage(n)),end:(n,r)=>Wr(()=>t?.end(n,r))}}function x_(e){const t=()=>e.initPipeline();let n=!1,r,o,i,s=0,a,c;const l=()=>{const A=e.readTarget?.(),D=e.readSandboxGeneration?.();return A===void 0||D===void 0?void 0:{target:A,generation:D}},u=()=>{const A=l();return A&&{...A,canvasReplaced:e.trackDocument?.(A.target)}},d=A=>{if(A?.canvasReplaced?.())return!0;const D=l();return A!==void 0&&D?.target===A.target&&D.generation!==A.generation},_=Kv({...e,waitScope:()=>({getSandboxTimeoutMs:A=>t().getSandboxTimeoutMs(A),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const A=c;if(!(!A||!e.onSandboxGenerationChange))return{getGeneration:()=>l()?.generation??A.generation,onChange:D=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===A.target||A.canvasReplaced?.())&&D()})??(()=>{})}}});let v;const E=(A,D)=>{if(v===A)return;v=A;const O=s;setTimeout(()=>{s!==O||t().signal.aborted||F(A,D).catch(()=>{})},0)},y=()=>{a?.abort(),a=void 0};let k;const C=()=>{const A=t().signal;A!==k&&(k?.removeEventListener("abort",y),k=A,A.addEventListener("abort",y))};async function F(A,D,O=0){const h=++s;y(),a=new AbortController,c=void 0,C();const f=()=>s!==h,p=_.readTarget(),b=t().generation,x=()=>b===t().generation&&!t().signal.aborted,N=D?"init:reset-":"init:",S=D_(()=>e.observeShow?.(P_(A,D,e.readEmail())));if(!D){const ie=_.publicEmail();ie?.id,ie?.renderGuid,ie?.preheader}let w=!1,M=!1,B,W=!1;const re=()=>{if(d(B))throw ea()},oe=()=>{if(f())throw Ie("Fill superseded")};try{n=!0,await _.sendInitStart(),oe(),B=u(),c=B,O===0&&_.fireWillInit(),await(D||O>0?_.refreshContent():_.sendContent()),w=!0,oe(),re();const ie=_.contentSent();_.noteFilled(ie?.target,ie?.docId),S.stage("content"),D||_.publicEmail()?.id;try{await _.sendPreheader()}catch(X){if(Hs(X)||f())throw X;`${N}`,String(X)}oe();try{await _.sendSubject()}catch(X){if(Hs(X)||f())throw X;`${N}`,String(X)}if(oe(),re(),_.showFilled(p),await _.sendInited(),oe(),re(),M=!0,o===A){const X=e.readSandboxGeneration?.()??i;X!==void 0&&(r=X)}S.stage("reveal"),await _.revealFilled(),re(),S.end("revealed")}catch(ie){const X=!f()&&x()&&d(B),$=X?ea():void 0,g=$??ie,I=X&&O<k_?R(A,D,O+1):void 0;W=X&&I===void 0;const P=f()?void 0:{showId:A,contentApplied:w,sandboxInitedAcked:M,superseded:!1,...e.describeSurface?.(),error:String($??ie)};P&&(`${N}`,void 0);const j=!f()&&e.recoverFailedFill?.(p)===!0;if(S.end(f()?"superseded":j?"recovered":ui(g)||!x()?"aborted":"failed",P),!j&&!f()&&ki(t(),A)&&t().failShow(A,g),I!==void 0)return I;throw g}finally{T(A,D,N,{superseded:f(),sessionGeneration:b,contentApplied:w,sandboxInitedAcked:M&&!W,retry:!W,commit:x()})}}function T(A,D,O,h){const{superseded:f,contentApplied:p,sandboxInitedAcked:b}=h;if(f){`${O}`;return}b&&h.commit?_.fireInit(A,D||void 0):b?(`${O}`,h.sessionGeneration,t().generation,t().signal.aborted,void 0):p?(`${O}`,void 0):(`${O}`,void 0),n=!1,a=void 0,!b&&o===A&&(o=void 0,r===i&&(r=void 0)),!b&&p&&h.retry&&E(A,D)}function R(A,D,O){return F(A,D,O)}return{channel:_,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:A=>{r=A},lastCorrelation:()=>o,markCorrelation:A=>{o=A},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:A=>{i=A},fill:A=>F(A,!1),refill:A=>F(A,!0),stop:()=>{s+=1,y(),n=!1,k?.removeEventListener("abort",y),k=void 0}}}function M_(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:xu(e,n)}function xu(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function L_(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:i}=e,s=u=>{const d=n(),m=o();if(!M_(d,u,m)){u.showId,u.navId,u.emailId,d?.id,d?.showId,d?.renderGuid;return}u.showId,d?.id,d?.renderGuid,t.markFilled(i()),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=i();if(t.filledGeneration()===u)return;const d=n(),m=o();if(!d?.renderGuid||!xu(d,m))return;const _=`${mu}${d.renderGuid}`;t.markFilled(u),t.markCorrelation(_);const v=r()?.isReady()===!0;d.id,d.renderGuid,(v?E=>t.refill(E):E=>t.fill(E))(_).catch(()=>{t.lastCorrelation()===_&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var N_=U("canvas.health");function F_(e){return e??""}function B_(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function ta(e){return e.length>0}function j_(e){const t=ye(e),n=fe(e),r=()=>ee(t.sessionKey())?void 0:t.current(),o=()=>{const L=r();return Au({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},i=()=>e.getInstance(Fe)??Pi;let s={},a=!1;const c=e.getInstance(we)?.watch(L=>{a=!!L?.element});let l=!1,u=!1,d=!1,m=0;const _=()=>{const L=me(e);if(!L)return;const J=++m,Z=L.spare();return Z&&Tu(e,Z.element),(Z?Z.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(J!==m)return;l=!0;const be=L.spare();be&&Db(e,be.element),d&&(d=!1,b(),X())})},v=O_({run:()=>{d||_()?.catch(()=>{})}}),E=()=>{T_(e).noteContentShown(),!l&&!d&&v.start()};let y=!1;const k=L=>{const J=me(e),Z=J?.spare()?.element.contentWindow;u&&J&&Z&&L===Z&&(u=!1,J.promote(),J.busy(!1),y=!0)};let C=!1;const R=x_({container:e,messageService:n,initPipeline:i,readDocument:r,readEmail:o,revealFilled:()=>{const L=me(e);return y&&L&&(y=!1,v.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:k,noteFilled:(L,J)=>me(e)?.noteFilled(L,J),recoverFailedFill:L=>{const J=me(e),Z=J?.spare()?.element.contentWindow;return!u||!J||!Z||L!==Z?!1:(u=!1,l=!1,f="reload",J.busy(!1),J.peek("email")?.reload(),C=!0,X(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>Te(n),onSandboxGenerationChange:L=>un(n,L),trackDocument:L=>xb(e,L),observeShow:L=>e.getInstance(N_)?.begin(L),describeSurface:()=>({canvasPath:f,promoted:u,spareClean:l,handshake:n.isInited(),generation:Te(n)}),events:{willInit:L=>{_e(e,H.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{E(),_e(e,H.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{_e(e,H.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{_e(e,H.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{_e(e,H.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),A=L_({pipeline:R,initPipeline:i,readEmail:o,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>Te(n)});let D="",O="",h="",f="none";const p=()=>{const L=me(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:K.SANDBOX_LOCK_EDIT,data:!0})},b=()=>{const L=me(e)?.spare();L&&(p(),l=!1,u=!0,kb(e,L.element))},x=(L,J)=>{const Z=me(e);if(!Z)return!0;const be=Z.spare(),te=be&&l?"spare":"prepare";if(f=te,Z.busy(!0),be&&l)return b(),!0;v.cancel(),p();const et=_();if(et===void 0)return f="reload",Z.busy(!1),Z.peek("email")?.reload(),!0;d=!0;const qe=m;return et.catch(()=>{!d||qe!==m||(d=!1,f="reload",Z.busy(!1),Z.peek("email")?.reload())}),!1},N=()=>{if(ee(t.sessionKey()))return;q(),R.noteSandboxGeneration(Te(n));const L=o(),J=B_(L?.renderGuid,L?.showId,L?.id,s.emailId),Z=F_(L?.renderGuid);if(Z!==O){const et=O;O=Z;const qe=me(e)?.peek("email")?.filled,Wd=qe!==void 0&&qe!==Z;ta(Z)&&(ta(et)||Wd)&&x(et||(qe??""),Z)}if(d)return;(J!==D||C)&&(C=!1,D=J,A.showRequestIdentityChanged());const be=r(),te=`${J}|${be?.get().docId??""}|${Te(n)}`;te!==h&&be?.isReady()===!0&&(h=te,A.selfInitChanged()),A.saasChanged(),oe()};let S=!1,w="",M="",B=!1,W=!1;const re=L=>{L.source==="user"?W=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(B=!0),X()},oe=()=>{const L=o();if(!L?.renderGuid)return;const J=R.channel.readContent(),Z=JSON.stringify([L.preheader,L.common_styles,L.meta,L.subject,L.utm_parameters?.utm_campaign??"",L.utm_parameters?.utm_content??"",L.utm_parameters?.utm_medium??"",L.utm_parameters?.utm_source??"",L.utm_parameters?.utm_term??""]),be=S&&J!==M,te=S&&Z!==w;S=!0,M=J,w=Z;const et=B&&!W;if(B=!1,W=!1,R.isEventsLocked()||et)return;const qe={...L,id:s.isTemplate||L.isNew?void 0:L.id,html:J};if(be){_e(e,H.ON_CONTENT_CHANGED_ID).fire(J),_e(e,H.ON_EMAIL_CHANGED_ID).fire(qe);return}te&&L.is_inited&&_e(e,H.ON_EMAIL_CHANGED_ID).fire(qe)};let ie=!1;const X=()=>{ie||(ie=!0,queueMicrotask(()=>{ie=!1,N()}))};e.inject(Di,{pipeline:R,setRoute:L=>{L.emailId===s.emailId&&!!L.isTemplate==!!s.isTemplate||(s=L,X())}});let $,g;const I=()=>{const L=r()?.get().docId;L!==g&&($?.(),g=L,$=r()?.subscribe(re)),X()};let P,j;const q=()=>{const L=e.getInstance(Fe);!L||L===P||(j?.(),P=L,j=L.onShowRequested(J=>A.showRequested(J)))},Q=n.addListener(L=>{L.data?.operation===K.SANDBOX_RESIZED&&v.notify()}),G=t.subscribe(I),z=un(n,X);I(),e.getInstance(Y)?.addDispose(()=>{c?.dispose(),j?.(),z(),G(),$?.(),Q.dispose(),v.cancel(),R.stop()})}function U_(){return $f!=="useblocks"}var Mu={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},$_={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:!0,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},na=Mu,H_=["freeUserBlocks","blocks"],No={};function V_(e){No=e}var Lu=e=>H_.includes(e)?na:No[e]??No.editor??na,Fo={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},G_={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:!0,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},q_={...Fo,config:{...Fo.config,imageCenterFileManagerView:!1}};V_({pro:$_,editor:G_,simple:U_()?Fo:q_,blocks:Mu});function W_(e,t,n=e.getInstance(ge)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Pu(e).isCodeMode&&Mo(e,!1)}function z_(e){e.getInstance(mf)||e.inject(Ve,void 0)}function Cr(e){return String(e.standaloneKey||"").trim()||void 0}function K_(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function Mi(e){return K_(e)?!!Cr(e):!1}function Sn(e){return!!Cr(e)&&!Mi(e)}var Y_=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function ra(e){return e==="server"?"serverSide":e}function X_({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=ce();let i={kind:"pending"},s;const a=new Promise(m=>{s=m}),c=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function l(){i.kind!=="pending"&&o.set(Vr(r,e))}function u(m){if(i.kind!=="pending")return;clearTimeout(c),i=m;const _=Vr(r,e);o.set(_),s(_)}function d(m,_){r[ra(m)]=_,m==="server"&&i.kind==="pending"?u({kind:"applied"}):l()}return{watch:m=>o.watch(m),select:m=>o.select(m),get:()=>o.get(),ready:()=>a,state:()=>i,layers:()=>({...r}),bootstrap(){const m=Vr(r,e);return Object.fromEntries(Y_.map(_=>[_,m[_]]))},merge(m,_){d(_,{...r[ra(_)],...m})},replace(m,_){d(_,m)},setMode(m){r.user={...r.user,mode:m},l()},setAdvancedConfigs(m){r.advancedConfigs=m,l()},serverAbsent(m){u({kind:"absent",reason:m})},applyServerResponse(m){i.kind==="pending"&&d("server",{...r.serverSide,...m})},dispose(){clearTimeout(c)}}}var J_=5e3,Q_="blocks";function Z_(){return{...Lu(Q_)?.config,mergeTags:void 0}}function ey(e,t){e.getInstance(we)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},o=t.layers().user.mode;t.replace(r.mode===void 0&&o!==void 0?{...r,mode:o}:r,"user")})}function ty(e,t){let n;Ai(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const i={};r?.theme&&(i.theme=r.theme),r?.locale&&(i.locale=r.locale),t.replace(i,"profile")})}function ny(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function ry(e,t){let n,r=!1,o;const i=a=>{o??=wr(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&W_(e,a,t)},s=Ai(e).watch(({profile:a})=>{const c=a?.email_builder_config,l=ny(c);if(l===void 0||c===n)return;const u=n===void 0;n=c,!(u&&r)&&i(l)});e.getInstance(Y)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,i(c)})}var oa="замкнутый контур: app_init не выполняется";function oy(e,t){if(e.getInstance(Ve)){t.serverAbsent(oa);return}const n=e.getInstance(we)?.watch(r=>{Sn(r)&&t.serverAbsent(oa)});n&&e.getInstance(Y)?.addDisposable(n)}async function iy(e,t){if(e.getInstance(pi)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Xe);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function sy(e){e.injectFactory(ge,(t,n)=>{if(n)return n;const r=X_({base:Z_(),env:{modeDefaults:o=>Lu(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:J_});return ey(e,r),ty(e,r),ry(e,r),oy(e,r),iy(e,r),e.getInstance(Y)?.addDisposable(r),r},!0)}var Pt=class extends ve{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function V(e,t,n){const r=lf(e);return(o,i,s)=>{const a=r(async c=>{const l=t?t(c):c;s&&o.bind(s);const u=await o(l);return n?n(u):u},i,s);return()=>a.dispose()}}var ay=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new go;this.handleDestroy=V(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Pt(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},Li=U("DestroyableService");function cy(e){e.injectFactory(Li,(t,n)=>{if(n)return n;const r=e.getInstance(Y);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new ay({lifetime:r,options:e.getInstance(we),getInstance:()=>e.getInstance(bn),release:()=>bf(e.getInstance(Ic)??e)})},!0)}function ly(e){const t=e.getInstance(Li);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var uy=1e3;function Nu(e,t,n=uy,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const s of o)if(!Nu(e[s],t[s],n,r+1))return!1;return!0}return!1}function sn(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const o=t[r],i=e[r];Nu(o,i)||(n[r]=o)}return n}var dy=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function fy(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function py({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??En();let i;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,c)=>{i=setTimeout(()=>{const l=new mr(o);n.value.id,bh(l,fy(s,r)),c(l)},o)})])}catch(s){throw ml(s),s}finally{i!==void 0&&clearTimeout(i)}}function hy(e){const{emails:t}=e,n=async(r,o)=>{const i=dy(o),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...i}:i,c=s?sn(s,i):i,l=u=>{const d=String(u.id??r??ke()),m=u.id===void 0?{...u,id:d}:u;return t.cache.addOrUpdate(d,()=>m)};return await l(await py(e,{prev:s,patch:c,value:a,source:o.source??""},l))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const o=await n(void 0,r);return o?.renderGuid?o:{...o,renderGuid:ke()}},async updateEmail(r,o){return await n(r,o)}}}var zr=20;function my(e){const t=gy(e);return e.saveTimeoutMs?vy(t,e.saveTimeoutMs):t}function gy({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:i}){const s=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(l=>String(l?.parent)===String(a)));return{async readRevisions(a,c=1){const l=await s(a,c);return{revisions:l.slice(zr*(c-1),zr*c),page:c,hasMore:l.length>zr*c}},async readAutosave(a){const c=await r?.(a)??NaN,l=Number.isFinite(c)?c:void 0,u=await n?.(a);if(!u?.asked)return Ah(await s(a,1),l);if(!u.revision)return bs([],l);const d={...u.revision,parent:a,isAutosave:!0};return bs([d],l,await s(a,1))},async saveAutosave(a,c){const l=await o?.(a),u=i?.();return await e.create({...Dh(c),...l!==void 0?{author:l}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function vy(e,t,n){return{...e,async saveAutosave(r,o){const i=t();if(i===void 0)return e.saveAutosave(r,o);let s;try{return await Promise.race([e.saveAutosave(r,o),new Promise((a,c)=>{s=setTimeout(()=>c(new Yc(i,n)),i)})])}catch(a){throw ml(a),a}finally{s!==void 0&&clearTimeout(s)}}}}var by=class extends df{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}},_y=class extends Je{};var ia=class extends ve{_items=new Map;_onChangeEmitter=new pf;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const o=await t(n);return Ne(n,o)||this._onChangeEmitter.fire(),o}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([o,i])=>o)),r=(await this.entries()).filter(([o,i])=>!n.has(o));for(const[o,i]of e)t.push(this.addOrUpdate(o,()=>i)),n.add(o);for(const[o]of r)t.push(this.remove(o));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function yy(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:i=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(l=>{for(const u of c){const d=l[u],m=t[u];return u==="id"||typeof d!="string"?d===m:typeof m=="string"&&d.startsWith(m)}return!0}),a=e.length}return r&&(e=e.sort((c,l)=>(c[r]>l[r]?1:l[r]>c[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(i*(o-1),i*o)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/i)}}function Ey(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const o=t.get(r.id)||{};t.set(r.id,{...o,...r})}return[...t].map(([n,r])=>r)}function wy(e,t){return sa(e)&&sa(t)?String(e)===String(t):e===t}function sa(e){return typeof e=="string"||typeof e=="number"}var Sy=class extends ve{_cache=new ia;_readEmitter=new Je;_saveEmitter=this.addDisposable(new by);_removeEmitter=this.addDisposable(new _y);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}async confirmedMissing(e){if(!this.hasReadHandler())return!1;const{results:t,errors:n}=await this._readEmitter.fireSettled(e);return!n.length&&!t.some(Boolean)}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ve);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new ia),o=n.addDisposable(new Je);t=this._foreignCache[e]={get:async(i,s={})=>{await r.getOrCreate(i,async()=>{try{const c=Ey(await o.fire(i))||[];for(const l of c)l[e]=i,await this._cache.add(l.id,l);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const l=c[e];return l==null||wy(l,i)});return yy(a,s)},first(i,s={}){return t.get(i,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:o.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=ke()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async o=>{const i=o?{...o,...t}:t;if(!r)return t=o?sn(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:i,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function In(e){const t=U(e);return n=>n.getOrCreateInstance(t,()=>new Sy)}function Fu(e){const t=e.getInstance(Y);if(!t)throw new Error("Failed");return t}function aa(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Bn(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function Iy(e,t,n){return e&&!aa(t)&&aa(e)?{...n,meta:e.meta}:n}var Ty=U("CurrentProject"),Ay={};function Tn(e){return e?.getInstance(Ty)?.get()??Ay}function Ni(e){const t=Tn(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Bu=In("plugin.dataSource.emails"),ju=In("plugin.dataSource.emailRevisions"),Uu=Ir("plugin.readEmailAutosave"),ca=U("emailDocuments.provided");function Cy(e){const t=Bu(e),n=ju(e),r=n.byForeignKey("parent");if(e.getInstance(ca))return{emails:t,emailRevisions:n};e.inject(ca,!0);const o=()=>En(e.getInstance(Fe)?.contentReadyTimeoutMs),i=hy({emails:t,saveTimeoutMs:o}),s=new Map,a=(c,l)=>u=>{const d=u?.id??l;return(typeof d=="string"||typeof d=="number")&&s.set(String(d),c),u};return tm(e,{...i,createEmail:c=>i.createEmail(c).then(a(Date.now())),updateEmail:(c,l)=>i.updateEmail(c,l).then(a(Date.now(),c))}),im(e,my({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const l=await _e(e,Uu).fire(c);return l.length===0?{asked:!1}:{asked:!0,revision:l[0]??null}},savedAt:async c=>{const l=Ih((await t.cache.getIfPresent(c))?.modified),u=s.get(String(c))??NaN;return Number.isFinite(u)&&!(l>=u)?u:l},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:o,integratorProject:()=>Tn(e).requested})),Fu(e).addDisposable(t.onSave(({prev:c,patch:l,value:u})=>Iy(c,l,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function la(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 Ry(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Oy="po",jn=null;function ky(){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([Oy],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Py(){return jn===null&&(jn=ky().catch(e=>{throw jn=null,e})),jn}async function $u(e){if(typeof e=="object")return Fi(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Dy(t):xy(t)}function Fi(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Dy(e){try{return Fi(JSON.parse(e))}catch{return}}var ua=!1;async function xy(e){try{return Fi((await Py()).parsePoCatalog(e))}catch{ua||(ua=!0);return}}var My="em_locale",Ly="em_ant_locale",Ny="locale",Fy="ant_locale";function Bi(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Hu(e,t){const n=Bi(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function By(){return Bi("em_locale")??Hu(Ny,"em_locale")}function da(e){try{localStorage.setItem(My,JSON.stringify(e))}catch{}}function jy(){return Bi("em_ant_locale")??Hu(Fy,"em_ant_locale")}function Uy(e,t){try{localStorage.setItem(Ly,JSON.stringify({id:e,data:t}))}catch{}}var $y=8e3;function Hy(e,t){const n=e,r=t,o=Object.keys(n).filter(i=>i!=="");return o.length!==Object.keys(r).filter(i=>i!=="").length?!1:o.every(i=>JSON.stringify(n[i])===JSON.stringify(r[i]))}function Vy(e){const t=By(),n=jy();let r={ready:!1},o;const i=ce(r);let s=0;const a=y=>{r={...r,...y},i.set(r)},c=()=>{r.ready||a({ready:!0})},l=setTimeout(c,e.unlockAfterMs??$y),u=y=>y!==s;let d;async function m(y,k){if(n?.id===y&&n.data&&a({antd:n.data}),!d)return;const C=await d(y).catch(()=>{});!C||u(k)||(a({antd:C}),Uy(y,C))}async function _(y,k){const C=await e.askHost(y).catch(()=>null);if(u(k))return!0;if(C==null)return!1;const F=await $u(C);return u(k)||(F&&a({catalog:F}),c()),!0}async function v(y,k){const C=await e.readList();if(u(k))return;if("error"in C){a({failure:{kind:"GET_LOCALES_ERROR",error:C.error}}),c();return}const F=C.data.find(R=>R.locale===y);if(!F){Ry("em_locale")&&a({catalog:void 0}),c();return}if(la(t,F)&&(!o||o.catalog===t?.data)){c();return}if(o?.entry&&r.catalog===o.catalog&&la(o.entry,F)){da(o.entry),c();return}const T=await e.readCatalog(y);if(!u(k)){if("error"in T){a({failure:{kind:"GET_LOCALE_ERROR",error:T.error}}),c();return}T.data&&(o?.id===y&&r.catalog===o.catalog&&Hy(o.catalog,T.data)||a({catalog:T.data}),da({id:y,time:F.updatedAt||Math.floor(Date.now()/1e3),hash:F.contentHash,data:T.data})),c()}}async function E(y,k){if(!await _(y,k)){if(!u(k)&&(o?.id===y&&r.catalog===o.catalog||y==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await v(y,k)}}return{set(y){if(!y||y===r.id)return;const k=s+=1;a({id:y,failure:void 0});const C=o?.id===y&&r.catalog===o.catalog;(o&&!C&&r.catalog===o.catalog||y==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===y&&t.data&&(a({catalog:t.data}),c()),m(y,k),E(y,k)},prime(y,k,C){r.id&&r.id!==y||r.catalog||!k||(o=t?.id===y&&t.data&&(!C||t.time>=C.time)?{id:y,catalog:t.data}:{id:y,catalog:k,entry:C?{id:y,time:C.time,hash:C.hash,data:k}:void 0},a({catalog:o.catalog}))},useAntdLoader(y){d=y,r.id&&m(r.id,s)},state:i,snapshot:()=>r,dispose:()=>clearTimeout(l)}}var Gy=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})},fa=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),qy=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:o,format:i,baseUrl:s,cancelToken:a,...c})=>{const l=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,l),d=o&&this.toQueryString(o),m=this.contentFormatters[r||"application/json"],_=i||u.format;return this.customFetch(`${s||this.baseUrl||""}${n}${d?`?${d}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):u.signal)||null,body:typeof e>"u"||e===null?null:m(e)}).then(async v=>{const E=v;E.data=null,E.error=null;const y=_?v.clone():v,k=_?await y[_]().then(C=>(E.ok?E.data=C:E.error=C,E)).catch(C=>(E.error=C,E)):E;return a&&this.abortControllers.delete(a),k})}},Wy=U("rest.v2.transport"),pa=Symbol("rest.v2.secureRequest");function zy(e){return e.getOrCreateInstance(Wy,()=>{const t=e.getInstance(tf)?.execute||fetch;return new qy({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[pa]:!0}),customFetch:(n,r={})=>{const{[pa]:o,...i}=r;return t(n,{...i,[vf]:o!==!0})}})})}function Vu(e,t){const n=zy(e);return Object.assign({},...t.map(r=>new r(n)))}function ha(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Rr(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:ha(n.details,"wp_code")??n.code,message:ha(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 Gu(e){return!e.ok||!!e.error}function qu(){return el(hr.em_translations_v2)??!0}function Ky(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Yy(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Xy(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],o=r[0];return typeof o=="string"&&o!==""&&t.push({locale:o,updatedAt:Ky(r[1])}),t},[]):[]}function Jy(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Yy(n.updated_at),contentHash:n.content_hash}),t),[])}function Wu(e){return Vu(e,[Gy])}function cr(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Bo(e){return!e.ok||e.error!=null}function jo(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Kr(e){return{data:await $u(e)??null}}async function Qy(e){if(qu())try{const n=await Wu(e).localesList();return Gu(n)?{error:Rr(n)}:{data:Jy(n.data)}}catch(n){return cr(n)}const t=Ac(e,[Lc]);try{const n=await t.get_translations2({file:"react_app"});return Bo(n)?jo(n):{data:Xy(n.data)}}catch(n){return cr(n)}}async function Zy(e,t){if(qu())try{const r=await Wu(e).jsonList({locale:t});return Gu(r)?{error:Rr(r)}:Kr(r.data)}catch(r){return cr(r)}const n=Ac(e,[Lc]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Bo(r)?jo(r):Kr(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Bo(r)?jo(r):Kr(r.data)}catch(r){return cr(r)}}}var Un=new WeakMap;function eE(e){const t=Un.get(e);if(t!==void 0)return t;const n=Qy(e).then(r=>("error"in r&&Un.delete(e),r),r=>{throw Un.delete(e),r});return Un.set(e,n),n}var vt=U("locale.service");function tE(e){if(e.getInstance(vt))return;const t=Vy({readList:()=>eE(e),readCatalog:n=>Zy(e,n),askHost:async n=>(await _e(e,H.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Ve)});e.inject(vt,t),e.getInstance(Y)?.addDispose(()=>t.dispose())}function nE(e){const t=e.getInstance(ge);if(!t)return;const n=e.getInstance(vt);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"en_US"));e.getInstance(Y)?.addDisposable(r)}var rE="user_id",oE="project_id",ma=U("rest.identityHeadersProvided");function iE(e){if(e.getInstance(ma))return;e.inject(ma,!0);let t;e.getInstance(we)?.watch(n=>{t=n}),e.addService(pr,{execute(n,r){if(r?.public)return;const o=t?.user?.id??Xl(e).profile?.id;o!=null&&o!==""&&n.headers.set(rE,String(o));const i=t?.project;i!=null&&i!==""&&n.headers.set(oE,String(i))}})}function sE(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function aE(e){return e.id??sE(e.catalog)}function cE(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function lE(e){return cE(e||"en_US")}var uE="Accept-Language",ga=U("rest.localeHeaderProvided");function dE(e){e.getInstance(ga)||(e.inject(ga,!0),e.addService(pr,{execute(t){const n=e.getInstance(vt)?.snapshot();t.headers.set(uE,lE(n&&aE(n)))}}))}function fE(e){if(!e)return!1;try{return e.getInstance(Ve)!==void 0}catch{return!1}}var pE="Invalid standaloneKey.",PC=U("StandaloneMockGuard");function hE(){const e=new Error(pE);return e.name="InvalidStandaloneKeyError",e}function mE(e){e.addService(pr,{execute:()=>{if(fE(e))throw hE()}})}function gE(e){Yd(e),mE(e)}function vE(e){const t=new gu;e.inject(Fe,t);const n=e.getInstance(we)?.watch(o=>{if(!o)return;const i=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...i!==void 0?{signal:i}:{}})}),r=e.getInstance(Y);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var zu=In("plugin.dataSource.blocks"),bE=In("plugin.dataSource.blockRevisions"),_E=In("plugin.dataSource.comments"),yE=Ir("plugin.readTemplateBlocks"),EE=Ir("plugin.readCommonBlocks"),wE=e=>e.replaceAll("&","&amp;").replaceAll("<","&lt;");function Ku(e=""){return`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1004
+ `));return{html:qb(t.html),hasBrowserExtensionArtifacts:t.found}}function Sn(e){return e?.getContent()??""}function Ed(e,t){e?.mutate({content:Hs(t)},{source:"remote"})}function $r(e){return B(e)}function ye(e,t){return e.getOrCreateInstance(t,()=>new et)}function ne(e,t){return e.getOrCreateInstance(t,()=>new et).event}function Er(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Wb=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 zb(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 Kb(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(ie(n),new Promise((r,o)=>{let s=!1,i,a;const c=u=>{s||(s=!0,i!==void 0&&(clearTimeout(i),i=void 0),a?.dispose(),n?.removeEventListener("abort",l),u())},l=()=>{c(()=>o(Te(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&c(()=>r())}),e.isInited()&&e.getTarget()){c(()=>r());return}t>0&&(i=setTimeout(()=>{c(()=>o(new Wb(t)))},t)),n?.addEventListener("abort",l)}))}var wd=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 Sd(e,t,n){return t<=0?e:new Promise((r,o)=>{let s=!1,i;const a=c=>{s||(s=!0,i!==void 0&&(clearTimeout(i),i=void 0),c())};i=setTimeout(()=>{a(()=>o(new wd(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>o(c))})})}var Xb=2,on=Symbol("sandbox:frame-replaced");function Ca(e){return e===on}function ut(e,t,n,r,o,s,i){const a=`sandbox:${t}`,c=s?.getSandboxTimeoutMs(t)??js[t],l=()=>{let g=Sd(e.sendAsync(n,r),c,a);return g=fr(g,s?.signal),dt(a,g,o)};if(t==="INIT_START"&&zb(e)){const g=s?.getSandboxReadyTimeoutMs()??2e4,y=e,E=P=>{const O=Kb(y,g,s?.signal);return dt("sandbox:INIT_START:ready-wait",O,o).then(()=>{if(!i||P<=0)return l();const x=i.getGeneration();let w;const C=new Promise((D,R)=>{w=i.onChange(()=>{i.getGeneration()!==x&&R(on)})}),T=l();return T.catch(()=>{}),Promise.race([T,C]).finally(()=>w?.()).catch(D=>{if(D!==on)throw D;return{...o},E(P-1)})})};return E(Xb)}if(!i)return l();const u=i.getGeneration();let d;const f=new Promise((g,y)=>{d=i.onChange(()=>{i.getGeneration()!==u&&y(on)})}),v=l();return v.catch(()=>{}),Promise.race([v,f]).finally(()=>d?.()).catch(g=>{throw g===on&&{...o},g})}var Id="self-init:";function Yb(e){return e.startsWith(Id)}function ti(e,t){const n=e.getActiveShowRequest();return Yb(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Jb(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let s="",i;const a=g=>{i={target:e.readTarget?.(),docId:g}},c=()=>e.readDocument()?Sn(e.readDocument()):s,l=()=>nt(e.container).editorPolicy,u=()=>e.readEmail(),d=()=>{const g=u();return{...g,id:e.isTemplate()||g.isNew?void 0:g.id,html:c()}};let f=!1;const v={readContent:c,publicEmail:d,sendInitStart:()=>ut(n,"INIT_START",X.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>ut(n,"INITED",X.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),o()),async sendContent(){const g=u(),{html:y,hasBrowserExtensionArtifacts:E}=yd(g?.html||"");E&&e.events.browserExtensionDetected(),Ed(e.readDocument(),y),s=y,a(g.renderGuid),await ut(n,"SET_ENTITY",X.SANDBOX_SET_ENTITY,Er(c(),g.renderGuid,l(),e.readDocument()?.get().version),{guid:g.renderGuid,emailId:g.id??null},r(),o())},refreshContent:()=>(a(u().renderGuid),ut(n,"SET_ENTITY",X.SANDBOX_SET_ENTITY,Er(c(),u().renderGuid,l(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const g=u();if(g.preheader!==void 0)return ut(n,"PREHEADER",X.SANDBOX_PREHEADER_UPDATE,{value:g.preheader,guid:g.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const g=u();if(g.subject!==void 0)return ut(n,"SUBJECT",X.SANDBOX_SUBJECT_UPDATE,{value:g.subject,guid:g.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:g=>e.showFilled?.(g),noteFilled:(g,y)=>e.noteFilled?.(g,y),contentSent:()=>i,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(d()),fireInit(g,y){if(!ti(t(),g)){t().getActiveShowRequest()?.showId;return}const E=u();E.id,E.renderGuid,t().completeShow(g);const P=e.readDocument();Ut(P,{is_inited:!0},{source:"system"});const O=()=>{const w=d();y&&(w.reset=!0);const C=e.events.inited(w);return y||(f&&v.fireEmailChanged(),f=!0),C};if(!P||P.isReady())return O();const{docId:x}=P.get();return P.whenReady().then(()=>e.readDocument()?.get().docId===x?O():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(d())},fireContentChanged(){e.events.contentChanged(c())}};return v}var Qb=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}},Zb=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(Te("Superseded by newer show()")),n.aborted?Promise.reject(Te(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const s=setTimeout(()=>{this._settle(e.showId,()=>{o(new Qb(e.showId,t))})},t);s.unref?.();const i=()=>{this._settle(e.showId,()=>{o(Te(n.reason))})};n.addEventListener("abort",i,{once:!0});const a=()=>{clearTimeout(s),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:s,dispose:a});for(const c of this._listeners)c(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 ey(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function ty(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Zl(e),n=eu(e),r=Tm(e.sandbox);t<n+r}var Ad=class{_controller=new AbortController;_externalSignalDisposable=new de;_sessionChangeListeners=new Set;_showRegistry=new Zb;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Zl(this._timeouts)}getSandboxTimeoutMs(e){return Ql(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return eu(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=ey(this._timeouts,e.timeouts),ty(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new de,this._linkExternalSignal(e)}abort(e){const t=e??Te("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new de}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new de,this._showRegistry.rejectAll(Te("Init session replaced")),this._controller.signal.aborted||this._controller.abort(Te("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??Te()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??Te()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},ni=(()=>{const e=new Ad;return e.configure({}),e})();function yt(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function st(e){return!e||e==="none"}function ny(e){const t=e.contain??"",n=e.willChange??"";return!st(e.transform)||!st(e.perspective)||!st(e.filter)||!st(e.backdropFilter)||!st(e.translate)||!st(e.rotate)||!st(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Oa(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function ry(e){const t=[],n=document.documentElement,r=Oa(getComputedStyle(n)),o=r.x||r.y;let s="none";const i=getComputedStyle(e).position;(i==="absolute"||i==="fixed")&&(s=i);for(let a=yt(e);a&&a!==n;a=yt(a)){const c=getComputedStyle(a),l=s==="none"||ny(c)||s==="absolute"&&!!c.position&&c.position!=="static",u=a===document.body&&!o;if(l){s="none";const d=u?{x:!1,y:!1}:Oa(c);(d.x||d.y)&&t.push({node:a,...d})}(c.position==="absolute"||c.position==="fixed")&&(s==="none"||c.position==="fixed")&&(s=c.position==="fixed"?"fixed":"absolute")}return t}function Td(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function Kn(e){return Number.parseFloat(e)||0}function zo(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=Td(e),o=Kn(n.borderLeftWidth),s=Kn(n.borderTopWidth),i=Kn(n.borderRightWidth),a=Kn(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-i):0,l=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-s-a):0;return{left:t.left+o*r.x,top:t.top+s*r.y,right:t.right-(i+c)*r.x,bottom:t.bottom-(a+l)*r.y}}function oy(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(s,i,a)=>{i&&(r.left=Math.max(r.left,s.left),r.right=Math.min(r.right,s.right)),a&&(r.top=Math.max(r.top,s.top),r.bottom=Math.min(r.bottom,s.bottom))};return t.forEach(s=>o(zo(s.node),s.x,s.y)),n&&o(zo(n),!0,!0),r}var Ko={originX:0,originY:0,scaleX:1,scaleY:1};function wr(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function Cd(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,o=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*o,scaleX:r,scaleY:o}}function Od(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var sy=1e3;function iy(e){const{slot:t,own:n}=e;let r,o=0,s=!1;const i=()=>{if(r=void 0,!s){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(i))}},a=()=>{!s&&r===void 0&&(r=window.requestAnimationFrame(i))},c=()=>{o=performance.now()+sy,a()},l=[window],u=[document.documentElement];for(let E=t;E;E=yt(E)){const P=E.getRootNode();P instanceof ShadowRoot&&!l.includes(P)&&(l.push(P),u.push(P))}const d=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];l.forEach(E=>d.forEach(([P,O])=>E.addEventListener(P,O,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const f=typeof MutationObserver=="function"?new MutationObserver(E=>{E.some(P=>!n.contains(P.target))&&a()}):void 0;u.forEach(E=>f?.observe(E,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let v;try{if(typeof ResizeObserver=="function"){const E=new ResizeObserver(a);typeof E.observe=="function"&&(v=E)}}catch{v=void 0}let g=[];return{schedule:a,observe:E=>{!v||E.length===g.length&&E.every((P,O)=>P===g[O])||(v.disconnect(),g=E,E.forEach(P=>v?.observe(P)))},dispose(){s=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),l.forEach(E=>d.forEach(([P,O])=>E.removeEventListener(P,O,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),f?.disconnect(),v?.disconnect()}}}var ay="pluginZoom",cy=/^(?:ant|vscode|monaco|docs)-/;function ly(e){return cy.test(e)}function uy(){const e="ub".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var dy=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function fy(){return dy}var py=new Set;function hy(e,t,n=py){return e.startsWith(`${t}-`)?!1:!ly(e)&&!n.has(e)}function my(e,t){return`--${t}-${e}`}function Pd(e){const t=uy();return hy(e,t,fy())?my(e,t):`--${e}`}function gy(e,t){const n=Pd(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function Rd(e,t){return gy(e,t)}var Dd=300,Pa=15e3,vy=5e3,Ra="em-canvas-busy-style";function _y(){if(document.getElementById(Ra))return;const e=document.createElement("style");e.id=Ra,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var by="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function yy(e){const t=Rd("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(Pd("colorPrimary")).trim()||t}function kd(e){_y();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",by),n.appendChild(r);const o=document.createElement("span");return o.setAttribute("role","img"),o.setAttribute("aria-label","loading"),o.setAttribute("style",`display:inline-flex;color:${yy(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function Ey(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),s=Math.min(r.right,e.right,n.width),i=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return s<=o||a<=i?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+s)/2-e.left,y:(i+a)/2-e.top}}function wy(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const o={left:n.left,top:n.top,right:n.right,bottom:n.bottom},s=r.getBoundingClientRect();if(s.width>0&&!Od({left:s.left,top:s.top,width:s.width,height:s.height},o)){const i=wr(o,Cd(s,wr(o,Ko),Ko));Object.assign(r.style,{left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const i=Ey(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(kd(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function ao(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(kd(e))},Dd);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var Sy=8e3;function Iy(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function Ay(e,t){for(let n=yt(e);n;n=yt(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",s=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(i=>Rt(i)>0);if(o&&s)return n;if(n===t)return null}return null}function Rt(e){return Number.parseFloat(e)||0}function Xn(e,t){return Math.abs(e-t)<=1}function Ty(e){const t=getComputedStyle(e),n=Rt(t.borderTopWidth),r=Rt(t.borderRightWidth),o=Rt(t.borderBottomWidth),s=Rt(t.borderLeftWidth),i=(a,c,l)=>Math.max(0,Rt(a)-Math.max(c,l));return{...zo(e),radii:[i(t.borderTopLeftRadius,n,s),i(t.borderTopRightRadius,n,r),i(t.borderBottomRightRadius,o,r),i(t.borderBottomLeftRadius,o,s)]}}function Cy(e,t){const n=Xn(t.top,e.top),r=Xn(t.bottom,e.bottom),o=Xn(t.left,e.left),s=Xn(t.right,e.right),i=[n&&o?e.radii[0]:0,n&&s?e.radii[1]:0,r&&s?e.radii[2]:0,r&&o?e.radii[3]:0];return i.every(a=>a===0)?"":i.map(a=>`${a}px`).join(" ")}function Oy(e,t,n,r,o,s){const i=n.readyTimeoutMs??Sy,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden",a.style.setProperty("zoom",Rd(ay,"1"));const c=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(c)),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=c,a.appendChild(l),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(l);const u=new de;let d=!1,f,v=!1,g,y,E,P;const O=()=>{clearTimeout(P),P=setTimeout(()=>{v||(v=!0,y?.(new Error(`[canvas] ${e}: документ не загрузился за ${i} мс`)))},i)},x=()=>d?(E=Promise.resolve(),v=!0,E):(v=!1,E=new Promise(($,_)=>{g=$,y=_}),O(),E),w=()=>{if(clearTimeout(P),d=!0,v){E=Promise.resolve();return}v=!0,n.mark?.("loaded"),g?.()};l.addEventListener("load",w),u.addDispose(()=>{clearTimeout(P),l.removeEventListener("load",w)});let C;const T=()=>{C??=n.bindResizer?.(l)},D=()=>{C?.dispose(),C=void 0};let R=null,m=null,p,h=Ko,b="",L="",F=0;const I=$=>{const _=JSON.stringify($);return _===b?!1:(b=_,a.style.visibility=$.visibility,a.style.left=`${$.css.left}px`,a.style.top=`${$.css.top}px`,a.style.width=`${$.css.width}px`,a.style.height=`${$.css.height}px`,a.style.borderRadius=$.radius,l.style.width=$.elementWidth>0?`${$.elementWidth}px`:"100%",l.style.transform=$.shiftX!==0?`translate(${$.shiftX}px, ${$.shiftY}px)`:`translateY(${$.shiftY}px)`,!0)};let S=!1;const N=()=>{if(!R)return b="",a.style.visibility="hidden",l.removeAttribute("id"),!1;n.elementId&&(l.id=n.elementId);const $=R.getBoundingClientRect(),_=ry(R),A=m?.isConnected?m:null;p?.observe([R,l,..._.map(te=>te.node),...A?[A]:[]]);const k=oy($,_,A),U=Math.max(0,k.right-k.left),q=Math.max(0,k.bottom-k.top),Q=getComputedStyle(R).visibility==="visible",G=U<=0||q<=0,z=G?{left:k.left,top:k.top,right:k.left,bottom:k.top}:k,M=G?null:Ay(R,A??_[0]?.node??null),J=M?Cy(Ty(M),z):"",Z=te=>I({visibility:Q&&!S?"":"hidden",css:wr(z,te),elementWidth:$.width/te.scaleX,shiftX:($.left-z.left)/te.scaleX,shiftY:($.top-z.top)/te.scaleY,radius:J});let be=Z(h);if(!G){const te=a.getBoundingClientRect();te.width>0&&!Od({left:te.left,top:te.top,width:te.width,height:te.height},z)&&(h=Cd(te,wr(z,h),h),be=Z(h)||be)}return be},j=()=>{if(!R)return!1;let $=N();const _=l.getBoundingClientRect().height;_>0&&_!==F&&(F=_,R.style.height=`${_/Td(R).y}px`,$=!0);const A=getComputedStyle(R).pointerEvents;return A!==L&&(L=A,a.style.pointerEvents=A),$},W=()=>{p?.dispose(),p=void 0},re=$=>{p=iy({slot:$,own:a,measure:j,onDetached:W})};let oe=[];const se=($,_)=>{if(m=_,$&&oe.length>0){const A=oe;oe=[],A.forEach(k=>k())}if($===R){$&&!p&&re($),j();return}if(W(),R&&R.style.removeProperty("height"),b="",F=0,L="",R=$,!$){N(),D();return}n.onShown?.(l),re($),j(),T()};u.addDispose(W);const Y=$=>{d=!1,f=void 0,s?.(),$&&n.onReload?.(l);let _;v||E===void 0?_=x():(O(),_=E);try{l.contentWindow?.location.reload()}catch{l.src=c}return _};return{element:l,ready(){return E??x()},reload:()=>Y(!0),reloadQuietly:()=>Y(!1),followReload:()=>{f=void 0,s?.(),n.onReload?.(l)},moveTo($){if(a.parentNode===$)return E??x();d=!1,f=void 0,s?.();let _;return v||E===void 0?_=x():(O(),_=E),$.appendChild(a),n.onReload?.(l),b="",p?.schedule(),_},get shown(){return R!==null},get slot(){return R},whenShown(){return R!==null?Promise.resolve():new Promise($=>{oe.push($)})},get filled(){return f},noteFilled($){f=$},alignTo($,_){se($,_??null)},hold($){S!==$&&(S=$,N())},scrollBy($,_){let A=$,k=_;for(let U=R?yt(R):null;U;U=yt(U)){if(Math.abs(A)<1&&Math.abs(k)<1)return;const q=getComputedStyle(U);if((q.overflowY==="auto"||q.overflowY==="scroll")&&U.scrollHeight>U.clientHeight){const Q=U.scrollTop,G=U.scrollLeft;U.scrollBy({left:A,top:k,behavior:"instant"}),A-=U.scrollLeft-G,k-=U.scrollTop-Q}}(Math.abs(A)>=1||Math.abs(k)>=1)&&window.scrollBy({left:A,top:k,behavior:"instant"})},resize(){C?.resize()},dispose(){se(null,null),D(),u.dispose(),a.remove()}}}function Py(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(h,b)=>h==="email"?`email:${b??n}`:h,s=new Map;let i,a=[],c=!1,l,u,d=!1,f,v,g="shown",y=0,E,P,O;const x=h=>u!==void 0&&h.filled!==void 0&&h.filled!==u,w=()=>{E=void 0;const h=f;!d||!h||u===void 0||P===u||!x(h)||(P=u,e.onForeignDocument?.({wanted:u,filled:h.filled,role:g,heldMs:Date.now()-y}))},C=()=>{d=!1,f=void 0,v=void 0,clearTimeout(E),E=void 0},T=(h,b)=>{const L=s.get("email"),F=L?.slot??null;return h&&F&&x(h)?(h.alignTo(null),d||(d=!0,y=Date.now(),E=setTimeout(w,vy)),g=b,f=h,!(i!==void 0||c)&&v!==h&&(v=h,e.onShown?.(h.element)),!l&&!i&&(l=ao(F)),!1):(d&&(C(),l?.remove(),l=void 0),h?.alignTo(F,L?.clip??null),!0)},D=()=>{d&&!c&&T(t.get(o("email")),"shown")},R=()=>{a.forEach(h=>clearTimeout(h)),a=[],i?.remove(),i=void 0,l?.remove(),l=void 0,(c||d)&&(c=!1,T(t.get(o("email")),"shown"))},m=(h,b,L)=>{const F=o(h,b),I=t.get(F);if(I)return I;const S=e.resolveMount();if(!S)return Iy();const N=Oy(h,S,e,h==="email"?b??n:void 0,L,h==="email"?()=>D():void 0);return t.set(F,N),N},p={get:h=>m(h),current:h=>m(h),peek:h=>t.get(o(h)),spare:()=>t.get(o("email",r())),ensureSpare:()=>m("email",r(),!0),promote(){const h=t.get(o("email",r()));if(!h)return;const b=t.get(o("email"));n=r(),O=void 0,T(h,"spare"),b?.alignTo(null)},alignSurface(h,b,L){const F=s.get(h);if(s.set(h,{slot:b,clip:L??null}),h==="email"&&c){l?.remove(),l=b?ao(b):void 0;return}const I=b?m(h):t.get(o(h));if(h!=="email"){I?.alignTo(b,L??null);return}if(!b){O=F?.slot&&I?.shown?{slot:F.slot,handle:I}:void 0,d&&(C(),l?.remove(),l=void 0),I?.alignTo(null);return}const S=O?.slot===b&&O.handle===I;if(O=void 0,F?.slot===b&&I?.shown||S){I?.alignTo(b,L??null);return}T(I,"shown")},want(h){u=h,h!==void 0&&D()},noteFilled(h,b){const L=p.byWindow(h);L&&(L.noteFilled(b),L===t.get(o("email"))&&D())},visible(){for(const h of t.values())if(h.shown)return h},byWindow(h){if(h){for(const b of t.values())if(b.element.contentWindow===h)return b}},busy(h){if(R(),!h)return;if(!p.visible()){c=!0,l?.remove(),l=void 0;const F=s.get("email");F?.slot&&(l=ao(F.slot)),a=[setTimeout(R,Pa)];return}const b=e.resolveMount();if(!b)return;const L=wy(b,()=>p.visible()?.element.parentElement?.getBoundingClientRect()??null);i=L,a=[setTimeout(()=>L.showSpinner(),Dd),setTimeout(R,Pa)]},remount(h){R();const b=o("email");t.forEach((L,F)=>{if(F===b){L.moveTo(h).catch(()=>{});return}L.dispose(),t.delete(F)})},dispose(){u=void 0,c=!1,C(),O=void 0,R(),t.forEach(h=>h.dispose()),t.clear(),s.clear(),n="a",u=void 0,P=void 0}};return p}var Ry=B("canvas.resizerBinder"),Xo=B("canvas.service"),Dy={created:we.canvasCreated,loaded:we.canvasLoaded},xd=new WeakMap;function Yo(e){return xd.get(e)??0}function ky(e,t){if(e.getInstance(Xo))return;const n=Py({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:vb,elementId:t.elementId,bindResizer:o=>e.getInstance(Ry)?.(o),onCreated:o=>mn(e,o,"fresh"),onReload:o=>{xd.set(o,Yo(o)+1),mn(e,o,"fresh")},onShown:o=>{const s=n.byWindow(pe(e).getTarget());s&&s.element!==o&&Da(s.element)===Da(o)||mn(e,o,"switch")},mark:o=>t.mark?.(Dy[o]),onForeignDocument:o=>{({...o},$m("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:o.role},contexts:{canvasIdentity:{...o,path:window.location.pathname}}}))}}),r=pe(e).addListener(X.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(Xo,n),e.getInstance(K)?.addDispose(()=>{r.dispose(),n.dispose()})}function Da(e){return e.parentElement?.dataset.canvasHost}function mn(e,t,n){const r=pe(e),o=t.contentWindow;if(!o)return;const s=r.getTarget()===o;s&&n==="switch"||(n==="fresh"&&(r.forget(o),s&&r.setTarget(void 0)),r.setTarget(o),Rm(r))}function xy(e,t){mn(e,t,"promote")}function Ly(e,t){mn(e,t,"switch")}function Ny(e,t){const n=t.contentWindow;n&&pe(e).greet(n)}function Ld(e,t){const n=t.contentWindow;n&&pe(e).forget(n)}function My(e,t){const n=ve(e)?.byWindow(t)?.element;if(!n)return;const r=Yo(n);return()=>Yo(n)!==r}function ve(e){return e.getInstance(Xo)}function Nd({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:s}){if(!r)return;const i={id:o??void 0,renderGuid:n,showId:s?.id,isNew:o==null,showToken:s?.token},a={...e,...i};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Hr(e){return{...Nd({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function ar(e){const t=Ee(e),n=t.current();if(!n||!ee(t.sessionKey()))return;const r=Hr(n),o=n.isDirty();ye(e,H.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function Fy(e){const t=Ee(e);return!t.current()||!ee(t.sessionKey())?!1:(ar(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function By(e){const t=Ee(e),n=pe(e),r=()=>e.getInstance(Ue)??ni;let o,s,i=!1,a=!1,c,l;const u=L=>Hr(L),d=()=>{const L=x(),F=L?.get().docId;if(!L||!F||F!==c||i)return;const I=L.get().version;I!==l&&(l=I,ye(e,H.ON_BLOCK_CHANGED_ID).fire(u(L)))};let f;const v=L=>{const F=t.showFacts();!F||F.id===f||!ti(L,F.id)||(f=F.id,L.completeShow(F.id))},g=async(L,F,I)=>{const S=I.generation,N=()=>I.generation!==S||I.signal.aborted||t.current()!==L||a,j=Ce(n);let W;const re=new Promise(se=>{W=En(n,()=>se("regenerated"))}),oe=async(...se)=>await Promise.race([ut(...se).then(()=>"sent"),re])==="sent";i=!0;try{if(!await oe(n,"INIT_START",X.SANDBOX_INIT_START,{guid:F},void 0,I)||N())return;const{html:se,hasBrowserExtensionArtifacts:Y}=yd(Sn(L));if(Y&&ye(e,H.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Ed(L,se),!await oe(n,"SET_ENTITY",X.SANDBOX_SET_ENTITY,Er(Sn(L),F,nt(e).editorPolicy,L.get().version),void 0,I)||N()||!await oe(n,"INITED",X.SANDBOX_INITED,{guid:F},void 0,I)||N())return;o=F,s=j,w(),l=L.get().version,c!==F&&(c=F,ye(e,H.ON_BLOCK_INIT_ID).fire(u(L))),v(I)}finally{W?.(),i=!1,(Ce(n)!==j||t.current()!==L)&&D()}};let y,E,P;const O=()=>{const L=ve(e)?.peek("block");return L?.reload?(L.reload().catch(()=>{}),!0):!1},x=()=>ee(t.sessionKey())?t.current():void 0,w=()=>{const L=x()?.get().docId,F=!L||P===L||o===L&&s===Ce(n);ve(e)?.peek("block")?.hold(!F)},C=()=>{if(a||(w(),d(),i))return;const L=x(),F=L?.get().docId;if(!L||!F)return;if(o===F&&s===Ce(n)){v(r());return}if(!L.isReady())return;const I=r();I.signal.aborted||o!==void 0&&o!==F&&y!==F&&(y=F,O())||g(L,F,I).catch(()=>{if(!(a||t.current()!==L)){if(E!==F){E=F,O();return}P=F,w()}})};let T=!1;const D=()=>{T||a||(T=!0,queueMicrotask(()=>{T=!1,C()}))};let R,m;const p=()=>{const L=x(),F=L?.get().docId;F!==m&&(R?.(),m=F,R=L?.subscribe(D)),w(),D()},h=t.subscribe(p),b=En(n,()=>{w(),D()});p(),e.getInstance(K)?.addDispose(()=>{a=!0,b(),R?.(),h()})}function jy(e){const t=Ee(e);let n="email";const r=()=>{if(!t.current())return;const s=ee(t.sessionKey())?"block":"email",i=ve(e);if(s===n||!i)return;n=s;const a=i.peek(s);if(a){Ly(e,a.element);return}i.get(s)},o=t.subscribe(r);e.getInstance(K)?.addDispose(o)}var Uy=200;function $y({startVersion:e,limit:t=Uy}){let n=[],r=e;const o=s=>{n=n.filter(i=>i.version>s),r=Math.max(r,s)};return{record(s){!s.changes?.length&&!s.contentReplaced||(n.push(s),n.length>t&&o(n[n.length-t-1].version))},rebase(s,i){if(i<r)return null;const a=n.filter(l=>l.version>i);o(i);let c=s;for(const l of a){if(l.contentReplaced||!l.changes)return null;const u=l.changes,d=[];for(const f of c){if(l.fromCanvas&&u.some(g=>f.range.start<=g.oldEnd&&f.range.end>=g.oldPosition))return null;const v=pu(f.range,u,"after");if(!v)return null;d.push({range:v,text:f.text})}c=d}return c}}}function Hy(e,t){let n=0;return e.map(({start:r,end:o,text:s})=>{const i=new Me(r,t.slice(r,o),r+n,s);return n+=s.length-(o-r),i})}function Vy(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return Hy(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function Gy(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var qy=32;function Wy(e=qy){const t=new Map;return{find(n,r){const o=t.get(n);return o&&Fo(o.scope,r)?o.echo:void 0},remember(n,r,o){t.delete(n),t.set(n,{scope:r,echo:o}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>Fo(r.scope,n)).map(r=>r.echo)}}}function zy(e,t){const n=fm(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var ri=B("canvas.sandboxFill");function Md(e){return e.getInstance(ri)?.pipeline.isEventsLocked()===!0}var Ky=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,Xy=/<\/?[a-zA-Z]/g;function ka(e){return e.match(Xy)?.length??0}function xa(e){return[...e.matchAll(Ky)].map(t=>[t.index,t.index+t[0].length])}function co(e,t,n){let r=0,o=0;for(const[s,i]of n){for(;o<t.length&&t[o][1]<=s;)o++;let a=s;for(let c=o;c<t.length&&t[c][0]<i;c++)r+=ka(e.substring(a,Math.max(a,t[c][0]))),a=Math.max(a,t[c][1]);r+=ka(e.substring(Math.min(a,i),i))}return r}function Fd(e,t){const n=[...t].sort((c,l)=>c.oldPosition-l.oldPosition||c.oldEnd-l.oldEnd),r=[],o=[],s=[];let i=0,a=0;for(const c of n){const l=e.substring(i,c.oldPosition);r.push(l,c.newText),a+=l.length,o.push([c.oldPosition,c.oldEnd]),s.push([a,a+c.newText.length]),a+=c.newText.length,i=c.oldEnd}return r.push(e.substring(i)),{next:r.join(""),removed:o,inserted:s}}var Yy=/<(?:!doctype|html|head|body)\b/i;function Jy(e,t){return e.reduce((n,r)=>n+r.oldLength,0)<t.trim().length?!1:Yy.test(t)&&!Fd(t,e).next.trim()}function Qy(e,t){if(e.reduce((i,a)=>i+a.oldLength,0)<=200)return null;const n=xa(t),r=Fd(t,e),o=co(t,n,r.removed)-co(r.next,xa(r.next),r.inserted),s=co(t,n,[[0,t.length]]);return o>100&&o>s*.2?{removed:o,total:s}:null}function it(e){wn(e,{origin:"canvas-channel"})}var Zy=100;function eE(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===X.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function tE(e){const t=Ee(e),n=pe(e);let r;const o=(c,l)=>{const u=c.get().docId;let d=!1,f=null,v=null,g;const y=$y({startVersion:c.get().version});let E=c.getContent();const P=Wy(),O=au(e),x=O.open(u,()=>c.get().version);let w=!1;const C=A=>({generation:Ce(n),originId:A});let T=C(null),D=!0;const R=(A,k)=>{!D||t.current()!==c||(wn(k,{origin:"canvas-channel"}),v?.splice(0,v.length),n.sendAsync(X.SANDBOX_SET_ENTITY,Er(Sn(c),u,nt(e).editorPolicy,c.get().version)).catch(it))},m=A=>{const k=A[A.length-1],U=[...A].reverse().find(G=>G.answer?.actionId!==void 0)?.answer?.actionId,q=k.answer?.selection,Q=U!==void 0||q?{...U!==void 0?{actionId:U}:{},...q?{selection:q}:{}}:void 0;return{edits:A.map(G=>G.edits),guid:u,rev:k.rev,...Q?{historyAnswer:Q}:{}}},p=()=>{const A=l.activeMove(),k=A&&g?.action===A.kind?g:void 0;if(k&&(g=void 0),!(!k&&!A?.selection))return{...k?{actionId:k.actionId}:{},...A?.selection?{selection:A.selection}:{}}},h=A=>{b({edits:[],rev:c.get().version,answer:{actionId:A.actionId}}).catch(it)},b=async A=>{if(v){v.push(A);return}v=[A];try{do await n.sendAsync(X.SANDBOX_UPDATE_ENTITY,m(v.splice(0,v.length)));while(v.length)}catch(k){R("app edits failed to reach the canvas",k)}finally{v=null}},L=A=>{A.length&&n.sendAsync(X.SANDBOX_UPDATE_ENTITY,m(A)).catch(it)},F=(A,k)=>{w=!0,L(v?.splice(0,v.length)??[]);const U={edits:[A],guid:u,rev:c.get().version,...k!==null?{changeId:k}:{}};k!==null&&P.remember(k,T,U),n.sendAsync(X.SANDBOX_UPDATE_ENTITY,U).catch(it)},I=new Set,S=(A,k,U,q)=>{F([],q);const{length:Q,hash:G}=Zr(JSON.stringify(U.map(M=>[M.oldText,M.newText]))),z=`${Q}:${G}`;I.has(z)||(I.add(z),R(A,k))},N=(A,k,U)=>S("canvas service batch removes a large part of the email",new Error(`canvas service batch removes ${A.removed} of ${A.total} tags`),k,U),j=({changeId:A,baseRev:k})=>{!w&&(A!==null||k!==null)&&F([],A)},W=A=>{if(A.guid!==u)return;const k=lg(A);w=!1,T=C(k.originId);try{re(A,k)}catch(U){j(k),R("canvas batch failed to apply",U)}finally{j(k),k.changeId!==null&&O.note(k.changeId,T)}},re=(A,k)=>{const{pushUndoStop:U}=A,q=k.changeId!==null?P.find(k.changeId,T):void 0;if(q){w=!0,n.sendAsync(X.SANDBOX_UPDATE_ENTITY,q).catch(it);return}let{edits:Q,selection:G}=A;if(k.baseRev!==null){const z=y.rebase(Q,k.baseRev);if(!z){wn(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),F([],k.changeId);return}z!==Q&&(G=void 0),Q=z}try{d=!0,f=k.changeId;const z=Vy(Q,c.getContent());if(Jy(z,c.getContent())){S("canvas batch erases the whole email",new Error("canvas batch erases the whole email"),z,k.changeId);return}if(U===!1){const M=Qy(z,c.getContent());if(M){N(M,z,k.changeId);return}l.applyWithoutHistory(z)}else l.recordAt(A.typedAt,()=>c.mutate({changes:z},{source:Md(e)?"system":"user"}),G),A.closesStep&&l.closeGroup()}finally{d=!1,f=null}},oe=c.subscribe(({changes:A,version:k})=>{const U=c.getContent(),q=!A?.length&&U!==E;if(E=U,y.record({version:k,changes:A,contentReplaced:q,fromCanvas:d}),!A?.length)return;const Q=Gy(A);d?F(Q,f):b({edits:Q,rev:k,answer:p()}).catch(it)}),se=n.addListener(X.APPLICATION_UPDATE_ENTITY,W),Y=n.addListenerAsyncPipe(sr,(A,k)=>{g=eE(A);try{return k?.(A)}finally{const U=g;g=void 0,U&&h(U)}},Zy),$=(A,k,{reportId:U,dropsCovered:q})=>{const Q=v?.splice(0,v.length)??[];n.sendAsync(X.SANDBOX_UPDATE_ENTITY,{edits:[zy(A,k)],guid:u,rev:c.get().version,resync:{textFingerprint:Zr(k),reportId:U}}).catch(G=>R("canvas resync edit failed to reach the canvas",G)),q&&L(Q)},_=n.addListener(X.APPLICATION_SYNC_DRIFT,A=>{if(!((A.reason==="echo-timeout"||A.reason==="resync-failed")&&A.guid!==void 0&&A.guid!==u)){if(A.reason==="resync-failed"){R("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(A.reason==="echo-timeout"){const{textFingerprint:k}=A,U=Sn(c),q=Zr(U);if(k?.length===q.length&&k.hash===q.hash){P.echoes(C(A.originId??null)).forEach(G=>{n.sendAsync(X.SANDBOX_UPDATE_ENTITY,G).catch(it)}),A.reportId!==void 0&&$(U,U,A);return}const Q=new Error(`canvas echo timeout, ${A.unsent??0} edits unsent`);if(A.canvasText===void 0){R("canvas lost the echo of its batch",Q);return}$(A.canvasText,U,A)}}});return()=>{D=!1,x(),oe(),se.dispose(),Y.dispose(),_.dispose()}};let s;const i=()=>{const c=t.current(),l=t.history(),u=c?.get().docId;u!==s&&(r?.(),r=void 0,s=u,c&&l&&(r=o(c,l)))},a=t.subscribe(i);i(),e.getInstance(K)?.addDispose(()=>{r?.(),a()})}function nE(e){const t=pe(e),n=()=>ve(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(X.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(X.RELOAD,a=>{const c=ve(e)?.byWindow(a);c&&Ld(e,c.element)}),s=t.addListener(a=>{a.data?.operation===X.SANDBOX_RESIZED&&n()?.resize()}),i=ne(e,H.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(K)?.addDispose(()=>{r.dispose(),o.dispose(),s.dispose(),i.dispose()})}function La(){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 rE(e){const t=e.getInstance(_e);let n,r;e.getInstance(K)?.addDispose(()=>{r?.remove(),r=void 0}),ky(e,{resolveMount:()=>n,resolveSrc:s=>gd(s==="block"),elementId:"email_iframe",mark:s=>ce(s)}),t?.watch(s=>{const i=s?.element;if(n&&i instanceof HTMLElement&&i!==n){n=i,ve(e)?.remount(i),r?.remove(),r=void 0;return}if(!n){if(i instanceof HTMLElement)n=i;else if(s!==void 0){n=r??=La(),ve(e)?.alignSurface("email",r,r);return}else return;ve(e)?.get("email")}});let o;e.getInstance(K)?.addDispose(()=>{o?.remove(),o=void 0}),T_(e).watch(s=>{const i=ve(e);if(i){if(s){o??=La(),i.alignSurface("email",o,o);return}o&&(i.alignSurface("email",null),o.remove(),o=void 0)}})}var oi=B("canvas.headerFlow"),Na=["subject","preheader"],Ma=3e3,oE=3,sE={subject:X.SANDBOX_SUBJECT_UPDATE,preheader:X.SANDBOX_PREHEADER_UPDATE};function iE(e){const t=Ee(e),n=pe(e),r=C=>C?"remote":Md(e)?"system":"user",o=(C,{guid:T,value:D,forced:R})=>{const m=xt(t);if(!m||typeof D!="string"||T&&T!==m.get().docId)return;const p=t.forcedHeaders();if(p?.[C]!==void 0&&!R&&D!==p[C])return;const h=m.get().attributes[C];if(!R&&v(C,D,h))return;const b=!R&&d.delete(C);R&&(E.delete(C),E.size===0&&t.endForcedHeaders()),c=!0;try{Ut(m,{[C]:D},{source:b?"system":r(R)})}finally{c=!1}s[C]=D};let s={},i,a,c=!1,l=Promise.resolve();const u={},d=new Map,f=(C,T)=>{s[C]=T;const D={};d.set(C,D);const R=()=>{d.get(C)===D&&d.delete(C)};g(C,T,{force:!0}).then(R),setTimeout(R,Ma)},v=(C,T,D)=>{const R=t.showFill();if(!R||typeof D!="string")return!1;const m=u[C]?.showId===R.showId?u[C]:void 0;return T===D?(u[C]=m??{showId:R.showId,codeEdits:R.codeEdits,corrections:0},!1):m&&R.codeEdits>m.codeEdits&&T!==m.stale?!1:((!m||T===m.stale&&m.corrections<oE)&&(u[C]={showId:R.showId,stale:T,codeEdits:R.codeEdits,corrections:(m?.corrections??0)+1},f(C,D)),!0)},g=(C,T,{force:D=!1,echo:R=!1,undoStep:m=!1})=>(l=n.sendAsync(sE[C],{value:T,guid:xt(t)?.get().docId,...D?{force:!0}:{},...R?{echo:!0}:{},...m?{undoStep:!0}:{}}).catch(p=>{}),l);let y;const E=new Set;e.inject(oi,{whenDelivered:async()=>{await l},reassert:C=>{const T=xt(t),D=Na.filter(R=>typeof C[R]=="string");if(!(!T||D.length===0)){c=!0;try{Ut(T,Object.fromEntries(D.map(R=>[R,C[R]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(D.map(R=>[R,C[R]]))),clearTimeout(y),y=setTimeout(()=>{E.clear(),t.endForcedHeaders()},Ma),E.clear();for(const R of D)E.add(R);for(const R of D)s[R]=C[R],g(R,C[R],{force:!0,echo:!0})}}});const P=()=>{i?.(),i=void 0;const C=xt(t);if(C!==a&&d.clear(),a=C,!C){s={};return}const T=C.get().attributes;s={subject:T.subject,preheader:T.preheader},i=C.subscribe(({source:D})=>{if(c)return;const R=C.get().attributes,m=t.forcedHeaders();for(const p of Na){const h=R[p];if(h===s[p])continue;s[p]=h,d.delete(p);const b=D==="system"&&m?.[p]!==void 0;g(p,h??"",{force:b,echo:b,undoStep:D==="user"})}})};P();const O=t.subscribe(P),x=n.addListenerAsync(X.APPLICATION_SUBJECT_UPDATE,C=>o("subject",C)),w=n.addListenerAsync(X.APPLICATION_PREHEADER_UPDATE,C=>o("preheader",C));e.getInstance(K)?.addDispose(()=>{x.dispose(),w.dispose(),O(),i?.(),clearTimeout(y)})}function aE(e){const t=Ee(e);let n={document:void 0,seq:0};const r=()=>{const s=t.recoveryFacts(),i=xt(t);if(!s?.applied||!i||String(s.emailId)!==String(i.get().serverId)||(n.document!==i&&(n={document:i,seq:0}),s.applied.seq<=n.seq))return;n={document:i,seq:s.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(oi)?.reassert(a)},o=t.subscribe(r);e.getInstance(K)?.addDispose(o)}function cE(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?gm:mm}function lE(e,t,n=!1){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1,blocksTemplateEnabled:n}}function uE(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Fa(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Jo(e,t){const n={...e};for(const r of Object.keys(t)){const o=t[r],s=e[r];Fa(o)&&Fa(s)?n[r]=Jo(s,o):o!==void 0&&(n[r]=o)}return n}function dE(e,t){const n=Bs;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const o=JSON.parse(r);if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0)return Jo(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Jo(n,t):n}var fE=ae(void 0),Ba=fE,Bd=B("CodeMode");function jd(){let e;try{const t=window.localStorage?.getItem(Dr.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function pE(e){try{window.localStorage?.setItem(Dr.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function Vr(e){return e.getOrCreateInstance(Bd,()=>{const t=ae(jd());return t.watch(pE),t})}function Ud(e){return e?.getInstance(Bd)?.get()??jd()}function Qo(e,t){const n=Vr(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function hE(e,t){const n=Vr(e);n.set({...n.get(),direction:t})}var mE=B("DefaultCommonStyles");function $d(e){return e.getOrCreateInstance(mE,()=>ae(void 0))}function gE(e,t){$d(e).set(t)}var vE=B("CanvasViewport"),_E=B("CanvasPreviewPage"),bE=B("CanvasTemplateBlocks");function Qe(e,t,n){let r,o;const s=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==o&&(o=c,e.send(t,r.value))},i=n.watch(c=>{r={value:c},s()}),a=e.onInit(()=>{o=void 0,s()});return{dispose(){i.dispose(),a.dispose()}}}function Yn(e){const t=ae(e());return{source:t,refresh:()=>t.set(e())}}function yE(e){const t=pe(e),n=e.getInstance(he),r=e.getInstance(_e),o=Ee(e),s=Vr(e),i=matchMedia(vm),a=()=>n?.get()??{};let c;const l=Yn(()=>cE(Ba.get()??a().theme,i.matches)),u=e.getOrCreateInstance(bE,()=>ae(!1)),d=Yn(()=>lE(a(),ee(o.sessionKey()),u.get()===!0)),f=u.watch(()=>d.refresh()),v=Yn(()=>a().lockEditor),g=Yn(()=>dE(o.current()?.get().attributes?.common_styles,c)),y=e.getOrCreateInstance(vE,()=>ae()),E=e.getOrCreateInstance(_E,()=>ae()),P=[Qe(t,Je.theme,l.source),Qe(t,Je.flags,d.source),Qe(t,Je.lockEditor,v.source),Qe(t,Je.commonStyles,g.source),Qe(t,Je.codeMode,s.select(uE)),Qe(t,Je.appName,ae("useblocks")),Qe(t,Je.previewPage,E),Qe(t,Je.viewport,y)],O=()=>{l.refresh(),d.refresh(),v.refresh()},x=n?.watch(O),w=$d(e).watch(h=>{c=h,g.refresh()}),C=r?.watch(h=>{h&&"commonStyles"in h&&(c=h.commonStyles),g.refresh()});let T;const D=()=>{T?.(),T=o.current()?.subscribe(()=>g.refresh()),g.refresh(),d.refresh()};D();const R=o.subscribe(D),m=()=>l.refresh();i.addEventListener("change",m);const p=Ba.watch(()=>l.refresh());e.getInstance(K)?.addDispose(()=>{P.forEach(h=>h.dispose()),x?.dispose(),f.dispose(),w.dispose(),C?.dispose(),T?.(),R(),i.removeEventListener("change",m),p.dispose()})}var Zo;(function(e){function t(o,s,i=(a,c)=>a===c){if(o===s)return!0;if(o.length!==s.length)return!1;for(let a=0;a<o.length;a++)if(!i(o[a],s[a]))return!1;return!0}e.isEqual=t;function n(o,s=i=>i){const i=new Set;return o.filter(a=>{const c=s(a);return i.has(c)?!1:(i.add(c),!0)})}e.unique=n;function r(o=[],s=[],i=(a,c)=>a===c){const a=[],c=[],l=[];for(const u of o){const d=s.find(f=>i(u,f));d?l.push({prev:u,next:d}):c.push(u)}for(const u of s)o.find(d=>i(u,d))||a.push(u);return{added:a,removed:c,exists:l}}e.diff=r})(Zo||(Zo={}));function EE(e,t){return e.type===t.type&&e.key===t.key}function wE(e){const t=pe(e),n=()=>e.getServices(Dt)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(X.SANDBOX_ADD_EXTENSIONS,r)}),s=up(Dt),i=e.onInject(a=>{if(a!==s)return;const c=n();if(!t.isInited()){r=c;return}const{added:l,removed:u}=Zo.diff(r,c,EE);if(r=c,u.length){if(u.some(d=>d.type==="script")){t.send(X.RELOAD);return}t.send(X.SANDBOX_REMOVE_EXTENSIONS,u.map(d=>d.key))}l.length&&t.send(X.SANDBOX_ADD_EXTENSIONS,l)});e.getInstance(K)?.addDispose(()=>{o.dispose(),i?.dispose()})}var SE=new Set([...Object.values(X).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(Cs)]);function IE(e){return e.length>0&&!e.startsWith("em:")&&!SE.has(e)}function AE(e){const t=pe(e),n=new Map;let r=!1,o=-1,s=new Set;const i=l=>(l!==o&&(o=l,s=new Set),s),a=t.observeOutgoing((l,u)=>{if(!r||!IE(l))return;const d=Ce(t);n.set(l,{data:u,generation:d,scripts:new Set(i(d))})}),c=t.addListener(Cs,l=>{if(l.phase!=="ready"||l.status!=="success")return;r=!0;const u=Ce(t),d=i(u);d.add(l.key);for(const[f,v]of n)v.generation===u||![...v.scripts].every(g=>d.has(g))||(v.generation=u,t.send(f,v.data))});e.getInstance(K)?.addDispose(()=>{a.dispose(),c.dispose()})}var TE=B("prewarm.editorVisible");function CE(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function OE(e={}){const t=e.paint??CE;let n=!1,r=!1,o=!1,s=!1,i=!1;const a=[],c=()=>{i||s||!n||!r||!o||(s=!0,t(()=>{i=!0,ce(we.editorVisible);for(const l of a.splice(0))l()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){o=!0,c()},whenVisible(l){if(i){l();return}a.push(l)},contentShown:()=>o}}function PE(e){return e.getOrCreateInstance(TE,()=>OE())}var RE=500,DE=500,kE=5e3;function xE(e){const t=e.quietMs??RE,n=e.floorMs??DE,r=e.ceilingMs??kE;let o,s,i=0;const a=()=>{clearTimeout(o),clearTimeout(s),o=void 0,s=void 0},c=()=>{a(),e.run()},l=()=>{clearTimeout(o);const u=n-(Date.now()-i);o=setTimeout(c,Math.max(t,u))};return{start(){a(),i=Date.now(),s=setTimeout(c,r),l()},notify(){o!==void 0&&l()},cancel:a}}var LE=2;function ja(){return new Error("[sandbox] document reloaded during fill")}function NE(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function lo(e){try{e()}catch{}}function ME(e){let t;return lo(()=>{t=e()}),{stage:n=>lo(()=>t?.stage(n)),end:(n,r)=>lo(()=>t?.end(n,r))}}function FE(e){const t=()=>e.initPipeline();let n=!1,r,o,s,i=0,a,c;const l=()=>{const T=e.readTarget?.(),D=e.readSandboxGeneration?.();return T===void 0||D===void 0?void 0:{target:T,generation:D}},u=()=>{const T=l();return T&&{...T,canvasReplaced:e.trackDocument?.(T.target)}},d=T=>{if(T?.canvasReplaced?.())return!0;const D=l();return T!==void 0&&D?.target===T.target&&D.generation!==T.generation},v=Jb({...e,waitScope:()=>({getSandboxTimeoutMs:T=>t().getSandboxTimeoutMs(T),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const T=c;if(!(!T||!e.onSandboxGenerationChange))return{getGeneration:()=>l()?.generation??T.generation,onChange:D=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===T.target||T.canvasReplaced?.())&&D()})??(()=>{})}}});let g;const y=(T,D)=>{if(g===T)return;g=T;const R=i;setTimeout(()=>{i!==R||t().signal.aborted||x(T,D).catch(()=>{})},0)},E=()=>{a?.abort(),a=void 0};let P;const O=()=>{const T=t().signal;T!==P&&(P?.removeEventListener("abort",E),P=T,T.addEventListener("abort",E))};async function x(T,D,R=0){const m=++i;E(),a=new AbortController,c=void 0,O();const p=()=>i!==m,h=v.readTarget(),b=t().generation,L=()=>b===t().generation&&!t().signal.aborted,F=D?"init:reset-":"init:",I=ME(()=>e.observeShow?.(NE(T,D,e.readEmail())));if(!D){const se=v.publicEmail();se?.id,se?.renderGuid,se?.preheader}let S=!1,N=!1,j,W=!1;const re=()=>{if(d(j))throw ja()},oe=()=>{if(p())throw Te("Fill superseded")};try{n=!0,await v.sendInitStart(),oe(),j=u(),c=j,R===0&&v.fireWillInit(),await(D||R>0?v.refreshContent():v.sendContent()),S=!0,oe(),re();const se=v.contentSent();v.noteFilled(se?.target,se?.docId),I.stage("content"),D||v.publicEmail()?.id;try{await v.sendPreheader()}catch(Y){if(Ca(Y)||p())throw Y;`${F}`,String(Y)}oe();try{await v.sendSubject()}catch(Y){if(Ca(Y)||p())throw Y;`${F}`,String(Y)}if(oe(),re(),v.showFilled(h),await v.sendInited(),oe(),re(),N=!0,o===T){const Y=e.readSandboxGeneration?.()??s;Y!==void 0&&(r=Y)}I.stage("reveal"),await v.revealFilled(),re(),I.end("revealed")}catch(se){const Y=!p()&&L()&&d(j),$=Y?ja():void 0,_=$??se,A=Y&&R<LE?C(T,D,R+1):void 0;W=Y&&A===void 0;const k=p()?void 0:{showId:T,contentApplied:S,sandboxInitedAcked:N,superseded:!1,...e.describeSurface?.(),error:String($??se)};k&&(`${F}`,void 0);const U=!p()&&e.recoverFailedFill?.(h)===!0;if(I.end(p()?"superseded":U?"recovered":Es(_)||!L()?"aborted":"failed",k),!U&&!p()&&ti(t(),T)&&t().failShow(T,_),A!==void 0)return A;throw _}finally{w(T,D,F,{superseded:p(),sessionGeneration:b,contentApplied:S,sandboxInitedAcked:N&&!W,retry:!W,commit:L()})}}function w(T,D,R,m){const{superseded:p,contentApplied:h,sandboxInitedAcked:b}=m;if(p){`${R}`;return}b&&m.commit?v.fireInit(T,D||void 0):b?(`${R}`,m.sessionGeneration,t().generation,t().signal.aborted,void 0):h?(`${R}`,void 0):(`${R}`,void 0),n=!1,a=void 0,!b&&o===T&&(o=void 0,r===s&&(r=void 0)),!b&&h&&m.retry&&y(T,D)}function C(T,D,R){return x(T,D,R)}return{channel:v,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:T=>{r=T},lastCorrelation:()=>o,markCorrelation:T=>{o=T},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:T=>{s=T},fill:T=>x(T,!1),refill:T=>x(T,!0),stop:()=>{i+=1,E(),n=!1,P?.removeEventListener("abort",E),P=void 0}}}function BE(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:Hd(e,n)}function Hd(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function jE(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:s}=e,i=u=>{const d=n(),f=o();if(!BE(d,u,f)){u.showId,u.navId,u.emailId,d?.id,d?.showId,d?.renderGuid;return}u.showId,d?.id,d?.renderGuid,t.markFilled(s()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{i(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&i(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=s();if(t.filledGeneration()===u)return;const d=n(),f=o();if(!d?.renderGuid||!Hd(d,f))return;const v=`${Id}${d.renderGuid}`;t.markFilled(u),t.markCorrelation(v);const g=r()?.isReady()===!0;d.id,d.renderGuid,(g?y=>t.refill(y):y=>t.fill(y))(v).catch(()=>{t.lastCorrelation()===v&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var UE=B("canvas.health");function $E(e){return e??""}function HE(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Ua(e){return e.length>0}function VE(e){const t=Ee(e),n=pe(e),r=()=>ee(t.sessionKey())?void 0:t.current(),o=()=>{const M=r();return Nd({attributes:M?.get().attributes??{},readContent:()=>M?.getContent(),docId:M?.get().docId,hasSession:!!M,serverId:M?.get().serverId,show:t.showFacts()})},s=()=>e.getInstance(Ue)??ni;let i={},a=!1;const c=e.getInstance(_e)?.watch(M=>{a=!!M?.element});let l=!1,u=!1,d=!1,f=0;const v=()=>{const M=ve(e);if(!M)return;const J=++f,Z=M.spare();return Z&&Ld(e,Z.element),(Z?Z.reloadQuietly():M.ensureSpare()?.ready())?.then(()=>{if(J!==f)return;l=!0;const be=M.spare();be&&Ny(e,be.element),d&&(d=!1,b(),Y())})},g=xE({run:()=>{d||v()?.catch(()=>{})}}),y=()=>{PE(e).noteContentShown(),!l&&!d&&g.start()};let E=!1;const P=M=>{const J=ve(e),Z=J?.spare()?.element.contentWindow;u&&J&&Z&&M===Z&&(u=!1,J.promote(),J.busy(!1),E=!0)};let O=!1;const C=FE({container:e,messageService:n,initPipeline:s,readDocument:r,readEmail:o,revealFilled:()=>{const M=ve(e);return E&&M&&(E=!1,g.start()),a?M?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:P,noteFilled:(M,J)=>ve(e)?.noteFilled(M,J),recoverFailedFill:M=>{const J=ve(e),Z=J?.spare()?.element.contentWindow;return!u||!J||!Z||M!==Z?!1:(u=!1,l=!1,p="reload",J.busy(!1),J.peek("email")?.reload(),O=!0,Y(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>Ce(n),onSandboxGenerationChange:M=>En(n,M),trackDocument:M=>My(e,M),observeShow:M=>e.getInstance(UE)?.begin(M),describeSurface:()=>({canvasPath:p,promoted:u,spareClean:l,handshake:n.isInited(),generation:Ce(n)}),events:{willInit:M=>{ye(e,H.WILL_EMAIL_INIT_ID).fire(M)},inited:M=>{y(),ye(e,H.ON_EMAIL_INIT_ID).fire(M)},contentChanged:M=>{ye(e,H.ON_CONTENT_CHANGED_ID).fire(M)},emailChanged:M=>{ye(e,H.ON_EMAIL_CHANGED_ID).fire(M)},browserExtensionDetected:()=>{ye(e,H.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),T=jE({pipeline:C,initPipeline:s,readEmail:o,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>Ce(n)});let D="",R="",m="",p="none";const h=()=>{const M=ve(e)?.spare()?.element.contentWindow;M&&n.getTarget()===M||n.sendNow({operation:X.SANDBOX_LOCK_EDIT,data:!0})},b=()=>{const M=ve(e)?.spare();M&&(h(),l=!1,u=!0,xy(e,M.element))},L=(M,J)=>{const Z=ve(e);if(!Z)return!0;const be=Z.spare(),te=be&&l?"spare":"prepare";if(p=te,Z.busy(!0),be&&l)return b(),!0;g.cancel(),h();const rt=v();if(rt===void 0)return p="reload",Z.busy(!1),Z.peek("email")?.reload(),!0;d=!0;const Ye=f;return rt.catch(()=>{!d||Ye!==f||(d=!1,p="reload",Z.busy(!1),Z.peek("email")?.reload())}),!1},F=()=>{if(ee(t.sessionKey()))return;q(),C.noteSandboxGeneration(Ce(n));const M=o(),J=HE(M?.renderGuid,M?.showId,M?.id,i.emailId),Z=$E(M?.renderGuid);if(Z!==R){const rt=R;R=Z;const Ye=ve(e)?.peek("email")?.filled,rp=Ye!==void 0&&Ye!==Z;Ua(Z)&&(Ua(rt)||rp)&&L(rt||(Ye??""),Z)}if(d)return;(J!==D||O)&&(O=!1,D=J,T.showRequestIdentityChanged());const be=r(),te=`${J}|${be?.get().docId??""}|${Ce(n)}`;te!==m&&be?.isReady()===!0&&(m=te,T.selfInitChanged()),T.saasChanged(),oe()};let I=!1,S="",N="",j=!1,W=!1;const re=M=>{M.source==="user"?W=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(j=!0),Y()},oe=()=>{const M=o();if(!M?.renderGuid)return;const J=C.channel.readContent(),Z=JSON.stringify([M.preheader,M.common_styles,M.meta,M.subject,M.utm_parameters?.utm_campaign??"",M.utm_parameters?.utm_content??"",M.utm_parameters?.utm_medium??"",M.utm_parameters?.utm_source??"",M.utm_parameters?.utm_term??""]),be=I&&J!==N,te=I&&Z!==S;I=!0,N=J,S=Z;const rt=j&&!W;if(j=!1,W=!1,C.isEventsLocked()||rt)return;const Ye={...M,id:i.isTemplate||M.isNew?void 0:M.id,html:J};if(be){ye(e,H.ON_CONTENT_CHANGED_ID).fire(J),ye(e,H.ON_EMAIL_CHANGED_ID).fire(Ye);return}te&&M.is_inited&&ye(e,H.ON_EMAIL_CHANGED_ID).fire(Ye)};let se=!1;const Y=()=>{se||(se=!0,queueMicrotask(()=>{se=!1,F()}))};e.inject(ri,{pipeline:C,setRoute:M=>{M.emailId===i.emailId&&!!M.isTemplate==!!i.isTemplate||(i=M,Y())}});let $,_;const A=()=>{const M=r()?.get().docId;M!==_&&($?.(),_=M,$=r()?.subscribe(re)),Y()};let k,U;const q=()=>{const M=e.getInstance(Ue);!M||M===k||(U?.(),k=M,U=M.onShowRequested(J=>T.showRequested(J)))},Q=n.addListener(M=>{M.data?.operation===X.SANDBOX_RESIZED&&g.notify()}),G=t.subscribe(A),z=En(n,Y);A(),e.getInstance(K)?.addDispose(()=>{c?.dispose(),U?.(),z(),G(),$?.(),Q.dispose(),g.cancel(),C.stop()})}function GE(){return pm!=="useblocks"}var Vd={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!1,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},qE={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:!0,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!1,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}},$a=Vd,WE=["freeUserBlocks","blocks"],es={};function zE(e){es=e}var Gd=e=>WE.includes(e)?$a:es[e]??es.editor??$a,ts={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!1,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},KE={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:!0,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!1,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},XE={...ts,config:{...ts.config,imageCenterFileManagerView:!1}};zE({pro:qE,editor:KE,simple:GE()?ts:XE,blocks:Vd});function YE(e,t,n=e.getInstance(he)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Ud(e).isCodeMode&&Qo(e,!1)}function JE(e){e.getInstance(mp)||e.inject(je,void 0)}function Gr(e){return String(e.standaloneKey||"").trim()||void 0}function QE(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function si(e){return QE(e)?!!Gr(e):!1}function Nn(e){return!!Gr(e)&&!si(e)}var ZE=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Ha(e){return e==="server"?"serverSide":e}function ew({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=ae();let s={kind:"pending"},i;const a=new Promise(f=>{i=f}),c=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function l(){s.kind!=="pending"&&o.set(io(r,e))}function u(f){if(s.kind!=="pending")return;clearTimeout(c),s=f;const v=io(r,e);o.set(v),i(v)}function d(f,v){r[Ha(f)]=v,f==="server"&&s.kind==="pending"?u({kind:"applied"}):l()}return{watch:f=>o.watch(f),select:f=>o.select(f),get:()=>o.get(),ready:()=>a,state:()=>s,layers:()=>({...r}),bootstrap(){const f=io(r,e);return Object.fromEntries(ZE.map(v=>[v,f[v]]))},merge(f,v){d(v,{...r[Ha(v)],...f})},replace(f,v){d(v,f)},setMode(f){r.user={...r.user,mode:f},l()},setAdvancedConfigs(f){r.advancedConfigs=f,l()},serverAbsent(f){u({kind:"absent",reason:f})},applyServerResponse(f){s.kind==="pending"&&d("server",{...r.serverSide,...f})},dispose(){clearTimeout(c)}}}var tw=5e3,nw="blocks";function rw(){return{...Gd(nw)?.config,mergeTags:void 0}}function ow(e,t){e.getInstance(_e)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},o=t.layers().user.mode;t.replace(r.mode===void 0&&o!==void 0?{...r,mode:o}:r,"user")})}function sw(e,t){let n;Js(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const s={};r?.theme&&(s.theme=r.theme),r?.locale&&(s.locale=r.locale),t.replace(s,"profile")})}function iw(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function aw(e,t){let n,r=!1,o;const s=a=>{o??=jr(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&YE(e,a,t)},i=Js(e).watch(({profile:a})=>{const c=a?.email_builder_config,l=iw(c);if(l===void 0||c===n)return;const u=n===void 0;n=c,!(u&&r)&&s(l)});e.getInstance(K)?.addDisposable(i),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,s(c)})}var Va="замкнутый контур: app_init не выполняется";function cw(e,t){if(e.getInstance(je)){t.serverAbsent(Va);return}const n=e.getInstance(_e)?.watch(r=>{Nn(r)&&t.serverAbsent(Va)});n&&e.getInstance(K)?.addDisposable(n)}async function lw(e,t){if(e.getInstance(Ns)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Ke);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function uw(e){e.injectFactory(he,(t,n)=>{if(n)return n;const r=ew({base:rw(),env:{modeDefaults:o=>Gd(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:tw});return ow(e,r),sw(e,r),aw(e,r),cw(e,r),lw(e,r),e.getInstance(K)?.addDisposable(r),r},!0)}var Bt=class extends de{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function V(e,t,n){const r=cp(e);return(o,s,i)=>{const a=r(async c=>{const l=t?t(c):c;i&&o.bind(i);const u=await o(l);return n?n(u):u},s,i);return()=>a.dispose()}}var dw=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Lo;this.handleDestroy=V(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Bt(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{}}},ii=B("DestroyableService");function fw(e){e.injectFactory(ii,(t,n)=>{if(n)return n;const r=e.getInstance(K);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new dw({lifetime:r,options:e.getInstance(_e),getInstance:()=>e.getInstance(Gt),release:()=>fh(e.getInstance(hl)??e)})},!0)}function pw(e){const t=e.getInstance(ii);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var hw=1e3;function qd(e,t,n=hw,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;for(const i of o)if(!qd(e[i],t[i],n,r+1))return!1;return!0}return!1}function gn(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const o=t[r],s=e[r];qd(o,s)||(n[r]=o)}return n}var mw=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function gw(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function vw({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??xn();let s;try{const i=e.notifySave(n);return await Promise.race([i,new Promise((a,c)=>{s=setTimeout(()=>{const l=new kr(o);n.value.id,Eg(l,gw(i,r)),c(l)},o)})])}catch(i){throw Iu(i),i}finally{s!==void 0&&clearTimeout(s)}}function _w(e){const{emails:t}=e,n=async(r,o)=>{const s=mw(o),i=r===void 0?void 0:await t.cache.getIfPresent(r),a=i?{...i,...s}:s,c=i?gn(i,s):s,l=u=>{const d=String(u.id??r??xe()),f=u.id===void 0?{...u,id:d}:u;return t.cache.addOrUpdate(d,()=>f)};return await l(await vw(e,{prev:i,patch:c,value:a,source:o.source??""},l))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const o=await n(void 0,r);return o?.renderGuid?o:{...o,renderGuid:xe()}},async updateEmail(r,o){return await n(r,o)}}}var uo=20;function bw(e){const t=yw(e);return e.saveTimeoutMs?Ew(t,e.saveTimeoutMs):t}function yw({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:s}){const i=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(l=>String(l?.parent)===String(a)));return{async readRevisions(a,c=1){const l=await i(a,c);return{revisions:l.slice(uo*(c-1),uo*c),page:c,hasMore:l.length>uo*c}},async readAutosave(a){const c=await r?.(a)??NaN,l=Number.isFinite(c)?c:void 0,u=await n?.(a);if(!u?.asked)return Pg(await i(a,1),l);if(!u.revision)return ra([],l);const d={...u.revision,parent:a,isAutosave:!0};return ra([d],l,await i(a,1))},async saveAutosave(a,c){const l=await o?.(a),u=s?.();return await e.create({...Ng(c),...l!==void 0?{author:l}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Ew(e,t,n){return{...e,async saveAutosave(r,o){const s=t();if(s===void 0)return e.saveAutosave(r,o);let i;try{return await Promise.race([e.saveAutosave(r,o),new Promise((a,c)=>{i=setTimeout(()=>c(new ou(s,n)),s)})])}catch(a){throw Iu(a),a}finally{i!==void 0&&clearTimeout(i)}}}}var ww=class extends sp{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}},Sw=class extends et{};var Ga=class extends de{_items=new Map;_onChangeEmitter=new dp;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const o=await t(n);return Ae(n,o)||this._onChangeEmitter.fire(),o}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([o,s])=>o)),r=(await this.entries()).filter(([o,s])=>!n.has(o));for(const[o,s]of e)t.push(this.addOrUpdate(o,()=>s)),n.add(o);for(const[o]of r)t.push(this.remove(o));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function Iw(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:s=20}={}){const i=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(l=>{for(const u of c){const d=l[u],f=t[u];return u==="id"||typeof d!="string"?d===f:typeof f=="string"&&d.startsWith(f)}return!0}),a=e.length}return r&&(e=e.sort((c,l)=>(c[r]>l[r]?1:l[r]>c[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(s*(o-1),s*o)),{data:e,filteredTotal:a,total:i,totalPages:Math.ceil(a/s)}}function Aw(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const o=t.get(r.id)||{};t.set(r.id,{...o,...r})}return[...t].map(([n,r])=>r)}function Tw(e,t){return qa(e)&&qa(t)?String(e)===String(t):e===t}function qa(e){return typeof e=="string"||typeof e=="number"}var Cw=class extends de{_cache=new Ga;_readEmitter=new et;_saveEmitter=this.addDisposable(new ww);_removeEmitter=this.addDisposable(new Sw);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}async confirmedMissing(e){if(!this.hasReadHandler())return!1;const{results:t,errors:n}=await this._readEmitter.fireSettled(e);return!n.length&&!t.some(Boolean)}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new de);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Ga),o=n.addDisposable(new et);t=this._foreignCache[e]={get:async(s,i={})=>{await r.getOrCreate(s,async()=>{try{const c=Aw(await o.fire(s))||[];for(const l of c)l[e]=s,await this._cache.add(l.id,l);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const l=c[e];return l==null||Tw(l,s)});return Iw(a,i)},first(s,i={}){return t.get(s,{...i,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:o.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=xe()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async o=>{const s=o?{...o,...t}:t;if(!r)return t=o?gn(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:s,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 Mn(e){const t=B(e);return n=>n.getOrCreateInstance(t,()=>new Cw)}function Wd(e){const t=e.getInstance(K);if(!t)throw new Error("Failed");return t}function Wa(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Jn(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function Ow(e,t,n){return e&&!Wa(t)&&Wa(e)?{...n,meta:e.meta}:n}var Pw=B("CurrentProject"),Rw={};function Fn(e){return e?.getInstance(Pw)?.get()??Rw}function ai(e){const t=Fn(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var zd=Mn("plugin.dataSource.emails"),Kd=Mn("plugin.dataSource.emailRevisions"),Xd=$r("plugin.readEmailAutosave"),za=B("emailDocuments.provided");function Dw(e){const t=zd(e),n=Kd(e),r=n.byForeignKey("parent");if(e.getInstance(za))return{emails:t,emailRevisions:n};e.inject(za,!0);const o=()=>xn(e.getInstance(Ue)?.contentReadyTimeoutMs),s=_w({emails:t,saveTimeoutMs:o}),i=new Map,a=(c,l)=>u=>{const d=u?.id??l;return(typeof d=="string"||typeof d=="number")&&i.set(String(d),c),u};return ov(e,{...s,createEmail:c=>s.createEmail(c).then(a(Date.now())),updateEmail:(c,l)=>s.updateEmail(c,l).then(a(Date.now(),c))}),cv(e,bw({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const l=await ye(e,Xd).fire(c);return l.length===0?{asked:!1}:{asked:!0,revision:l[0]??null}},savedAt:async c=>{const l=Cg((await t.cache.getIfPresent(c))?.modified),u=i.get(String(c))??NaN;return Number.isFinite(u)&&!(l>=u)?u:l},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:o,integratorProject:()=>Fn(e).requested})),Wd(e).addDisposable(t.onSave(({prev:c,patch:l,value:u})=>Ow(c,l,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function kw(e){return{handleLoad:V(ke(e,fl)),handleLoadImage:V(ke(e,H.UPLOAD_EVENT_ID)),handleFileProxy:V(ke(e,H.FILE_PROXY_EVENT_ID)),handleUrlProxy:V(ke(e,H.PROXY_URL_EVENT_ID)),handleAITextRequest:V(ke(e,H.AI_TEXT_REQUEST_ID)),handleAIImageRequest:V(ke(e,H.AI_IMAGE_REQUEST_ID)),handleReadLocale:V(ke(e,H.READ_LOCALE)),handleLimitUsage:V(ke(e,H.ON_LIMIT_ID)),handleTranslate:V(ke(e,H.ON_TRANSLATE_ID))}}function xw(e,t){const n=e.getInstance(K),r=e.getInstance(_e);if(!n||!r)throw new Error(`[plugin] ${t}: время жизни и опции регистрирует bootstrapEarly`);return{lifetime:n,options:r}}function Lw(e){const{lifetime:t,options:n}=xw(e,"provideLoadHandler");e.getInstanceAsync(Gt).then(r=>{if(t.isDisposed())return;const o=t.addDisposable(new Bt(r.handleLoad));t.addDisposable(n.watch(({handleLoad:s})=>o.setListener(s)))},()=>{})}function Ka(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 Nw(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Mw="po",Qn=null;function Fw(){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([Mw],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Bw(){return Qn===null&&(Qn=Fw().catch(e=>{throw Qn=null,e})),Qn}async function Yd(e){if(typeof e=="object")return ci(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?jw(t):Uw(t)}function ci(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function jw(e){try{return ci(JSON.parse(e))}catch{return}}var Xa=!1;async function Uw(e){try{return ci((await Bw()).parsePoCatalog(e))}catch{Xa||(Xa=!0);return}}var $w="em_locale",Hw="em_ant_locale",Vw="locale",Gw="ant_locale";function li(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Jd(e,t){const n=li(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function qw(){return li("em_locale")??Jd(Vw,"em_locale")}function Ya(e){try{localStorage.setItem($w,JSON.stringify(e))}catch{}}function Ww(){return li("em_ant_locale")??Jd(Gw,"em_ant_locale")}function zw(e,t){try{localStorage.setItem(Hw,JSON.stringify({id:e,data:t}))}catch{}}var Kw=8e3;function Xw(e,t){const n=e,r=t,o=Object.keys(n).filter(s=>s!=="");return o.length!==Object.keys(r).filter(s=>s!=="").length?!1:o.every(s=>JSON.stringify(n[s])===JSON.stringify(r[s]))}function Yw(e){const t=qw(),n=Ww();let r={ready:!1},o;const s=ae(r);let i=0;const a=E=>{r={...r,...E},s.set(r)},c=()=>{r.ready||a({ready:!0})},l=setTimeout(c,e.unlockAfterMs??Kw),u=E=>E!==i;let d;async function f(E,P){if(n?.id===E&&n.data&&a({antd:n.data}),!d)return;const O=await d(E).catch(()=>{});!O||u(P)||(a({antd:O}),zw(E,O))}async function v(E,P){const O=await e.askHost(E).catch(()=>null);if(u(P))return!0;if(O==null)return!1;const x=await Yd(O);return u(P)||(x&&a({catalog:x}),c()),!0}async function g(E,P){const O=await e.readList();if(u(P))return;if("error"in O){a({failure:{kind:"GET_LOCALES_ERROR",error:O.error}}),c();return}const x=O.data.find(C=>C.locale===E);if(!x){Nw("em_locale")&&a({catalog:void 0}),c();return}if(Ka(t,x)&&(!o||o.catalog===t?.data)){c();return}if(o?.entry&&r.catalog===o.catalog&&Ka(o.entry,x)){Ya(o.entry),c();return}const w=await e.readCatalog(E);if(!u(P)){if("error"in w){a({failure:{kind:"GET_LOCALE_ERROR",error:w.error}}),c();return}w.data&&(o?.id===E&&r.catalog===o.catalog&&Xw(o.catalog,w.data)||a({catalog:w.data}),Ya({id:E,time:x.updatedAt||Math.floor(Date.now()/1e3),hash:x.contentHash,data:w.data})),c()}}async function y(E,P){if(!await v(E,P)){if(!u(P)&&(o?.id===E&&r.catalog===o.catalog||E==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await g(E,P)}}return{set(E){if(!E||E===r.id)return;const P=i+=1;a({id:E,failure:void 0});const O=o?.id===E&&r.catalog===o.catalog;(o&&!O&&r.catalog===o.catalog||E==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===E&&t.data&&(a({catalog:t.data}),c()),f(E,P),y(E,P)},prime(E,P,O){r.id&&r.id!==E||r.catalog||!P||(o=t?.id===E&&t.data&&(!O||t.time>=O.time)?{id:E,catalog:t.data}:{id:E,catalog:P,entry:O?{id:E,time:O.time,hash:O.hash,data:P}:void 0},a({catalog:o.catalog}))},useAntdLoader(E){d=E,r.id&&f(r.id,i)},state:s,snapshot:()=>r,dispose:()=>clearTimeout(l)}}var Jw=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})},Ja=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),Qw=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:o,format:s,baseUrl:i,cancelToken:a,...c})=>{const l=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,l),d=o&&this.toQueryString(o),f=this.contentFormatters[r||"application/json"],v=s||u.format;return this.customFetch(`${i||this.baseUrl||""}${n}${d?`?${d}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):u.signal)||null,body:typeof e>"u"||e===null?null:f(e)}).then(async g=>{const y=g;y.data=null,y.error=null;const E=v?g.clone():g,P=v?await E[v]().then(O=>(y.ok?y.data=O:y.error=O,y)).catch(O=>(y.error=O,y)):y;return a&&this.abortControllers.delete(a),P})}},Zw=B("rest.v2.transport"),Qa=Symbol("rest.v2.secureRequest");function eS(e){return e.getOrCreateInstance(Zw,()=>{const t=e.getInstance(Ps)?.execute||fetch;return new Qw({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[Qa]:!0}),customFetch:(n,r={})=>{const{[Qa]:o,...s}=r;return t(n,{...s,[yl]:o!==!0})}})})}function Qd(e,t){const n=eS(e);return Object.assign({},...t.map(r=>new r(n)))}function Za(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function qr(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Za(n.details,"wp_code")??n.code,message:Za(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 Zd(e){return!e.ok||!!e.error}function ef(){return lu(Dr.em_translations_v2)??!0}function tS(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function nS(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function rS(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],o=r[0];return typeof o=="string"&&o!==""&&t.push({locale:o,updatedAt:tS(r[1])}),t},[]):[]}function oS(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:nS(n.updated_at),contentHash:n.content_hash}),t),[])}function tf(e){return Qd(e,[Jw])}function Sr(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function ns(e){return!e.ok||e.error!=null}function rs(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function fo(e){return{data:await Yd(e)??null}}async function sS(e){if(ef())try{const n=await tf(e).localesList();return Zd(n)?{error:qr(n)}:{data:oS(n.data)}}catch(n){return Sr(n)}const t=El(e,[bl]);try{const n=await t.get_translations2({file:"react_app"});return ns(n)?rs(n):{data:rS(n.data)}}catch(n){return Sr(n)}}async function iS(e,t){if(ef())try{const r=await tf(e).jsonList({locale:t});return Zd(r)?{error:qr(r)}:fo(r.data)}catch(r){return Sr(r)}const n=El(e,[bl]);try{const r=await n.get_translations3({id:t,file:"react_app"});return ns(r)?rs(r):fo(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return ns(r)?rs(r):fo(r.data)}catch(r){return Sr(r)}}}var Zn=new WeakMap;function aS(e){const t=Zn.get(e);if(t!==void 0)return t;const n=sS(e).then(r=>("error"in r&&Zn.delete(e),r),r=>{throw Zn.delete(e),r});return Zn.set(e,n),n}var Et=B("locale.service");function cS(e){if(e.getInstance(Et))return;const t=Yw({readList:()=>aS(e),readCatalog:n=>iS(e,n),askHost:async n=>(await ye(e,H.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(je)});e.inject(Et,t),e.getInstance(K)?.addDispose(()=>t.dispose())}function lS(e){const t=e.getInstance(he);if(!t)return;const n=e.getInstance(Et);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"en_US"));e.getInstance(K)?.addDisposable(r)}var uS="user_id",dS="project_id",ec=B("rest.identityHeadersProvided");function fS(e){if(e.getInstance(ec))return;e.inject(ec,!0);let t;e.getInstance(_e)?.watch(n=>{t=n}),e.addService(wt,{execute(n,r){if(r?.public)return;const o=t?.user?.id??sd(e).profile?.id;o!=null&&o!==""&&n.headers.set(uS,String(o));const s=t?.project;s!=null&&s!==""&&n.headers.set(dS,String(s))}})}function pS(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function hS(e){return e.id??pS(e.catalog)}function mS(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function gS(e){return mS(e||"en_US")}var vS="Accept-Language",tc=B("rest.localeHeaderProvided");function _S(e){e.getInstance(tc)||(e.inject(tc,!0),e.addService(wt,{execute(t){const n=e.getInstance(Et)?.snapshot();t.headers.set(vS,gS(n&&hS(n)))}}))}function bS(e){if(!e)return!1;try{return e.getInstance(je)!==void 0}catch{return!1}}var yS="Invalid standaloneKey.",H0=B("StandaloneMockGuard");function ES(){const e=new Error(yS);return e.name="InvalidStandaloneKeyError",e}function wS(e){e.addService(wt,{execute:()=>{if(bS(e))throw ES()}})}function SS(e){Zh(e),wS(e)}function IS(e){const t=new Ad;e.inject(Ue,t);const n=e.getInstance(_e)?.watch(o=>{if(!o)return;const s=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...s!==void 0?{signal:s}:{}})}),r=e.getInstance(K);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var nf=Mn("plugin.dataSource.blocks"),AS=Mn("plugin.dataSource.blockRevisions"),TS=Mn("plugin.dataSource.comments"),CS=$r("plugin.readTemplateBlocks"),OS=$r("plugin.readCommonBlocks"),PS=e=>e.replaceAll("&","&amp;").replaceAll("<","&lt;");function rf(e=""){return`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1005
1005
  <html>
1006
1006
 
1007
1007
  <head>
1008
1008
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
1009
1009
  <meta name="x-apple-disable-message-reformatting">
1010
1010
  <meta name="viewport" content="width=device-width, initial-scale=1">
1011
- <title>${wE(e)}</title>
1011
+ <title>${PS(e)}</title>
1012
1012
  <style type="text/css">
1013
1013
  html {
1014
1014
  -webkit-text-size-adjust: none;
@@ -1056,10 +1056,10 @@ import{n as wc,r as Sc,t as zd}from"./static/esm/971f1b2c.js";import{$ as Kd,A a
1056
1056
  </table>
1057
1057
  </body>
1058
1058
 
1059
- </html>`}function SE(e,t){return{isNew:!0,is_inited:!1,subject:t||void 0,preheader:void 0,description:"",html:Ku(t),project:e?.id,project_title:e?.title??"",utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}function IE(e){return e("New email")}var Yu=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function TE(e){return!Object.keys(e).some(t=>Yu.has(t))}function AE(e){const t={},n={};for(const[r,o]of Object.entries(e))Yu.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function va(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function Or(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function CE(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function An(e){return{emails:Bu(e),blocks:zu(e),emailRevisions:ju(e),blocksRevision:bE(e),comments:_E(e)}}function RE(e){const t=Object.values(An(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function kr(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(TE(e))return{email:va(e)};{const{showOptions:n,misplacedEmailFields:r}=AE(e),o=Object.keys(r);t&&o.length>0&&void 0;const i=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:va({...r,...i})}}}function ji(e){const t=Re(e);return t&&ee(t.sessionKey())?t.suspendedDocument():t?.current()}function Kn(e){return ji(e)?.getContent()}function Xu(e,t){const n=t??SE(),r=ji(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:Kn(e)??n.html}:n}async function Xt(e){return(await e.getInstanceAsync(Xe))?.project}async function Ju(e){return Ni(e)??await Xt(e)}async function ba(e,t){const n=zu(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(o=>o!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await Ju(e),{filter:{id:t}})}function _a(e){if(!e)return;if(Or(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=kr(e,!1).email.id;return t==null?void 0:String(t)}function OE(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function kE(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}async function PE(e,t,n){const r=En(e.getInstance(Fe)?.contentReadyTimeoutMs);let o;try{return await Promise.race([t,new Promise((i,s)=>{o=setTimeout(()=>{t.then(n,()=>{}),s(new mr(r,"handleSaveBlock","block"))},r)})])}finally{clearTimeout(o)}}function Ft({code:e,project:t,...n},r){const o=Ge(n),i=Ni(r),s=Ze(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:s.toEditorForm(e)}:{},...i===void 0?{}:{project:i},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function Oe({html:e,renderGuid:t,showToken:n,showId:r,...o},i){const{requested:s}=Tn(i),a=Ql(i);return Ge({...o,code:Ze(i).toOutputForm(e),project:s===void 0?o.project:s,utm_parameters:a.UTMEnabled?o.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0,secretHash:void 0})}function Uo(e){return e==null?"":e.replaceAll(`\r
1059
+ </html>`}function RS(e,t){return{isNew:!0,is_inited:!1,subject:t||void 0,preheader:void 0,description:"",html:rf(t),project:e?.id,project_title:e?.title??"",utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}function DS(e){return e("New email")}var of=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function kS(e){return!Object.keys(e).some(t=>of.has(t))}function xS(e){const t={},n={};for(const[r,o]of Object.entries(e))of.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function nc(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function Wr(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function LS(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function Bn(e){return{emails:zd(e),blocks:nf(e),emailRevisions:Kd(e),blocksRevision:AS(e),comments:TS(e)}}function NS(e){const t=Object.values(Bn(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function zr(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(kS(e))return{email:nc(e)};{const{showOptions:n,misplacedEmailFields:r}=xS(e),o=Object.keys(r);t&&o.length>0&&void 0;const s=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:nc({...r,...s})}}}function ui(e){const t=Re(e);return t&&ee(t.sessionKey())?t.suspendedDocument():t?.current()}function cr(e){return ui(e)?.getContent()}function sf(e,t){const n=t??RS(),r=ui(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:cr(e)??n.html}:n}async function sn(e){return(await e.getInstanceAsync(Ke))?.project}async function af(e){return ai(e)??await sn(e)}async function rc(e,t){const n=nf(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(o=>o!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await af(e),{filter:{id:t}})}function oc(e){if(!e)return;if(Wr(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=zr(e,!1).email.id;return t==null?void 0:String(t)}function MS(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function FS(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}async function BS(e,t,n){const r=xn(e.getInstance(Ue)?.contentReadyTimeoutMs);let o;try{return await Promise.race([t,new Promise((s,i)=>{o=setTimeout(()=>{t.then(n,()=>{}),i(new kr(r,"handleSaveBlock","block"))},r)})])}finally{clearTimeout(o)}}function Vt({code:e,project:t,...n},r){const o=Xe(n),s=ai(r),i=nt(r);return e&&i.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:i.toEditorForm(e)}:{},...s===void 0?{}:{project:s},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function De({html:e,renderGuid:t,showToken:n,showId:r,...o},s){const{requested:i}=Fn(s),a=ad(s);return Xe({...o,code:nt(s).toOutputForm(e),project:i===void 0?o.project:i,utm_parameters:a.UTMEnabled?o.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0,secretHash:void 0})}function os(e){return e==null?"":e.replaceAll(`\r
1060
1060
  `,`
1061
- `)}function ya(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function DE(e,t,n,r){const o=xE(e,t,n,r);return o===void 0}function xE(e,t,n,r){if(Or(t))return"block";const{email:o}=kr(t,!1),i=Ft(o,e),s=i.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=Re(e)?.current();if(!a)return"no-session";const c=a.get(),l=c.attributes;if(c.serverId!==s)return"document-id";if(l.is_inited!==!0)return"not-inited";const u=ya(Uo(n??a.getContent()));if(i.html!==void 0&&ya(Uo(i.html))!==u)return"html";if(i.subject!==void 0&&i.subject!==l.subject)return"subject";if(i.preheader!==void 0&&i.preheader!==l.preheader)return"preheader";if(i.common_styles!==void 0&&i.common_styles!==l.common_styles)return"common_styles"}function Ea(e,t){if(Or(t))return;const{email:n}=kr(t,!1),r=Ft(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:Uo(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function ME(e){return Array.isArray(e)?e.some(t=>So(t)):So(e)}function LE(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])ME(t[n])&&delete t[n];return t}function NE(e,t){const n={...e};return delete n.id,{...n,...t}}function FE(e,t){var n=0,r,o;t=t||{};function i(){var s=r,a=arguments.length,c,l;e:for(;s;){if(s.args.length!==arguments.length){s=s.next;continue}for(l=0;l<a;l++)if(s.args[l]!==arguments[l]){s=s.next;continue e}return s!==r&&(s===o&&(o=s.prev),s.prev.next=s.next,s.next&&(s.next.prev=s.prev),s.next=r,s.prev=null,r.prev=s,r=s),s.val}for(c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];return s={args:c,val:e.apply(null,c)},r?(r.prev=s,s.next=r):o=s,n===t.maxSize?(o=o.prev,o.next=null):n++,r=s,s.val}return i.clear=function(){r=null,o=null,n=0},i}var BE=zd((e=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(a){return o(s(a),arguments)}function r(a,c){return n.apply(null,[a].concat(c||[]))}function o(a,c){for(var l=1,u=a.length,d,m="",_=0,v,E,y,k,C,F,T;_<u;_++)if(typeof a[_]=="string")m+=a[_];else if(typeof a[_]=="object"){if(E=a[_],E.keys)for(d=c[l],v=0;v<E.keys.length;v++){if(d==null)throw new Error(n('[sprintf] Cannot access property "%s" of undefined value "%s"',E.keys[v],E.keys[v-1]));d=d[E.keys[v]]}else E.param_no?d=c[E.param_no]:d=c[l++];if(t.not_type.test(E.type)&&t.not_primitive.test(E.type)&&d instanceof Function&&(d=d()),t.numeric_arg.test(E.type)&&typeof d!="number"&&isNaN(d))throw new TypeError(n("[sprintf] expecting number but found %T",d));switch(t.number.test(E.type)&&(F=d>=0),E.type){case"b":d=parseInt(d,10).toString(2);break;case"c":d=String.fromCharCode(parseInt(d,10));break;case"d":case"i":d=parseInt(d,10);break;case"j":d=JSON.stringify(d,null,E.width?parseInt(E.width):0);break;case"e":d=E.precision?parseFloat(d).toExponential(E.precision):parseFloat(d).toExponential();break;case"f":d=E.precision?parseFloat(d).toFixed(E.precision):parseFloat(d);break;case"g":d=E.precision?String(Number(d.toPrecision(E.precision))):parseFloat(d);break;case"o":d=(parseInt(d,10)>>>0).toString(8);break;case"s":d=String(d),d=E.precision?d.substring(0,E.precision):d;break;case"t":d=String(!!d),d=E.precision?d.substring(0,E.precision):d;break;case"T":d=Object.prototype.toString.call(d).slice(8,-1).toLowerCase(),d=E.precision?d.substring(0,E.precision):d;break;case"u":d=parseInt(d,10)>>>0;break;case"v":d=d.valueOf(),d=E.precision?d.substring(0,E.precision):d;break;case"x":d=(parseInt(d,10)>>>0).toString(16);break;case"X":d=(parseInt(d,10)>>>0).toString(16).toUpperCase()}t.json.test(E.type)?m+=d:(t.number.test(E.type)&&(!F||E.sign)?(T=F?"+":"-",d=d.toString().replace(t.sign,"")):T="",k=E.pad_char?E.pad_char==="0"?"0":E.pad_char.charAt(1):" ",C=E.width-(T+d).length,y=E.width&&C>0?k.repeat(C):"",m+=E.align?T+d+y:k==="0"?T+y+d:y+T+d)}return m}var i=Object.create(null);function s(a){if(i[a])return i[a];for(var c=a,l,u=[],d=0;c;){if((l=t.text.exec(c))!==null)u.push(l[0]);else if((l=t.modulo.exec(c))!==null)u.push("%");else if((l=t.placeholder.exec(c))!==null){if(l[2]){d|=1;var m=[],_=l[2],v=[];if((v=t.key.exec(_))!==null)for(m.push(v[1]);(_=_.substring(v[0].length))!=="";)if((v=t.key_access.exec(_))!==null)m.push(v[1]);else if((v=t.index_access.exec(_))!==null)m.push(v[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=m}else d|=2;if(d===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");u.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");c=c.substring(l[0].length)}return i[a]=u}typeof e<"u"&&(e.sprintf=n,e.vsprintf=r),typeof window<"u"&&(window.sprintf=n,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()})),DC=Sc(BE()),xC=FE(console.error),wa={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},jE=["(","?"],$n={")":["("],":":["?","?:"]},UE=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;function $E(e){for(var t=[],n=[],r,o,i,s;r=e.match(UE);){for(o=r[0],i=e.substr(0,r.index).trim(),i&&t.push(i);s=n.pop();){if($n[o]){if($n[o][0]===s){o=$n[o][1]||o;break}}else if(jE.indexOf(s)>=0||wa[s]<wa[o]){n.push(s);break}t.push(s)}$n[o]||n.push(o),e=e.substr(r.index+o.length)}return e=e.trim(),e&&t.push(e),t.concat(n.reverse())}var HE={"!":function(e){return!e},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"<":function(e,t){return e<t},"<=":function(e,t){return e<=t},">":function(e,t){return e>t},">=":function(e,t){return e>=t},"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},"&&":function(e,t){return e&&t},"||":function(e,t){return e||t},"?:":function(e,t,n){if(e)throw t;return n}};function VE(e,t){for(var n=[],r=0,o,i,s,a,c;r<e.length;r++){if(a=e[r],s=HE[a],s){for(o=s.length,i=Array(o);o--;)i[o]=n.pop();try{c=s.apply(null,i)}catch(l){return l}}else t.hasOwnProperty(a)?c=t[a]:c=+a;n.push(c)}return n[0]}function GE(e){var t=$E(e);return function(n){return VE(t,n)}}function qE(e){var t=GE(e);return function(n){return+t({n})}}var Sa={contextDelimiter:"",onMissingKey:null};function WE(e){for(var t=e.split(";"),n=0,r;n<t.length;n++)if(r=t[n].trim(),r.indexOf("plural=")===0)return r.substr(7)}function Ui(e,t){var n;this.data=e,this.pluralForms={},this.options={};for(n in Sa)this.options[n]=t!==void 0&&n in t?t[n]:Sa[n]}Ui.prototype.getPluralForm=function(e,t){var n=this.pluralForms[e],r,o,i;return n||(r=this.data[e][""],i=r["Plural-Forms"]||r["plural-forms"]||r.plural_forms,typeof i!="function"&&(o=WE(r["Plural-Forms"]||r["plural-forms"]||r.plural_forms),i=qE(o)),n=this.pluralForms[e]=i),n(t)};Ui.prototype.dcnpgettext=function(e,t,n,r,o){var i,s,a;return o===void 0?i=0:i=this.getPluralForm(e,o),s=n,t&&(s=t+this.options.contextDelimiter+n),a=this.data[e][s],a&&a[i]?a[i]:(this.options.onMissingKey&&this.options.onMissingKey(n,e),i===0?n:r)};var Ia={"":{plural_forms(e){return e===1?0:1}}},zE=/^i18n\.(n?gettext|has_translation)(_|$)/,Qu=(e,t,n)=>{const r=new Ui({}),o=new Set,i=()=>{o.forEach(T=>T())},s=T=>(o.add(T),()=>o.delete(T)),a=(T="default")=>r.data[T],c=(T,R="default")=>{r.data[R]={...r.data[R],...T},r.data[R][""]={...Ia[""],...r.data[R]?.[""]},delete r.pluralForms[R]},l=(T,R)=>{c(T,R),i()},u=(T,R="default")=>{r.data[R]={...r.data[R],...T,"":{...Ia[""],...r.data[R]?.[""],...T?.[""]}},delete r.pluralForms[R],i()},d=(T,R)=>{r.data={},r.pluralForms={},l(T,R)},m=(T="default",R,A,D,O)=>(r.data[T]||c(void 0,T),r.dcnpgettext(T,R,A,D,O)),_=(T="default")=>T,v=(T,R)=>{let A=m(R,void 0,T);return n?(A=n.applyFilters("i18n.gettext",A,T,R),n.applyFilters("i18n.gettext_"+_(R),A,T,R)):A},E=(T,R,A)=>{let D=m(A,R,T);return n?(D=n.applyFilters("i18n.gettext_with_context",D,T,R,A),n.applyFilters("i18n.gettext_with_context_"+_(A),D,T,R,A)):D},y=(T,R,A,D)=>{let O=m(D,void 0,T,R,A);return n?(O=n.applyFilters("i18n.ngettext",O,T,R,A,D),n.applyFilters("i18n.ngettext_"+_(D),O,T,R,A,D)):O},k=(T,R,A,D,O)=>{let h=m(O,D,T,R,A);return n?(h=n.applyFilters("i18n.ngettext_with_context",h,T,R,A,D,O),n.applyFilters("i18n.ngettext_with_context_"+_(O),h,T,R,A,D,O)):h},C=()=>E("ltr","text direction")==="rtl",F=(T,R,A)=>{const D=R?R+""+T:T;let O=!!r.data?.[A??"default"]?.[D];return n&&(O=n.applyFilters("i18n.has_translation",O,T,R,A),O=n.applyFilters("i18n.has_translation_"+_(A),O,T,R,A)),O};if(e&&l(e,t),n){const T=R=>{zE.test(R)&&i()};n.addAction("hookAdded","core/i18n",T),n.addAction("hookRemoved","core/i18n",T)}return{getLocaleData:a,setLocaleData:l,addLocaleData:u,resetLocaleData:d,subscribe:s,__:v,_x:E,_n:y,_nx:k,isRTL:C,hasTranslation:F}};function Zu(e){return!(typeof e!="string"||e===""||!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e))}function $i(e){return!(typeof e!="string"||e===""||/^__/.test(e)||!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e))}function Ta(e,t){return function(r,o,i,s=10){const a=e[t];if(!$i(r)||!Zu(o)||typeof i!="function"||typeof s!="number")return;const c={callback:i,priority:s,namespace:o};if(a[r]){const l=a[r].handlers;let u;for(u=l.length;u>0&&!(s>=l[u-1].priority);u--);u===l.length?l[u]=c:l.splice(u,0,c),a.__current.forEach(d=>{d.name===r&&d.currentIndex>=u&&d.currentIndex++})}else a[r]={handlers:[c],runs:0};r!=="hookAdded"&&e.doAction("hookAdded",r,o,i,s)}}function Hn(e,t,n=!1){return function(o,i){const s=e[t];if(!$i(o)||!n&&!Zu(i))return;if(!s[o])return 0;let a=0;if(n)a=s[o].handlers.length,s[o]={runs:s[o].runs,handlers:[]};else{const c=s[o].handlers;for(let l=c.length-1;l>=0;l--)c[l].namespace===i&&(c.splice(l,1),a++,s.__current.forEach(u=>{u.name===o&&u.currentIndex>=l&&u.currentIndex--}))}return o!=="hookRemoved"&&e.doAction("hookRemoved",o,i),a}}function Aa(e,t){return function(r,o){const i=e[t];return typeof o<"u"?r in i&&i[r].handlers.some(s=>s.namespace===o):r in i}}function Ca(e,t,n=!1){return function(o,...i){const s=e[t];s[o]||(s[o]={handlers:[],runs:0}),s[o].runs++;const a=s[o].handlers;if(!a||!a.length)return n?i[0]:void 0;const c={name:o,currentIndex:0};for(s.__current.push(c);c.currentIndex<a.length;){const l=a[c.currentIndex].callback.apply(null,i);n&&(i[0]=l),c.currentIndex++}if(s.__current.pop(),n)return i[0]}}function Ra(e,t){return function(){var r;const o=e[t];return(r=o.__current[o.__current.length-1]?.name)!==null&&r!==void 0?r:null}}function Oa(e,t){return function(r){const o=e[t];return typeof r>"u"?typeof o.__current[0]<"u":o.__current[0]?r===o.__current[0].name:!1}}function ka(e,t){return function(r){const o=e[t];if($i(r))return o[r]&&o[r].runs?o[r].runs:0}}var KE=class{constructor(){this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=Ta(this,"actions"),this.addFilter=Ta(this,"filters"),this.removeAction=Hn(this,"actions"),this.removeFilter=Hn(this,"filters"),this.hasAction=Aa(this,"actions"),this.hasFilter=Aa(this,"filters"),this.removeAllActions=Hn(this,"actions",!0),this.removeAllFilters=Hn(this,"filters",!0),this.doAction=Ca(this,"actions"),this.applyFilters=Ca(this,"filters",!0),this.currentAction=Ra(this,"actions"),this.currentFilter=Ra(this,"filters"),this.doingAction=Oa(this,"actions"),this.doingFilter=Oa(this,"filters"),this.didAction=ka(this,"actions"),this.didFilter=ka(this,"filters")}};function YE(){return new KE}var ed=YE(),{addAction:MC,addFilter:LC,removeAction:NC,removeFilter:FC,hasAction:BC,hasFilter:jC,removeAllActions:UC,removeAllFilters:$C,doAction:HC,applyFilters:VC,currentAction:GC,currentFilter:qC,doingAction:WC,doingFilter:zC,didAction:KC,didFilter:YC,actions:XC,filters:JC}=ed,pe=Qu(void 0,void 0,ed),QC=pe.getLocaleData.bind(pe),ZC=pe.setLocaleData.bind(pe),e0=pe.resetLocaleData.bind(pe),t0=pe.subscribe.bind(pe),n0=pe.__.bind(pe),r0=pe._x.bind(pe),o0=pe._n.bind(pe),i0=pe._nx.bind(pe),s0=pe.isRTL.bind(pe),a0=pe.hasTranslation.bind(pe);function XE(e,t){if(e.html)return e;const n=e.subject||t;return{...e,subject:n,html:Ku(n)}}function JE(e,t){if(e.html||e.subject||!t?.subject)return e;const n={...e};return delete n.subject,n}async function QE(e){const t=e.getInstance(vt);t&&!t.snapshot().ready&&await new Promise(r=>{const o=t.state.watch(({ready:i})=>{i&&(queueMicrotask(()=>o.dispose()),r())})});const n=Qu(t?.snapshot().catalog);return IE(r=>n.__(r))}function lt({code:e,project:t,...n},r,o){const i=o??Ni(r);return{...n,...e?{html:Ze(r).toEditorForm(e)}:{},renderGuid:ke(),...i===void 0?{}:{project:i}}}function Se({html:e,renderGuid:t,...n},r){const{requested:o}=Tn(r);return Ge({...n,code:Ze(r).toOutputForm(e),project:o===void 0?n.project:o,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function td(e){return Re(e)?.current()?.get().serverId??void 0}function $o(e,t,n){return n===void 0&&(n=e.post===void 0?td(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function Jt(e,t){return Ge({...e,link:void 0,comment_status:void 0})}function Yn({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?td(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||Mh(n.slug),parent:o}}function Ho({html:e,isAutosave:t,...n},r){return Ge({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:Ge({html:e,ampHtml:e&&""})})}function Xn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function Pa({html:e,isAutosave:t,...n}){return Ge({...n,autosave:t?!0:void 0,code:e,guid:void 0})}function ZE(e){return String(e).replace(/"/g,"&quot;")}function ew(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 Hi(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 Da(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),o=ZE(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function xa(e,t){return e.replace(new RegExp(`\\s+${t}\\s*=\\s*["'][^"']*["']`,"gi"),"")}function Ma(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function nd(e){if(!e?.trim())return{};const t=Hi(e);return t?{emBlockId:Ma(t.full,"em-block-id"),emBlockVersion:Ma(t.full,"em-block-version")}:{}}function rd(e,t,n){if(!e?.trim()||!t)return e;const r=Hi(e);if(!r)return e;const o=String(t),i=ew(n??new Date);let{full:s,index:a}=r;const c=s.length;return/\bem-block-id\s*=/.test(s)||(s=Da(s,"em-block-id",o)),s=Da(s,"em-block-version",i),e.slice(0,a)+s+e.slice(a+c)}function tw(e){const t=e?.trim()?Hi(e):null;if(!t)return e;const{full:n,index:r}=t,o=xa(xa(n,"em-block-id"),"em-block-version");return e.slice(0,r)+o+e.slice(r+n.length)}function nw(e,t){const{emBlockId:n,emBlockVersion:r}=nd(e);return n&&r?e:rd(e,t)}var Dt=U("NotificationService"),rw=U("emailTemplate.reads");async function ow(e,t){try{const n=ft(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,sw(e,t,n);return}}var iw=U("emailTemplate.notifiedFailures");function sw(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(iw,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(Dt).then(()=>{vn(e,H.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function aw(e,t){const n=e.getOrCreateInstance(rw,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=ow(e,t).then(i=>(i===void 0&&n.delete(t),i));return n.set(t,o),o}var cw=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:fa.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:fa.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},c0=U("projects.v2IdByWpId"),l0=U("projects.wpIdByV2Id"),u0=U("emails.v2SavedAtOnOpen"),d0=U("emails.v2OpeningReads"),Vo=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function lw(e,t){if(!t)throw new Vo(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new Vo(e,Rr(t))}function uw(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var dw=/^[A-Za-z0-9_-]{1,128}$/,fw=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),La=new Set;function pw(e){return dw.test(e)?!0:(La.has(e)||La.add(e),!1)}function hw(e){return e&&!e.ok?String(Rr(e).data.code??""):""}var od=()=>({isAutosave:!1});function Na(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function mw(e,t){const n=new AbortController,r=En(e.getInstance(Fe)?.contentReadyTimeoutMs);let o;const i=new Promise((s,a)=>{o=setTimeout(()=>{n.abort(),a(new Vo("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),i])}finally{clearTimeout(o)}}function gw(e,t){return Zc(t,e==="block")}async function vw(e,t,n,r,o){if(!pw(n))return od();const i=Lt(e),s=wn(e),a=gw(t,n);try{const c=await bw(e,t,n,r,o);return c.id&&(i.set(a,c.id),s.delete(a)),c}catch(c){throw bm(s,a,r.html??""),c}}async function bw(e,t,n,r,o){const i=Vu(e,[cw]),s={entityId:n,...o?{autosave:!0}:{}},a=await mw(e,c=>t==="email"?i.emailsRevisionsCreate(s,Na(t,r),{signal:c}):i.blocksRevisionsCreate(s,Na(t,r),{signal:c}));return fw.has(hw(a))?od():(lw("обновление",a),uw(a.data??{}))}function _w(e,t,n,r){return vw(e,t,n,r,!1)}async function yw(e,t,n){if(t==null||t===""||n===void 0||!Ut(e))return Fa;const r=Date.now(),o=mi(String(t));return kl(o,{html:n},r,Si(Lt(e),o,wn(e),n)),await _w(e,"block",String(t),{html:n}),rr(o,r,Lt(e).get(o)??void 0),()=>gi(o,r)}function Fa(){}var Yr="EXTERNAL",Ba=Symbol("supersededShow");function Ew(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var ww="email_id";function Xr(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var Sw=class extends ve{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=Rc();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=An(t),this._eventLock=RE(t);const n=ne(e,H.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(ne(e,H.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(pr,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(ww,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Fe)??Pi}_throwIfDestroyed(){if(this.isDisposed())throw Ke()}async getTemplateEmail(e){const t=await aw(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,LE(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Xt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,lt(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,Yn(o,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,$o(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const i=this._dataSources.emails,s=i.cache,a=await Xt(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let l=Ft(e,this._container);const u=l.id;let d=u;if(u!==void 0){const m=await i.get(u);l={...m??{},...l,utm_parameters:l.utm_parameters??m?.utm_parameters??{},renderGuid:m?.renderGuid??ke(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a}}else{d=n??ke();const m=await i.get(d);l={...l,utm_parameters:l.utm_parameters??{},renderGuid:m?.renderGuid??ke(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a},delete l.project}if(t){const m=await this.getTemplateEmail(String(t));m&&(l=NE(m,l))}return u===void 0&&!l.html&&(l=XE(l,await QE(this._container))),await s.setAll([[d,l]]),l}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Ea(this._container,e))return!1;const n=Kn(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Ea(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Kn(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&OE({ticket:t,emailId:_a(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Ba;if(!e)return;const n=this._getInitPipeline();if(se(n.signal),Or(e))return this._showBlock(e,n);const r=ee(ye(this._container).sessionKey()),o=kE(e);if(!r&&!o&&DE(this._container,e,Kn(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const i=kr(e);i.email.id,this._prevCommand?.id;let s,a="",c=0,l=!1,u,d=Promise.resolve(),m,_=!1;try{this._eventLock.suspendChange();const{email:v,blocks:E,autosaves:y,comments:k,templateId:C,reload:F}=i;s=v.id;const T=Ft(v,this._container),R=T.id,A=R??ke(),D=await ct("getProject",Xt(this._container));se(n.signal),a=ke();const O={isNew:R===void 0,id:String(A),project:D},h=F===!0&&R!==void 0;h&&(await this._dataSources.emails.remove(String(R),{silent:!0}),String(R)),c=++this._showToken,String(A);const f=[];f.push(this.setBlocks(E)),v.id!==void 0&&(f.push(this.setComments(k)),f.push(this.setEmailRevisions(y,String(v.id)))),f.push(this.setEmail(v,So(C)?C:Number(C),R===void 0?String(A):void 0,c,a)),await ct("setEmail+blocks+revisions",Promise.all(f),{emailId:R??String(A),showId:a,targetShowToken:c}),se(n.signal);const p=await this._dataSources.emails.get(String(A)),b=ye(this._container),x={id:a,token:c};if(r){zn(this._container);const w=b.suspendedDocument()?.get().serverId;!h&&R!==void 0&&w!=null&&String(w)===String(R)&&b.resumeSuspended()}R===void 0?m=b.startNewDraft(p??T,{patch:JE(T,p),show:x}):h?m=b.reload(R,{email:p??T,patch:T,show:x}):b.sessionKey()===wt(R)?m=b.show(T,x):m=b.open(R,{email:p??T,patch:T,show:x}),b.beginShowFill(a);const N=!!this._prevCommand&&Ne(this._prevCommand,O);O.id,!this._prevCommand||Ne(this._prevCommand,O),this._prevCommand?.id,this._rememberShow(O),d=n.requestShow({showId:a,navId:String(A),emailId:R,isNew:R===void 0}),_=!0;const S=()=>b.endShowFill(a);Promise.allSettled([d,m.whenReady()]).then(S),String(A),l=!0}catch(v){u=v,_&&a&&n.failShow(a,v),a&&Re(this._container)?.endShowFill(a),ui(v)||(Wc(v),void 0)}finally{this._eventLock.resumeChange()}if(!l)throw u instanceof Error?u:new Error(`[useblocks] show() setup failed: ${String(u??"unknown error")}`);return ct("show-init-deferred",Promise.all([d,m?.whenReady().catch(v=>{if(v instanceof dt){const E=wi(v);throw E?new Error(`[useblocks] show(): email open failed (${E})`,{cause:v}):v}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:i,reload:s}=CE(e),a=ke();let c=!1;try{await this.setBlocks(o),se(t.signal),s&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const l=n.id!==void 0&&n.id!==""?String(n.id):void 0,u=ye(this._container);if(!s&&l!==void 0&&u.sessionKey()===er(l)){const C=Xr(n)?await this._storeShownBlock(n):void 0,F={id:a,token:++this._showToken},T=u.show(C,F),R=t.requestShow({showId:a,navId:l,emailId:void 0,isNew:!1});c=!0,await ct("show-block-init",Promise.all([R,T?.whenReady().catch(()=>{})]),{showId:a});return}const d=r||s?await ba(this._container,String(n.id)):void 0,m=d&&(s||Xr(n))?await this._storeShownBlock({...Se(d,this._container),...n}):r||s?d:await this._storeShownBlock(n);if(se(t.signal),!m)throw new Error(`[useblocks] show(): block ${String(n.id)} not found`);i!==void 0&&m.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(i.filter(C=>C.id!==void 0).map(C=>[C.id,Xn(C,String(m.id))])),this._prevCommand=void 0,this._lastShow=void 0;const _=m.id!==void 0?String(m.id):ke(),v={id:a,token:++this._showToken};zn(this._container);const E=s?u.reloadBlock(_,m,v):u.openBlock(_,m,v);m.id;const y=t.requestShow({showId:a,navId:_,emailId:void 0,isNew:m.id===void 0});c=!0;const k=E.whenReady().catch(C=>{if(C instanceof dt)throw C});await ct("show-block-init",Promise.all([y,k]),{showId:a})}catch(l){throw c&&t.failShow(a,l),l}}async _storeShownBlock(e){const t=lt(e,this._container,await Xt(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();se(e.signal);const t=ye(this._container);if(ee(t.sessionKey())&&!t.hasSuspended())throw new Error("[useblocks] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:Yr,fallbackTitle:ru(this._container)});if(se(e.signal),!n)throw Ew(t.emailSaveState().error);return Oe(Xu(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=ye(this._container),t=e.current();if(!t||!ee(e.sessionKey()))throw new Error("[useblocks] saveBlock(): no open block");return dh(t,async()=>{await t.whenReady();const n=Tr(t),r=t.get().version,o=t.get().serverId,i=typeof n.global_block=="boolean"?n.global_block:o!=null&&nd(n.html??"").emBlockId===String(o),s=o!=null&&i?rd(n.html,String(o),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:s,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},c=this._dataSources.blocks,l=await yw(this._container,t.get().serverId,a.html),u=t.get().serverId==null?c.create(a,{source:Yr}):c.update(String(t.get().serverId),a,{source:Yr}),d=await PE(this._container,u,m=>{m&&l(),m&&ye(this._container).current()===t&&t.get().serverId==null&&m.id!==void 0&&t.markSaved(r,String(m.id))});if(!d)throw new Error("[useblocks] save(): block was not saved");return l(),t.markSaved(r,d.id!==void 0?String(d.id):void 0),Se(d,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=_a(e);const n=this._queuedShow(e,t).then(r=>r===Ba?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),se(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=ye(this._container);if(n!==void 0&&r.sessionKey()===er(n))return;const o=t.code===void 0&&n!==void 0?await ba(this._container,n):void 0,i=o&&Xr(t)?await this._storeShownBlock({...Se(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!i)throw new Error(`[useblocks] openBlock(): block ${String(n)} not found`);zn(this._container);const s=r.openBlockOver(i.id!==void 0?String(i.id):ke(),i);i.id,r.hasSuspended(),_e(this._container,H.ON_BLOCK_OPEN_ID).fire({block:i}),await s.whenReady().catch(a=>{if(a instanceof dt)throw r.current()===s&&(_e(this._container,H.ON_BLOCK_CLOSE_ID).fire({block:i,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),Mb(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function Iw(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 Tw(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),o=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:o,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Iw(e)}}function Jr(e,t){return t?Tw(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var id=["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"],Aw=[...id,"html","id","project","password"],f0=new Set(["html",...id,"global_block","project"]);function Cw(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(Aw),r={};for(const o of Object.keys(e))n.has(o)||(r[o]=e[o]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Rw(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Cw(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 Go=new WeakMap;function Ow(e){let t=Go.get(e);return t||(t={byId:new Map,fallback:[]},Go.set(e,t)),t}function kw(e){Go.delete(e)}function Pw(e,t){const{byId:n,fallback:r}=Ow(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const i=r.indexOf(o);return i>=0&&r.splice(i,1),o}return}for(let o=r.length-1;o>=0;o--){const i=r[o],s=e.name!=null&&e.name!==""&&i.name!=null&&i.name!==""&&i.name===e.name,a=e.type!=null&&e.type!==""&&i.insertFrom===e.type;if(s&&a)return r.splice(o,1),i.id!=null&&i.id!==""&&n.delete(String(i.id)),i}}async function Dw(e,t){const{blocks:n}=An(e);return await n.cache.getIfPresent(t)??void 0}async function xw(e,t){if(!t.blockId)return;const n=await Dw(e,t.blockId);if(n)return Rw(n,t)}async function Mw(e,t){const n=Pw(e,t);if(n)return Jr(e,n);const r=await xw(t,e);return r?Jr(e,r):Jr(e,void 0)}var Lw=Pc("application_block_inserted"),Nw=-1e3,ja=new WeakSet;function Fw(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 Bw(e){if(!e||ja.has(e))return;ja.add(e);const t=new ve,n=fe(e);return t.addDisposable(n.addListenerAsyncPipe(Lw,async(r,o)=>{const i=Fw(r)?await Mw(r,e):r;return o?o(i):i},Nw)),t.addDisposable({dispose:()=>{kw(e)}}),t}var jw=Ir("plugin.readBlockAutosave"),p0=U("blockDocuments.provided"),sd=U("plugin.earlyWindow");function Uw(e){return e.getOrCreateInstance(sd,()=>({depth:0}))}function $w(e){const t=Uw(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function ad(e){return(e?.getInstance(sd)?.depth??0)>0}function cd(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,i,s)=>{const a=e(o,i,s);if(r&&ad(t)){const c=n;queueMicrotask(()=>{o.call(s,c)})}return a}}var Qr=100,Hw=class extends ve{_container;_events;constructor(e){super(),this._container=e;const t=Bw(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:i}=An(e),s=ne(e,H.ON_SHARE_ID),a=ne(e,H.ON_SHOW_PREVIEW_ID),c=ne(e,H.ON_EMAIL_CLONE_ID),l=ne(e,H.ON_BLOCK_OPEN_ID),u=ne(e,H.ON_BLOCK_CLOSE_ID),d=ne(e,H.ON_BLOCK_CLONE_ID),m=ne(e,H.ON_BLOCK_INIT_ID),_=ne(e,H.ON_BLOCK_CHANGED_ID),v=ne(e,H.ON_CODE_VALIDATE_ID),E=ne(e,H.ON_IMPORT_VALIDATE_ID),y=ne(e,H.ON_SUBJECT_CHANGED_ID),k=ne(e,H.ON_EMAIL_CHANGED_ID),C=ne(e,H.ON_PREHEADER_CHANGED_ID),F=ne(e,H.ON_SAVEBUTTON_CLICK_ID),T=ne(e,H.ON_BLOCK_SAVEBUTTON_CLICK_ID),R=ne(e,H.ON_NEXTBUTTON_CLICK_ID),A=ne(e,H.ON_SEND_LIVEPREVIEW_ID),D=ne(e,H.ON_SEND_TESTEMAIL_ID),O=ne(e,EE),h=ne(e,H.ON_CONTENT_CHANGED_ID),f=ne(e,yE),p=ne(e,H.ON_PREVIOUSBUTTON_CLICK_ID),b=ne(e,H.ON_SEND_EMAIL_MODAL_ID),x=of(ne(e,H.ON_EMAIL_INIT_ID),S=>!S.reset),N=ne(e,H.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:V(C),handleSubjectChanged:V(y),handleValidate:V(v),handleImportValidate:V(E),handleReadEmail:V(n.handlerRead,S=>S,S=>S&&Ft(S,e)),handleSaveEmail:V(n.onSave,function({prev:S,patch:w,value:M,source:B}){const W=S?Oe(S,e):void 0;return{prev:W,patch:sn(W,Oe(w,e)),value:Oe(M,e),source:B}},S=>S?Ft(S,e):void 0),handleRemoveEmail:V(n.onRemove,({value:S,source:w})=>({value:Oe(S,e),source:w}),()=>{}),handleReadCommonBlocks:V(O,S=>S.project,S=>S?.map(w=>lt(w,e))),handleReadTemplateBlocks:V(f,S=>S,S=>S?.map(w=>lt(w,e))),handleReadBlocks:V(t.byForeignKey("project").handleRead,S=>Tn(e).requested||String(S),S=>S?.map(w=>lt(w,e))),handleReadBlock:V(t.handlerRead,S=>S,S=>S?lt(S,e):void 0),handleOpenBlock:V(l,({block:S})=>({block:Se(S,e)})),handleCloseBlock:V(u,({block:S,hasUnsavedChanges:w})=>({block:Se(S,e),hasUnsavedChanges:w})),handleCloneBlock:V(d,S=>Se({...S,html:tw(S.html)},e)),handleSaveBlock:V(t.onSave,function({prev:S,patch:w,value:M,source:B}){const W=M.global_block===!0&&M.id&&typeof M.html=="string"?{...M,html:nw(M.html,String(M.id))}:M,re=S?Se(S,e):void 0;return{prev:re,patch:sn(re,Se(w,e)),value:Se(W,e),source:B}},S=>S?lt(S,e):void 0),handleRemoveBlock:V(t.onRemove,({value:S,source:w})=>({value:Se(S,e),source:w}),()=>{}),handleReadComments:V(r.byForeignKey("post").handleRead,S=>S,S=>S?.map(w=>$o(w,e))),handleSaveComment:V(r.onSave,function({prev:S,patch:w,value:M,source:B}){const W=S?Jt(S,e):void 0;return{prev:W,patch:sn(W,Jt(w,e)),value:Jt(M,e),source:B}},S=>S?$o(S,e):void 0),handleRemoveComment:V(r.onRemove,({value:S,source:w})=>({value:Jt(S,e),source:w}),()=>{}),handleReadEmailRevisions:V(o.byForeignKey("parent").handleRead,S=>S,S=>S?.map(w=>Yn(w,e))),handleReadEmailAutosave:V(ne(e,Uu),S=>S,S=>S?Yn(S,e):null),handleEmailAutosave:V(o.onSave,function({prev:S,patch:w,value:M,source:B}){return{value:Ho(M,e),source:B}},S=>S?Yn(S,e):void 0),handleRemoveEmailAutoSave:V(o.onRemove,({value:S,source:w})=>({value:Ho(S,e),source:w}),()=>{}),handleReadBlockRevisions:V(i.byForeignKey("parent").handleRead,S=>S,S=>S?.map(w=>Xn(w))),handleReadBlockAutosave:V(ne(e,jw),S=>S,S=>S?Xn(S):null),handleBlockAutosave:V(i.onSave,({value:S,source:w})=>({value:Pa(S),source:w}),S=>S?Xn(S):void 0),handleRemoveBlockAutoSave:V(i.onRemove,({value:S,source:w})=>({value:Pa(S),source:w}),()=>{}),handleBlockInit:V(m,S=>Se(S,e)),handleBlockChanged:V(Mr(_,Qr),S=>Se(S,e)),handleEmailChanged:V(Mr(k,Qr),S=>Oe(S,e)),handleEmailInit:cd(V(x,S=>Oe(S,e)),e),handlePreviousButtonClick:V(p,S=>Oe(S,e)),handleNextButtonClick:V(R,S=>Oe(S,e)),handleSaveButtonClick:V(F,S=>Oe(S,e)),handleSaveBlockButtonClick:V(T,S=>Se(S,e)),handleHtmlChanged:V(Mr(h,Qr)),handleTestEmailSend:V(D,({html:S,...w})=>({...w,code:S,compiled:{html:S,ampHtml:""}})),handleTestEmailModal:V(b,S=>Oe(S,e)),handleCloneEmail:V(c,S=>Oe(S,e)),handleShareEmail:V(s),handlePreviewEmail:V(a),handleLivePreviewEmail:V(A),handleAnalyticsEvent:V(N)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new Pt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Vw=U("DataController"),Gw=U("DataEvents");function ld(e){return e.getOrCreateInstance(Vw,()=>{const t=new Sw(e);return e.getInstance(Y)?.addDisposable(t),t})}function ud(e){return e.getOrCreateInstance(Gw,()=>new Hw(e))}var qw=U("plugin.pluginStart");function dd(e){return e.getOrCreateInstance(qw,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(Y)?.addDispose(()=>t()),{done:n,finish:t}})}function Ww(e){return dd(e).done}function zw(e){const t=dd(e);return t.run===void 0&&(t.run=(e.getInstance(ci)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var Kw=U("plugin.startupShow");function Yw(e){const t=ld(e),n=ud(e),r=e.getInstance(we),o=e.getInstance(Y),i={current:Promise.resolve()};e.inject(Kw,i);let s=!1;const a=r?.watch(l=>{l&&n.setOptions(l),s=(l?.plugins?.length??0)>0,i.current=i.current.catch(()=>{})}),c=r?.select(l=>l?.content).watch(l=>{if(l===void 0)return;const u=()=>(ae(Ee.showStart),t.show(l).finally(()=>ae(Ee.showEnd))),d=s?Ww(e).then(u):u();d.catch(()=>{}),i.current=d});a&&o?.addDisposable(a),c&&o?.addDisposable(c)}function Xw(e){const t=ld(e);return{...ud(e).get(),show(n){return ae(Ee.showStart),t.show(n).finally(()=>ae(Ee.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return ae(Ee.showStart),t.showBlock(n,r).finally(()=>ae(Ee.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function fd(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Pr(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let i=t;i<e.length;i++){const s=e[i];if(o){o=!1;continue}if(s==="\\"){o=!0;continue}if(r){s===r&&(r="");continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n++;continue}if(s===")"&&(n--,n<0))return!1}return n===0}function Jw(e){return(t,n,r)=>Pr(t)?e(t,n,r):!1}function Qw(e){return t=>Pr(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Zw(e){return(t,n,r)=>Pr(t)?fd(t)?e(t,n,r):t:!1}function eS(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Pr(n)?fd(n)?e(t):t:!1}}function tS(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function Vi(e,t){const n=e.length;for(let r=0;r<n;r++){const o=e.charCodeAt(r);if(o===0||t==='"'&&o===34||t==="'"&&o===39||t===""&&(o===32||o===9||o===10||o===13||o===12||o===34||o===39||o===60||o===62||o===61||o===96))return!1}return!0}function nS(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let i=0;i<e;i++){const s=r[i]%62;o+=t.charAt(s)}return o}var rS=8,oS=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=nS(rS),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Dr=new oS;function Ua(e,t){return t!==void 0&&!Vi(e,t)?`%|{${Dr.getOrCreateByKey(e)}}|%`:e}function iS(e){const t=Dr.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function de(e,t,n){return t!==void 0?Vi(e,t)?e:`%|{${Dr.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function sS(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function le(e){return e.startsWith("<!--")&&e.endsWith("-->")?sS(e.slice(4,-3)):e}function aS(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const o=e.match(/\[%\s*([^%]*?)\s*%\]/);o&&(r=o[1]);const i=r.trim();return t.test(i)||n.test(i)}function cS(e,t,n){return t!==void 0?Vi(e,t)?e:`%|{${Dr.getOrCreateByKey(e)}}|%`:n||tS(e)||aS(e)?`<!--${e}-->`:e}var ot=Jw(de),it=Qw(le),lS=Zw(de),uS=eS(le),pd=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",iS),e.escape("@{","}",de,!0).unescape("<!--@{","}-->",le,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Ua,!0),e.escape("{{","}}",Ua,!0),e.createSyntax("brace-percent").escape("{%","%}",de).unescape("<!--{%","%}-->",le),e.createSyntax("brace-hash").escape("{#","#}",de).unescape("<!--{#","#}-->",le),e.createSyntax("proscript").escape("[%","%]",cS,!0).unescape("<!--[%","%]-->",le,!0),e.createSyntax("getresponse").escape("[[IF","]]",de).escape("[[if","]]",de).escape("[[ELSE]]","",de).escape("[[else]]","",de).escape("[[ENDIF]]","",de).escape("[[endif]]","",de).unescape("<!--[[IF","]]-->",le).unescape("<!--[[if","]]-->",le).unescape("<!--[[ELSE]]","-->",le).unescape("<!--[[else]]","-->",le).unescape("<!--[[ENDIF]]","-->",le).unescape("<!--[[endif]]","-->",le),e.createSyntax("expert-sender").escape("<if",">",de).escape("</if",">",de).escape("<else",">",de).escape("</else",">",de).escape("<var ",">",de,!0).unescape("<!--<if ",">-->",le).unescape("<!--</if",">-->",le).unescape("<!--<else ",">-->",le).unescape("<!--</else",">-->",le).unescape("<!--<var",">-->",le,!0),e.createSyntax("velocity").escape("#if",")",ot).escape("#elseif",")",ot).escape("#else","",de).escape("#foreach",")",ot).escape("#macro",")",ot).escape("#set",")",lS,!0).escape("#parse",")",ot).escape("#include",")",ot).escape("#evaluate",")",ot).escape("#end","",de).escape("#break","",de).escape("#stop","",de).unescape("<!--#macro","-->",it).unescape("<!--#if","-->",it).unescape("<!--#elseif","-->",it).unescape("<!--#else","-->",le).unescape("<!--#foreach","-->",it).unescape("<!--#parse","-->",it).unescape("<!--#include","-->",it).unescape("<!--#evaluate","-->",it).unescape("<!--#end","-->",le).unescape("<!--#break","-->",le).unescape("<!--#stop","-->",le).unescape("<!--#set","-->",uS,!0),e.createSyntax("mailchimp").escape("*|","|*",de).unescape("<!--*|","|*-->",le)},qo="bare",dS=new Map;function fS(e){return e?dS.get(e)??qo:qo}var hd=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function $a(e){return hd.includes(e)}function zt(e){return e==="bare"||e==="html-comment"}function Zr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function pS(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!zt(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[l,u]of[["output",r.output],["editor",r.editor]])if(u!==void 0&&!zt(u))return t(`templateDirectives.${l}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!Zr(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[l,u]of Object.entries(r.syntaxes))if(!(!$a(l)||u===void 0||zt(u))){if(!Zr(u))return t(`templateDirectives.syntaxes.${l}: expected a form or an object, configuration ignored.`),n;for(const d of["output","editor"]){const m=u[d];if(m!==void 0&&!zt(m))return t(`templateDirectives.syntaxes.${l}.${d}: unknown form "${String(m)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??qo;let i=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),i=void 0);const s=[];if(r.syntaxes)for(const l of Object.keys(r.syntaxes)){if(!$a(l)){t(`templateDirectives.syntaxes: unknown syntax id "${l}", entry ignored.`);continue}s.push(l)}else s.push(...hd);const a={},c={};for(const l of s){const u=r.syntaxes?.[l],d=Zr(u)?u:void 0,m=(zt(u)?u:d?.output)??o;let _=d?.editor??i??m;m==="bare"&&_==="html-comment"&&(t(`templateDirectives.syntaxes.${l}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),_="bare"),a[l]=m,c[l]=_}return{output:a,editor:c}}function md(e,t,n,r){for(let o=t;o<n;o++){const i=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?i===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(i)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):i==="<"?r.insideTag=!0:i===">"?r.insideTag=!1:r.insideTag&&(i==='"'||i==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=i,r.unquotedAttr=!1):r.insideTag&&/\S/.test(i)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(i)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function Qt(e,t){return e.start<t.end&&t.start<e.end}function Ha(e,t,n,r,o=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const i=t.flatMap(u=>u.match(e).flatMap(d=>!Number.isInteger(d.start)||!Number.isInteger(d.end)||d.start<0||d.end>e.length||d.start>=d.end?[]:[{range:d,mapFn:u.mapFn,overrideBuiltins:u.overrideBuiltins,syntax:u.syntax,isVariable:u.isVariable}])).sort((u,d)=>u.range.start-d.range.start||u.range.end-d.range.end),s=[],a=o.slice().sort((u,d)=>u.start-d.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(const{range:u,mapFn:d,overrideBuiltins:m,syntax:_,isVariable:v}of i){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):md(e,l,u.start,c),l=u.end,a.some(C=>Qt(C,u)))continue;const E=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,y=e.substring(u.start,u.end),k=d(y,E,c.insideTag);k!==!1&&k!==y&&(s.push({range:u,text:k,overrideBuiltins:m,syntax:_,isVariable:v}),a.push(u))}return s.sort((u,d)=>u.range.start-d.range.start||u.range.end-d.range.end)}function hS(e,t){const n=t.reduce((a,{mapFn:c,start:l,end:u,syntax:d,isVariable:m})=>(a[l]||(a[l]=[]),a[l].push({value:u,mapFn:c,syntax:d,isVariable:m}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),i=[];let s;for(;(s=o.exec(e))!==null;){const a=s[0];i.push({start:s.index,startToken:a,endTokens:n[a]})}return i}function eo(e,t,n,r,o=!1){const i=[];if(n&&(t=t.filter(l=>l.isVariable)),!t.length)return i;const s=hS(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let l=0;l<s.length;l++){const{start:u,startToken:d,endTokens:m}=s[l];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):md(e,c,u,a),c=u;const _=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let v=!1;for(const{mapFn:E,value:y,syntax:k,isVariable:C}of m){let F=u+d.length,T=e.indexOf(y,F);for(;T!==-1;){let R=T,A=u+d.length,D=0;for(;R!==-1;){const b=e.indexOf(d,A);if(b!==-1&&b<R)D++,A=b+d.length,R=e.indexOf(y,A);else if(D>0)D--,A=R+y.length,R=e.indexOf(y,A);else break}if(R<0)break;const O=R+y.length,h=e.substring(u,O),f=E(h,_,a.insideTag);if(f===!1){F=T+Math.max(y.length,1),T=e.indexOf(y,F);continue}(o||f!==h)&&i.push({range:{start:u,end:O},text:o?h:f,syntax:k,isVariable:C});const p=s.findIndex(({start:b})=>b>=O);p>l?l=p-1:l=s.length,v=!0;break}if(v)break}}return i}function Vn(e,t){if(!t.length)return e;const n=t.slice().sort((o,i)=>i.range.start-o.range.start);let r=e;for(const{text:o,range:i}of n)r=r.slice(0,i.start)+o+r.slice(i.end);return r}var mS=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=pd){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,i,s){return t.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this},unescape(r,o,i,s){return n.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let o=!1;const i={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(s=>s!==n),this._unescapeMatchers=this._unescapeMatchers.filter(s=>s!==r))}};return this.addDisposable(i),i}_collectMappings(e,t,n){const r=eo(e,this._escapes,t,n),o=Ha(e,this._escapeMatchers,t,n),i=o.filter(c=>c.overrideBuiltins).map(c=>c.range),s=r.filter(c=>!i.some(l=>Qt(l,c.range))),a=o.filter(c=>c.overrideBuiltins||!s.some(l=>Qt(c.range,l.range)));return[...s,...a].sort((c,l)=>c.range.start-l.range.start||c.range.end-l.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=eo(e,this._unescapes,t),r=Ha(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),i=n.filter(a=>!o.some(c=>Qt(c,a.range))),s=r.filter(a=>a.overrideBuiltins||!i.some(c=>Qt(a.range,c.range)));return[...i,...s].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>fS(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return eo(e,this._escapes,t,n,!0)}getEscapedText(e,t){return Vn(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return Vn(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=i=>i===void 0?void 0:t[i],r=Object.values(t);let o=e;return r.includes("bare")&&(o=Vn(o,this._collectRevertMappings(o).filter(i=>n(i.syntax)==="bare"))),r.includes("html-comment")&&(o=Vn(o,this._collectMappings(o).filter(i=>!i.isVariable&&n(i.syntax)==="html-comment"&&i.text.startsWith("<!--")&&i.text.endsWith("-->")))),o}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}},gd="em___script",Zt=`<${gd}`,Wo=`</${gd}>`;function Va(e){return e.replace("<script",Zt).replace("<\/script>",Wo)}var Ga=new mS(e=>{e.escape("<script","<\/script>",t=>Va(t)).unescape(Zt,Wo,t=>t.replace(Zt,"<script").replace(Wo,"<\/script>")),e.escape("<script","/>",t=>Va(t)).unescape(Zt,"/>",t=>t.replace(Zt,"<script")),pd(e)});function gS(e){const t=pS(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return rl();const n=new Set(Object.keys(t.output).filter(o=>t.output[o]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:o=>Ga.normalizeToPolicy(o,t.editor),toOutputForm:o=>Ga.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:nl(r)}}function vS(e){let t;e.injectFactory(si,()=>{const n=e.getInstance(ge)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:gS(n)}),t.policy})}var bS=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function _S(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function yS(e,t){const n=[];for(const r of e.awaits?.services??[])for(const o of t.get(r)??[])o!==e&&n.push(o);return n}function vd(e){const t=_S(e),n=[],r=new Set,o=[],i=new Set,s=a=>{if(!r.has(a)){if(i.has(a)){const c=o.indexOf(a);throw new bS([...o.slice(c),a].map(l=>l.name))}i.add(a),o.push(a);for(const c of yS(a,t))s(c);o.pop(),i.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var ES=[{name:"rest.client",setup:gE},{name:"auth.oauth",setup:Qd},{name:"rest.identityHeaders",setup:iE},{name:"rest.localeHeader",setup:dE},{name:"lifetime.destroyable",provides:[Li],setup:cy},{name:"appInit",provides:[Xe,pi],setup:_p},{name:"config",provides:[ge],setup:sy},{name:"templateDirectives",provides:[si],setup:vS},{name:"email.documents",setup:Cy},{name:"show.initPipeline",provides:[Fe],setup:vE},{name:"show",setup:Yw},{name:"locale.service",provides:[vt],setup:tE},{name:"locale.fromConfig",awaits:{services:[ge,vt]},setup:nE},{name:"canvas.early",setup:e_},{name:"canvas.previewSettings",setup:g_},{name:"canvas.sandboxExtensions",setup:b_},{name:"canvas.sandboxScriptRelay",setup:E_},{name:"canvas.headerSync",provides:[xi],setup:r_},{name:"canvas.headersAfterRecovery",setup:o_},{name:"canvas.ampSync",setup:Xg},{name:"canvas.moduleBridge",setup:Cv},{name:"canvas.port",setup:sv},{name:"canvas.images",setup:ov},{name:"canvas.edits",setup:Qb},{name:"canvas.surfaceFollowsSession",setup:Nb},{name:"canvas.blockContent",setup:Lb},{name:"canvas.sandboxFill",provides:[Di],setup:j_},{name:"canvas.reactions",setup:Zb}],qa;function Gi(e){const t=e.getInstance(we);if(t)return t;e.getInstance(Y)||e.inject(Y,new ve);const n=ce();e.inject(we,n),qa??=vd(ES);for(const r of qa)r.setup(e);return n}function wS(e){}var SS=[{name:"save.previewFollow",setup:wS}],Wa=U("plugin.lateUnitsInstalled");function IS(e){if(!e.getInstance(Wa)){e.inject(Wa,!0);for(const t of vd(SS))t.setup(e)}}function TS(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function AS(e){if(!e)return;const t=ri(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 CS=Bt(e=>{let t,n,r;return{async setOptions(o){const i=r!==o.getAuthToken,s=!Ne(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(Ve)||!o.getAuthToken)&&!(!i&&!s&&!a))try{const c=await o.getAuthToken(o.user,o.project);e.inject(Jd,Promise.resolve(c||""));const l=AS(c);if(!l)return;e.inject(gf,l);const u=e.getInstance(Xe),d=u?await u.catch(()=>{}):void 0;e.inject(Xe,Promise.resolve(TS(l,d)))}catch{}}}});function RS(e,t){if(e.getInstance(ts))return;e.inject(ts,!0);const n=Pe(e,H.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var OS=Bt(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!Sn(r)){t&&(z_(e),Mi(r)),t=void 0;return}const i=Cr(r);if(!i||t===i&&e.getInstance(Ve))return;t=i,e.inject(Ve,i);const s=e.getInstance(Y);s&&RS(e,s)}}}),kS=Bt(e=>{const t=e.getInstance(Y),n=Pe(e,Oc),r=V(n),o=t.addDisposable(new Pt(r));return{setOptions({handleLoad:i}){o.setListener(i)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function bd(e,t,n=!0){const r=e,o=t;for(const i of Object.keys(o)){const s=o[i];s!=null&&(n&&typeof s=="object"?r[i]=bd(r[i]||{},s,!0):r[i]=s)}return e}async function PS(e){const t=(await Gf(()=>import("./static/esm/2490dab8.js").then(n=>Sc(n.default)),[],import.meta.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var _d=U("EditorOptions"),zo=jf;function DS(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function xS(e){return e.getOrCreateInstance(_d,()=>{const t=ce(zo);let n=zo.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(PS(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function MS(e){return e?.getInstance(_d)?.get()??zo}function LS(e,t={}){const n=xS(e);n.set(bd({...n.get()},DS(t)))}function NS(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function FS(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var BS=U("plugin.publicConfig");function Ko(e){return e.getInstance(ge)?.get()??{}}function za(e){return e.getInstance(ge)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Ka(e){const t=Pu(e),n=Ko(e);return{...n,locale:n.locale||"en_US",theme:n.theme||"light",editor:FS(MS(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Ya(e){return e.getInstance(ge)?.get()!==void 0}function jS(e){const t=Rc(),n=_e(e,kc);let r,o,i=!1;const s=async()=>{try{return e.getInstance(Xe)===void 0?{}:(await e.getInstanceAsync(Xe))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:d=!1}={})=>{await e.getInstance(ge)?.ready(),Nc(e).set(Ko(e).revisionService===!0);const{codeModeDirection:m,editor:_}=Ko(e);_&&LS(e,NS(_)),m!==void 0&&!(d&&m===o)&&(o=m,m==="none"?Mo(e,!1):(Mo(e,!0),d_(e,m)))},c=async()=>{if(!Ya(e))return;const d=Ka(e),m=JSON.stringify(d);m!==r&&(r=m,await n.fire(d))},l=async d=>{const m=e.getInstance(ge),_={advancedConfigs:za(e).advancedConfigs,serverSide:await s(),user:d};m?.setAdvancedConfigs({..._.advancedConfigs,..._.user?.advancedConfigs});const v=m?.layers().user.mode;m?.replace(_.user?.mode===void 0&&v!==void 0?{..._.user,mode:v}:_.user,"user"),m?.replace(_.serverSide,"server"),await a(),await c()},u=d=>{const{commonStyles:m,..._}=d;return"commonStyles"in d&&p_(e,m===void 0?void 0:m),_};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:s,getConfig:()=>Ya(e)?Ka(e):{},setConfig:t.decorate(async d=>{await l(u(d))}),updateConfig:t.decorate(async d=>{const m=u(d);await l({...za(e).user,...m})}),announceAssembled(){i||(i=!0,e.getInstance(ge)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function yd(e){return e.getOrCreateInstance(BS,()=>jS(e))}function US(e){const t=yd(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var $S=Bt(e=>{const t=e.getInstance(Y),n=t.addDisposable(new Je),r=t.addDisposable(new Je),o=vn(e,kc),i=V(n.event),s=V(r.event),a=cd(V(o.event),e),c=t.addDisposable(new Pt(i)),l=t.addDisposable(new Pt(s)),u=t.addDisposable(new Pt(a));return{instance:{handleSetOptions:i,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(d){c.setListener(d.handleSetOptions),l.setListener(d.handleOptionsChanged),u.setListener(d.handleConfigChanged),yd(e).announceAssembled(),await n.fire(d),await r.fire(d)},dispose(){}}}),to,Ed="core";function HS(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Ed],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function VS(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Cn().then(()=>{}):t([Ed],e)}function Cn(){return to===void 0&&(to=HS().then(e=>(ln()&&e.installDiagnostics().catch(t=>{}),e))),to}var no=null,ro=null;async function GS(e){typeof e?.prefetch=="function"&&await e.prefetch()}function qi(){return no||(no=Cn().then(()=>{})),no}function wd(e){return ro||(ro=GS(e)),ro}function qS(){return wd(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function WS(){const e=typeof window.__useblocks__<"u"?window.__useblocks__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function zS(e){return Promise.all([qi(),wd(e)]).then(()=>{})}function KS(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Xa(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>VS(t?{priority:t}:void 0)).then(()=>(Oi(t?{priority:t}:void 0),n?qi():void 0)).catch(()=>{})}function YS(e){const t=KS(e);if(t==="eager")Xa(e);else if(t==="idle"){const n=()=>Xa(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Sd="PluginRegistry";function XS(e=af()){return e.getOrCreateInstance(Sd,()=>new Qf)}var Yo=new Zf(()=>XS());function JS(e){const t=je(e),n=Er(e);return{dispose:()=>{Ae("ui",()=>n.disposeAll()),Ae("commands",()=>t.disposeAll())}}}function QS(e,t){const n=mt(e);return t.onLifecycle(r=>n.handle(r))}var ZS=["Commands","Ui","Agent","Document"],Id=new Set(["Agent","Document"]),Ja=new Map;function eI(e,t){for(let n=e;typeof n=="function";n=Object.getPrototypeOf(n))if(Hl(n,t))return!0;return!1}function tI(e,t,n){Ja.get(e)!==t&&Ja.set(e,t)}function nI(e,t){if(eI(t,e))return;const n=typeof t=="function"?t.name||"anonymous":typeof t;if(Id.has(e)){tI(e,t,n);return}}function rI(e){const t=ZS.map(n=>e.on(n,r=>nI(n,r)));return{dispose:()=>t.forEach(n=>n.dispose())}}var Qa=new WeakMap,Za=new WeakSet;function oI(e,t,n){const r=e.getInstance(Y);if(r?.isDisposed()){Ae("ui",()=>Er(e).disposeAll()),Ae("commands",()=>je(e).disposeAll());return}Qa.get(e)?.dispose();const o=new ve([QS(e,t),rI(n)]);Qa.set(e,o),r?.addDisposable(o),r&&!Za.has(e)&&(Za.add(e),r.addDisposable(JS(e)))}function iI(e){return e?.lockEditor===!0}var ec={text:"text",img:"image",a:"link",button:"button",div:"container",vindent:"spacer",video:"video",table:"table",customTable:"table",structure:"row",column:"column",td:"cell",var:"variable",countdown:"countdown",carousel:"carousel",accordion:"accordion",social:"social",floatBlock:"floatingBlock"};function sI(e){return typeof e=="string"&&Object.hasOwn(ec,e)&&ec[e]||"none"}function an(e,t,n){let r,o;const i=()=>{const s=e.getInstance(t);return s===void 0||r?r!==void 0:(r=n(s),!0)};return i()||(o=e.onInject(s=>{s===t&&i()&&o?.dispose()})),{dispose:()=>{o?.dispose(),r?.dispose()}}}function aI(e){const t=$t(e),n={editor:!1,document:!1},r=()=>Wt(t,{readOnly:n.editor||n.document});r();const o=[Ci(e).watch(i=>Wt(t,{headless:i})),Ar(e).watch(({isCodeMode:i})=>Wt(t,{codeMode:i})),an(e,ge,i=>i.watch(s=>{n.editor=iI(s),r()})),an(e,jt,i=>{let s,a;const c=()=>{const m=i.sessionKey(),_=m!==void 0&&!ee(m)?i.current()?.get().attributes:void 0;n.document=_?.lock===!0&&!jc(e,_),r()},l=()=>{const m=i.sessionKey();Wt(t,{documentOpen:m!==void 0,documentKind:m===void 0?void 0:ee(m)?"block":"email"});const _=i.current();_!==s&&(a?.(),s=_,a=_?.subscribe(c)),c()};l();const u=i.subscribe(l),d=Ep(e,c);return{dispose:()=>{u(),a?.(),d.dispose()}}})];return o.push(an(e,Ic,i=>{const s=()=>{const l=i.getState(),u=Ce(t)?.documentKind==="block"?l.blockSlice:l.emailSlice;Wt(t,{selection:sI(u?.elementSettings?.type)})};s();const a=t.select(l=>l?.documentKind).watch(s),c=i.subscribe(s);return{dispose:()=>{c(),a.dispose()}}})),{dispose:()=>o.forEach(i=>i.dispose())}}var cI=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],lI=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],lr=new Map([...cI.map(e=>[e,"event"]),...lI.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),uI=new Map([["use","use `useAsync()` or await `ready` first"]]);function dI(e){return uI.get(e)??"await `ready` first"}var fI=new Set(["async","queued"]),pI=Symbol.for("emailmaker.earlyCtxPlaceholder");function tc(e){return e[pI]=!0,e}function hI(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${dI(e)}).`)}function mI(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function gI(e){return[...lr].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function vI(e,t){for(const n of gI(e)){const r=lr.get(n);if(r!==void 0&&fI.has(r)){const o=async(...i)=>{await t;const s=e[n];if(typeof s!="function"||s===o)throw mI(n);return s.apply(e,i)};e[n]=tc(o);continue}e[n]=tc(()=>{throw hI(n)})}}function bI(e,t,n){e.getInstanceAsync(Dt).then(()=>{vn(e,H.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function _I(e,t){e.getInstanceAsync(Dt).then(()=>{vn(e,H.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var yI=Bt(e=>{let t;function n(){return new Promise(o=>{const i=e.getOrCreateInstance(li,()=>new Set),s=()=>{i.delete(s),o()};i.add(s)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const i=e.getInstance(bn),s=e.getInstance(Sd);if(!t){t=new Jf(i,s,{ensureHostRuntimeReady:qS,explainScriptFailure:WS,openEarlyWindow:()=>$w(e),reportLoadFailure:l=>_I(e,l)}),e.inject(ci,t),oI(e,t,s);const c=t.onLifecycle(l=>{l.type==="create:error"&&bI(e,l.name,l.error)});e.getInstance(Y)?.addDisposable(c),e.getInstance(Y)?.addDisposable(aI(e))}const a=o?.plugins||[];i&&(Ci(e),a.length>0&&vI(i,n()),await t.setPlugins(a))},instance:{use(o){return typeof o=="function"?r().useByCtor(o):r().useByKey(o)},useAsync(o){return r().useAsync(o)},waitPlugin(o){return r().waitFor(o)}},dispose(){t?.dispose(),t=void 0}}}),EI=class{_context;constructor(e){this._context=e}tools(){return xn(this._context.container).tools()}invoke(e,t,n){return xn(this._context.container).invoke(e,t,n)}turn(e){return xn(this._context.container).turn(e)}undoTurn(){return xn(this._context.container).undoTurn()}},Td=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const o=this._listeners.indexOf(r);o>=0&&this._listeners.splice(o,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},wI=U("ELEMENT_INSERT_HTML_PIPELINE"),SI=U("BLOCK_INSERT_HTML_PIPELINE"),II="application_block_inserted",TI=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(SI,()=>new Td).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(yn,()=>new _n),o=n?e.bind(n):e;return r.addListener(II,o,t)}},AI=class{_context;constructor(e){this._context=e}register(e,t){const n=this._context.container,r=mt(n).current(),o={},i={};for(const[s,a]of Object.entries(e)){const{run:c,...l}=a;if(typeof c!="function")throw new Error(`Command "${s}" of "${r.name}" has no \`run\`; declare it with defineCommand({ title, run }).`);o[s]=l,i[s]=c}return je(n).register(r,o,i,t)}run(e,...t){return je(this._context.container).run(e,t[0],{caller:"plugin"})}has(e){return je(this._context.container).has(e)}},CI=class{_context;constructor(e){this._context=e}onWillSave(e){const t=this._context.container;return Ye(t).onWillSave(mt(t).current(),e)}onDidChange(e){const t=this._context.container;return Ye(t).onDidChange(mt(t).current(),e)}get selection(){return Ye(this._context.container).selection}transaction(e){return Ti(this._context.container).group(e)}},Wi=U("ComponentRegistry"),RI=U("ComponentRegistryGate");function zi(){return xt.getOrCreateInstance(RI,()=>({pending:[]}))}function OI(e=Wi){return zi().factory!==void 0||xt.getInstance(e)!==void 0}function Xo(e,t,n=Wi){if(OI(n)){t(ur(e,n));return}zi().pending.push(()=>t(ur(e,n)))}function ur(e,t=Wi){const n=xt.getInstance(t);if(n)return n;const r=zi().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return xt.getOrCreateInstance(t,r)}var kI=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=i=>{if(!n){n=!0;for(const s of t)s.dispose();e(i)}};t.push(this._container.addService(Rn,{execute:i=>{r(i.value.map(s=>({name:s.name,html:s.html})))}}));const o=this._container.getInstance(Kd)?.watch(i=>{i&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(Rn,{execute:r=>{const o=ur(n),i=r.value.find(s=>s.name===e);if(i){const{icon:s,title:a,fallbackTooltip:c,...l}=t;s&&(i.icon=o.getReactNode(s)),a&&(i.title=o.getReactNode(a)),c&&(i.fallbackTooltip=o.getReactNode(c)),Object.assign(i,l)}}})}delete(e){this._container.addService(Rn,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService(Rn,{execute:r=>{const o=ur(n);r.value.splice(t??r.value.length,0,{...e,title:o.getReactNode(e.title),icon:o.getReactNode(e.icon),fallbackTooltip:o.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(wI,()=>new Td).add(e,t??0,n)}handleInject(e,t,n){return Ot(this._container,hf).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},PI=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(yn,()=>new _n)}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 DI(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function nc(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var xI=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ot(t,Of),this._closeModalEmitter=Ot(t,Ff),this._updateModalEmitter=Ot(t,Lf)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Xo(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:nc(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Xo(this._container,r=>{const o=i=>i===void 0?void 0:r.getReactNode(i);this._updateModalEmitter.fire(DI({...t,content:o(t.content),title:o(t.title),id:e,modalProps:nc(r,n)}))})}};function Gn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var MI=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=o=>{this._loadedSettled||(this._loadedSettled=!0,r(o))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=o=>{this._readySettled||(this._readySettled=!0,r(o))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},LI=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(yn,()=>new _n)}_createScriptHandle(e,t){const n=this._messageService.addListener(ai,o=>{if(o.key===e){if(o.phase==="load"&&o.status==="success"){r.resolveLoaded();return}if(o.phase==="ready"&&o.status==="success"){r.resolveReady();return}if(o.phase==="load"){r.rejectLoad(new Error(o.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(o.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new MI(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(Tt,{...Gn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(Tt,{...Gn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(Tt,{...Gn(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(Tt,{...Gn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},NI=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Jo(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&NI.has(t)}function Ad(){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 oo(){return`__settingsPanel:${Ad()}`}function io(e,t){return{type:e,props:t}}function FI(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Jo(e)}function rc(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Jo(t)){const r=oo();return n(e.add(r,t)),io(r,{})}if(typeof t=="function"){const r=oo();return n(e.add(r,t)),io(r,{})}if(FI(t)){const r=t.type;if(typeof r=="string")return t;if(Jo(r)||typeof r=="function"){const o=oo();return n(e.add(o,r)),io(o,t.props)}return t}return t}var BI=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??Ad();Xo(this._container,n=>{const r=s=>this._trackRegistration(s),o=rc(n,e.content,r),i=e.advancedTabs?.map(s=>({...s,content:rc(n,s.content,r)}));Ot(this._container,es).fire({...e,content:o,advancedTabs:i,instanceKey:t,type:_f})})}closeSettingsPanel(){this._clearPanelRegistrations(),Ot(this._container,es).fire(null)}},jI=class{_context;constructor(e){this._context=e}get apiVersion(){return this._service().apiVersion}supports(e,t){return this._service().supports(e,t)}addViews(e,t){return this._service().addViews(this._owner(),e,t,this._context)}addItem(e){return this._service().addItem(this._owner(),e)}open(e,...t){return this._service().open(e,t[0])}_service(){return Er(this._context.container)}_owner(){return mt(this._context.container).current()}},Cd=Ii({SandboxScriptApi:LI,ElementsApi:kI,BlocksApi:TI,MessageService:PI,SettingsPanelApi:BI,ModalApi:xI,Commands:AI,Ui:jI,Agent:EI,Document:CI});function so(e,t,n,r={}){const o=Object.assign({},e);for(const[i,s]of Object.entries(t))if(s!==void 0)if(n.includes(i)&&typeof s=="object"&&s!==null){const a=o[i],c=r[i]??{};o[i]=Object.assign({},typeof a=="object"&&a!==null?a:c,s)}else o[i]=s;return o}var Le={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}},UI={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"},ao={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},oc={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},yt={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:Le.border,borderRadius:Le.borderRadius,textAlign:"center",padding:Le.padding},ic={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Le.padding},co={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Le.border,borderRadius:Le.borderRadiusCards};function $I(e){return{...UI,...e}}function HI(e){return{...ao,...e,bold:e?.bold??ao.bold,italic:e?.italic??ao.italic}}function VI(e){return{...oc,...e,underline:e?.underline??oc.underline}}function GI(e){return{...yt,...e,bold:e?.bold??yt.bold,italic:e?.italic??yt.italic,border:{...yt.border,...e?.border},borderRadius:{...yt.borderRadius,...e?.borderRadius},padding:{...yt.padding,...e?.padding}}}function qI(e){return{...ic,...e,padding:{...ic.padding,...e?.padding}}}function WI(e){return{...co,...e,border:{...co.border,...e?.border},borderRadius:{...co.borderRadius,...e?.borderRadius}}}function lo(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 sc(e){let t={...ii};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function uo(e){return{text:$I(e.text),headings:HI(e.headings),links:VI(e.links),buttons:GI(e.buttons),block:qI(e.block),cards:WI(e.cards)}}var Qo=U("EmailSettingsPort");function zI(e){return e?.getInstance(Qo)}var KI=1e4,Rd=class{_editor;_layoutSettingsChanged=new go;_contentStylesChanged=new go;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!ad(this._editor.container)||!At(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(Qo);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return lo(this._settings().read())}_getCurrentContentStyles(){const e=At(this._editor.container)?.current()?.get().attributes.common_styles;return uo(sc(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(Qo),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(yn,()=>new _n),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const o=r?.data,i=o?.operation;if(i===K.APPLICATION_EMAIL_SETTINGS_SET){const c=lo(o?.settings),l=this._getLayoutSnapshot(c);l!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=l,this._layoutSettingsChanged.fire(c));return}if(i!==K.APPLICATION_COMMON_STYLES_UPDATE)return;const s=uo(r.data?.settings?.commonStyles??{...ii}),a=this._getContentSnapshot(s);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=lo(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=KI){const t=At(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,o=Pe(r,H.ON_EMAIL_INIT_ID);return new Promise(i=>{let s=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},l=o(()=>{s||(s=!0,c(),l.dispose(),i())});a=setTimeout(()=>{s||(s=!0,l.dispose(),i())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=At(this._editor.container)?.current();if(!t)return;const n=sc(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=so(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Le.border,borderRadius:Le.borderRadius,padding:Le.padding})),e.block!==void 0&&(n.block=so(n.block||{},e.block,["padding"],{padding:Le.padding})),e.cards!==void 0&&(n.cards=so(n.cards||{},e.cards,["border","borderRadius"],{border:Le.border,borderRadius:Le.borderRadiusCards}));const r=JSON.stringify(n);Mt(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=uo(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},YI={...Cd,...Ii({EmailSettingsApi:Rd})};function XI(e){const t=e;return Id.has(e)&&Yo.has(t)&&!Hl(Yo.get(t),e)}function JI(e){Yo.addAll(Object.fromEntries(Object.entries(e).filter(([t])=>!XI(t))))}var QI={...Cd},h0={...QI,...Ii({EmailSettingsApi:Rd})},ZI={...YI};function eT(){JI(ZI)}var tT=[Bt(()=>{eT()}),kS,$S,OS,If,CS,Mf];async function nT(){return(await Cn()).asyncMixins}var rT=yI,oT=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await nT()}catch(s){throw e.failPendingWaits(s),s}t=o(e);const i=await e.getInstanceAsync(bn);Object.assign(i,t.instance||{});for(const s of e.getInstance(li)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},iT=kf([...tT]);function fo(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const i of r.values())i();r.clear()}return{event(i,s,a){const c=Symbol("subscription");return t||(n.set(c,{listener:i,priority:s,thisArg:a}),e&&r.set(c,e(i,s,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(i){o(),e=i;for(const[s,{listener:a,priority:c,thisArg:l}]of n)r.set(s,i(a,c,l))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function sT(e){const t=fo(),n=fo(),r=fo();return e.getInstance(Y)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Dt).then(o=>{t.attach(o.onNotify),n.attach(o.onError),r.attach(o.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(o){const i=e.getInstance(Dt);if(i){i.notify(o);return}e.getInstanceAsync(Dt).then(s=>s.notify(o),()=>{})}}}var Od=U("CodeErrors"),aT=[];function cT(e){return e?.getInstance(Od)?.get()??aT}function lT(e){return e?.getInstance(Od)!==void 0}function uT(e){const t=zl(e);let n;const r=()=>{const i=e.getInstance(ge);return i&&!n&&(n=i.watch(s=>t.set(s?.agent??{}))),n!==void 0},o=r()?void 0:e.onInject(i=>{i===ge&&r()&&o?.dispose()});return{dispose:()=>{o?.dispose(),n?.dispose()}}}function dT(e){const t=Ye(e);return an(e,jt,n=>{let r,o;const i=()=>{const c=n.sessionKey();c!==void 0&&t.emitChange({kind:ee(c)?"block":"email"})},s=()=>{const c=n.current();c!==r&&(o?.(),r=c,o=c?.subscribe(i),c&&i())};s();const a=n.subscribe(s);return{dispose:()=>{a(),o?.()}}})}function fT(e,t){if(e===t)return!0;try{return Ne(JSON.parse(e||"{}"),JSON.parse(t||"{}"))}catch{return!1}}var m0=U("planFeatures.source");function po(e){return Re(e)?.current()}function pT(e){return Ce($t(e))?.readOnly===!0}var hT=()=>ue("readOnly","The document is read-only.");function mT(e,t){return!1}var gT=e=>ue("lockedByPlan",e);function vT(e,t,n){return mT(e,t)?gT(`Working with ${n} is not available on the current plan.`):void 0}function bT(e){return vT(e,"undo_redo","undo and redo")}var _T=wf+Pf;function kd(e){const t=fe(e);return t.isInited()&&!!t.getTarget()}async function yT(e,t){const n=fe(e);if(!kd(e))return ue("unavailable","The canvas is not open.");try{const r=await hu(n.sendAsync(K.SANDBOX_ELEMENT_OPERATION,t),_T,"sandbox:element");if(!r)return ue("unavailable","The canvas does not support element commands.");if(r.ok)return pt(r.value);const o=r;return ue(o.code,o.message)}catch(r){if(r instanceof pu)return ue("unavailable","The canvas did not answer in time.");throw r}}var Pd=["subject","preheader","title","utm_parameters","common_styles","meta"],ET={id:0,below:0},ac=()=>({code:"nothingToUndo",message:"The last answer changed nothing that could be undone."}),Et=e=>({code:"undoConflict",message:e});function wT(e,t,n){return e==="common_styles"?fT(t,n??""):Ne(t,n)}function cc(e,t){return Object.fromEntries(Pd.filter(n=>!wT(n,e[n],t[n])).map(n=>[n,e[n]]))}function ST(e){const t=()=>{const n=po(e);if(!n)return;const{docId:r,attributes:o}=n.get();return{docId:r,step:Re(e)?.history()?.currentStep()??ET,fields:Object.fromEntries(Pd.map(i=>[i,o[i]]))}};return{document:()=>po(e)?.get().docId,capture:t,undoRefusal:()=>bT(e)?.error,settle:async()=>{if(kd(e))return(await yT(e,{op:"settle"})).ok?void 0:Et("The canvas did not answer, so edits made after the answer cannot be ruled out.")},undo:(n,r)=>{const o=n,i=r;if(!o)return ac();if(i?.docId!==o.docId)return Et("The answer ended on another email.");const s=i.step.id!==o.step.id,a=cc(o.fields,i.fields);if(!s&&Object.keys(a).length===0)return ac();const c=po(e),l=t();if(!c||l?.docId!==i.docId)return Et("Another email is open now, not the one the answer changed.");if(pT(e))return hT().error;if(l.step.id!==i.step.id||Object.keys(cc(l.fields,i.fields)).length>0)return Et("The email was edited after the answer.");if(s&&i.step.below!==o.step.id)return Et("The answer moved through the undo history itself and cannot be taken back as one step.");if(s&&!Re(e)?.history()?.tryUndo())return Et("The step of the answer could not be undone: the text changed under it.");Object.keys(a).length>0&&(c.mutate({attributes:a},{source:"user"}),zI(e)?.markAppearanceChanged())}}}function IT(e){let t;return Ti(e).connect({begin:()=>{t??=Re(e)?.history()?.beginTransaction()},end:()=>{const n=t;t=void 0,n?.()},answers:ST(e)})}function TT(e){const t=Ye(e).selection,n=fe(e),r=()=>t.set(null),o=n.addListener(a=>{const c=a?.data;c?.operation===K.APPLICATION_ELEMENT_SETTINGS_SET?t.set(c.type&&typeof c.elementRef=="string"?c.elementRef:null):c?.operation===K.APPLICATION_ELEMENT_SETTINGS_CLOSE&&r()}),i=un(n,r),s=an(e,jt,a=>{let c=a.current();return{dispose:a.subscribe(()=>{a.current()!==c&&(c=a.current(),r())})}});return{dispose:()=>{o.dispose(),i(),s.dispose()}}}function AT(e){const t=[uT(e),IT(e),dT(e),TT(e)];return{dispose:()=>t.forEach(n=>n.dispose())}}var CT="SAVE",RT="SAVE_BLOCK",g0="SET_THEME",v0="NOTIFY",b0="SET_CONFIG",_0="UPDATE_CONFIG",Dd=class extends ve{_options;_listeners=[];constructor(e){super(),this._options=e}fire=e=>{if(!this.isDisposed()){let t;const n=[...this._listeners];for(const r of n){if(t===!1)return!1;t instanceof Promise?t=t.then(o=>o===!1||this.isDisposed()?!1:r(o)).catch(o=>{}):t=r(e)}return t}};addEventListener=e=>{const t=this._listeners,n=this._options;return t.push(e),t.length===1&&this._options?.onFirstListenerAdd&&this._options.onFirstListenerAdd(),{dispose:()=>{const r=t.indexOf(e);r>=0&&(t.splice(r,1),t.length||n?.onFirstListenerAdd&&n.onLastListenerRemove())}}};event=this.addEventListener},lc;(function(e){function t(o){let i;const s=new Dd({onFirstListenerAdd(){i=o(s.fire)},onLastListenerRemove(){i.dispose()}});return s.event}e.snapshot=t;function n(o,i){return t(s=>o(a=>i(a)&&s(a)))}e.filter=n;function r(o,i){return t(s=>o(a=>s(i(a))))}e.map=r})(lc||(lc={}));var OT=U("helpers.commandEmitter");function kT(e,t,n){e instanceof xf||(e=Xd(e)),e.getOrCreateInstance(OT,()=>new Dd).fire({id:t,payload:n})}function PT(e,t,{yieldable:n=!1,details:r,prepare:o}={}){const i=je(e),s=new Map,a=new Set,c=i.commands.watch(()=>{i.disposed||Object.entries(t).forEach(([l,{declaration:u,handler:d}])=>{const m=i.info(l)?.owner;m?n&&m!==ht&&!a.has(l)&&(a.add(l),`${l}${m.name}`,void 0):(a.delete(l),s.set(l,i.register(ht,{[l]:u},{[l]:d},{},{yieldable:n,details:r,prepare:o})))})});return{dispose:()=>{c.dispose(),s.forEach(l=>l.dispose())}}}var Ki="document.getSnapshot",DT="document.save",xd=Symbol.for("emailmaker.legacyEmailSnapshot"),Zo=Symbol.for("emailmaker.legacyEmailSnapshotError");function xT(e,t){return Object.defineProperty(e,xd,{value:t})}function MT(e){return xT({kind:"email",id:e.id==null?null:String(e.id),content:e.code??"",subject:e.subject??"",preheader:e.preheader??""},e)}function LT(e){return{kind:"block",id:e.id==null?null:String(e.id),content:e.code??"",subject:"",preheader:""}}function NT(e,t){return PT(e,{[Ki]:{declaration:{title:"Get document snapshot",description:"Returns the open document: kind, id, HTML content, subject and preheader.",agent:{readOnly:!0}},handler:async()=>{try{const n=Re(e),r=ee(n?.sessionKey())?await t.getBlockSnapshot():null;return pt(r?LT(r):MT(await t.readEmailSnapshot()))}catch(n){return Object.defineProperty(ue("internal",n instanceof Error?n.message:String(n)),Zo,{value:n})}}},[DT]:{declaration:{title:"Save document",description:"Saves the open document and finishes when the save is done. A save refused by a rule (a plugin check, empty content, too many tags, edits still on their way, the host cancelled it) answers `refused`, and its message names the reason: tell the user.",agent:!0},handler:(n,r)=>$T(e,r.caller)}})}async function FT(e,t){const n=await je(e).run(Ki,void 0,{caller:"plugin"});if(n.ok===!1){if(Zo in n)throw n[Zo];return t()}return n.value[xd]}function BT(e){return je(e).info(Ki)?.owner===ht}var jT="The host cancelled this save, so nothing was saved. Tell the user; do not repeat the call unless the user asks for it again.";async function UT(e,t,n){const r=await new Promise(a=>{kT(e,t,{source:Ag,settle:a})});if(r.ok!==!1)return pt();if(r.reason==="unready")return;const o=n==="agent"?r.refusal??(r.reason==="aborted"?jT:void 0):void 0,i=r.reason==="locked"?"readOnly":r.reason==="aborted"?"aborted":"internal",s=o?ue("refused",o):ue(i,r.message);return r.notified?Object.defineProperty(s,Rg,{value:!0}):s}async function $T(e,t){if(Ce($t(e))?.readOnly)return ue("readOnly","The editor is read-only.");const n=Re(e)?.sessionKey();if(n!==void 0){const o=ee(n);if(kg(e,o?"block":"email")){const i=await UT(e,o?RT:CT,t);if(i)return i}}const r=e.getInstance(bn);if(n===void 0||!r)return ue("unavailable","There is no open document to save.");try{return await(ee(n)?r.saveBlock():r.save()),pt()}catch(o){if(o instanceof He&&o.reason==="locked")return ue("readOnly",o.message);const i=t==="agent"?ch(o):void 0;return i?ue("refused",i):ue("internal",o instanceof Error?o.message:String(o))}}var HT=class extends ve{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=An(e),this.addDisposable(Pe(e,H.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t})),this.addDisposable(NT(e,this)),this.addDisposable(AT(e))}openEmail(){const e=Re(this._container);if(e&&ee(e.sessionKey())&&!e.hasSuspended())throw new Error("[useblocks] no open email: only a block is shown");return Xu(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>Se(t,this._container))}async _readProjectBlocks(){const e=await Ju(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>Jt(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>Ho(n,this._container))}async getEmailSnapshot(){return ee(Re(this._container)?.sessionKey())||!BT(this._container)?this.readEmailSnapshot():FT(this._container,()=>this.readEmailSnapshot())}async readEmailSnapshot(){return Oe(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Re(this._container),t=e?.current();return!e||!t||!ee(e.sessionKey())?null:(await t.whenReady(),Se(Tr(t),this._container))}setEmailMeta(e){const t=ji(this._container);if(!t)return;const n=t.get().attributes.meta;Mt(t,{meta:Bn({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&Bn(o,e))}setBlockMeta(e,t){const n=Re(this._container);if(n?.sessionKey()===er(e)){const o=n.current();o&&Mt(o,{meta:Bn({meta:o.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,i=>i&&Bn(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return lT(this._container)?cT(this._container):void 0}},VT=U("EmailDataController");function GT(e){return e.getOrCreateInstance(VT,()=>{const t=new HT(e);return e.getInstance(Y)?.addDisposable(t),t})}function qT(e){const t=GT(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function WT(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function zT(e){let t;const n=Fu(e),r=Pe(e,H.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:i})=>{t=i}));const o=()=>t?WT(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:i=>o()?.getPast(i)??[],getFuture:i=>o()?.getFuture(i)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:i=>o()?.restoreSnapshot(i)}}}var KT=U("plugin.mountElement");function YT(e){const t=e.getInstance(we)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function XT(e){return e.getOrCreateInstance(KT,()=>{let t=!1,n;return{get:()=>t?n:YT(e),set(r){t=!0,n=r}}})}function JT(e){const t=XT(e);return{getElement:()=>t.get()}}function QT(e){return{handleLoadImage:V(Pe(e,H.UPLOAD_EVENT_ID)),handleFileProxy:V(Pe(e,H.FILE_PROXY_EVENT_ID)),handleUrlProxy:V(Pe(e,H.PROXY_URL_EVENT_ID)),handleAITextRequest:V(Pe(e,H.AI_TEXT_REQUEST_ID)),handleAIImageRequest:V(Pe(e,H.AI_IMAGE_REQUEST_ID)),handleReadLocale:V(Pe(e,H.READ_LOCALE)),handleLimitUsage:V(Pe(e,H.ON_LIMIT_ID)),handleTranslate:V(Pe(e,H.ON_TRANSLATE_ID))}}var ZT=[ly,Xw,sT,US,qT,zT,JT,QT];function eA(e,t=ZT){const n=Gi(e);IS(e);const r=iT(e),o=rT(e),i=oT(e),s={...r.instance,...o.instance,...i.instance};for(const c of t)Object.assign(s,c(e));let a=!0;return{instance:s,async setOptions(c){await r.setOptions(c);const l=a&&n.get()===c;a=!1,l||n.set(c),await o.setOptions(c),await i.setOptions(c)}}}function tA(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var nA=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]}},rA="editor-runtime.react.copies",ho=8;function pn(e){return e&&typeof e=="object"?e:void 0}function uc(e){const t=pn(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=pn(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function oA(e){const t=pn(e),n=t&&typeof t.version=="string"?t.version:void 0,r=pn(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function iA(e,t,n){return e.package===t&&e.version===n}function sA({ourReact:e,entries:t,packageName:n,version:r}){const o=uc(e);if(!o||!Array.isArray(t))return[];const i=[],s=new Set;for(const a of t){const c=pn(a);if(!c||!iA(c,n,r))continue;const l=uc(c.react);!l||l===o||s.has(l)||(s.add(l),i.push({package:n,version:r,reactVersion:oA(c.react),react:c.react}))}return i}function aA({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,ho))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>ho&&n.push(` …and ${t.length-ho} 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(`
1062
- `)}var dc=new Set;function cA({packageName:e="useblocks",version:t="1.3.11-dev.3",log:n=r=>{}}={}){const r=o=>{try{const i=globalThis[Symbol.for(rA)],s=sA({ourReact:o,entries:i,packageName:e,version:t}).filter(a=>!dc.has(a.react));if(!s.length)return;s.forEach(a=>dc.add(a.react)),n(aA({packageName:e,copies:s}))}catch{}};try{const o=fi()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function lA(e,t,n){se(e.signal);const r=t??xt.createChild();Gi(r);const o=r.getInstance(Y);let i;async function s(){r.inject(Tc,tA(new nA)),cA();const a=eA(r),c={...a.instance,container:r,get ready(){return i??Promise.resolve(c)},async reset(l){if(se(l.signal),o.isDisposed())throw Ke();return await a.setOptions(l),c}};r.inject(bn,c);try{if(n?.onInstance?.(c),await a.setOptions(e),se(e.signal),o.isDisposed()||await zw(r),e.devTools)try{const l=r.getInstance(ci);l&&await(await Cn()).initDevTools(r,l)}catch{}return se(e.signal),vn(r,Oc).fire(c),c}catch(l){throw o.dispose(),l}}try{return i=Qn(s(),e.signal),i.catch(()=>{}),await i}catch(a){throw o.isDisposed()||o.dispose(),a}}var hn=new WeakMap;function uA(e){return e?hn.get(e):void 0}function Md(e){try{e.getInstance(Y)?.dispose()}catch{}try{e.dispose()}catch{}}function dA(e,t){if(!e)return;const n=hn.get(e);n&&n!==t&&Md(n),hn.set(e,t)}function fA(e,t){e&&hn.get(e)===t&&hn.delete(e)}function pA(e){const t=xt.createChild();return Sn(e)&&t.inject(Ve,Cr(e)),t}var cn=new WeakMap,hA="data-useblocks-config-styles";function mA(e){return typeof e=="string"?e.trim():""}function fc(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function gA(e,t,n){if(!e||typeof document>"u")return null;const r=mA(t),o=cn.get(e),i=n||e;if(!r)return o&&(o.remove(),cn.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==i||o!==i.firstChild)&&fc(i,o),o;const s=document.createElement("style");return s.setAttribute(hA,"true"),s.textContent=r,fc(i,s),cn.set(e,s),s}function vA(e){if(!e)return;const t=cn.get(e);t&&(t.remove(),cn.delete(e))}function Ld(){return!1}var bA=`
1061
+ `)}function sc(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function jS(e,t,n,r){const o=US(e,t,n,r);return o===void 0}function US(e,t,n,r){if(Wr(t))return"block";const{email:o}=zr(t,!1),s=Vt(o,e),i=s.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const a=Re(e)?.current();if(!a)return"no-session";const c=a.get(),l=c.attributes;if(c.serverId!==i)return"document-id";if(l.is_inited!==!0)return"not-inited";const u=sc(os(n??a.getContent()));if(s.html!==void 0&&sc(os(s.html))!==u)return"html";if(s.subject!==void 0&&s.subject!==l.subject)return"subject";if(s.preheader!==void 0&&s.preheader!==l.preheader)return"preheader";if(s.common_styles!==void 0&&s.common_styles!==l.common_styles)return"common_styles"}function ic(e,t){if(Wr(t))return;const{email:n}=zr(t,!1),r=Vt(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:os(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function $S(e){return Array.isArray(e)?e.some(t=>$o(t)):$o(e)}function HS(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])$S(t[n])&&delete t[n];return t}function VS(e,t){const n={...e};return delete n.id,{...n,...t}}function GS(e,t){var n=0,r,o;t=t||{};function s(){var i=r,a=arguments.length,c,l;e:for(;i;){if(i.args.length!==arguments.length){i=i.next;continue}for(l=0;l<a;l++)if(i.args[l]!==arguments[l]){i=i.next;continue e}return i!==r&&(i===o&&(o=i.prev),i.prev.next=i.next,i.next&&(i.next.prev=i.prev),i.next=r,i.prev=null,r.prev=i,r=i),i.val}for(c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];return i={args:c,val:e.apply(null,c)},r?(r.prev=i,i.next=r):o=i,n===t.maxSize?(o=o.prev,o.next=null):n++,r=i,i.val}return s.clear=function(){r=null,o=null,n=0},s}var qS=op((e=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(a){return o(i(a),arguments)}function r(a,c){return n.apply(null,[a].concat(c||[]))}function o(a,c){for(var l=1,u=a.length,d,f="",v=0,g,y,E,P,O,x,w;v<u;v++)if(typeof a[v]=="string")f+=a[v];else if(typeof a[v]=="object"){if(y=a[v],y.keys)for(d=c[l],g=0;g<y.keys.length;g++){if(d==null)throw new Error(n('[sprintf] Cannot access property "%s" of undefined value "%s"',y.keys[g],y.keys[g-1]));d=d[y.keys[g]]}else y.param_no?d=c[y.param_no]:d=c[l++];if(t.not_type.test(y.type)&&t.not_primitive.test(y.type)&&d instanceof Function&&(d=d()),t.numeric_arg.test(y.type)&&typeof d!="number"&&isNaN(d))throw new TypeError(n("[sprintf] expecting number but found %T",d));switch(t.number.test(y.type)&&(x=d>=0),y.type){case"b":d=parseInt(d,10).toString(2);break;case"c":d=String.fromCharCode(parseInt(d,10));break;case"d":case"i":d=parseInt(d,10);break;case"j":d=JSON.stringify(d,null,y.width?parseInt(y.width):0);break;case"e":d=y.precision?parseFloat(d).toExponential(y.precision):parseFloat(d).toExponential();break;case"f":d=y.precision?parseFloat(d).toFixed(y.precision):parseFloat(d);break;case"g":d=y.precision?String(Number(d.toPrecision(y.precision))):parseFloat(d);break;case"o":d=(parseInt(d,10)>>>0).toString(8);break;case"s":d=String(d),d=y.precision?d.substring(0,y.precision):d;break;case"t":d=String(!!d),d=y.precision?d.substring(0,y.precision):d;break;case"T":d=Object.prototype.toString.call(d).slice(8,-1).toLowerCase(),d=y.precision?d.substring(0,y.precision):d;break;case"u":d=parseInt(d,10)>>>0;break;case"v":d=d.valueOf(),d=y.precision?d.substring(0,y.precision):d;break;case"x":d=(parseInt(d,10)>>>0).toString(16);break;case"X":d=(parseInt(d,10)>>>0).toString(16).toUpperCase()}t.json.test(y.type)?f+=d:(t.number.test(y.type)&&(!x||y.sign)?(w=x?"+":"-",d=d.toString().replace(t.sign,"")):w="",P=y.pad_char?y.pad_char==="0"?"0":y.pad_char.charAt(1):" ",O=y.width-(w+d).length,E=y.width&&O>0?P.repeat(O):"",f+=y.align?w+d+E:P==="0"?w+E+d:E+w+d)}return f}var s=Object.create(null);function i(a){if(s[a])return s[a];for(var c=a,l,u=[],d=0;c;){if((l=t.text.exec(c))!==null)u.push(l[0]);else if((l=t.modulo.exec(c))!==null)u.push("%");else if((l=t.placeholder.exec(c))!==null){if(l[2]){d|=1;var f=[],v=l[2],g=[];if((g=t.key.exec(v))!==null)for(f.push(g[1]);(v=v.substring(g[0].length))!=="";)if((g=t.key_access.exec(v))!==null)f.push(g[1]);else if((g=t.index_access.exec(v))!==null)f.push(g[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=f}else d|=2;if(d===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");u.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");c=c.substring(l[0].length)}return s[a]=u}typeof e<"u"&&(e.sprintf=n,e.vsprintf=r),typeof window<"u"&&(window.sprintf=n,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()})),V0=dl(qS()),G0=GS(console.error),ac={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},WS=["(","?"],er={")":["("],":":["?","?:"]},zS=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;function KS(e){for(var t=[],n=[],r,o,s,i;r=e.match(zS);){for(o=r[0],s=e.substr(0,r.index).trim(),s&&t.push(s);i=n.pop();){if(er[o]){if(er[o][0]===i){o=er[o][1]||o;break}}else if(WS.indexOf(i)>=0||ac[i]<ac[o]){n.push(i);break}t.push(i)}er[o]||n.push(o),e=e.substr(r.index+o.length)}return e=e.trim(),e&&t.push(e),t.concat(n.reverse())}var XS={"!":function(e){return!e},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"<":function(e,t){return e<t},"<=":function(e,t){return e<=t},">":function(e,t){return e>t},">=":function(e,t){return e>=t},"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},"&&":function(e,t){return e&&t},"||":function(e,t){return e||t},"?:":function(e,t,n){if(e)throw t;return n}};function YS(e,t){for(var n=[],r=0,o,s,i,a,c;r<e.length;r++){if(a=e[r],i=XS[a],i){for(o=i.length,s=Array(o);o--;)s[o]=n.pop();try{c=i.apply(null,s)}catch(l){return l}}else t.hasOwnProperty(a)?c=t[a]:c=+a;n.push(c)}return n[0]}function JS(e){var t=KS(e);return function(n){return YS(t,n)}}function QS(e){var t=JS(e);return function(n){return+t({n})}}var cc={contextDelimiter:"",onMissingKey:null};function ZS(e){for(var t=e.split(";"),n=0,r;n<t.length;n++)if(r=t[n].trim(),r.indexOf("plural=")===0)return r.substr(7)}function di(e,t){var n;this.data=e,this.pluralForms={},this.options={};for(n in cc)this.options[n]=t!==void 0&&n in t?t[n]:cc[n]}di.prototype.getPluralForm=function(e,t){var n=this.pluralForms[e],r,o,s;return n||(r=this.data[e][""],s=r["Plural-Forms"]||r["plural-forms"]||r.plural_forms,typeof s!="function"&&(o=ZS(r["Plural-Forms"]||r["plural-forms"]||r.plural_forms),s=QS(o)),n=this.pluralForms[e]=s),n(t)};di.prototype.dcnpgettext=function(e,t,n,r,o){var s,i,a;return o===void 0?s=0:s=this.getPluralForm(e,o),i=n,t&&(i=t+this.options.contextDelimiter+n),a=this.data[e][i],a&&a[s]?a[s]:(this.options.onMissingKey&&this.options.onMissingKey(n,e),s===0?n:r)};var lc={"":{plural_forms(e){return e===1?0:1}}},eI=/^i18n\.(n?gettext|has_translation)(_|$)/,cf=(e,t,n)=>{const r=new di({}),o=new Set,s=()=>{o.forEach(w=>w())},i=w=>(o.add(w),()=>o.delete(w)),a=(w="default")=>r.data[w],c=(w,C="default")=>{r.data[C]={...r.data[C],...w},r.data[C][""]={...lc[""],...r.data[C]?.[""]},delete r.pluralForms[C]},l=(w,C)=>{c(w,C),s()},u=(w,C="default")=>{r.data[C]={...r.data[C],...w,"":{...lc[""],...r.data[C]?.[""],...w?.[""]}},delete r.pluralForms[C],s()},d=(w,C)=>{r.data={},r.pluralForms={},l(w,C)},f=(w="default",C,T,D,R)=>(r.data[w]||c(void 0,w),r.dcnpgettext(w,C,T,D,R)),v=(w="default")=>w,g=(w,C)=>{let T=f(C,void 0,w);return n?(T=n.applyFilters("i18n.gettext",T,w,C),n.applyFilters("i18n.gettext_"+v(C),T,w,C)):T},y=(w,C,T)=>{let D=f(T,C,w);return n?(D=n.applyFilters("i18n.gettext_with_context",D,w,C,T),n.applyFilters("i18n.gettext_with_context_"+v(T),D,w,C,T)):D},E=(w,C,T,D)=>{let R=f(D,void 0,w,C,T);return n?(R=n.applyFilters("i18n.ngettext",R,w,C,T,D),n.applyFilters("i18n.ngettext_"+v(D),R,w,C,T,D)):R},P=(w,C,T,D,R)=>{let m=f(R,D,w,C,T);return n?(m=n.applyFilters("i18n.ngettext_with_context",m,w,C,T,D,R),n.applyFilters("i18n.ngettext_with_context_"+v(R),m,w,C,T,D,R)):m},O=()=>y("ltr","text direction")==="rtl",x=(w,C,T)=>{const D=C?C+""+w:w;let R=!!r.data?.[T??"default"]?.[D];return n&&(R=n.applyFilters("i18n.has_translation",R,w,C,T),R=n.applyFilters("i18n.has_translation_"+v(T),R,w,C,T)),R};if(e&&l(e,t),n){const w=C=>{eI.test(C)&&s()};n.addAction("hookAdded","core/i18n",w),n.addAction("hookRemoved","core/i18n",w)}return{getLocaleData:a,setLocaleData:l,addLocaleData:u,resetLocaleData:d,subscribe:i,__:g,_x:y,_n:E,_nx:P,isRTL:O,hasTranslation:x}};function lf(e){return!(typeof e!="string"||e===""||!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e))}function fi(e){return!(typeof e!="string"||e===""||/^__/.test(e)||!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e))}function uc(e,t){return function(r,o,s,i=10){const a=e[t];if(!fi(r)||!lf(o)||typeof s!="function"||typeof i!="number")return;const c={callback:s,priority:i,namespace:o};if(a[r]){const l=a[r].handlers;let u;for(u=l.length;u>0&&!(i>=l[u-1].priority);u--);u===l.length?l[u]=c:l.splice(u,0,c),a.__current.forEach(d=>{d.name===r&&d.currentIndex>=u&&d.currentIndex++})}else a[r]={handlers:[c],runs:0};r!=="hookAdded"&&e.doAction("hookAdded",r,o,s,i)}}function tr(e,t,n=!1){return function(o,s){const i=e[t];if(!fi(o)||!n&&!lf(s))return;if(!i[o])return 0;let a=0;if(n)a=i[o].handlers.length,i[o]={runs:i[o].runs,handlers:[]};else{const c=i[o].handlers;for(let l=c.length-1;l>=0;l--)c[l].namespace===s&&(c.splice(l,1),a++,i.__current.forEach(u=>{u.name===o&&u.currentIndex>=l&&u.currentIndex--}))}return o!=="hookRemoved"&&e.doAction("hookRemoved",o,s),a}}function dc(e,t){return function(r,o){const s=e[t];return typeof o<"u"?r in s&&s[r].handlers.some(i=>i.namespace===o):r in s}}function fc(e,t,n=!1){return function(o,...s){const i=e[t];i[o]||(i[o]={handlers:[],runs:0}),i[o].runs++;const a=i[o].handlers;if(!a||!a.length)return n?s[0]:void 0;const c={name:o,currentIndex:0};for(i.__current.push(c);c.currentIndex<a.length;){const l=a[c.currentIndex].callback.apply(null,s);n&&(s[0]=l),c.currentIndex++}if(i.__current.pop(),n)return s[0]}}function pc(e,t){return function(){var r;const o=e[t];return(r=o.__current[o.__current.length-1]?.name)!==null&&r!==void 0?r:null}}function hc(e,t){return function(r){const o=e[t];return typeof r>"u"?typeof o.__current[0]<"u":o.__current[0]?r===o.__current[0].name:!1}}function mc(e,t){return function(r){const o=e[t];if(fi(r))return o[r]&&o[r].runs?o[r].runs:0}}var tI=class{constructor(){this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=uc(this,"actions"),this.addFilter=uc(this,"filters"),this.removeAction=tr(this,"actions"),this.removeFilter=tr(this,"filters"),this.hasAction=dc(this,"actions"),this.hasFilter=dc(this,"filters"),this.removeAllActions=tr(this,"actions",!0),this.removeAllFilters=tr(this,"filters",!0),this.doAction=fc(this,"actions"),this.applyFilters=fc(this,"filters",!0),this.currentAction=pc(this,"actions"),this.currentFilter=pc(this,"filters"),this.doingAction=hc(this,"actions"),this.doingFilter=hc(this,"filters"),this.didAction=mc(this,"actions"),this.didFilter=mc(this,"filters")}};function nI(){return new tI}var uf=nI(),{addAction:q0,addFilter:W0,removeAction:z0,removeFilter:K0,hasAction:X0,hasFilter:Y0,removeAllActions:J0,removeAllFilters:Q0,doAction:Z0,applyFilters:eP,currentAction:tP,currentFilter:nP,doingAction:rP,doingFilter:oP,didAction:sP,didFilter:iP,actions:aP,filters:cP}=uf,me=cf(void 0,void 0,uf),lP=me.getLocaleData.bind(me),uP=me.setLocaleData.bind(me),dP=me.resetLocaleData.bind(me),fP=me.subscribe.bind(me),pP=me.__.bind(me),hP=me._x.bind(me),mP=me._n.bind(me),gP=me._nx.bind(me),vP=me.isRTL.bind(me),_P=me.hasTranslation.bind(me);function rI(e,t){if(e.html)return e;const n=e.subject||t;return{...e,subject:n,html:rf(n)}}function oI(e,t){if(e.html||e.subject||!t?.subject)return e;const n={...e};return delete n.subject,n}async function sI(e){const t=e.getInstance(Et);t&&!t.snapshot().ready&&await new Promise(r=>{const o=t.state.watch(({ready:s})=>{s&&(queueMicrotask(()=>o.dispose()),r())})});const n=cf(t?.snapshot().catalog);return DS(r=>n.__(r))}function ft({code:e,project:t,...n},r,o){const s=o??ai(r);return{...n,...e?{html:nt(r).toEditorForm(e)}:{},renderGuid:xe(),...s===void 0?{}:{project:s}}}function Se({html:e,renderGuid:t,...n},r){const{requested:o}=Fn(r);return Xe({...n,code:nt(r).toOutputForm(e),project:o===void 0?n.project:o,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function df(e){return Re(e)?.current()?.get().serverId??void 0}function ss(e,t,n){return n===void 0&&(n=e.post===void 0?df(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function an(e,t){return Xe({...e,link:void 0,comment_status:void 0})}function lr({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?df(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||Fg(n.slug),parent:o}}function is({html:e,isAutosave:t,...n},r){return Xe({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:Xe({html:e,ampHtml:e&&""})})}function ur({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function gc({html:e,isAutosave:t,...n}){return Xe({...n,autosave:t?!0:void 0,code:e,guid:void 0})}var pi=e=>{const t={current:Promise.resolve(),state:e,decorate:(n,r)=>(r&&(n=n.bind(r)),function(...o){const s=t.current.then(()=>n(...o));return t.current=s.then(i=>{t.state=i},i=>{}),s})};return t};function iI(e){return String(e).replace(/"/g,"&quot;")}function aI(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 hi(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 vc(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),o=iI(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function _c(e,t){return e.replace(new RegExp(`\\s+${t}\\s*=\\s*["'][^"']*["']`,"gi"),"")}function bc(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function ff(e){if(!e?.trim())return{};const t=hi(e);return t?{emBlockId:bc(t.full,"em-block-id"),emBlockVersion:bc(t.full,"em-block-version")}:{}}function pf(e,t,n){if(!e?.trim()||!t)return e;const r=hi(e);if(!r)return e;const o=String(t),s=aI(n??new Date);let{full:i,index:a}=r;const c=i.length;return/\bem-block-id\s*=/.test(i)||(i=vc(i,"em-block-id",o)),i=vc(i,"em-block-version",s),e.slice(0,a)+i+e.slice(a+c)}function cI(e){const t=e?.trim()?hi(e):null;if(!t)return e;const{full:n,index:r}=t,o=_c(_c(n,"em-block-id"),"em-block-version");return e.slice(0,r)+o+e.slice(r+n.length)}function lI(e,t){const{emBlockId:n,emBlockVersion:r}=ff(e);return n&&r?e:pf(e,t)}var jt=B("NotificationService"),uI=B("emailTemplate.reads");async function dI(e,t){try{const n=gt(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,pI(e,t,n);return}}var fI=B("emailTemplate.notifiedFailures");function pI(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(fI,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(jt).then(()=>{On(e,H.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function hI(e,t){const n=e.getOrCreateInstance(uI,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=dI(e,t).then(s=>(s===void 0&&n.delete(t),s));return n.set(t,o),o}var mI=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Ja.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Ja.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},bP=B("projects.v2IdByWpId"),yP=B("projects.wpIdByV2Id"),EP=B("emails.v2SavedAtOnOpen"),wP=B("emails.v2OpeningReads"),as=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function gI(e,t){if(!t)throw new as(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new as(e,qr(t))}function vI(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var _I=/^[A-Za-z0-9_-]{1,128}$/,bI=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),yc=new Set;function yI(e){return _I.test(e)?!0:(yc.has(e)||yc.add(e),!1)}function EI(e){return e&&!e.ok?String(qr(e).data.code??""):""}var hf=()=>({isAutosave:!1});function Ec(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function wI(e,t){const n=new AbortController,r=xn(e.getInstance(Ue)?.contentReadyTimeoutMs);let o;const s=new Promise((i,a)=>{o=setTimeout(()=>{n.abort(),a(new as("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),s])}finally{clearTimeout(o)}}function SI(e,t){return cu(t,e==="block")}async function II(e,t,n,r,o){if(!yI(n))return hf();const s=$t(e),i=Ln(e),a=SI(t,n);try{const c=await AI(e,t,n,r,o);return c.id&&(s.set(a,c.id),i.delete(a)),c}catch(c){throw Ev(i,a,r.html??""),c}}async function AI(e,t,n,r,o){const s=Qd(e,[mI]),i={entityId:n,...o?{autosave:!0}:{}},a=await wI(e,c=>t==="email"?s.emailsRevisionsCreate(i,Ec(t,r),{signal:c}):s.blocksRevisionsCreate(i,Ec(t,r),{signal:c}));return bI.has(EI(a))?hf():(gI("обновление",a),vI(a.data??{}))}function TI(e,t,n,r){return II(e,t,n,r,!1)}async function CI(e,t,n){if(t==null||t===""||n===void 0||!Kt(e))return wc;const r=Date.now(),o=Us(String(t));return ju(o,{html:n},r,Ks($t(e),o,Ln(e),n)),await TI(e,"block",String(t),{html:n}),_r(o,r,$t(e).get(o)??void 0),()=>$s(o,r)}function wc(){}var po="EXTERNAL",Sc=Symbol("supersededShow");function OI(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var PI="email_id";function ho(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var RI=class extends de{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=pi();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=Bn(t),this._eventLock=NS(t);const n=ne(e,H.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(ne(e,H.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(wt,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(PI,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Ue)??ni}_throwIfDestroyed(){if(this.isDisposed())throw Be()}async getTemplateEmail(e){const t=await hI(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,HS(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await sn(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,ft(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,lr(o,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,ss(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const s=this._dataSources.emails,i=s.cache,a=await sn(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let l=Vt(e,this._container);const u=l.id;let d=u;if(u!==void 0){const f=await s.get(u);l={...f??{},...l,utm_parameters:l.utm_parameters??f?.utm_parameters??{},renderGuid:f?.renderGuid??xe(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a}}else{d=n??xe();const f=await s.get(d);l={...l,utm_parameters:l.utm_parameters??{},renderGuid:f?.renderGuid??xe(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a},delete l.project}if(t){const f=await this.getTemplateEmail(String(t));f&&(l=VS(f,l))}return u===void 0&&!l.html&&(l=rI(l,await sI(this._container))),await i.setAll([[d,l]]),l}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==ic(this._container,e))return!1;const n=cr(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=ic(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:cr(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&MS({ticket:t,emailId:oc(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Sc;if(!e)return;const n=this._getInitPipeline();if(ie(n.signal),Wr(e))return this._showBlock(e,n);const r=ee(Ee(this._container).sessionKey()),o=FS(e);if(!r&&!o&&jS(this._container,e,cr(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const s=zr(e);s.email.id,this._prevCommand?.id;let i,a="",c=0,l=!1,u,d=Promise.resolve(),f,v=!1;try{this._eventLock.suspendChange();const{email:g,blocks:y,autosaves:E,comments:P,templateId:O,reload:x}=s;i=g.id;const w=Vt(g,this._container),C=w.id,T=C??xe(),D=await dt("getProject",sn(this._container));ie(n.signal),a=xe();const R={isNew:C===void 0,id:String(T),project:D},m=x===!0&&C!==void 0;m&&(await this._dataSources.emails.remove(String(C),{silent:!0}),String(C)),c=++this._showToken,String(T);const p=[];p.push(this.setBlocks(y)),g.id!==void 0&&(p.push(this.setComments(P)),p.push(this.setEmailRevisions(E,String(g.id)))),p.push(this.setEmail(g,$o(O)?O:Number(O),C===void 0?String(T):void 0,c,a)),await dt("setEmail+blocks+revisions",Promise.all(p),{emailId:C??String(T),showId:a,targetShowToken:c}),ie(n.signal);const h=await this._dataSources.emails.get(String(T)),b=Ee(this._container),L={id:a,token:c};if(r){ar(this._container);const S=b.suspendedDocument()?.get().serverId;!m&&C!==void 0&&S!=null&&String(S)===String(C)&&b.resumeSuspended()}C===void 0?f=b.startNewDraft(h??w,{patch:oI(w,h),show:L}):m?f=b.reload(C,{email:h??w,patch:w,show:L}):b.sessionKey()===Ot(C)?f=b.show(w,L):f=b.open(C,{email:h??w,patch:w,show:L}),b.beginShowFill(a);const F=!!this._prevCommand&&Ae(this._prevCommand,R);R.id,!this._prevCommand||Ae(this._prevCommand,R),this._prevCommand?.id,this._rememberShow(R),d=n.requestShow({showId:a,navId:String(T),emailId:C,isNew:C===void 0}),v=!0;const I=()=>b.endShowFill(a);Promise.allSettled([d,f.whenReady()]).then(I),String(T),l=!0}catch(g){u=g,v&&a&&n.failShow(a,g),a&&Re(this._container)?.endShowFill(a),Es(g)||(tu(g),void 0)}finally{this._eventLock.resumeChange()}if(!l)throw u instanceof Error?u:new Error(`[useblocks] show() setup failed: ${String(u??"unknown error")}`);return dt("show-init-deferred",Promise.all([d,f?.whenReady().catch(g=>{if(g instanceof ht){const y=zs(g);throw y?new Error(`[useblocks] show(): email open failed (${y})`,{cause:g}):g}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:s,reload:i}=LS(e),a=xe();let c=!1;try{await this.setBlocks(o),ie(t.signal),i&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const l=n.id!==void 0&&n.id!==""?String(n.id):void 0,u=Ee(this._container);if(!i&&l!==void 0&&u.sessionKey()===mr(l)){const O=ho(n)?await this._storeShownBlock(n):void 0,x={id:a,token:++this._showToken},w=u.show(O,x),C=t.requestShow({showId:a,navId:l,emailId:void 0,isNew:!1});c=!0,await dt("show-block-init",Promise.all([C,w?.whenReady().catch(()=>{})]),{showId:a});return}const d=r||i?await rc(this._container,String(n.id)):void 0,f=d&&(i||ho(n))?await this._storeShownBlock({...Se(d,this._container),...n}):r||i?d:await this._storeShownBlock(n);if(ie(t.signal),!f)throw new Error(`[useblocks] show(): block ${String(n.id)} not found`);s!==void 0&&f.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(s.filter(O=>O.id!==void 0).map(O=>[O.id,ur(O,String(f.id))])),this._prevCommand=void 0,this._lastShow=void 0;const v=f.id!==void 0?String(f.id):xe(),g={id:a,token:++this._showToken};ar(this._container);const y=i?u.reloadBlock(v,f,g):u.openBlock(v,f,g);f.id;const E=t.requestShow({showId:a,navId:v,emailId:void 0,isNew:f.id===void 0});c=!0;const P=y.whenReady().catch(O=>{if(O instanceof ht)throw O});await dt("show-block-init",Promise.all([E,P]),{showId:a})}catch(l){throw c&&t.failShow(a,l),l}}async _storeShownBlock(e){const t=ft(e,this._container,await sn(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();ie(e.signal);const t=Ee(this._container);if(ee(t.sessionKey())&&!t.hasSuspended())throw new Error("[useblocks] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:po,fallbackTitle:fd(this._container)});if(ie(e.signal),!n)throw OI(t.emailSaveState().error);return De(sf(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=Ee(this._container),t=e.current();if(!t||!ee(e.sessionKey()))throw new Error("[useblocks] saveBlock(): no open block");return hg(t,async()=>{await t.whenReady();const n=Hr(t),r=t.get().version,o=t.get().serverId,s=typeof n.global_block=="boolean"?n.global_block:o!=null&&ff(n.html??"").emBlockId===String(o),i=o!=null&&s?pf(n.html,String(o),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:i,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},c=this._dataSources.blocks,l=await CI(this._container,t.get().serverId,a.html),u=t.get().serverId==null?c.create(a,{source:po}):c.update(String(t.get().serverId),a,{source:po}),d=await BS(this._container,u,f=>{f&&l(),f&&Ee(this._container).current()===t&&t.get().serverId==null&&f.id!==void 0&&t.markSaved(r,String(f.id))});if(!d)throw new Error("[useblocks] save(): block was not saved");return l(),t.markSaved(r,d.id!==void 0?String(d.id):void 0),Se(d,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=oc(e);const n=this._queuedShow(e,t).then(r=>r===Sc?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),ie(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=Ee(this._container);if(n!==void 0&&r.sessionKey()===mr(n))return;const o=t.code===void 0&&n!==void 0?await rc(this._container,n):void 0,s=o&&ho(t)?await this._storeShownBlock({...Se(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!s)throw new Error(`[useblocks] openBlock(): block ${String(n)} not found`);ar(this._container);const i=r.openBlockOver(s.id!==void 0?String(s.id):xe(),s);s.id,r.hasSuspended(),ye(this._container,H.ON_BLOCK_OPEN_ID).fire({block:s}),await i.whenReady().catch(a=>{if(a instanceof ht)throw r.current()===i&&(ye(this._container,H.ON_BLOCK_CLOSE_ID).fire({block:s,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),Fy(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function DI(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 kI(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),o=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:o,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:DI(e)}}function mo(e,t){return t?kI(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var mf=["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"],xI=[...mf,"html","id","project","password"],SP=new Set(["html",...mf,"global_block","project"]);function LI(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(xI),r={};for(const o of Object.keys(e))n.has(o)||(r[o]=e[o]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function NI(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...LI(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 cs=new WeakMap;function MI(e){let t=cs.get(e);return t||(t={byId:new Map,fallback:[]},cs.set(e,t)),t}function FI(e){cs.delete(e)}function BI(e,t){const{byId:n,fallback:r}=MI(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const s=r.indexOf(o);return s>=0&&r.splice(s,1),o}return}for(let o=r.length-1;o>=0;o--){const s=r[o],i=e.name!=null&&e.name!==""&&s.name!=null&&s.name!==""&&s.name===e.name,a=e.type!=null&&e.type!==""&&s.insertFrom===e.type;if(i&&a)return r.splice(o,1),s.id!=null&&s.id!==""&&n.delete(String(s.id)),s}}async function jI(e,t){const{blocks:n}=Bn(e);return await n.cache.getIfPresent(t)??void 0}async function UI(e,t){if(!t.blockId)return;const n=await jI(e,t.blockId);if(n)return NI(n,t)}async function $I(e,t){const n=BI(e,t);if(n)return mo(e,n);const r=await UI(t,e);return r?mo(e,r):mo(e,void 0)}var HI="application_block_inserted",VI=-1e3,Ic=new WeakSet;function GI(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 qI(e){if(!e||Ic.has(e))return;Ic.add(e);const t=new de,n=pe(e);return t.addDisposable(n.addListenerAsyncPipe(HI,async(r,o)=>{const s=GI(r)?await $I(r,e):r;return o?o(s):s},VI)),t.addDisposable({dispose:()=>{FI(e)}}),t}var WI=$r("plugin.readBlockAutosave"),IP=B("blockDocuments.provided"),gf=B("plugin.earlyWindow");function zI(e){return e.getOrCreateInstance(gf,()=>({depth:0}))}function KI(e){const t=zI(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function vf(e){return(e?.getInstance(gf)?.depth??0)>0}function _f(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,s,i)=>{const a=e(o,s,i);if(r&&vf(t)){const c=n;queueMicrotask(()=>{o.call(i,c)})}return a}}var go=100,XI=class extends de{_container;_events;constructor(e){super(),this._container=e;const t=qI(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:s}=Bn(e),i=ne(e,H.ON_SHARE_ID),a=ne(e,H.ON_SHOW_PREVIEW_ID),c=ne(e,H.ON_EMAIL_CLONE_ID),l=ne(e,H.ON_BLOCK_OPEN_ID),u=ne(e,H.ON_BLOCK_CLOSE_ID),d=ne(e,H.ON_BLOCK_CLONE_ID),f=ne(e,H.ON_BLOCK_INIT_ID),v=ne(e,H.ON_BLOCK_CHANGED_ID),g=ne(e,H.ON_CODE_VALIDATE_ID),y=ne(e,H.ON_IMPORT_VALIDATE_ID),E=ne(e,H.ON_SUBJECT_CHANGED_ID),P=ne(e,H.ON_EMAIL_CHANGED_ID),O=ne(e,H.ON_PREHEADER_CHANGED_ID),x=ne(e,H.ON_SAVEBUTTON_CLICK_ID),w=ne(e,H.ON_BLOCK_SAVEBUTTON_CLICK_ID),C=ne(e,H.ON_NEXTBUTTON_CLICK_ID),T=ne(e,H.ON_SEND_LIVEPREVIEW_ID),D=ne(e,H.ON_SEND_TESTEMAIL_ID),R=ne(e,OS),m=ne(e,H.ON_CONTENT_CHANGED_ID),p=ne(e,CS),h=ne(e,H.ON_PREVIOUSBUTTON_CLICK_ID),b=ne(e,H.ON_SEND_EMAIL_MODAL_ID),L=fp(ne(e,H.ON_EMAIL_INIT_ID),I=>!I.reset),F=ne(e,H.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:V(O),handleSubjectChanged:V(E),handleValidate:V(g),handleImportValidate:V(y),handleReadEmail:V(n.handlerRead,I=>I,I=>I&&Vt(I,e)),handleSaveEmail:V(n.onSave,function({prev:I,patch:S,value:N,source:j}){const W=I?De(I,e):void 0;return{prev:W,patch:gn(W,De(S,e)),value:De(N,e),source:j}},I=>I?Vt(I,e):void 0),handleRemoveEmail:V(n.onRemove,({value:I,source:S})=>({value:De(I,e),source:S}),()=>{}),handleReadCommonBlocks:V(R,I=>I.project,I=>I?.map(S=>ft(S,e))),handleReadTemplateBlocks:V(p,I=>I,I=>I?.map(S=>ft(S,e))),handleReadBlocks:V(t.byForeignKey("project").handleRead,I=>Fn(e).requested||String(I),I=>I?.map(S=>ft(S,e))),handleReadBlock:V(t.handlerRead,I=>I,I=>I?ft(I,e):void 0),handleOpenBlock:V(l,({block:I})=>({block:Se(I,e)})),handleCloseBlock:V(u,({block:I,hasUnsavedChanges:S})=>({block:Se(I,e),hasUnsavedChanges:S})),handleCloneBlock:V(d,I=>Se({...I,html:cI(I.html)},e)),handleSaveBlock:V(t.onSave,function({prev:I,patch:S,value:N,source:j}){const W=N.global_block===!0&&N.id&&typeof N.html=="string"?{...N,html:lI(N.html,String(N.id))}:N,re=I?Se(I,e):void 0;return{prev:re,patch:gn(re,Se(S,e)),value:Se(W,e),source:j}},I=>I?ft(I,e):void 0),handleRemoveBlock:V(t.onRemove,({value:I,source:S})=>({value:Se(I,e),source:S}),()=>{}),handleReadComments:V(r.byForeignKey("post").handleRead,I=>I,I=>I?.map(S=>ss(S,e))),handleSaveComment:V(r.onSave,function({prev:I,patch:S,value:N,source:j}){const W=I?an(I,e):void 0;return{prev:W,patch:gn(W,an(S,e)),value:an(N,e),source:j}},I=>I?ss(I,e):void 0),handleRemoveComment:V(r.onRemove,({value:I,source:S})=>({value:an(I,e),source:S}),()=>{}),handleReadEmailRevisions:V(o.byForeignKey("parent").handleRead,I=>I,I=>I?.map(S=>lr(S,e))),handleReadEmailAutosave:V(ne(e,Xd),I=>I,I=>I?lr(I,e):null),handleEmailAutosave:V(o.onSave,function({prev:I,patch:S,value:N,source:j}){return{value:is(N,e),source:j}},I=>I?lr(I,e):void 0),handleRemoveEmailAutoSave:V(o.onRemove,({value:I,source:S})=>({value:is(I,e),source:S}),()=>{}),handleReadBlockRevisions:V(s.byForeignKey("parent").handleRead,I=>I,I=>I?.map(S=>ur(S))),handleReadBlockAutosave:V(ne(e,WI),I=>I,I=>I?ur(I):null),handleBlockAutosave:V(s.onSave,({value:I,source:S})=>({value:gc(I),source:S}),I=>I?ur(I):void 0),handleRemoveBlockAutoSave:V(s.onRemove,({value:I,source:S})=>({value:gc(I),source:S}),()=>{}),handleBlockInit:V(f,I=>Se(I,e)),handleBlockChanged:V(Jr(v,go),I=>Se(I,e)),handleEmailChanged:V(Jr(P,go),I=>De(I,e)),handleEmailInit:_f(V(L,I=>De(I,e)),e),handlePreviousButtonClick:V(h,I=>De(I,e)),handleNextButtonClick:V(C,I=>De(I,e)),handleSaveButtonClick:V(x,I=>De(I,e)),handleSaveBlockButtonClick:V(w,I=>Se(I,e)),handleHtmlChanged:V(Jr(m,go)),handleTestEmailSend:V(D,({html:I,...S})=>({...S,code:I,compiled:{html:I,ampHtml:""}})),handleTestEmailModal:V(b,I=>De(I,e)),handleCloneEmail:V(c,I=>De(I,e)),handleShareEmail:V(i),handlePreviewEmail:V(a),handleLivePreviewEmail:V(T),handleAnalyticsEvent:V(F)}}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 Bt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},YI=B("DataController"),JI=B("DataEvents");function bf(e){return e.getOrCreateInstance(YI,()=>{const t=new RI(e);return e.getInstance(K)?.addDisposable(t),t})}function yf(e){return e.getOrCreateInstance(JI,()=>new XI(e))}var QI=B("plugin.pluginStart");function Ef(e){return e.getOrCreateInstance(QI,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(K)?.addDispose(()=>t()),{done:n,finish:t}})}function ZI(e){return Ef(e).done}function eA(e){const t=Ef(e);return t.run===void 0&&(t.run=(e.getInstance(Is)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var tA=B("plugin.startupShow");function nA(e){const t=bf(e),n=yf(e),r=e.getInstance(_e),o=e.getInstance(K),s={current:Promise.resolve()};e.inject(tA,s);let i=!1;const a=r?.watch(l=>{l&&n.setOptions(l),i=(l?.plugins?.length??0)>0,s.current=s.current.catch(()=>{})}),c=r?.select(l=>l?.content).watch(l=>{if(l===void 0)return;const u=()=>(ce(we.showStart),t.show(l).finally(()=>ce(we.showEnd))),d=i?ZI(e).then(u):u();d.catch(()=>{}),s.current=d});a&&o?.addDisposable(a),c&&o?.addDisposable(c)}function rA(e){const t=bf(e);return{...yf(e).get(),show(n){return ce(we.showStart),t.show(n).finally(()=>ce(we.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return ce(we.showStart),t.showBlock(n,r).finally(()=>ce(we.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function wf(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Kr(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let s=t;s<e.length;s++){const i=e[s];if(o){o=!1;continue}if(i==="\\"){o=!0;continue}if(r){i===r&&(r="");continue}if(i==='"'||i==="'"){r=i;continue}if(i==="("){n++;continue}if(i===")"&&(n--,n<0))return!1}return n===0}function oA(e){return(t,n,r)=>Kr(t)?e(t,n,r):!1}function sA(e){return t=>Kr(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function iA(e){return(t,n,r)=>Kr(t)?wf(t)?e(t,n,r):t:!1}function aA(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Kr(n)?wf(n)?e(t):t:!1}}function cA(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function mi(e,t){const n=e.length;for(let r=0;r<n;r++){const o=e.charCodeAt(r);if(o===0||t==='"'&&o===34||t==="'"&&o===39||t===""&&(o===32||o===9||o===10||o===13||o===12||o===34||o===39||o===60||o===62||o===61||o===96))return!1}return!0}function lA(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let s=0;s<e;s++){const i=r[s]%62;o+=t.charAt(i)}return o}var uA=8,dA=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=lA(uA),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Xr=new dA;function Ac(e,t){return t!==void 0&&!mi(e,t)?`%|{${Xr.getOrCreateByKey(e)}}|%`:e}function fA(e){const t=Xr.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function fe(e,t,n){return t!==void 0?mi(e,t)?e:`%|{${Xr.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function pA(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function le(e){return e.startsWith("<!--")&&e.endsWith("-->")?pA(e.slice(4,-3)):e}function hA(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const o=e.match(/\[%\s*([^%]*?)\s*%\]/);o&&(r=o[1]);const s=r.trim();return t.test(s)||n.test(s)}function mA(e,t,n){return t!==void 0?mi(e,t)?e:`%|{${Xr.getOrCreateByKey(e)}}|%`:n||cA(e)||hA(e)?`<!--${e}-->`:e}var at=oA(fe),ct=sA(le),gA=iA(fe),vA=aA(le),Sf=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",fA),e.escape("@{","}",fe,!0).unescape("<!--@{","}-->",le,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Ac,!0),e.escape("{{","}}",Ac,!0),e.createSyntax("brace-percent").escape("{%","%}",fe).unescape("<!--{%","%}-->",le),e.createSyntax("brace-hash").escape("{#","#}",fe).unescape("<!--{#","#}-->",le),e.createSyntax("proscript").escape("[%","%]",mA,!0).unescape("<!--[%","%]-->",le,!0),e.createSyntax("getresponse").escape("[[IF","]]",fe).escape("[[if","]]",fe).escape("[[ELSE]]","",fe).escape("[[else]]","",fe).escape("[[ENDIF]]","",fe).escape("[[endif]]","",fe).unescape("<!--[[IF","]]-->",le).unescape("<!--[[if","]]-->",le).unescape("<!--[[ELSE]]","-->",le).unescape("<!--[[else]]","-->",le).unescape("<!--[[ENDIF]]","-->",le).unescape("<!--[[endif]]","-->",le),e.createSyntax("expert-sender").escape("<if",">",fe).escape("</if",">",fe).escape("<else",">",fe).escape("</else",">",fe).escape("<var ",">",fe,!0).unescape("<!--<if ",">-->",le).unescape("<!--</if",">-->",le).unescape("<!--<else ",">-->",le).unescape("<!--</else",">-->",le).unescape("<!--<var",">-->",le,!0),e.createSyntax("velocity").escape("#if",")",at).escape("#elseif",")",at).escape("#else","",fe).escape("#foreach",")",at).escape("#macro",")",at).escape("#set",")",gA,!0).escape("#parse",")",at).escape("#include",")",at).escape("#evaluate",")",at).escape("#end","",fe).escape("#break","",fe).escape("#stop","",fe).unescape("<!--#macro","-->",ct).unescape("<!--#if","-->",ct).unescape("<!--#elseif","-->",ct).unescape("<!--#else","-->",le).unescape("<!--#foreach","-->",ct).unescape("<!--#parse","-->",ct).unescape("<!--#include","-->",ct).unescape("<!--#evaluate","-->",ct).unescape("<!--#end","-->",le).unescape("<!--#break","-->",le).unescape("<!--#stop","-->",le).unescape("<!--#set","-->",vA,!0),e.createSyntax("mailchimp").escape("*|","|*",fe).unescape("<!--*|","|*-->",le)},ls="bare",_A=new Map;function bA(e){return e?_A.get(e)??ls:ls}var If=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function Tc(e){return If.includes(e)}function tn(e){return e==="bare"||e==="html-comment"}function vo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yA(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!tn(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[l,u]of[["output",r.output],["editor",r.editor]])if(u!==void 0&&!tn(u))return t(`templateDirectives.${l}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!vo(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[l,u]of Object.entries(r.syntaxes))if(!(!Tc(l)||u===void 0||tn(u))){if(!vo(u))return t(`templateDirectives.syntaxes.${l}: expected a form or an object, configuration ignored.`),n;for(const d of["output","editor"]){const f=u[d];if(f!==void 0&&!tn(f))return t(`templateDirectives.syntaxes.${l}.${d}: unknown form "${String(f)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??ls;let s=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),s=void 0);const i=[];if(r.syntaxes)for(const l of Object.keys(r.syntaxes)){if(!Tc(l)){t(`templateDirectives.syntaxes: unknown syntax id "${l}", entry ignored.`);continue}i.push(l)}else i.push(...If);const a={},c={};for(const l of i){const u=r.syntaxes?.[l],d=vo(u)?u:void 0,f=(tn(u)?u:d?.output)??o;let v=d?.editor??s??f;f==="bare"&&v==="html-comment"&&(t(`templateDirectives.syntaxes.${l}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),v="bare"),a[l]=f,c[l]=v}return{output:a,editor:c}}function Af(e,t,n,r){for(let o=t;o<n;o++){const s=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?s===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(s)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):s==="<"?r.insideTag=!0:s===">"?r.insideTag=!1:r.insideTag&&(s==='"'||s==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=s,r.unquotedAttr=!1):r.insideTag&&/\S/.test(s)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(s)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function cn(e,t){return e.start<t.end&&t.start<e.end}function Cc(e,t,n,r,o=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const s=t.flatMap(u=>u.match(e).flatMap(d=>!Number.isInteger(d.start)||!Number.isInteger(d.end)||d.start<0||d.end>e.length||d.start>=d.end?[]:[{range:d,mapFn:u.mapFn,overrideBuiltins:u.overrideBuiltins,syntax:u.syntax,isVariable:u.isVariable}])).sort((u,d)=>u.range.start-d.range.start||u.range.end-d.range.end),i=[],a=o.slice().sort((u,d)=>u.start-d.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(const{range:u,mapFn:d,overrideBuiltins:f,syntax:v,isVariable:g}of s){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):Af(e,l,u.start,c),l=u.end,a.some(O=>cn(O,u)))continue;const y=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,E=e.substring(u.start,u.end),P=d(E,y,c.insideTag);P!==!1&&P!==E&&(i.push({range:u,text:P,overrideBuiltins:f,syntax:v,isVariable:g}),a.push(u))}return i.sort((u,d)=>u.range.start-d.range.start||u.range.end-d.range.end)}function EA(e,t){const n=t.reduce((a,{mapFn:c,start:l,end:u,syntax:d,isVariable:f})=>(a[l]||(a[l]=[]),a[l].push({value:u,mapFn:c,syntax:d,isVariable:f}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),s=[];let i;for(;(i=o.exec(e))!==null;){const a=i[0];s.push({start:i.index,startToken:a,endTokens:n[a]})}return s}function _o(e,t,n,r,o=!1){const s=[];if(n&&(t=t.filter(l=>l.isVariable)),!t.length)return s;const i=EA(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let l=0;l<i.length;l++){const{start:u,startToken:d,endTokens:f}=i[l];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):Af(e,c,u,a),c=u;const v=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let g=!1;for(const{mapFn:y,value:E,syntax:P,isVariable:O}of f){let x=u+d.length,w=e.indexOf(E,x);for(;w!==-1;){let C=w,T=u+d.length,D=0;for(;C!==-1;){const b=e.indexOf(d,T);if(b!==-1&&b<C)D++,T=b+d.length,C=e.indexOf(E,T);else if(D>0)D--,T=C+E.length,C=e.indexOf(E,T);else break}if(C<0)break;const R=C+E.length,m=e.substring(u,R),p=y(m,v,a.insideTag);if(p===!1){x=w+Math.max(E.length,1),w=e.indexOf(E,x);continue}(o||p!==m)&&s.push({range:{start:u,end:R},text:o?m:p,syntax:P,isVariable:O});const h=i.findIndex(({start:b})=>b>=R);h>l?l=h-1:l=i.length,g=!0;break}if(g)break}}return s}function nr(e,t){if(!t.length)return e;const n=t.slice().sort((o,s)=>s.range.start-o.range.start);let r=e;for(const{text:o,range:s}of n)r=r.slice(0,s.start)+o+r.slice(s.end);return r}var wA=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=Sf){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,s,i){return t.push({start:r,end:o,mapFn:s,isVariable:i,syntax:this.syntax||r}),this},unescape(r,o,s,i){return n.push({start:r,end:o,mapFn:s,isVariable:i,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let o=!1;const s={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(i=>i!==n),this._unescapeMatchers=this._unescapeMatchers.filter(i=>i!==r))}};return this.addDisposable(s),s}_collectMappings(e,t,n){const r=_o(e,this._escapes,t,n),o=Cc(e,this._escapeMatchers,t,n),s=o.filter(c=>c.overrideBuiltins).map(c=>c.range),i=r.filter(c=>!s.some(l=>cn(l,c.range))),a=o.filter(c=>c.overrideBuiltins||!i.some(l=>cn(c.range,l.range)));return[...i,...a].sort((c,l)=>c.range.start-l.range.start||c.range.end-l.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=_o(e,this._unescapes,t),r=Cc(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),s=n.filter(a=>!o.some(c=>cn(c,a.range))),i=r.filter(a=>a.overrideBuiltins||!s.some(c=>cn(a.range,c.range)));return[...s,...i].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>bA(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return _o(e,this._escapes,t,n,!0)}getEscapedText(e,t){return nr(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return nr(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=s=>s===void 0?void 0:t[s],r=Object.values(t);let o=e;return r.includes("bare")&&(o=nr(o,this._collectRevertMappings(o).filter(s=>n(s.syntax)==="bare"))),r.includes("html-comment")&&(o=nr(o,this._collectMappings(o).filter(s=>!s.isVariable&&n(s.syntax)==="html-comment"&&s.text.startsWith("<!--")&&s.text.endsWith("-->")))),o}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}},Tf="em___script",ln=`<${Tf}`,us=`</${Tf}>`;function Oc(e){return e.replace("<script",ln).replace("<\/script>",us)}var Pc=new wA(e=>{e.escape("<script","<\/script>",t=>Oc(t)).unescape(ln,us,t=>t.replace(ln,"<script").replace(us,"<\/script>")),e.escape("<script","/>",t=>Oc(t)).unescape(ln,"/>",t=>t.replace(ln,"<script")),Sf(e)});function SA(e){const t=yA(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return fu();const n=new Set(Object.keys(t.output).filter(o=>t.output[o]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:o=>Pc.normalizeToPolicy(o,t.editor),toOutputForm:o=>Pc.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:du(r)}}function IA(e){let t;e.injectFactory(Os,()=>{const n=e.getInstance(he)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:SA(n)}),t.policy})}var AA=[{name:"rest.client",setup:SS},{name:"auth.oauth",setup:um},{name:"auth.apply",awaits:{signals:[Rr]},reaches:[Fs],setup:dm},{name:"rest.identityHeaders",setup:fS},{name:"rest.localeHeader",setup:_S},{name:"lifetime.destroyable",provides:[ii],setup:fw},{name:"host.load",setup:Lw},{name:"appInit",provides:[Ke,Ns],setup:rm},{name:"config",provides:[he],setup:uw},{name:"templateDirectives",provides:[Os],setup:IA},{name:"email.documents",setup:Dw},{name:"show.initPipeline",provides:[Ue],setup:IS},{name:"show",setup:nA},{name:"locale.service",provides:[Et],setup:cS},{name:"locale.fromConfig",awaits:{services:[he,Et]},setup:lS},{name:"canvas.early",setup:rE},{name:"canvas.previewSettings",setup:yE},{name:"canvas.sandboxExtensions",setup:wE},{name:"canvas.sandboxScriptRelay",setup:AE},{name:"canvas.headerSync",provides:[oi],setup:iE},{name:"canvas.headersAfterRecovery",setup:aE},{name:"canvas.ampSync",setup:Z_},{name:"canvas.moduleBridge",setup:Rb},{name:"canvas.port",setup:lb},{name:"canvas.images",setup:ab},{name:"canvas.edits",setup:tE},{name:"canvas.surfaceFollowsSession",setup:jy},{name:"canvas.blockContent",setup:By},{name:"canvas.sandboxFill",provides:[ri],setup:VE},{name:"canvas.reactions",setup:nE}],Rc;function gi(e){const t=e.getInstance(_e);if(t)return t;e.getInstance(K)||e.inject(K,new de);const n=ae();e.inject(_e,n),Rc??=Ms(AA);for(const r of Rc)r.setup(e);return n}function TA(e){}var CA=[{name:"save.previewFollow",setup:TA}],Dc=B("plugin.lateUnitsInstalled");function OA(e){if(!e.getInstance(Dc)){e.inject(Dc,!0);for(const t of Ms(CA))t.setup(e)}}var bo,Cf="core";function PA(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Cf],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function RA(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?jn().then(()=>{}):t([Cf],e)}function jn(){return bo===void 0&&(bo=PA().then(e=>(bn()&&e.installDiagnostics().catch(t=>{}),e))),bo}var yo=null,Eo=null;async function DA(e){typeof e?.prefetch=="function"&&await e.prefetch()}function vi(){return yo||(yo=jn().then(()=>{})),yo}function Of(e){return Eo||(Eo=DA(e)),Eo}function kA(){return Of(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function xA(){const e=typeof window.__useblocks__<"u"?window.__useblocks__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function LA(e){return Promise.all([vi(),Of(e)]).then(()=>{})}function NA(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function kc(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>RA(t?{priority:t}:void 0)).then(()=>(ei(t?{priority:t}:void 0),n?vi():void 0)).catch(()=>{})}function MA(e){const t=NA(e);if(t==="eager")kc(e);else if(t==="idle"){const n=()=>kc(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Pf="PluginRegistry";function FA(e=pp()){return e.getOrCreateInstance(Pf,()=>new Cp)}var ds=new Op(()=>FA());function BA(e){const t=Ve(e),n=Br(e);return{dispose:()=>{Oe("ui",()=>n.disposeAll()),Oe("commands",()=>t.disposeAll())}}}function jA(e,t){const n=bt(e);return t.onLifecycle(r=>n.handle(r))}var UA=["Commands","Ui","Agent","Document"],Rf=new Set(["Agent","Document"]),xc=new Map;function $A(e,t){for(let n=e;typeof n=="function";n=Object.getPrototypeOf(n))if(Ju(n,t))return!0;return!1}function HA(e,t,n){xc.get(e)!==t&&xc.set(e,t)}function VA(e,t){if($A(t,e))return;const n=typeof t=="function"?t.name||"anonymous":typeof t;if(Rf.has(e)){HA(e,t,n);return}}function GA(e){const t=UA.map(n=>e.on(n,r=>VA(n,r)));return{dispose:()=>t.forEach(n=>n.dispose())}}var Lc=new WeakMap,Nc=new WeakSet;function qA(e,t,n){const r=e.getInstance(K);if(r?.isDisposed()){Oe("ui",()=>Br(e).disposeAll()),Oe("commands",()=>Ve(e).disposeAll());return}Lc.get(e)?.dispose();const o=new de([jA(e,t),GA(n)]);Lc.set(e,o),r?.addDisposable(o),r&&!Nc.has(e)&&(Nc.add(e),r.addDisposable(BA(e)))}function WA(e){return e?.lockEditor===!0}var Mc={text:"text",img:"image",a:"link",button:"button",div:"container",vindent:"spacer",video:"video",table:"table",customTable:"table",structure:"row",column:"column",td:"cell",var:"variable",countdown:"countdown",carousel:"carousel",accordion:"accordion",social:"social",floatBlock:"floatingBlock"};function zA(e){return typeof e=="string"&&Object.hasOwn(Mc,e)&&Mc[e]||"none"}function vn(e,t,n){let r,o;const s=()=>{const i=e.getInstance(t);return i===void 0||r?r!==void 0:(r=n(i),!0)};return s()||(o=e.onInject(i=>{i===t&&s()&&o?.dispose()})),{dispose:()=>{o?.dispose(),r?.dispose()}}}function KA(e){const t=Xt(e),n={editor:!1,document:!1},r=()=>en(t,{readOnly:n.editor||n.document});r();const o=[Qs(e).watch(s=>en(t,{headless:s})),Vr(e).watch(({isCodeMode:s})=>en(t,{codeMode:s})),vn(e,he,s=>s.watch(i=>{n.editor=WA(i),r()})),vn(e,zt,s=>{let i,a;const c=()=>{const f=s.sessionKey(),v=f!==void 0&&!ee(f)?s.current()?.get().attributes:void 0;n.document=v?.lock===!0&&!Kl(e,v),r()},l=()=>{const f=s.sessionKey();en(t,{documentOpen:f!==void 0,documentKind:f===void 0?void 0:ee(f)?"block":"email"});const v=s.current();v!==i&&(a?.(),i=v,a=v?.subscribe(c)),c()};l();const u=s.subscribe(l),d=Im(e,c);return{dispose:()=>{u(),a?.(),d.dispose()}}})];return o.push(vn(e,hl,s=>{const i=()=>{const l=s.getState(),u=Pe(t)?.documentKind==="block"?l.blockSlice:l.emailSlice;en(t,{selection:zA(u?.elementSettings?.type)})};i();const a=t.select(l=>l?.documentKind).watch(i),c=s.subscribe(i);return{dispose:()=>{c(),a.dispose()}}})),{dispose:()=>o.forEach(s=>s.dispose())}}var XA=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],YA=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],Ir=new Map([...XA.map(e=>[e,"event"]),...YA.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),JA=new Map([["use","use `useAsync()` or await `ready` first"]]);function QA(e){return JA.get(e)??"await `ready` first"}var ZA=new Set(["async","queued"]),eT=Symbol.for("emailmaker.earlyCtxPlaceholder");function Fc(e){return e[eT]=!0,e}function tT(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${QA(e)}).`)}function nT(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function rT(e){return[...Ir].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function oT(e,t){for(const n of rT(e)){const r=Ir.get(n);if(r!==void 0&&ZA.has(r)){const o=async(...s)=>{await t;const i=e[n];if(typeof i!="function"||i===o)throw nT(n);return i.apply(e,s)};e[n]=Fc(o);continue}e[n]=Fc(()=>{throw tT(n)})}}function sT(e,t,n){e.getInstanceAsync(jt).then(()=>{On(e,H.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function iT(e,t){e.getInstanceAsync(jt).then(()=>{On(e,H.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var aT=vp(e=>{let t;function n(){return new Promise(o=>{const s=e.getOrCreateInstance(ws,()=>new Set),i=()=>{s.delete(i),o()};s.add(i)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const s=e.getInstance(Gt),i=e.getInstance(Pf);if(!t){t=new Tp(s,i,{ensureHostRuntimeReady:kA,explainScriptFailure:xA,openEarlyWindow:()=>KI(e),reportLoadFailure:l=>iT(e,l)}),e.inject(Is,t),qA(e,t,i);const c=t.onLifecycle(l=>{l.type==="create:error"&&sT(e,l.name,l.error)});e.getInstance(K)?.addDisposable(c),e.getInstance(K)?.addDisposable(KA(e))}const a=o?.plugins||[];s&&(Qs(e),a.length>0&&oT(s,n()),await t.setPlugins(a))},instance:{use(o){return typeof o=="function"?r().useByCtor(o):r().useByKey(o)},useAsync(o){return r().useAsync(o)},waitPlugin(o){return r().waitFor(o)}},dispose(){t?.dispose(),t=void 0}}});async function cT(){return(await jn()).asyncMixins}var lT=aT,uT=e=>{let t=null,n=null,r=!1;const o=async()=>{let s;try{s=await cT()}catch(c){throw e.failPendingWaits(c),c}const i=s(e),a=await e.getInstanceAsync(Gt);Object.assign(a,i.instance||{});for(const c of e.getInstance(ws)??[])c();return i};return{instance:{},async setOptions(s){!t&&!r&&(n??=o().catch(i=>{throw n=null,i}),t=await n),t&&await t.setOptions(s)},dispose(){t?.dispose(),r=!0}}},dT=class{_context;constructor(e){this._context=e}tools(){return Wn(this._context.container).tools()}invoke(e,t,n){return Wn(this._context.container).invoke(e,t,n)}turn(e){return Wn(this._context.container).turn(e)}undoTurn(){return Wn(this._context.container).undoTurn()}},Df=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const o=this._listeners.indexOf(r);o>=0&&this._listeners.splice(o,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},fT=B("ELEMENT_INSERT_HTML_PIPELINE"),pT=B("BLOCK_INSERT_HTML_PIPELINE"),hT="application_block_inserted",mT=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(pT,()=>new Df).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Dn,()=>new Pn),o=n?e.bind(n):e;return r.addListener(hT,o,t)}},gT=class{_context;constructor(e){this._context=e}register(e,t){const n=this._context.container,r=bt(n).current(),o={},s={};for(const[i,a]of Object.entries(e)){const{run:c,...l}=a;if(typeof c!="function")throw new Error(`Command "${i}" of "${r.name}" has no \`run\`; declare it with defineCommand({ title, run }).`);o[i]=l,s[i]=c}return Ve(n).register(r,o,s,t)}run(e,...t){return Ve(this._context.container).run(e,t[0],{caller:"plugin"})}has(e){return Ve(this._context.container).has(e)}},vT=class{_context;constructor(e){this._context=e}onWillSave(e){const t=this._context.container;return Ze(t).onWillSave(bt(t).current(),e)}onDidChange(e){const t=this._context.container;return Ze(t).onDidChange(bt(t).current(),e)}get selection(){return Ze(this._context.container).selection}transaction(e){return Ys(this._context.container).group(e)}},_i=B("ComponentRegistry"),_T=B("ComponentRegistryGate");function bi(){return Ge.getOrCreateInstance(_T,()=>({pending:[]}))}function bT(e=_i){return bi().factory!==void 0||Ge.getInstance(e)!==void 0}function fs(e,t,n=_i){if(bT(n)){t(Ar(e,n));return}bi().pending.push(()=>t(Ar(e,n)))}function Ar(e,t=_i){const n=Ge.getInstance(t);if(n)return n;const r=bi().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return Ge.getOrCreateInstance(t,r)}var yT=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=s=>{if(!n){n=!0;for(const i of t)i.dispose();e(s)}};t.push(this._container.addService($n,{execute:s=>{r(s.value.map(i=>({name:i.name,html:i.html})))}}));const o=this._container.getInstance(Jp)?.watch(s=>{s&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService($n,{execute:r=>{const o=Ar(n),s=r.value.find(i=>i.name===e);if(s){const{icon:i,title:a,fallbackTooltip:c,...l}=t;i&&(s.icon=o.getReactNode(i)),a&&(s.title=o.getReactNode(a)),c&&(s.fallbackTooltip=o.getReactNode(c)),Object.assign(s,l)}}})}delete(e){this._container.addService($n,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService($n,{execute:r=>{const o=Ar(n);r.value.splice(t??r.value.length,0,{...e,title:o.getReactNode(e.title),icon:o.getReactNode(e.icon),fallbackTooltip:o.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(fT,()=>new Df).add(e,t??0,n)}handleInject(e,t,n){return Nt(this._container,Yp).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},ET=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Dn,()=>new Pn)}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 wT(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Bc(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var ST=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Nt(t,Zp),this._closeModalEmitter=Nt(t,eh),this._updateModalEmitter=Nt(t,th)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return fs(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Bc(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;fs(this._container,r=>{const o=s=>s===void 0?void 0:r.getReactNode(s);this._updateModalEmitter.fire(wT({...t,content:o(t.content),title:o(t.title),id:e,modalProps:Bc(r,n)}))})}};function rr(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var IT=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=o=>{this._loadedSettled||(this._loadedSettled=!0,r(o))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=o=>{this._readySettled||(this._readySettled=!0,r(o))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},AT=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Dn,()=>new Pn)}_createScriptHandle(e,t){const n=this._messageService.addListener(Cs,o=>{if(o.key===e){if(o.phase==="load"&&o.status==="success"){r.resolveLoaded();return}if(o.phase==="ready"&&o.status==="success"){r.resolveReady();return}if(o.phase==="load"){r.rejectLoad(new Error(o.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(o.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new IT(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(Dt,{...rr(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(Dt,{...rr(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(Dt,{...rr(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(Dt,{...rr(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},TT=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function ps(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&TT.has(t)}function kf(){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 wo(){return`__settingsPanel:${kf()}`}function So(e,t){return{type:e,props:t}}function CT(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!ps(e)}function jc(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(ps(t)){const r=wo();return n(e.add(r,t)),So(r,{})}if(typeof t=="function"){const r=wo();return n(e.add(r,t)),So(r,{})}if(CT(t)){const r=t.type;if(typeof r=="string")return t;if(ps(r)||typeof r=="function"){const o=wo();return n(e.add(o,r)),So(o,t.props)}return t}return t}var OT=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??kf();fs(this._container,n=>{const r=i=>this._trackRegistration(i),o=jc(n,e.content,r),s=e.advancedTabs?.map(i=>({...i,content:jc(n,i.content,r)}));Nt(this._container,xi).fire({...e,content:o,advancedTabs:s,instanceKey:t,type:Qp})})}closeSettingsPanel(){this._clearPanelRegistrations(),Nt(this._container,xi).fire(null)}},PT=class{_context;constructor(e){this._context=e}get apiVersion(){return this._service().apiVersion}supports(e,t){return this._service().supports(e,t)}addViews(e,t){return this._service().addViews(this._owner(),e,t,this._context)}addItem(e){return this._service().addItem(this._owner(),e)}open(e,...t){return this._service().open(e,t[0])}_service(){return Br(this._context.container)}_owner(){return bt(this._context.container).current()}},xf=Xs({SandboxScriptApi:AT,ElementsApi:yT,BlocksApi:mT,MessageService:ET,SettingsPanelApi:OT,ModalApi:ST,Commands:gT,Ui:PT,Agent:dT,Document:vT});function Io(e,t,n,r={}){const o=Object.assign({},e);for(const[s,i]of Object.entries(t))if(i!==void 0)if(n.includes(s)&&typeof i=="object"&&i!==null){const a=o[s],c=r[s]??{};o[s]=Object.assign({},typeof a=="object"&&a!==null?a:c,i)}else o[s]=i;return o}var Fe={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}},RT={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"},Ao={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},Uc={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Tt={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:Fe.border,borderRadius:Fe.borderRadius,textAlign:"center",padding:Fe.padding},$c={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Fe.padding},To={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Fe.border,borderRadius:Fe.borderRadiusCards};function DT(e){return{...RT,...e}}function kT(e){return{...Ao,...e,bold:e?.bold??Ao.bold,italic:e?.italic??Ao.italic}}function xT(e){return{...Uc,...e,underline:e?.underline??Uc.underline}}function LT(e){return{...Tt,...e,bold:e?.bold??Tt.bold,italic:e?.italic??Tt.italic,border:{...Tt.border,...e?.border},borderRadius:{...Tt.borderRadius,...e?.borderRadius},padding:{...Tt.padding,...e?.padding}}}function NT(e){return{...$c,...e,padding:{...$c.padding,...e?.padding}}}function MT(e){return{...To,...e,border:{...To.border,...e?.border},borderRadius:{...To.borderRadius,...e?.borderRadius}}}function Co(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 Hc(e){let t={...Bs};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Oo(e){return{text:DT(e.text),headings:kT(e.headings),links:xT(e.links),buttons:LT(e.buttons),block:NT(e.block),cards:MT(e.cards)}}var hs=B("EmailSettingsPort");function FT(e){return e?.getInstance(hs)}var BT=1e4,Lf=class{_editor;_layoutSettingsChanged=new Lo;_contentStylesChanged=new Lo;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!vf(this._editor.container)||!kt(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(hs);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Co(this._settings().read())}_getCurrentContentStyles(){const e=kt(this._editor.container)?.current()?.get().attributes.common_styles;return Oo(Hc(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(hs),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Dn,()=>new Pn),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const o=r?.data,s=o?.operation;if(s===X.APPLICATION_EMAIL_SETTINGS_SET){const c=Co(o?.settings),l=this._getLayoutSnapshot(c);l!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=l,this._layoutSettingsChanged.fire(c));return}if(s!==X.APPLICATION_COMMON_STYLES_UPDATE)return;const i=Oo(r.data?.settings?.commonStyles??{...Bs}),a=this._getContentSnapshot(i);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(i))})})();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=Co(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=BT){const t=kt(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,o=ke(r,H.ON_EMAIL_INIT_ID);return new Promise(s=>{let i=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},l=o(()=>{i||(i=!0,c(),l.dispose(),s())});a=setTimeout(()=>{i||(i=!0,l.dispose(),s())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=kt(this._editor.container)?.current();if(!t)return;const n=Hc(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=Io(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Fe.border,borderRadius:Fe.borderRadius,padding:Fe.padding})),e.block!==void 0&&(n.block=Io(n.block||{},e.block,["padding"],{padding:Fe.padding})),e.cards!==void 0&&(n.cards=Io(n.cards||{},e.cards,["border","borderRadius"],{border:Fe.border,borderRadius:Fe.borderRadiusCards}));const r=JSON.stringify(n);Ut(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=Oo(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},jT={...xf,...Xs({EmailSettingsApi:Lf})};function UT(e){const t=e;return Rf.has(e)&&ds.has(t)&&!Ju(ds.get(t),e)}function $T(e){ds.addAll(Object.fromEntries(Object.entries(e).filter(([t])=>!UT(t))))}var HT={...xf},AP={...HT,...Xs({EmailSettingsApi:Lf})},VT={...jT};function GT(){$T(VT)}function Po(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const s of r.values())s();r.clear()}return{event(s,i,a){const c=Symbol("subscription");return t||(n.set(c,{listener:s,priority:i,thisArg:a}),e&&r.set(c,e(s,i,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(s){o(),e=s;for(const[i,{listener:a,priority:c,thisArg:l}]of n)r.set(i,s(a,c,l))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function qT(e){const t=Po(),n=Po(),r=Po();return e.getInstance(K)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(jt).then(o=>{t.attach(o.onNotify),n.attach(o.onError),r.attach(o.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(o){const s=e.getInstance(jt);if(s){s.notify(o);return}e.getInstanceAsync(jt).then(i=>i.notify(o),()=>{})}}}function Nf(e,t,n=!0){const r=e,o=t;for(const s of Object.keys(o)){const i=o[s];i!=null&&(n&&typeof i=="object"?r[s]=Nf(r[s]||{},i,!0):r[s]=i)}return e}async function WT(e){const t=(await bp(()=>import("./static/esm/2490dab8.js").then(n=>dl(n.default)),[],import.meta.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var Mf=B("EditorOptions"),ms=wm;function zT(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function KT(e){return e.getOrCreateInstance(Mf,()=>{const t=ae(ms);let n=ms.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(WT(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function XT(e){return e?.getInstance(Mf)?.get()??ms}function YT(e,t={}){const n=KT(e);n.set(Nf({...n.get()},zT(t)))}function JT(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function QT(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var ZT=B("plugin.publicConfig");function gs(e){return e.getInstance(he)?.get()??{}}function Vc(e){return e.getInstance(he)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Gc(e){const t=Ud(e),n=gs(e);return{...n,locale:n.locale||"en_US",theme:n.theme||"light",editor:QT(XT(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function qc(e){return e.getInstance(he)?.get()!==void 0}function eC(e){const t=pi(),n=ye(e,pl);let r,o,s=!1;const i=async()=>{try{return e.getInstance(Ke)===void 0?{}:(await e.getInstanceAsync(Ke))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:d=!1}={})=>{await e.getInstance(he)?.ready(),ql(e).set(gs(e).revisionService===!0);const{codeModeDirection:f,editor:v}=gs(e);v&&YT(e,JT(v)),f!==void 0&&!(d&&f===o)&&(o=f,f==="none"?Qo(e,!1):(Qo(e,!0),hE(e,f)))},c=async()=>{if(!qc(e))return;const d=Gc(e),f=JSON.stringify(d);f!==r&&(r=f,await n.fire(d))},l=async d=>{const f=e.getInstance(he),v={advancedConfigs:Vc(e).advancedConfigs,serverSide:await i(),user:d};f?.setAdvancedConfigs({...v.advancedConfigs,...v.user?.advancedConfigs});const g=f?.layers().user.mode;f?.replace(v.user?.mode===void 0&&g!==void 0?{...v.user,mode:g}:v.user,"user"),f?.replace(v.serverSide,"server"),await a(),await c()},u=d=>{const{commonStyles:f,...v}=d;return"commonStyles"in d&&gE(e,f===void 0?void 0:f),v};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:i,getConfig:()=>qc(e)?Gc(e):{},setConfig:t.decorate(async d=>{await l(u(d))}),updateConfig:t.decorate(async d=>{const f=u(d);await l({...Vc(e).user,...f})}),announceAssembled(){s||(s=!0,e.getInstance(he)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function Ff(e){return e.getOrCreateInstance(ZT,()=>eC(e))}function tC(e){const t=Ff(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Bf=B("CodeErrors"),nC=[];function rC(e){return e?.getInstance(Bf)?.get()??nC}function oC(e){return e?.getInstance(Bf)!==void 0}function sC(e){const t=nd(e);let n;const r=()=>{const s=e.getInstance(he);return s&&!n&&(n=s.watch(i=>t.set(i?.agent??{}))),n!==void 0},o=r()?void 0:e.onInject(s=>{s===he&&r()&&o?.dispose()});return{dispose:()=>{o?.dispose(),n?.dispose()}}}function iC(e){const t=Ze(e);return vn(e,zt,n=>{let r,o;const s=()=>{const c=n.sessionKey();c!==void 0&&t.emitChange({kind:ee(c)?"block":"email"})},i=()=>{const c=n.current();c!==r&&(o?.(),r=c,o=c?.subscribe(s),c&&s())};i();const a=n.subscribe(i);return{dispose:()=>{a(),o?.()}}})}function aC(e,t){if(e===t)return!0;try{return Ae(JSON.parse(e||"{}"),JSON.parse(t||"{}"))}catch{return!1}}var TP=B("planFeatures.source");function Ro(e){return Re(e)?.current()}function cC(e){return Pe(Xt(e))?.readOnly===!0}var lC=()=>ue("readOnly","The document is read-only.");function uC(e,t){return!1}var dC=e=>ue("lockedByPlan",e);function fC(e,t,n){return uC(e,t)?dC(`Working with ${n} is not available on the current plan.`):void 0}function pC(e){return fC(e,"undo_redo","undo and redo")}var hC=_m+bm;function jf(e){const t=pe(e);return t.isInited()&&!!t.getTarget()}async function mC(e,t){const n=pe(e);if(!jf(e))return ue("unavailable","The canvas is not open.");try{const r=await Sd(n.sendAsync(X.SANDBOX_ELEMENT_OPERATION,t),hC,"sandbox:element");if(!r)return ue("unavailable","The canvas does not support element commands.");if(r.ok)return vt(r.value);const o=r;return ue(o.code,o.message)}catch(r){if(r instanceof wd)return ue("unavailable","The canvas did not answer in time.");throw r}}var Uf=["subject","preheader","title","utm_parameters","common_styles","meta"],gC={id:0,below:0},Wc=()=>({code:"nothingToUndo",message:"The last answer changed nothing that could be undone."}),Ct=e=>({code:"undoConflict",message:e});function vC(e,t,n){return e==="common_styles"?aC(t,n??""):Ae(t,n)}function zc(e,t){return Object.fromEntries(Uf.filter(n=>!vC(n,e[n],t[n])).map(n=>[n,e[n]]))}function _C(e){const t=()=>{const n=Ro(e);if(!n)return;const{docId:r,attributes:o}=n.get();return{docId:r,step:Re(e)?.history()?.currentStep()??gC,fields:Object.fromEntries(Uf.map(s=>[s,o[s]]))}};return{document:()=>Ro(e)?.get().docId,capture:t,undoRefusal:()=>pC(e)?.error,settle:async()=>{if(jf(e))return(await mC(e,{op:"settle"})).ok?void 0:Ct("The canvas did not answer, so edits made after the answer cannot be ruled out.")},undo:(n,r)=>{const o=n,s=r;if(!o)return Wc();if(s?.docId!==o.docId)return Ct("The answer ended on another email.");const i=s.step.id!==o.step.id,a=zc(o.fields,s.fields);if(!i&&Object.keys(a).length===0)return Wc();const c=Ro(e),l=t();if(!c||l?.docId!==s.docId)return Ct("Another email is open now, not the one the answer changed.");if(cC(e))return lC().error;if(l.step.id!==s.step.id||Object.keys(zc(l.fields,s.fields)).length>0)return Ct("The email was edited after the answer.");if(i&&s.step.below!==o.step.id)return Ct("The answer moved through the undo history itself and cannot be taken back as one step.");if(i&&!Re(e)?.history()?.tryUndo())return Ct("The step of the answer could not be undone: the text changed under it.");Object.keys(a).length>0&&(c.mutate({attributes:a},{source:"user"}),FT(e)?.markAppearanceChanged())}}}function bC(e){let t;return Ys(e).connect({begin:()=>{t??=Re(e)?.history()?.beginTransaction()},end:()=>{const n=t;t=void 0,n?.()},answers:_C(e)})}function yC(e){const t=Ze(e).selection,n=pe(e),r=()=>t.set(null),o=n.addListener(a=>{const c=a?.data;c?.operation===X.APPLICATION_ELEMENT_SETTINGS_SET?t.set(c.type&&typeof c.elementRef=="string"?c.elementRef:null):c?.operation===X.APPLICATION_ELEMENT_SETTINGS_CLOSE&&r()}),s=En(n,r),i=vn(e,zt,a=>{let c=a.current();return{dispose:a.subscribe(()=>{a.current()!==c&&(c=a.current(),r())})}});return{dispose:()=>{o.dispose(),s(),i.dispose()}}}function EC(e){const t=[sC(e),bC(e),iC(e),yC(e)];return{dispose:()=>t.forEach(n=>n.dispose())}}var wC="SAVE",SC="SAVE_BLOCK",CP="SET_THEME",OP="NOTIFY",PP="SET_CONFIG",RP="UPDATE_CONFIG",$f=class extends de{_options;_listeners=[];constructor(e){super(),this._options=e}fire=e=>{if(!this.isDisposed()){let t;const n=[...this._listeners];for(const r of n){if(t===!1)return!1;t instanceof Promise?t=t.then(o=>o===!1||this.isDisposed()?!1:r(o)).catch(o=>{}):t=r(e)}return t}};addEventListener=e=>{const t=this._listeners,n=this._options;return t.push(e),t.length===1&&this._options?.onFirstListenerAdd&&this._options.onFirstListenerAdd(),{dispose:()=>{const r=t.indexOf(e);r>=0&&(t.splice(r,1),t.length||n?.onFirstListenerAdd&&n.onLastListenerRemove())}}};event=this.addEventListener},Kc;(function(e){function t(o){let s;const i=new $f({onFirstListenerAdd(){s=o(i.fire)},onLastListenerRemove(){s.dispose()}});return i.event}e.snapshot=t;function n(o,s){return t(i=>o(a=>s(a)&&i(a)))}e.filter=n;function r(o,s){return t(i=>o(a=>i(s(a))))}e.map=r})(Kc||(Kc={}));var IC=B("helpers.commandEmitter");function AC(e,t,n){e instanceof lp||(e=dh(e)),e.getOrCreateInstance(IC,()=>new $f).fire({id:t,payload:n})}function TC(e,t,{yieldable:n=!1,details:r,prepare:o}={}){const s=Ve(e),i=new Map,a=new Set,c=s.commands.watch(()=>{s.disposed||Object.entries(t).forEach(([l,{declaration:u,handler:d}])=>{const f=s.info(l)?.owner;f?n&&f!==_t&&!a.has(l)&&(a.add(l),`${l}${f.name}`,void 0):(a.delete(l),i.set(l,s.register(_t,{[l]:u},{[l]:d},{},{yieldable:n,details:r,prepare:o})))})});return{dispose:()=>{c.dispose(),i.forEach(l=>l.dispose())}}}var yi="document.getSnapshot",CC="document.save",Hf=Symbol.for("emailmaker.legacyEmailSnapshot"),vs=Symbol.for("emailmaker.legacyEmailSnapshotError");function OC(e,t){return Object.defineProperty(e,Hf,{value:t})}function PC(e){return OC({kind:"email",id:e.id==null?null:String(e.id),content:e.code??"",subject:e.subject??"",preheader:e.preheader??""},e)}function RC(e){return{kind:"block",id:e.id==null?null:String(e.id),content:e.code??"",subject:"",preheader:""}}function DC(e,t){return TC(e,{[yi]:{declaration:{title:"Get document snapshot",description:"Returns the open document: kind, id, HTML content, subject and preheader.",agent:{readOnly:!0}},handler:async()=>{try{const n=Re(e),r=ee(n?.sessionKey())?await t.getBlockSnapshot():null;return vt(r?RC(r):PC(await t.readEmailSnapshot()))}catch(n){return Object.defineProperty(ue("internal",n instanceof Error?n.message:String(n)),vs,{value:n})}}},[CC]:{declaration:{title:"Save document",description:"Saves the open document and finishes when the save is done. A save refused by a rule (a plugin check, empty content, too many tags, edits still on their way, the host cancelled it) answers `refused`, and its message names the reason: tell the user.",agent:!0},handler:(n,r)=>MC(e,r.caller)}})}async function kC(e,t){const n=await Ve(e).run(yi,void 0,{caller:"plugin"});if(n.ok===!1){if(vs in n)throw n[vs];return t()}return n.value[Hf]}function xC(e){return Ve(e).info(yi)?.owner===_t}var LC="The host cancelled this save, so nothing was saved. Tell the user; do not repeat the call unless the user asks for it again.";async function NC(e,t,n){const r=await new Promise(a=>{AC(e,t,{source:P_,settle:a})});if(r.ok!==!1)return vt();if(r.reason==="unready")return;const o=n==="agent"?r.refusal??(r.reason==="aborted"?LC:void 0):void 0,s=r.reason==="locked"?"readOnly":r.reason==="aborted"?"aborted":"internal",i=o?ue("refused",o):ue(s,r.message);return r.notified?Object.defineProperty(i,D_,{value:!0}):i}async function MC(e,t){if(Pe(Xt(e))?.readOnly)return ue("readOnly","The editor is read-only.");const n=Re(e)?.sessionKey();if(n!==void 0){const o=ee(n);if(x_(e,o?"block":"email")){const s=await NC(e,o?SC:wC,t);if(s)return s}}const r=e.getInstance(Gt);if(n===void 0||!r)return ue("unavailable","There is no open document to save.");try{return await(ee(n)?r.saveBlock():r.save()),vt()}catch(o){if(o instanceof ze&&o.reason==="locked")return ue("readOnly",o.message);const s=t==="agent"?dg(o):void 0;return s?ue("refused",s):ue("internal",o instanceof Error?o.message:String(o))}}var FC=class extends de{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=Bn(e),this.addDisposable(ke(e,H.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t})),this.addDisposable(DC(e,this)),this.addDisposable(EC(e))}openEmail(){const e=Re(this._container);if(e&&ee(e.sessionKey())&&!e.hasSuspended())throw new Error("[useblocks] no open email: only a block is shown");return sf(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>Se(t,this._container))}async _readProjectBlocks(){const e=await af(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>an(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>is(n,this._container))}async getEmailSnapshot(){return ee(Re(this._container)?.sessionKey())||!xC(this._container)?this.readEmailSnapshot():kC(this._container,()=>this.readEmailSnapshot())}async readEmailSnapshot(){return De(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Re(this._container),t=e?.current();return!e||!t||!ee(e.sessionKey())?null:(await t.whenReady(),Se(Hr(t),this._container))}setEmailMeta(e){const t=ui(this._container);if(!t)return;const n=t.get().attributes.meta;Ut(t,{meta:Jn({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&Jn(o,e))}setBlockMeta(e,t){const n=Re(this._container);if(n?.sessionKey()===mr(e)){const o=n.current();o&&Ut(o,{meta:Jn({meta:o.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,s=>s&&Jn(s,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return oC(this._container)?rC(this._container):void 0}},BC=B("EmailDataController");function jC(e){return e.getOrCreateInstance(BC,()=>{const t=new FC(e);return e.getInstance(K)?.addDisposable(t),t})}function UC(e){const t=jC(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function $C(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function HC(e){let t;const n=Wd(e),r=ke(e,H.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:s})=>{t=s}));const o=()=>t?$C(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:s=>o()?.getPast(s)??[],getFuture:s=>o()?.getFuture(s)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:s=>o()?.restoreSnapshot(s)}}}var VC=B("plugin.mountElement");function GC(e){const t=e.getInstance(_e)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function qC(e){return e.getOrCreateInstance(VC,()=>{let t=!1,n;return{get:()=>t?n:GC(e),set(r){t=!0,n=r}}})}function WC(e){const t=qC(e);return{getElement:()=>t.get()}}var mt="options.announced",Xc={passes:[mt],awaits:[Fs]},Vf=B("plugin.optionsEvents");function zC(e){const t=e.getInstance(K),n=t.addDisposable(new et),r=t.addDisposable(new et),o=On(e,pl),s={handleSetOptions:V(n.event),handleOptionsChanged:V(r.event),handleConfigChanged:_f(V(o.event),e)};e.inject(Vf,s);const i=t.addDisposable(new Bt(s.handleSetOptions)),a=t.addDisposable(new Bt(s.handleOptionsChanged)),c=t.addDisposable(new Bt(s.handleConfigChanged)),l=async d=>{await n.fire(d),await r.fire(d)},u=Wt(e).each((d,f)=>{i.setListener(f.handleSetOptions),a.setListener(f.handleOptionsChanged),c.setListener(f.handleConfigChanged),Ff(e).announceAssembled(),d.hold(l(f).then(()=>d.reach(mt)))});t.addDisposable(u)}function KC(e){return{...e.getInstance(Vf)}}function XC(e=Gl){const t=new Error(e);return t.name="AuthPipelineError",t}async function Gf(e,t,n,r){const o=r?.attemptTimeout??Mt(n),s=Mt(n)?Ll(n):kn(n).length>0?[yn(n)]:[];if(s.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const i=e.startsWith("/")?e:`/${e}`;let a,c;for(let l=0;l<s.length;l++){const u=s[l],d=l===s.length-1,f=o?Ml(t.signal):void 0;try{const v=await fetch(`${u}${i}`,{...t,...f?{signal:f.signal}:{}});if(!v.ok&&Fl(v.status)){if(a=v,!d){pr(u,n);continue}break}return v.ok&&Ul(u,n),v}catch(v){const g=f?.timeoutError();if(!g&&!Bl(v))throw v;c=g||v,d||pr(u,n)}finally{f?.done()}}if(Mt(n)&&$l(),a)return a;throw c instanceof Error?c:new Error("[apiOriginFailover] fetch chain failed")}function Yc(e){e.inject(rn,void 0),e.inject(xo,void 0)}function YC(e){let t,n;const r=pi();return e.addService(wt,{execute:r.decorate(async(o,s)=>{if(s?.public||!t)return;const i=String(e.getInstance(xo)||"").trim();if(i){o.headers.append("authorization",`Bearer ${i}`);return}if(!e.getInstance(rn))try{const a=e.getInstance(Hl),c=String(a?.getOptions()?.baseUrl||"").trim(),l=Nl(n||c||void 0);if(!l)throw new Error("JWT auth requires baseUrl");const u=await Gf("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},l);if(!u.ok)throw new Error(`JWT auth failed: ${u.status}`);const d=await u.json(),f=String(d.token||"").trim();if(!f)throw new Error("JWT auth failed: empty token");e.inject(rn,void 0),e.inject(xo,f),o.headers.append("authorization",`Bearer ${f}`)}catch{throw e.inject(rn,Gl),XC()}})}),{apply(o){const s=o.jwtAuth,i=String(o.baseUrl||"").trim()||void 0,a=!Ae(s,t),c=i!==n;if(t=s,n=i,!s){Yc(e);return}a||c?Yc(e):e.inject(rn,void 0)}}}function JC(e){const t=YC(e),n=Wt(e).each((r,o)=>{r.whenReached(mt,()=>t.apply(o))});e.getInstance(K)?.addDisposable(n)}function QC(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function ZC(e){if(!e)return;const t=Ss(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}function eO(e,t){if(e.getInstance(Ai))return;e.inject(Ai,!0);const n=ke(e,H.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var Tr="standalone.keyDecided";function tO(e){let t,n=!1;return{apply(r,o){const s=o??n,i=n;if(s&&!i&&(t=e.getInstance(je)||void 0),n=!0,!Nn(r)){t&&(JE(e),si(r)),t=void 0;return}const a=Gr(r);if(!a||i&&t===a&&e.getInstance(je))return;t=a,e.inject(je,a);const c=e.getInstance(K);c&&eO(e,c)}}}function nO(e){const t=tO(e);let n=0;const r=Wt(e).each((o,s)=>{const i=n>0;n+=1,o.whenReached(mt,()=>{t.apply(s,i),o.reach(Tr)})});e.getInstance(K)?.addDisposable(r)}var Jc=new WeakMap;async function rO(e){if(e.getInstance(Ke)!==void 0)try{return await e.getInstanceAsync(Ke)}catch{return}}async function oO(e,t){const n=Jc.get(e),r=n?.getAuthToken!==t.getAuthToken||!Ae(n?.user,t.user)||n?.project!==t.project;if(Jc.set(e,{getAuthToken:t.getAuthToken,user:t.user,project:t.project}),!(!e.getInstance(je)||!t.getAuthToken||!r))try{const o=await t.getAuthToken(t.user,t.project);e.inject(_p,Promise.resolve(o||""));const s=ZC(o);if(!s)return;e.inject(ap,s),e.inject(Ke,Promise.resolve(QC(s,await rO(e))))}catch{}}function sO(e){const t=Wt(e).each((n,r)=>{n.whenReached(Tr,()=>{n.hold(oO(e,r).then(()=>n.reach(Rr)))})});e.getInstance(K)?.addDisposable(t)}var iO=[{name:"options.events",reaches:[mt],setup:zC},{name:"standalone.immediate",awaits:{signals:[mt]},reaches:[Tr],setup:nO},{name:"auth.jwt",awaits:{signals:[mt]},setup:JC},{name:"standalone.bootstrapToken",awaits:{signals:[Tr]},reaches:[Rr],setup:sO}],aO=[KC,pw,rA,qT,tC,UC,HC,WC,kw];function cO(e,t=aO){const n=gi(e);OA(e),GT();for(const f of Ms(iO))f.setup(e);const r=lT(e),o=uT(e),s={...r.instance,...o.instance};for(const f of t)Object.assign(s,f(e));let i=!0;const a=Wt(e);let c=-1,l,u=0;const d=async(f,v,g)=>{const y=P=>{if(v.failed)throw P};for(const P of Xc.passes)await v.passed(P).catch(y);for(const P of Xc.awaits)v.isReached(P)||await v.reached(P).catch(y);if(c>g){await l?.outcome;return}c=g,l=v;const E=i&&n.get()===f;i=!1,E||n.set(f),await r.setOptions(f),await o.setOptions(f)};return{instance:s,async setOptions(f){const v=u++,g=a.begin(f),y=d(f,g,v);g.hold(y),await y,await g.outcome}}}function lO(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var uO=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]}},dO="editor-runtime.react.copies",Do=8;function In(e){return e&&typeof e=="object"?e:void 0}function Qc(e){const t=In(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=In(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function fO(e){const t=In(e),n=t&&typeof t.version=="string"?t.version:void 0,r=In(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function pO(e,t,n){return e.package===t&&e.version===n}function hO({ourReact:e,entries:t,packageName:n,version:r}){const o=Qc(e);if(!o||!Array.isArray(t))return[];const s=[],i=new Set;for(const a of t){const c=In(a);if(!c||!pO(c,n,r))continue;const l=Qc(c.react);!l||l===o||i.has(l)||(i.add(l),s.push({package:n,version:r,reactVersion:fO(c.react),react:c.react}))}return s}function mO({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,Do))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Do&&n.push(` …and ${t.length-Do} 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(`
1062
+ `)}var Zc=new Set;function gO({packageName:e="useblocks",version:t="1.3.16",log:n=r=>{}}={}){const r=o=>{try{const s=globalThis[Symbol.for(dO)],i=hO({ourReact:o,entries:s,packageName:e,version:t}).filter(a=>!Zc.has(a.react));if(!i.length)return;i.forEach(a=>Zc.add(a.react)),n(mO({packageName:e,copies:i}))}catch{}};try{const o=Ts()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function vO(e,t,n){ie(e.signal);const r=t??Ge.createChild();gi(r);const o=r.getInstance(K);let s;async function i(){r.inject(_l,lO(new uO)),gO();const a=cO(r),c={...a.instance,container:r,get ready(){return s??Promise.resolve(c)},async reset(l){if(ie(l.signal),o.isDisposed())throw Be();return await a.setOptions(l),c}};r.inject(Gt,c);try{if(n?.onInstance?.(c),await a.setOptions(e),ie(e.signal),o.isDisposed())throw Be();if(o.isDisposed()||await eA(r),e.devTools)try{const l=r.getInstance(Is);l&&await(await jn()).initDevTools(r,l)}catch{}return ie(e.signal),On(r,fl).fire(c),c}catch(l){throw o.dispose(),l}}try{return s=fr(i(),e.signal),s.catch(()=>{}),await s}catch(a){throw o.isDisposed()||o.dispose(),a}}var An=new WeakMap;function _O(e){return e?An.get(e):void 0}function qf(e){try{e.getInstance(K)?.dispose()}catch{}try{e.dispose()}catch{}}function bO(e,t){if(!e)return;const n=An.get(e);n&&n!==t&&qf(n),An.set(e,t)}function yO(e,t){e&&An.get(e)===t&&An.delete(e)}function EO(e){const t=Ge.createChild();return Nn(e)&&t.inject(je,Gr(e)),t}var _n=new WeakMap,wO="data-useblocks-config-styles";function SO(e){return typeof e=="string"?e.trim():""}function el(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function IO(e,t,n){if(!e||typeof document>"u")return null;const r=SO(t),o=_n.get(e),s=n||e;if(!r)return o&&(o.remove(),_n.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==s||o!==s.firstChild)&&el(s,o),o;const i=document.createElement("style");return i.setAttribute(wO,"true"),i.textContent=r,el(s,i),_n.set(e,i),i}function AO(e){if(!e)return;const t=_n.get(e);t&&(t.remove(),_n.delete(e))}function Wf(){return!1}var TO=`
1063
1063
  .blocks-app-initial-spinner-wrapper {
1064
1064
  width: 100%;
1065
1065
  height: 100%;
@@ -1088,7 +1088,7 @@ import{n as wc,r as Sc,t as zd}from"./static/esm/971f1b2c.js";import{$ as Kd,A a
1088
1088
  100% {
1089
1089
  transform: rotate(360deg);
1090
1090
  }
1091
- }`;function _A(){return()=>{}}function yA(e,t){if(!Ld()||!e||typeof document>"u")return _A();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const o=document.createElement("style");o.setAttribute(t,"true"),o.textContent=bA,document.head?.appendChild(o),e.appendChild(n);let i=!1;return()=>{i||(i=!0,n.remove(),o.remove())}}function EA(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function wA({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,i){const s=t.get(o);if(s!==void 0)return s;const a=i().catch(c=>{throw n.has(o)||(n.add(o),r(c)),EA(c)||t.delete(o),c});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var Yi=wA();function Nd(){Yi.clear()}ff(()=>Yi.clear());var pc=new WeakMap;function Xi(e){return uf(e)}function SA(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function IA(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function TA(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 Ji=new WeakMap;function mo(e,t){Ji.set(e,t)}function AA(e){return Ji.get(e)}function CA(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&Ji.get(r)||e,i=Xi(n);if(!i)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await TA(o);if(o.getAuthToken&&!a)throw IA();a&&s.set("authorization",a);const c=await yf("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},i,{attemptTimeout:Mi(o)||void 0});if(!c.ok)throw SA(c.status,c.statusText);return await c.json()}}function RA(e){return JSON.stringify({baseUrl:Xi(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function OA(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function kA(e){return t=>Yi.run(RA(t),()=>(ae("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>ae("appInit:end",{kind:"network"}))))}function PA(e,t){if(Sn(e)||!e.appInit&&!Xi(e.baseUrl)||!OA(e))return e;const n=e.appInit??CA(e,t);let r=pc.get(n);return r||(r=kA(n),pc.set(n,r)),{...e,appInit:r}}var Fd=0;function DA(){return Fd}function xA(){Fd+=1,Nd()}var hc=new WeakMap,mc=new WeakMap,MA=3e4;function LA(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function NA(e,t){try{const n=ri(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+MA}function FA(e){const t=new Map,n=new Map;return async(r,o,i)=>{const s=LA(r,o);if(i)return n.delete(s),t.delete(s),Nd(),e(r,o,i);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let c=t.get(s);return c===void 0&&(ae("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,o,i)).then(l=>{const u=String(l||"").trim();return u&&n.set(s,{token:l,expiresAtMs:NA(u,Date.now())}),l}).finally(()=>{ae("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,c)),c}}function BA(e){if(Sn(e))return e;const t=e.getAuthToken;if(!t)return e;let n=hc.get(t);const r=DA();return(!n||mc.get(t)!==r)&&(n=FA(t),hc.set(t,n),mc.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var jA="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function UA(e){const t=new Error(jA,{cause:e});return t.name="EditorStartFailedError",t}var $A={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function gc(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Bd=["handleLoad","handleDestroy"];function jd(e,t){let n=e;for(const r of Bd){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(i,...s)=>o(t,...s)})}return n}function HA(e){let t,n="pending",r,o,i,s;const a=new Set,c=[],l=new Set;let u,d;const m=new Promise((w,M)=>{u=w,d=M});m.catch(()=>{});const _={},v=w=>t?.[w],E=()=>r??Ke(),y=(w,M)=>{const B=v(w);if(typeof B!="function")throw gc(w);return B.apply(t,M)},k=(w,M)=>{try{return Promise.resolve(y(w,M))}catch(B){return Promise.reject(B)}},C=()=>{const w=t?.container?.getInstance?.(Y);if(!(n!=="ready"||w?.isDisposed()||typeof v("getConfig")!="function"))try{s=y("getConfig",[])}catch{}},F=()=>n==="dead"?Promise.reject(E()):n==="ready"?Promise.resolve():m,T=()=>{for(const[w,M]of lr)M==="field"&&(_[w]=v(w))},R=w=>{const M=v(w.name);w.dispose||typeof M!="function"||n==="dead"||(w.dispose=M.apply(t,w.args))},A=()=>a.forEach(R),D=()=>{for(const w of a){try{w.dispose?.()}catch{}w.dispose=void 0}},O=()=>{T(),A()},h=()=>{i?.delete(O),i=void 0},f=(w,M)=>{const[B,...W]=M;return!Bd.includes(w)||typeof B!="function"?M:[(re,...oe)=>B(_,...oe),...W]},p=(w,M)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof v(w)!="function")throw gc(w);const B={name:w,args:f(w,M)};return a.add(B),R(B),()=>{a.delete(B),B.dispose?.(),B.dispose=void 0}},b=()=>t?.container?.getInstance(we)?.get()?.content,x=()=>{const w=e.element();return w!==void 0&&typeof w!="string"?w:void 0},N=(w,M)=>{switch(M){case"event":return(...B)=>p(w,B);case"async":return(...B)=>(w==="show"&&B[0]!==void 0&&e.shown?.(B[0]),n!=="dead"&&typeof v(w)=="function"?k(w,B):F().then(()=>y(w,B)));case"queued":return(...B)=>{if(n==="dead"){if(w==="notify")return;throw E()}if(n==="pending"){c.push({name:w,args:B});return}return y(w,B)};case"sync":return(...B)=>{if(n==="dead"){if(w==="getConfig")return s;throw E()}if(typeof v(w)!="function")throw new Error(`[emailmaker] \`${w}\` is not available before the editor is ready: ${$A[w]??"await `ready` first"}`);const W=y(w,B);return w==="getConfig"&&(s=W),W};case"element":return()=>{if(typeof v(w)!="function")return x();try{return y(w,[])}catch{return x()}};case"codeErrors":return()=>n==="ready"&&typeof v(w)=="function"?y(w,[]):[];case"field":return}};for(const[w,M]of lr)_[w]=N(w,M);_.reset=w=>(w?.content!==void 0&&e.shown?.(w.content),F().then(async()=>{const M=w?.content!==void 0&&Ne(w.content,b());await y("reset",[jd(w,S)]),M&&await y("show",[w.content])}).then(()=>_)),_.destroy=()=>{if(n==="dead")return;const w=Ie("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),l.forEach(M=>M(w)),C(),e.destroy()},Object.defineProperty(_,"ready",{get:()=>o,enumerable:!0,configurable:!0});const S=_;return{object:S,get state(){return n},get editor(){return t},bind:w=>{n==="dead"||t===w||(D(),h(),t=w,T(),A(),n==="pending"&&(i=w.container.getOrCreateInstance(li,()=>new Set),i.add(O)))},settle:()=>{if(n==="pending"){n="ready",h(),T(),A();for(const w of c.splice(0))try{y(w.name,w.args)}catch(M){queueMicrotask(()=>{throw M})}u()}},kill:(w,M)=>{n!=="dead"&&(C(),n="dead",r=w,c.length=0,l.forEach(B=>B(w)),h(),M?.keepSubscriptions||(D(),a.clear()),d(w))},detach:()=>{D(),a.clear()},setReady:w=>{o=w},trackCall:w=>(l.add(w),()=>l.delete(w)),hasCalls:()=>l.size>0}}var Ud="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function VA(){return Ie(Ud)}function GA(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ud}function qA(e,t,n){if(typeof document>"u")return;let r=!1,o;const i=()=>{r=!0,o?.disconnect(),o=void 0},s=()=>{r||(i(),t())};if(n.addDispose(i),!e.isConnected){queueMicrotask(s);return}o=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function WA(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const i=new AbortController;return qA(n,()=>{n.id,i.abort(VA())},o),oi(r,i.signal)}var $d="Superseded by newer init() on the same mount element";function vc(){return Ie($d)}function zA(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===$d}var Kt=new Map,bc=new WeakMap,qn=new WeakMap;function KA(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function YA(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=KA(e);(n?Kt.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(vc())});const r=bc.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(vc())});const o=qn.get(e)??Promise.resolve();let i;const s=new Promise(u=>{i=u}),a=o.then(()=>s);qn.set(e,a),a.then(()=>{qn.get(e)===a&&qn.delete(e)});const c=new AbortController,l={element:e,controller:c,supersedable:t};if(r.add(l),bc.set(e,r),n){const u=Kt.get(n)??new Set;u.add(l),Kt.set(n,u)}return{signal:c.signal,previous:o,release:()=>{i(),r.delete(l);const u=n?Kt.get(n):void 0;n&&u?.delete(l)&&u.size===0&&Kt.delete(n)}}}var mn=new WeakMap;function Qi(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function ei(e){return Object.entries(e).filter(([t,n])=>Qi(t,n)).map(([t])=>t).sort()}function _c(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!Qi(n,r)&&(t[n]=r);return t}function ti(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:mn.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},mn.set(e,r));const{current:o,trampolines:i}=r;o.clear();const s={...t};for(const a of ei(t)){o.set(a,t[a]);let c=i.get(a);c||(c=(...l)=>o.get(a)?.(...l),i.set(a,c)),s[a]=c}return r.lastOptions=t,s}function Hd(e,t){const n=e?mn.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];Qi(r,o)?n.current.set(r,o):n.current.delete(r)}}function XA(e){const t=e?mn.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,i)=>t.current.set(i,o)),t.lastOptions=r}}function JA(e,t,n){const r=e?mn.get(e):void 0;if(!r||!n)return!1;const o=ei(t),i=Ne(o,ei(r.lastOptions)),s=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!i||!s||!Ne(_c(t),_c(r.lastOptions))?!1:(ti(e,t),!0)}var Be=new WeakMap;function xr(e){let t=Be.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},Be.set(e,t)),t}var Qe=e=>e!==void 0&&e.state!=="dead";function QA(e){const t=Be.get(e)?.shared;return Qe(t)?t:void 0}function ZA(e,t){xr(e).shared=t}function eC(e,t){!(Qe(e.shared)&&[...e.counted].some(Qe))||e.warned||!t.devTools||(e.warned=!0)}function tC(e,t,n,r){const o=xr(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(i=>i.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(i=>i!==t&&Qe(i)),t],eC(o,r),o.latestCall}function nC(e,t){return Be.get(e)?.latestCall===t}function rC(e){const t=Be.get(e);if(t)return t.order=t.order.filter(Qe),t.order.at(-1)?.object}function gn(e,t){const n=Be.get(e);return n?Qe(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&Qe(r)):!1}function oC(e,t){const n=Be.get(e),r=n?.order.filter(o=>o!==t&&Qe(o)).at(-1);return r?n?.options.get(r):void 0}function Vd(e,t){xr(e).content={value:t}}function iC(e){return Be.get(e)?.content}function sC(e,t,n,r){const o=xr(e);if(o.counted.delete(t),o.options.delete(t),gn(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),Gd(e,r)}function Gd(e,t){const n=Be.get(e);!n||gn(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!gn(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function aC(e,t){const n=Be.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);Be.delete(e)}}var y0=wc({FileManagerApiError:()=>cC,IntegratorSaveTimeoutError:()=>mr,SaveRefusedError:()=>He}),cC=class qd extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,o){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=o,Error.captureStackTrace&&Error.captureStackTrace(this,qd)}},E0=wc({mapHttpStatusToErrorCode:()=>nf});function lC(e,t){return{...e,element:t}}function ni(){return()=>{}}function uC(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?ni():(gA(t,e.config?.styles,t),()=>{vA(t)})}function dC(e){if(!Ld()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:ni()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:ni()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=yA(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function fC(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function dr(e){try{e.destroy()}catch{}}function Jn(e,...t){const n=xe.get(e);t.some(r=>r!==void 0&&r===n)&&xe.delete(e)}var w0="1.3.11-dev.3";async function S0(e){Oi(),await zS(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function I0(e){return vC(e).ready}function pC(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function hC(e){const t=xe.get(e);return t&&!(t instanceof Promise)?t:void 0}function fr(e,t,n){const r=t??hC(e);r&&(Jn(e,r),dr(r)),aC(e,n)}function mC(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const s=t.editor;gC(s),t.kill(Ke());return}if(n==="single"){fr(o,t.editor,Ke());return}const i=oC(o,t);sC(o,t,Ke(),()=>fr(o,t.editor,Ke())),i&&gn(o)&&Hd(o,i)}function gC(e){e&&dr(e)}function vC(e){ae(Ee.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=oi(e.signal,n.signal),o=t==="single"?pC(e.element):void 0,i=o?QA(o):void 0;let s;if(i)s={control:i,mode:t,ref:{host:o}};else{const u={},d=HA({element:()=>u.host??e.element,destroy:()=>mC(s),shown:m=>{u.host&&Vd(u.host,m)}});s={control:d,mode:t,ref:u},o&&ZA(o,d)}const{control:a}=s,c=a.trackCall(u=>n.abort(u)),l=wC(jd({...e,signal:r},a.object),s).then(()=>(c(),ae(Ee.initEnd),a.settle(),a.object),u=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const d=s.ref.host;throw d&&Gd(d,()=>fr(d,void 0,Ke())),u});return a.setReady(l),a.object}function T0(e){const t=typeof e=="string"?document.querySelector(e):e;return t?rC(t):void 0}function bC(e){let t,n,r=!1;try{t=e.container.getInstance(we)?.get(),n=e.container.getInstance(Fe)?.externalSignal;const o=At(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:_C(e),dirty:r}}async function _C(e){try{return await e.getEmailSnapshot()}catch{return}}function yC(e){const t=At(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function yc(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||gn(e,n)}async function EC(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),zA(o)||GA(o))return;const i=()=>fr(t,e,UA(o)),{options:s}=n;if(!s||!yc(t,r)){i();return}const a=await n.email,c=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,l=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:c?{...l,email:c}:s.content}),n.dirty&&c&&yC(e),yc(t,r)?xe.set(t,e):i()}catch{i()}}async function wC(e,t){se(e.signal);const n=new ve;let r,o,i,s,a=0;try{const c=await Rf(e.element,n,e.signal);c&&(s=c,t.ref.host=c,a=tC(c,t.control,t.mode,e));const l=WA({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),u=YA(c,{supersede:t.mode==="single"});r=u.release;const d=oi(l,u.signal);se(d),i=XA(c),Hd(c,e),await Qn(u.previous,d),o=SC(e,c,t,d,i);const m=await Qn(o,d);return c&&e.content!==void 0&&Vd(c,e.content),m}catch(c){throw s&&i&&nC(s,a)&&i(),c}finally{const c=r;o!==void 0&&c?o.then(c,c):c?.(),n.dispose()}}async function Ec(e,t,n,r){const o=iC(t);n===void 0||r||!o||Ne(n,o.value)||await e.show(n)}async function SC(e,t,n,r,o){const{control:i}=n,s=E=>i.bind(E);se(r);let a;const c=E=>{xA();const y=BA(lC(E,t)),k=PA(y,()=>a);return{preparedOptions:k,preparedOptionsWithSignal:r!=null?{...k,signal:r}:k}};let l;if(t){const E=xe.get(t);if(E){let y;try{y=await E,se(r)}catch{se(r),Jn(t,E),y=void 0}if(y)if(y.getElement()===t){const k=uA(t);a=k;const C=y.container.getInstance(we)?.get();if(JA(t,e,C))return s(y),r&&y.container.getInstance(Fe)?.relinkExternalSignal(r),xe.set(t,y),await Ec(y,t,e.content,!1),y;const F=!Ne(e.content,C?.content);l=c(ti(t,e));const{preparedOptions:T,preparedOptionsWithSignal:R}=l,A=k&&AA(k),D=bC(y);try{k&&mo(k,T),s(y);const O=await y.reset(fC(e,R));return se(r),xe.set(t,y),await Ec(y,t,e.content,F),O}catch(O){if(k&&A&&mo(k,A),!hp(O))throw o(),await EC(y,t,D,n,O),O;Jn(t,E,y),dr(y),se(r)}}else Jn(t,E,y),dr(y)}}se(r),l??=c(ti(t,e,{fresh:!0}));const{preparedOptions:u}=l,d=uC(u),m=dC(u),_=r!=null?{...m.options,signal:r}:m.options;let v;try{a=pA(_),dA(t,a),mo(a,u),Gi(a).set(_),await qi(),ae(Ee.coreReady),se(r),se(r),v=lA(_,a,{onInstance:s}),t&&xe.set(t,v);const E=await v;if(r?.aborted&&(E.destroy(),se(r)),t)if(xe.get(t)===v)xe.set(t,E);else throw E.destroy(),se(r),Ie(r?.reason);return E}catch(E){throw d(),m.cleanup(),a&&(Md(a),fA(t,a)),t&&v&&xe.get(t)===v&&xe.delete(t),E}}async function A0(e){return(await Cn()).parseAMP(e)}typeof window<"u"&&(ln()&&fp(),YS(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{Ud as ELEMENT_DETACHED_ABORT_MESSAGE,$d as SUPERSEDED_INIT_ABORT_MESSAGE,vC as create,y0 as errors,T0 as getInstance,E0 as helpers,I0 as init,GA as isElementDetachedError,zA as isSupersededInitError,A0 as parseAMP,Yo as pluginRegistry,S0 as preload,w0 as version};
1091
+ }`;function CO(){return()=>{}}function OO(e,t){if(!Wf()||!e||typeof document>"u")return CO();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const o=document.createElement("style");o.setAttribute(t,"true"),o.textContent=TO,document.head?.appendChild(o),e.appendChild(n);let s=!1;return()=>{s||(s=!0,n.remove(),o.remove())}}function PO(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function RO({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,s){const i=t.get(o);if(i!==void 0)return i;const a=s().catch(c=>{throw n.has(o)||(n.add(o),r(c)),PO(c)||t.delete(o),c});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var Ei=RO();function zf(){Ei.clear()}zh(()=>Ei.clear());var tl=new WeakMap;function wi(e){return Nl(e)}function DO(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function kO(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function xO(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 Si=new WeakMap;function ko(e,t){Si.set(e,t)}function LO(e){return Si.get(e)}function NO(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&Si.get(r)||e,s=wi(n);if(!s)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await xO(o);if(o.getAuthToken&&!a)throw kO();a&&i.set("authorization",a);const c=await Gf("/app/v1/app_init",{method:"POST",headers:i,body:new URLSearchParams,credentials:"same-origin"},s,{attemptTimeout:si(o)||void 0});if(!c.ok)throw DO(c.status,c.statusText);return await c.json()}}function MO(e){return JSON.stringify({baseUrl:wi(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function FO(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function BO(e){return t=>Ei.run(MO(t),()=>(ce("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>ce("appInit:end",{kind:"network"}))))}function jO(e,t){if(Nn(e)||!e.appInit&&!wi(e.baseUrl)||!FO(e))return e;const n=e.appInit??NO(e,t);let r=tl.get(n);return r||(r=BO(n),tl.set(n,r)),{...e,appInit:r}}var Kf=0;function UO(){return Kf}function $O(){Kf+=1,zf()}var nl=new WeakMap,rl=new WeakMap,HO=3e4;function VO(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function GO(e,t){try{const n=Ss(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+HO}function qO(e){const t=new Map,n=new Map;return async(r,o,s)=>{const i=VO(r,o);if(s)return n.delete(i),t.delete(i),zf(),e(r,o,s);const a=n.get(i);if(a&&!t.has(i)){if(a.expiresAtMs>Date.now())return a.token;n.delete(i)}let c=t.get(i);return c===void 0&&(ce("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,o,s)).then(l=>{const u=String(l||"").trim();return u&&n.set(i,{token:l,expiresAtMs:GO(u,Date.now())}),l}).finally(()=>{ce("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,c)),c}}function WO(e){if(Nn(e))return e;const t=e.getAuthToken;if(!t)return e;let n=nl.get(t);const r=UO();return(!n||rl.get(t)!==r)&&(n=qO(t),nl.set(t,n),rl.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var zO="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function KO(e){const t=new Error(zO,{cause:e});return t.name="EditorStartFailedError",t}var XO={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function ol(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Xf=["handleLoad","handleDestroy"];function Yf(e,t){let n=e;for(const r of Xf){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(s,...i)=>o(t,...i)})}return n}function YO(e){let t,n="pending",r,o,s,i;const a=new Set,c=[],l=new Set;let u,d;const f=new Promise((S,N)=>{u=S,d=N});f.catch(()=>{});const v={},g=S=>t?.[S],y=()=>r??Be(),E=(S,N)=>{const j=g(S);if(typeof j!="function")throw ol(S);return j.apply(t,N)},P=(S,N)=>{try{return Promise.resolve(E(S,N))}catch(j){return Promise.reject(j)}},O=()=>{const S=t?.container?.getInstance?.(K);if(!(n!=="ready"||S?.isDisposed()||typeof g("getConfig")!="function"))try{i=E("getConfig",[])}catch{}},x=()=>n==="dead"?Promise.reject(y()):n==="ready"?Promise.resolve():f,w=()=>{for(const[S,N]of Ir)N==="field"&&(v[S]=g(S))},C=S=>{const N=g(S.name);S.dispose||typeof N!="function"||n==="dead"||(S.dispose=N.apply(t,S.args))},T=()=>a.forEach(C),D=()=>{for(const S of a){try{S.dispose?.()}catch{}S.dispose=void 0}},R=()=>{w(),T()},m=()=>{s?.delete(R),s=void 0},p=(S,N)=>{const[j,...W]=N;return!Xf.includes(S)||typeof j!="function"?N:[(re,...oe)=>j(v,...oe),...W]},h=(S,N)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof g(S)!="function")throw ol(S);const j={name:S,args:p(S,N)};return a.add(j),C(j),()=>{a.delete(j),j.dispose?.(),j.dispose=void 0}},b=()=>t?.container?.getInstance(_e)?.get()?.content,L=()=>{const S=e.element();return S!==void 0&&typeof S!="string"?S:void 0},F=(S,N)=>{switch(N){case"event":return(...j)=>h(S,j);case"async":return(...j)=>(S==="show"&&j[0]!==void 0&&e.shown?.(j[0]),n!=="dead"&&typeof g(S)=="function"?P(S,j):x().then(()=>E(S,j)));case"queued":return(...j)=>{if(n==="dead"){if(S==="notify")return;throw y()}if(n==="pending"){c.push({name:S,args:j});return}return E(S,j)};case"sync":return(...j)=>{if(n==="dead"){if(S==="getConfig")return i;throw y()}if(typeof g(S)!="function")throw new Error(`[emailmaker] \`${S}\` is not available before the editor is ready: ${XO[S]??"await `ready` first"}`);const W=E(S,j);return S==="getConfig"&&(i=W),W};case"element":return()=>{if(typeof g(S)!="function")return L();try{return E(S,[])}catch{return L()}};case"codeErrors":return()=>n==="ready"&&typeof g(S)=="function"?E(S,[]):[];case"field":return}};for(const[S,N]of Ir)v[S]=F(S,N);v.reset=S=>(S?.content!==void 0&&e.shown?.(S.content),x().then(async()=>{const N=S?.content!==void 0&&Ae(S.content,b());await E("reset",[Yf(S,I)]),N&&await E("show",[S.content])}).then(()=>v)),v.destroy=()=>{if(n==="dead")return;const S=Te("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),l.forEach(N=>N(S)),O(),e.destroy()},Object.defineProperty(v,"ready",{get:()=>o,enumerable:!0,configurable:!0});const I=v;return{object:I,get state(){return n},get editor(){return t},bind:S=>{n==="dead"||t===S||(D(),m(),t=S,w(),T(),n==="pending"&&(s=S.container.getOrCreateInstance(ws,()=>new Set),s.add(R)))},settle:()=>{if(n==="pending"){n="ready",m(),w(),T();for(const S of c.splice(0))try{E(S.name,S.args)}catch(N){queueMicrotask(()=>{throw N})}u()}},kill:(S,N)=>{n!=="dead"&&(O(),n="dead",r=S,c.length=0,l.forEach(j=>j(S)),m(),N?.keepSubscriptions||(D(),a.clear()),d(S))},detach:()=>{D(),a.clear()},setReady:S=>{o=S},trackCall:S=>(l.add(S),()=>l.delete(S)),hasCalls:()=>l.size>0}}var Jf="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function JO(){return Te(Jf)}function QO(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Jf}function ZO(e,t,n){if(typeof document>"u")return;let r=!1,o;const s=()=>{r=!0,o?.disconnect(),o=void 0},i=()=>{r||(s(),t())};if(n.addDispose(s),!e.isConnected){queueMicrotask(i);return}o=new MutationObserver(()=>{e.isConnected||i()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function e0(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const s=new AbortController;return ZO(n,()=>{n.id,s.abort(JO())},o),Pr(r,s.signal)}var Qf="Superseded by newer init() on the same mount element";function sl(){return Te(Qf)}function t0(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Qf}var nn=new Map,il=new WeakMap,or=new WeakMap;function n0(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function r0(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=n0(e);(n?nn.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(sl())});const r=il.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(sl())});const o=or.get(e)??Promise.resolve();let s;const i=new Promise(u=>{s=u}),a=o.then(()=>i);or.set(e,a),a.then(()=>{or.get(e)===a&&or.delete(e)});const c=new AbortController,l={element:e,controller:c,supersedable:t};if(r.add(l),il.set(e,r),n){const u=nn.get(n)??new Set;u.add(l),nn.set(n,u)}return{signal:c.signal,previous:o,release:()=>{s(),r.delete(l);const u=n?nn.get(n):void 0;n&&u?.delete(l)&&u.size===0&&nn.delete(n)}}}var Tn=new WeakMap;function Ii(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function _s(e){return Object.entries(e).filter(([t,n])=>Ii(t,n)).map(([t])=>t).sort()}function al(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!Ii(n,r)&&(t[n]=r);return t}function bs(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Tn.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Tn.set(e,r));const{current:o,trampolines:s}=r;o.clear();const i={...t};for(const a of _s(t)){o.set(a,t[a]);let c=s.get(a);c||(c=(...l)=>o.get(a)?.(...l),s.set(a,c)),i[a]=c}return r.lastOptions=t,i}function Zf(e,t){const n=e?Tn.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];Ii(r,o)?n.current.set(r,o):n.current.delete(r)}}function o0(e){const t=e?Tn.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,s)=>t.current.set(s,o)),t.lastOptions=r}}function s0(e,t,n){const r=e?Tn.get(e):void 0;if(!r||!n)return!1;const o=_s(t),s=Ae(o,_s(r.lastOptions)),i=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!s||!i||!Ae(al(t),al(r.lastOptions))?!1:(bs(e,t),!0)}var $e=new WeakMap;function Yr(e){let t=$e.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},$e.set(e,t)),t}var tt=e=>e!==void 0&&e.state!=="dead";function i0(e){const t=$e.get(e)?.shared;return tt(t)?t:void 0}function a0(e,t){Yr(e).shared=t}function c0(e,t){!(tt(e.shared)&&[...e.counted].some(tt))||e.warned||!t.devTools||(e.warned=!0)}function l0(e,t,n,r){const o=Yr(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(s=>s.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(s=>s!==t&&tt(s)),t],c0(o,r),o.latestCall}function u0(e,t){return $e.get(e)?.latestCall===t}function d0(e){const t=$e.get(e);if(t)return t.order=t.order.filter(tt),t.order.at(-1)?.object}function Cn(e,t){const n=$e.get(e);return n?tt(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&tt(r)):!1}function f0(e,t){const n=$e.get(e),r=n?.order.filter(o=>o!==t&&tt(o)).at(-1);return r?n?.options.get(r):void 0}function ep(e,t){Yr(e).content={value:t}}function p0(e){return $e.get(e)?.content}function h0(e,t,n,r){const o=Yr(e);if(o.counted.delete(t),o.options.delete(t),Cn(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),tp(e,r)}function tp(e,t){const n=$e.get(e);!n||Cn(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Cn(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function m0(e,t){const n=$e.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);$e.delete(e)}}var DP=ul({FileManagerApiError:()=>g0,IntegratorSaveTimeoutError:()=>kr,SaveRefusedError:()=>ze}),g0=class np extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,o){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=o,Error.captureStackTrace&&Error.captureStackTrace(this,np)}},kP=ul({mapHttpStatusToErrorCode:()=>ip});function v0(e,t){return{...e,element:t}}function ys(){return()=>{}}function _0(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?ys():(IO(t,e.config?.styles,t),()=>{AO(t)})}function b0(e){if(!Wf()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:ys()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:ys()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=OO(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function y0(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function Cr(e){try{e.destroy()}catch{}}function dr(e,...t){const n=Ne.get(e);t.some(r=>r!==void 0&&r===n)&&Ne.delete(e)}var xP="1.3.16";async function LP(e){ei(),await LA(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function NP(e){return A0(e).ready}function E0(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function w0(e){const t=Ne.get(e);return t&&!(t instanceof Promise)?t:void 0}function Or(e,t,n){const r=t??w0(e);r&&(dr(e,r),Cr(r)),m0(e,n)}function S0(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const i=t.editor;I0(i),t.kill(Be());return}if(n==="single"){Or(o,t.editor,Be());return}const s=f0(o,t);h0(o,t,Be(),()=>Or(o,t.editor,Be())),s&&Cn(o)&&Zf(o,s)}function I0(e){e&&Cr(e)}function A0(e){ce(we.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=Pr(e.signal,n.signal),o=t==="single"?E0(e.element):void 0,s=o?i0(o):void 0;let i;if(s)i={control:s,mode:t,ref:{host:o}};else{const u={},d=YO({element:()=>u.host??e.element,destroy:()=>S0(i),shown:f=>{u.host&&ep(u.host,f)}});i={control:d,mode:t,ref:u},o&&a0(o,d)}const{control:a}=i,c=a.trackCall(u=>n.abort(u)),l=R0(Yf({...e,signal:r},a.object),i).then(()=>(c(),ce(we.initEnd),a.settle(),a.object),u=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const d=i.ref.host;throw d&&tp(d,()=>Or(d,void 0,Be())),u});return a.setReady(l),a.object}function MP(e){const t=typeof e=="string"?document.querySelector(e):e;return t?d0(t):void 0}function T0(e){let t,n,r=!1;try{t=e.container.getInstance(_e)?.get(),n=e.container.getInstance(Ue)?.externalSignal;const o=kt(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:C0(e),dirty:r}}async function C0(e){try{return await e.getEmailSnapshot()}catch{return}}function O0(e){const t=kt(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function cl(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Cn(e,n)}async function P0(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),t0(o)||QO(o))return;const s=()=>Or(t,e,KO(o)),{options:i}=n;if(!i||!cl(t,r)){s();return}const a=await n.email,c=a&&(i.content!==void 0||a.id!==void 0)?a:void 0,l=typeof i.content=="object"&&"email"in i.content?i.content:void 0;try{await e.reset({...i,signal:i.signal??n.signal,content:c?{...l,email:c}:i.content}),n.dirty&&c&&O0(e),cl(t,r)?Ne.set(t,e):s()}catch{s()}}async function R0(e,t){ie(e.signal);const n=new de;let r,o,s,i,a=0;try{const c=await gp(e.element,n,e.signal);c&&(i=c,t.ref.host=c,a=l0(c,t.control,t.mode,e));const l=e0({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),u=r0(c,{supersede:t.mode==="single"});r=u.release;const d=Pr(l,u.signal);ie(d),s=o0(c),Zf(c,e),await fr(u.previous,d),o=D0(e,c,t,d,s);const f=await fr(o,d);return c&&e.content!==void 0&&ep(c,e.content),f}catch(c){throw i&&s&&u0(i,a)&&s(),c}finally{const c=r;o!==void 0&&c?o.then(c,c):c?.(),n.dispose()}}async function ll(e,t,n,r){const o=p0(t);n===void 0||r||!o||Ae(n,o.value)||await e.show(n)}async function D0(e,t,n,r,o){const{control:s}=n,i=y=>s.bind(y);ie(r);let a;const c=y=>{$O();const E=WO(v0(y,t)),P=jO(E,()=>a);return{preparedOptions:P,preparedOptionsWithSignal:r!=null?{...P,signal:r}:P}};let l;if(t){const y=Ne.get(t);if(y){let E;try{E=await y,ie(r)}catch{ie(r),dr(t,y),E=void 0}if(E)if(E.getElement()===t){const P=_O(t);a=P;const O=E.container.getInstance(_e)?.get();if(s0(t,e,O))return i(E),r&&E.container.getInstance(Ue)?.relinkExternalSignal(r),Ne.set(t,E),await ll(E,t,e.content,!1),E;const x=!Ae(e.content,O?.content);l=c(bs(t,e));const{preparedOptions:w,preparedOptionsWithSignal:C}=l,T=P&&LO(P),D=T0(E);try{P&&ko(P,w),i(E);const R=await E.reset(y0(e,C));return ie(r),Ne.set(t,E),await ll(E,t,e.content,x),R}catch(R){if(P&&T&&ko(P,T),!Vp(R))throw o(),await P0(E,t,D,n,R),R;dr(t,y,E),Cr(E),ie(r)}}else dr(t,y,E),Cr(E)}}ie(r),l??=c(bs(t,e,{fresh:!0}));const{preparedOptions:u}=l,d=_0(u),f=b0(u),v=r!=null?{...f.options,signal:r}:f.options;let g;try{a=EO(v),bO(t,a),ko(a,u),gi(a).set(v),await vi(),ce(we.coreReady),ie(r),ie(r),g=vO(v,a,{onInstance:i}),t&&Ne.set(t,g);const y=await g;if(r?.aborted&&(y.destroy(),ie(r)),t)if(Ne.get(t)===g)Ne.set(t,y);else throw y.destroy(),ie(r),Te(r?.reason);return y}catch(y){throw d(),f.cleanup(),a&&(qf(a),yO(t,a)),t&&g&&Ne.get(t)===g&&Ne.delete(t),y}}async function FP(e){return(await jn()).parseAMP(e)}typeof window<"u"&&(bn()&&$p(),MA(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{Jf as ELEMENT_DETACHED_ABORT_MESSAGE,Qf as SUPERSEDED_INIT_ABORT_MESSAGE,A0 as create,DP as errors,MP as getInstance,kP as helpers,NP as init,QO as isElementDetachedError,t0 as isSupersededInitError,FP as parseAMP,ds as pluginRegistry,LP as preload,xP as version};
1092
1092
 
1093
1093
 
1094
- window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/11009bdf.js":[],"static/core/11dadbc0.js":["static/core/1c3a16fc.js"],"static/core/160bf060.js":[],"static/core/1c06cdb7.js":[],"static/core/1c3a16fc.js":[],"static/core/1c7a6d45.js":["static/core/b9f553d7.js","__delivery__/libs"],"static/core/1ed86ed3.js":[],"static/core/257745eb.js":[],"static/core/261a3a42.js":[],"static/core/2bed6a18.js":["static/core/1c3a16fc.js","static/core/ed65b5c3.js","__delivery__/libs"],"static/core/347b0a0b.js":["__delivery__/libs"],"static/core/3b65bc50.js":["static/core/467344d4.js","static/core/11009bdf.js","static/core/d2cf6b4b.js"],"static/core/3d8e2478.js":[],"static/core/3eeb4445.js":[],"static/core/3fd50a29.js":[],"static/core/467344d4.js":[],"static/core/48da14fd.js":[],"static/core/513e36bd.js":["static/core/94f9492b.js","static/core/7e329493.js","static/core/516f59e7.js"],"static/core/516f59e7.js":["static/core/76543cb2.js"],"static/core/58dca22f.js":[],"static/core/5da33486.js":["static/core/94f9492b.js"],"static/core/6172f09a.js":["static/core/b9f553d7.js","static/core/ff7d14e8.js","__delivery__/libs"],"static/core/62855b97.js":[],"static/core/6561b34a.js":[],"static/core/66113a18.js":["static/core/11009bdf.js"],"static/core/71727873.js":["static/core/76543cb2.js","static/core/7e329493.js","static/core/516f59e7.js"],"static/core/76543cb2.js":[],"static/core/7b850506.js":[],"static/core/7e329493.js":[],"static/core/8406bab5.js":["static/core/516f59e7.js"],"static/core/8845436d.js":["static/core/b9f553d7.js","__delivery__/libs"],"static/core/94f9492b.js":[],"static/core/a6303cb2.js":["static/core/ff7d14e8.js"],"static/core/aee84e3d.js":[],"static/core/b1edf5c5.js":[],"static/core/b55ae539.js":[],"static/core/b59c63d2.js":[],"static/core/b5da36e5.js":[],"static/core/b9f553d7.js":["static/core/e7620593.js","static/core/ff7d14e8.js","__delivery__/libs"],"static/core/bda2d9d5.js":["static/core/b59c63d2.js"],"static/core/c0a3f7d0.js":["static/core/8845436d.js","static/core/ed65b5c3.js","__delivery__/libs","static/core/b9f553d7.js"],"static/core/c13b3d4f.js":[],"static/core/d2cf6b4b.js":["static/core/11009bdf.js"],"static/core/d343e46e.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/d9d5b376.js":[],"static/core/dcc37768.js":[],"static/core/dd008ec2.js":["static/core/347b0a0b.js","__delivery__/libs"],"static/core/e037a420.js":["static/core/b9f553d7.js","static/core/8845436d.js","static/core/1c7a6d45.js","static/core/2bed6a18.js","__delivery__/libs"],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/e698ec22.js":["static/core/1c06cdb7.js"],"static/core/e7620593.js":[],"static/core/e7e888c1.js":[],"static/core/ed65b5c3.js":["static/core/1c3a16fc.js","static/core/1c06cdb7.js","static/core/b59c63d2.js","static/core/76543cb2.js","static/core/347b0a0b.js","__delivery__/libs"],"static/core/ef035f6b.js":["static/core/467344d4.js"],"static/core/f1b8515a.js":[],"static/core/f8585ce6.js":[],"static/core/fb2fe2db.js":[],"static/core/ff7d14e8.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/971f1b2c.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/971f1b2c.js","static/esm/c5372168.js","static/esm/f76c9d9d.js"],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/971f1b2c.js":[],"static/esm/c5372168.js":[],"static/esm/f76c9d9d.js":[]},"bundles":{"static/core/ed65b5c3.js":["static/core/eb2aeda1.js","static/core/43bfb22e.js","static/core/a36f6cb5.js"],"static/core/ef035f6b.js":["static/core/a71c4cd8.js"],"static/core/6172f09a.js":["static/core/8daf15a4.js"],"static/core/2bed6a18.js":["static/core/a73da823.js"],"static/core/c0a3f7d0.js":["static/core/54f84c92.js"],"core":["static/core/2ff39ddf.js","static/core/cf7d1dd7.js","static/core/a42ab03f.js","static/core/d55483bf.js","static/core/b503e1b2.js"]}});
1094
+ window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/160bf060.js":[],"static/core/16612c9f.js":["static/core/3e1acefc.js"],"static/core/1e160f23.js":["static/core/66853555.js"],"static/core/1ed86ed3.js":[],"static/core/23e22cd2.js":[],"static/core/25562e5d.js":[],"static/core/2633e871.js":[],"static/core/2740933f.js":["static/core/beebdf4d.js"],"static/core/2a8b14c0.js":[],"static/core/2ae78ac6.js":["static/core/b6418818.js"],"static/core/31e587ab.js":["static/core/beebdf4d.js","static/core/b6418818.js","static/core/e94e24b5.js"],"static/core/3454ca99.js":[],"static/core/36071466.js":["static/core/d6c7eb44.js","__delivery__/libs"],"static/core/3cd95e0a.js":["static/core/b492a9b0.js","static/core/3e80379e.js","static/core/e98b0c61.js","static/core/c03fc17e.js","__delivery__/libs"],"static/core/3e1acefc.js":[],"static/core/3e80379e.js":["static/core/b492a9b0.js","__delivery__/libs"],"static/core/3f3feb86.js":[],"static/core/3fd50a29.js":[],"static/core/48da14fd.js":[],"static/core/4adb5ee9.js":[],"static/core/4e07805d.js":["static/core/9da6c313.js","static/core/e81b521f.js","static/core/f0f20c47.js","static/core/66853555.js","static/core/d6c7eb44.js","__delivery__/libs"],"static/core/4f8847e6.js":[],"static/core/519dfcc7.js":["static/core/3e80379e.js","static/core/4e07805d.js","__delivery__/libs","static/core/b492a9b0.js"],"static/core/53c22855.js":["static/core/f674f125.js"],"static/core/552f7d30.js":["static/core/b492a9b0.js","static/core/f674f125.js","__delivery__/libs"],"static/core/5de3cd2c.js":["static/core/e81b521f.js"],"static/core/6561b34a.js":[],"static/core/66853555.js":[],"static/core/69688fad.js":[],"static/core/713de1e1.js":["static/core/9da6c313.js"],"static/core/7ae6cf52.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/7b850506.js":[],"static/core/80907514.js":["static/core/f0f20c47.js"],"static/core/86f73ee9.js":["static/core/3e1acefc.js","static/core/ec079650.js","static/core/1e160f23.js"],"static/core/8b9a4f49.js":[],"static/core/9348ac64.js":[],"static/core/9da6c313.js":[],"static/core/a004861a.js":[],"static/core/aeec5659.js":[],"static/core/b492a9b0.js":["static/core/e7620593.js","static/core/f674f125.js","__delivery__/libs"],"static/core/b6418818.js":[],"static/core/beebdf4d.js":[],"static/core/c03fc17e.js":["static/core/9da6c313.js","static/core/4e07805d.js","__delivery__/libs"],"static/core/c3344bbc.js":[],"static/core/c3544cf4.js":["static/core/1e160f23.js"],"static/core/cc4458d8.js":[],"static/core/d551e71d.js":[],"static/core/d5be6857.js":[],"static/core/d6c7eb44.js":["__delivery__/libs"],"static/core/d9ff5568.js":[],"static/core/dcc37768.js":[],"static/core/e2710fd3.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/e7620593.js":[],"static/core/e7c7173a.js":["static/core/66853555.js","static/core/ec079650.js","static/core/1e160f23.js"],"static/core/e81b521f.js":[],"static/core/e94e24b5.js":["static/core/b6418818.js"],"static/core/e98b0c61.js":["static/core/b492a9b0.js","__delivery__/libs"],"static/core/ec079650.js":[],"static/core/ecc4d431.js":[],"static/core/f0f20c47.js":[],"static/core/f5d42c73.js":[],"static/core/f674f125.js":[],"static/core/f97efb0a.js":[],"static/core/fb2fe2db.js":[],"static/core/ff0af9ff.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/971f1b2c.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/971f1b2c.js","static/esm/1d0ba521.js","static/esm/f76c9d9d.js"],"static/esm/1d0ba521.js":[],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/971f1b2c.js":[],"static/esm/f76c9d9d.js":[]},"bundles":{"static/core/4e07805d.js":["static/core/50b377c7.js","static/core/523ea2ec.js","static/core/88cd6d99.js"],"static/core/2740933f.js":["static/core/a71c4cd8.js"],"static/core/552f7d30.js":["static/core/ac633841.js"],"static/core/c03fc17e.js":["static/core/a73da823.js"],"static/core/519dfcc7.js":["static/core/b1cc9ee5.js"],"core":["static/core/2ff39ddf.js","static/core/d3e42889.js","static/core/3fb28e82.js","static/core/e7f792fb.js","static/core/b6bccb63.js"]}});