useblocks 1.1.85-dev.3 → 1.1.85-dev.4

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.
package/useblocks-esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import{t as ei}from"./static/esm/50fbfdf6.js";import{$ as Vo,A as Ko,At as Wo,B as Yo,C as Xo,Ct as te,D as Jo,Dt as ft,E as Qo,Et as Zo,F as We,G as ti,H as Ye,I as es,J as ts,K as ns,L as rs,M as is,Mt as Q,N as Ze,O as ni,Ot as O,P as os,Q as ri,R as ss,S as as,St as ls,T as ds,Tt as $,V as Gn,W as cs,X as us,Y as ii,Z as Pe,_ as pt,_t as fs,a as ps,at as Xt,b as hs,bt as qn,c as ms,ct as gs,d as bt,dt as vs,et as we,f as bs,ft as F,g as oi,gt as pe,h as Es,ht as Ce,i as ys,it as oe,j as _s,jt as ws,k as Ss,kt as le,l as M,lt as $n,m as bn,mt as En,n as Is,nt as De,o as Le,ot as he,p as Ts,pt as si,q as yn,r as As,rt as Et,s as Cs,st as Rs,t as ce,tt as k,u as Ps,ut as Ds,v as Os,vt as Jt,w as ai,wt as _n,x as zn,xt as xs,y as Ls,yt as Ms,z as Te}from"./static/esm/cb0e9a7f.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var h=(function(){if(typeof document<"u"&&document.querySelector)try{var _=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(_&&_.src)return _.src.substring(0,_.src.lastIndexOf("/")+1)}catch{}try{var T=import.meta.url;if(T)return T.substring(0,T.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var c=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(c)||c.indexOf("//")===0)return c.charAt(c.length-1)==="/"?c:c+"/";var a=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",p=a?new URL(c,a).href:c;return p.charAt(p.length-1)==="/"?p:p+"/"}catch{var m=String(h);return m.charAt(m.length-1)==="/"?m:m+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var c=h==null?"":String(h);c||(c="./");try{var a=String(c);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a)||a.indexOf("//")===0)return a.charAt(a.length-1)==="/"?a:a+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",m=p?new URL(a,p).href:a;return m.charAt(m.length-1)==="/"?m:m+"/"}catch{var _=String(c);return _.charAt(_.length-1)==="/"?_:_+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var c="";try{if(typeof window<"u"){for(var a in window)if(!(a==="__useblocks__"||!/^__[^_].*__$/.test(a))){var p;try{p=window[a]}catch{continue}if(p&&typeof p=="object"&&p.publicPath){c=" Another product namespace ("+a+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function c(P){try{var N=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return N?new URL(String(P||""),N).href:String(P||"")}catch{return String(P||"")}}var a=String(h||"");if(!a)return"";if(/^(?:data:|blob:)/.test(a))return a;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a)||a.indexOf("//")===0||a.charAt(0)==="/")return c(a);var p=a.replace(/^\.\/+/,"").replace(/^\/+/,""),m="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),_=m&&p.indexOf(m+"/")!==0?m+"/"+p:p,T=e.publicPath||"./";try{return new URL(_,T).href}catch{return T.slice(-1)!=="/"&&(T+="/"),c(T+_)}}),e.version||(e.version="1.1.85-dev.3");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
1
+ import{t as ni}from"./static/esm/50fbfdf6.js";import{$ as Wo,A as Yo,At as Xo,B as Jo,C as Qo,Ct as te,D as Zo,Dt as ft,E as es,Et as ts,F as We,G as ri,H as Ye,I as ns,J as rs,K as is,L as os,M as ss,Mt as Q,N as Ze,O as ii,Ot as O,P as as,Q as oi,R as ls,S as ds,St as cs,T as us,Tt as $,V as qn,W as fs,X as ps,Y as si,Z as Pe,_ as pt,_t as hs,a as ms,at as Jt,b as gs,bt as $n,c as vs,ct as bs,d as bt,dt as Es,et as we,f as ys,ft as F,g as ai,gt as pe,h as _s,ht as Ce,i as ws,it as oe,j as Ss,jt as Is,k as Ts,kt as le,l as M,lt as zn,m as En,mt as yn,n as As,nt as De,o as Le,ot as he,p as Cs,pt as li,q as _n,r as Rs,rt as Et,s as Ps,st as Ds,t as ce,tt as k,u as Os,ut as xs,v as Ls,vt as Qt,w as di,wt as wn,x as Vn,xt as Ms,y as ks,yt as Ns,z as Te}from"./static/esm/cb0e9a7f.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var h=(function(){if(typeof document<"u"&&document.querySelector)try{var _=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(_&&_.src)return _.src.substring(0,_.src.lastIndexOf("/")+1)}catch{}try{var T=import.meta.url;if(T)return T.substring(0,T.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var c=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(c)||c.indexOf("//")===0)return c.charAt(c.length-1)==="/"?c:c+"/";var a=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",p=a?new URL(c,a).href:c;return p.charAt(p.length-1)==="/"?p:p+"/"}catch{var m=String(h);return m.charAt(m.length-1)==="/"?m:m+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var c=h==null?"":String(h);c||(c="./");try{var a=String(c);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a)||a.indexOf("//")===0)return a.charAt(a.length-1)==="/"?a:a+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",m=p?new URL(a,p).href:a;return m.charAt(m.length-1)==="/"?m:m+"/"}catch{var _=String(c);return _.charAt(_.length-1)==="/"?_:_+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var c="";try{if(typeof window<"u"){for(var a in window)if(!(a==="__useblocks__"||!/^__[^_].*__$/.test(a))){var p;try{p=window[a]}catch{continue}if(p&&typeof p=="object"&&p.publicPath){c=" Another product namespace ("+a+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function c(P){try{var N=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return N?new URL(String(P||""),N).href:String(P||"")}catch{return String(P||"")}}var a=String(h||"");if(!a)return"";if(/^(?:data:|blob:)/.test(a))return a;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a)||a.indexOf("//")===0||a.charAt(0)==="/")return c(a);var p=a.replace(/^\.\/+/,"").replace(/^\/+/,""),m="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),_=m&&p.indexOf(m+"/")!==0?m+"/"+p:p,T=e.publicPath||"./";try{return new URL(_,T).href}catch{return T.slice(-1)!=="/"&&(T+="/"),c(T+_)}}),e.version||(e.version="1.1.85-dev.4");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
2
2
  * Async AMD Loader (IIFE version for injection)
3
3
  *
4
4
  * This file is injected at the beginning of iframe entry points.
@@ -993,14 +993,14 @@ import{t as ei}from"./static/esm/50fbfdf6.js";import{$ as Vo,A as Ko,At as Wo,B
993
993
  __amdEnv.syncRequire = syncRequire;
994
994
  __amdEnv.diagnosticsBuffer = diagBuffer;
995
995
  })();
996
- `,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"useblocks-core.168aeeb1.js",po:"useblocks-po.168aeeb1.js",monaco:"static/monaco/index.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(h){var c,a=function(){return c||(c=Promise.resolve().then(h))};return{then:function(p,m){return a().then(p,m)},catch:function(p){return a().catch(p)},finally:function(p){return a().finally(p)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=i(function(){return o.then(function(h){return h.React})}),t.ReactDom=i(function(){return o.then(function(h){return h.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(h){return h.Classnames})}),t.Dayjs=i(function(){return o.then(function(h){return h.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(h){var c=h[0]||Object.create(null),a=Object.create(null);for(var p in c)Object.prototype.hasOwnProperty.call(c,p)&&(a[p]=c[p]);for(var m in a)Object.prototype.hasOwnProperty.call(a,m)&&(t[m]=a[m]);return a})}),d={},l={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},f={Antd:"[runtime] `antd` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",AntDesignIcons:"[runtime] `@ant-design/icons` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated."},u=Object.create(null);if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var c in h)Object.prototype.hasOwnProperty.call(h,c)&&(u[c]=h[c])},e.__compatPending){for(var g=0;g<e.__compatPending.length;g+=1)e.registerCompat(e.__compatPending[g]);e.__compatPending=void 0}for(var b in l)Object.prototype.hasOwnProperty.call(l,b)&&(function(h,c,a){var p=!1,m=function(){if(!(h in u))throw new Error(c);return u[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var _=m();return p||(p=!0),_},set:function(_){u[h]=_}}),Object.defineProperty(d,h,{configurable:!0,enumerable:!0,get:m,set:function(_){u[h]=_}})})(b,l[b],f[b]);var E=t;for(var I in d)Object.prototype.hasOwnProperty.call(d,I)&&(E===t&&(E=Object.create(t)),Object.defineProperty(E,I,Object.getOwnPropertyDescriptor(d,I)));var v=s,y=[],w=function(){for(var h=[],c=0;c<y.length;c+=1)(function(a){var p=t[a];p&&typeof p.then=="function"&&h.push(Promise.resolve(p).then(function(m){t[a]=m}))})(y[c]);return Promise.all(h)},S=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(w).then(function(){if(typeof S=="function")return S.call(e)})},typeof e.define=="function"){let h=function(c){if(!c||typeof c!="object"&&typeof c!="function"||c.__esModule)return c;if(A){var a=A.get(c);if(a)return a}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var m=Reflect.ownKeys(c),_=0;_<m.length;_++){var T=m[_];if(T!=="__esModule"){var P=Object.getOwnPropertyDescriptor(c,T);P&&Object.defineProperty(p,T,P)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:c,writable:!1}),A&&A.set(c,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var c=E.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.React;return h(p)})}),e.define("useblocks/runtime/react",[],function(){var c=E.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.React;return h(p)})}),e.define("react-dom",[],function(){var c=E.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("useblocks/runtime/react-dom",[],function(){var c=E.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("react-dom/client",[],function(){var c=E.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var c=E.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("react/jsx-runtime",[],function(){var c=E.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var c=E.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("react/jsx-dev-runtime",[],function(){var c=E.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var c=E.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("antd",[],function(){var c=E.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Antd;return h(p)})}),e.define("useblocks/runtime/antd",[],function(){var c=E.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Antd;return h(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var c=E.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var c=E.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("@ant-design/icons",[],function(){var c=E.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var c=E.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("@ant-design/cssinjs",[],function(){var c=E.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var c=E.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("classnames",[],function(){var c=E.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Classnames;return h(p)})}),e.define("useblocks/runtime/classnames",[],function(){var c=E.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Classnames;return h(p)})}),e.define("dayjs",[],function(){var c=E.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks/runtime/dayjs",[],function(){var c=E.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks-ui-kit",[],function(){var c=E.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit",[],function(){var c=E.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit/icons",[],function(){var c=E.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.UiKitIcons;return h(p)})}),e.define("useblocks-ui-kit/icons",[],function(){var c=E.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.UiKitIcons;return h(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var ks=new Function("url","return import(url)");function Ns(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Fs(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function js(e){return e.type==="umd"||e.resolve==="registry"}var Bs=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(Fs(e))return this._resolveDescriptor(e);throw new Error(`Unknown plugin entry format: ${JSON.stringify(e)}`)}async _resolveDescriptor(e){const t=e.resolve??(e.type==="umd"?"window":"module");if(js(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await ks(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}initSync(e){const t=[];for(const n of e){const r=this._getOrCreate(n,void 0);t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const{ctor:i,options:o}=await this._resolveEntry(r),s=this._getOrCreate(i,o);n.has(s)||(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const d=await this._resolveEntry(s);t.add(d.ctor),n.push(d)}const r=[];this._map.forEach((s,d)=>{t.has(d)||r.push({key:d,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:d,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(d),this._optionsMap.delete(d),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const f=this._creationOrder.indexOf(l);f>=0&&this._creationOrder.splice(f,1)}const i=[],o=new Set;for(const{ctor:s,options:d}of n){const l=this._getOrCreate(s,d);o.has(l)||(o.add(l),i.push(l))}this._activated&&await this._startPluginsBatch(i)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,i)=>{let o,s=!1;const d=()=>{s||(s=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,d),r())};this._pluginRegistry.on(e,d),n!==void 0&&n>0&&(o=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,d),i(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),i=this._createPluginInstance(e,r),o=i.constructor.name;this._emitLifecycle({type:"created",plugin:i,name:o}),i.required?.(),this._map.set(n,i),this._creationOrder.push(i),this._setupReadyPromise(i)}return this._map.get(n)}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);try{return Ns(e)?new e(this._context,t):e(this._context,t)||{}}finally{this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const i of t){if(this._initializedPlugins.has(i))continue;const o=this._initializingPlugins.get(i);if(o){n.add(o);continue}r.push(i)}if(r.length>0){const i=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,i);n.add(i),i.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===i&&this._initializingPlugins.delete(o)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(i){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:i})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},Us=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const i of n)try{i.callback(t)}catch{}const r=n.filter(i=>!i.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(i=>(t.ctor=i,t.loading=void 0,this._notifyListeners(e,i),i));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!1};return r.push(i),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!0};return r.push(i),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(i=>i.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Hs=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()}},Vn=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 Gs(e,t){return t+e}function qs(){return typeof performance>"u"?Date.now():Gs(performance.now(),performance.timeOrigin)}var $s="emailmaker:diagnostics",zs="diagnostics",Vs="diagnostics";function Kn(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Vs}=1`:e}var At;function Ks(){try{const e=new URLSearchParams(window.location.search).get(zs);return e===null?void 0:e!=="0"}catch{return}}function Ws(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Ys(){try{const e=window.localStorage.getItem($s);return e===null?void 0:e==="1"}catch{return}}function qe(){return At===void 0&&(At=typeof window>"u"?!1:Ks()??Ws()??Ys()??!1),At}function Xs(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var J={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},lm=Object.values(J),dm=[J.canvasPainted,J.canvasSettled,J.appVisible,J.editorVisible],Js=5e3,Qs=3e3,Wn="diagnosticsStore",et,Ne;function Yn(){return{marks:new Vn(Js),resources:new Vn(Qs)}}function li(){if(Ne)return Ne;const e=wn();return e?(Ne=e[Wn]??et??Yn(),e[Wn]=Ne,et=void 0,Ne):(et??=Yn(),et)}function G(e,t){qe()&&li().marks.push({phase:e,at:qs(),...t})}function wn(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[Xs()];return e!==null&&typeof e=="object"?e:void 0}function Zs(e){const t=e.length,n=li();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function ea(){const e=wn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Zs(e.diagnosticsBuffer)}var ta="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function di(){const e=new Error(ta);return e.name="DestroyedInstanceError",e}function Qt(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const o=e,s=t;return o.length===s.length&&o.every((d,l)=>Qt(d,s[l]))}const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&Qt(e[o],t[o]))}function ci(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const d=t(s);o&&Qt(i,d)||(i=d,o=!0,r(d))})},select(r){return ci(n,r)}};return n}function Me(...e){let t=e[0],n=e.length>0;const r=new Set,i={get(){return n?t:void 0},set(o){t=o,n=!0;for(const s of Array.from(r))s(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return ci(i,o)}};return i}var ui=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:us.UrlEncoded,...t})},fi=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 na(e){return String(e||"").trim()||void 0}var ra=class extends Q{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=na(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)}},Sn=O("AppInitService");function ia(e){return async()=>{const t=await e();return(await new ui(t).app_init_create({})).data}}function oa(e){e.injectFactory(Sn,()=>{const t=new ra({options:e.getInstance(oe),isStandalone:()=>!!e.getInstance(he),resolveRestBaseUrl:n=>n?zn(n):zn()||void 0,setRestBaseUrl:n=>{e.getInstance(Os)?.setOptions(n?{baseUrl:n}:{})},fallbackAppInit:ia(()=>e.getInstanceAsync(ts)),publish:n=>{e.inject(Pe,n)}});return e.getInstance(k)?.addDisposable(t),t},!0)}var In=O("documentSession.emailDocuments");function Ct(e){return e?.getInstance(In)}var sa=O("RevisionServiceFlag");function aa(e){return e.getOrCreateInstance(sa,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function pi(e){return aa(e).isEnabled()}var la=O("EmailRightsResolver");function da(e,t){const n=e.getInstance(la);return n?n(t):!0}var hi=O("EmailHistoryAvailabilityResolver");function ca(e){return e.getInstance(hi)!==void 0}async function ua(e){const t=e.getInstance(hi);if(!t)return!0;try{return await t()}catch{return!1}}var Tn={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},mi=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],gi=2e4,fa=mi.reduce((e,t)=>e+Tn[t],0),vi=gi+fa+3e3;function pa(e){return mi.reduce((t,n)=>t+bi(n,e),0)}function bi(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:Tn[e]}function Ei(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:vi}function yi(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:gi}function _i(e=vi){return e+3e3}var ha=()=>_i();function ma(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function ga(e){return t=>ma(e.getOrCreateInstance(F.BEFORE_SAVE_EMAIL,()=>new pe).fire(t),ha())}function va(e){return e!=null&&e!==""}var ba;function yt(e,t){return ba?.capture(e,t)}function Ea(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function tt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var re=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${tt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${tt(this.oldText)}")`:`(replace@${this.oldPosition} "${tt(this.oldText)}" with "${tt(this.newText)}")`}};function Xn(e,t){return e===null||e.length===0?t:new ya(e,t).compress()}var ya=class se{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),i=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(i===null)break;this._acceptCurr(i),i=this._getCurr(++n);continue}if(i===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldEnd<=r.newPosition){this._acceptCurr(i),i=this._getCurr(++n);continue}if(r.newEnd<=i.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldPosition<r.newPosition){const[l,f]=se._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(l),i=f;continue}if(r.newPosition<i.oldPosition){const[l,f]=se._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(l),r=f;continue}let s,d;if(i.oldEnd===r.newEnd)s=r,d=i,r=this._getPrev(++t),i=this._getCurr(++n);else if(i.oldEnd<r.newEnd){const[l,f]=se._splitPrev(r,i.oldLength);s=l,d=i,r=f,i=this._getCurr(++n)}else{const[l,f]=se._splitCurr(i,r.newLength);s=r,d=l,r=this._getPrev(++t),i=f}this._result[this._resultLen++]=new re(s.oldPosition,s.oldText,d.newPosition,d.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=d.newLength-d.oldLength}const o=se._merge(this._result);return se._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=se._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=se._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new re(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new re(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),i=t.newText.substr(n);return[new re(t.oldPosition,t.oldText,t.newPosition,r),new re(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new re(t.oldPosition,r,t.newPosition,t.newText),new re(t.oldPosition+n,i,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,i=t[0];for(let o=1;o<t.length;o++){const s=t[o];i.oldEnd===s.oldPosition?i=new re(i.oldPosition,i.oldText+s.oldText,i.newPosition,i.newText+s.newText):(n[r++]=i,i=s)}return n[r++]=i,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o.oldText!==o.newText&&(n[r++]=o)}return n}};function _a(e){return new re(e.newPosition,e.newText,e.oldPosition,e.oldText)}function wa(e){return e.map(_a)}function Jn(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Sa(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const i=t[r];n=n.slice(0,i.oldPosition)+i.newText+n.slice(i.oldEnd)}return n}function Ia(e,t,n){let r=0;const i=e.start===e.end;for(const o of t){const s=o.newLength-o.oldLength;if(o.oldLength===0){const d=o.oldPosition;if(i&&d===e.start)r+=n==="after"?s:0;else{if(e.start<d&&d<e.end)return null;d<=e.start&&(r+=s)}continue}if(i){if(e.start>=o.oldEnd)r+=s;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=s;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var ht=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Qn=0,Ta=Math.random().toString(36).slice(2,8);function Aa(){return Qn+=1,`doc-${Ta}-${Qn}`}function Ca(e){const t=e.createBuffer(),n=e.docId??Aa();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const d=new Set;let l=!1,f=!1,u;const g=new Set;let b=null;const E=()=>(b?.version!==i&&(b={version:i,value:t.read()}),b.value),I=v=>Object.entries(v).some(([y,w])=>s[y]!==w);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:E,mutate(v,{source:y}){if(l)return i;const w=v.changes?.length?v.changes:void 0,S=w?Sa(E(),w):v.content!==void 0?v.content:void 0,A=S!==void 0&&S!==E(),h=v.attributes!==void 0&&I(v.attributes);if(!A&&!h)return i;const c=!(i>(o??-1));return A&&t.write(S),h&&(s={...s,...v.attributes}),i+=1,y!=="user"&&c&&(o=i),d.forEach(a=>a({source:y,version:i,changes:w})),i},markSaved(v,y){const w={serverId:r,savedVersion:o};y!==void 0&&(r=y),(o===null||v>o)&&(o=v),(w.serverId!==r||w.savedVersion!==o)&&d.forEach(S=>S({source:"system",version:i}))},markReady(){f||u!==void 0||(f=!0,g.forEach(v=>v.resolve()),g.clear(),d.forEach(v=>v({source:"system",version:i})))},isReady:()=>f,markFailed(v){f||u!==void 0||l||(u=v,g.forEach(y=>y.reject(new ht(v))),g.clear(),d.forEach(y=>y({source:"system",version:i})))},failure:()=>u,whenReady(){return f?Promise.resolve():u!==void 0?Promise.reject(new ht(u)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((v,y)=>{g.add({resolve:v,reject:y})})},subscribe(v){return d.add(v),()=>d.delete(v)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>l,dispose(){l=!0,g.forEach(v=>v.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),g.clear(),d.clear(),t.dispose()}}}var Ra=500,Pa=100,Rt=0;function Da(e,t={}){const n=t.groupIntervalMs??Ra,r=t.maxSteps??Pa,i=t.now??(()=>0);let o=[],s=0,d=Rt+=1,l=null,f=!1,u=!1,g=!1;const b=new Set,E=()=>b.forEach(a=>a()),I=(a,p)=>{if(a.length){u=!0;try{e.mutate({changes:a},{source:p})}finally{u=!1}}},v=a=>I(a,"user"),y=a=>{const p=i();f&&l!==null&&p-l<n?o[s-1]=Xn(o[s-1],a):(o=o.slice(0,s),o.push(a),s=o.length,f=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,d=Rt+=1)),l=p,E()},w=()=>{f=!1,l=null},S=a=>{if(!a.length)return;const p=o.length>s;p&&(o=o.slice(0,s)),s>0&&(o[s-1]=Xn(o[s-1],a)),w(),p&&E()},A=e.subscribe(({source:a,changes:p})=>{if(!(g||u||!p?.length)){if(a==="remote"){h();return}if(a!=="user"){S(p);return}y(p)}}),h=()=>{o=[],s=0,w(),d=Rt+=1,E()},c=()=>{if(s===0)return!1;const a=wa(o[s-1]);return Jn(e.getContent(),a)?(v(a),s-=1,w(),!0):(o=o.slice(0,s-1),s=o.length,w(),E(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){c()&&E()},redo(){if(!(s>=o.length)){if(!Jn(e.getContent(),o[s])){o=o.slice(0,s),w(),E();return}v(o[s]),s+=1,w(),E()}},clear:h,applyWithoutHistory(a){const p=e.get().version;if(I(a,"system"),e.get().version===p){w();return}S(a)},getPast:a=>o.slice(0,s).reverse().slice(0,a),getFuture:a=>o.slice(s).reverse().slice(0,a),createSnapshot:()=>({stackId:d,index:s}),restoreSnapshot(a){if(a.stackId!==d||a.index>s)return!1;for(;s>a.index;)if(!c())return E(),!1;return E(),!0},subscribe(a){return b.add(a),()=>b.delete(a)},dispose(){g=!0,A(),b.clear(),o=[],s=0}}}var Oa=["edit","move","resize","insert"];function Pt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function xa(e){return typeof e=="string"?e:null}function La(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Ma(e){return Oa.includes(e)?e:null}function ka(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:xa(t.originId),changeId:Pt(t.changeId),rev:Pt(t.rev),baseRev:Pt(t.baseRev),expected:La(t.expected),intent:Ma(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var Zn=class extends Error{reason;constructor(e){super(`сохранение не состоялось: ${e}`),this.name="SaveRefusedError",this.reason=e}},wi="draft";function Fe(e){return e==null||e===""?wi:String(e)}function Na(e){return e==null||e===""?`${Zt}${wi}`:`${Zt}${String(e)}`}var Zt="block:";function me(e){return e?.startsWith(Zt)===!0}function je(e){return me(e.sessionKey())?void 0:e.current()}function Ue(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return G(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(G(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw`${e}`,{error:String(i),...n},i})}function Si(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Ii(e,{freshSince:t}={}){return!(!e?.slug?.includes("autosave")||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Fa(e,t={}){const n=Si((e??[]).filter(r=>r?.html?.trim()));return Ii(n,t)?n:null}function ja(e){const t=Date.parse(Si(e)?.modified??"");return{autosave:Fa(e),...Number.isFinite(t)?{latestAt:t}:{}}}function Ba({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Ti=e=>e.replace(/\r\n?/g,`
997
- `),er=["recovery","plugin","rest"],Ua=["subject","preheader"];function Ha(e){let t={},n;for(let i=er.length-1;i>=0;i--){const o=e.get(er[i]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const i of Ua){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Ai(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Ti(t.content):void 0,i=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...i?{changes:[new re(0,n,0,r)]}:{}},{source:"remote"})}var tr=e=>typeof e=="string"?e.trim():"";function Ga(e,t,n){const{version:r,attributes:i}=e.get(),o=i,s=tr(o.title)||tr(o.subject);return{version:r,payload:{html:e.getContent(),title:s,subject:o.subject,preheader:o.preheader,description:o.description,common_styles:o.common_styles||"",meta:o.meta,utm_parameters:o.utm_parameters,parent_email:o.parent_email,is_template:o.is_template||!1,is_inited:o.is_inited,tags:o.tags,emailtags:o.emailtags,group:o.group,renderGuid:e.get().docId,project:t.project??o.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source}}}async function qa(e,t,n,r,i){if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(i);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,i):t.saveAutosave(r,i)}function ge(e,t=!1){const n={};for(const r of Object.keys(e)){let i=e[r];i!==void 0&&!(typeof i=="number"&&Number.isNaN(i))&&(t&&typeof i=="object"&&i!==null&&(i=ge(i)),n[r]=i)}return n}var $a=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Ci(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!$a.has(t))):{}}function mt(e,t,n={}){e&&e.mutate({attributes:za(e.get().attributes,t)},{source:n.source??"user"})}function za(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function An(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Va(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Ri(e){if(!e)return null;const t=Ci(e);return e.common_styles!==void 0&&(t.common_styles=Va(e.common_styles)),An(e.html,t)}function Pi(e){return e?An(e.html,ge(Ci(e))):null}var Ka=["common_styles","subject","preheader","meta"];function nr(e){if(!e?.html?.trim())return null;const t={};for(const n of Ka)Wa(n,e[n])&&(t[n]=e[n]);return An(e.html,t)}function Wa(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 Ya=10,Xa=(e,t)=>e.key===t.key&&Ja(e.serverId,t.serverId),Ja=(e,t)=>e==null||e===t;function Qa(e){return typeof e?.then=="function"}var rr=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Di=e=>{e.request.serverId!=null&&e.document.markSaved(e.document.get().version)},Za=e=>{Ai(e.document,Ha(e.reports)),Di(e)},Dt=(e,t)=>{if(!e.ready){Za(e);return}Ai(e.document,t)},el=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 tl(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:d,onAdapterError:l,onTimeout:f}=e;let u;const g=new Set,b=new Set,E=()=>g.forEach(m=>m()),I=(m,_)=>{if(!(m.closed||m.ready)){if(m.error!==void 0){m.document.markFailed(m.error),m.document.get().docId;return}Di(m),m.ready=!0,m.document.markReady(),m.document.get().docId,[...m.reports.keys()]}},v=(m,_,T)=>{l?.(_.id,T),!(!_.required||m.closed)&&(m.error=T,m.document.get().docId,_.id,E())},y=(m,_)=>{const T=new Set(_.map(R=>R.id));_.forEach(R=>{R.watch&&m.watchers.push(R.watch(D=>m.closed?!1:m.ready&&D?.content!==void 0&&Ba({hasUnsavedUserEdit:m.document.isDirty()})==="skip"?(m.document.get().docId,R.id,!1):(D&&m.reports.set(R.id,D),Dt(m,D),!0)))});const P=(R,D)=>{m.closed||(D&&m.reports.set(R.id,D),Dt(m,D))},N=()=>{T.size>0||m.closed||(rr(m),I(m,[]))},X=[];if(_.forEach(R=>{let D;try{D=R.load()}catch(q){v(m,R,q),T.delete(R.id);return}if(Qa(D)){X.push({id:R.id,required:R.required,load:()=>D});return}P(R,D),T.delete(R.id)}),X.length===0){N();return}m.timer=setTimeout(()=>{m.timer=void 0,f?.([...T]),m.document.get().docId,[...T],I(m,[...T])},n),m.timer.unref?.(),X.forEach(R=>{R.load().then(D=>P(R,D)).catch(D=>{v(m,R,D)}).finally(()=>{T.delete(R.id),N()})})},w=async(m,_,T)=>{if(T==="snapshot"||T==="anchor")return;const P=o?.();if(P)return P.resolve({project:_.project??m.project,tags:(m.tags??[]).map(N=>({name:N}))})},S=m=>{if(m.lock===!0&&s?.(m)===!1)return new Zn("locked");const _=m.tags?.length??0,T=m.emailtags?.length??0;if(Math.max(_,T)>Ya)return new Zn("too-many-tags")},A=async(m,_,T)=>{try{await m.document.whenReady()}catch(D){return m.saveError=D,m.saveFailures+=1,m.saveFailures,!1}if(m.closed)return!1;const P=S(m.document.get().attributes);if(P)return m.saveError=P,m.saveFailures+=1,P.reason,E(),!1;if(d&&(await d(el(m)).catch(()=>{}),m.closed))return!1;let N;try{N=await w(m.document.get().attributes,T,_)}catch(D){return m.saveError=D,m.saveFailures+=1,m.saveFailures,E(),!1}if(m.closed)return!1;const{payload:X,version:R}=Ga(m.document,T,N);m.document.get().docId;try{const D=m.document.get().serverId!=null,q=await qa(r(),i(m.request.key),_,m.document.get().serverId,X);if(m.closed)return!0;let j;if(_==="snapshot"||_==="anchor"){const x=q?.modified!=null?Date.parse(q.modified):NaN;j=Number.isFinite(x)?x:Date.now(),m.snapshotVersion=R,m.lastRevisionAt=j}else m.document.markSaved(R,q?.id!=null?String(q.id):void 0);const K=m.document.get().serverId;!D&&K!=null&&(m.recoveryFacts={emailId:K,historyLoaded:!0,isRecovering:!1}),m.saveError=void 0,m.saveFailures=0,m.document.get().serverId,E();const de={intent:_,serverId:m.document.get().serverId,created:!D,...j!==void 0?{revisionAt:j}:{}};return b.forEach(x=>x(de)),!0}catch(D){return m.saveError=D,m.saveFailures+=1,m.saveFailures,E(),!1}},h=()=>{u&&(u.closed=!0,u.watchers.forEach(m=>m()),u.watchers=[],rr(u),u.history.dispose(),u.document.dispose(),u=void 0)},c=(m,_,T)=>{let P=!1;_.show&&(m.show?.id!==_.show.id||m.show.token!==_.show.token)&&(m.show=_.show,P=!0,{docId:m.document.get().docId,..._.show});const N=T==="show"?Pi(_.patch):null;N&&(m.reports.set("plugin",N),Dt(m,N)),P&&E()},a=(m,_={})=>{const T=u;return!T||T.closed?Promise.resolve(!1):T.saving?m==="snapshot"?Promise.resolve(!1):(T.inFlight??Promise.resolve(!1)).then(()=>a(m,_)):(T.saving=!0,T.inFlight=A(T,m,_).finally(()=>{T.saving=!1,T.inFlight=void 0}),T.inFlight)},p=(m,_="open")=>{if(u&&!u.closed&&_!=="new"&&Xa(u.request,m))return c(u,m,_),u.document;h();const T=Ca({createBuffer:()=>Ea(""),serverId:m.serverId??null}),P={request:m,show:m.show,document:T,history:Da(T,{now:Date.now}),watchers:[],saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return u=P,T.get().docId,m.serverId,y(P,t(m,{publishRecoveryFacts(N){P.closed||(P.recoveryFacts=N,E())},readShownContent:()=>P.closed?null:P.document.getContent()})),E(),T};return{openWith:p,open:(m,_={})=>p({key:Fe(m),serverId:m,email:_.email,patch:_.patch,show:_.show},"open"),openDraft:(m,_={})=>p({key:Fe(void 0),serverId:null,email:m,patch:_.patch,show:_.show},"open"),startNewDraft:(m,_={})=>p({key:Fe(void 0),serverId:null,email:m,patch:_.patch,show:_.show},"new"),reload:(m,_={})=>p({key:Fe(m),serverId:m,email:_.email,patch:_.patch,show:_.show},"new"),openBlock:(m,_)=>p({key:me(m)?m:Na(m),serverId:_?.id!=null?String(_.id):null,email:_},"open"),show:(m,_)=>{const T=u;if(!(!T||T.closed))return p({...T.request,patch:m,show:_},"show")},current:()=>u?.document,save:a,saveState:()=>({error:u?.saveError,failures:u?.saveFailures??0,saving:u?.saving===!0}),revisionFacts(){if(!u)return;const m=u.revisionFactsSnapshot;return m&&m.snapshotVersion===u.snapshotVersion&&m.lastRevisionAt===u.lastRevisionAt?m:(u.revisionFactsSnapshot={snapshotVersion:u.snapshotVersion,lastRevisionAt:u.lastRevisionAt},u.revisionFactsSnapshot)},recoveryFacts:()=>u?.recoveryFacts,history:()=>u?.history,forcedHeaders:()=>u?.forcedHeaders,beginForcedHeaders(m){u&&!u.closed&&(u.forcedHeaders=m)},endForcedHeaders(){u&&(u.forcedHeaders=void 0)},onSaved(m){return b.add(m),()=>b.delete(m)},showFacts:()=>u?.show,sessionKey:()=>u?.request.key,openError:()=>u?.error,subscribe(m){return g.add(m),()=>g.delete(m)},close(){u&&(h(),E())}}}var Oi=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function xi(e){if(e instanceof Oi)return e.reason;if(e instanceof ht)return xi(e.reason)}function nl(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Oi("not-found");return Ri(n)}}}var Li=O("EmailPort");function rl(e){return e.getInstance(Li)}function il(e,t){e.inject(Li,t)}var Mi=O("documentSession.restEmailPortFactories");function ki(e){return e.getInstance(Mi)!==void 0}function Se(e){const t=e.getInstance(Mi);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var ol=O("EmailTermsResolver");function sl(e){return e.getInstance(ol)}var Ni=O("EmailHistoryPort"),al=O("BlockHistoryPort");function Fi(e){return e.getInstance(al)}function ji(e){return e.getInstance(Ni)}function ll(e,t){e.inject(Ni,t)}var dl="em_autosave_pending";function gt(e){return`${dl}_${e}`}function cl(e,t){try{sessionStorage.setItem(gt(e),JSON.stringify(t))}catch{}}function ul(e){try{const t=sessionStorage.getItem(gt(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(gt(e)),null):n}catch{return null}}function nt(e){try{sessionStorage.removeItem(gt(e))}catch{}}var fl=2e3,pl=5e3,hl=5,ml=5e3,gl=4;function vl(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function bl(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.fc97f6e8.js",po:"useblocks-po.fc97f6e8.js",monaco:"static/monaco/index.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(h){var c,a=function(){return c||(c=Promise.resolve().then(h))};return{then:function(p,m){return a().then(p,m)},catch:function(p){return a().catch(p)},finally:function(p){return a().finally(p)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=i(function(){return o.then(function(h){return h.React})}),t.ReactDom=i(function(){return o.then(function(h){return h.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(h){return h.Classnames})}),t.Dayjs=i(function(){return o.then(function(h){return h.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(h){var c=h[0]||Object.create(null),a=Object.create(null);for(var p in c)Object.prototype.hasOwnProperty.call(c,p)&&(a[p]=c[p]);for(var m in a)Object.prototype.hasOwnProperty.call(a,m)&&(t[m]=a[m]);return a})}),d={},l={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},f={Antd:"[runtime] `antd` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",AntDesignIcons:"[runtime] `@ant-design/icons` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated."},u=Object.create(null);if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var c in h)Object.prototype.hasOwnProperty.call(h,c)&&(u[c]=h[c])},e.__compatPending){for(var g=0;g<e.__compatPending.length;g+=1)e.registerCompat(e.__compatPending[g]);e.__compatPending=void 0}for(var b in l)Object.prototype.hasOwnProperty.call(l,b)&&(function(h,c,a){var p=!1,m=function(){if(!(h in u))throw new Error(c);return u[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var _=m();return p||(p=!0),_},set:function(_){u[h]=_}}),Object.defineProperty(d,h,{configurable:!0,enumerable:!0,get:m,set:function(_){u[h]=_}})})(b,l[b],f[b]);var E=t;for(var I in d)Object.prototype.hasOwnProperty.call(d,I)&&(E===t&&(E=Object.create(t)),Object.defineProperty(E,I,Object.getOwnPropertyDescriptor(d,I)));var v=s,y=[],w=function(){for(var h=[],c=0;c<y.length;c+=1)(function(a){var p=t[a];p&&typeof p.then=="function"&&h.push(Promise.resolve(p).then(function(m){t[a]=m}))})(y[c]);return Promise.all(h)},S=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(w).then(function(){if(typeof S=="function")return S.call(e)})},typeof e.define=="function"){let h=function(c){if(!c||typeof c!="object"&&typeof c!="function"||c.__esModule)return c;if(A){var a=A.get(c);if(a)return a}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var m=Reflect.ownKeys(c),_=0;_<m.length;_++){var T=m[_];if(T!=="__esModule"){var P=Object.getOwnPropertyDescriptor(c,T);P&&Object.defineProperty(p,T,P)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:c,writable:!1}),A&&A.set(c,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var c=E.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.React;return h(p)})}),e.define("useblocks/runtime/react",[],function(){var c=E.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.React;return h(p)})}),e.define("react-dom",[],function(){var c=E.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("useblocks/runtime/react-dom",[],function(){var c=E.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("react-dom/client",[],function(){var c=E.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var c=E.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("react/jsx-runtime",[],function(){var c=E.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var c=E.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("react/jsx-dev-runtime",[],function(){var c=E.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var c=E.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("antd",[],function(){var c=E.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Antd;return h(p)})}),e.define("useblocks/runtime/antd",[],function(){var c=E.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Antd;return h(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var c=E.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var c=E.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("@ant-design/icons",[],function(){var c=E.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var c=E.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("@ant-design/cssinjs",[],function(){var c=E.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var c=E.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("classnames",[],function(){var c=E.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Classnames;return h(p)})}),e.define("useblocks/runtime/classnames",[],function(){var c=E.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Classnames;return h(p)})}),e.define("dayjs",[],function(){var c=E.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks/runtime/dayjs",[],function(){var c=E.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks-ui-kit",[],function(){var c=E.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit",[],function(){var c=E.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit/icons",[],function(){var c=E.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.UiKitIcons;return h(p)})}),e.define("useblocks-ui-kit/icons",[],function(){var c=E.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?v.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):v.then(function(a){var p=a.UiKitIcons;return h(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Fs=new Function("url","return import(url)");function js(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Bs(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Us(e){return e.type==="umd"||e.resolve==="registry"}var Hs=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(Bs(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(Us(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Fs(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}initSync(e){const t=[];for(const n of e){const r=this._getOrCreate(n,void 0);t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const{ctor:i,options:o}=await this._resolveEntry(r),s=this._getOrCreate(i,o);n.has(s)||(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const d=await this._resolveEntry(s);t.add(d.ctor),n.push(d)}const r=[];this._map.forEach((s,d)=>{t.has(d)||r.push({key:d,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:d,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(d),this._optionsMap.delete(d),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const f=this._creationOrder.indexOf(l);f>=0&&this._creationOrder.splice(f,1)}const i=[],o=new Set;for(const{ctor:s,options:d}of n){const l=this._getOrCreate(s,d);o.has(l)||(o.add(l),i.push(l))}this._activated&&await this._startPluginsBatch(i)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,i)=>{let o,s=!1;const d=()=>{s||(s=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,d),r())};this._pluginRegistry.on(e,d),n!==void 0&&n>0&&(o=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,d),i(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),i=this._createPluginInstance(e,r),o=i.constructor.name;this._emitLifecycle({type:"created",plugin:i,name:o}),i.required?.(),this._map.set(n,i),this._creationOrder.push(i),this._setupReadyPromise(i)}return this._map.get(n)}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);try{return js(e)?new e(this._context,t):e(this._context,t)||{}}finally{this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const i of t){if(this._initializedPlugins.has(i))continue;const o=this._initializingPlugins.get(i);if(o){n.add(o);continue}r.push(i)}if(r.length>0){const i=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,i);n.add(i),i.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===i&&this._initializingPlugins.delete(o)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(i){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:i})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},Gs=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const i of n)try{i.callback(t)}catch{}const r=n.filter(i=>!i.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(i=>(t.ctor=i,t.loading=void 0,this._notifyListeners(e,i),i));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!1};return r.push(i),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!0};return r.push(i),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(i=>i.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},qs=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()}},Kn=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 $s(e,t){return t+e}function zs(){return typeof performance>"u"?Date.now():$s(performance.now(),performance.timeOrigin)}var Vs="emailmaker:diagnostics",Ks="diagnostics",Ws="diagnostics";function Wn(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Ws}=1`:e}var At;function Ys(){try{const e=new URLSearchParams(window.location.search).get(Ks);return e===null?void 0:e!=="0"}catch{return}}function Xs(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Js(){try{const e=window.localStorage.getItem(Vs);return e===null?void 0:e==="1"}catch{return}}function qe(){return At===void 0&&(At=typeof window>"u"?!1:Ys()??Xs()??Js()??!1),At}function Qs(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var J={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},cm=Object.values(J),um=[J.canvasPainted,J.canvasSettled,J.appVisible,J.editorVisible],Zs=5e3,ea=3e3,Yn="diagnosticsStore",et,Ne;function Xn(){return{marks:new Kn(Zs),resources:new Kn(ea)}}function ci(){if(Ne)return Ne;const e=Sn();return e?(Ne=e[Yn]??et??Xn(),e[Yn]=Ne,et=void 0,Ne):(et??=Xn(),et)}function G(e,t){qe()&&ci().marks.push({phase:e,at:zs(),...t})}function Sn(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[Qs()];return e!==null&&typeof e=="object"?e:void 0}function ta(e){const t=e.length,n=ci();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function na(){const e=Sn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:ta(e.diagnosticsBuffer)}var ra="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function ui(){const e=new Error(ra);return e.name="DestroyedInstanceError",e}function Zt(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const o=e,s=t;return o.length===s.length&&o.every((d,l)=>Zt(d,s[l]))}const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&Zt(e[o],t[o]))}function fi(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const d=t(s);o&&Zt(i,d)||(i=d,o=!0,r(d))})},select(r){return fi(n,r)}};return n}function Me(...e){let t=e[0],n=e.length>0;const r=new Set,i={get(){return n?t:void 0},set(o){t=o,n=!0;for(const s of Array.from(r))s(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return fi(i,o)}};return i}var pi=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:ps.UrlEncoded,...t})},hi=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 ia(e){return String(e||"").trim()||void 0}var oa=class extends Q{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=ia(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)}},In=O("AppInitService");function sa(e){return async()=>{const t=await e();return(await new pi(t).app_init_create({})).data}}function aa(e){e.injectFactory(In,()=>{const t=new oa({options:e.getInstance(oe),isStandalone:()=>!!e.getInstance(he),resolveRestBaseUrl:n=>n?Vn(n):Vn()||void 0,setRestBaseUrl:n=>{e.getInstance(Ls)?.setOptions(n?{baseUrl:n}:{})},fallbackAppInit:sa(()=>e.getInstanceAsync(rs)),publish:n=>{e.inject(Pe,n)}});return e.getInstance(k)?.addDisposable(t),t},!0)}var Tn=O("documentSession.emailDocuments");function Ct(e){return e?.getInstance(Tn)}var la=O("RevisionServiceFlag");function da(e){return e.getOrCreateInstance(la,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function mi(e){return da(e).isEnabled()}var ca=O("EmailRightsResolver");function ua(e,t){const n=e.getInstance(ca);return n?n(t):!0}var gi=O("EmailHistoryAvailabilityResolver");function fa(e){return e.getInstance(gi)!==void 0}async function pa(e){const t=e.getInstance(gi);if(!t)return!0;try{return await t()}catch{return!1}}var An={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},vi=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],bi=2e4,ha=vi.reduce((e,t)=>e+An[t],0),Ei=bi+ha+3e3;function ma(e){return vi.reduce((t,n)=>t+yi(n,e),0)}function yi(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:An[e]}function _i(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Ei}function wi(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:bi}function Si(e=Ei){return e+3e3}var ga=()=>Si();function va(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function ba(e){return t=>va(e.getOrCreateInstance(F.BEFORE_SAVE_EMAIL,()=>new pe).fire(t),ga())}function Ea(e){return e!=null&&e!==""}var ya;function yt(e,t){return ya?.capture(e,t)}function _a(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function tt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var re=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${tt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${tt(this.oldText)}")`:`(replace@${this.oldPosition} "${tt(this.oldText)}" with "${tt(this.newText)}")`}};function Jn(e,t){return e===null||e.length===0?t:new wa(e,t).compress()}var wa=class se{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),i=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(i===null)break;this._acceptCurr(i),i=this._getCurr(++n);continue}if(i===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldEnd<=r.newPosition){this._acceptCurr(i),i=this._getCurr(++n);continue}if(r.newEnd<=i.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldPosition<r.newPosition){const[l,f]=se._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(l),i=f;continue}if(r.newPosition<i.oldPosition){const[l,f]=se._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(l),r=f;continue}let s,d;if(i.oldEnd===r.newEnd)s=r,d=i,r=this._getPrev(++t),i=this._getCurr(++n);else if(i.oldEnd<r.newEnd){const[l,f]=se._splitPrev(r,i.oldLength);s=l,d=i,r=f,i=this._getCurr(++n)}else{const[l,f]=se._splitCurr(i,r.newLength);s=r,d=l,r=this._getPrev(++t),i=f}this._result[this._resultLen++]=new re(s.oldPosition,s.oldText,d.newPosition,d.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=d.newLength-d.oldLength}const o=se._merge(this._result);return se._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=se._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=se._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new re(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new re(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),i=t.newText.substr(n);return[new re(t.oldPosition,t.oldText,t.newPosition,r),new re(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new re(t.oldPosition,r,t.newPosition,t.newText),new re(t.oldPosition+n,i,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,i=t[0];for(let o=1;o<t.length;o++){const s=t[o];i.oldEnd===s.oldPosition?i=new re(i.oldPosition,i.oldText+s.oldText,i.newPosition,i.newText+s.newText):(n[r++]=i,i=s)}return n[r++]=i,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o.oldText!==o.newText&&(n[r++]=o)}return n}};function Sa(e){return new re(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Ia(e){return e.map(Sa)}function Qn(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Ta(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const i=t[r];n=n.slice(0,i.oldPosition)+i.newText+n.slice(i.oldEnd)}return n}function Aa(e,t,n){let r=0;const i=e.start===e.end;for(const o of t){const s=o.newLength-o.oldLength;if(o.oldLength===0){const d=o.oldPosition;if(i&&d===e.start)r+=n==="after"?s:0;else{if(e.start<d&&d<e.end)return null;d<=e.start&&(r+=s)}continue}if(i){if(e.start>=o.oldEnd)r+=s;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=s;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var ht=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Zn=0,Ca=Math.random().toString(36).slice(2,8);function Ra(){return Zn+=1,`doc-${Ca}-${Zn}`}function Pa(e){const t=e.createBuffer(),n=e.docId??Ra();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const d=new Set;let l=!1,f=!1,u;const g=new Set;let b=null;const E=()=>(b?.version!==i&&(b={version:i,value:t.read()}),b.value),I=v=>Object.entries(v).some(([y,w])=>s[y]!==w);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:E,mutate(v,{source:y}){if(l)return i;const w=v.changes?.length?v.changes:void 0,S=w?Ta(E(),w):v.content!==void 0?v.content:void 0,A=S!==void 0&&S!==E(),h=v.attributes!==void 0&&I(v.attributes);if(!A&&!h)return i;const c=!(i>(o??-1));return A&&t.write(S),h&&(s={...s,...v.attributes}),i+=1,y!=="user"&&c&&(o=i),d.forEach(a=>a({source:y,version:i,changes:w})),i},markSaved(v,y){const w={serverId:r,savedVersion:o};y!==void 0&&(r=y),(o===null||v>o)&&(o=v),(w.serverId!==r||w.savedVersion!==o)&&d.forEach(S=>S({source:"system",version:i}))},markReady(){f||u!==void 0||(f=!0,g.forEach(v=>v.resolve()),g.clear(),d.forEach(v=>v({source:"system",version:i})))},isReady:()=>f,markFailed(v){f||u!==void 0||l||(u=v,g.forEach(y=>y.reject(new ht(v))),g.clear(),d.forEach(y=>y({source:"system",version:i})))},failure:()=>u,whenReady(){return f?Promise.resolve():u!==void 0?Promise.reject(new ht(u)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((v,y)=>{g.add({resolve:v,reject:y})})},subscribe(v){return d.add(v),()=>d.delete(v)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>l,dispose(){l=!0,g.forEach(v=>v.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),g.clear(),d.clear(),t.dispose()}}}var Da=500,Oa=100,Rt=0;function xa(e,t={}){const n=t.groupIntervalMs??Da,r=t.maxSteps??Oa,i=t.now??(()=>0);let o=[],s=0,d=Rt+=1,l=null,f=!1,u=!1,g=!1;const b=new Set,E=()=>b.forEach(a=>a()),I=(a,p)=>{if(a.length){u=!0;try{e.mutate({changes:a},{source:p})}finally{u=!1}}},v=a=>I(a,"user"),y=a=>{const p=i();f&&l!==null&&p-l<n?o[s-1]=Jn(o[s-1],a):(o=o.slice(0,s),o.push(a),s=o.length,f=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,d=Rt+=1)),l=p,E()},w=()=>{f=!1,l=null},S=a=>{if(!a.length)return;const p=o.length>s;p&&(o=o.slice(0,s)),s>0&&(o[s-1]=Jn(o[s-1],a)),w(),p&&E()},A=e.subscribe(({source:a,changes:p})=>{if(!(g||u||!p?.length)){if(a==="remote"){h();return}if(a!=="user"){S(p);return}y(p)}}),h=()=>{o=[],s=0,w(),d=Rt+=1,E()},c=()=>{if(s===0)return!1;const a=Ia(o[s-1]);return Qn(e.getContent(),a)?(v(a),s-=1,w(),!0):(o=o.slice(0,s-1),s=o.length,w(),E(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){c()&&E()},redo(){if(!(s>=o.length)){if(!Qn(e.getContent(),o[s])){o=o.slice(0,s),w(),E();return}v(o[s]),s+=1,w(),E()}},clear:h,applyWithoutHistory(a){const p=e.get().version;if(I(a,"system"),e.get().version===p){w();return}S(a)},getPast:a=>o.slice(0,s).reverse().slice(0,a),getFuture:a=>o.slice(s).reverse().slice(0,a),createSnapshot:()=>({stackId:d,index:s}),restoreSnapshot(a){if(a.stackId!==d||a.index>s)return!1;for(;s>a.index;)if(!c())return E(),!1;return E(),!0},subscribe(a){return b.add(a),()=>b.delete(a)},dispose(){g=!0,A(),b.clear(),o=[],s=0}}}var La=["edit","move","resize","insert"];function Pt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Ma(e){return typeof e=="string"?e:null}function ka(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Na(e){return La.includes(e)?e:null}function Fa(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Ma(t.originId),changeId:Pt(t.changeId),rev:Pt(t.rev),baseRev:Pt(t.baseRev),expected:ka(t.expected),intent:Na(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var er=class extends Error{reason;constructor(e){super(`сохранение не состоялось: ${e}`),this.name="SaveRefusedError",this.reason=e}},Ii="draft";function Fe(e){return e==null||e===""?Ii:String(e)}function ja(e){return e==null||e===""?`${en}${Ii}`:`${en}${String(e)}`}var en="block:";function me(e){return e?.startsWith(en)===!0}function je(e){return me(e.sessionKey())?void 0:e.current()}function Ue(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return G(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(G(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw`${e}`,{error:String(i),...n},i})}function Ti(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Ai(e,{freshSince:t}={}){return!(!e?.slug?.includes("autosave")||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Ba(e,t={}){const n=Ti((e??[]).filter(r=>r?.html?.trim()));return Ai(n,t)?n:null}function Ua(e){const t=Date.parse(Ti(e)?.modified??"");return{autosave:Ba(e),...Number.isFinite(t)?{latestAt:t}:{}}}function Ha({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Ci=e=>e.replace(/\r\n?/g,`
997
+ `),tr=["recovery","plugin","rest"],Ga=["subject","preheader"];function qa(e){let t={},n;for(let i=tr.length-1;i>=0;i--){const o=e.get(tr[i]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const i of Ga){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Ri(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Ci(t.content):void 0,i=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...i?{changes:[new re(0,n,0,r)]}:{}},{source:"remote"})}var nr=e=>typeof e=="string"?e.trim():"";function $a(e,t,n){const{version:r,attributes:i}=e.get(),o=i,s=nr(o.title)||nr(o.subject);return{version:r,payload:{html:e.getContent(),title:s,subject:o.subject,preheader:o.preheader,description:o.description,common_styles:o.common_styles||"",meta:o.meta,utm_parameters:o.utm_parameters,parent_email:o.parent_email,is_template:o.is_template||!1,is_inited:o.is_inited,tags:o.tags,emailtags:o.emailtags,group:o.group,renderGuid:e.get().docId,project:t.project??o.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source}}}async function za(e,t,n,r,i){if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(i);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,i):t.saveAutosave(r,i)}function ge(e,t=!1){const n={};for(const r of Object.keys(e)){let i=e[r];i!==void 0&&!(typeof i=="number"&&Number.isNaN(i))&&(t&&typeof i=="object"&&i!==null&&(i=ge(i)),n[r]=i)}return n}var Va=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Pi(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Va.has(t))):{}}function mt(e,t,n={}){e&&e.mutate({attributes:Ka(e.get().attributes,t)},{source:n.source??"user"})}function Ka(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Cn(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Wa(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Di(e){if(!e)return null;const t=Pi(e);return e.common_styles!==void 0&&(t.common_styles=Wa(e.common_styles)),Cn(e.html,t)}function Oi(e){return e?Cn(e.html,ge(Pi(e))):null}var Ya=["common_styles","subject","preheader","meta"];function rr(e){if(!e?.html?.trim())return null;const t={};for(const n of Ya)Xa(n,e[n])&&(t[n]=e[n]);return Cn(e.html,t)}function Xa(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 Ja=10,Qa=(e,t)=>e.key===t.key&&Za(e.serverId,t.serverId),Za=(e,t)=>e==null||e===t;function el(e){return typeof e?.then=="function"}var ir=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},xi=e=>{e.request.serverId!=null&&e.document.markSaved(e.document.get().version)},tl=e=>{Ri(e.document,qa(e.reports)),xi(e)},Dt=(e,t)=>{if(!e.ready){tl(e);return}Ri(e.document,t)},nl=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 rl(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:d,onAdapterError:l,onTimeout:f}=e;let u;const g=new Set,b=new Set,E=()=>g.forEach(m=>m()),I=(m,_)=>{if(!(m.closed||m.ready)){if(m.error!==void 0){m.document.markFailed(m.error),m.document.get().docId;return}xi(m),m.ready=!0,m.document.markReady(),m.document.get().docId,[...m.reports.keys()]}},v=(m,_,T)=>{l?.(_.id,T),!(!_.required||m.closed)&&(m.error=T,m.document.get().docId,_.id,E())},y=(m,_)=>{const T=new Set(_.map(R=>R.id));_.forEach(R=>{R.watch&&m.watchers.push(R.watch(D=>m.closed?!1:m.ready&&D?.content!==void 0&&Ha({hasUnsavedUserEdit:m.document.isDirty()})==="skip"?(m.document.get().docId,R.id,!1):(D&&m.reports.set(R.id,D),Dt(m,D),!0)))});const P=(R,D)=>{m.closed||(D&&m.reports.set(R.id,D),Dt(m,D))},N=()=>{T.size>0||m.closed||(ir(m),I(m,[]))},X=[];if(_.forEach(R=>{let D;try{D=R.load()}catch(q){v(m,R,q),T.delete(R.id);return}if(el(D)){X.push({id:R.id,required:R.required,load:()=>D});return}P(R,D),T.delete(R.id)}),X.length===0){N();return}m.timer=setTimeout(()=>{m.timer=void 0,f?.([...T]),m.document.get().docId,[...T],I(m,[...T])},n),m.timer.unref?.(),X.forEach(R=>{R.load().then(D=>P(R,D)).catch(D=>{v(m,R,D)}).finally(()=>{T.delete(R.id),N()})})},w=async(m,_,T)=>{if(T==="snapshot"||T==="anchor")return;const P=o?.();if(P)return P.resolve({project:_.project??m.project,tags:(m.tags??[]).map(N=>({name:N}))})},S=m=>{if(m.lock===!0&&s?.(m)===!1)return new er("locked");const _=m.tags?.length??0,T=m.emailtags?.length??0;if(Math.max(_,T)>Ja)return new er("too-many-tags")},A=async(m,_,T)=>{try{await m.document.whenReady()}catch(D){return m.saveError=D,m.saveFailures+=1,m.saveFailures,!1}if(m.closed)return!1;const P=S(m.document.get().attributes);if(P)return m.saveError=P,m.saveFailures+=1,P.reason,E(),!1;if(d&&(await d(nl(m)).catch(()=>{}),m.closed))return!1;let N;try{N=await w(m.document.get().attributes,T,_)}catch(D){return m.saveError=D,m.saveFailures+=1,m.saveFailures,E(),!1}if(m.closed)return!1;const{payload:X,version:R}=$a(m.document,T,N);m.document.get().docId;try{const D=m.document.get().serverId!=null,q=await za(r(),i(m.request.key),_,m.document.get().serverId,X);if(m.closed)return!0;let j;if(_==="snapshot"||_==="anchor"){const x=q?.modified!=null?Date.parse(q.modified):NaN;j=Number.isFinite(x)?x:Date.now(),m.snapshotVersion=R,m.lastRevisionAt=j}else m.document.markSaved(R,q?.id!=null?String(q.id):void 0);const K=m.document.get().serverId;!D&&K!=null&&(m.recoveryFacts={emailId:K,historyLoaded:!0,isRecovering:!1}),m.saveError=void 0,m.saveFailures=0,m.document.get().serverId,E();const de={intent:_,serverId:m.document.get().serverId,created:!D,...j!==void 0?{revisionAt:j}:{}};return b.forEach(x=>x(de)),!0}catch(D){return m.saveError=D,m.saveFailures+=1,m.saveFailures,E(),!1}},h=()=>{u&&(u.closed=!0,u.watchers.forEach(m=>m()),u.watchers=[],ir(u),u.history.dispose(),u.document.dispose(),u=void 0)},c=(m,_,T)=>{let P=!1;_.show&&(m.show?.id!==_.show.id||m.show.token!==_.show.token)&&(m.show=_.show,P=!0,{docId:m.document.get().docId,..._.show});const N=T==="show"?Oi(_.patch):null;N&&(m.reports.set("plugin",N),Dt(m,N)),P&&E()},a=(m,_={})=>{const T=u;return!T||T.closed?Promise.resolve(!1):T.saving?m==="snapshot"?Promise.resolve(!1):(T.inFlight??Promise.resolve(!1)).then(()=>a(m,_)):(T.saving=!0,T.inFlight=A(T,m,_).finally(()=>{T.saving=!1,T.inFlight=void 0}),T.inFlight)},p=(m,_="open")=>{if(u&&!u.closed&&_!=="new"&&Qa(u.request,m))return c(u,m,_),u.document;h();const T=Pa({createBuffer:()=>_a(""),serverId:m.serverId??null}),P={request:m,show:m.show,document:T,history:xa(T,{now:Date.now}),watchers:[],saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return u=P,T.get().docId,m.serverId,y(P,t(m,{publishRecoveryFacts(N){P.closed||(P.recoveryFacts=N,E())},readShownContent:()=>P.closed?null:P.document.getContent()})),E(),T};return{openWith:p,open:(m,_={})=>p({key:Fe(m),serverId:m,email:_.email,patch:_.patch,show:_.show},"open"),openDraft:(m,_={})=>p({key:Fe(void 0),serverId:null,email:m,patch:_.patch,show:_.show},"open"),startNewDraft:(m,_={})=>p({key:Fe(void 0),serverId:null,email:m,patch:_.patch,show:_.show},"new"),reload:(m,_={})=>p({key:Fe(m),serverId:m,email:_.email,patch:_.patch,show:_.show},"new"),openBlock:(m,_)=>p({key:me(m)?m:ja(m),serverId:_?.id!=null?String(_.id):null,email:_},"open"),show:(m,_)=>{const T=u;if(!(!T||T.closed))return p({...T.request,patch:m,show:_},"show")},current:()=>u?.document,save:a,saveState:()=>({error:u?.saveError,failures:u?.saveFailures??0,saving:u?.saving===!0}),revisionFacts(){if(!u)return;const m=u.revisionFactsSnapshot;return m&&m.snapshotVersion===u.snapshotVersion&&m.lastRevisionAt===u.lastRevisionAt?m:(u.revisionFactsSnapshot={snapshotVersion:u.snapshotVersion,lastRevisionAt:u.lastRevisionAt},u.revisionFactsSnapshot)},recoveryFacts:()=>u?.recoveryFacts,history:()=>u?.history,forcedHeaders:()=>u?.forcedHeaders,beginForcedHeaders(m){u&&!u.closed&&(u.forcedHeaders=m)},endForcedHeaders(){u&&(u.forcedHeaders=void 0)},onSaved(m){return b.add(m),()=>b.delete(m)},showFacts:()=>u?.show,sessionKey:()=>u?.request.key,openError:()=>u?.error,subscribe(m){return g.add(m),()=>g.delete(m)},close(){u&&(h(),E())}}}var Li=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Mi(e){if(e instanceof Li)return e.reason;if(e instanceof ht)return Mi(e.reason)}function il(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Li("not-found");return Di(n)}}}var ki=O("EmailPort");function ol(e){return e.getInstance(ki)}function sl(e,t){e.inject(ki,t)}var Ni=O("documentSession.restEmailPortFactories");function Fi(e){return e.getInstance(Ni)!==void 0}function Se(e){const t=e.getInstance(Ni);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var al=O("EmailTermsResolver");function ll(e){return e.getInstance(al)}var ji=O("EmailHistoryPort"),dl=O("BlockHistoryPort");function Bi(e){return e.getInstance(dl)}function Ui(e){return e.getInstance(ji)}function cl(e,t){e.inject(ji,t)}var ul="em_autosave_pending";function gt(e){return`${ul}_${e}`}function fl(e,t){try{sessionStorage.setItem(gt(e),JSON.stringify(t))}catch{}}function pl(e){try{const t=sessionStorage.getItem(gt(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(gt(e)),null):n}catch{return null}}function nt(e){try{sessionStorage.removeItem(gt(e))}catch{}}var hl=2e3,ml=5e3,gl=5,vl=5e3,bl=4;function El(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function yl(e,t){return e==null||t==null?!1:e.replaceAll(`\r
998
998
  `,`
999
999
  `)===t.replaceAll(`\r
1000
1000
  `,`
1001
- `)}function El({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:d,pageLoadTs:l=vl()}){let f=null,u=!1,g=!1,b=0,E={emailId:e,historyLoaded:!1,isRecovering:!1},I=null;const v=new Promise(R=>{I=R}),y=R=>{E={...E,...R},o(E)},w=R=>{b+=1,y({applied:{phase:R,seq:b}})},S=()=>{f?.timer&&clearTimeout(f.timer),f=null},A=R=>{if(!g){if(I){const D=I;I=null,D(R),R.revision&&w(R.phase);return}s(R)&&R.revision&&w(R.phase)}},h=()=>{if(!f||g)return;const R=f.phase==="fast",D=R?fl:ml,q=R?hl:gl;f.timer=setTimeout(()=>{const j=f;if(!(!j||g)){if(j.attempts+=1,_(),R&&j.attempts>=q){const{pending:K}=j;nt(e),y({isRecovering:!1}),A({revision:{html:K.html,common_styles:K.common_styles,subject:K.subject,preheader:K.preheader},phase:"timeout"}),u=!0,j.phase="bg",j.attempts=0,h();return}if(!R&&j.attempts>=q){nt(e),S(),y({isRecovering:!1}),u=!0;return}h()}},D),f.timer.unref?.()},c=R=>{f={phase:"fast",attempts:0,pending:R,timer:null},y({isRecovering:!0}),h()},a=(R,D)=>Ii(R.autosave,D===void 0?{}:{freshSince:D})?R.autosave:null,p=R=>{if(g)return;if(y({historyLoaded:!0,latestRevisionAt:R.latestAt!==void 0&&Number.isFinite(R.latestAt)?R.latestAt:void 0}),n&&f){const j=a(R,f.pending.sentAt);if(!j)return;const K=f.phase==="fast"?"found":"bg";nt(e),S(),y({isRecovering:!1}),u=!0,A({revision:j,phase:K});return}if(u)return;const D=n?ul(e):null,q=D&&(D.sentAt<l||!bl(D.html,i()))?D:null;if(q){const j=a(R,q.sentAt);if(j){nt(e),u=!0,A({revision:j,phase:"found"});return}c(q);return}u=!0,A({revision:a(R),phase:"normal"})},m=R=>{g||(d?.(R),E.historyLoaded||(y({historyLoaded:!1,latestRevisionAt:void 0}),N()),!f&&A({revision:null,phase:"normal"}))},_=()=>t(e).then(p).catch(m);let T,P=!1;const N=()=>{P||f||g||(P=!0,T=setTimeout(()=>{T=void 0,!g&&!E.historyLoaded&&_()},pl))},X=()=>{g||(y({historyLoaded:!1,latestRevisionAt:void 0}),A({revision:null,phase:"normal"}))};return r?r().then(R=>R?_():X()):_(),{verdict:()=>v,dispose(){g=!0,T!==void 0&&(clearTimeout(T),T=void 0),S()}}}function yl({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const d=El({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:l,phase:f})=>{const u=nr(l);return s?.(u)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:l})=>nr(l)),watch(l){return s=l,()=>{s=null,d.dispose()}}}}function Bi(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){cl(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function _l(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=await t.updateEmail(n,r);return await e.updateEmail(n,r),i}}}var Ui=O("CurrentUser"),Hi={};function Gi(e){return e.getOrCreateInstance(Ui,()=>Me(Hi))}function qi(e){return e?.getInstance(Ui)?.get()??Hi}function $i(e){return e?.getInstance(we)?.get()??{}}var wl=1.5;function Sl(e){return!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=wl*e.autosaveTimeoutMs?"none":"revision"}var Il=4;function Tl(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=()=>n().autosaveTimeoutMs*2**Math.min(o(),Il),d=()=>{const w=t();if(!w||w.isDisposed())return"none";const{latestRevisionAt:S,snapshotVersion:A,...h}=n();return Sl({...h,isDirty:w.isDirty(),isNew:w.isNew(),isReady:w.isReady(),latestRevisionAgeMs:S!=null?Date.now()-S:void 0,isSnapshotSent:A!=null&&A===w.get().version})},l=()=>{const w=t();if(!w||w.isDisposed())return!1;if(!w.isDirty())return w.isNew();const{snapshotVersion:S}=n();return!(S!=null&&S===w.get().version)};let f,u,g,b,E=!1;const I=()=>{u=void 0;const w=t();if(!w||w.isDisposed())return;if(w.get().docId!==f){v();return}const S=d();S==="create"?r():S==="revision"?i():l()&&(f=w.get().docId,u=setTimeout(I,s()))},v=()=>{const w=t();E||!w||u!==void 0||d()==="none"&&!l()||(f=w.get().docId,u=setTimeout(I,s()))},y=()=>{const w=t();w!==g&&(b?.(),g=w,b=w?.subscribe(v),u!==void 0&&(clearTimeout(u),u=void 0))};return y(),v(),{refresh:()=>{E||(y(),v())},stop:()=>{E=!0,b?.(),b=void 0,g=void 0,u!==void 0&&(clearTimeout(u),u=void 0)}}}var zi=O("documentSession.autosaveUiFacts"),Vi={isUserBusy:!1,saveContext:{}};function Al(e){return e.getOrCreateInstance(zi,()=>Me(Vi))}function ir(e){return e?.getInstance(zi)?.get()??Vi}var Cl=1e4;function Rl(e,t){const n=()=>{const l=t.current(),f=l?.get().serverId??void 0,u=me(t.sessionKey()),g=t.recoveryFacts(),b=g?.emailId===f?g:void 0,E=t.revisionFacts(),I=b?.latestRevisionAt,v=E?.lastRevisionAt,y=qi(e).profile;return{isInited:u||l?.get().attributes.is_inited===!0,isEnabled:!!y?.autosaves,isHistoryLoaded:b?.historyLoaded===!0,isUserBusy:ir(e).isUserBusy,autosaveTimeoutMs:$i(e).autosaveTimeout||Cl,latestRevisionAt:I!==void 0||v!==void 0?Math.max(I??0,v??0):void 0,snapshotVersion:E?.snapshotVersion}},r=()=>{const l=ir(e).saveContext;return{...l,project:l.project??t.current()?.get().attributes.project}},i=Tl({readDocument:()=>t.current(),readEnvironment:n,readFailures:()=>t.saveState().failures,onCreate:()=>{me(t.sessionKey())||t.save("materialize",r())},onRevision:()=>{t.save("snapshot",{project:r().project})}}),o=t.subscribe(i.refresh),s=Gi(e).watch(()=>i.refresh()),d=Al(e).watch(()=>i.refresh());return()=>{o(),s.dispose(),d.dispose(),i.stop()}}var or=12e3;function ve(e){return e.getOrCreateInstance(In,()=>{const t=tl({resolveAdapters:(r,i)=>Ol(r,e,i),resolveWritePort:()=>Ki(e),resolveHistoryPort:r=>me(r)?Yi(e):Wi(e),resolveTerms:()=>sl(e),canEdit:r=>da(e,r),notifyBeforeSave:ga(e),timeoutMs:or,onAdapterError:(r,i)=>{i instanceof Error&&i.message,yt(i,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=Rl(e,t);return e.getInstance(k)?.addDispose(n),t})}function Cn(e){return e?.getInstance(In)}function Ki(e){const t=rl(e);return t?Rn(e)?_l(t,Se(e).email(e)):t:Se(e).email(e)}function Pl(e){return ji(e)!==void 0||ki(e)}function Wi(e){const t=ji(e);return t?Rn(e)?(G("port:history:server-backed"),Bi(t,Se(e).history(e))):(G("port:history:integrator"),t):(G("port:history:rest (порт не зарегистрирован)"),Se(e).history(e))}function Yi(e){const t=Fi(e);return t?Rn(e)?(G("port:block-history:server-backed"),Bi(t,Se(e).blockHistory(e))):(G("port:block-history:integrator"),t):(G("port:block-history:rest (порт не зарегистрирован)"),Se(e).blockHistory(e))}function Dl(e){return Fi(e)!==void 0||ki(e)}function Rn(e){return pi(e)}function Ol({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>Ri(e),required:!0}):n&&s.push(nl(Ki(i),n)),t&&s.push({id:"plugin",load:()=>Pi(t)});const d=me(r);return va(n)&&(d?Dl(i):Pl(i))&&s.push(yl({port:d?Yi(i):Wi(i),revisionServiceEnabled:pi(i),...!d&&ca(i)?{isHistoryAvailable:()=>ua(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),s}function Y(e){return e.getOrCreateInstance(We,()=>new Ye)}var Xi=new WeakMap,en=new WeakMap;function ue(e){return Xi.get(e)??0}function Ji(e,t){let n=en.get(e);return n||(n=new Set,en.set(e,n)),n.add(t),()=>{n?.delete(t)}}function xl(e){Xi.set(e,ue(e)+1),en.get(e)?.forEach(t=>t())}function Ll(e){const t=ve(e),n=Y(e).addListener(M.APPLICATION_HAS_AMP,r=>{je(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(k)?.addDispose(()=>n.dispose())}function Ml(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function kl(e){const t=e.fetchImpl??((o,s)=>fetch(o,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,i=o=>{try{const s=new URL(o,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:i,async load(o){if(!i(o))return;const s=!r.has(o);r.add(o);try{const d=await t(o,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!d.ok)return;const l=await d.blob();return Ml(l)?l:void 0}catch{return}}}}var _e={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Nl(e){const t={maxBytes:e.maxBytes??_e.maxBytes,maxImageBytes:e.maxImageBytes??_e.maxImageBytes,ttlMs:e.ttlMs??_e.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const d=g=>{const b=r.get(g);b&&(s-=b.bytes,r.delete(g))},l=g=>t.ttlMs<=0||n()-g.storedAt<t.ttlMs,f=()=>{if(s<=t.maxBytes)return;const g=[...r.entries()].sort((b,E)=>b[1].usedAt-E[1].usedAt);for(const[b]of g){if(s<=t.maxBytes)return;d(b)}},u=(g,b)=>{b.size>t.maxImageBytes||(r.set(g,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,f())};return{async get(g){const b=r.get(g);if(b&&l(b))return b.usedAt=n(),o.hits+=1,b.blob;b&&d(g);const E=i.get(g);if(E!==void 0)return E;o.loads+=1;const I=(async()=>{try{const v=await e.load(g);return v?u(g,v):o.failures+=1,v}catch{o.failures+=1;return}finally{i.delete(g)}})();return i.set(g,I),I},forget(g){d(g),i.delete(g)},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var Fl=["emcdn.ru","scr.emcdn.ru"];function jl(e){const t=String(e??"").trim();if(!t)return"";try{return new URL(t.includes("//")?t:`https://${t}`).hostname}catch{return t.split("/")[0].split(":")[0]}}function Bl(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const d=jl(s);d&&o.add(d)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function sr(e){const t=e??{},n=t.isPlugin!==!0?Fl:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],..._e};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:Bl(i.sourceHosts,n),maxBytes:i.maxBytes??_e.maxBytes,maxImageBytes:i.maxImageBytes??_e.maxImageBytes,ttlMs:i.ttlMs??_e.ttlMs}}function Ul(e){const t=Y(e),n=e.getInstance(we);let r=sr(n?.get());const i=kl({sourceHosts:()=>r.sourceHosts}),o=Nl({load:I=>i.load(I),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),s=()=>{t.send(M.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},d=t.onInit(()=>s()),l=n?.watch(()=>{const I=sr(n.get()),v=JSON.stringify(I)!==JSON.stringify(r);r=I,I.enabled||o.clear(),v&&t.isInited()&&s()}),f={asked:0,served:0,refused:0},u=[],g=(I,v)=>(f.refused+=1,u.push({url:I,reason:v}),u.length>20&&u.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...f},refusals:[...u],store:o.stats()})}),E=t.addListenerAsync(M.APPLICATION_CANVAS_IMAGE_GET,async I=>{const v=I?.url??"";if(f.asked+=1,!r.enabled||!v)return g(v,"disabled");if(!i.accepts(v))return g(v,"host");I.fresh&&o.forget(v);const y=await o.get(v);return y?(f.served+=1,{blob:y}):g(v,"load-failed")});e.getInstance(k)?.addDispose(()=>{d.dispose(),l?.dispose(),E.dispose(),o.clear(),delete b.__emmCanvasImages__})}var Hl=2e3;function Gl(e){const t=Y(e),n=new Set,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;const d=new MessageChannel;let l=!1;const f=g=>{g.data?.operationId==="em:port-ready"&&(l=!0,d.port1.removeEventListener("message",f),t.drainWindow(s))};d.port1.addEventListener("message",f),t.sendPort(s,d.port2),t.usePort(d.port1,!1,s);const u=setTimeout(()=>{n.delete(u),!l&&(yt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d.port1.removeEventListener("message",f),t.useWindow(s))},Hl);n.add(u)},i=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),o=t.onInit(()=>r());e.getInstance(k)?.addDispose(()=>{for(const s of n)clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var ql=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function $l(e){return ql.test(e)||e.indexOf("//")===0}function rt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function zl(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function ar(e,t){const n=e==null||e===""?"./":String(e);if($l(n))return rt(n);const r=t??zl();if(!r)return rt(n);try{return rt(new URL(n,r).href)}catch{return rt(n)}}function Vl(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?ar(window.__useblocks__.publicPath):ar("/")}var Kl=()=>"",Wl=()=>"168aeeb1";function Qi(e){const t=e?"iframe-eblock":"iframe",n=Kl();if(n){const o=n.replace(/\/?$/,"/");return Kn(`${o}${t}.html`,qe())}const r=Wl(),i=`${Vl().replace(/\/?$/,"/")}iframe/`;return Kn(`${i}${t}${r?`.${r}`:""}.html`,qe())}var lr="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function tn(e){return/^file:/i.test(String(e||"").trim())}function Yl(e){return tn(e)?`${lr} allow-same-origin`:lr}var Xl="em:module-body-ack";function Jl(e,t,n){try{const r=new URL("./",new URL(t,n)).href,i=new URL(e,r).href;return i.startsWith(r)?i:void 0}catch{return}}function Pn(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.[0-9a-f]{6,})?\.html$/.exec(t);return n?`js/${n[1]}.body.js`:void 0}function Ql(e,t){const n=Pn(t)?.replace(/^js\/|\.body\.js$/g,""),r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function Zl(e,t){const n=Pn(t)?.replace(/\.body\.js$/,".js");if(!n||!(n in e))return[];const r=new Set([n]),i=[n],o=[];for(;i.length>0;)for(const s of e[i.shift()]??[])r.has(s)||(r.add(s),o.push(s),i.push(s));return o}async function ed(e){try{const t=await fetch(e);return t.ok?await t.blob():void 0}catch{return}}function td(e){const t=new Map,n=r=>{const i=Jl(r,e.canvasSrc,e.origin);if(!i)return;const o=t.get(i);if(o!==void 0)return o;const s=e.fetchBody(i);return t.set(i,s),s};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r){for(const i of r)n(i)},reset(){t.clear()},get size(){return t.size}}}async function nd(e,t,n){try{const r=new URL(".vite/manifest.json",new URL("./",new URL(e,t))).href,i=await fetch(r);if(!i.ok)return;const o=await i.json();n(Ql(o,e))}catch{}}function rd(e){try{return tn(new URL(e,window.location.href).href)}catch{return tn(window.location.href)}}function id(e){Y(e);const t=Qi(!1);if(rd(t))return;const n=td({canvasSrc:t,origin:window.location.href,fetchBody:ed}),r=Pn(t);r&&n.warm([r]);const i={"js/iframe-eblock.js":["js/discussHandlers.BxlCsZ-4.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.BxlCsZ-4.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.BxlCsZ-4.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};i?n.warm(Zl(i,t)):nd(t,window.location.href,s=>n.warm(s));const o=s=>{const d=s.data;if(!d||d.operationId!=="em:module-body"||!d.result)return;const l=s.source;l&&(l.postMessage({operationId:Xl,for:d.result},"*"),n.take(d.data?.url??"").then(f=>{l.postMessage({operationId:d.result,data:f??null},"*")}))};window.addEventListener("message",o),e.getInstance(k)?.addDispose(()=>{window.removeEventListener("message",o),n.reset()})}var Ae=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,od=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Oe=/<style\b[^>]*>[\s\S]*?<\/style>/gi,dr=/display:\s*none\s*!important/gi,sd=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,ad=/\s*height\s*:\s*100%\s*!important\s*;?/gi,ld=/height\s*:\s*100%\s*!important/i,dd=[".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 cd(e){return dr.lastIndex=0,(e.match(dr)||[]).length}function Zi(e){const t=e.trim(),n=cd(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=dd.filter(i=>t.includes(i)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function ud(e){Oe.lastIndex=0;for(const t of e.matchAll(Oe))if(Zi(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function fd(e){let t=!1;return Oe.lastIndex=0,{html:e.replace(Oe,n=>Zi(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function pd(e){return Ae.lastIndex=0,Ae.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||ud(e)}function hd(e){if(!pd(e))return{html:e,found:!1};let t=!1,n=e;Ae.lastIndex=0,Ae.test(n)&&(Ae.lastIndex=0,n=n.replace(Ae,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(od,""),t=!0);const r=fd(n);return n=r.html,t=t||r.found,{html:n,found:t}}function md(e){return!e||!ld.test(e)?e:(Oe.lastIndex=0,e.replace(Oe,t=>t.replace(sd,(n,r,i,o)=>`${r}${i.replace(ad,"")}${o}`)))}function eo(e){const t=hd(e.replaceAll(`\r
1001
+ `)}function _l({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:d,pageLoadTs:l=El()}){let f=null,u=!1,g=!1,b=0,E={emailId:e,historyLoaded:!1,isRecovering:!1},I=null;const v=new Promise(R=>{I=R}),y=R=>{E={...E,...R},o(E)},w=R=>{b+=1,y({applied:{phase:R,seq:b}})},S=()=>{f?.timer&&clearTimeout(f.timer),f=null},A=R=>{if(!g){if(I){const D=I;I=null,D(R),R.revision&&w(R.phase);return}s(R)&&R.revision&&w(R.phase)}},h=()=>{if(!f||g)return;const R=f.phase==="fast",D=R?hl:vl,q=R?gl:bl;f.timer=setTimeout(()=>{const j=f;if(!(!j||g)){if(j.attempts+=1,_(),R&&j.attempts>=q){const{pending:K}=j;nt(e),y({isRecovering:!1}),A({revision:{html:K.html,common_styles:K.common_styles,subject:K.subject,preheader:K.preheader},phase:"timeout"}),u=!0,j.phase="bg",j.attempts=0,h();return}if(!R&&j.attempts>=q){nt(e),S(),y({isRecovering:!1}),u=!0;return}h()}},D),f.timer.unref?.()},c=R=>{f={phase:"fast",attempts:0,pending:R,timer:null},y({isRecovering:!0}),h()},a=(R,D)=>Ai(R.autosave,D===void 0?{}:{freshSince:D})?R.autosave:null,p=R=>{if(g)return;if(y({historyLoaded:!0,latestRevisionAt:R.latestAt!==void 0&&Number.isFinite(R.latestAt)?R.latestAt:void 0}),n&&f){const j=a(R,f.pending.sentAt);if(!j)return;const K=f.phase==="fast"?"found":"bg";nt(e),S(),y({isRecovering:!1}),u=!0,A({revision:j,phase:K});return}if(u)return;const D=n?pl(e):null,q=D&&(D.sentAt<l||!yl(D.html,i()))?D:null;if(q){const j=a(R,q.sentAt);if(j){nt(e),u=!0,A({revision:j,phase:"found"});return}c(q);return}u=!0,A({revision:a(R),phase:"normal"})},m=R=>{g||(d?.(R),E.historyLoaded||(y({historyLoaded:!1,latestRevisionAt:void 0}),N()),!f&&A({revision:null,phase:"normal"}))},_=()=>t(e).then(p).catch(m);let T,P=!1;const N=()=>{P||f||g||(P=!0,T=setTimeout(()=>{T=void 0,!g&&!E.historyLoaded&&_()},ml))},X=()=>{g||(y({historyLoaded:!1,latestRevisionAt:void 0}),A({revision:null,phase:"normal"}))};return r?r().then(R=>R?_():X()):_(),{verdict:()=>v,dispose(){g=!0,T!==void 0&&(clearTimeout(T),T=void 0),S()}}}function wl({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const d=_l({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:l,phase:f})=>{const u=rr(l);return s?.(u)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:l})=>rr(l)),watch(l){return s=l,()=>{s=null,d.dispose()}}}}function Hi(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){fl(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function Sl(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=await t.updateEmail(n,r);return await e.updateEmail(n,r),i}}}var Gi=O("CurrentUser"),qi={};function $i(e){return e.getOrCreateInstance(Gi,()=>Me(qi))}function zi(e){return e?.getInstance(Gi)?.get()??qi}function Vi(e){return e?.getInstance(we)?.get()??{}}var Il=1.5;function Tl(e){return!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=Il*e.autosaveTimeoutMs?"none":"revision"}var Al=4;function Cl(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=()=>n().autosaveTimeoutMs*2**Math.min(o(),Al),d=()=>{const w=t();if(!w||w.isDisposed())return"none";const{latestRevisionAt:S,snapshotVersion:A,...h}=n();return Tl({...h,isDirty:w.isDirty(),isNew:w.isNew(),isReady:w.isReady(),latestRevisionAgeMs:S!=null?Date.now()-S:void 0,isSnapshotSent:A!=null&&A===w.get().version})},l=()=>{const w=t();if(!w||w.isDisposed())return!1;if(!w.isDirty())return w.isNew();const{snapshotVersion:S}=n();return!(S!=null&&S===w.get().version)};let f,u,g,b,E=!1;const I=()=>{u=void 0;const w=t();if(!w||w.isDisposed())return;if(w.get().docId!==f){v();return}const S=d();S==="create"?r():S==="revision"?i():l()&&(f=w.get().docId,u=setTimeout(I,s()))},v=()=>{const w=t();E||!w||u!==void 0||d()==="none"&&!l()||(f=w.get().docId,u=setTimeout(I,s()))},y=()=>{const w=t();w!==g&&(b?.(),g=w,b=w?.subscribe(v),u!==void 0&&(clearTimeout(u),u=void 0))};return y(),v(),{refresh:()=>{E||(y(),v())},stop:()=>{E=!0,b?.(),b=void 0,g=void 0,u!==void 0&&(clearTimeout(u),u=void 0)}}}var Ki=O("documentSession.autosaveUiFacts"),Wi={isUserBusy:!1,saveContext:{}};function Rl(e){return e.getOrCreateInstance(Ki,()=>Me(Wi))}function or(e){return e?.getInstance(Ki)?.get()??Wi}var Pl=1e4;function Dl(e,t){const n=()=>{const l=t.current(),f=l?.get().serverId??void 0,u=me(t.sessionKey()),g=t.recoveryFacts(),b=g?.emailId===f?g:void 0,E=t.revisionFacts(),I=b?.latestRevisionAt,v=E?.lastRevisionAt,y=zi(e).profile;return{isInited:u||l?.get().attributes.is_inited===!0,isEnabled:!!y?.autosaves,isHistoryLoaded:b?.historyLoaded===!0,isUserBusy:or(e).isUserBusy,autosaveTimeoutMs:Vi(e).autosaveTimeout||Pl,latestRevisionAt:I!==void 0||v!==void 0?Math.max(I??0,v??0):void 0,snapshotVersion:E?.snapshotVersion}},r=()=>{const l=or(e).saveContext;return{...l,project:l.project??t.current()?.get().attributes.project}},i=Cl({readDocument:()=>t.current(),readEnvironment:n,readFailures:()=>t.saveState().failures,onCreate:()=>{me(t.sessionKey())||t.save("materialize",r())},onRevision:()=>{t.save("snapshot",{project:r().project})}}),o=t.subscribe(i.refresh),s=$i(e).watch(()=>i.refresh()),d=Rl(e).watch(()=>i.refresh());return()=>{o(),s.dispose(),d.dispose(),i.stop()}}var sr=12e3;function ve(e){return e.getOrCreateInstance(Tn,()=>{const t=rl({resolveAdapters:(r,i)=>Ll(r,e,i),resolveWritePort:()=>Yi(e),resolveHistoryPort:r=>me(r)?Ji(e):Xi(e),resolveTerms:()=>ll(e),canEdit:r=>ua(e,r),notifyBeforeSave:ba(e),timeoutMs:sr,onAdapterError:(r,i)=>{i instanceof Error&&i.message,yt(i,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=Dl(e,t);return e.getInstance(k)?.addDispose(n),t})}function Rn(e){return e?.getInstance(Tn)}function Yi(e){const t=ol(e);return t?Pn(e)?Sl(t,Se(e).email(e)):t:Se(e).email(e)}function Ol(e){return Ui(e)!==void 0||Fi(e)}function Xi(e){const t=Ui(e);return t?Pn(e)?(G("port:history:server-backed"),Hi(t,Se(e).history(e))):(G("port:history:integrator"),t):(G("port:history:rest (порт не зарегистрирован)"),Se(e).history(e))}function Ji(e){const t=Bi(e);return t?Pn(e)?(G("port:block-history:server-backed"),Hi(t,Se(e).blockHistory(e))):(G("port:block-history:integrator"),t):(G("port:block-history:rest (порт не зарегистрирован)"),Se(e).blockHistory(e))}function xl(e){return Bi(e)!==void 0||Fi(e)}function Pn(e){return mi(e)}function Ll({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>Di(e),required:!0}):n&&s.push(il(Yi(i),n)),t&&s.push({id:"plugin",load:()=>Oi(t)});const d=me(r);return Ea(n)&&(d?xl(i):Ol(i))&&s.push(wl({port:d?Ji(i):Xi(i),revisionServiceEnabled:mi(i),...!d&&fa(i)?{isHistoryAvailable:()=>pa(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),s}function Y(e){return e.getOrCreateInstance(We,()=>new Ye)}var Qi=new WeakMap,tn=new WeakMap;function ue(e){return Qi.get(e)??0}function Zi(e,t){let n=tn.get(e);return n||(n=new Set,tn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Ml(e){Qi.set(e,ue(e)+1),tn.get(e)?.forEach(t=>t())}function kl(e){const t=ve(e),n=Y(e).addListener(M.APPLICATION_HAS_AMP,r=>{je(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(k)?.addDispose(()=>n.dispose())}function Nl(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Fl(e){const t=e.fetchImpl??((o,s)=>fetch(o,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,i=o=>{try{const s=new URL(o,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:i,async load(o){if(!i(o))return;const s=!r.has(o);r.add(o);try{const d=await t(o,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!d.ok)return;const l=await d.blob();return Nl(l)?l:void 0}catch{return}}}}var _e={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function jl(e){const t={maxBytes:e.maxBytes??_e.maxBytes,maxImageBytes:e.maxImageBytes??_e.maxImageBytes,ttlMs:e.ttlMs??_e.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const d=g=>{const b=r.get(g);b&&(s-=b.bytes,r.delete(g))},l=g=>t.ttlMs<=0||n()-g.storedAt<t.ttlMs,f=()=>{if(s<=t.maxBytes)return;const g=[...r.entries()].sort((b,E)=>b[1].usedAt-E[1].usedAt);for(const[b]of g){if(s<=t.maxBytes)return;d(b)}},u=(g,b)=>{b.size>t.maxImageBytes||(r.set(g,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,f())};return{async get(g){const b=r.get(g);if(b&&l(b))return b.usedAt=n(),o.hits+=1,b.blob;b&&d(g);const E=i.get(g);if(E!==void 0)return E;o.loads+=1;const I=(async()=>{try{const v=await e.load(g);return v?u(g,v):o.failures+=1,v}catch{o.failures+=1;return}finally{i.delete(g)}})();return i.set(g,I),I},forget(g){d(g),i.delete(g)},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var Bl=["emcdn.ru","scr.emcdn.ru"];function Ul(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 Hl(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const d=Ul(s);d&&o.add(d)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function ar(e){const t=e??{},n=t.isPlugin!==!0?Bl:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],..._e};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:Hl(i.sourceHosts,n),maxBytes:i.maxBytes??_e.maxBytes,maxImageBytes:i.maxImageBytes??_e.maxImageBytes,ttlMs:i.ttlMs??_e.ttlMs}}function Gl(e){const t=Y(e),n=e.getInstance(we);let r=ar(n?.get());const i=Fl({sourceHosts:()=>r.sourceHosts}),o=jl({load:I=>i.load(I),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),s=()=>{t.send(M.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},d=t.onInit(()=>s()),l=n?.watch(()=>{const I=ar(n.get()),v=JSON.stringify(I)!==JSON.stringify(r);r=I,I.enabled||o.clear(),v&&t.isInited()&&s()}),f={asked:0,served:0,refused:0},u=[],g=(I,v)=>(f.refused+=1,u.push({url:I,reason:v}),u.length>20&&u.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...f},refusals:[...u],store:o.stats()})}),E=t.addListenerAsync(M.APPLICATION_CANVAS_IMAGE_GET,async I=>{const v=I?.url??"";if(f.asked+=1,!r.enabled||!v)return g(v,"disabled");if(!i.accepts(v))return g(v,"host");I.fresh&&o.forget(v);const y=await o.get(v);return y?(f.served+=1,{blob:y}):g(v,"load-failed")});e.getInstance(k)?.addDispose(()=>{d.dispose(),l?.dispose(),E.dispose(),o.clear(),delete b.__emmCanvasImages__})}var ql=2e3;function $l(e){const t=Y(e),n=new Set,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;const d=new MessageChannel;let l=!1;const f=g=>{g.data?.operationId==="em:port-ready"&&(l=!0,d.port1.removeEventListener("message",f),t.drainWindow(s))};d.port1.addEventListener("message",f),t.sendPort(s,d.port2),t.usePort(d.port1,!1,s);const u=setTimeout(()=>{n.delete(u),!l&&(yt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d.port1.removeEventListener("message",f),t.useWindow(s))},ql);n.add(u)},i=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),o=t.onInit(()=>r());e.getInstance(k)?.addDispose(()=>{for(const s of n)clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var zl=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Vl(e){return zl.test(e)||e.indexOf("//")===0}function rt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Kl(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function lr(e,t){const n=e==null||e===""?"./":String(e);if(Vl(n))return rt(n);const r=t??Kl();if(!r)return rt(n);try{return rt(new URL(n,r).href)}catch{return rt(n)}}function Wl(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?lr(window.__useblocks__.publicPath):lr("/")}var Yl=()=>"",Xl=()=>"fc97f6e8";function eo(e){const t=e?"iframe-eblock":"iframe",n=Yl();if(n){const o=n.replace(/\/?$/,"/");return Wn(`${o}${t}.html`,qe())}const r=Xl(),i=`${Wl().replace(/\/?$/,"/")}iframe/`;return Wn(`${i}${t}${r?`.${r}`:""}.html`,qe())}var dr="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function nn(e){return/^file:/i.test(String(e||"").trim())}function Jl(e){return nn(e)?`${dr} allow-same-origin`:dr}var Ql="em:module-body-ack";function Zl(e,t,n){try{const r=new URL("./",new URL(t,n)).href,i=new URL(e,r).href;return i.startsWith(r)?i:void 0}catch{return}}function Dn(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.[0-9a-f]{6,})?\.html$/.exec(t);return n?`js/${n[1]}.body.js`:void 0}function ed(e,t){const n=Dn(t)?.replace(/^js\/|\.body\.js$/g,""),r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function td(e,t){const n=Dn(t)?.replace(/\.body\.js$/,".js");if(!n||!(n in e))return[];const r=new Set([n]),i=[n],o=[];for(;i.length>0;)for(const s of e[i.shift()]??[])r.has(s)||(r.add(s),o.push(s),i.push(s));return o}async function nd(e){try{const t=await fetch(e);return t.ok?await t.blob():void 0}catch{return}}function rd(e){const t=new Map,n=r=>{const i=Zl(r,e.canvasSrc,e.origin);if(!i)return;const o=t.get(i);if(o!==void 0)return o;const s=e.fetchBody(i);return t.set(i,s),s};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r){for(const i of r)n(i)},reset(){t.clear()},get size(){return t.size}}}async function id(e,t,n){try{const r=new URL(".vite/manifest.json",new URL("./",new URL(e,t))).href,i=await fetch(r);if(!i.ok)return;const o=await i.json();n(ed(o,e))}catch{}}function od(e){try{return nn(new URL(e,window.location.href).href)}catch{return nn(window.location.href)}}function sd(e){Y(e);const t=eo(!1);if(od(t))return;const n=rd({canvasSrc:t,origin:window.location.href,fetchBody:nd}),r=Dn(t);r&&n.warm([r]);const i={"js/iframe-eblock.js":["js/discussHandlers.Cyqpdj2X.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.Cyqpdj2X.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.Cyqpdj2X.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};i?n.warm(td(i,t)):id(t,window.location.href,s=>n.warm(s));const o=s=>{const d=s.data;if(!d||d.operationId!=="em:module-body"||!d.result)return;const l=s.source;l&&(l.postMessage({operationId:Ql,for:d.result},"*"),n.take(d.data?.url??"").then(f=>{l.postMessage({operationId:d.result,data:f??null},"*")}))};window.addEventListener("message",o),e.getInstance(k)?.addDispose(()=>{window.removeEventListener("message",o),n.reset()})}var Ae=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,ad=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Oe=/<style\b[^>]*>[\s\S]*?<\/style>/gi,cr=/display:\s*none\s*!important/gi,ld=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,dd=/\s*height\s*:\s*100%\s*!important\s*;?/gi,cd=/height\s*:\s*100%\s*!important/i,ud=[".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 fd(e){return cr.lastIndex=0,(e.match(cr)||[]).length}function to(e){const t=e.trim(),n=fd(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=ud.filter(i=>t.includes(i)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function pd(e){Oe.lastIndex=0;for(const t of e.matchAll(Oe))if(to(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function hd(e){let t=!1;return Oe.lastIndex=0,{html:e.replace(Oe,n=>to(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function md(e){return Ae.lastIndex=0,Ae.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||pd(e)}function gd(e){if(!md(e))return{html:e,found:!1};let t=!1,n=e;Ae.lastIndex=0,Ae.test(n)&&(Ae.lastIndex=0,n=n.replace(Ae,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(ad,""),t=!0);const r=hd(n);return n=r.html,t=t||r.found,{html:n,found:t}}function vd(e){return!e||!cd.test(e)?e:(Oe.lastIndex=0,e.replace(Oe,t=>t.replace(ld,(n,r,i,o)=>`${r}${i.replace(dd,"")}${o}`)))}function no(e){const t=gd(e.replaceAll(`\r
1002
1002
  `,`
1003
- `));return{html:md(t.html),hasBrowserExtensionArtifacts:t.found}}function nn(e){return e?.getContent()??""}function to(e,t){e?.mutate({content:Ti(t)},{source:"remote"})}function no(e){return O(e)}function ie(e,t){return e.getOrCreateInstance(t,()=>new pe)}function V(e,t){return e.getOrCreateInstance(t,()=>new pe).event}function rn(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var gd=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}},vd=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,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new gd(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(te(n.reason))})};n.addEventListener("abort",s,{once:!0});const d=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:d});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function bd(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Ed(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Ei(e),n=yi(e),r=pa(e.sandbox);t<n+r}var ro=class{_controller=new AbortController;_externalSignalDisposable=new Q;_sessionChangeListeners=new Set;_showRegistry=new vd;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Ei(this._timeouts)}getSandboxTimeoutMs(e){return bi(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return yi(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=bd(this._timeouts,e.timeouts),Ed(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}abort(e){const t=e??te("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Q}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Q,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)})}},Dn=(()=>{const e=new ro;return e.configure({}),e})(),yd=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 _d(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 wd(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():($(n),new Promise((r,i)=>{let o=!1,s,d;const l=u=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),d?.dispose(),n?.removeEventListener("abort",f),u())},f=()=>{l(()=>i(te(n?.reason)))};if(d=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>i(new yd(t)))},t)),n?.addEventListener("abort",f)}))}var Sd=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 Id(e,t,n){return t<=0?e:new Promise((r,i)=>{let o=!1,s;const d=l=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{d(()=>i(new Sd(n,t)))},t),e.then(l=>{d(()=>r(l))},l=>{d(()=>i(l))})})}var Td=2,it=Symbol("sandbox:frame-replaced");function ae(e,t,n,r,i,o,s){const d=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??Tn[t],f=()=>{let I=Id(e.sendAsync(n,r),l,d);return I=_n(I,o?.signal),Ue(d,I,i)};if(t==="INIT_START"&&_d(e)){const I=o?.getSandboxReadyTimeoutMs()??2e4,v=e,y=w=>{const S=wd(v,I,o?.signal);return Ue("sandbox:INIT_START:ready-wait",S,i).then(()=>{if(!s||w<=0)return f();const A=s.getGeneration();let h;const c=new Promise((p,m)=>{h=s.onChange(()=>{s.getGeneration()!==A&&m(it)})}),a=f();return a.catch(()=>{}),Promise.race([a,c]).finally(()=>h?.()).catch(p=>{if(p!==it)throw p;return{...i},y(w-1)})})};return y(Td)}if(!s)return f();const u=s.getGeneration();let g;const b=new Promise((I,v)=>{g=s.onChange(()=>{s.getGeneration()!==u&&v(it)})}),E=f();return E.catch(()=>{}),Promise.race([E,b]).finally(()=>g?.()).catch(I=>{throw I===it&&{...i},I})}var Ad=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Cd=200;function Rd(e=new Set){const t=new Set;return(n,r)=>{if(!Ad.some(([o,s])=>!e.has(o)&&s.test(n)))return;const i=r??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=Cd&&t.clear(),t.add(i))}}function Pd(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Rd()}}var Dd=Pd();function ke(e){return e?.getInstance(_s)??Dd}function Od(e){const t=ve(e),n=Y(e),r=()=>e.getInstance(De)??Dn;let i,o,s=!1,d=!1;const l=async(S,A,h)=>{const c=h.generation,a=()=>h.generation!==c||h.signal.aborted||t.current()!==S||d,p=ue(n);s=!0;try{if(await ae(n,"INIT_START",M.SANDBOX_INIT_START,{guid:A},void 0,h),a())return;const{html:m,hasBrowserExtensionArtifacts:_}=eo(nn(S));if(_&&ie(e,F.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),to(S,m),await ae(n,"SET_ENTITY",M.SANDBOX_SET_ENTITY,rn(nn(S),A,ke(e).editorPolicy,S.get().version),void 0,h),a())return;await ae(n,"INITED",M.SANDBOX_INITED,{guid:A},void 0,h),i=A,o=p}finally{s=!1}},f=()=>me(t.sessionKey())?t.current():void 0,u=()=>{if(d||s)return;const S=f(),A=S?.get().docId;if(!S||!A||i===A&&o===ue(n)||!S.isReady())return;const h=r();h.signal.aborted||l(S,A,h).catch(()=>{})};let g=!1;const b=()=>{g||d||(g=!0,queueMicrotask(()=>{g=!1,u()}))};let E,I;const v=()=>{const S=f(),A=S?.get().docId;A!==I&&(E?.(),I=A,E=S?.subscribe(b)),b()},y=t.subscribe(v),w=Ji(n,b);v(),e.getInstance(k)?.addDispose(()=>{d=!0,w(),E?.(),y()})}var xd=200;function Ld({startVersion:e,limit:t=xd}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const d=n.filter(f=>f.version>s);i(s);let l=o;for(const f of d){if(f.fromCanvas||f.contentReplaced||!f.changes)return null;const u=f.changes,g=[];for(const b of l){const E=Ia(b.range,u,"after");if(!E)return null;g.push({range:E,text:b.text})}l=g}return l}}}function Md(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new re(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function kd(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Md(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Nd(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var On=O("canvas.sandboxFill");function io(e){return e.getInstance(On)?.pipeline.isEventsLocked()===!0}function Ot(e){yt(e,{origin:"canvas-channel"})}function Fd(e){const t=ve(e),n=Y(e);let r;const i=(l,f)=>{const u=l.get().docId;let g=!1,b=null,E=null;const I=Ld({startVersion:l.get().version});let v=l.getContent();const y=async(c,a)=>{if(E){E.push({edits:c,rev:a});return}E=[{edits:c,rev:a}];try{do{const p=E.splice(0,E.length);await n.sendAsync(M.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev})}while(E.length)}finally{E=null}},w=(c,a)=>{const p=E?.splice(0,E.length)??[];p.length&&n.sendAsync(M.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev}).catch(Ot),n.sendAsync(M.SANDBOX_UPDATE_ENTITY,{edits:[c],guid:u,rev:l.get().version,...a!==null?{changeId:a}:{}}).catch(Ot)},S=c=>{const{guid:a,pushUndoStop:p}=c;if(a!==u)return;const m=ka(c);let{edits:_}=c;if(m.baseRev!==null){const P=I.rebase(_,m.baseRev);if(!P){yt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),w([],m.changeId);return}_=P}const T=l.get().version;try{g=!0,b=m.changeId;const P=kd(_,l.getContent());p===!1?f.applyWithoutHistory(P):l.mutate({changes:P},{source:io(e)?"system":"user"})}finally{g=!1,b=null}l.get().version===T&&m.baseRev!==null&&w([],m.changeId)},A=l.subscribe(({changes:c,version:a})=>{const p=l.getContent(),m=!c?.length&&p!==v;if(v=p,I.record({version:a,changes:c,contentReplaced:m,fromCanvas:g}),!c?.length)return;const _=Nd(c);g?w(_,b):y(_,a).catch(Ot)}),h=n.addListener(M.APPLICATION_UPDATE_ENTITY,S);return()=>{A(),h.dispose()}};let o;const s=()=>{const l=t.current(),f=t.history(),u=l?.get().docId;u!==o&&(r?.(),r=void 0,o=u,l&&f&&(r=i(l,f)))},d=t.subscribe(s);s(),e.getInstance(k)?.addDispose(()=>{r?.(),d()})}var jd=300,Bd=15e3,cr="em-canvas-busy-style";function Ud(){if(document.getElementById(cr))return;const e=document.createElement("style");e.id=cr,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function Hd(e){const t=e.getBoundingClientRect(),n=document.createElement("div");return n.setAttribute("aria-busy","true"),Object.assign(n.style,{position:"fixed",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,cursor:"progress",display:"flex",alignItems:"center",justifyContent:"center"}),e.appendChild(n),{showSpinner(){Ud(),n.style.background="rgba(128, 128, 128, 0.15)";const r=document.createElement("div");Object.assign(r.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),n.appendChild(r)},remove:()=>n.remove()}}var Gd=8e3;function qd(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,whenShown:()=>Promise.resolve(),alignTo:()=>{},resize:()=>{},dispose:()=>{}}}var $d=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="hidden")return t}return null};function zd(e,t,n,r,i){const o=n.readyTimeoutMs??Gd,s=document.createElement("div");s.dataset.canvasHost=e,r&&(s.dataset.canvasPlace=r),s.style.position="fixed",s.style.overflow="hidden",s.style.visibility="hidden";const d=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(d)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=d,s.appendChild(l),t.appendChild(s),n.mark?.("created"),i||n.onCreated?.(l);const f=new Q;let u=!1,g=!1,b,E,I,v;const y=()=>{clearTimeout(v),v=setTimeout(()=>{g||(g=!0,E?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},w=()=>u?(I=Promise.resolve(),g=!0,I):(g=!1,I=new Promise((x,U)=>{b=x,E=U}),y(),I),S=()=>{if(clearTimeout(v),u=!0,g){I=Promise.resolve();return}g=!0,n.mark?.("loaded"),b?.()};l.addEventListener("load",S),f.addDispose(()=>{clearTimeout(v),l.removeEventListener("load",S)});let A;const h=()=>{A??=n.bindResizer?.(l)};let c=null,a=null,p;const m=()=>{if(!c){s.style.visibility="hidden",l.removeAttribute("id");return}n.elementId&&(l.id=n.elementId);const x=c.getBoundingClientRect(),U=a?.isConnected?a:$d(c),B=U?U.getBoundingClientRect():null,W=B?Math.max(x.top,B.top):x.top,be=B?Math.min(x.bottom,B.bottom):x.bottom,Qe=Math.max(0,be-W);s.style.visibility=Qe>0?"visible":"hidden",s.style.left=`${x.left}px`,s.style.top=`${W}px`,s.style.width=`${x.width}px`,s.style.height=`${Qe}px`,l.style.transform=`translateY(${x.top-W}px)`};let _="",T="",P=0,N;const X=()=>{if(!c){N=void 0;return}N=window.requestAnimationFrame(X);const x=c.getBoundingClientRect(),U=a?.isConnected?a.getBoundingClientRect():void 0,B=`${Math.round(x.left)}:${Math.round(x.top)}:${Math.round(x.width)}:${Math.round(x.height)}:${U?`${Math.round(U.top)}:${Math.round(U.height)}`:"-"}`;B!==_&&(_=B,m());const W=l.getBoundingClientRect().height;W>0&&W!==P&&(P=W,c.style.height=`${W}px`);const be=getComputedStyle(c).pointerEvents;be!==T&&(T=be,s.style.pointerEvents=be)},R=()=>{N===void 0&&c&&(N=window.requestAnimationFrame(X))},D=()=>{N!==void 0&&(window.cancelAnimationFrame(N),N=void 0)},q=()=>m();let j=[];const K=(x,U)=>{if(a=U,x&&j.length>0){const B=j;j=[],B.forEach(W=>W())}if(x===c){m();return}if(p?.disconnect(),p=void 0,c&&c.style.removeProperty("height"),_="",P=0,T="",c=x,!x){D(),m();return}n.onShown?.(l);try{if(typeof ResizeObserver=="function"){const B=new ResizeObserver(m);typeof B.observe=="function"&&(p=B,p.observe(x))}}catch{p=void 0}m(),h(),R()};window.addEventListener("scroll",q,!0),window.addEventListener("resize",q),f.addDispose(()=>{p?.disconnect(),N!==void 0&&window.cancelAnimationFrame(N),window.removeEventListener("scroll",q,!0),window.removeEventListener("resize",q)});const de=x=>{u=!1,x&&n.onReload?.(l);let U;g||I===void 0?U=w():(y(),U=I);try{l.contentWindow?.location.reload()}catch{l.src=d}return U};return{element:l,ready(){return I??w()},reload:()=>de(!0),reloadQuietly:()=>de(!1),get shown(){return c!==null},whenShown(){return c!==null?Promise.resolve():new Promise(x=>{j.push(x)})},alignTo(x,U){K(x,U??null)},scrollBy(x,U){for(let B=c?.parentElement??null;B;B=B.parentElement){const W=getComputedStyle(B);if((W.overflowY==="auto"||W.overflowY==="scroll")&&B.scrollHeight>B.clientHeight){B.scrollTop+=U,B.scrollLeft+=x;return}}window.scrollBy(x,U)},resize(){A?.resize()},dispose(){K(null,null),A?.dispose(),f.dispose(),s.remove()}}}function Vd(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,g)=>u==="email"?`email:${g??n}`:u;let o,s=[];const d=()=>{s.forEach(u=>clearTimeout(u)),s=[],o?.remove(),o=void 0},l=new Map,f=(u,g,b)=>{const E=i(u,g),I=t.get(E);if(I)return I;const v=e.resolveMount();if(!v)return qd();const y=zd(u,v,e,u==="email"?g??n:void 0,b);return t.set(E,y),y};return{get:u=>f(u),current:u=>f(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>f("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const g=t.get(i("email"));n=r();const b=l.get("email");u.alignTo(b?.slot??null,b?.clip??null),g?.alignTo(null)},alignSurface(u,g,b){l.set(u,{slot:g,clip:b??null}),(g?f(u):t.get(i(u)))?.alignTo(g,b??null)},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const g of t.values())if(g.element.contentWindow===u)return g}},busy(u){d();const g=u?e.resolveMount():void 0;if(!g)return;const b=Hd(g);o=b,s=[setTimeout(()=>b.showSpinner(),jd),setTimeout(d,Bd)]},dispose(){d(),t.forEach(u=>u.dispose()),t.clear(),l.clear(),n="a"}}}var Kd=O("canvas.resizerBinder"),on=O("canvas.service"),Wd={created:J.canvasCreated,loaded:J.canvasLoaded};function Yd(e,t){if(e.getInstance(on))return;const n=Vd({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:Yl,elementId:t.elementId,bindResizer:i=>e.getInstance(Kd)?.(i),onCreated:i=>ct(e,i,"fresh"),onReload:i=>ct(e,i,"fresh"),onShown:i=>ct(e,i,"switch"),mark:i=>t.mark?.(Wd[i])}),r=Y(e).addListener(M.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(on,n),e.getInstance(k)?.addDispose(()=>{r.dispose(),n.dispose()})}function ct(e,t,n){const r=Y(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),xl(r))}function Xd(e,t){ct(e,t,"promote")}function Jd(e,t){const n=t.contentWindow;n&&Y(e).greet(n)}function Qd(e,t){const n=t.contentWindow;n&&Y(e).forget(n)}function fe(e){return e.getInstance(on)}function Zd(e){const t=Y(e),n=()=>fe(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(M.RELOAD,async()=>{await n()?.reload()}),i=t.addListener(s=>{s.data?.operation===M.SANDBOX_RESIZED&&n()?.resize()}),o=V(e,F.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(k)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose()})}var cm=O("HeadlessMode"),ec=O("HiddenMount");function tc(e){return e.getOrCreateInstance(ec,()=>Me(!1))}function ur(){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 nc(e){const t=e.getInstance(oe);let n,r;e.getInstance(k)?.addDispose(()=>{r?.remove(),r=void 0}),Yd(e,{resolveMount:()=>n,resolveSrc:o=>Qi(o==="block"),elementId:"email_iframe",mark:o=>G(o)}),t?.watch(o=>{if(n)return;const s=o?.element;if(s instanceof HTMLElement)n=s;else if(o!==void 0)n=r??=ur();else return;fe(e)?.get("email")});let i;e.getInstance(k)?.addDispose(()=>{i?.remove(),i=void 0}),tc(e).watch(o=>{const s=fe(e);if(s){if(o){i??=ur(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var oo=O("canvas.headerFlow"),fr=["subject","preheader"],rc=3e3,ic={subject:M.SANDBOX_SUBJECT_UPDATE,preheader:M.SANDBOX_PREHEADER_UPDATE};function oc(e){const t=ve(e),n=Y(e),r=v=>v?"remote":io(e)?"system":"user",i=(v,{guid:y,value:w,forced:S})=>{const A=je(t);if(!A||typeof w!="string"||y&&y!==A.get().docId)return;const h=t.forcedHeaders();if(h?.[v]&&!S&&w!==h[v])return;S&&t.endForcedHeaders();const c=A.get().attributes[v]??"";d=!0;try{mt(A,{[v]:w},{source:r(S)})}finally{d=!1}o[v]=w,ie(e,F.ON_HEADER_APPLIED_ID).fire({field:v,value:w,forced:!!S,isGenerated:w!==c&&!!w})};let o={},s,d=!1,l=Promise.resolve();const f=(v,y,w)=>{l=n.sendAsync(ic[v],{value:y,guid:je(t)?.get().docId,...w?{force:!0,echo:!0}:{}}).catch(S=>{})};let u;e.inject(oo,{whenDelivered:async()=>{await l},reassert:v=>{const y=je(t),w=fr.filter(S=>v[S]);if(!(!y||w.length===0)){d=!0;try{mt(y,Object.fromEntries(w.map(S=>[S,v[S]])),{source:"system"})}finally{d=!1}t.beginForcedHeaders({subject:v.subject??"",preheader:v.preheader??""}),clearTimeout(u),u=setTimeout(()=>t.endForcedHeaders(),rc);for(const S of w)o[S]=v[S],f(S,v[S],!0)}}});const g=()=>{s?.(),s=void 0;const v=je(t);if(!v){o={};return}const y=v.get().attributes;o={subject:y.subject,preheader:y.preheader},s=v.subscribe(({source:w})=>{if(d)return;const S=v.get().attributes,A=t.forcedHeaders();for(const h of fr){const c=S[h];c!==o[h]&&(o[h]=c,f(h,c??"",w==="system"&&A?.[h]!==void 0))}})};g();const b=t.subscribe(g),E=n.addListenerAsync(M.APPLICATION_SUBJECT_UPDATE,v=>i("subject",v)),I=n.addListenerAsync(M.APPLICATION_PREHEADER_UPDATE,v=>i("preheader",v));e.getInstance(k)?.addDispose(()=>{E.dispose(),I.dispose(),b(),s?.(),clearTimeout(u)})}function pr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sn(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];pr(i)&&pr(o)?n[r]=sn(o,i):i!==void 0&&(n[r]=i)}return n}function sc(e,t){const n=bn;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const i=JSON.parse(r);if(i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length>0)return sn(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?sn(n,t):n}function ac(){const e=window.localStorage.getItem(bt.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?ms:Ps;return e&&e!=="system"?e:t}function lc(){const e=window.localStorage.getItem(bt.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function dc(e){const{config:t}=e;return{operation:M.UPDATE_PREVIEW,theme:e.theme,commonStyles:sc(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}function cc(e){const t=Y(e),n=e.getInstance(we),r=e.getInstance(oe),i=ve(e);let o,s="";const d=()=>{const w=n?.get()??{},S=dc({config:w,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:ac(),codeMode:lc(),appName:"useblocks"}),A=JSON.stringify(S);A!==s&&(s=A,t.send(S))},l=t.onInit(()=>{s="",d()}),f=()=>{t.isInited()&&d()},u=n?.watch(f),g=r?.watch(w=>{o=w?.commonStyles,f()});let b;const E=()=>{b?.(),b=i.current()?.subscribe(f),f()};E();const I=i.subscribe(E),v=matchMedia(bs),y=()=>f();v.addEventListener("change",y),e.getInstance(k)?.addDispose(()=>{l.dispose(),u?.dispose(),g?.dispose(),b?.(),I(),v.removeEventListener("change",y)})}var an;(function(e){function t(i,o,s=(d,l)=>d===l){if(i===o)return!0;if(i.length!==o.length)return!1;for(let d=0;d<i.length;d++)if(!s(i[d],o[d]))return!1;return!0}e.isEqual=t;function n(i,o=s=>s){const s=new Set;return i.filter(d=>{const l=o(d);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(i=[],o=[],s=(d,l)=>d===l){const d=[],l=[],f=[];for(const u of i){const g=o.find(b=>s(u,b));g?f.push({prev:u,next:g}):l.push(u)}for(const u of o)i.find(g=>s(u,g))||d.push(u);return{added:d,removed:l,exists:f}}e.diff=r})(an||(an={}));function uc(e,t){return e.type===t.type&&e.key===t.key}function fc(e){const t=Y(e),n=()=>e.getServices(Te)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(M.SANDBOX_ADD_EXTENSIONS,r)}),o=ws(Te),s=e.onInject(d=>{if(d!==o)return;const l=n();if(!t.isInited()){r=l;return}const{added:f,removed:u}=an.diff(r,l,uc);if(r=l,u.length){if(u.some(g=>g.type==="script")){t.send(M.RELOAD);return}t.send(M.SANDBOX_REMOVE_EXTENSIONS,u.map(g=>g.key))}f.length&&t.send(M.SANDBOX_ADD_EXTENSIONS,f)});e.getInstance(k)?.addDispose(()=>{i.dispose(),s?.dispose()})}var pc=O("prewarm.editorVisible");function hc(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function mc(e={}){const t=e.paint??hc;let n=!1,r=!1,i=!1,o=!1,s=!1;const d=[],l=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,G(J.editorVisible);for(const f of d.splice(0))f()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){i=!0,l()},whenVisible(f){if(s){f();return}d.push(f)},contentShown:()=>i}}function gc(e){return e.getOrCreateInstance(pc,()=>mc())}var vc=500,bc=500,Ec=5e3;function yc(e){const t=e.quietMs??vc,n=e.floorMs??bc,r=e.ceilingMs??Ec;let i,o,s=0;const d=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},l=()=>{d(),e.run()},f=()=>{clearTimeout(i);const u=n-(Date.now()-s);i=setTimeout(l,Math.max(t,u))};return{start(){d(),s=Date.now(),o=setTimeout(l,r),f()},notify(){i!==void 0&&f()},cancel:d}}function _c({attributes:e,readContent:t,docId:n,hasSession:r,serverId:i,show:o}){if(!r)return;const s={id:i??void 0,renderGuid:n,showId:o?.id,isNew:i==null,showToken:o?.token},d={...e,...s};return Object.defineProperty(d,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),d}var so="self-init:";function wc(e){return e.startsWith(so)}function ao(e,t){const n=e.getActiveShowRequest();return wc(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Sc(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t();let i="";const o=()=>e.readDocument()?nn(e.readDocument()):i,s=()=>ke(e.container).editorPolicy,d=()=>e.readEmail(),l=()=>{const f=d();return{...f,id:e.isTemplate()||f.isNew?void 0:f.id,html:o()}};return{readContent:o,publicEmail:l,sendInitStart:()=>ae(n,"INIT_START",M.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>ae(n,"INITED",M.SANDBOX_INITED,{guid:d().renderGuid},void 0,r()),async sendContent(){const f=d(),{html:u,hasBrowserExtensionArtifacts:g}=eo(f?.html||"");g&&e.events.browserExtensionDetected(),to(e.readDocument(),u),i=u,await ae(n,"SET_ENTITY",M.SANDBOX_SET_ENTITY,rn(o(),f.renderGuid,s(),e.readDocument()?.get().version),{guid:f.renderGuid,emailId:f.id??null},r())},refreshContent:()=>ae(n,"SET_ENTITY",M.SANDBOX_SET_ENTITY,rn(o(),d().renderGuid,s(),e.readDocument()?.get().version),void 0,r()),sendPreheader:async()=>{const f=d();if(f.preheader!==void 0)return ae(n,"PREHEADER",M.SANDBOX_PREHEADER_UPDATE,{value:f.preheader,guid:f.renderGuid,force:!0},void 0,r())},sendSubject:async()=>{const f=d();if(f.subject!==void 0)return ae(n,"SUBJECT",M.SANDBOX_SUBJECT_UPDATE,{value:f.subject,guid:f.renderGuid,force:!0},void 0,r())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:f=>e.showFilled?.(f),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(l()),fireInit(f,u){if(!ao(t(),f)){t().getActiveShowRequest()?.showId;return}const g=d();g.id,g.renderGuid,t().completeShow(f),mt(e.readDocument(),{is_inited:!0},{source:"system"});const b=l();return u&&(b.reset=!0),e.events.inited(b)},fireEmailChanged(){e.events.emailChanged(l())},fireContentChanged(){e.events.contentChanged(o())}}}function Ic(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,d;const l=Sc({...e,waitScope:()=>({getSandboxTimeoutMs:y=>t().getSandboxTimeoutMs(y),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:d?.signal??t().signal})});let f;const u=(y,w)=>{if(f===y)return;f=y;const S=s;setTimeout(()=>{s!==S||t().signal.aborted||I(y,w).catch(()=>{})},0)},g=()=>{d?.abort(),d=void 0};let b;const E=()=>{const y=t().signal;y!==b&&(b?.removeEventListener("abort",g),b=y,y.addEventListener("abort",g))};async function I(y,w){const S=++s;g(),d=new AbortController,E();const A=()=>s!==S,h=l.readTarget(),c=t().generation,a=()=>c===t().generation&&!t().signal.aborted,p=w?"init:reset-":"init:";if(!w){const T=l.publicEmail();T?.id,T?.renderGuid,T?.preheader}let m=!1,_=!1;try{n=!0,await l.sendInitStart(),l.fireWillInit(),await(w?l.refreshContent():l.sendContent()),m=!0,w||l.publicEmail()?.id;try{await l.sendPreheader()}catch(T){`${p}`,String(T)}try{await l.sendSubject()}catch(T){`${p}`,String(T)}if(A()||l.showFilled(h),await l.sendInited(),_=!0,i===y){const T=e.readSandboxGeneration?.()??o;T!==void 0&&(r=T)}await l.revealFilled()}catch(T){throw A()||(`${p}`,{...e.describeSurface?.(),error:String(T)},void 0),!A()&&ao(t(),y)&&t().failShow(y,T),T}finally{v(y,w,p,{superseded:A(),sessionGeneration:c,contentApplied:m,sandboxInitedAcked:_,commit:a()})}}function v(y,w,S,A){const{superseded:h,contentApplied:c,sandboxInitedAcked:a}=A;if(h){`${S}`;return}a&&A.commit?l.fireInit(y,w||void 0):a?(`${S}`,A.sessionGeneration,t().generation,t().signal.aborted,void 0):c?(`${S}`,void 0):(`${S}`,void 0),n=!1,d=void 0,!a&&i===y&&(i=void 0,r===o&&(r=void 0)),!a&&c&&u(y,w)}return{channel:l,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:y=>{r=y},lastCorrelation:()=>i,markCorrelation:y=>{i=y},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:y=>{o=y},fill:y=>I(y,!1),refill:y=>I(y,!0),stop:()=>{s+=1,g(),n=!1,b?.removeEventListener("abort",g),b=void 0}}}function Tc(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:lo(e,n)}function lo(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Ac(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=u=>{const g=n(),b=i();if(!Tc(g,u,b)){u.showId,u.navId,u.emailId,g?.id,g?.showId,g?.renderGuid;return}u.showId,g?.id,g?.renderGuid,t.markFilled(o()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{s(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&s(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=o();if(t.filledGeneration()===u)return;const g=n(),b=i();if(!g?.renderGuid||!lo(g,b))return;const E=`${so}${g.renderGuid}`;t.markFilled(u),t.markCorrelation(E);const I=r()?.isReady()===!0;g.id,g.renderGuid,(I?v=>t.refill(v):v=>t.fill(v))(E).catch(()=>{t.lastCorrelation()===E&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id}}}function Cc(e){return e??""}function Rc(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Pc(e){const t=ve(e),n=Y(e),r=()=>me(t.sessionKey())?void 0:t.current(),i=()=>{const C=r();return _c({attributes:C?.get().attributes??{},readContent:()=>C?.getContent(),docId:C?.get().docId,hasSession:!!C,serverId:C?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(De)??Dn;let s={},d=!1;const l=e.getInstance(oe)?.watch(C=>{d=!!C?.element});let f=!1,u=!1,g=!1,b=0;const E=()=>{const C=fe(e);if(!C)return;const z=++b,H=C.spare();return H&&Qd(e,H.element),(H?H.reloadQuietly():C.ensureSpare()?.ready())?.then(()=>{if(z!==b)return;f=!0;const ne=C.spare();ne&&Jd(e,ne.element),g&&(g=!1,T(),K())})},I=yc({run:()=>{g||E()?.catch(()=>{})}}),v=()=>{gc(e).noteContentShown(),!f&&!g&&I.start()};let y=!1;const A=Ic({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const C=fe(e);return y&&C&&(y=!1,I.start()),d?C?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:C=>{const z=fe(e),H=z?.spare()?.element.contentWindow;u&&z&&H&&C===H&&(u=!1,z.promote(),z.busy(!1),y=!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>ue(n),describeSurface:()=>({canvasPath:_,promoted:u,spareClean:f,handshake:n.isInited(),generation:ue(n)}),events:{willInit:C=>{ie(e,F.WILL_EMAIL_INIT_ID).fire(C)},inited:C=>{v(),ie(e,F.ON_EMAIL_INIT_ID).fire(C)},contentChanged:C=>{ie(e,F.ON_CONTENT_CHANGED_ID).fire(C)},emailChanged:C=>{ie(e,F.ON_EMAIL_CHANGED_ID).fire(C)},browserExtensionDetected:()=>{ie(e,F.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),h=Ac({pipeline:A,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>ue(n)});let c="",a="",p="";const m=C=>C.length>0;let _="none";const T=()=>{const C=fe(e)?.spare();C&&(n.send({operation:M.SANDBOX_LOCK_EDIT,data:!0}),f=!1,u=!0,Xd(e,C.element))},P=(C,z)=>{const H=fe(e);if(!H)return!0;const ne=H.spare(),Ee=ne&&f?"spare":"prepare";if(_=Ee,H.busy(!0),ne&&f)return T(),!0;I.cancel(),n.send({operation:M.SANDBOX_LOCK_EDIT,data:!0});const ye=E();if(ye===void 0)return _="reload",H.busy(!1),H.peek("email")?.reload(),!0;g=!0;const Tt=b;return ye.catch(()=>{!g||Tt!==b||(g=!1,_="reload",H.busy(!1),H.peek("email")?.reload())}),!1},N=()=>{be(),A.noteSandboxGeneration(ue(n));const C=i(),z=Rc(C?.renderGuid,C?.showId,C?.id,s.emailId),H=Cc(C?.renderGuid);if(H!==a){const ye=m(a),Tt=a;a=H,ye&&P(Tt,H)}if(g)return;z!==c&&(c=z,h.showRequestIdentityChanged());const ne=r(),Ee=`${z}|${ne?.get().docId??""}|${ue(n)}`;Ee!==p&&ne?.isReady()===!0&&(p=Ee,h.selfInitChanged()),h.saasChanged(),q()};let X=!1,R="",D="";const q=()=>{const C=i();if(!C?.renderGuid)return;const z=A.channel.readContent(),H=JSON.stringify([C.preheader,C.common_styles,C.meta,C.subject,C.utm_parameters?.utm_campaign??"",C.utm_parameters?.utm_content??"",C.utm_parameters?.utm_medium??"",C.utm_parameters?.utm_source??"",C.utm_parameters?.utm_term??""]),ne=X&&z!==D,Ee=X&&H!==R;if(X=!0,D=z,R=H,A.isEventsLocked())return;const ye={...C,id:s.isTemplate||C.isNew?void 0:C.id,html:z};if(ne){ie(e,F.ON_CONTENT_CHANGED_ID).fire(z),ie(e,F.ON_EMAIL_CHANGED_ID).fire(ye);return}Ee&&C.is_inited&&ie(e,F.ON_EMAIL_CHANGED_ID).fire(ye)};let j=!1;const K=()=>{j||(j=!0,queueMicrotask(()=>{j=!1,N()}))};e.inject(On,{pipeline:A,setRoute:C=>{C.emailId===s.emailId&&!!C.isTemplate==!!s.isTemplate||(s=C,K())}});let de,x;const U=()=>{const C=r()?.get().docId;C!==x&&(de?.(),x=C,de=r()?.subscribe(K)),K()};let B,W;const be=()=>{const C=e.getInstance(De);!C||C===B||(W?.(),B=C,W=C.onShowRequested(z=>h.showRequested(z)))},Qe=n.addListener(C=>{C.data?.operation===M.SANDBOX_RESIZED&&I.notify()}),$o=t.subscribe(U),zo=Ji(n,K);U(),e.getInstance(k)?.addDispose(()=>{l?.dispose(),W?.(),zo(),$o(),de?.(),Qe.dispose(),I.cancel(),A.stop()})}function Dc(){return Ts!=="useblocks"}var ln={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Oc={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},hr=ln,xc=["freeUserBlocks","blocks"],co={};function Lc(e){co=e}var uo=e=>xc.includes(e)?hr:co[e]??hr,dn={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},Mc={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},kc={...dn,config:{...dn.config,imageCenterFileManagerView:!1}};Lc({pro:Oc,editor:Mc,simple:Dc()?dn:kc,freeUserBlocks:ln,blocks:ln});var mr=new Set;function Nc(){return window.localStorage.getItem(bt.em_color_scheme)??void 0}function Fc(e){return mr.add(e),e(Nc()),{dispose(){mr.delete(e)}}}function xn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function jc(e,t){return t.modeDefaults(xn(e,t.fallbackMode))}function Bc(e,t){const n=xn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Uc(e,t){const n=xn(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Hc(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Gc(e){return Qo(e.map(t=>t?.resourceProxy))}function qc(e){return Jo(e.map(t=>t?.resourceProxyPolicy))}function $c(e){return ds(e.map(t=>t?.backendProxy))}function zc(e){return ni(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Vc(e,t){return[e.base,jc(e,t),e.profile,e.serverSide,Bc(e,t.fallbackMode),e.user,Uc(e,t.fallbackMode),e.local]}function xt(e,t){const n=Vc(e,t),r=ni(n),i=Hc(n);i!==void 0&&(r.fileManager=i);const o=Gc(n);o!==void 0&&(r.resourceProxy=o);const s=qc(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const d=$c(n);d!==void 0&&(r.backendProxy=d);const l=zc(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}var Kc=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function gr(e){return e==="server"?"serverSide":e}function Wc({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=Me();let o={kind:"pending"},s;const d=new Promise(b=>{s=b}),l=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function f(){o.kind!=="pending"&&i.set(xt(r,e))}function u(b){if(o.kind!=="pending")return;clearTimeout(l),o=b;const E=xt(r,e);i.set(E),s(E)}function g(b,E){r[gr(b)]=E,b==="server"&&o.kind==="pending"?u({kind:"applied"}):f()}return{watch:b=>i.watch(b),select:b=>i.select(b),get:()=>i.get(),ready:()=>d,state:()=>o,layers:()=>({...r}),bootstrap(){const b=xt(r,e);return Object.fromEntries(Kc.map(E=>[E,b[E]]))},merge(b,E){g(E,{...r[gr(E)],...b})},replace(b,E){g(E,b)},setMode(b){r.user={...r.user,mode:b},f()},setAdvancedConfigs(b){r.advancedConfigs=b,f()},serverAbsent(b){u({kind:"absent",reason:b})},applyServerResponse(b){o.kind==="pending"&&g("server",{...r.serverSide,...b})},dispose(){clearTimeout(l)}}}var Yc=5e3,Xc="blocks";function Jc(){return{...uo(Xc)?.config,mergeTags:void 0}}function Qc(e,t){e.getInstance(oe)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function Zc(e,t){let n;Gi(e).watch(({profile:r})=>{const i=`${r?.theme??""}|${r?.locale??""}`;if(i===n)return;n=i;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function eu(e,t){let n=null;const r=Fc(i=>{const o=typeof i=="string"&&i?i:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(k)?.addDisposable(r)}async function tu(e,t){if(e.getInstance(Sn)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Pe);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function nu(e){e.injectFactory(we,(t,n)=>{if(n)return n;const r=Wc({base:Jc(),env:{modeDefaults:i=>uo(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Yc});return Qc(e,r),Zc(e,r),eu(e,r),tu(e,r),e.getInstance(k)?.addDisposable(r),r},!0)}var Re=class extends Q{_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 L(e,t,n){const r=ls(e);return(i,o,s)=>{const d=r(async l=>{const f=t?t(l):l;s&&i.bind(s);const u=await i(f);return n?n(u):u},o,s);return()=>d.dispose()}}var ru=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Jt;this.handleDestroy=L(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Re(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},Ln=O("DestroyableService");function iu(e){e.injectFactory(Ln,()=>{const t=e.getInstance(k);if(!t)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new ru({lifetime:t,options:e.getInstance(oe),getInstance:()=>e.getInstance(Et),release:()=>Ss(e.getInstance(vs)??e)})},!0)}function ou(e){const t=e.getInstance(Ln);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var su=1e3;function fo(e,t,n=su,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const s of i)if(!fo(e[s],t[s],n,r+1))return!1;return!0}return!1}function He(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const i=t[r],o=e[r];fo(i,o)||(n[r]=i)}return n}var au=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail не ответил за ${e}ms — письмо не сохранено`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},lu=({source:e,emailtags:t,group:n,tags:r,...i})=>i,du=()=>_i();async function cu({emails:e},t){const n=du();let r;try{return await Promise.race([e.notifySave(t),new Promise((i,o)=>{r=setTimeout(()=>{const s=new au(n);t.value.id,o(s)},n)})])}finally{r!==void 0&&clearTimeout(r)}}function uu(e){const{emails:t}=e,n=async(r,i)=>{const o=lu(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),d=s?{...s,...o}:o,l=await cu(e,{prev:s,patch:s?He(s,o):o,value:d,source:i.source??""}),f=String(l.id??r??le()),u=l.id===void 0?{...l,id:f}:l;return await t.cache.addOrUpdate(f,()=>u)};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const i=await n(void 0,r);return i?.renderGuid?i:{...i,renderGuid:le()}},async updateEmail(r,i){return await n(r,i)}}}var Lt=20,fu=({source:e,emailtags:t,group:n,tags:r,...i})=>i;function pu({revisions:e,revisionsByEmail:t}){const n=async(r,i)=>(t.clear(),await t.get(r,{page:i}),(await e.cache.values()??[]).filter(o=>String(o?.parent)===String(r)));return{async readRevisions(r,i=1){const o=await n(r,i);return{revisions:o.slice(Lt*(i-1),Lt*i),page:i,hasMore:o.length>Lt*i}},async readAutosave(r){return ja(await n(r,1))},async saveAutosave(r,i){const o=fu(i);return await e.create({...o,parent:r,modified:new Date().toString()})}}}var hu=class extends fs{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}},mu=class extends pe{};var vr=class extends Q{_items=new Map;_onChangeEmitter=new Ms;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const i=await t(n);return pt(n,i)||this._onChangeEmitter.fire(),i}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([i,o])=>i)),r=(await this.entries()).filter(([i,o])=>!n.has(i));for(const[i,o]of e)t.push(this.addOrUpdate(i,()=>o)),n.add(i);for(const[i]of r)t.push(this.remove(i));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function gu(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let d=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(f=>{for(const u of l){const g=f[u],b=t[u];return u==="id"||typeof g!="string"?g===b:typeof b=="string"&&g.startsWith(b)}return!0}),d=e.length}return r&&(e=e.sort((l,f)=>(l[r]>f[r]?1:f[r]>l[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:d,total:s,totalPages:Math.ceil(d/o)}}function vu(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const i=t.get(r.id)||{};t.set(r.id,{...i,...r})}return[...t].map(([n,r])=>r)}function bu(e,t){return br(e)&&br(t)?String(e)===String(t):e===t}function br(e){return typeof e=="string"||typeof e=="number"}var Eu=class extends Q{_cache=new vr;_readEmitter=new pe;_saveEmitter=this.addDisposable(new hu);_removeEmitter=this.addDisposable(new mu);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new Q);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new vr),i=n.addDisposable(new pe);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const l=vu(await i.fire(o))||[];for(const f of l)f[e]=o,await this._cache.add(f.id,f);return l}catch{return[]}});const d=(await this._cache.values()||[]).filter(l=>{const f=l[e];return f==null||bu(f,o)});return gu(d,s)},first(o,s={}){return t.get(o,{...s,page:1,pageSize:1}).then(({data:d})=>d[0])},handleRead:i.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=le()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async i=>{const o=i?{...i,...t}:t;if(!r)return t=i?He(i,t):t,await this._saveEmitter.fire({prev:i,patch:t,value:o,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Xe(e){const t=O(e);return n=>n.getOrCreateInstance(t,()=>new Eu)}function yu(e){const t=e.getInstance(k);if(!t)throw new Error("Failed");return t}function Er(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function _u(e,t,n){return e&&!Er(t)&&Er(e)?{...n,meta:e.meta}:n}var po=Xe("plugin.dataSource.emails"),ho=Xe("plugin.dataSource.emailRevisions"),yr=O("emailDocuments.provided");function wu(e){const t=po(e),n=ho(e),r=n.byForeignKey("parent");return e.getInstance(yr)?{emails:t,emailRevisions:n}:(e.inject(yr,!0),il(e,uu({emails:t})),ll(e,pu({revisions:n,revisionsByEmail:r})),yu(e).addDisposable(t.onSave(({prev:i,patch:o,value:s})=>_u(i,o,s),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function _r(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 Su(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Iu="po",ot=null;function Tu(){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([Iu],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Au(){return ot===null&&(ot=Tu().catch(e=>{throw ot=null,e})),ot}async function mo(e){if(typeof e=="object")return Mn(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Cu(t):Ru(t)}function Mn(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Cu(e){try{return Mn(JSON.parse(e))}catch{return}}var wr=!1;async function Ru(e){try{return Mn((await Au()).parsePoCatalog(e))}catch{wr||(wr=!0);return}}var Pu="em_locale",Du="em_ant_locale",Ou="locale",xu="ant_locale";function kn(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function go(e,t){const n=kn(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Lu(){return kn("em_locale")??go(Ou,"em_locale")}function Sr(e){try{localStorage.setItem(Pu,JSON.stringify(e))}catch{}}function Mu(){return kn("em_ant_locale")??go(xu,"em_ant_locale")}function ku(e,t){try{localStorage.setItem(Du,JSON.stringify({id:e,data:t}))}catch{}}var Nu=8e3;function Fu(e,t){const n=e,r=t,i=Object.keys(n).filter(o=>o!=="");return i.length!==Object.keys(r).filter(o=>o!=="").length?!1:i.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function ju(e){const t=Lu(),n=Mu();let r={ready:!1},i;const o=Me(r);let s=0;const d=y=>{r={...r,...y},o.set(r)},l=()=>{r.ready||d({ready:!0})},f=setTimeout(l,e.unlockAfterMs??Nu),u=y=>y!==s;let g;async function b(y,w){if(n?.id===y&&n.data&&d({antd:n.data}),!g)return;const S=await g(y).catch(()=>{});!S||u(w)||(d({antd:S}),ku(y,S))}async function E(y,w){const S=await e.askHost(y).catch(()=>null);if(u(w))return!0;if(S==null)return!1;const A=await mo(S);return u(w)||(A&&d({catalog:A}),l()),!0}async function I(y,w){const S=await e.readList();if(u(w))return;if("error"in S){d({failure:{kind:"GET_LOCALES_ERROR",error:S.error}}),l();return}const A=S.data.find(c=>c.locale===y);if(!A){Su("em_locale")&&d({catalog:void 0}),l();return}if(_r(t,A)&&(!i||i.catalog===t?.data)){l();return}if(i?.entry&&r.catalog===i.catalog&&_r(i.entry,A)){Sr(i.entry),l();return}const h=await e.readCatalog(y);if(!u(w)){if("error"in h){d({failure:{kind:"GET_LOCALE_ERROR",error:h.error}}),l();return}h.data&&(i?.id===y&&r.catalog===i.catalog&&Fu(i.catalog,h.data)||d({catalog:h.data}),Sr({id:y,time:A.updatedAt||Math.floor(Date.now()/1e3),hash:A.contentHash,data:h.data})),l()}}async function v(y,w){if(!await E(y,w)){if(!u(w)&&(i?.id===y&&r.catalog===i.catalog||y==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await I(y,w)}}return{set(y){if(!y||y===r.id)return;const w=s+=1;d({id:y,failure:void 0});const S=i?.id===y&&r.catalog===i.catalog;(i&&!S&&r.catalog===i.catalog||y==="en_US"&&r.catalog)&&d({catalog:void 0}),t?.id===y&&t.data&&(d({catalog:t.data}),l()),b(y,w),v(y,w)},prime(y,w,S){r.id||r.catalog||!w||(i=t?.id===y&&t.data&&(!S||t.time>=S.time)?{id:y,catalog:t.data}:{id:y,catalog:w,entry:S?{id:y,time:S.time,hash:S.hash,data:w}:void 0},d({catalog:i.catalog}))},useAntdLoader(y){g=y,r.id&&b(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(f)}}var Bu=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})},Uu=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:o,baseUrl:s,cancelToken:d,...l})=>{const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(l,f),g=i&&this.toQueryString(i),b=this.contentFormatters[r||"application/json"],E=o||u.format;return this.customFetch(`${s||this.baseUrl||""}${n}${g?`?${g}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(d?this.createAbortSignal(d):u.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async I=>{const v=I;v.data=null,v.error=null;const y=E?I.clone():I,w=E?await y[E]().then(S=>(v.ok?v.data=S:v.error=S,v)).catch(S=>(v.error=S,v)):v;return d&&this.abortControllers.delete(d),w})}},Hu=O("rest.v2.transport"),Ir=Symbol("rest.v2.secureRequest");function Gu(e){return e.getOrCreateInstance(Hu,()=>{const t=e.getInstance(ti)?.execute||fetch;return new Uu({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[Ir]:!0}),customFetch:(n,r={})=>{const{[Ir]:i,...o}=r;return t(n,{...o,[ns]:i!==!0})}})})}function qu(e,t){const n=Gu(e);return Object.assign({},...t.map(r=>new r(n)))}function Tr(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function vo(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Tr(n.details,"wp_code")??n.code,message:Tr(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 bo(e){return!e.ok||!!e.error}function $u(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Eo(){return $u(bt.em_translations_v2)??!0}function zu(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Vu(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Ku(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],i=r[0];return typeof i=="string"&&i!==""&&t.push({locale:i,updatedAt:zu(r[1])}),t},[]):[]}function Wu(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Vu(n.updated_at),contentHash:n.content_hash}),t),[])}function yo(e){return qu(e,[Bu])}function vt(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function cn(e){return!e.ok||e.error!=null}function un(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Mt(e){return{data:await mo(e)??null}}async function Yu(e){if(Eo())try{const n=await yo(e).localesList();return bo(n)?{error:vo(n)}:{data:Wu(n.data)}}catch(n){return vt(n)}const t=ii(e,[fi]);try{const n=await t.get_translations2({file:"react_app"});return cn(n)?un(n):{data:Ku(n.data)}}catch(n){return vt(n)}}async function Xu(e,t){if(Eo())try{const r=await yo(e).jsonList({locale:t});return bo(r)?{error:vo(r)}:Mt(r.data)}catch(r){return vt(r)}const n=ii(e,[fi]);try{const r=await n.get_translations3({id:t,file:"react_app"});return cn(r)?un(r):Mt(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return cn(r)?un(r):Mt(r.data)}catch(r){return vt(r)}}}var $e=O("locale.service");function Ju(e){if(e.getInstance($e))return;const t=ju({readList:()=>Yu(e),readCatalog:n=>Xu(e,n),askHost:async n=>(await ie(e,F.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(he)});e.inject($e,t),e.getInstance(k)?.addDispose(()=>t.dispose())}function Qu(e){const t=e.getInstance(we);if(!t)return;const n=e.getInstance($e);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i));e.getInstance(k)?.addDisposable(r)}var Zu="user_id",ef="project_id",Ar=O("rest.identityHeadersProvided");function tf(e){if(e.getInstance(Ar))return;e.inject(Ar,!0);let t;e.getInstance(oe)?.watch(n=>{t=n}),e.addService(yn,{execute(n,r){if(r?.public)return;const i=t?.user?.id??qi(e).profile?.id;i!=null&&i!==""&&n.headers.set(Zu,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(ef,String(o))}})}function nf(e){if(!e)return!1;try{return e.getInstance(he)!==void 0}catch{return!1}}var rf="Invalid standaloneKey.",um=O("StandaloneMockGuard");function of(){const e=new Error(rf);return e.name="InvalidStandaloneKeyError",e}function sf(e){e.addService(yn,{execute:()=>{if(nf(e))throw of()}})}function af(e){hs(e),sf(e)}function lf(e){const t=new ro;e.inject(De,t);let n;const r=e.getInstance(oe)?.watch(o=>{o&&(o.signal!==void 0&&(n=o.signal),t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...n!==void 0?{signal:n}:{}}))}),i=e.getInstance(k);r&&i?.addDisposable(r),i?.addDispose(()=>{t.abort()})}var df=Xe("plugin.dataSource.blocks"),cf=Xe("plugin.dataSource.blockRevisions"),uf=Xe("plugin.dataSource.comments"),ff=no(),pf=no(),_o=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1003
+ `));return{html:vd(t.html),hasBrowserExtensionArtifacts:t.found}}function rn(e){return e?.getContent()??""}function ro(e,t){e?.mutate({content:Ci(t)},{source:"remote"})}function io(e){return O(e)}function ie(e,t){return e.getOrCreateInstance(t,()=>new pe)}function V(e,t){return e.getOrCreateInstance(t,()=>new pe).event}function on(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var bd=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}},Ed=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,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new bd(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(te(n.reason))})};n.addEventListener("abort",s,{once:!0});const d=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:d});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function yd(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function _d(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=_i(e),n=wi(e),r=ma(e.sandbox);t<n+r}var oo=class{_controller=new AbortController;_externalSignalDisposable=new Q;_sessionChangeListeners=new Set;_showRegistry=new Ed;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return _i(this._timeouts)}getSandboxTimeoutMs(e){return yi(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return wi(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=yd(this._timeouts,e.timeouts),_d(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}abort(e){const t=e??te("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Q}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Q,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)})}},On=(()=>{const e=new oo;return e.configure({}),e})(),wd=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 Sd(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 Id(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():($(n),new Promise((r,i)=>{let o=!1,s,d;const l=u=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),d?.dispose(),n?.removeEventListener("abort",f),u())},f=()=>{l(()=>i(te(n?.reason)))};if(d=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>i(new wd(t)))},t)),n?.addEventListener("abort",f)}))}var Td=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 Ad(e,t,n){return t<=0?e:new Promise((r,i)=>{let o=!1,s;const d=l=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{d(()=>i(new Td(n,t)))},t),e.then(l=>{d(()=>r(l))},l=>{d(()=>i(l))})})}var Cd=2,it=Symbol("sandbox:frame-replaced");function ae(e,t,n,r,i,o,s){const d=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??An[t],f=()=>{let I=Ad(e.sendAsync(n,r),l,d);return I=wn(I,o?.signal),Ue(d,I,i)};if(t==="INIT_START"&&Sd(e)){const I=o?.getSandboxReadyTimeoutMs()??2e4,v=e,y=w=>{const S=Id(v,I,o?.signal);return Ue("sandbox:INIT_START:ready-wait",S,i).then(()=>{if(!s||w<=0)return f();const A=s.getGeneration();let h;const c=new Promise((p,m)=>{h=s.onChange(()=>{s.getGeneration()!==A&&m(it)})}),a=f();return a.catch(()=>{}),Promise.race([a,c]).finally(()=>h?.()).catch(p=>{if(p!==it)throw p;return{...i},y(w-1)})})};return y(Cd)}if(!s)return f();const u=s.getGeneration();let g;const b=new Promise((I,v)=>{g=s.onChange(()=>{s.getGeneration()!==u&&v(it)})}),E=f();return E.catch(()=>{}),Promise.race([E,b]).finally(()=>g?.()).catch(I=>{throw I===it&&{...i},I})}var Rd=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Pd=200;function Dd(e=new Set){const t=new Set;return(n,r)=>{if(!Rd.some(([o,s])=>!e.has(o)&&s.test(n)))return;const i=r??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=Pd&&t.clear(),t.add(i))}}function Od(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Dd()}}var xd=Od();function ke(e){return e?.getInstance(Ss)??xd}function Ld(e){const t=ve(e),n=Y(e),r=()=>e.getInstance(De)??On;let i,o,s=!1,d=!1;const l=async(S,A,h)=>{const c=h.generation,a=()=>h.generation!==c||h.signal.aborted||t.current()!==S||d,p=ue(n);s=!0;try{if(await ae(n,"INIT_START",M.SANDBOX_INIT_START,{guid:A},void 0,h),a())return;const{html:m,hasBrowserExtensionArtifacts:_}=no(rn(S));if(_&&ie(e,F.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),ro(S,m),await ae(n,"SET_ENTITY",M.SANDBOX_SET_ENTITY,on(rn(S),A,ke(e).editorPolicy,S.get().version),void 0,h),a())return;await ae(n,"INITED",M.SANDBOX_INITED,{guid:A},void 0,h),i=A,o=p}finally{s=!1}},f=()=>me(t.sessionKey())?t.current():void 0,u=()=>{if(d||s)return;const S=f(),A=S?.get().docId;if(!S||!A||i===A&&o===ue(n)||!S.isReady())return;const h=r();h.signal.aborted||l(S,A,h).catch(()=>{})};let g=!1;const b=()=>{g||d||(g=!0,queueMicrotask(()=>{g=!1,u()}))};let E,I;const v=()=>{const S=f(),A=S?.get().docId;A!==I&&(E?.(),I=A,E=S?.subscribe(b)),b()},y=t.subscribe(v),w=Zi(n,b);v(),e.getInstance(k)?.addDispose(()=>{d=!0,w(),E?.(),y()})}var Md=200;function kd({startVersion:e,limit:t=Md}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const d=n.filter(f=>f.version>s);i(s);let l=o;for(const f of d){if(f.fromCanvas||f.contentReplaced||!f.changes)return null;const u=f.changes,g=[];for(const b of l){const E=Aa(b.range,u,"after");if(!E)return null;g.push({range:E,text:b.text})}l=g}return l}}}function Nd(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new re(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Fd(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Nd(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function jd(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var xn=O("canvas.sandboxFill");function so(e){return e.getInstance(xn)?.pipeline.isEventsLocked()===!0}function Ot(e){yt(e,{origin:"canvas-channel"})}function Bd(e){const t=ve(e),n=Y(e);let r;const i=(l,f)=>{const u=l.get().docId;let g=!1,b=null,E=null;const I=kd({startVersion:l.get().version});let v=l.getContent();const y=async(c,a)=>{if(E){E.push({edits:c,rev:a});return}E=[{edits:c,rev:a}];try{do{const p=E.splice(0,E.length);await n.sendAsync(M.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev})}while(E.length)}finally{E=null}},w=(c,a)=>{const p=E?.splice(0,E.length)??[];p.length&&n.sendAsync(M.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev}).catch(Ot),n.sendAsync(M.SANDBOX_UPDATE_ENTITY,{edits:[c],guid:u,rev:l.get().version,...a!==null?{changeId:a}:{}}).catch(Ot)},S=c=>{const{guid:a,pushUndoStop:p}=c;if(a!==u)return;const m=Fa(c);let{edits:_}=c;if(m.baseRev!==null){const P=I.rebase(_,m.baseRev);if(!P){yt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),w([],m.changeId);return}_=P}const T=l.get().version;try{g=!0,b=m.changeId;const P=Fd(_,l.getContent());p===!1?f.applyWithoutHistory(P):l.mutate({changes:P},{source:so(e)?"system":"user"})}finally{g=!1,b=null}l.get().version===T&&m.baseRev!==null&&w([],m.changeId)},A=l.subscribe(({changes:c,version:a})=>{const p=l.getContent(),m=!c?.length&&p!==v;if(v=p,I.record({version:a,changes:c,contentReplaced:m,fromCanvas:g}),!c?.length)return;const _=jd(c);g?w(_,b):y(_,a).catch(Ot)}),h=n.addListener(M.APPLICATION_UPDATE_ENTITY,S);return()=>{A(),h.dispose()}};let o;const s=()=>{const l=t.current(),f=t.history(),u=l?.get().docId;u!==o&&(r?.(),r=void 0,o=u,l&&f&&(r=i(l,f)))},d=t.subscribe(s);s(),e.getInstance(k)?.addDispose(()=>{r?.(),d()})}var Ud=300,Hd=15e3,ur="em-canvas-busy-style";function Gd(){if(document.getElementById(ur))return;const e=document.createElement("style");e.id=ur,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function qd(e){const t=e.getBoundingClientRect(),n=document.createElement("div");return n.setAttribute("aria-busy","true"),Object.assign(n.style,{position:"fixed",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,cursor:"progress",display:"flex",alignItems:"center",justifyContent:"center"}),e.appendChild(n),{showSpinner(){Gd(),n.style.background="rgba(128, 128, 128, 0.15)";const r=document.createElement("div");Object.assign(r.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),n.appendChild(r)},remove:()=>n.remove()}}var $d=8e3;function zd(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,whenShown:()=>Promise.resolve(),alignTo:()=>{},resize:()=>{},dispose:()=>{}}}var Vd=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="hidden")return t}return null};function Kd(e,t,n,r,i){const o=n.readyTimeoutMs??$d,s=document.createElement("div");s.dataset.canvasHost=e,r&&(s.dataset.canvasPlace=r),s.style.position="fixed",s.style.overflow="hidden",s.style.visibility="hidden";const d=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(d)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=d,s.appendChild(l),t.appendChild(s),n.mark?.("created"),i||n.onCreated?.(l);const f=new Q;let u=!1,g=!1,b,E,I,v;const y=()=>{clearTimeout(v),v=setTimeout(()=>{g||(g=!0,E?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},w=()=>u?(I=Promise.resolve(),g=!0,I):(g=!1,I=new Promise((x,U)=>{b=x,E=U}),y(),I),S=()=>{if(clearTimeout(v),u=!0,g){I=Promise.resolve();return}g=!0,n.mark?.("loaded"),b?.()};l.addEventListener("load",S),f.addDispose(()=>{clearTimeout(v),l.removeEventListener("load",S)});let A;const h=()=>{A??=n.bindResizer?.(l)};let c=null,a=null,p;const m=()=>{if(!c){s.style.visibility="hidden",l.removeAttribute("id");return}n.elementId&&(l.id=n.elementId);const x=c.getBoundingClientRect(),U=a?.isConnected?a:Vd(c),B=U?U.getBoundingClientRect():null,W=B?Math.max(x.top,B.top):x.top,be=B?Math.min(x.bottom,B.bottom):x.bottom,Qe=Math.max(0,be-W);s.style.visibility=Qe>0?"visible":"hidden",s.style.left=`${x.left}px`,s.style.top=`${W}px`,s.style.width=`${x.width}px`,s.style.height=`${Qe}px`,l.style.transform=`translateY(${x.top-W}px)`};let _="",T="",P=0,N;const X=()=>{if(!c){N=void 0;return}N=window.requestAnimationFrame(X);const x=c.getBoundingClientRect(),U=a?.isConnected?a.getBoundingClientRect():void 0,B=`${Math.round(x.left)}:${Math.round(x.top)}:${Math.round(x.width)}:${Math.round(x.height)}:${U?`${Math.round(U.top)}:${Math.round(U.height)}`:"-"}`;B!==_&&(_=B,m());const W=l.getBoundingClientRect().height;W>0&&W!==P&&(P=W,c.style.height=`${W}px`);const be=getComputedStyle(c).pointerEvents;be!==T&&(T=be,s.style.pointerEvents=be)},R=()=>{N===void 0&&c&&(N=window.requestAnimationFrame(X))},D=()=>{N!==void 0&&(window.cancelAnimationFrame(N),N=void 0)},q=()=>m();let j=[];const K=(x,U)=>{if(a=U,x&&j.length>0){const B=j;j=[],B.forEach(W=>W())}if(x===c){m();return}if(p?.disconnect(),p=void 0,c&&c.style.removeProperty("height"),_="",P=0,T="",c=x,!x){D(),m();return}n.onShown?.(l);try{if(typeof ResizeObserver=="function"){const B=new ResizeObserver(m);typeof B.observe=="function"&&(p=B,p.observe(x))}}catch{p=void 0}m(),h(),R()};window.addEventListener("scroll",q,!0),window.addEventListener("resize",q),f.addDispose(()=>{p?.disconnect(),N!==void 0&&window.cancelAnimationFrame(N),window.removeEventListener("scroll",q,!0),window.removeEventListener("resize",q)});const de=x=>{u=!1,x&&n.onReload?.(l);let U;g||I===void 0?U=w():(y(),U=I);try{l.contentWindow?.location.reload()}catch{l.src=d}return U};return{element:l,ready(){return I??w()},reload:()=>de(!0),reloadQuietly:()=>de(!1),get shown(){return c!==null},whenShown(){return c!==null?Promise.resolve():new Promise(x=>{j.push(x)})},alignTo(x,U){K(x,U??null)},scrollBy(x,U){for(let B=c?.parentElement??null;B;B=B.parentElement){const W=getComputedStyle(B);if((W.overflowY==="auto"||W.overflowY==="scroll")&&B.scrollHeight>B.clientHeight){B.scrollTop+=U,B.scrollLeft+=x;return}}window.scrollBy(x,U)},resize(){A?.resize()},dispose(){K(null,null),A?.dispose(),f.dispose(),s.remove()}}}function Wd(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,g)=>u==="email"?`email:${g??n}`:u;let o,s=[];const d=()=>{s.forEach(u=>clearTimeout(u)),s=[],o?.remove(),o=void 0},l=new Map,f=(u,g,b)=>{const E=i(u,g),I=t.get(E);if(I)return I;const v=e.resolveMount();if(!v)return zd();const y=Kd(u,v,e,u==="email"?g??n:void 0,b);return t.set(E,y),y};return{get:u=>f(u),current:u=>f(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>f("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const g=t.get(i("email"));n=r();const b=l.get("email");u.alignTo(b?.slot??null,b?.clip??null),g?.alignTo(null)},alignSurface(u,g,b){l.set(u,{slot:g,clip:b??null}),(g?f(u):t.get(i(u)))?.alignTo(g,b??null)},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const g of t.values())if(g.element.contentWindow===u)return g}},busy(u){d();const g=u?e.resolveMount():void 0;if(!g)return;const b=qd(g);o=b,s=[setTimeout(()=>b.showSpinner(),Ud),setTimeout(d,Hd)]},dispose(){d(),t.forEach(u=>u.dispose()),t.clear(),l.clear(),n="a"}}}var Yd=O("canvas.resizerBinder"),sn=O("canvas.service"),Xd={created:J.canvasCreated,loaded:J.canvasLoaded};function Jd(e,t){if(e.getInstance(sn))return;const n=Wd({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:Jl,elementId:t.elementId,bindResizer:i=>e.getInstance(Yd)?.(i),onCreated:i=>ct(e,i,"fresh"),onReload:i=>ct(e,i,"fresh"),onShown:i=>ct(e,i,"switch"),mark:i=>t.mark?.(Xd[i])}),r=Y(e).addListener(M.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(sn,n),e.getInstance(k)?.addDispose(()=>{r.dispose(),n.dispose()})}function ct(e,t,n){const r=Y(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),Ml(r))}function Qd(e,t){ct(e,t,"promote")}function Zd(e,t){const n=t.contentWindow;n&&Y(e).greet(n)}function ec(e,t){const n=t.contentWindow;n&&Y(e).forget(n)}function fe(e){return e.getInstance(sn)}function tc(e){const t=Y(e),n=()=>fe(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(M.RELOAD,async()=>{await n()?.reload()}),i=t.addListener(s=>{s.data?.operation===M.SANDBOX_RESIZED&&n()?.resize()}),o=V(e,F.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(k)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose()})}var fm=O("HeadlessMode"),nc=O("HiddenMount");function rc(e){return e.getOrCreateInstance(nc,()=>Me(!1))}function fr(){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 ic(e){const t=e.getInstance(oe);let n,r;e.getInstance(k)?.addDispose(()=>{r?.remove(),r=void 0}),Jd(e,{resolveMount:()=>n,resolveSrc:o=>eo(o==="block"),elementId:"email_iframe",mark:o=>G(o)}),t?.watch(o=>{if(n)return;const s=o?.element;if(s instanceof HTMLElement)n=s;else if(o!==void 0)n=r??=fr();else return;fe(e)?.get("email")});let i;e.getInstance(k)?.addDispose(()=>{i?.remove(),i=void 0}),rc(e).watch(o=>{const s=fe(e);if(s){if(o){i??=fr(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var ao=O("canvas.headerFlow"),pr=["subject","preheader"],oc=3e3,sc={subject:M.SANDBOX_SUBJECT_UPDATE,preheader:M.SANDBOX_PREHEADER_UPDATE};function ac(e){const t=ve(e),n=Y(e),r=v=>v?"remote":so(e)?"system":"user",i=(v,{guid:y,value:w,forced:S})=>{const A=je(t);if(!A||typeof w!="string"||y&&y!==A.get().docId)return;const h=t.forcedHeaders();if(h?.[v]&&!S&&w!==h[v])return;S&&t.endForcedHeaders();const c=A.get().attributes[v]??"";d=!0;try{mt(A,{[v]:w},{source:r(S)})}finally{d=!1}o[v]=w,ie(e,F.ON_HEADER_APPLIED_ID).fire({field:v,value:w,forced:!!S,isGenerated:w!==c&&!!w})};let o={},s,d=!1,l=Promise.resolve();const f=(v,y,w)=>{l=n.sendAsync(sc[v],{value:y,guid:je(t)?.get().docId,...w?{force:!0,echo:!0}:{}}).catch(S=>{})};let u;e.inject(ao,{whenDelivered:async()=>{await l},reassert:v=>{const y=je(t),w=pr.filter(S=>v[S]);if(!(!y||w.length===0)){d=!0;try{mt(y,Object.fromEntries(w.map(S=>[S,v[S]])),{source:"system"})}finally{d=!1}t.beginForcedHeaders({subject:v.subject??"",preheader:v.preheader??""}),clearTimeout(u),u=setTimeout(()=>t.endForcedHeaders(),oc);for(const S of w)o[S]=v[S],f(S,v[S],!0)}}});const g=()=>{s?.(),s=void 0;const v=je(t);if(!v){o={};return}const y=v.get().attributes;o={subject:y.subject,preheader:y.preheader},s=v.subscribe(({source:w})=>{if(d)return;const S=v.get().attributes,A=t.forcedHeaders();for(const h of pr){const c=S[h];c!==o[h]&&(o[h]=c,f(h,c??"",w==="system"&&A?.[h]!==void 0))}})};g();const b=t.subscribe(g),E=n.addListenerAsync(M.APPLICATION_SUBJECT_UPDATE,v=>i("subject",v)),I=n.addListenerAsync(M.APPLICATION_PREHEADER_UPDATE,v=>i("preheader",v));e.getInstance(k)?.addDispose(()=>{E.dispose(),I.dispose(),b(),s?.(),clearTimeout(u)})}function hr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function an(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];hr(i)&&hr(o)?n[r]=an(o,i):i!==void 0&&(n[r]=i)}return n}function lc(e,t){const n=En;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const i=JSON.parse(r);if(i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length>0)return an(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?an(n,t):n}function dc(){const e=window.localStorage.getItem(bt.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?vs:Os;return e&&e!=="system"?e:t}function cc(){const e=window.localStorage.getItem(bt.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function uc(e){const{config:t}=e;return{operation:M.UPDATE_PREVIEW,theme:e.theme,commonStyles:lc(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}function fc(e){const t=Y(e),n=e.getInstance(we),r=e.getInstance(oe),i=ve(e);let o,s="";const d=()=>{const w=n?.get()??{},S=uc({config:w,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:dc(),codeMode:cc(),appName:"useblocks"}),A=JSON.stringify(S);A!==s&&(s=A,t.send(S))},l=t.onInit(()=>{s="",d()}),f=()=>{t.isInited()&&d()},u=n?.watch(f),g=r?.watch(w=>{o=w?.commonStyles,f()});let b;const E=()=>{b?.(),b=i.current()?.subscribe(f),f()};E();const I=i.subscribe(E),v=matchMedia(ys),y=()=>f();v.addEventListener("change",y),e.getInstance(k)?.addDispose(()=>{l.dispose(),u?.dispose(),g?.dispose(),b?.(),I(),v.removeEventListener("change",y)})}var ln;(function(e){function t(i,o,s=(d,l)=>d===l){if(i===o)return!0;if(i.length!==o.length)return!1;for(let d=0;d<i.length;d++)if(!s(i[d],o[d]))return!1;return!0}e.isEqual=t;function n(i,o=s=>s){const s=new Set;return i.filter(d=>{const l=o(d);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(i=[],o=[],s=(d,l)=>d===l){const d=[],l=[],f=[];for(const u of i){const g=o.find(b=>s(u,b));g?f.push({prev:u,next:g}):l.push(u)}for(const u of o)i.find(g=>s(u,g))||d.push(u);return{added:d,removed:l,exists:f}}e.diff=r})(ln||(ln={}));function pc(e,t){return e.type===t.type&&e.key===t.key}function hc(e){const t=Y(e),n=()=>e.getServices(Te)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(M.SANDBOX_ADD_EXTENSIONS,r)}),o=Is(Te),s=e.onInject(d=>{if(d!==o)return;const l=n();if(!t.isInited()){r=l;return}const{added:f,removed:u}=ln.diff(r,l,pc);if(r=l,u.length){if(u.some(g=>g.type==="script")){t.send(M.RELOAD);return}t.send(M.SANDBOX_REMOVE_EXTENSIONS,u.map(g=>g.key))}f.length&&t.send(M.SANDBOX_ADD_EXTENSIONS,f)});e.getInstance(k)?.addDispose(()=>{i.dispose(),s?.dispose()})}var mc=O("prewarm.editorVisible");function gc(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function vc(e={}){const t=e.paint??gc;let n=!1,r=!1,i=!1,o=!1,s=!1;const d=[],l=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,G(J.editorVisible);for(const f of d.splice(0))f()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){i=!0,l()},whenVisible(f){if(s){f();return}d.push(f)},contentShown:()=>i}}function bc(e){return e.getOrCreateInstance(mc,()=>vc())}var Ec=500,yc=500,_c=5e3;function wc(e){const t=e.quietMs??Ec,n=e.floorMs??yc,r=e.ceilingMs??_c;let i,o,s=0;const d=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},l=()=>{d(),e.run()},f=()=>{clearTimeout(i);const u=n-(Date.now()-s);i=setTimeout(l,Math.max(t,u))};return{start(){d(),s=Date.now(),o=setTimeout(l,r),f()},notify(){i!==void 0&&f()},cancel:d}}function Sc({attributes:e,readContent:t,docId:n,hasSession:r,serverId:i,show:o}){if(!r)return;const s={id:i??void 0,renderGuid:n,showId:o?.id,isNew:i==null,showToken:o?.token},d={...e,...s};return Object.defineProperty(d,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),d}var lo="self-init:";function Ic(e){return e.startsWith(lo)}function co(e,t){const n=e.getActiveShowRequest();return Ic(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Tc(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t();let i="";const o=()=>e.readDocument()?rn(e.readDocument()):i,s=()=>ke(e.container).editorPolicy,d=()=>e.readEmail(),l=()=>{const f=d();return{...f,id:e.isTemplate()||f.isNew?void 0:f.id,html:o()}};return{readContent:o,publicEmail:l,sendInitStart:()=>ae(n,"INIT_START",M.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>ae(n,"INITED",M.SANDBOX_INITED,{guid:d().renderGuid},void 0,r()),async sendContent(){const f=d(),{html:u,hasBrowserExtensionArtifacts:g}=no(f?.html||"");g&&e.events.browserExtensionDetected(),ro(e.readDocument(),u),i=u,await ae(n,"SET_ENTITY",M.SANDBOX_SET_ENTITY,on(o(),f.renderGuid,s(),e.readDocument()?.get().version),{guid:f.renderGuid,emailId:f.id??null},r())},refreshContent:()=>ae(n,"SET_ENTITY",M.SANDBOX_SET_ENTITY,on(o(),d().renderGuid,s(),e.readDocument()?.get().version),void 0,r()),sendPreheader:async()=>{const f=d();if(f.preheader!==void 0)return ae(n,"PREHEADER",M.SANDBOX_PREHEADER_UPDATE,{value:f.preheader,guid:f.renderGuid,force:!0},void 0,r())},sendSubject:async()=>{const f=d();if(f.subject!==void 0)return ae(n,"SUBJECT",M.SANDBOX_SUBJECT_UPDATE,{value:f.subject,guid:f.renderGuid,force:!0},void 0,r())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:f=>e.showFilled?.(f),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(l()),fireInit(f,u){if(!co(t(),f)){t().getActiveShowRequest()?.showId;return}const g=d();g.id,g.renderGuid,t().completeShow(f),mt(e.readDocument(),{is_inited:!0},{source:"system"});const b=l();return u&&(b.reset=!0),e.events.inited(b)},fireEmailChanged(){e.events.emailChanged(l())},fireContentChanged(){e.events.contentChanged(o())}}}function Ac(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,d;const l=Tc({...e,waitScope:()=>({getSandboxTimeoutMs:y=>t().getSandboxTimeoutMs(y),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:d?.signal??t().signal})});let f;const u=(y,w)=>{if(f===y)return;f=y;const S=s;setTimeout(()=>{s!==S||t().signal.aborted||I(y,w).catch(()=>{})},0)},g=()=>{d?.abort(),d=void 0};let b;const E=()=>{const y=t().signal;y!==b&&(b?.removeEventListener("abort",g),b=y,y.addEventListener("abort",g))};async function I(y,w){const S=++s;g(),d=new AbortController,E();const A=()=>s!==S,h=l.readTarget(),c=t().generation,a=()=>c===t().generation&&!t().signal.aborted,p=w?"init:reset-":"init:";if(!w){const T=l.publicEmail();T?.id,T?.renderGuid,T?.preheader}let m=!1,_=!1;try{n=!0,await l.sendInitStart(),l.fireWillInit(),await(w?l.refreshContent():l.sendContent()),m=!0,w||l.publicEmail()?.id;try{await l.sendPreheader()}catch(T){`${p}`,String(T)}try{await l.sendSubject()}catch(T){`${p}`,String(T)}if(A()||l.showFilled(h),await l.sendInited(),_=!0,i===y){const T=e.readSandboxGeneration?.()??o;T!==void 0&&(r=T)}await l.revealFilled()}catch(T){throw A()||(`${p}`,{...e.describeSurface?.(),error:String(T)},void 0),!A()&&co(t(),y)&&t().failShow(y,T),T}finally{v(y,w,p,{superseded:A(),sessionGeneration:c,contentApplied:m,sandboxInitedAcked:_,commit:a()})}}function v(y,w,S,A){const{superseded:h,contentApplied:c,sandboxInitedAcked:a}=A;if(h){`${S}`;return}a&&A.commit?l.fireInit(y,w||void 0):a?(`${S}`,A.sessionGeneration,t().generation,t().signal.aborted,void 0):c?(`${S}`,void 0):(`${S}`,void 0),n=!1,d=void 0,!a&&i===y&&(i=void 0,r===o&&(r=void 0)),!a&&c&&u(y,w)}return{channel:l,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:y=>{r=y},lastCorrelation:()=>i,markCorrelation:y=>{i=y},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:y=>{o=y},fill:y=>I(y,!1),refill:y=>I(y,!0),stop:()=>{s+=1,g(),n=!1,b?.removeEventListener("abort",g),b=void 0}}}function Cc(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:uo(e,n)}function uo(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Rc(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=u=>{const g=n(),b=i();if(!Cc(g,u,b)){u.showId,u.navId,u.emailId,g?.id,g?.showId,g?.renderGuid;return}u.showId,g?.id,g?.renderGuid,t.markFilled(o()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{s(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&s(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=o();if(t.filledGeneration()===u)return;const g=n(),b=i();if(!g?.renderGuid||!uo(g,b))return;const E=`${lo}${g.renderGuid}`;t.markFilled(u),t.markCorrelation(E);const I=r()?.isReady()===!0;g.id,g.renderGuid,(I?v=>t.refill(v):v=>t.fill(v))(E).catch(()=>{t.lastCorrelation()===E&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id}}}function Pc(e){return e??""}function Dc(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Oc(e){const t=ve(e),n=Y(e),r=()=>me(t.sessionKey())?void 0:t.current(),i=()=>{const C=r();return Sc({attributes:C?.get().attributes??{},readContent:()=>C?.getContent(),docId:C?.get().docId,hasSession:!!C,serverId:C?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(De)??On;let s={},d=!1;const l=e.getInstance(oe)?.watch(C=>{d=!!C?.element});let f=!1,u=!1,g=!1,b=0;const E=()=>{const C=fe(e);if(!C)return;const z=++b,H=C.spare();return H&&ec(e,H.element),(H?H.reloadQuietly():C.ensureSpare()?.ready())?.then(()=>{if(z!==b)return;f=!0;const ne=C.spare();ne&&Zd(e,ne.element),g&&(g=!1,T(),K())})},I=wc({run:()=>{g||E()?.catch(()=>{})}}),v=()=>{bc(e).noteContentShown(),!f&&!g&&I.start()};let y=!1;const A=Ac({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const C=fe(e);return y&&C&&(y=!1,I.start()),d?C?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:C=>{const z=fe(e),H=z?.spare()?.element.contentWindow;u&&z&&H&&C===H&&(u=!1,z.promote(),z.busy(!1),y=!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>ue(n),describeSurface:()=>({canvasPath:_,promoted:u,spareClean:f,handshake:n.isInited(),generation:ue(n)}),events:{willInit:C=>{ie(e,F.WILL_EMAIL_INIT_ID).fire(C)},inited:C=>{v(),ie(e,F.ON_EMAIL_INIT_ID).fire(C)},contentChanged:C=>{ie(e,F.ON_CONTENT_CHANGED_ID).fire(C)},emailChanged:C=>{ie(e,F.ON_EMAIL_CHANGED_ID).fire(C)},browserExtensionDetected:()=>{ie(e,F.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),h=Rc({pipeline:A,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>ue(n)});let c="",a="",p="";const m=C=>C.length>0;let _="none";const T=()=>{const C=fe(e)?.spare();C&&(n.send({operation:M.SANDBOX_LOCK_EDIT,data:!0}),f=!1,u=!0,Qd(e,C.element))},P=(C,z)=>{const H=fe(e);if(!H)return!0;const ne=H.spare(),Ee=ne&&f?"spare":"prepare";if(_=Ee,H.busy(!0),ne&&f)return T(),!0;I.cancel(),n.send({operation:M.SANDBOX_LOCK_EDIT,data:!0});const ye=E();if(ye===void 0)return _="reload",H.busy(!1),H.peek("email")?.reload(),!0;g=!0;const Tt=b;return ye.catch(()=>{!g||Tt!==b||(g=!1,_="reload",H.busy(!1),H.peek("email")?.reload())}),!1},N=()=>{be(),A.noteSandboxGeneration(ue(n));const C=i(),z=Dc(C?.renderGuid,C?.showId,C?.id,s.emailId),H=Pc(C?.renderGuid);if(H!==a){const ye=m(a),Tt=a;a=H,ye&&P(Tt,H)}if(g)return;z!==c&&(c=z,h.showRequestIdentityChanged());const ne=r(),Ee=`${z}|${ne?.get().docId??""}|${ue(n)}`;Ee!==p&&ne?.isReady()===!0&&(p=Ee,h.selfInitChanged()),h.saasChanged(),q()};let X=!1,R="",D="";const q=()=>{const C=i();if(!C?.renderGuid)return;const z=A.channel.readContent(),H=JSON.stringify([C.preheader,C.common_styles,C.meta,C.subject,C.utm_parameters?.utm_campaign??"",C.utm_parameters?.utm_content??"",C.utm_parameters?.utm_medium??"",C.utm_parameters?.utm_source??"",C.utm_parameters?.utm_term??""]),ne=X&&z!==D,Ee=X&&H!==R;if(X=!0,D=z,R=H,A.isEventsLocked())return;const ye={...C,id:s.isTemplate||C.isNew?void 0:C.id,html:z};if(ne){ie(e,F.ON_CONTENT_CHANGED_ID).fire(z),ie(e,F.ON_EMAIL_CHANGED_ID).fire(ye);return}Ee&&C.is_inited&&ie(e,F.ON_EMAIL_CHANGED_ID).fire(ye)};let j=!1;const K=()=>{j||(j=!0,queueMicrotask(()=>{j=!1,N()}))};e.inject(xn,{pipeline:A,setRoute:C=>{C.emailId===s.emailId&&!!C.isTemplate==!!s.isTemplate||(s=C,K())}});let de,x;const U=()=>{const C=r()?.get().docId;C!==x&&(de?.(),x=C,de=r()?.subscribe(K)),K()};let B,W;const be=()=>{const C=e.getInstance(De);!C||C===B||(W?.(),B=C,W=C.onShowRequested(z=>h.showRequested(z)))},Qe=n.addListener(C=>{C.data?.operation===M.SANDBOX_RESIZED&&I.notify()}),Vo=t.subscribe(U),Ko=Zi(n,K);U(),e.getInstance(k)?.addDispose(()=>{l?.dispose(),W?.(),Ko(),Vo(),de?.(),Qe.dispose(),I.cancel(),A.stop()})}function xc(){return Cs!=="useblocks"}var dn={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Lc={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},mr=dn,Mc=["freeUserBlocks","blocks"],fo={};function kc(e){fo=e}var po=e=>Mc.includes(e)?mr:fo[e]??mr,cn={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},Nc={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Fc={...cn,config:{...cn.config,imageCenterFileManagerView:!1}};kc({pro:Lc,editor:Nc,simple:xc()?cn:Fc,freeUserBlocks:dn,blocks:dn});var gr=new Set;function jc(){return window.localStorage.getItem(bt.em_color_scheme)??void 0}function Bc(e){return gr.add(e),e(jc()),{dispose(){gr.delete(e)}}}function Ln(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Uc(e,t){return t.modeDefaults(Ln(e,t.fallbackMode))}function Hc(e,t){const n=Ln(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Gc(e,t){const n=Ln(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function qc(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function $c(e){return es(e.map(t=>t?.resourceProxy))}function zc(e){return Zo(e.map(t=>t?.resourceProxyPolicy))}function Vc(e){return us(e.map(t=>t?.backendProxy))}function Kc(e){return ii(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Wc(e,t){return[e.base,Uc(e,t),e.profile,e.serverSide,Hc(e,t.fallbackMode),e.user,Gc(e,t.fallbackMode),e.local]}function xt(e,t){const n=Wc(e,t),r=ii(n),i=qc(n);i!==void 0&&(r.fileManager=i);const o=$c(n);o!==void 0&&(r.resourceProxy=o);const s=zc(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const d=Vc(n);d!==void 0&&(r.backendProxy=d);const l=Kc(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}var Yc=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function vr(e){return e==="server"?"serverSide":e}function Xc({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=Me();let o={kind:"pending"},s;const d=new Promise(b=>{s=b}),l=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function f(){o.kind!=="pending"&&i.set(xt(r,e))}function u(b){if(o.kind!=="pending")return;clearTimeout(l),o=b;const E=xt(r,e);i.set(E),s(E)}function g(b,E){r[vr(b)]=E,b==="server"&&o.kind==="pending"?u({kind:"applied"}):f()}return{watch:b=>i.watch(b),select:b=>i.select(b),get:()=>i.get(),ready:()=>d,state:()=>o,layers:()=>({...r}),bootstrap(){const b=xt(r,e);return Object.fromEntries(Yc.map(E=>[E,b[E]]))},merge(b,E){g(E,{...r[vr(E)],...b})},replace(b,E){g(E,b)},setMode(b){r.user={...r.user,mode:b},f()},setAdvancedConfigs(b){r.advancedConfigs=b,f()},serverAbsent(b){u({kind:"absent",reason:b})},applyServerResponse(b){o.kind==="pending"&&g("server",{...r.serverSide,...b})},dispose(){clearTimeout(l)}}}var Jc=5e3,Qc="blocks";function Zc(){return{...po(Qc)?.config,mergeTags:void 0}}function eu(e,t){e.getInstance(oe)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function tu(e,t){let n;$i(e).watch(({profile:r})=>{const i=`${r?.theme??""}|${r?.locale??""}`;if(i===n)return;n=i;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function nu(e,t){let n=null;const r=Bc(i=>{const o=typeof i=="string"&&i?i:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(k)?.addDisposable(r)}async function ru(e,t){if(e.getInstance(In)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Pe);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function iu(e){e.injectFactory(we,(t,n)=>{if(n)return n;const r=Xc({base:Zc(),env:{modeDefaults:i=>po(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Jc});return eu(e,r),tu(e,r),nu(e,r),ru(e,r),e.getInstance(k)?.addDisposable(r),r},!0)}var Re=class extends Q{_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 L(e,t,n){const r=cs(e);return(i,o,s)=>{const d=r(async l=>{const f=t?t(l):l;s&&i.bind(s);const u=await i(f);return n?n(u):u},o,s);return()=>d.dispose()}}var ou=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Qt;this.handleDestroy=L(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Re(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},Mn=O("DestroyableService");function su(e){e.injectFactory(Mn,()=>{const t=e.getInstance(k);if(!t)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new ou({lifetime:t,options:e.getInstance(oe),getInstance:()=>e.getInstance(Et),release:()=>Ts(e.getInstance(Es)??e)})},!0)}function au(e){const t=e.getInstance(Mn);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var lu=1e3;function ho(e,t,n=lu,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const s of i)if(!ho(e[s],t[s],n,r+1))return!1;return!0}return!1}function He(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const i=t[r],o=e[r];ho(i,o)||(n[r]=i)}return n}var du=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail не ответил за ${e}ms — письмо не сохранено`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},cu=({source:e,emailtags:t,group:n,tags:r,...i})=>i,uu=()=>Si();async function fu({emails:e},t){const n=uu();let r;try{return await Promise.race([e.notifySave(t),new Promise((i,o)=>{r=setTimeout(()=>{const s=new du(n);t.value.id,o(s)},n)})])}finally{r!==void 0&&clearTimeout(r)}}function pu(e){const{emails:t}=e,n=async(r,i)=>{const o=cu(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),d=s?{...s,...o}:o,l=await fu(e,{prev:s,patch:s?He(s,o):o,value:d,source:i.source??""}),f=String(l.id??r??le()),u=l.id===void 0?{...l,id:f}:l;return await t.cache.addOrUpdate(f,()=>u)};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const i=await n(void 0,r);return i?.renderGuid?i:{...i,renderGuid:le()}},async updateEmail(r,i){return await n(r,i)}}}var Lt=20,hu=({source:e,emailtags:t,group:n,tags:r,...i})=>i;function mu({revisions:e,revisionsByEmail:t}){const n=async(r,i)=>(t.clear(),await t.get(r,{page:i}),(await e.cache.values()??[]).filter(o=>String(o?.parent)===String(r)));return{async readRevisions(r,i=1){const o=await n(r,i);return{revisions:o.slice(Lt*(i-1),Lt*i),page:i,hasMore:o.length>Lt*i}},async readAutosave(r){return Ua(await n(r,1))},async saveAutosave(r,i){const o=hu(i);return await e.create({...o,parent:r,modified:new Date().toString()})}}}var gu=class extends hs{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}},vu=class extends pe{};var br=class extends Q{_items=new Map;_onChangeEmitter=new Ns;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const i=await t(n);return pt(n,i)||this._onChangeEmitter.fire(),i}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([i,o])=>i)),r=(await this.entries()).filter(([i,o])=>!n.has(i));for(const[i,o]of e)t.push(this.addOrUpdate(i,()=>o)),n.add(i);for(const[i]of r)t.push(this.remove(i));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function bu(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let d=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(f=>{for(const u of l){const g=f[u],b=t[u];return u==="id"||typeof g!="string"?g===b:typeof b=="string"&&g.startsWith(b)}return!0}),d=e.length}return r&&(e=e.sort((l,f)=>(l[r]>f[r]?1:f[r]>l[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:d,total:s,totalPages:Math.ceil(d/o)}}function Eu(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const i=t.get(r.id)||{};t.set(r.id,{...i,...r})}return[...t].map(([n,r])=>r)}function yu(e,t){return Er(e)&&Er(t)?String(e)===String(t):e===t}function Er(e){return typeof e=="string"||typeof e=="number"}var _u=class extends Q{_cache=new br;_readEmitter=new pe;_saveEmitter=this.addDisposable(new gu);_removeEmitter=this.addDisposable(new vu);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new Q);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new br),i=n.addDisposable(new pe);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const l=Eu(await i.fire(o))||[];for(const f of l)f[e]=o,await this._cache.add(f.id,f);return l}catch{return[]}});const d=(await this._cache.values()||[]).filter(l=>{const f=l[e];return f==null||yu(f,o)});return bu(d,s)},first(o,s={}){return t.get(o,{...s,page:1,pageSize:1}).then(({data:d})=>d[0])},handleRead:i.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=le()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async i=>{const o=i?{...i,...t}:t;if(!r)return t=i?He(i,t):t,await this._saveEmitter.fire({prev:i,patch:t,value:o,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Xe(e){const t=O(e);return n=>n.getOrCreateInstance(t,()=>new _u)}function wu(e){const t=e.getInstance(k);if(!t)throw new Error("Failed");return t}function yr(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Su(e,t,n){return e&&!yr(t)&&yr(e)?{...n,meta:e.meta}:n}var mo=Xe("plugin.dataSource.emails"),go=Xe("plugin.dataSource.emailRevisions"),_r=O("emailDocuments.provided");function Iu(e){const t=mo(e),n=go(e),r=n.byForeignKey("parent");return e.getInstance(_r)?{emails:t,emailRevisions:n}:(e.inject(_r,!0),sl(e,pu({emails:t})),cl(e,mu({revisions:n,revisionsByEmail:r})),wu(e).addDisposable(t.onSave(({prev:i,patch:o,value:s})=>Su(i,o,s),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function wr(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 Tu(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Au="po",ot=null;function Cu(){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([Au],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Ru(){return ot===null&&(ot=Cu().catch(e=>{throw ot=null,e})),ot}async function vo(e){if(typeof e=="object")return kn(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Pu(t):Du(t)}function kn(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Pu(e){try{return kn(JSON.parse(e))}catch{return}}var Sr=!1;async function Du(e){try{return kn((await Ru()).parsePoCatalog(e))}catch{Sr||(Sr=!0);return}}var Ou="em_locale",xu="em_ant_locale",Lu="locale",Mu="ant_locale";function Nn(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function bo(e,t){const n=Nn(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function ku(){return Nn("em_locale")??bo(Lu,"em_locale")}function Ir(e){try{localStorage.setItem(Ou,JSON.stringify(e))}catch{}}function Nu(){return Nn("em_ant_locale")??bo(Mu,"em_ant_locale")}function Fu(e,t){try{localStorage.setItem(xu,JSON.stringify({id:e,data:t}))}catch{}}var ju=8e3;function Bu(e,t){const n=e,r=t,i=Object.keys(n).filter(o=>o!=="");return i.length!==Object.keys(r).filter(o=>o!=="").length?!1:i.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function Uu(e){const t=ku(),n=Nu();let r={ready:!1},i;const o=Me(r);let s=0;const d=y=>{r={...r,...y},o.set(r)},l=()=>{r.ready||d({ready:!0})},f=setTimeout(l,e.unlockAfterMs??ju),u=y=>y!==s;let g;async function b(y,w){if(n?.id===y&&n.data&&d({antd:n.data}),!g)return;const S=await g(y).catch(()=>{});!S||u(w)||(d({antd:S}),Fu(y,S))}async function E(y,w){const S=await e.askHost(y).catch(()=>null);if(u(w))return!0;if(S==null)return!1;const A=await vo(S);return u(w)||(A&&d({catalog:A}),l()),!0}async function I(y,w){const S=await e.readList();if(u(w))return;if("error"in S){d({failure:{kind:"GET_LOCALES_ERROR",error:S.error}}),l();return}const A=S.data.find(c=>c.locale===y);if(!A){Tu("em_locale")&&d({catalog:void 0}),l();return}if(wr(t,A)&&(!i||i.catalog===t?.data)){l();return}if(i?.entry&&r.catalog===i.catalog&&wr(i.entry,A)){Ir(i.entry),l();return}const h=await e.readCatalog(y);if(!u(w)){if("error"in h){d({failure:{kind:"GET_LOCALE_ERROR",error:h.error}}),l();return}h.data&&(i?.id===y&&r.catalog===i.catalog&&Bu(i.catalog,h.data)||d({catalog:h.data}),Ir({id:y,time:A.updatedAt||Math.floor(Date.now()/1e3),hash:A.contentHash,data:h.data})),l()}}async function v(y,w){if(!await E(y,w)){if(!u(w)&&(i?.id===y&&r.catalog===i.catalog||y==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await I(y,w)}}return{set(y){if(!y||y===r.id)return;const w=s+=1;d({id:y,failure:void 0});const S=i?.id===y&&r.catalog===i.catalog;(i&&!S&&r.catalog===i.catalog||y==="en_US"&&r.catalog)&&d({catalog:void 0}),t?.id===y&&t.data&&(d({catalog:t.data}),l()),b(y,w),v(y,w)},prime(y,w,S){r.id||r.catalog||!w||(i=t?.id===y&&t.data&&(!S||t.time>=S.time)?{id:y,catalog:t.data}:{id:y,catalog:w,entry:S?{id:y,time:S.time,hash:S.hash,data:w}:void 0},d({catalog:i.catalog}))},useAntdLoader(y){g=y,r.id&&b(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(f)}}var Hu=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})},Gu=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:o,baseUrl:s,cancelToken:d,...l})=>{const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(l,f),g=i&&this.toQueryString(i),b=this.contentFormatters[r||"application/json"],E=o||u.format;return this.customFetch(`${s||this.baseUrl||""}${n}${g?`?${g}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(d?this.createAbortSignal(d):u.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async I=>{const v=I;v.data=null,v.error=null;const y=E?I.clone():I,w=E?await y[E]().then(S=>(v.ok?v.data=S:v.error=S,v)).catch(S=>(v.error=S,v)):v;return d&&this.abortControllers.delete(d),w})}},qu=O("rest.v2.transport"),Tr=Symbol("rest.v2.secureRequest");function $u(e){return e.getOrCreateInstance(qu,()=>{const t=e.getInstance(ri)?.execute||fetch;return new Gu({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[Tr]:!0}),customFetch:(n,r={})=>{const{[Tr]:i,...o}=r;return t(n,{...o,[is]:i!==!0})}})})}function zu(e,t){const n=$u(e);return Object.assign({},...t.map(r=>new r(n)))}function Ar(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Eo(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Ar(n.details,"wp_code")??n.code,message:Ar(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 yo(e){return!e.ok||!!e.error}function Vu(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function _o(){return Vu(bt.em_translations_v2)??!0}function Ku(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Wu(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Yu(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],i=r[0];return typeof i=="string"&&i!==""&&t.push({locale:i,updatedAt:Ku(r[1])}),t},[]):[]}function Xu(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Wu(n.updated_at),contentHash:n.content_hash}),t),[])}function wo(e){return zu(e,[Hu])}function vt(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function un(e){return!e.ok||e.error!=null}function fn(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Mt(e){return{data:await vo(e)??null}}async function Ju(e){if(_o())try{const n=await wo(e).localesList();return yo(n)?{error:Eo(n)}:{data:Xu(n.data)}}catch(n){return vt(n)}const t=si(e,[hi]);try{const n=await t.get_translations2({file:"react_app"});return un(n)?fn(n):{data:Yu(n.data)}}catch(n){return vt(n)}}async function Qu(e,t){if(_o())try{const r=await wo(e).jsonList({locale:t});return yo(r)?{error:Eo(r)}:Mt(r.data)}catch(r){return vt(r)}const n=si(e,[hi]);try{const r=await n.get_translations3({id:t,file:"react_app"});return un(r)?fn(r):Mt(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return un(r)?fn(r):Mt(r.data)}catch(r){return vt(r)}}}var $e=O("locale.service");function Zu(e){if(e.getInstance($e))return;const t=Uu({readList:()=>Ju(e),readCatalog:n=>Qu(e,n),askHost:async n=>(await ie(e,F.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(he)});e.inject($e,t),e.getInstance(k)?.addDispose(()=>t.dispose())}function ef(e){const t=e.getInstance(we);if(!t)return;const n=e.getInstance($e);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i));e.getInstance(k)?.addDisposable(r)}var tf="user_id",nf="project_id",Cr=O("rest.identityHeadersProvided");function rf(e){if(e.getInstance(Cr))return;e.inject(Cr,!0);let t;e.getInstance(oe)?.watch(n=>{t=n}),e.addService(_n,{execute(n,r){if(r?.public)return;const i=t?.user?.id??zi(e).profile?.id;i!=null&&i!==""&&n.headers.set(tf,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(nf,String(o))}})}function of(e){if(!e)return!1;try{return e.getInstance(he)!==void 0}catch{return!1}}var sf="Invalid standaloneKey.",pm=O("StandaloneMockGuard");function af(){const e=new Error(sf);return e.name="InvalidStandaloneKeyError",e}function lf(e){e.addService(_n,{execute:()=>{if(of(e))throw af()}})}function df(e){gs(e),lf(e)}function cf(e){const t=new oo;e.inject(De,t);let n;const r=e.getInstance(oe)?.watch(o=>{o&&(o.signal!==void 0&&(n=o.signal),t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...n!==void 0?{signal:n}:{}}))}),i=e.getInstance(k);r&&i?.addDisposable(r),i?.addDispose(()=>{t.abort()})}var uf=Xe("plugin.dataSource.blocks"),ff=Xe("plugin.dataSource.blockRevisions"),pf=Xe("plugin.dataSource.comments"),hf=io(),mf=io(),So=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1004
1004
  <html>
1005
1005
  <head>
1006
1006
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -1041,10 +1041,10 @@ import{t as ei}from"./static/esm/50fbfdf6.js";import{$ as Vo,A as Ko,At as Wo,B
1041
1041
  </tr>
1042
1042
  </table>
1043
1043
  </body>
1044
- </html>`;function hf(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:_o,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var mf=O("CurrentProject"),gf={};function _t(e){return e?.getInstance(mf)?.get()??gf}function wo(e){const t=_t(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var So=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function vf(e){return!Object.keys(e).some(t=>So.has(t))}function bf(e){const t={},n={};for(const[r,i]of Object.entries(e))So.has(r)?t[r]=i:n[r]=i;return{showOptions:t,misplacedEmailFields:n}}function Cr(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function wt(e){return{emails:po(e),blocks:df(e),emailRevisions:ho(e),blocksRevision:cf(e),comments:uf(e)}}function Ef(e){const t=Object.values(wt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Nn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(vf(e))return{email:Cr(e)};{const{showOptions:n,misplacedEmailFields:r}=bf(e),i=Object.keys(r);t&&i.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Cr({...r,...o})}}}function Io(e){return Cn(e)?.current()}function ut(e){return Io(e)?.getContent()}function yf(e,t){const n=t??hf(),r=Io(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:ut(e)??n.html}:n}async function kt(e){return(await e.getInstanceAsync(Pe))?.project}function xe({code:e,project:t,...n},r){const i=ge(n),o=wo(r),s=ke(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...i,...e?{html:s.toEditorForm(e)}:{},...o===void 0?{}:{project:o},utm_parameters:i.utm_parameters||{},_embedded:void 0}}function Z({html:e,renderGuid:t,showToken:n,showId:r,...i},o){const{requested:s}=_t(o),d=$i(o);return ge({...i,code:ke(o).toOutputForm(e),project:s===void 0?i.project:s,utm_parameters:d.UTMEnabled?i.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0})}function fn(e){return e==null?"":e.replaceAll(`\r
1044
+ </html>`;function gf(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:So,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var vf=O("CurrentProject"),bf={};function _t(e){return e?.getInstance(vf)?.get()??bf}function Io(e){const t=_t(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var To=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Ef(e){return!Object.keys(e).some(t=>To.has(t))}function yf(e){const t={},n={};for(const[r,i]of Object.entries(e))To.has(r)?t[r]=i:n[r]=i;return{showOptions:t,misplacedEmailFields:n}}function Rr(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function wt(e){return{emails:mo(e),blocks:uf(e),emailRevisions:go(e),blocksRevision:ff(e),comments:pf(e)}}function _f(e){const t=Object.values(wt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Fn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Ef(e))return{email:Rr(e)};{const{showOptions:n,misplacedEmailFields:r}=yf(e),i=Object.keys(r);t&&i.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Rr({...r,...o})}}}function Ao(e){return Rn(e)?.current()}function ut(e){return Ao(e)?.getContent()}function wf(e,t){const n=t??gf(),r=Ao(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:ut(e)??n.html}:n}async function kt(e){return(await e.getInstanceAsync(Pe))?.project}function xe({code:e,project:t,...n},r){const i=ge(n),o=Io(r),s=ke(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...i,...e?{html:s.toEditorForm(e)}:{},...o===void 0?{}:{project:o},utm_parameters:i.utm_parameters||{},_embedded:void 0}}function Z({html:e,renderGuid:t,showToken:n,showId:r,...i},o){const{requested:s}=_t(o),d=Vi(o);return ge({...i,code:ke(o).toOutputForm(e),project:s===void 0?i.project:s,utm_parameters:d.UTMEnabled?i.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0})}function pn(e){return e==null?"":e.replaceAll(`\r
1045
1045
  `,`
1046
- `)}function Rr(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function _f(e,t,n,r){const i=wf(e,t,n,r);return i===void 0}function wf(e,t,n,r){const{email:i}=Nn(t,!1),o=xe(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const d=Cn(e)?.current();if(!d)return"no-session";const l=d.get(),f=l.attributes;if(l.serverId!==s)return"document-id";if(f.is_inited!==!0)return"not-inited";const u=Rr(fn(n??d.getContent()));if(o.html!==void 0&&Rr(fn(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==f.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==f.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==f.common_styles)return"common_styles"}function Pr(e,t){const{email:n}=Nn(t,!1),r=xe(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:fn(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Sf(e,t){const n={...e};return delete n.id,{...n,...t}}function If(e){return e.html?e:{...e,html:_o}}function Be({code:e,project:t,...n},r,i){const o=i??wo(r);return{...n,...e?{html:ke(r).toEditorForm(e)}:{},renderGuid:le(),...o===void 0?{}:{project:o}}}function st({html:e,renderGuid:t,...n},r){const{requested:i}=_t(r);return ge({...n,code:ke(r).toOutputForm(e),project:i===void 0?n.project:i,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function To(e){return Cn(e)?.current()?.get().serverId??void 0}function pn(e,t,n){return n===void 0&&(n=e.post===void 0?To(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function at(e,t){return ge({...e,link:void 0,comment_status:void 0})}function hn({code:e,...t},n,r){return r===void 0&&(r=t.parent===void 0?To(n):t.parent),{...t,...e?{html:e}:{},parent:r}}function Dr({html:e,...t},n){return ge({...t,code:e,guid:void 0,compiled:ge({html:e,ampHtml:e&&""})})}var Tf=O("emailTemplate.reads");async function Af(e,t){try{return await Se(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message;return}}function Cf(e,t){const n=e.getOrCreateInstance(Tf,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=Af(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var Rf="EXTERNAL";function Pf(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"сохранение не состоялось")}var Df="email_id",Of=class extends Q{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_dataSources;_eventLock;_queue=Cs();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=wt(t),this._eventLock=Ef(t);const n=V(e,F.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(yn,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Df,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(De)??Dn}_throwIfDestroyed(){if(this.isDisposed())throw di()}async getTemplateEmail(e){const t=await Cf(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await kt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Be(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,hn(i,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,pn(i,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,i){const o=this._dataSources.emails,s=o.cache,d=await kt(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let f=xe(e,this._container);const u=f.id;let g=u;if(u!==void 0){const b=await o.get(u);f={...b??{},...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d}}else{g=n??le();const b=await o.get(g);f={...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d},delete f.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(f=Sf(b,f))}return u===void 0&&(f=If(f)),await s.addOrUpdate(g,()=>f),f}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Pr(this._container,e))return!1;const n=ut(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Pr(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:ut(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&t!==this._showRequests){this._showRequests;return}if(!e)return;const n=this._getInitPipeline();if($(n.signal),_f(this._container,e,ut(this._container),this._prevCommand?.id)||this._isRepeatOfLastShow(e))return;const r=Nn(e);r.email.id,this._prevCommand?.id;let i,o="",s=0,d=!1,l,f=Promise.resolve(),u,g=!1;try{this._eventLock.suspendChange();const{email:b,blocks:E,autosaves:I,comments:v,templateId:y,reload:w}=r;i=b.id;const S=xe(b,this._container),A=S.id,h=A??le(),c=await Ue("getProject",kt(this._container));$(n.signal),o=le();const a={isNew:A===void 0,id:String(h),project:c},p=w===!0&&A!==void 0;p&&(await this._dataSources.emails.remove(String(A),{silent:!0}),String(A)),s=++this._showToken,String(h);const m=[];m.push(this.setBlocks(E)),b.id!==void 0&&(m.push(this.setComments(v)),m.push(this.setEmailRevisions(I,String(b.id)))),m.push(this.setEmail(b,Number(y),A===void 0?String(h):void 0,s,o)),await Ue("setEmail+blocks+revisions",Promise.all(m),{emailId:A??String(h),showId:o,targetShowToken:s}),$(n.signal);const _=await this._dataSources.emails.get(String(h)),T=ve(this._container),P={id:o,token:s};A===void 0?u=T.startNewDraft(_??S,{patch:S,show:P}):p?u=T.reload(A,{email:_??S,patch:S,show:P}):T.sessionKey()===Fe(A)?u=T.show(S,P):u=T.open(A,{email:_??S,patch:S,show:P});const N=!!this._prevCommand&&pt(this._prevCommand,a);a.id,!this._prevCommand||pt(this._prevCommand,a),this._prevCommand?.id,this._rememberShow(a),f=n.requestShow({showId:o,navId:String(h),emailId:A,isNew:A===void 0}),g=!0,String(h),d=!0}catch(b){l=b,g&&o&&n.failShow(o,b),String(b)}finally{this._eventLock.resumeChange()}if(!d)throw l instanceof Error?l:new Error(`[useblocks] show() setup failed: ${String(l??"unknown error")}`);return Ue("show-init-deferred",Promise.all([f,u?.whenReady().catch(b=>{if(b instanceof ht){const E=xi(b);throw E?new Error(`[useblocks] show(): email open failed (${E})`,{cause:b}):b}})??Promise.resolve()]).then(()=>{}),{showId:o,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();$(e.signal);const t=ve(this._container),n=await t.save("publish",{source:Rf});if($(e.signal),!n)throw Pf(t.saveState().error);return Z(yf(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function xf(e){return String(e).replace(/"/g,"&quot;")}function Lf(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 Mf(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 Or(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=xf(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function kf(e,t,n){if(!e?.trim()||!t)return e;const r=Mf(e);if(!r)return e;const i=String(t),o=Lf(n??new Date);let{full:s,index:d}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=Or(s,"em-block-id",i)),s=Or(s,"em-block-version",o),e.slice(0,d)+s+e.slice(d+l)}function Nf(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 Ff(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Nf(e)}}function Nt(e,t){return t?Ff(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Ao=["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"],jf=[...Ao,"html","id","project","password"],fm=new Set(["html",...Ao,"global_block","project"]);function Bf(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(jf),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Uf(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Bf(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 mn=new WeakMap;function Hf(e){let t=mn.get(e);return t||(t={byId:new Map,fallback:[]},mn.set(e,t)),t}function Gf(e){mn.delete(e)}function qf(e,t){const{byId:n,fallback:r}=Hf(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,d=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&d)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function $f(e,t){const{blocks:n}=wt(e);return await n.cache.getIfPresent(t)??void 0}async function zf(e,t){if(!t.blockId)return;const n=await $f(e,t.blockId);if(n)return Uf(n,t)}async function Vf(e,t){const n=qf(e,t);if(n)return Nt(e,n);const r=await zf(t,e);return r?Nt(e,r):Nt(e,void 0)}var Kf=cs("application_block_inserted"),Wf=-1e3,xr=new WeakSet;function Yf(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 Xf(e){if(!e||xr.has(e))return;xr.add(e);const t=new Q,n=Y(e);return t.addDisposable(n.addListenerAsyncPipe(Kf,async(r,i)=>{const o=Yf(r)?await Vf(r,e):r;return i?i(o):o},Wf)),t.addDisposable({dispose:()=>{Gf(e)}}),t}var Lr=100,Jf=class extends Q{_container;_events;constructor(e){super(),this._container=e;const t=Xf(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=wt(e),o=V(e,F.ON_SHARE_ID),s=V(e,F.ON_SHOW_PREVIEW_ID),d=V(e,F.ON_EMAIL_CLONE_ID),l=V(e,F.ON_CODE_VALIDATE_ID),f=V(e,F.ON_SUBJECT_CHANGED_ID),u=V(e,F.ON_EMAIL_CHANGED_ID),g=V(e,F.ON_PREHEADER_CHANGED_ID),b=V(e,F.ON_SAVEBUTTON_CLICK_ID),E=V(e,F.ON_NEXTBUTTON_CLICK_ID),I=V(e,F.ON_SEND_LIVEPREVIEW_ID),v=V(e,F.ON_SEND_TESTEMAIL_ID),y=V(e,pf),w=V(e,F.ON_CONTENT_CHANGED_ID),S=V(e,ff),A=V(e,F.ON_PREVIOUSBUTTON_CLICK_ID),h=V(e,F.ON_SEND_EMAIL_MODAL_ID),c=xs(V(e,F.ON_EMAIL_INIT_ID),a=>!a.reset);return{handlePreheaderChanged:L(g),handleSubjectChanged:L(f),handleValidate:L(l),handleReadEmail:L(n.handlerRead,a=>a,a=>a&&xe(a,e)),handleSaveEmail:L(n.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?Z(a,e):void 0;return{prev:T,patch:He(T,Z(p,e)),value:Z(m,e),source:_}},a=>a?xe(a,e):void 0),handleRemoveEmail:L(n.onRemove,({value:a,source:p})=>({value:Z(a,e),source:p}),()=>{}),handleReadCommonBlocks:L(y,a=>a.project,a=>a?.map(p=>Be(p,e))),handleReadTemplateBlocks:L(S,a=>a,a=>a?.map(p=>Be(p,e))),handleReadBlocks:L(t.byForeignKey("project").handleRead,a=>_t(e).requested||String(a),a=>a?.map(p=>Be(p,e))),handleSaveBlock:L(t.onSave,function({prev:a,patch:p,value:m,source:_}){const T=m.global_block===!0&&m.id&&typeof m.html=="string"?{...m,html:kf(m.html,String(m.id))}:m,P=a?st(a,e):void 0;return{prev:P,patch:He(P,st(p,e)),value:st(T,e),source:_}},a=>a?Be(a,e):void 0),handleRemoveBlock:L(t.onRemove,({value:a,source:p})=>({value:st(a,e),source:p}),()=>{}),handleReadComments:L(r.byForeignKey("post").handleRead,a=>a,a=>a?.map(p=>pn(p,e))),handleSaveComment:L(r.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?at(a,e):void 0;return{prev:T,patch:He(T,at(p,e)),value:at(m,e),source:_}},a=>a?pn(a,e):void 0),handleRemoveComment:L(r.onRemove,({value:a,source:p})=>({value:at(a,e),source:p}),()=>{}),handleReadEmailRevisions:L(i.byForeignKey("parent").handleRead,a=>a,a=>a?.map(p=>hn(p,e))),handleEmailAutosave:L(i.onSave,function({prev:a,patch:p,value:m,source:_}){return{value:Dr(m,e),source:_}},a=>a?hn(a,e):void 0),handleRemoveEmailAutoSave:L(i.onRemove,({value:a,source:p})=>({value:Dr(a,e),source:p}),()=>{}),handleEmailChanged:L(qn(u,Lr),a=>Z(a,e)),handleEmailInit:L(c,a=>Z(a,e)),handlePreviousButtonClick:L(A,a=>Z(a,e)),handleNextButtonClick:L(E,a=>Z(a,e)),handleSaveButtonClick:L(b,a=>Z(a,e)),handleHtmlChanged:L(qn(w,Lr)),handleTestEmailSend:L(v,({html:a,...p})=>({...p,code:a,compiled:{html:a,ampHtml:""}})),handleTestEmailModal:L(h,a=>Z(a,e)),handleCloneEmail:L(d,a=>Z(a,e)),handleShareEmail:L(o),handlePreviewEmail:L(s),handleLivePreviewEmail:L(I)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new Re(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Qf=O("DataController"),Zf=O("DataEvents");function Co(e){return e.getOrCreateInstance(Qf,()=>{const t=new Of(e);return e.getInstance(k)?.addDisposable(t),t})}function Ro(e){return e.getOrCreateInstance(Zf,()=>new Jf(e))}var ep=O("plugin.startupShow");function tp(e){const t=Co(e),n=Ro(e),r=e.getInstance(oe),i=e.getInstance(k),o={current:Promise.resolve()};e.inject(ep,o);const s=r?.watch(l=>{l&&n.setOptions(l)}),d=r?.select(l=>l?.content).watch(l=>{l!==void 0&&(G(J.showStart),o.current=(async()=>{try{await t.show(l)}catch{}finally{G(J.showEnd)}})())});s&&i?.addDisposable(s),d&&i?.addDisposable(d)}function np(e){const t=Co(e);return{...Ro(e).get(),show(n){return G(J.showStart),t.show(n).finally(()=>G(J.showEnd))},save(){return t.save()}}}var rp=[{name:"rest.client",setup:af},{name:"auth.oauth",setup:Es},{name:"rest.identityHeaders",setup:tf},{name:"lifetime.destroyable",provides:[Ln],setup:iu},{name:"appInit",provides:[Pe,Sn],setup:oa},{name:"config",provides:[we],setup:nu},{name:"email.documents",setup:wu},{name:"show.initPipeline",provides:[De],setup:lf},{name:"show",setup:tp},{name:"locale.service",provides:[$e],setup:Ju},{name:"locale.fromConfig",awaits:{services:[we,$e]},setup:Qu},{name:"canvas.early",setup:nc},{name:"canvas.previewSettings",setup:cc},{name:"canvas.sandboxExtensions",setup:fc},{name:"canvas.headerSync",provides:[oo],setup:oc},{name:"canvas.ampSync",setup:Ll},{name:"canvas.moduleBridge",setup:id},{name:"canvas.port",setup:Gl},{name:"canvas.images",setup:Ul},{name:"canvas.edits",setup:Fd},{name:"canvas.blockContent",setup:Od},{name:"canvas.sandboxFill",provides:[On],setup:Pc},{name:"canvas.reactions",setup:Zd}],ip=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function op(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function sp(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function Po(e){const t=op(e),n=[],r=new Set,i=[],o=new Set,s=d=>{if(!r.has(d)){if(o.has(d)){const l=i.indexOf(d);throw new ip([...i.slice(l),d].map(f=>f.name))}o.add(d),i.push(d);for(const l of sp(d,t))s(l);i.pop(),o.delete(d),r.add(d),n.push(d)}};for(const d of e)s(d);return n}var Mr;function Fn(e){const t=e.getInstance(oe);if(t)return t;e.getInstance(k)||e.inject(k,new Q);const n=Me();e.inject(oe,n),Mr??=Po(rp);for(const r of Mr)r.setup(e);return n}function ap(e){}var lp=[{name:"save.previewFollow",setup:ap}],kr=O("plugin.lateUnitsInstalled");function dp(e){if(!e.getInstance(kr)){e.inject(kr,!0);for(const t of Po(lp))t.setup(e)}}function cp(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function up(e){if(!e)return;const t=oi(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 fp=Le(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!pt(t,i.user),d=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(he)||!i.getAuthToken)&&!(!o&&!s&&!d))try{const l=await i.getAuthToken(i.user,i.project);e.inject(gs,Promise.resolve(l||""));const f=up(l);if(!f)return;e.inject(Ds,f);const u=e.getInstance(Pe),g=u?await u.catch(()=>{}):void 0;e.inject(Pe,Promise.resolve(cp(f,g)))}catch{}}}});function pp(e,t){if(e.getInstance($n))return;e.inject($n,!0);const n=En(e,F.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function hp(e){e.getInstance(Rs)||e.inject(he,void 0)}function St(e){return String(e.standaloneKey||"").trim()||void 0}function mp(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function jn(e){return mp(e)?!!St(e):!1}function It(e){return!!St(e)&&!jn(e)}var gp=Le(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!It(r)){t&&(hp(e),jn(r)),t=void 0;return}const o=St(r);if(!o||t===o&&e.getInstance(he))return;t=o,e.inject(he,o);const s=e.getInstance(k);s&&pp(e,s)}}}),vp=Le(e=>{const t=e.getInstance(k),n=En(e,ri),r=L(n),i=t.addDisposable(new Re(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),bp=Le(e=>{const t=e.getInstance(k),n=t.addDisposable(new pe),r=t.addDisposable(new pe),i=si(e,Vo),o=L(n.event),s=L(r.event),d=L(i.event),l=t.addDisposable(new Re(o)),f=t.addDisposable(new Re(s)),u=t.addDisposable(new Re(d));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:d},async setOptions(g){l.setListener(g.handleSetOptions),f.setListener(g.handleOptionsChanged),u.setListener(g.handleConfigChanged),await n.fire(g),await r.fire(g)},dispose(){}}}),Ft,Do="core";function Ep(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Do],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function yp(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Je().then(()=>{}):t([Do],e)}function Je(){return Ft===void 0&&(Ft=Ep().then(e=>(qe()&&e.installDiagnostics().catch(t=>{}),e))),Ft}var jt=null,Bt=null;async function _p(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Bn(){return jt||(jt=Je().then(()=>{})),jt}function Oo(e){return Bt||(Bt=_p(e)),Bt}function wp(){return Oo(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Sp(e){return Promise.all([Bn(),Oo(e)]).then(()=>{})}function Ip(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Nr(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>yp(t?{priority:t}:void 0)).then(()=>n?Bn():void 0).catch(()=>{})}function Tp(e){const t=Ip(e);if(t==="eager")Nr(e);else if(t==="idle"){const n=()=>Nr(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var xo="PluginRegistry";function Ap(e=Wo()){return e.getOrCreateInstance(xo,()=>new Us)}var Cp=new Hs(()=>Ap()),Rp=Le(e=>{let t;function n(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(r){const i=e.getInstance(Et),o=e.getInstance(xo);t||(t=new Bs(i,o,{ensureHostRuntimeReady:wp}),e.inject(Xt,t));const s=r?.plugins||[];i&&await t.setPlugins(s)},instance:{use(r){return typeof r=="function"?n().useByCtor(r):n().useByKey(r)},useAsync(r){return n().useAsync(r)},waitPlugin(r){return n().waitFor(r)}},dispose(){t?.dispose(),t=void 0}}}),Lo=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},Pp=O("ELEMENT_INSERT_HTML_PIPELINE"),Dp=O("BLOCK_INSERT_HTML_PIPELINE"),Op="application_block_inserted",xp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Dp,()=>new Lo).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(We,()=>new Ye),i=n?e.bind(n):e;return r.addListener(Op,i,t)}},Lp=O("ComponentRegistry"),Fr;function ze(e,t=Lp){const n=ft.getInstance(t);if(n)return n;if(!Fr)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return ft.getOrCreateInstance(t,Fr)}var Mp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(Ze,{execute:n=>{t.dispose(),e(n.value.map(r=>({name:r.name,html:r.html})))}})})}update(e,t){const n=this._container,r=ze(n);return n.addService(Ze,{execute:i=>{const o=i.value.find(s=>s.name===e);if(o){const{icon:s,title:d,fallbackTooltip:l,...f}=t;s&&(o.icon=r.getReactNode(s)),d&&(o.title=r.getReactNode(d)),l&&(o.fallbackTooltip=r.getReactNode(l)),Object.assign(o,f)}}})}delete(e){this._container.addService(Ze,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container,r=ze(n);return n.addService(Ze,{execute:i=>{i.value.splice(t??i.value.length,0,{...e,title:r.getReactNode(e.title),icon:r.getReactNode(e.icon),fallbackTooltip:r.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Pp,()=>new Lo).add(e,t??0,n)}handleInject(e,t,n){return Ce(this._container,os).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},kp=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(We,()=>new Ye)}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 Np(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var Fp=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ce(t,rs),this._closeModalEmitter=Ce(t,es),this._updateModalEmitter=Ce(t,ss)}get _container(){return this._context.container}show(e){const t=ze(this._container),n=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r=e.modalProps;return this._showModalEmitter.fire({...e,content:t.getReactNode(e.content),title:t.getReactNode(e.title),id:n,modalProps:r?{...r,footer:t.getReactNode(r.footer),okText:t.getReactNode(r.okText),cancelText:t.getReactNode(r.cancelText),closeIcon:t.getReactNode(r.closeIcon)}:void 0}),n}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=ze(this._container),r=t.modalProps;this._updateModalEmitter.fire(Np({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},jp=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),n())},s=d=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),r(d))};this._resolveLoaded=o,this._rejectLoaded=s}),this.ready=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),n())},s=d=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),r(d))};this._resolveReady=o,this._rejectReady=s})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},Bp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(We,()=>new Ye)}_createScriptHandle(e,t){const n=this._messageService.addListener(Yo,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new jp(t,n);return r}registerSandboxCSS(e){return this._container.addService(Te,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Te,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},Up=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function gn(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Up.has(t)}function Mo(){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 Ut(){return`__settingsPanel:${Mo()}`}function Ht(e,t){return{type:e,props:t}}function Hp(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!gn(e)}function jr(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(gn(t)){const r=Ut();return n(e.add(r,t)),Ht(r,{})}if(typeof t=="function"){const r=Ut();return n(e.add(r,t)),Ht(r,{})}if(Hp(t)){const r=t.type;if(typeof r=="string")return t;if(gn(r)||typeof r=="function"){const i=Ut();return n(e.add(i,r)),Ht(i,t.props)}return t}return t}var Gp=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=ze(this._container),n=s=>this._trackRegistration(s),r=jr(t,e.content,n),i=e.advancedTabs?.map(s=>({...s,content:jr(t,s.content,n)})),o=e.instanceKey??Mo();Ce(this._container,Gn).fire({...e,content:r,advancedTabs:i,instanceKey:o,type:is})}closeSettingsPanel(){this._clearPanelRegistrations(),Ce(this._container,Gn).fire(null)}},ko={SandboxScriptApi:Bp,ElementsApi:Mp,BlocksApi:xp,MessageService:kp,SettingsPanelApi:Gp,ModalApi:Fp};function Gt(e,t,n,r={}){const i=Object.assign({},e);for(const[o,s]of Object.entries(t))if(s!==void 0)if(n.includes(o)&&typeof s=="object"&&s!==null){const d=i[o],l=r[o]??{};i[o]=Object.assign({},typeof d=="object"&&d!==null?d:l,s)}else i[o]=s;return i}var ee={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}},qp={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"},qt={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},Br={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Ie={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:ee.border,borderRadius:ee.borderRadius,textAlign:"center",padding:ee.padding},Ur={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:ee.padding},$t={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:ee.border,borderRadius:ee.borderRadiusCards};function $p(e){return{...qp,...e}}function zp(e){return{...qt,...e,bold:e?.bold??qt.bold,italic:e?.italic??qt.italic}}function Vp(e){return{...Br,...e,underline:e?.underline??Br.underline}}function Kp(e){return{...Ie,...e,bold:e?.bold??Ie.bold,italic:e?.italic??Ie.italic,border:{...Ie.border,...e?.border},borderRadius:{...Ie.borderRadius,...e?.borderRadius},padding:{...Ie.padding,...e?.padding}}}function Wp(e){return{...Ur,...e,padding:{...Ur.padding,...e?.padding}}}function Yp(e){return{...$t,...e,border:{...$t.border,...e?.border},borderRadius:{...$t.borderRadius,...e?.borderRadius}}}function zt(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 Hr(e){let t={...bn};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Vt(e){return{text:$p(e.text),headings:zp(e.headings),links:Vp(e.links),buttons:Kp(e.buttons),block:Wp(e.block),cards:Yp(e.cards)}}var Gr=O("EmailSettingsPort"),Xp=1e4,No=class{_editor;_layoutSettingsChanged=new Jt;_contentStylesChanged=new Jt;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(Gr);if(!t)throw new Error("[extensions] настройки письма ещё не загружены — работа с UI начинается с init()");return t}_getCurrentLayoutSettings(){return zt(this._settings().read())}_getCurrentContentStyles(){const e=Ct(this._editor.container)?.current()?.get().attributes.common_styles;return Vt(Hr(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(Gr),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(We,()=>new Ye),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const i=r?.data,o=i?.operation;if(o===M.APPLICATION_EMAIL_SETTINGS_SET){const l=zt(i?.settings),f=this._getLayoutSnapshot(l);f!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=f,this._layoutSettingsChanged.fire(l));return}if(o!==M.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Vt(r.data?.settings?.commonStyles??{...bn}),d=this._getContentSnapshot(s);d!==this._prevContentSnapshot&&(this._prevContentSnapshot=d,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=zt(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Xp){const t=Ct(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,i=En(r,F.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,d;const l=()=>{d&&(clearTimeout(d),d=void 0)},f=i(()=>{s||(s=!0,l(),f.dispose(),o())});d=setTimeout(()=>{s||(s=!0,f.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Ct(this._editor.container)?.current();if(!t)return;const n=Hr(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=Gt(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:ee.border,borderRadius:ee.borderRadius,padding:ee.padding})),e.block!==void 0&&(n.block=Gt(n.block||{},e.block,["padding"],{padding:ee.padding})),e.cards!==void 0&&(n.cards=Gt(n.cards||{},e.cards,["border","borderRadius"],{border:ee.border,borderRadius:ee.borderRadiusCards}));const r=JSON.stringify(n);mt(t,{common_styles:r}),this._settings().markAppearanceChanged();const i=Vt(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},Jp={...ko,EmailSettingsApi:No},Qp={...ko},pm={...Qp,EmailSettingsApi:No},Zp={...Jp};function eh(){Cp.addAll(Zp)}var th=[Le(()=>{eh()}),vp,bp,gp,ys,fp,As];async function nh(){return(await Je()).asyncMixins}var rh=Rp,ih=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await nh()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(Et);Object.assign(o,t.instance||{})}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},oh=ps([...th]);function Kt(){let e,t=!1;const n=new Map,r=new Map;function i(){for(const o of r.values())o();r.clear()}return{event(o,s,d){const l=Symbol("subscription");return t||(n.set(l,{listener:o,priority:s,thisArg:d}),e&&r.set(l,e(o,s,d))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(o){i(),e=o;for(const[s,{listener:d,priority:l,thisArg:f}]of n)r.set(s,o(d,l,f))},dispose(){t=!0,i(),n.clear(),e=void 0}}}var qr=O("NotificationService");function sh(e){const t=Kt(),n=Kt(),r=Kt();return e.getInstance(k)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(qr).then(i=>{t.attach(i.onNotify),n.attach(i.onError),r.attach(i.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(i){const o=e.getInstance(qr);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(i)}}}var ah=[ou,np,sh];function lh(e,t=ah){const n=Fn(e);dp(e);const r=oh(e),i=rh(e),o=ih(e),s={...r.instance,...i.instance,...o.instance};for(const l of t)Object.assign(s,l(e));let d=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const f=d&&n.get()===l;d=!1,f||n.set(l),await i.setOptions(l),await o.setOptions(l)}}}var dh=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]}},ch="editor-runtime.react.copies",Wt=8;function Ve(e){return e&&typeof e=="object"?e:void 0}function $r(e){const t=Ve(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Ve(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function uh(e){const t=Ve(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Ve(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function fh(e,t,n){return e.package===t&&e.version===n}function ph({ourReact:e,entries:t,packageName:n,version:r}){const i=$r(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const d of t){const l=Ve(d);if(!l||!fh(l,n,r))continue;const f=$r(l.react);!f||f===i||s.has(f)||(s.add(f),o.push({package:n,version:r,reactVersion:uh(l.react),react:l.react}))}return o}function hh({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,Wt))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Wt&&n.push(` …and ${t.length-Wt} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
1047
- `)}var zr=new Set;function mh({packageName:e="useblocks",version:t="1.1.85-dev.3",log:n=r=>{}}={}){const r=i=>{try{const o=globalThis[Symbol.for(ch)],s=ph({ourReact:i,entries:o,packageName:e,version:t}).filter(d=>!zr.has(d.react));if(!s.length)return;s.forEach(d=>zr.add(d.react)),n(hh({packageName:e,copies:s}))}catch{}};try{const i=wn()?.modules?.React;if(i&&typeof i.then=="function"){i.then(r,()=>{});return}r(i)}catch{}}async function gh(e,t){$(e.signal);const n=t??ft.createChild();Fn(n);const r=n.getInstance(k);async function i(){n.inject(Ko,new dh),mh();const o=lh(n),s={...o.instance,container:n,async reset(d){if($(d.signal),r.isDisposed())throw di();return await o.setOptions(d),s}};n.inject(Et,s);try{if(await o.setOptions(e),$(e.signal),r.isDisposed()||await n.getInstance(Xt)?.activate(),e.devTools)try{const d=n.getInstance(Xt);d&&await(await Je()).initDevTools(n,d)}catch{}return $(e.signal),si(n,ri).fire(s),s}catch(d){throw r.dispose(),d}}try{return await _n(i(),e.signal)}catch(o){throw r.isDisposed()||r.dispose(),o}}var Ke=new WeakMap;function vh(e){return e?Ke.get(e):void 0}function Fo(e){try{e.getInstance(k)?.dispose()}catch{}try{e.dispose()}catch{}}function bh(e,t){if(!e)return;const n=Ke.get(e);n&&n!==t&&Fo(n),Ke.set(e,t)}function Eh(e,t){e&&Ke.get(e)===t&&Ke.delete(e)}function yh(e){const t=ft.createChild();return It(e)&&t.inject(he,St(e)),t}var Ge=new WeakMap,_h="data-useblocks-config-styles";function wh(e){return typeof e=="string"?e.trim():""}function Vr(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Sh(e,t,n){if(!e||typeof document>"u")return null;const r=wh(t),i=Ge.get(e),o=n||e;if(!r)return i&&(i.remove(),Ge.delete(e)),null;if(i)return i.textContent!==r&&(i.textContent=r),(i.parentNode!==o||i!==o.firstChild)&&Vr(o,i),i;const s=document.createElement("style");return s.setAttribute(_h,"true"),s.textContent=r,Vr(o,s),Ge.set(e,s),s}function Ih(e){if(!e)return;const t=Ge.get(e);t&&(t.remove(),Ge.delete(e))}function jo(){return!1}var Th=`
1046
+ `)}function Pr(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Sf(e,t,n,r){const i=If(e,t,n,r);return i===void 0}function If(e,t,n,r){const{email:i}=Fn(t,!1),o=xe(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const d=Rn(e)?.current();if(!d)return"no-session";const l=d.get(),f=l.attributes;if(l.serverId!==s)return"document-id";if(f.is_inited!==!0)return"not-inited";const u=Pr(pn(n??d.getContent()));if(o.html!==void 0&&Pr(pn(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==f.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==f.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==f.common_styles)return"common_styles"}function Dr(e,t){const{email:n}=Fn(t,!1),r=xe(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:pn(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Tf(e,t){const n={...e};return delete n.id,{...n,...t}}function Af(e){return e.html?e:{...e,html:So}}function Be({code:e,project:t,...n},r,i){const o=i??Io(r);return{...n,...e?{html:ke(r).toEditorForm(e)}:{},renderGuid:le(),...o===void 0?{}:{project:o}}}function st({html:e,renderGuid:t,...n},r){const{requested:i}=_t(r);return ge({...n,code:ke(r).toOutputForm(e),project:i===void 0?n.project:i,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function Co(e){return Rn(e)?.current()?.get().serverId??void 0}function hn(e,t,n){return n===void 0&&(n=e.post===void 0?Co(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function at(e,t){return ge({...e,link:void 0,comment_status:void 0})}function mn({code:e,...t},n,r){return r===void 0&&(r=t.parent===void 0?Co(n):t.parent),{...t,...e?{html:e}:{},parent:r}}function Or({html:e,...t},n){return ge({...t,code:e,guid:void 0,compiled:ge({html:e,ampHtml:e&&""})})}var Cf=O("emailTemplate.reads");async function Rf(e,t){try{return await Se(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message;return}}function Pf(e,t){const n=e.getOrCreateInstance(Cf,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=Rf(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var Df="EXTERNAL";function Of(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"сохранение не состоялось")}var xf="email_id",Lf=class extends Q{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_dataSources;_eventLock;_queue=Ps();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=wt(t),this._eventLock=_f(t);const n=V(e,F.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(_n,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(xf,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(De)??On}_throwIfDestroyed(){if(this.isDisposed())throw ui()}async getTemplateEmail(e){const t=await Pf(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await kt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Be(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,mn(i,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,hn(i,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,i){const o=this._dataSources.emails,s=o.cache,d=await kt(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let f=xe(e,this._container);const u=f.id;let g=u;if(u!==void 0){const b=await o.get(u);f={...b??{},...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d}}else{g=n??le();const b=await o.get(g);f={...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d},delete f.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(f=Tf(b,f))}return u===void 0&&(f=Af(f)),await s.addOrUpdate(g,()=>f),f}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Dr(this._container,e))return!1;const n=ut(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Dr(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:ut(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&t!==this._showRequests){this._showRequests;return}if(!e)return;const n=this._getInitPipeline();if($(n.signal),Sf(this._container,e,ut(this._container),this._prevCommand?.id)||this._isRepeatOfLastShow(e))return;const r=Fn(e);r.email.id,this._prevCommand?.id;let i,o="",s=0,d=!1,l,f=Promise.resolve(),u,g=!1;try{this._eventLock.suspendChange();const{email:b,blocks:E,autosaves:I,comments:v,templateId:y,reload:w}=r;i=b.id;const S=xe(b,this._container),A=S.id,h=A??le(),c=await Ue("getProject",kt(this._container));$(n.signal),o=le();const a={isNew:A===void 0,id:String(h),project:c},p=w===!0&&A!==void 0;p&&(await this._dataSources.emails.remove(String(A),{silent:!0}),String(A)),s=++this._showToken,String(h);const m=[];m.push(this.setBlocks(E)),b.id!==void 0&&(m.push(this.setComments(v)),m.push(this.setEmailRevisions(I,String(b.id)))),m.push(this.setEmail(b,Number(y),A===void 0?String(h):void 0,s,o)),await Ue("setEmail+blocks+revisions",Promise.all(m),{emailId:A??String(h),showId:o,targetShowToken:s}),$(n.signal);const _=await this._dataSources.emails.get(String(h)),T=ve(this._container),P={id:o,token:s};A===void 0?u=T.startNewDraft(_??S,{patch:S,show:P}):p?u=T.reload(A,{email:_??S,patch:S,show:P}):T.sessionKey()===Fe(A)?u=T.show(S,P):u=T.open(A,{email:_??S,patch:S,show:P});const N=!!this._prevCommand&&pt(this._prevCommand,a);a.id,!this._prevCommand||pt(this._prevCommand,a),this._prevCommand?.id,this._rememberShow(a),f=n.requestShow({showId:o,navId:String(h),emailId:A,isNew:A===void 0}),g=!0,String(h),d=!0}catch(b){l=b,g&&o&&n.failShow(o,b),String(b)}finally{this._eventLock.resumeChange()}if(!d)throw l instanceof Error?l:new Error(`[useblocks] show() setup failed: ${String(l??"unknown error")}`);return Ue("show-init-deferred",Promise.all([f,u?.whenReady().catch(b=>{if(b instanceof ht){const E=Mi(b);throw E?new Error(`[useblocks] show(): email open failed (${E})`,{cause:b}):b}})??Promise.resolve()]).then(()=>{}),{showId:o,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();$(e.signal);const t=ve(this._container),n=await t.save("publish",{source:Df});if($(e.signal),!n)throw Of(t.saveState().error);return Z(wf(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function Mf(e){return String(e).replace(/"/g,"&quot;")}function kf(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 Nf(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 xr(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=Mf(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function Ff(e,t,n){if(!e?.trim()||!t)return e;const r=Nf(e);if(!r)return e;const i=String(t),o=kf(n??new Date);let{full:s,index:d}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=xr(s,"em-block-id",i)),s=xr(s,"em-block-version",o),e.slice(0,d)+s+e.slice(d+l)}function jf(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function Bf(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:jf(e)}}function Nt(e,t){return t?Bf(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Ro=["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"],Uf=[...Ro,"html","id","project","password"],hm=new Set(["html",...Ro,"global_block","project"]);function Hf(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(Uf),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Gf(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Hf(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 gn=new WeakMap;function qf(e){let t=gn.get(e);return t||(t={byId:new Map,fallback:[]},gn.set(e,t)),t}function $f(e){gn.delete(e)}function zf(e,t){const{byId:n,fallback:r}=qf(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,d=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&d)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function Vf(e,t){const{blocks:n}=wt(e);return await n.cache.getIfPresent(t)??void 0}async function Kf(e,t){if(!t.blockId)return;const n=await Vf(e,t.blockId);if(n)return Gf(n,t)}async function Wf(e,t){const n=zf(e,t);if(n)return Nt(e,n);const r=await Kf(t,e);return r?Nt(e,r):Nt(e,void 0)}var Yf=fs("application_block_inserted"),Xf=-1e3,Lr=new WeakSet;function Jf(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 Qf(e){if(!e||Lr.has(e))return;Lr.add(e);const t=new Q,n=Y(e);return t.addDisposable(n.addListenerAsyncPipe(Yf,async(r,i)=>{const o=Jf(r)?await Wf(r,e):r;return i?i(o):o},Xf)),t.addDisposable({dispose:()=>{$f(e)}}),t}var Mr=100,Zf=class extends Q{_container;_events;constructor(e){super(),this._container=e;const t=Qf(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=wt(e),o=V(e,F.ON_SHARE_ID),s=V(e,F.ON_SHOW_PREVIEW_ID),d=V(e,F.ON_EMAIL_CLONE_ID),l=V(e,F.ON_CODE_VALIDATE_ID),f=V(e,F.ON_SUBJECT_CHANGED_ID),u=V(e,F.ON_EMAIL_CHANGED_ID),g=V(e,F.ON_PREHEADER_CHANGED_ID),b=V(e,F.ON_SAVEBUTTON_CLICK_ID),E=V(e,F.ON_NEXTBUTTON_CLICK_ID),I=V(e,F.ON_SEND_LIVEPREVIEW_ID),v=V(e,F.ON_SEND_TESTEMAIL_ID),y=V(e,mf),w=V(e,F.ON_CONTENT_CHANGED_ID),S=V(e,hf),A=V(e,F.ON_PREVIOUSBUTTON_CLICK_ID),h=V(e,F.ON_SEND_EMAIL_MODAL_ID),c=Ms(V(e,F.ON_EMAIL_INIT_ID),a=>!a.reset);return{handlePreheaderChanged:L(g),handleSubjectChanged:L(f),handleValidate:L(l),handleReadEmail:L(n.handlerRead,a=>a,a=>a&&xe(a,e)),handleSaveEmail:L(n.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?Z(a,e):void 0;return{prev:T,patch:He(T,Z(p,e)),value:Z(m,e),source:_}},a=>a?xe(a,e):void 0),handleRemoveEmail:L(n.onRemove,({value:a,source:p})=>({value:Z(a,e),source:p}),()=>{}),handleReadCommonBlocks:L(y,a=>a.project,a=>a?.map(p=>Be(p,e))),handleReadTemplateBlocks:L(S,a=>a,a=>a?.map(p=>Be(p,e))),handleReadBlocks:L(t.byForeignKey("project").handleRead,a=>_t(e).requested||String(a),a=>a?.map(p=>Be(p,e))),handleSaveBlock:L(t.onSave,function({prev:a,patch:p,value:m,source:_}){const T=m.global_block===!0&&m.id&&typeof m.html=="string"?{...m,html:Ff(m.html,String(m.id))}:m,P=a?st(a,e):void 0;return{prev:P,patch:He(P,st(p,e)),value:st(T,e),source:_}},a=>a?Be(a,e):void 0),handleRemoveBlock:L(t.onRemove,({value:a,source:p})=>({value:st(a,e),source:p}),()=>{}),handleReadComments:L(r.byForeignKey("post").handleRead,a=>a,a=>a?.map(p=>hn(p,e))),handleSaveComment:L(r.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?at(a,e):void 0;return{prev:T,patch:He(T,at(p,e)),value:at(m,e),source:_}},a=>a?hn(a,e):void 0),handleRemoveComment:L(r.onRemove,({value:a,source:p})=>({value:at(a,e),source:p}),()=>{}),handleReadEmailRevisions:L(i.byForeignKey("parent").handleRead,a=>a,a=>a?.map(p=>mn(p,e))),handleEmailAutosave:L(i.onSave,function({prev:a,patch:p,value:m,source:_}){return{value:Or(m,e),source:_}},a=>a?mn(a,e):void 0),handleRemoveEmailAutoSave:L(i.onRemove,({value:a,source:p})=>({value:Or(a,e),source:p}),()=>{}),handleEmailChanged:L($n(u,Mr),a=>Z(a,e)),handleEmailInit:L(c,a=>Z(a,e)),handlePreviousButtonClick:L(A,a=>Z(a,e)),handleNextButtonClick:L(E,a=>Z(a,e)),handleSaveButtonClick:L(b,a=>Z(a,e)),handleHtmlChanged:L($n(w,Mr)),handleTestEmailSend:L(v,({html:a,...p})=>({...p,code:a,compiled:{html:a,ampHtml:""}})),handleTestEmailModal:L(h,a=>Z(a,e)),handleCloneEmail:L(d,a=>Z(a,e)),handleShareEmail:L(o),handlePreviewEmail:L(s),handleLivePreviewEmail:L(I)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new Re(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},ep=O("DataController"),tp=O("DataEvents");function Po(e){return e.getOrCreateInstance(ep,()=>{const t=new Lf(e);return e.getInstance(k)?.addDisposable(t),t})}function Do(e){return e.getOrCreateInstance(tp,()=>new Zf(e))}var np=O("plugin.startupShow");function rp(e){const t=Po(e),n=Do(e),r=e.getInstance(oe),i=e.getInstance(k),o={current:Promise.resolve()};e.inject(np,o);const s=r?.watch(l=>{l&&n.setOptions(l)}),d=r?.select(l=>l?.content).watch(l=>{l!==void 0&&(G(J.showStart),o.current=(async()=>{try{await t.show(l)}catch{}finally{G(J.showEnd)}})())});s&&i?.addDisposable(s),d&&i?.addDisposable(d)}function ip(e){const t=Po(e);return{...Do(e).get(),show(n){return G(J.showStart),t.show(n).finally(()=>G(J.showEnd))},save(){return t.save()}}}var op=[{name:"rest.client",setup:df},{name:"auth.oauth",setup:_s},{name:"rest.identityHeaders",setup:rf},{name:"lifetime.destroyable",provides:[Mn],setup:su},{name:"appInit",provides:[Pe,In],setup:aa},{name:"config",provides:[we],setup:iu},{name:"email.documents",setup:Iu},{name:"show.initPipeline",provides:[De],setup:cf},{name:"show",setup:rp},{name:"locale.service",provides:[$e],setup:Zu},{name:"locale.fromConfig",awaits:{services:[we,$e]},setup:ef},{name:"canvas.early",setup:ic},{name:"canvas.previewSettings",setup:fc},{name:"canvas.sandboxExtensions",setup:hc},{name:"canvas.headerSync",provides:[ao],setup:ac},{name:"canvas.ampSync",setup:kl},{name:"canvas.moduleBridge",setup:sd},{name:"canvas.port",setup:$l},{name:"canvas.images",setup:Gl},{name:"canvas.edits",setup:Bd},{name:"canvas.blockContent",setup:Ld},{name:"canvas.sandboxFill",provides:[xn],setup:Oc},{name:"canvas.reactions",setup:tc}],sp=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function ap(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function lp(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function Oo(e){const t=ap(e),n=[],r=new Set,i=[],o=new Set,s=d=>{if(!r.has(d)){if(o.has(d)){const l=i.indexOf(d);throw new sp([...i.slice(l),d].map(f=>f.name))}o.add(d),i.push(d);for(const l of lp(d,t))s(l);i.pop(),o.delete(d),r.add(d),n.push(d)}};for(const d of e)s(d);return n}var kr;function jn(e){const t=e.getInstance(oe);if(t)return t;e.getInstance(k)||e.inject(k,new Q);const n=Me();e.inject(oe,n),kr??=Oo(op);for(const r of kr)r.setup(e);return n}function dp(e){}var cp=[{name:"save.previewFollow",setup:dp}],Nr=O("plugin.lateUnitsInstalled");function up(e){if(!e.getInstance(Nr)){e.inject(Nr,!0);for(const t of Oo(cp))t.setup(e)}}function fp(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function pp(e){if(!e)return;const t=ai(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 hp=Le(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!pt(t,i.user),d=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(he)||!i.getAuthToken)&&!(!o&&!s&&!d))try{const l=await i.getAuthToken(i.user,i.project);e.inject(bs,Promise.resolve(l||""));const f=pp(l);if(!f)return;e.inject(xs,f);const u=e.getInstance(Pe),g=u?await u.catch(()=>{}):void 0;e.inject(Pe,Promise.resolve(fp(f,g)))}catch{}}}});function mp(e,t){if(e.getInstance(zn))return;e.inject(zn,!0);const n=yn(e,F.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function gp(e){e.getInstance(Ds)||e.inject(he,void 0)}function St(e){return String(e.standaloneKey||"").trim()||void 0}function vp(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function Bn(e){return vp(e)?!!St(e):!1}function It(e){return!!St(e)&&!Bn(e)}var bp=Le(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!It(r)){t&&(gp(e),Bn(r)),t=void 0;return}const o=St(r);if(!o||t===o&&e.getInstance(he))return;t=o,e.inject(he,o);const s=e.getInstance(k);s&&mp(e,s)}}}),Ep=Le(e=>{const t=e.getInstance(k),n=yn(e,oi),r=L(n),i=t.addDisposable(new Re(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),yp=Le(e=>{const t=e.getInstance(k),n=t.addDisposable(new pe),r=t.addDisposable(new pe),i=li(e,Wo),o=L(n.event),s=L(r.event),d=L(i.event),l=t.addDisposable(new Re(o)),f=t.addDisposable(new Re(s)),u=t.addDisposable(new Re(d));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:d},async setOptions(g){l.setListener(g.handleSetOptions),f.setListener(g.handleOptionsChanged),u.setListener(g.handleConfigChanged),await n.fire(g),await r.fire(g)},dispose(){}}}),Ft,xo="core";function _p(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([xo],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function wp(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Je().then(()=>{}):t([xo],e)}function Je(){return Ft===void 0&&(Ft=_p().then(e=>(qe()&&e.installDiagnostics().catch(t=>{}),e))),Ft}var jt=null,Bt=null;async function Sp(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Un(){return jt||(jt=Je().then(()=>{})),jt}function Lo(e){return Bt||(Bt=Sp(e)),Bt}function Ip(){return Lo(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Tp(e){return Promise.all([Un(),Lo(e)]).then(()=>{})}function Ap(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Fr(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>wp(t?{priority:t}:void 0)).then(()=>n?Un():void 0).catch(()=>{})}function Cp(e){const t=Ap(e);if(t==="eager")Fr(e);else if(t==="idle"){const n=()=>Fr(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Mo="PluginRegistry";function Rp(e=Xo()){return e.getOrCreateInstance(Mo,()=>new Gs)}var Pp=new qs(()=>Rp()),Dp=Le(e=>{let t;function n(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(r){const i=e.getInstance(Et),o=e.getInstance(Mo);t||(t=new Hs(i,o,{ensureHostRuntimeReady:Ip}),e.inject(Jt,t));const s=r?.plugins||[];i&&await t.setPlugins(s)},instance:{use(r){return typeof r=="function"?n().useByCtor(r):n().useByKey(r)},useAsync(r){return n().useAsync(r)},waitPlugin(r){return n().waitFor(r)}},dispose(){t?.dispose(),t=void 0}}}),ko=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},Op=O("ELEMENT_INSERT_HTML_PIPELINE"),xp=O("BLOCK_INSERT_HTML_PIPELINE"),Lp="application_block_inserted",Mp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(xp,()=>new ko).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(We,()=>new Ye),i=n?e.bind(n):e;return r.addListener(Lp,i,t)}},kp=O("ComponentRegistry"),jr;function ze(e,t=kp){const n=ft.getInstance(t);if(n)return n;if(!jr)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return ft.getOrCreateInstance(t,jr)}var Np=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(Ze,{execute:n=>{t.dispose(),e(n.value.map(r=>({name:r.name,html:r.html})))}})})}update(e,t){const n=this._container,r=ze(n);return n.addService(Ze,{execute:i=>{const o=i.value.find(s=>s.name===e);if(o){const{icon:s,title:d,fallbackTooltip:l,...f}=t;s&&(o.icon=r.getReactNode(s)),d&&(o.title=r.getReactNode(d)),l&&(o.fallbackTooltip=r.getReactNode(l)),Object.assign(o,f)}}})}delete(e){this._container.addService(Ze,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container,r=ze(n);return n.addService(Ze,{execute:i=>{i.value.splice(t??i.value.length,0,{...e,title:r.getReactNode(e.title),icon:r.getReactNode(e.icon),fallbackTooltip:r.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Op,()=>new ko).add(e,t??0,n)}handleInject(e,t,n){return Ce(this._container,as).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Fp=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(We,()=>new Ye)}send(e,t,n){this._messageService.send(e,t,n)}sendAsync(e,t,n=!0){return this._messageService.sendAsync(e,t,n)}addListener(e,t,n){return this._messageService.addListener(e,t,n)}addListenerAsync(e,t,n=0){return this._messageService.addListenerAsync(e,t,n)}onInit(e,t=!0,n=0){return this._messageService.onInit(e,t,n)}isInited(){return this._messageService.isInited()}};function jp(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var Bp=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ce(t,os),this._closeModalEmitter=Ce(t,ns),this._updateModalEmitter=Ce(t,ls)}get _container(){return this._context.container}show(e){const t=ze(this._container),n=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r=e.modalProps;return this._showModalEmitter.fire({...e,content:t.getReactNode(e.content),title:t.getReactNode(e.title),id:n,modalProps:r?{...r,footer:t.getReactNode(r.footer),okText:t.getReactNode(r.okText),cancelText:t.getReactNode(r.cancelText),closeIcon:t.getReactNode(r.closeIcon)}:void 0}),n}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=ze(this._container),r=t.modalProps;this._updateModalEmitter.fire(jp({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},Up=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),n())},s=d=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),r(d))};this._resolveLoaded=o,this._rejectLoaded=s}),this.ready=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),n())},s=d=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),r(d))};this._resolveReady=o,this._rejectReady=s})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},Hp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(We,()=>new Ye)}_createScriptHandle(e,t){const n=this._messageService.addListener(Jo,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new Up(t,n);return r}registerSandboxCSS(e){return this._container.addService(Te,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Te,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},Gp=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function vn(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Gp.has(t)}function No(){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 Ut(){return`__settingsPanel:${No()}`}function Ht(e,t){return{type:e,props:t}}function qp(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!vn(e)}function Br(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(vn(t)){const r=Ut();return n(e.add(r,t)),Ht(r,{})}if(typeof t=="function"){const r=Ut();return n(e.add(r,t)),Ht(r,{})}if(qp(t)){const r=t.type;if(typeof r=="string")return t;if(vn(r)||typeof r=="function"){const i=Ut();return n(e.add(i,r)),Ht(i,t.props)}return t}return t}var $p=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=ze(this._container),n=s=>this._trackRegistration(s),r=Br(t,e.content,n),i=e.advancedTabs?.map(s=>({...s,content:Br(t,s.content,n)})),o=e.instanceKey??No();Ce(this._container,qn).fire({...e,content:r,advancedTabs:i,instanceKey:o,type:ss})}closeSettingsPanel(){this._clearPanelRegistrations(),Ce(this._container,qn).fire(null)}},Fo={SandboxScriptApi:Hp,ElementsApi:Np,BlocksApi:Mp,MessageService:Fp,SettingsPanelApi:$p,ModalApi:Bp};function Gt(e,t,n,r={}){const i=Object.assign({},e);for(const[o,s]of Object.entries(t))if(s!==void 0)if(n.includes(o)&&typeof s=="object"&&s!==null){const d=i[o],l=r[o]??{};i[o]=Object.assign({},typeof d=="object"&&d!==null?d:l,s)}else i[o]=s;return i}var ee={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}},zp={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"},qt={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},Ur={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Ie={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:ee.border,borderRadius:ee.borderRadius,textAlign:"center",padding:ee.padding},Hr={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:ee.padding},$t={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:ee.border,borderRadius:ee.borderRadiusCards};function Vp(e){return{...zp,...e}}function Kp(e){return{...qt,...e,bold:e?.bold??qt.bold,italic:e?.italic??qt.italic}}function Wp(e){return{...Ur,...e,underline:e?.underline??Ur.underline}}function Yp(e){return{...Ie,...e,bold:e?.bold??Ie.bold,italic:e?.italic??Ie.italic,border:{...Ie.border,...e?.border},borderRadius:{...Ie.borderRadius,...e?.borderRadius},padding:{...Ie.padding,...e?.padding}}}function Xp(e){return{...Hr,...e,padding:{...Hr.padding,...e?.padding}}}function Jp(e){return{...$t,...e,border:{...$t.border,...e?.border},borderRadius:{...$t.borderRadius,...e?.borderRadius}}}function zt(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 Gr(e){let t={...En};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Vt(e){return{text:Vp(e.text),headings:Kp(e.headings),links:Wp(e.links),buttons:Yp(e.buttons),block:Xp(e.block),cards:Jp(e.cards)}}var qr=O("EmailSettingsPort"),Qp=1e4,jo=class{_editor;_layoutSettingsChanged=new Qt;_contentStylesChanged=new Qt;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(qr);if(!t)throw new Error("[extensions] настройки письма ещё не загружены — работа с UI начинается с init()");return t}_getCurrentLayoutSettings(){return zt(this._settings().read())}_getCurrentContentStyles(){const e=Ct(this._editor.container)?.current()?.get().attributes.common_styles;return Vt(Gr(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(qr),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(We,()=>new Ye),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const i=r?.data,o=i?.operation;if(o===M.APPLICATION_EMAIL_SETTINGS_SET){const l=zt(i?.settings),f=this._getLayoutSnapshot(l);f!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=f,this._layoutSettingsChanged.fire(l));return}if(o!==M.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Vt(r.data?.settings?.commonStyles??{...En}),d=this._getContentSnapshot(s);d!==this._prevContentSnapshot&&(this._prevContentSnapshot=d,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=zt(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Qp){const t=Ct(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,i=yn(r,F.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,d;const l=()=>{d&&(clearTimeout(d),d=void 0)},f=i(()=>{s||(s=!0,l(),f.dispose(),o())});d=setTimeout(()=>{s||(s=!0,f.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Ct(this._editor.container)?.current();if(!t)return;const n=Gr(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=Gt(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:ee.border,borderRadius:ee.borderRadius,padding:ee.padding})),e.block!==void 0&&(n.block=Gt(n.block||{},e.block,["padding"],{padding:ee.padding})),e.cards!==void 0&&(n.cards=Gt(n.cards||{},e.cards,["border","borderRadius"],{border:ee.border,borderRadius:ee.borderRadiusCards}));const r=JSON.stringify(n);mt(t,{common_styles:r}),this._settings().markAppearanceChanged();const i=Vt(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},Zp={...Fo,EmailSettingsApi:jo},eh={...Fo},mm={...eh,EmailSettingsApi:jo},th={...Zp};function nh(){Pp.addAll(th)}var rh=[Le(()=>{nh()}),Ep,yp,bp,ws,hp,Rs];async function ih(){return(await Je()).asyncMixins}var oh=Dp,sh=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await ih()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(Et);Object.assign(o,t.instance||{})}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},ah=ms([...rh]);function Kt(){let e,t=!1;const n=new Map,r=new Map;function i(){for(const o of r.values())o();r.clear()}return{event(o,s,d){const l=Symbol("subscription");return t||(n.set(l,{listener:o,priority:s,thisArg:d}),e&&r.set(l,e(o,s,d))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(o){i(),e=o;for(const[s,{listener:d,priority:l,thisArg:f}]of n)r.set(s,o(d,l,f))},dispose(){t=!0,i(),n.clear(),e=void 0}}}var $r=O("NotificationService");function lh(e){const t=Kt(),n=Kt(),r=Kt();return e.getInstance(k)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync($r).then(i=>{t.attach(i.onNotify),n.attach(i.onError),r.attach(i.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(i){const o=e.getInstance($r);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(i)}}}var dh=[au,ip,lh];function ch(e,t=dh){const n=jn(e);up(e);const r=ah(e),i=oh(e),o=sh(e),s={...r.instance,...i.instance,...o.instance};for(const l of t)Object.assign(s,l(e));let d=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const f=d&&n.get()===l;d=!1,f||n.set(l),await i.setOptions(l),await o.setOptions(l)}}}var uh=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]}},fh="editor-runtime.react.copies",Wt=8;function Ve(e){return e&&typeof e=="object"?e:void 0}function zr(e){const t=Ve(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Ve(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function ph(e){const t=Ve(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Ve(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function hh(e,t,n){return e.package===t&&e.version===n}function mh({ourReact:e,entries:t,packageName:n,version:r}){const i=zr(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const d of t){const l=Ve(d);if(!l||!hh(l,n,r))continue;const f=zr(l.react);!f||f===i||s.has(f)||(s.add(f),o.push({package:n,version:r,reactVersion:ph(l.react),react:l.react}))}return o}function gh({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,Wt))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Wt&&n.push(` …and ${t.length-Wt} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
1047
+ `)}var Vr=new Set;function vh({packageName:e="useblocks",version:t="1.1.85-dev.4",log:n=r=>{}}={}){const r=i=>{try{const o=globalThis[Symbol.for(fh)],s=mh({ourReact:i,entries:o,packageName:e,version:t}).filter(d=>!Vr.has(d.react));if(!s.length)return;s.forEach(d=>Vr.add(d.react)),n(gh({packageName:e,copies:s}))}catch{}};try{const i=Sn()?.modules?.React;if(i&&typeof i.then=="function"){i.then(r,()=>{});return}r(i)}catch{}}async function bh(e,t){$(e.signal);const n=t??ft.createChild();jn(n);const r=n.getInstance(k);async function i(){n.inject(Yo,new uh),vh();const o=ch(n),s={...o.instance,container:n,async reset(d){if($(d.signal),r.isDisposed())throw ui();return await o.setOptions(d),s}};n.inject(Et,s);try{if(await o.setOptions(e),$(e.signal),r.isDisposed()||await n.getInstance(Jt)?.activate(),e.devTools)try{const d=n.getInstance(Jt);d&&await(await Je()).initDevTools(n,d)}catch{}return $(e.signal),li(n,oi).fire(s),s}catch(d){throw r.dispose(),d}}try{return await wn(i(),e.signal)}catch(o){throw r.isDisposed()||r.dispose(),o}}var Ke=new WeakMap;function Eh(e){return e?Ke.get(e):void 0}function Bo(e){try{e.getInstance(k)?.dispose()}catch{}try{e.dispose()}catch{}}function yh(e,t){if(!e)return;const n=Ke.get(e);n&&n!==t&&Bo(n),Ke.set(e,t)}function _h(e,t){e&&Ke.get(e)===t&&Ke.delete(e)}function wh(e){const t=ft.createChild();return It(e)&&t.inject(he,St(e)),t}var Ge=new WeakMap,Sh="data-useblocks-config-styles";function Ih(e){return typeof e=="string"?e.trim():""}function Kr(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Th(e,t,n){if(!e||typeof document>"u")return null;const r=Ih(t),i=Ge.get(e),o=n||e;if(!r)return i&&(i.remove(),Ge.delete(e)),null;if(i)return i.textContent!==r&&(i.textContent=r),(i.parentNode!==o||i!==o.firstChild)&&Kr(o,i),i;const s=document.createElement("style");return s.setAttribute(Sh,"true"),s.textContent=r,Kr(o,s),Ge.set(e,s),s}function Ah(e){if(!e)return;const t=Ge.get(e);t&&(t.remove(),Ge.delete(e))}var Yt=new WeakMap;function Wr(e){const t=(Yt.get(e)??0)+1;Yt.set(e,t);const n=Object.create(e);return n.destroy=()=>{Yt.get(e)===t&&e.destroy()},n}function Uo(){return!1}var Ch=`
1048
1048
  .blocks-app-initial-spinner-wrapper {
1049
1049
  width: 100%;
1050
1050
  height: 100%;
@@ -1073,7 +1073,7 @@ import{t as ei}from"./static/esm/50fbfdf6.js";import{$ as Vo,A as Ko,At as Wo,B
1073
1073
  100% {
1074
1074
  transform: rotate(360deg);
1075
1075
  }
1076
- }`;function Ah(){return()=>{}}function Ch(e,t){if(!jo()||!e||typeof document>"u")return Ah();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=Th,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function Rh(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function Ph({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const d=o().catch(l=>{throw n.has(i)||(n.add(i),r(l)),Rh(l)||t.delete(i),l});return t.set(i,d),d},clear(){t.clear(),n.clear()},size(){return t.size}}}var Un=Ph();function Bo(){Un.clear()}Xo(()=>Un.clear());var Kr=new WeakMap,Wr=new WeakMap;function Dh(e,t){let n=Wr.get(t);n||(n=new Map,Wr.set(t,n));const r=n.get(e);if(r!==void 0)return r;const i=t.getInstance(ti),o=Ls({baseUrl:e,customFetch:i?.execute??fetch},t);return n.set(e,o),o}function Hn(e){return as(e)}function Oh(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function xh(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function Lh(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}function Mh(e,t){return async({baseUrl:n})=>{const r=Hn(n);if(!r)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json"});if(e.getAuthToken&&!await Lh(e))throw xh();const o=t();if(!o)throw new Error("[Loader] appInit requires the instance container");const s=new ui(Dh(r,o)),d={headers:Object.fromEntries(i.entries()),credentials:"same-origin",failoverAttemptTimeout:jn(e)||void 0},l=await s.app_init_create({},d);if(!l.ok)throw Oh(l.status,l.statusText);return l.data}}function kh(e){return JSON.stringify({baseUrl:Hn(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Nh(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function Fh(e){return t=>Un.run(kh(t),()=>(G("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>G("appInit:end",{kind:"network"}))))}function jh(e,t){if(It(e)||!e.appInit&&!Hn(e.baseUrl)||!Nh(e))return e;const n=e.appInit??Mh(e,t);let r=Kr.get(n);return r||(r=Fh(n),Kr.set(n,r)),{...e,appInit:r}}var Uo=0;function Bh(){return Uo}function Uh(){Uo+=1,Bo()}var Yr=new WeakMap,Xr=new WeakMap,Hh=3e4;function Gh(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function qh(e,t){try{const n=oi(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+Hh}function $h(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=Gh(r,i);if(o)return n.delete(s),t.delete(s),Bo(),e(r,i,o);const d=n.get(s);if(d&&!t.has(s)){if(d.expiresAtMs>Date.now())return d.token;n.delete(s)}let l=t.get(s);return l===void 0&&(G("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,i,o)).then(f=>{const u=String(f||"").trim();return u&&n.set(s,{token:f,expiresAtMs:qh(u,Date.now())}),f}).finally(()=>{G("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function zh(e){if(It(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Yr.get(t);const r=Bh();return(!n||Xr.get(t)!==r)&&(n=$h(t),Yr.set(t,n),Xr.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var Ho="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function Vh(){return te(Ho)}function Kh(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ho}function Wh(e,t,n){if(typeof document>"u")return;let r=!1,i;const o=()=>{r=!0,i?.disconnect(),i=void 0},s=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(s);return}i=new MutationObserver(()=>{e.isConnected||s()});let d=e.parentNode;for(;d;)i.observe(d,{childList:!0}),d=d.parentNode}function Yh(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:i}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return Wh(n,()=>{n.id,o.abort(Vh())},i),ai(r,o.signal)}var Go="Superseded by newer init() on the same mount element";function Jr(){return te(Go)}function Xh(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Go}var lt=new Map,dt=new WeakMap;function Jh(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function Qh(e){if(!e)return{release:()=>{}};const t=Jh(e);dt.get(e)?.abort(Jr()),t&&lt.get(t)?.abort(Jr());const n=new AbortController;return dt.set(e,n),t&&lt.set(t,n),{signal:n.signal,release:()=>{dt.get(e)===n&&dt.delete(e),t&&lt.get(t)===n&&lt.delete(t)}}}var hm=ei({FileManagerApiError:()=>Zh}),Zh=class qo extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,i){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,qo)}},mm=ei({mapHttpStatusToErrorCode:()=>Zo});function em(e,t){return{...e,element:t}}function vn(){return()=>{}}function tm(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?vn():(Sh(t,e.config?.styles,t),()=>{Ih(t)})}function nm(e){if(!jo()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:vn()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:vn()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=Ch(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function Qr(e){return e instanceof DOMException&&e.name==="AbortError"}function Zr(e){try{e.destroy()}catch{}}function Yt(e,...t){const n=ce.get(e);t.some(r=>r!==void 0&&r===n)&&ce.delete(e)}var gm="1.1.85-dev.3";async function vm(e){await Sp(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function bm(e){G(J.initStart);const t=await rm(e);return G(J.initEnd),t}async function rm(e){$(e.signal);const t=new Q;let n;try{const r=await Is(e.element,t,e.signal),i=Yh({hostElementOption:e.element,resolvedElement:r,externalSignal:e.signal,disposable:t}),o=Qh(r);n=o.release;const s=ai(i,o.signal);return await _n(im(e,r,s),s)}finally{n?.(),t.dispose()}}async function im(e,t,n){$(n),Uh();const r=em(e,t),i=zh(r);let o;const s=jh(i,()=>o),d=n!=null?{...s,signal:n}:s;if(t){const b=ce.get(t);if(b){let E;try{E=await b,$(n)}catch(I){if($(n),Yt(t,b),Qr(I))throw I;E=void 0}if(E)if(E.getElement()===t)try{return o=vh(t),await E.reset(d)}catch(I){if($(n),Xh(I)||Kh(I)||Qr(I)&&n?.aborted)throw I;Yt(t,b,E),Zr(E)}else Yt(t,b,E),Zr(E)}}$(n);const l=tm(s),f=nm(s),u=n!=null?{...f.options,signal:n}:f.options;let g;try{o=yh(u),bh(t,o),Fn(o).set(u),await Bn(),G(J.coreReady),$(n),$(n),g=gh(u,o),t&&ce.set(t,g);const b=await g;if(n?.aborted&&(b.destroy(),$(n)),t)if(ce.get(t)===g)ce.set(t,b);else throw b.destroy(),$(n),te(n?.reason);return b}catch(b){throw l(),f.cleanup(),o&&(Fo(o),Eh(t,o)),t&&g&&ce.get(t)===g&&ce.delete(t),b}}async function Em(e){return(await Je()).parseAMP(e)}typeof window<"u"&&(qe()&&ea(),Tp(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{Ho as ELEMENT_DETACHED_ABORT_MESSAGE,Go as SUPERSEDED_INIT_ABORT_MESSAGE,hm as errors,mm as helpers,bm as init,Kh as isElementDetachedError,Xh as isSupersededInitError,Em as parseAMP,Cp as pluginRegistry,vm as preload,gm as version};
1076
+ }`;function Rh(){return()=>{}}function Ph(e,t){if(!Uo()||!e||typeof document>"u")return Rh();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=Ch,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function Dh(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function Oh({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const d=o().catch(l=>{throw n.has(i)||(n.add(i),r(l)),Dh(l)||t.delete(i),l});return t.set(i,d),d},clear(){t.clear(),n.clear()},size(){return t.size}}}var Hn=Oh();function Ho(){Hn.clear()}Qo(()=>Hn.clear());var Yr=new WeakMap,Xr=new WeakMap;function xh(e,t){let n=Xr.get(t);n||(n=new Map,Xr.set(t,n));const r=n.get(e);if(r!==void 0)return r;const i=t.getInstance(ri),o=ks({baseUrl:e,customFetch:i?.execute??fetch},t);return n.set(e,o),o}function Gn(e){return ds(e)}function Lh(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function Mh(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function kh(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}function Nh(e,t){return async({baseUrl:n})=>{const r=Gn(n);if(!r)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json"});if(e.getAuthToken&&!await kh(e))throw Mh();const o=t();if(!o)throw new Error("[Loader] appInit requires the instance container");const s=new pi(xh(r,o)),d={headers:Object.fromEntries(i.entries()),credentials:"same-origin",failoverAttemptTimeout:Bn(e)||void 0},l=await s.app_init_create({},d);if(!l.ok)throw Lh(l.status,l.statusText);return l.data}}function Fh(e){return JSON.stringify({baseUrl:Gn(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function jh(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function Bh(e){return t=>Hn.run(Fh(t),()=>(G("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>G("appInit:end",{kind:"network"}))))}function Uh(e,t){if(It(e)||!e.appInit&&!Gn(e.baseUrl)||!jh(e))return e;const n=e.appInit??Nh(e,t);let r=Yr.get(n);return r||(r=Bh(n),Yr.set(n,r)),{...e,appInit:r}}var Go=0;function Hh(){return Go}function Gh(){Go+=1,Ho()}var Jr=new WeakMap,Qr=new WeakMap,qh=3e4;function $h(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function zh(e,t){try{const n=ai(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+qh}function Vh(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=$h(r,i);if(o)return n.delete(s),t.delete(s),Ho(),e(r,i,o);const d=n.get(s);if(d&&!t.has(s)){if(d.expiresAtMs>Date.now())return d.token;n.delete(s)}let l=t.get(s);return l===void 0&&(G("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,i,o)).then(f=>{const u=String(f||"").trim();return u&&n.set(s,{token:f,expiresAtMs:zh(u,Date.now())}),f}).finally(()=>{G("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function Kh(e){if(It(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Jr.get(t);const r=Hh();return(!n||Qr.get(t)!==r)&&(n=Vh(t),Jr.set(t,n),Qr.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var qo="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function Wh(){return te(qo)}function Yh(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===qo}function Xh(e,t,n){if(typeof document>"u")return;let r=!1,i;const o=()=>{r=!0,i?.disconnect(),i=void 0},s=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(s);return}i=new MutationObserver(()=>{e.isConnected||s()});let d=e.parentNode;for(;d;)i.observe(d,{childList:!0}),d=d.parentNode}function Jh(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:i}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return Xh(n,()=>{n.id,o.abort(Wh())},i),di(r,o.signal)}var $o="Superseded by newer init() on the same mount element";function Zr(){return te($o)}function Qh(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===$o}var lt=new Map,dt=new WeakMap;function Zh(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function em(e){if(!e)return{release:()=>{}};const t=Zh(e);dt.get(e)?.abort(Zr()),t&&lt.get(t)?.abort(Zr());const n=new AbortController;return dt.set(e,n),t&&lt.set(t,n),{signal:n.signal,release:()=>{dt.get(e)===n&&dt.delete(e),t&&lt.get(t)===n&&lt.delete(t)}}}var gm=ni({FileManagerApiError:()=>tm}),tm=class zo extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,i){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,zo)}},vm=ni({mapHttpStatusToErrorCode:()=>ts});function nm(e,t){return{...e,element:t}}function bn(){return()=>{}}function rm(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?bn():(Th(t,e.config?.styles,t),()=>{Ah(t)})}function im(e){if(!Uo()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:bn()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:bn()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=Ph(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function ei(e){return e instanceof DOMException&&e.name==="AbortError"}function ti(e){try{e.destroy()}catch{}}function Xt(e,...t){const n=ce.get(e);t.some(r=>r!==void 0&&r===n)&&ce.delete(e)}var bm="1.1.85-dev.4";async function Em(e){await Tp(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function ym(e){G(J.initStart);const t=await om(e);return G(J.initEnd),t}async function om(e){$(e.signal);const t=new Q;let n;try{const r=await As(e.element,t,e.signal),i=Jh({hostElementOption:e.element,resolvedElement:r,externalSignal:e.signal,disposable:t}),o=em(r);n=o.release;const s=di(i,o.signal);return await wn(sm(e,r,s),s)}finally{n?.(),t.dispose()}}async function sm(e,t,n){$(n),Gh();const r=nm(e,t),i=Kh(r);let o;const s=Uh(i,()=>o),d=n!=null?{...s,signal:n}:s;if(t){const b=ce.get(t);if(b){let E;try{E=await b,$(n)}catch(I){if($(n),Xt(t,b),ei(I))throw I;E=void 0}if(E)if(E.getElement()===t)try{return o=Eh(t),Wr(await E.reset(d))}catch(I){if($(n),Qh(I)||Yh(I)||ei(I)&&n?.aborted)throw I;Xt(t,b,E),ti(E)}else Xt(t,b,E),ti(E)}}$(n);const l=rm(s),f=im(s),u=n!=null?{...f.options,signal:n}:f.options;let g;try{o=wh(u),yh(t,o),jn(o).set(u),await Un(),G(J.coreReady),$(n),$(n),g=bh(u,o),t&&ce.set(t,g);const b=await g;if(n?.aborted&&(b.destroy(),$(n)),t)if(ce.get(t)===g)ce.set(t,b);else throw b.destroy(),$(n),te(n?.reason);return Wr(b)}catch(b){throw l(),f.cleanup(),o&&(Bo(o),_h(t,o)),t&&g&&ce.get(t)===g&&ce.delete(t),b}}async function _m(e){return(await Je()).parseAMP(e)}typeof window<"u"&&(qe()&&na(),Cp(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{qo as ELEMENT_DETACHED_ABORT_MESSAGE,$o as SUPERSEDED_INIT_ABORT_MESSAGE,gm as errors,vm as helpers,ym as init,Yh as isElementDetachedError,Qh as isSupersededInitError,_m as parseAMP,Pp as pluginRegistry,Em as preload,bm as version};
1077
1077
 
1078
1078
 
1079
1079
  window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/14a79b09.js":["static/core/b97bd382.js","__delivery__/libs"],"static/core/199dc589.js":[],"static/core/230f23ec.js":[],"static/core/30f16e98.js":["static/core/adf6e008.js"],"static/core/34730be9.js":["static/core/520ec797.js","static/core/4f790fdc.js","__delivery__/libs"],"static/core/364dcebf.js":[],"static/core/3832a02d.js":["static/core/520ec797.js","__delivery__/libs"],"static/core/3fd50a29.js":[],"static/core/48da14fd.js":[],"static/core/4916b3a1.js":["static/core/adf6e008.js","static/core/230f23ec.js","static/core/6541580a.js"],"static/core/4f790fdc.js":[],"static/core/520ec797.js":["static/core/b97bd382.js","__delivery__/libs"],"static/core/52fbc985.js":[],"static/core/57c114f0.js":[],"static/core/5bf994b4.js":[],"static/core/6541580a.js":["static/core/230f23ec.js"],"static/core/6561b34a.js":[],"static/core/79431a89.js":["static/core/4f790fdc.js","static/core/14a79b09.js","__delivery__/libs"],"static/core/79749848.js":[],"static/core/7b850506.js":[],"static/core/8fb0fe48.js":[],"static/core/9a70cc1e.js":[],"static/core/a15ab67d.js":[],"static/core/ac50dfd1.js":[],"static/core/adf6e008.js":[],"static/core/b743a76d.js":["static/core/230f23ec.js"],"static/core/b97bd382.js":["__delivery__/libs"],"static/core/ddb5a35d.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/dfddbd68.js":[],"static/core/e0d71533.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/ecad56ba.js":["static/core/520ec797.js"],"static/core/f3eda1c7.js":[],"static/core/fb2fe2db.js":[],"static/core/ffb36e93.js":[],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"compat-globals.js":["static/esm/50fbfdf6.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/50fbfdf6.js","static/esm/cb0e9a7f.js"],"static/esm/50fbfdf6.js":[],"static/esm/cb0e9a7f.js":[]},"bundles":{"static/core/b97bd382.js":["static/core/3bd1b21b.js","static/core/867b0259.js","static/core/a50825ac.js","static/core/daf98928.js"],"static/core/30f16e98.js":["static/core/a71c4cd8.js"],"static/core/3832a02d.js":["static/core/a3cd808c.js"],"static/core/14a79b09.js":["static/core/a73da823.js"],"static/core/520ec797.js":["static/core/dbeb2f23.js","static/core/5a0df1c2.js","static/core/f7fccabd.js"],"core":["static/core/2ff39ddf.js","static/core/fe480726.js","static/core/c00a8e02.js","static/core/d3e05bb9.js","static/core/a5b517f0.js"]}});