useblocks 1.1.85-dev.6 → 1.1.85-dev.7
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/README.md +14 -2
- package/iframe/.vite/manifest.json +4 -4
- package/iframe/js/{discussHandlers.Ced_gtP0.js → discussHandlers.C5qc-xPl.js} +2 -2
- package/iframe/js/iframe-eblock.body.js +1 -1
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.body.js +2 -2
- package/iframe/js/iframe.js +1 -1
- package/node_modules/useblocks-ui-kit/package.json +1 -1
- package/package.json +2 -2
- package/runtime/react/index.js +1 -1
- package/static/core/{6741eb70.js → 53bcd609.js} +2 -2
- package/static/core/{d0eece8b.js → 77d63e01.js} +1 -1
- package/static/core/{3a252a3c.js → 78b1e678.js} +1 -1
- package/static/core/{9600caf9.js → b49f995f.js} +3 -3
- package/static/core/{b6c5e3be.js → ea93d0cd.js} +2 -2
- package/static/umd-runtime/runtime.js +1 -1
- package/{useblocks-core.d62ebebc.js → useblocks-core.46f9d75a.js} +31 -31
- package/useblocks-esm.js +10 -10
- package/{useblocks-po.d62ebebc.js → useblocks-po.46f9d75a.js} +1 -1
- package/useblocks.d.ts +26 -6
- package/useblocks.js +11 -11
- /package/iframe/{iframe-eblock.d62ebebc.html → iframe-eblock.46f9d75a.html} +0 -0
- /package/iframe/{iframe.d62ebebc.html → iframe.46f9d75a.html} +0 -0
package/useblocks-esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as si}from"./static/esm/50fbfdf6.js";import{$ as
|
|
1
|
+
import{t as si}from"./static/esm/50fbfdf6.js";import{$ as Jo,A as Qo,At as le,B as Zo,C as es,Ct as ts,D as ns,Dt as rs,E as is,Et as $,F as Ye,G as ai,H as Xe,I as os,J as ss,K as as,L as ls,M as ds,Mt as cs,N as et,Nt as Z,O as li,Ot as pt,P as us,Q as di,R as fs,S as ps,St as hs,T as ms,Tt as ht,V as Wn,W as gs,X as vs,Y as ci,Z as Pe,_ as mt,_t as pe,a as bs,at as oe,b as ys,bt as Es,c as _s,ct as ws,d as Et,dt as Ss,et as we,f as Is,ft as Ts,g as ui,gt as Ce,h as As,ht as wn,i as Cs,it as fi,j as Rs,jt as Ps,k as Ds,kt as L,l as N,lt as Os,m as Sn,mt as In,n as xs,nt as De,o as Me,ot as Zt,p as Ls,pt as j,q as Tn,r as Ms,rt as _t,s as ks,st as he,t as ce,tt as F,u as Ns,ut as Yn,v as Fs,vt as js,w as An,wt as Q,x as Xn,xt as Jn,y as Bs,yt as en,z as Te}from"./static/esm/ff1698e6.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var h=(function(){if(typeof document<"u"&&document.querySelector)try{var _=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(_&&_.src)return _.src.substring(0,_.src.lastIndexOf("/")+1)}catch{}try{var T=import.meta.url;if(T)return T.substring(0,T.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var c=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(c)||c.indexOf("//")===0)return c.charAt(c.length-1)==="/"?c:c+"/";var a=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",p=a?new URL(c,a).href:c;return p.charAt(p.length-1)==="/"?p:p+"/"}catch{var m=String(h);return m.charAt(m.length-1)==="/"?m:m+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var c=h==null?"":String(h);c||(c="./");try{var a=String(c);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a)||a.indexOf("//")===0)return a.charAt(a.length-1)==="/"?a:a+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",m=p?new URL(a,p).href:a;return m.charAt(m.length-1)==="/"?m:m+"/"}catch{var _=String(c);return _.charAt(_.length-1)==="/"?_:_+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var c="";try{if(typeof window<"u"){for(var a in window)if(!(a==="__useblocks__"||!/^__[^_].*__$/.test(a))){var p;try{p=window[a]}catch{continue}if(p&&typeof p=="object"&&p.publicPath){c=" Another product namespace ("+a+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function c(D){try{var R=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return R?new URL(String(D||""),R).href:String(D||"")}catch{return String(D||"")}}var a=String(h||"");if(!a)return"";if(/^(?:data:|blob:)/.test(a))return a;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a)||a.indexOf("//")===0||a.charAt(0)==="/")return c(a);var p=a.replace(/^\.\/+/,"").replace(/^\/+/,""),m="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),_=m&&p.indexOf(m+"/")!==0?m+"/"+p:p,T=e.publicPath||"./";try{return new URL(_,T).href}catch{return T.slice(-1)!=="/"&&(T+="/"),c(T+_)}}),e.version||(e.version="1.1.85-dev.7");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
|
|
2
2
|
* Async AMD Loader (IIFE version for injection)
|
|
3
3
|
*
|
|
4
4
|
* This file is injected at the beginning of iframe entry points.
|
|
@@ -993,14 +993,14 @@ import{t as si}from"./static/esm/50fbfdf6.js";import{$ as Qo,A as Zo,At as le,B
|
|
|
993
993
|
__amdEnv.syncRequire = syncRequire;
|
|
994
994
|
__amdEnv.diagnosticsBuffer = diagBuffer;
|
|
995
995
|
})();
|
|
996
|
-
`,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"useblocks-core.d62ebebc.js",po:"useblocks-po.d62ebebc.js",monaco:"static/monaco/index.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(h){var c,a=function(){return c||(c=Promise.resolve().then(h))};return{then:function(p,m){return a().then(p,m)},catch:function(p){return a().catch(p)},finally:function(p){return a().finally(p)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=i(function(){return o.then(function(h){return h.React})}),t.ReactDom=i(function(){return o.then(function(h){return h.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(h){return h.Classnames})}),t.Dayjs=i(function(){return o.then(function(h){return h.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(h){var c=h[0]||Object.create(null),a=Object.create(null);for(var p in c)Object.prototype.hasOwnProperty.call(c,p)&&(a[p]=c[p]);for(var m in a)Object.prototype.hasOwnProperty.call(a,m)&&(t[m]=a[m]);return a})}),d={},l={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},f={Antd:"[runtime] `antd` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",AntDesignIcons:"[runtime] `@ant-design/icons` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated."},u=Object.create(null);if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var c in h)Object.prototype.hasOwnProperty.call(h,c)&&(u[c]=h[c])},e.__compatPending){for(var v=0;v<e.__compatPending.length;v+=1)e.registerCompat(e.__compatPending[v]);e.__compatPending=void 0}for(var b in l)Object.prototype.hasOwnProperty.call(l,b)&&(function(h,c,a){var p=!1,m=function(){if(!(h in u))throw new Error(c);return u[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var _=m();return p||(p=!0),_},set:function(_){u[h]=_}}),Object.defineProperty(d,h,{configurable:!0,enumerable:!0,get:m,set:function(_){u[h]=_}})})(b,l[b],f[b]);var E=t;for(var I in d)Object.prototype.hasOwnProperty.call(d,I)&&(E===t&&(E=Object.create(t)),Object.defineProperty(E,I,Object.getOwnPropertyDescriptor(d,I)));var g=s,y=[],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 C=Object.getOwnPropertyDescriptor(c,T);C&&Object.defineProperty(p,T,C)}}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?g.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.React;return h(p)})}),e.define("useblocks/runtime/react",[],function(){var c=E.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.React;return h(p)})}),e.define("react-dom",[],function(){var c=E.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("useblocks/runtime/react-dom",[],function(){var c=E.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("react-dom/client",[],function(){var c=E.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var c=E.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("react/jsx-runtime",[],function(){var c=E.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var c=E.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("react/jsx-dev-runtime",[],function(){var c=E.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var c=E.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("antd",[],function(){var c=E.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Antd;return h(p)})}),e.define("useblocks/runtime/antd",[],function(){var c=E.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Antd;return h(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var c=E.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var c=E.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("@ant-design/icons",[],function(){var c=E.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var c=E.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("@ant-design/cssinjs",[],function(){var c=E.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var c=E.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("classnames",[],function(){var c=E.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Classnames;return h(p)})}),e.define("useblocks/runtime/classnames",[],function(){var c=E.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Classnames;return h(p)})}),e.define("dayjs",[],function(){var c=E.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks/runtime/dayjs",[],function(){var c=E.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks-ui-kit",[],function(){var c=E.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit",[],function(){var c=E.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit/icons",[],function(){var c=E.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKitIcons;return h(p)})}),e.define("useblocks-ui-kit/icons",[],function(){var c=E.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKitIcons;return h(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Hs=new Function("url","return import(url)");function Gs(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function qs(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function $s(e){return e.type==="umd"||e.resolve==="registry"}var zs=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(qs(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($s(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Hs(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 Gs(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)}))}},Vs=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)}}}},Ks=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()}},Yn=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 Ws(e,t){return t+e}function Ys(){return typeof performance>"u"?Date.now():Ws(performance.now(),performance.timeOrigin)}var Xs="emailmaker:diagnostics",Js="diagnostics",Qs="diagnostics";function Xn(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Qs}=1`:e}var At;function Zs(){try{const e=new URLSearchParams(window.location.search).get(Js);return e===null?void 0:e!=="0"}catch{return}}function ea(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function ta(){try{const e=window.localStorage.getItem(Xs);return e===null?void 0:e==="1"}catch{return}}function qe(){return At===void 0&&(At=typeof window>"u"?!1:Zs()??ea()??ta()??!1),At}function na(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"},ym=Object.values(J),_m=[J.canvasPainted,J.canvasSettled,J.appVisible,J.editorVisible],ra=5e3,ia=3e3,Jn="diagnosticsStore",et,Ne;function Qn(){return{marks:new Yn(ra),resources:new Yn(ia)}}function hi(){if(Ne)return Ne;const e=In();return e?(Ne=e[Jn]??et??Qn(),e[Jn]=Ne,et=void 0,Ne):(et??=Qn(),et)}function $(e,t){qe()&&hi().marks.push({phase:e,at:Ys(),...t})}function In(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[na()];return e!==null&&typeof e=="object"?e:void 0}function oa(e){const t=e.length,n=hi();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function sa(){const e=In();return!e||!Array.isArray(e.diagnosticsBuffer)?0:oa(e.diagnosticsBuffer)}var aa="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Tn(){const e=new Error(aa);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 mi(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 mi(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 mi(i,o)}};return i}var gi=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:bs.UrlEncoded,...t})},vi=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 la(e){return String(e||"").trim()||void 0}var da=class extends Z{deps;_app;_baseUrl;_appInit;_restBaseUrl;_prevApp;constructor(e){super(),this.deps=e,this.addDisposable(e.options.select(t=>this._slice(t)).watch(t=>this._start(t)))}get app(){return this._app}_slice(e){return Object.prototype.hasOwnProperty.call(e,"baseUrl")&&(this._baseUrl=la(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)}},An=x("AppInitService");function ca(e){return async()=>{const t=await e();return(await new gi(t).app_init_create({})).data}}function ua(e){e.injectFactory(An,()=>{const t=new da({options:e.getInstance(oe),isStandalone:()=>!!e.getInstance(he),resolveRestBaseUrl:n=>n?Kn(n):Kn()||void 0,setRestBaseUrl:n=>{e.getInstance(js)?.setOptions(n?{baseUrl:n}:{})},fallbackAppInit:ca(()=>e.getInstanceAsync(as)),publish:n=>{e.inject(Pe,n)}});return e.getInstance(N)?.addDisposable(t),t},!0)}var Cn=x("documentSession.emailDocuments");function Ct(e){return e?.getInstance(Cn)}var fa=x("RevisionServiceFlag");function pa(e){return e.getOrCreateInstance(fa,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function bi(e){return pa(e).isEnabled()}var ha=x("EmailRightsResolver");function ma(e,t){const n=e.getInstance(ha);return n?n(t):!0}var Ei=x("EmailHistoryAvailabilityResolver");function ga(e){return e.getInstance(Ei)!==void 0}async function va(e){const t=e.getInstance(Ei);if(!t)return!0;try{return await t()}catch{return!1}}var Rn={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},yi=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],_i=2e4,ba=yi.reduce((e,t)=>e+Rn[t],0),wi=_i+ba+3e3;function Ea(e){return yi.reduce((t,n)=>t+Si(n,e),0)}function Si(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:Rn[e]}function Ii(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:wi}function Ti(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:_i}function Ai(e=wi){return e+3e3}var ya=()=>Ai();function _a(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function wa(e){return t=>_a(e.getOrCreateInstance(F.BEFORE_SAVE_EMAIL,()=>new pe).fire(t),ya())}function Sa(e){return e!=null&&e!==""}var Ia;function yt(e,t){return Ia?.capture(e,t)}function Ta(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 Zn(e,t){return e===null||e.length===0?t:new Aa(e,t).compress()}var Aa=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 Ca(e){return new re(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Ra(e){return e.map(Ca)}function er(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Pa(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 Da(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"}},tr=0,Oa=Math.random().toString(36).slice(2,8);function xa(){return tr+=1,`doc-${Oa}-${tr}`}function La(e){const t=e.createBuffer(),n=e.docId??xa();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const d=new Set;let l=!1,f=!1,u;const v=new Set;let b=null;const E=()=>(b?.version!==i&&(b={version:i,value:t.read()}),b.value),I=g=>Object.entries(g).some(([y,w])=>s[y]!==w);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:E,mutate(g,{source:y}){if(l)return i;const w=g.changes?.length?g.changes:void 0,S=w?Pa(E(),w):g.content!==void 0?g.content:void 0,A=S!==void 0&&S!==E(),h=g.attributes!==void 0&&I(g.attributes);if(!A&&!h)return i;const c=!(i>(o??-1));return A&&t.write(S),h&&(s={...s,...g.attributes}),i+=1,y!=="user"&&c&&(o=i),d.forEach(a=>a({source:y,version:i,changes:w})),i},markSaved(g,y){const w={serverId:r,savedVersion:o};y!==void 0&&(r=y),(o===null||g>o)&&(o=g),(w.serverId!==r||w.savedVersion!==o)&&d.forEach(S=>S({source:"system",version:i}))},markReady(){f||u!==void 0||(f=!0,v.forEach(g=>g.resolve()),v.clear(),d.forEach(g=>g({source:"system",version:i})))},isReady:()=>f,markFailed(g){f||u!==void 0||l||(u=g,v.forEach(y=>y.reject(new ht(g))),v.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((g,y)=>{v.add({resolve:g,reject:y})})},subscribe(g){return d.add(g),()=>d.delete(g)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>l,dispose(){l=!0,v.forEach(g=>g.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),v.clear(),d.clear(),t.dispose()}}}var Ma=500,ka=100,Rt=0;function Na(e,t={}){const n=t.groupIntervalMs??Ma,r=t.maxSteps??ka,i=t.now??(()=>0);let o=[],s=0,d=Rt+=1,l=null,f=!1,u=!1,v=!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}}},g=a=>I(a,"user"),y=a=>{const p=i();f&&l!==null&&p-l<n?o[s-1]=Zn(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]=Zn(o[s-1],a)),w(),p&&E()},A=e.subscribe(({source:a,changes:p})=>{if(!(v||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=Ra(o[s-1]);return er(e.getContent(),a)?(g(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(!er(e.getContent(),o[s])){o=o.slice(0,s),w(),E();return}g(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(){v=!0,A(),b.clear(),o=[],s=0}}}var Fa=["edit","move","resize","insert"];function Pt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ja(e){return typeof e=="string"?e:null}function Ba(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Ua(e){return Fa.includes(e)?e:null}function Ha(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:ja(t.originId),changeId:Pt(t.changeId),rev:Pt(t.rev),baseRev:Pt(t.baseRev),expected:Ba(t.expected),intent:Ua(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var nr=class extends Error{reason;constructor(e){super(`сохранение не состоялось: ${e}`),this.name="SaveRefusedError",this.reason=e}},Ci="draft";function Fe(e){return e==null||e===""?Ci:String(e)}function Ga(e){return e==null||e===""?`${Zt}${Ci}`:`${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 $(`show:gate:${e}`,{kind:"wait"}),t.then(i=>($(`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 Ri(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Pi(e,{freshSince:t}={}){return!(!e?.slug?.includes("autosave")||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function qa(e,t={}){const n=Ri((e??[]).filter(r=>r?.html?.trim()));return Pi(n,t)?n:null}function $a(e){const t=Date.parse(Ri(e)?.modified??"");return{autosave:qa(e),...Number.isFinite(t)?{latestAt:t}:{}}}function za({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Di=e=>e.replace(/\r\n?/g,`
|
|
997
|
-
`),rr=["recovery","plugin","rest"],Va=["subject","preheader"];function Ka(e){let t={},n;for(let i=rr.length-1;i>=0;i--){const o=e.get(rr[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 Va){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Oi(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Di(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 ir=e=>typeof e=="string"?e.trim():"";function Wa(e,t,n){const{version:r,attributes:i}=e.get(),o=i,s=ir(o.title)||ir(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 Ya(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 Xa=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function xi(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Xa.has(t))):{}}function mt(e,t,n={}){e&&e.mutate({attributes:Ja(e.get().attributes,t)},{source:n.source??"user"})}function Ja(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Pn(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Qa(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Li(e){if(!e)return null;const t=xi(e);return e.common_styles!==void 0&&(t.common_styles=Qa(e.common_styles)),Pn(e.html,t)}function Mi(e){return e?Pn(e.html,ge(xi(e))):null}var Za=["common_styles","subject","preheader","meta"];function or(e){if(!e?.html?.trim())return null;const t={};for(const n of Za)el(n,e[n])&&(t[n]=e[n]);return Pn(e.html,t)}function el(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 tl=10,nl=(e,t)=>e.key===t.key&&rl(e.serverId,t.serverId),rl=(e,t)=>e==null||e===t;function il(e){return typeof e?.then=="function"}var sr=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},ki=e=>{e.request.serverId!=null&&e.document.markSaved(e.document.get().version)},ol=e=>{Oi(e.document,Ka(e.reports)),ki(e)},Dt=(e,t)=>{if(!e.ready){ol(e);return}Oi(e.document,t)},sl=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 al(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:d,onAdapterError:l,onTimeout:f}=e;let u;const v=new Set,b=new Set,E=()=>v.forEach(m=>m()),I=(m,_)=>{if(!(m.closed||m.ready)){if(m.error!==void 0){m.document.markFailed(m.error),m.document.get().docId;return}ki(m),m.ready=!0,m.document.markReady(),m.document.get().docId,[...m.reports.keys()]}},g=(m,_,T)=>{l?.(_.id,T),!(!_.required||m.closed)&&(m.error=T,m.document.get().docId,_.id,E())},y=(m,_)=>{const T=new Set(_.map(R=>R.id));_.forEach(R=>{R.watch&&m.watchers.push(R.watch(O=>m.closed?!1:m.ready&&O?.content!==void 0&&za({hasUnsavedUserEdit:m.document.isDirty()})==="skip"?(m.document.get().docId,R.id,!1):(O&&m.reports.set(R.id,O),Dt(m,O),!0)))});const C=(R,O)=>{m.closed||(O&&m.reports.set(R.id,O),Dt(m,O))},P=()=>{T.size>0||m.closed||(sr(m),I(m,[]))},j=[];if(_.forEach(R=>{let O;try{O=R.load()}catch(z){g(m,R,z),T.delete(R.id);return}if(il(O)){j.push({id:R.id,required:R.required,load:()=>O});return}C(R,O),T.delete(R.id)}),j.length===0){P();return}m.timer=setTimeout(()=>{m.timer=void 0,f?.([...T]),m.document.get().docId,[...T],I(m,[...T])},n),m.timer.unref?.(),j.forEach(R=>{R.load().then(O=>C(R,O)).catch(O=>{g(m,R,O)}).finally(()=>{T.delete(R.id),P()})})},w=async(m,_,T)=>{if(T==="snapshot"||T==="anchor")return;const C=o?.();if(C)return C.resolve({project:_.project??m.project,tags:(m.tags??[]).map(P=>({name:P}))})},S=m=>{if(m.lock===!0&&s?.(m)===!1)return new nr("locked");const _=m.tags?.length??0,T=m.emailtags?.length??0;if(Math.max(_,T)>tl)return new nr("too-many-tags")},A=async(m,_,T)=>{try{await m.document.whenReady()}catch(O){return m.saveError=O,m.saveFailures+=1,m.saveFailures,!1}if(m.closed)return!1;const C=S(m.document.get().attributes);if(C)return m.saveError=C,m.saveFailures+=1,C.reason,E(),!1;if(d&&(await d(sl(m)).catch(()=>{}),m.closed))return!1;let P;try{P=await w(m.document.get().attributes,T,_)}catch(O){return m.saveError=O,m.saveFailures+=1,m.saveFailures,E(),!1}if(m.closed)return!1;const{payload:j,version:R}=Wa(m.document,T,P);m.document.get().docId;try{const O=m.document.get().serverId!=null,z=await Ya(r(),i(m.request.key),_,m.document.get().serverId,j);if(m.closed)return!0;let B;if(_==="snapshot"||_==="anchor"){const L=z?.modified!=null?Date.parse(z.modified):NaN;B=Number.isFinite(L)?L:Date.now(),m.snapshotVersion=R,m.lastRevisionAt=B}else m.document.markSaved(R,z?.id!=null?String(z.id):void 0);const W=m.document.get().serverId;!O&&W!=null&&(m.recoveryFacts={emailId:W,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:!O,...B!==void 0?{revisionAt:B}:{}};return b.forEach(L=>L(de)),!0}catch(O){return m.saveError=O,m.saveFailures+=1,m.saveFailures,E(),!1}},h=()=>{u&&(u.closed=!0,u.watchers.forEach(m=>m()),u.watchers=[],sr(u),u.history.dispose(),u.document.dispose(),u=void 0)},c=(m,_,T)=>{let C=!1;_.show&&(m.show?.id!==_.show.id||m.show.token!==_.show.token)&&(m.show=_.show,C=!0,{docId:m.document.get().docId,..._.show});const P=T==="show"?Mi(_.patch):null;P&&(m.reports.set("plugin",P),Dt(m,P)),C&&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"&&nl(u.request,m))return c(u,m,_),u.document;h();const T=La({createBuffer:()=>Ta(""),serverId:m.serverId??null}),C={request:m,show:m.show,document:T,history:Na(T,{now:Date.now}),watchers:[],saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return u=C,T.get().docId,m.serverId,y(C,t(m,{publishRecoveryFacts(P){C.closed||(C.recoveryFacts=P,E())},readShownContent:()=>C.closed?null:C.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:Ga(m),serverId:_?.id!=null?String(_.id):null,email:_},"open"),show:(m,_)=>{const T=u;if(!(!T||T.closed))return p({...T.request,patch:m,show:_},"show")},current:()=>u?.document,save:a,saveState:()=>({error:u?.saveError,failures:u?.saveFailures??0,saving:u?.saving===!0}),revisionFacts(){if(!u)return;const m=u.revisionFactsSnapshot;return m&&m.snapshotVersion===u.snapshotVersion&&m.lastRevisionAt===u.lastRevisionAt?m:(u.revisionFactsSnapshot={snapshotVersion:u.snapshotVersion,lastRevisionAt:u.lastRevisionAt},u.revisionFactsSnapshot)},recoveryFacts:()=>u?.recoveryFacts,history:()=>u?.history,forcedHeaders:()=>u?.forcedHeaders,beginForcedHeaders(m){u&&!u.closed&&(u.forcedHeaders=m)},endForcedHeaders(){u&&(u.forcedHeaders=void 0)},onSaved(m){return b.add(m),()=>b.delete(m)},showFacts:()=>u?.show,sessionKey:()=>u?.request.key,openError:()=>u?.error,subscribe(m){return v.add(m),()=>v.delete(m)},close(){u&&(h(),E())}}}var Ni=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Fi(e){if(e instanceof Ni)return e.reason;if(e instanceof ht)return Fi(e.reason)}function ll(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Ni("not-found");return Li(n)}}}var ji=x("EmailPort");function dl(e){return e.getInstance(ji)}function cl(e,t){e.inject(ji,t)}var Bi=x("documentSession.restEmailPortFactories");function Ui(e){return e.getInstance(Bi)!==void 0}function Se(e){const t=e.getInstance(Bi);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var ul=x("EmailTermsResolver");function fl(e){return e.getInstance(ul)}var Hi=x("EmailHistoryPort"),pl=x("BlockHistoryPort");function Gi(e){return e.getInstance(pl)}function qi(e){return e.getInstance(Hi)}function hl(e,t){e.inject(Hi,t)}var ml="em_autosave_pending";function gt(e){return`${ml}_${e}`}function gl(e,t){try{sessionStorage.setItem(gt(e),JSON.stringify(t))}catch{}}function vl(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 bl=2e3,El=5e3,yl=5,_l=5e3,wl=4;function Sl(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Il(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.46f9d75a.js",po:"useblocks-po.46f9d75a.js",monaco:"static/monaco/index.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(h){var c,a=function(){return c||(c=Promise.resolve().then(h))};return{then:function(p,m){return a().then(p,m)},catch:function(p){return a().catch(p)},finally:function(p){return a().finally(p)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=i(function(){return o.then(function(h){return h.React})}),t.ReactDom=i(function(){return o.then(function(h){return h.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(h){return h.Classnames})}),t.Dayjs=i(function(){return o.then(function(h){return h.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(h){var c=h[0]||Object.create(null),a=Object.create(null);for(var p in c)Object.prototype.hasOwnProperty.call(c,p)&&(a[p]=c[p]);for(var m in a)Object.prototype.hasOwnProperty.call(a,m)&&(t[m]=a[m]);return a})}),d={},l={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},f={Antd:"[runtime] `antd` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",AntDesignIcons:"[runtime] `@ant-design/icons` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated."},u=Object.create(null);if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var c in h)Object.prototype.hasOwnProperty.call(h,c)&&(u[c]=h[c])},e.__compatPending){for(var v=0;v<e.__compatPending.length;v+=1)e.registerCompat(e.__compatPending[v]);e.__compatPending=void 0}for(var b in l)Object.prototype.hasOwnProperty.call(l,b)&&(function(h,c,a){var p=!1,m=function(){if(!(h in u))throw new Error(c);return u[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var _=m();return p||(p=!0),_},set:function(_){u[h]=_}}),Object.defineProperty(d,h,{configurable:!0,enumerable:!0,get:m,set:function(_){u[h]=_}})})(b,l[b],f[b]);var y=t;for(var I in d)Object.prototype.hasOwnProperty.call(d,I)&&(y===t&&(y=Object.create(t)),Object.defineProperty(y,I,Object.getOwnPropertyDescriptor(d,I)));var g=s,E=[],w=function(){for(var h=[],c=0;c<E.length;c+=1)(function(a){var p=t[a];p&&typeof p.then=="function"&&h.push(Promise.resolve(p).then(function(m){t[a]=m}))})(E[c]);return Promise.all(h)},S=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(w).then(function(){if(typeof S=="function")return S.call(e)})},typeof e.define=="function"){let h=function(c){if(!c||typeof c!="object"&&typeof c!="function"||c.__esModule)return c;if(A){var a=A.get(c);if(a)return a}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var m=Reflect.ownKeys(c),_=0;_<m.length;_++){var T=m[_];if(T!=="__esModule"){var D=Object.getOwnPropertyDescriptor(c,T);D&&Object.defineProperty(p,T,D)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:c,writable:!1}),A&&A.set(c,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var c=y.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.React;return h(p)})}),e.define("useblocks/runtime/react",[],function(){var c=y.React;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.React)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.React;return h(p)})}),e.define("react-dom",[],function(){var c=y.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("useblocks/runtime/react-dom",[],function(){var c=y.ReactDom;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDom)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDom;return h(p)})}),e.define("react-dom/client",[],function(){var c=y.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var c=y.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactDomClient)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactDomClient;return h(p)})}),e.define("react/jsx-runtime",[],function(){var c=y.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var c=y.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxRuntime;return h(p)})}),e.define("react/jsx-dev-runtime",[],function(){var c=y.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var c=y.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.ReactJsxDevRuntime)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.ReactJsxDevRuntime;return h(p)})}),e.define("antd",[],function(){var c=y.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Antd;return h(p)})}),e.define("useblocks/runtime/antd",[],function(){var c=y.Antd;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Antd)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Antd;return h(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var c=y.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var c=y.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIconBase)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIconBase;return h(p)})}),e.define("@ant-design/icons",[],function(){var c=y.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var c=y.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignIcons;return h(p)})}),e.define("@ant-design/cssinjs",[],function(){var c=y.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var c=y.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.AntDesignCssinjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.AntDesignCssinjs;return h(p)})}),e.define("classnames",[],function(){var c=y.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Classnames;return h(p)})}),e.define("useblocks/runtime/classnames",[],function(){var c=y.Classnames;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Classnames)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Classnames;return h(p)})}),e.define("dayjs",[],function(){var c=y.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks/runtime/dayjs",[],function(){var c=y.Dayjs;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.Dayjs)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.Dayjs;return h(p)})}),e.define("useblocks-ui-kit",[],function(){var c=y.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit",[],function(){var c=y.UiKit;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKit)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKit;return h(p)})}),e.define("useblocks/ui-kit/icons",[],function(){var c=y.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKitIcons;return h(p)})}),e.define("useblocks-ui-kit/icons",[],function(){var c=y.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(a){return a===void 0?g.then(function(p){return h(p.UiKitIcons)}):h(a)}):c!==void 0?h(c):g.then(function(a){var p=a.UiKitIcons;return h(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Us=new Function("url","return import(url)");function Hs(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Gs(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function qs(e){return e.type==="umd"||e.resolve==="registry"}var $s=class{_context;_pluginRegistry;_options;_map=new Map;_optionsMap=new Map;_readyMap=new Map;_resolveMap=new Map;_initializingPlugins=new Map;_creatingPlugins=new Set;_initializedPlugins=new Set;_creationOrder=[];_lifecycleListeners=new Set;_activated=!1;constructor(e,t,n={}){this._context=e,this._pluginRegistry=t,this._options=n}activate(){return this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}activateSync(){this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}onLifecycle(e){return this._lifecycleListeners.add(e),{dispose:()=>this._lifecycleListeners.delete(e)}}_emitLifecycle(e){for(const t of Array.from(this._lifecycleListeners))try{t(e)}catch{}}async _resolveEntry(e){if(typeof e=="string"||typeof e=="symbol"){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);return{ctor:t}}if(typeof e=="function")return e.length===0?{ctor:await e()}:{ctor:e};if(Array.isArray(e)){const[t,n]=e;if(typeof t=="function")return{ctor:t,options:n};const r=await this._pluginRegistry.getAsync(t);if(!r)throw new Error(`Plugin "${String(t)}" not registered.`);return{ctor:r,options:n}}if(Gs(e))return this._resolveDescriptor(e);throw new Error(`Unknown plugin entry format: ${JSON.stringify(e)}`)}async _resolveDescriptor(e){const t=e.resolve??(e.type==="umd"?"window":"module");if(qs(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Us(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}initSync(e){const t=[];for(const n of e){const r=this._getOrCreate(n,void 0);t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const{ctor:i,options:o}=await this._resolveEntry(r),s=this._getOrCreate(i,o);n.has(s)||(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const d=await this._resolveEntry(s);t.add(d.ctor),n.push(d)}const r=[];this._map.forEach((s,d)=>{t.has(d)||r.push({key:d,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:d,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(d),this._optionsMap.delete(d),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const f=this._creationOrder.indexOf(l);f>=0&&this._creationOrder.splice(f,1)}const i=[],o=new Set;for(const{ctor:s,options:d}of n){const l=this._getOrCreate(s,d);o.has(l)||(o.add(l),i.push(l))}this._activated&&await this._startPluginsBatch(i)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,i)=>{let o,s=!1;const d=()=>{s||(s=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,d),r())};this._pluginRegistry.on(e,d),n!==void 0&&n>0&&(o=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,d),i(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),i=this._createPluginInstance(e,r),o=i.constructor.name;this._emitLifecycle({type:"created",plugin:i,name:o}),i.required?.(),this._map.set(n,i),this._creationOrder.push(i),this._setupReadyPromise(i)}return this._map.get(n)}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);try{return Hs(e)?new e(this._context,t):e(this._context,t)||{}}finally{this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const i of t){if(this._initializedPlugins.has(i))continue;const o=this._initializingPlugins.get(i);if(o){n.add(o);continue}r.push(i)}if(r.length>0){const i=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,i);n.add(i),i.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===i&&this._initializingPlugins.delete(o)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(i){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:i})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},zs=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const i of n)try{i.callback(t)}catch{}const r=n.filter(i=>!i.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(i=>(t.ctor=i,t.loading=void 0,this._notifyListeners(e,i),i));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!1};return r.push(i),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!0};return r.push(i),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(i=>i.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Vs=class{resolveRegistry;constructor(e){this.resolveRegistry=e}target(){return this.resolveRegistry()}get(e){return this.target().get(e)}getAsync(e){return this.target().getAsync(e)}add(e,t){return this.target().add(e,t)}addAll(e){return this.target().addAll(e)}addAsync(e,t){return this.target().addAsync(e,t)}has(e){return this.target().has(e)}isLoaded(e){return this.target().isLoaded(e)}override(e,t){return this.target().override(e,t)}on(e,t){return this.target().on(e,t)}once(e,t){return this.target().once(e,t)}off(e,t){return this.target().off(e,t)}keys(){return this.target().keys()}forContext(){return this.target().forContext()}},Qn=class{capacity;items=[];constructor(e){this.capacity=e}push(e){this.items.length>=this.capacity&&this.items.shift(),this.items.push(e)}snapshot(){return this.items.slice()}size(){return this.items.length}clear(){this.items=[]}};function Ks(e,t){return t+e}function Ws(){return typeof performance>"u"?Date.now():Ks(performance.now(),performance.timeOrigin)}var Ys="emailmaker:diagnostics",Xs="diagnostics",Js="diagnostics";function Zn(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Js}=1`:e}var Rt;function Qs(){try{const e=new URLSearchParams(window.location.search).get(Xs);return e===null?void 0:e!=="0"}catch{return}}function Zs(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function ea(){try{const e=window.localStorage.getItem(Ys);return e===null?void 0:e==="1"}catch{return}}function $e(){return Rt===void 0&&(Rt=typeof window>"u"?!1:Qs()??Zs()??ea()??!1),Rt}function ta(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var J={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},Im=Object.values(J),Tm=[J.canvasPainted,J.canvasSettled,J.appVisible,J.editorVisible],na=5e3,ra=3e3,er="diagnosticsStore",tt,Fe;function tr(){return{marks:new Qn(na),resources:new Qn(ra)}}function pi(){if(Fe)return Fe;const e=Cn();return e?(Fe=e[er]??tt??tr(),e[er]=Fe,tt=void 0,Fe):(tt??=tr(),tt)}function z(e,t){$e()&&pi().marks.push({phase:e,at:Ws(),...t})}function Cn(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[ta()];return e!==null&&typeof e=="object"?e:void 0}function ia(e){const t=e.length,n=pi();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function oa(){const e=Cn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:ia(e.diagnosticsBuffer)}var sa="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Rn(){const e=new Error(sa);return e.name="DestroyedInstanceError",e}function tn(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const o=e,s=t;return o.length===s.length&&o.every((d,l)=>tn(d,s[l]))}const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&tn(e[o],t[o]))}function hi(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const d=t(s);o&&tn(i,d)||(i=d,o=!0,r(d))})},select(r){return hi(n,r)}};return n}function ke(...e){let t=e[0],n=e.length>0;const r=new Set,i={get(){return n?t:void 0},set(o){t=o,n=!0;for(const s of Array.from(r))s(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return hi(i,o)}};return i}var mi=class{http;constructor(e){this.http=e}app_init_create=(e,t={})=>this.http.request({path:"/app/v1/app_init",method:"POST",body:e,type:vs.UrlEncoded,...t})},gi=class{http;constructor(e){this.http=e}get_translations2=({file:e,...t},n={})=>this.http.request({path:`/translations/v1/${e}`,method:"GET",...n});get_translations3=({id:e,file:t,...n},r={})=>this.http.request({path:`/translations/v1/${t}/${e}`,method:"GET",...r})};function aa(e){return String(e||"").trim()||void 0}var la=class extends Z{deps;_app;_baseUrl;_appInit;_restBaseUrl;_prevApp;constructor(e){super(),this.deps=e,this.addDisposable(e.options.select(t=>this._slice(t)).watch(t=>this._start(t)))}get app(){return this._app}_slice(e){return Object.prototype.hasOwnProperty.call(e,"baseUrl")&&(this._baseUrl=aa(e.baseUrl)),Object.prototype.hasOwnProperty.call(e,"appInit")&&(this._appInit=e.appInit),{appInit:this._appInit,user:e.user,project:e.project,baseUrl:this._baseUrl,restBaseUrl:this.deps.resolveRestBaseUrl(this._baseUrl),standalone:this.deps.isStandalone()}}_start(e){if(this._restBaseUrl!==e.restBaseUrl&&(this._restBaseUrl=e.restBaseUrl,this.deps.setRestBaseUrl(e.restBaseUrl)),e.standalone)return;const t=e.appInit||this.deps.fallbackAppInit,n=Promise.resolve(t({baseUrl:e.baseUrl,user:e.user,project:e.project,prevApp:this._prevApp}));this._app=n,n.then(r=>{this._app===n&&(this._prevApp=r)},()=>{}),this.deps.publish(n)}},Pn=L("AppInitService");function da(e){return async()=>{const t=await e();return(await new mi(t).app_init_create({})).data}}function ca(e){e.injectFactory(Pn,()=>{const t=new la({options:e.getInstance(oe),isStandalone:()=>!!e.getInstance(he),resolveRestBaseUrl:n=>n?Xn(n):Xn()||void 0,setRestBaseUrl:n=>{e.getInstance(Fs)?.setOptions(n?{baseUrl:n}:{})},fallbackAppInit:da(()=>e.getInstanceAsync(ss)),publish:n=>{e.inject(Pe,n)}});return e.getInstance(F)?.addDisposable(t),t},!0)}var Dn=L("documentSession.emailDocuments");function Pt(e){return e?.getInstance(Dn)}var ua=L("RevisionServiceFlag");function fa(e){return e.getOrCreateInstance(ua,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function vi(e){return fa(e).isEnabled()}var pa=L("EmailRightsResolver");function ha(e,t){const n=e.getInstance(pa);return n?n(t):!0}var bi=L("EmailHistoryAvailabilityResolver");function ma(e){return e.getInstance(bi)!==void 0}async function ga(e){const t=e.getInstance(bi);if(!t)return!0;try{return await t()}catch{return!1}}var On={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},yi=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Ei=2e4,va=yi.reduce((e,t)=>e+On[t],0),_i=Ei+va+3e3;function ba(e){return yi.reduce((t,n)=>t+wi(n,e),0)}function wi(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:On[e]}function Si(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:_i}function Ii(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Ei}function Ti(e=_i){return e+3e3}var ya=()=>Ti();function Ea(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function _a(e){return t=>Ea(e.getOrCreateInstance(j.BEFORE_SAVE_EMAIL,()=>new pe).fire(t),ya())}function wa(e){return e!=null&&e!==""}var Sa;function wt(e,t){return Sa?.capture(e,t)}function Ia(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function nt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var re=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${nt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${nt(this.oldText)}")`:`(replace@${this.oldPosition} "${nt(this.oldText)}" with "${nt(this.newText)}")`}};function nr(e,t){return e===null||e.length===0?t:new Ta(e,t).compress()}var Ta=class se{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),i=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(i===null)break;this._acceptCurr(i),i=this._getCurr(++n);continue}if(i===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldEnd<=r.newPosition){this._acceptCurr(i),i=this._getCurr(++n);continue}if(r.newEnd<=i.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldPosition<r.newPosition){const[l,f]=se._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(l),i=f;continue}if(r.newPosition<i.oldPosition){const[l,f]=se._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(l),r=f;continue}let s,d;if(i.oldEnd===r.newEnd)s=r,d=i,r=this._getPrev(++t),i=this._getCurr(++n);else if(i.oldEnd<r.newEnd){const[l,f]=se._splitPrev(r,i.oldLength);s=l,d=i,r=f,i=this._getCurr(++n)}else{const[l,f]=se._splitCurr(i,r.newLength);s=r,d=l,r=this._getPrev(++t),i=f}this._result[this._resultLen++]=new re(s.oldPosition,s.oldText,d.newPosition,d.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=d.newLength-d.oldLength}const o=se._merge(this._result);return se._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=se._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=se._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new re(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new re(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),i=t.newText.substr(n);return[new re(t.oldPosition,t.oldText,t.newPosition,r),new re(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new re(t.oldPosition,r,t.newPosition,t.newText),new re(t.oldPosition+n,i,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,i=t[0];for(let o=1;o<t.length;o++){const s=t[o];i.oldEnd===s.oldPosition?i=new re(i.oldPosition,i.oldText+s.oldText,i.newPosition,i.newText+s.newText):(n[r++]=i,i=s)}return n[r++]=i,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o.oldText!==o.newText&&(n[r++]=o)}return n}};function Aa(e){return new re(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Ca(e){return e.map(Aa)}function rr(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Ra(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const i=t[r];n=n.slice(0,i.oldPosition)+i.newText+n.slice(i.oldEnd)}return n}function Pa(e,t,n){let r=0;const i=e.start===e.end;for(const o of t){const s=o.newLength-o.oldLength;if(o.oldLength===0){const d=o.oldPosition;if(i&&d===e.start)r+=n==="after"?s:0;else{if(e.start<d&&d<e.end)return null;d<=e.start&&(r+=s)}continue}if(i){if(e.start>=o.oldEnd)r+=s;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=s;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var gt=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},ir=0,Da=Math.random().toString(36).slice(2,8);function Oa(){return ir+=1,`doc-${Da}-${ir}`}function xa(e){const t=e.createBuffer(),n=e.docId??Oa();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const d=new Set;let l=!1,f=!1,u;const v=new Set;let b=null;const y=()=>(b?.version!==i&&(b={version:i,value:t.read()}),b.value),I=g=>Object.entries(g).some(([E,w])=>s[E]!==w);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:y,mutate(g,{source:E}){if(l)return i;const w=g.changes?.length?g.changes:void 0,S=w?Ra(y(),w):g.content!==void 0?g.content:void 0,A=S!==void 0&&S!==y(),h=g.attributes!==void 0&&I(g.attributes);if(!A&&!h)return i;const c=!(i>(o??-1));return A&&t.write(S),h&&(s={...s,...g.attributes}),i+=1,E!=="user"&&c&&(o=i),d.forEach(a=>a({source:E,version:i,changes:w})),i},markSaved(g,E){const w={serverId:r,savedVersion:o};E!==void 0&&(r=E),(o===null||g>o)&&(o=g),(w.serverId!==r||w.savedVersion!==o)&&d.forEach(S=>S({source:"system",version:i}))},markReady(){f||u!==void 0||(f=!0,v.forEach(g=>g.resolve()),v.clear(),d.forEach(g=>g({source:"system",version:i})))},isReady:()=>f,markFailed(g){f||u!==void 0||l||(u=g,v.forEach(E=>E.reject(new gt(g))),v.clear(),d.forEach(E=>E({source:"system",version:i})))},failure:()=>u,whenReady(){return f?Promise.resolve():u!==void 0?Promise.reject(new gt(u)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((g,E)=>{v.add({resolve:g,reject:E})})},subscribe(g){return d.add(g),()=>d.delete(g)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>l,dispose(){l=!0,v.forEach(g=>g.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),v.clear(),d.clear(),t.dispose()}}}var La=500,Ma=100,Dt=0;function ka(e,t={}){const n=t.groupIntervalMs??La,r=t.maxSteps??Ma,i=t.now??(()=>0);let o=[],s=0,d=Dt+=1,l=null,f=!1,u=!1,v=!1;const b=new Set,y=()=>b.forEach(a=>a()),I=(a,p)=>{if(a.length){u=!0;try{e.mutate({changes:a},{source:p})}finally{u=!1}}},g=a=>I(a,"user"),E=a=>{const p=i();f&&l!==null&&p-l<n?o[s-1]=nr(o[s-1],a):(o=o.slice(0,s),o.push(a),s=o.length,f=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,d=Dt+=1)),l=p,y()},w=()=>{f=!1,l=null},S=a=>{if(!a.length)return;const p=o.length>s;p&&(o=o.slice(0,s)),s>0&&(o[s-1]=nr(o[s-1],a)),w(),p&&y()},A=e.subscribe(({source:a,changes:p})=>{if(!(v||u||!p?.length)){if(a==="remote"){h();return}if(a!=="user"){S(p);return}E(p)}}),h=()=>{o=[],s=0,w(),d=Dt+=1,y()},c=()=>{if(s===0)return!1;const a=Ca(o[s-1]);return rr(e.getContent(),a)?(g(a),s-=1,w(),!0):(o=o.slice(0,s-1),s=o.length,w(),y(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){c()&&y()},redo(){if(!(s>=o.length)){if(!rr(e.getContent(),o[s])){o=o.slice(0,s),w(),y();return}g(o[s]),s+=1,w(),y()}},clear:h,applyWithoutHistory(a){const p=e.get().version;if(I(a,"system"),e.get().version===p){w();return}S(a)},getPast:a=>o.slice(0,s).reverse().slice(0,a),getFuture:a=>o.slice(s).reverse().slice(0,a),createSnapshot:()=>({stackId:d,index:s}),restoreSnapshot(a){if(a.stackId!==d||a.index>s)return!1;for(;s>a.index;)if(!c())return y(),!1;return y(),!0},subscribe(a){return b.add(a),()=>b.delete(a)},dispose(){v=!0,A(),b.clear(),o=[],s=0}}}var Na=["edit","move","resize","insert"];function Ot(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Fa(e){return typeof e=="string"?e:null}function ja(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Ba(e){return Na.includes(e)?e:null}function Ua(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Fa(t.originId),changeId:Ot(t.changeId),rev:Ot(t.rev),baseRev:Ot(t.baseRev),expected:ja(t.expected),intent:Ba(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var or=class extends Error{reason;constructor(e){super(`сохранение не состоялось: ${e}`),this.name="SaveRefusedError",this.reason=e}},Ai="draft";function je(e){return e==null||e===""?Ai:String(e)}function Ha(e){return e==null||e===""?`${nn}${Ai}`:`${nn}${String(e)}`}var nn="block:";function me(e){return e?.startsWith(nn)===!0}function Be(e){return me(e.sessionKey())?void 0:e.current()}function He(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return z(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(z(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw`${e}`,{error:String(i),...n},i})}function Ci(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Ri(e,{freshSince:t}={}){return!(!e?.slug?.includes("autosave")||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Ga(e,t={}){const n=Ci((e??[]).filter(r=>r?.html?.trim()));return Ri(n,t)?n:null}function qa(e){const t=Date.parse(Ci(e)?.modified??"");return{autosave:Ga(e),...Number.isFinite(t)?{latestAt:t}:{}}}function $a({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Pi=e=>e.replace(/\r\n?/g,`
|
|
997
|
+
`),sr=["recovery","plugin","rest"],za=["subject","preheader"];function Va(e){let t={},n;for(let i=sr.length-1;i>=0;i--){const o=e.get(sr[i]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const i of za){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Di(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Pi(t.content):void 0,i=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...i?{changes:[new re(0,n,0,r)]}:{}},{source:"remote"})}var ar=e=>typeof e=="string"?e.trim():"";function Ka(e,t,n){const{version:r,attributes:i}=e.get(),o=i,s=ar(o.title)||ar(o.subject);return{version:r,payload:{html:e.getContent(),title:s,subject:o.subject,preheader:o.preheader,description:o.description,common_styles:o.common_styles||"",meta:o.meta,utm_parameters:o.utm_parameters,parent_email:o.parent_email,is_template:o.is_template||!1,is_inited:o.is_inited,tags:o.tags,emailtags:o.emailtags,group:o.group,renderGuid:e.get().docId,project:t.project??o.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source}}}async function Wa(e,t,n,r,i){if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(i);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,i):t.saveAutosave(r,i)}function ge(e,t=!1){const n={};for(const r of Object.keys(e)){let i=e[r];i!==void 0&&!(typeof i=="number"&&Number.isNaN(i))&&(t&&typeof i=="object"&&i!==null&&(i=ge(i)),n[r]=i)}return n}var Ya=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Oi(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Ya.has(t))):{}}function vt(e,t,n={}){e&&e.mutate({attributes:Xa(e.get().attributes,t)},{source:n.source??"user"})}function Xa(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function xn(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Ja(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function xi(e){if(!e)return null;const t=Oi(e);return e.common_styles!==void 0&&(t.common_styles=Ja(e.common_styles)),xn(e.html,t)}function Li(e){return e?xn(e.html,ge(Oi(e))):null}var Qa=["common_styles","subject","preheader","meta"];function lr(e){if(!e?.html?.trim())return null;const t={};for(const n of Qa)Za(n,e[n])&&(t[n]=e[n]);return xn(e.html,t)}function Za(e,t){return e==="common_styles"?typeof t=="string"&&t.startsWith("{"):e==="meta"?typeof t=="object"&&t!==null&&!Array.isArray(t):typeof t=="string"}var el=10,tl=(e,t)=>e.key===t.key&&nl(e.serverId,t.serverId),nl=(e,t)=>e==null||e===t;function rl(e){return typeof e?.then=="function"}var dr=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Mi=e=>{e.request.serverId!=null&&e.document.markSaved(e.document.get().version)},il=e=>{Di(e.document,Va(e.reports)),Mi(e)},xt=(e,t)=>{if(!e.ready){il(e);return}Di(e.document,t)},ol=e=>{const{attributes:t,serverId:n,docId:r}=e.document.get();return{...t,html:e.document.getContent(),id:n??void 0,isNew:n==null,renderGuid:r}};function sl(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:d,onAdapterError:l,onTimeout:f}=e;let u;const v=new Set,b=new Set,y=()=>v.forEach(m=>m()),I=(m,_)=>{if(!(m.closed||m.ready)){if(m.error!==void 0){m.document.markFailed(m.error),m.document.get().docId;return}Mi(m),m.ready=!0,m.document.markReady(),m.document.get().docId,[...m.reports.keys()]}},g=(m,_,T)=>{l?.(_.id,T),!(!_.required||m.closed)&&(m.error=T,m.document.get().docId,_.id,y())},E=(m,_)=>{const T=new Set(_.map(C=>C.id));_.forEach(C=>{C.watch&&m.watchers.push(C.watch(x=>m.closed?!1:m.ready&&x?.content!==void 0&&$a({hasUnsavedUserEdit:m.document.isDirty()})==="skip"?(m.document.get().docId,C.id,!1):(x&&m.reports.set(C.id,x),xt(m,x),!0)))});const D=(C,x)=>{m.closed||(x&&m.reports.set(C.id,x),xt(m,x))},R=()=>{T.size>0||m.closed||(dr(m),I(m,[]))},O=[];if(_.forEach(C=>{let x;try{x=C.load()}catch(B){g(m,C,B),T.delete(C.id);return}if(rl(x)){O.push({id:C.id,required:C.required,load:()=>x});return}D(C,x),T.delete(C.id)}),O.length===0){R();return}m.timer=setTimeout(()=>{m.timer=void 0,f?.([...T]),m.document.get().docId,[...T],I(m,[...T])},n),m.timer.unref?.(),O.forEach(C=>{C.load().then(x=>D(C,x)).catch(x=>{g(m,C,x)}).finally(()=>{T.delete(C.id),R()})})},w=async(m,_,T)=>{if(T==="snapshot"||T==="anchor")return;const D=o?.();if(D)return D.resolve({project:_.project??m.project,tags:(m.tags??[]).map(R=>({name:R}))})},S=m=>{if(m.lock===!0&&s?.(m)===!1)return new or("locked");const _=m.tags?.length??0,T=m.emailtags?.length??0;if(Math.max(_,T)>el)return new or("too-many-tags")},A=async(m,_,T)=>{try{await m.document.whenReady()}catch(x){return m.saveError=x,m.saveFailures+=1,m.saveFailures,!1}if(m.closed)return!1;const D=S(m.document.get().attributes);if(D)return m.saveError=D,m.saveFailures+=1,D.reason,y(),!1;if(d&&(await d(ol(m)).catch(()=>{}),m.closed))return!1;let R;try{R=await w(m.document.get().attributes,T,_)}catch(x){return m.saveError=x,m.saveFailures+=1,m.saveFailures,y(),!1}if(m.closed)return!1;const{payload:O,version:C}=Ka(m.document,T,R);m.document.get().docId;try{const x=m.document.get().serverId!=null,B=await Wa(r(),i(m.request.key),_,m.document.get().serverId,O);if(m.closed)return!0;let U;if(_==="snapshot"||_==="anchor"){const M=B?.modified!=null?Date.parse(B.modified):NaN;U=Number.isFinite(M)?M:Date.now(),m.snapshotVersion=C,m.lastRevisionAt=U}else m.document.markSaved(C,B?.id!=null?String(B.id):void 0);const W=m.document.get().serverId;!x&&W!=null&&(m.recoveryFacts={emailId:W,historyLoaded:!0,isRecovering:!1}),m.saveError=void 0,m.saveFailures=0,m.document.get().serverId,y();const de={intent:_,serverId:m.document.get().serverId,created:!x,...U!==void 0?{revisionAt:U}:{}};return b.forEach(M=>M(de)),!0}catch(x){return m.saveError=x,m.saveFailures+=1,m.saveFailures,y(),!1}},h=()=>{u&&(u.closed=!0,u.watchers.forEach(m=>m()),u.watchers=[],dr(u),u.history.dispose(),u.document.dispose(),u=void 0)},c=(m,_,T)=>{let D=!1;_.show&&(m.show?.id!==_.show.id||m.show.token!==_.show.token)&&(m.show=_.show,D=!0,{docId:m.document.get().docId,..._.show});const R=T==="show"?Li(_.patch):null;R&&(m.reports.set("plugin",R),xt(m,R)),D&&y()},a=(m,_={})=>{const T=u;return!T||T.closed?Promise.resolve(!1):T.saving?m==="snapshot"?Promise.resolve(!1):(T.inFlight??Promise.resolve(!1)).then(()=>a(m,_)):(T.saving=!0,T.inFlight=A(T,m,_).finally(()=>{T.saving=!1,T.inFlight=void 0}),T.inFlight)},p=(m,_="open")=>{if(u&&!u.closed&&_!=="new"&&tl(u.request,m))return c(u,m,_),u.document;h();const T=xa({createBuffer:()=>Ia(""),serverId:m.serverId??null}),D={request:m,show:m.show,document:T,history:ka(T,{now:Date.now}),watchers:[],saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return u=D,T.get().docId,m.serverId,E(D,t(m,{publishRecoveryFacts(R){D.closed||(D.recoveryFacts=R,y())},readShownContent:()=>D.closed?null:D.document.getContent()})),y(),T};return{openWith:p,open:(m,_={})=>p({key:je(m),serverId:m,email:_.email,patch:_.patch,show:_.show},"open"),openDraft:(m,_={})=>p({key:je(void 0),serverId:null,email:m,patch:_.patch,show:_.show},"open"),startNewDraft:(m,_={})=>p({key:je(void 0),serverId:null,email:m,patch:_.patch,show:_.show},"new"),reload:(m,_={})=>p({key:je(m),serverId:m,email:_.email,patch:_.patch,show:_.show},"new"),openBlock:(m,_)=>p({key:me(m)?m:Ha(m),serverId:_?.id!=null?String(_.id):null,email:_},"open"),show:(m,_)=>{const T=u;if(!(!T||T.closed))return p({...T.request,patch:m,show:_},"show")},current:()=>u?.document,save:a,saveState:()=>({error:u?.saveError,failures:u?.saveFailures??0,saving:u?.saving===!0}),revisionFacts(){if(!u)return;const m=u.revisionFactsSnapshot;return m&&m.snapshotVersion===u.snapshotVersion&&m.lastRevisionAt===u.lastRevisionAt?m:(u.revisionFactsSnapshot={snapshotVersion:u.snapshotVersion,lastRevisionAt:u.lastRevisionAt},u.revisionFactsSnapshot)},recoveryFacts:()=>u?.recoveryFacts,history:()=>u?.history,forcedHeaders:()=>u?.forcedHeaders,beginForcedHeaders(m){u&&!u.closed&&(u.forcedHeaders=m)},endForcedHeaders(){u&&(u.forcedHeaders=void 0)},onSaved(m){return b.add(m),()=>b.delete(m)},showFacts:()=>u?.show,sessionKey:()=>u?.request.key,openError:()=>u?.error,subscribe(m){return v.add(m),()=>v.delete(m)},close(){u&&(h(),y())}}}var ki=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Ni(e){if(e instanceof ki)return e.reason;if(e instanceof gt)return Ni(e.reason)}function al(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new ki("not-found");return xi(n)}}}var Fi=L("EmailPort");function ll(e){return e.getInstance(Fi)}function dl(e,t){e.inject(Fi,t)}var ji=L("documentSession.restEmailPortFactories");function Bi(e){return e.getInstance(ji)!==void 0}function Se(e){const t=e.getInstance(ji);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var cl=L("EmailTermsResolver");function ul(e){return e.getInstance(cl)}var Ui=L("EmailHistoryPort"),fl=L("BlockHistoryPort");function Hi(e){return e.getInstance(fl)}function Gi(e){return e.getInstance(Ui)}function pl(e,t){e.inject(Ui,t)}var hl="em_autosave_pending";function bt(e){return`${hl}_${e}`}function ml(e,t){try{sessionStorage.setItem(bt(e),JSON.stringify(t))}catch{}}function gl(e){try{const t=sessionStorage.getItem(bt(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(bt(e)),null):n}catch{return null}}function rt(e){try{sessionStorage.removeItem(bt(e))}catch{}}var vl=2e3,bl=5e3,yl=5,El=5e3,_l=4;function wl(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Sl(e,t){return e==null||t==null?!1:e.replaceAll(`\r
|
|
998
998
|
`,`
|
|
999
999
|
`)===t.replaceAll(`\r
|
|
1000
1000
|
`,`
|
|
1001
|
-
`)}function Tl({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:d,pageLoadTs:l=Sl()}){let f=null,u=!1,v=!1,b=0,E={emailId:e,historyLoaded:!1,isRecovering:!1},I=null;const g=new Promise(R=>{I=R}),y=R=>{E={...E,...R},o(E)},w=R=>{b+=1,y({applied:{phase:R,seq:b}})},S=()=>{f?.timer&&clearTimeout(f.timer),f=null},A=R=>{if(!v){if(I){const O=I;I=null,O(R),R.revision&&w(R.phase);return}s(R)&&R.revision&&w(R.phase)}},h=()=>{if(!f||v)return;const R=f.phase==="fast",O=R?bl:_l,z=R?yl:wl;f.timer=setTimeout(()=>{const B=f;if(!(!B||v)){if(B.attempts+=1,_(),R&&B.attempts>=z){const{pending:W}=B;nt(e),y({isRecovering:!1}),A({revision:{html:W.html,common_styles:W.common_styles,subject:W.subject,preheader:W.preheader},phase:"timeout"}),u=!0,B.phase="bg",B.attempts=0,h();return}if(!R&&B.attempts>=z){nt(e),S(),y({isRecovering:!1}),u=!0;return}h()}},O),f.timer.unref?.()},c=R=>{f={phase:"fast",attempts:0,pending:R,timer:null},y({isRecovering:!0}),h()},a=(R,O)=>Pi(R.autosave,O===void 0?{}:{freshSince:O})?R.autosave:null,p=R=>{if(v)return;if(y({historyLoaded:!0,latestRevisionAt:R.latestAt!==void 0&&Number.isFinite(R.latestAt)?R.latestAt:void 0}),n&&f){const B=a(R,f.pending.sentAt);if(!B)return;const W=f.phase==="fast"?"found":"bg";nt(e),S(),y({isRecovering:!1}),u=!0,A({revision:B,phase:W});return}if(u)return;const O=n?vl(e):null,z=O&&(O.sentAt<l||!Il(O.html,i()))?O:null;if(z){const B=a(R,z.sentAt);if(B){nt(e),u=!0,A({revision:B,phase:"found"});return}c(z);return}u=!0,A({revision:a(R),phase:"normal"})},m=R=>{v||(d?.(R),E.historyLoaded||(y({historyLoaded:!1,latestRevisionAt:void 0}),P()),!f&&A({revision:null,phase:"normal"}))},_=()=>t(e).then(p).catch(m);let T,C=!1;const P=()=>{C||f||v||(C=!0,T=setTimeout(()=>{T=void 0,!v&&!E.historyLoaded&&_()},El))},j=()=>{v||(y({historyLoaded:!1,latestRevisionAt:void 0}),A({revision:null,phase:"normal"}))};return r?r().then(R=>R?_():j()):_(),{verdict:()=>g,dispose(){v=!0,T!==void 0&&(clearTimeout(T),T=void 0),S()}}}function Al({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const d=Tl({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:l,phase:f})=>{const u=or(l);return s?.(u)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:l})=>or(l)),watch(l){return s=l,()=>{s=null,d.dispose()}}}}function $i(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){gl(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 Cl(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 zi=x("CurrentUser"),Vi={};function Ki(e){return e.getOrCreateInstance(zi,()=>Me(Vi))}function Wi(e){return e?.getInstance(zi)?.get()??Vi}function Yi(e){return e?.getInstance(we)?.get()??{}}var Rl=1.5;function Pl(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<=Rl*e.autosaveTimeoutMs?"none":"revision"}var Dl=4;function Ol(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=()=>n().autosaveTimeoutMs*2**Math.min(o(),Dl),d=()=>{const w=t();if(!w||w.isDisposed())return"none";const{latestRevisionAt:S,snapshotVersion:A,...h}=n();return Pl({...h,isDirty:w.isDirty(),isNew:w.isNew(),isReady:w.isReady(),latestRevisionAgeMs:S!=null?Date.now()-S:void 0,isSnapshotSent:A!=null&&A===w.get().version})},l=()=>{const w=t();if(!w||w.isDisposed())return!1;if(!w.isDirty())return w.isNew();const{snapshotVersion:S}=n();return!(S!=null&&S===w.get().version)};let f,u,v,b,E=!1;const I=()=>{u=void 0;const w=t();if(!w||w.isDisposed())return;if(w.get().docId!==f){g();return}const S=d();S==="create"?r():S==="revision"?i():l()&&(f=w.get().docId,u=setTimeout(I,s()))},g=()=>{const w=t();E||!w||u!==void 0||d()==="none"&&!l()||(f=w.get().docId,u=setTimeout(I,s()))},y=()=>{const w=t();w!==v&&(b?.(),v=w,b=w?.subscribe(g),u!==void 0&&(clearTimeout(u),u=void 0))};return y(),g(),{refresh:()=>{E||(y(),g())},stop:()=>{E=!0,b?.(),b=void 0,v=void 0,u!==void 0&&(clearTimeout(u),u=void 0)}}}var Xi=x("documentSession.autosaveUiFacts"),Ji={isUserBusy:!1,saveContext:{}};function xl(e){return e.getOrCreateInstance(Xi,()=>Me(Ji))}function ar(e){return e?.getInstance(Xi)?.get()??Ji}var Ll=1e4;function Ml(e,t){const n=()=>{const l=t.current(),f=l?.get().serverId??void 0,u=me(t.sessionKey()),v=t.recoveryFacts(),b=v?.emailId===f?v:void 0,E=t.revisionFacts(),I=b?.latestRevisionAt,g=E?.lastRevisionAt,y=Wi(e).profile;return{isInited:u||l?.get().attributes.is_inited===!0,isEnabled:!!y?.autosaves,isHistoryLoaded:b?.historyLoaded===!0,isUserBusy:ar(e).isUserBusy,autosaveTimeoutMs:Yi(e).autosaveTimeout||Ll,latestRevisionAt:I!==void 0||g!==void 0?Math.max(I??0,g??0):void 0,snapshotVersion:E?.snapshotVersion}},r=()=>{const l=ar(e).saveContext;return{...l,project:l.project??t.current()?.get().attributes.project}},i=Ol({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=Ki(e).watch(()=>i.refresh()),d=xl(e).watch(()=>i.refresh());return()=>{o(),s.dispose(),d.dispose(),i.stop()}}var lr=12e3;function ve(e){return e.getOrCreateInstance(Cn,()=>{const t=al({resolveAdapters:(r,i)=>Fl(r,e,i),resolveWritePort:()=>Qi(e),resolveHistoryPort:r=>me(r)?eo(e):Zi(e),resolveTerms:()=>fl(e),canEdit:r=>ma(e,r),notifyBeforeSave:wa(e),timeoutMs:lr,onAdapterError:(r,i)=>{i instanceof Error&&i.message,yt(i,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=Ml(e,t);return e.getInstance(N)?.addDispose(n),t})}function Dn(e){return e?.getInstance(Cn)}function Qi(e){const t=dl(e);return t?On(e)?Cl(t,Se(e).email(e)):t:Se(e).email(e)}function kl(e){return qi(e)!==void 0||Ui(e)}function Zi(e){const t=qi(e);return t?On(e)?($("port:history:server-backed"),$i(t,Se(e).history(e))):($("port:history:integrator"),t):($("port:history:rest (порт не зарегистрирован)"),Se(e).history(e))}function eo(e){const t=Gi(e);return t?On(e)?($("port:block-history:server-backed"),$i(t,Se(e).blockHistory(e))):($("port:block-history:integrator"),t):($("port:block-history:rest (порт не зарегистрирован)"),Se(e).blockHistory(e))}function Nl(e){return Gi(e)!==void 0||Ui(e)}function On(e){return bi(e)}function Fl({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>Li(e),required:!0}):n&&s.push(ll(Qi(i),n)),t&&s.push({id:"plugin",load:()=>Mi(t)});const d=me(r);return Sa(n)&&(d?Nl(i):kl(i))&&s.push(Al({port:d?eo(i):Zi(i),revisionServiceEnabled:bi(i),...!d&&ga(i)?{isHistoryAvailable:()=>va(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),s}function X(e){return e.getOrCreateInstance(We,()=>new Ye)}var to=new WeakMap,en=new WeakMap;function ue(e){return to.get(e)??0}function no(e,t){let n=en.get(e);return n||(n=new Set,en.set(e,n)),n.add(t),()=>{n?.delete(t)}}function jl(e){to.set(e,ue(e)+1),en.get(e)?.forEach(t=>t())}function Bl(e){const t=ve(e),n=X(e).addListener(k.APPLICATION_HAS_AMP,r=>{je(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(N)?.addDispose(()=>n.dispose())}function Ul(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Hl(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 Ul(l)?l:void 0}catch{return}}}}var _e={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Gl(e){const t={maxBytes:e.maxBytes??_e.maxBytes,maxImageBytes:e.maxImageBytes??_e.maxImageBytes,ttlMs:e.ttlMs??_e.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const d=v=>{const b=r.get(v);b&&(s-=b.bytes,r.delete(v))},l=v=>t.ttlMs<=0||n()-v.storedAt<t.ttlMs,f=()=>{if(s<=t.maxBytes)return;const v=[...r.entries()].sort((b,E)=>b[1].usedAt-E[1].usedAt);for(const[b]of v){if(s<=t.maxBytes)return;d(b)}},u=(v,b)=>{b.size>t.maxImageBytes||(r.set(v,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,f())};return{async get(v){const b=r.get(v);if(b&&l(b))return b.usedAt=n(),o.hits+=1,b.blob;b&&d(v);const E=i.get(v);if(E!==void 0)return E;o.loads+=1;const I=(async()=>{try{const g=await e.load(v);return g?u(v,g):o.failures+=1,g}catch{o.failures+=1;return}finally{i.delete(v)}})();return i.set(v,I),I},forget(v){d(v),i.delete(v)},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var ql=["emcdn.ru","scr.emcdn.ru"];function $l(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 zl(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const d=$l(s);d&&o.add(d)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function dr(e){const t=e??{},n=t.isPlugin!==!0?ql:[],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:zl(i.sourceHosts,n),maxBytes:i.maxBytes??_e.maxBytes,maxImageBytes:i.maxImageBytes??_e.maxImageBytes,ttlMs:i.ttlMs??_e.ttlMs}}function Vl(e){const t=X(e),n=e.getInstance(we);let r=dr(n?.get());const i=Hl({sourceHosts:()=>r.sourceHosts}),o=Gl({load:I=>i.load(I),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),s=()=>{t.send(k.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},d=t.onInit(()=>s()),l=n?.watch(()=>{const I=dr(n.get()),g=JSON.stringify(I)!==JSON.stringify(r);r=I,I.enabled||o.clear(),g&&t.isInited()&&s()}),f={asked:0,served:0,refused:0},u=[],v=(I,g)=>(f.refused+=1,u.push({url:I,reason:g}),u.length>20&&u.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...f},refusals:[...u],store:o.stats()})}),E=t.addListenerAsync(k.APPLICATION_CANVAS_IMAGE_GET,async I=>{const g=I?.url??"";if(f.asked+=1,!r.enabled||!g)return v(g,"disabled");if(!i.accepts(g))return v(g,"host");I.fresh&&o.forget(g);const y=await o.get(g);return y?(f.served+=1,{blob:y}):v(g,"load-failed")});e.getInstance(N)?.addDispose(()=>{d.dispose(),l?.dispose(),E.dispose(),o.clear(),delete b.__emmCanvasImages__})}var Kl=2e3;function Wl(e){const t=X(e),n=new Set,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;const d=new MessageChannel;let l=!1;const f=v=>{v.data?.operationId==="em:port-ready"&&(l=!0,d.port1.removeEventListener("message",f),t.drainWindow(s))};d.port1.addEventListener("message",f),t.sendPort(s,d.port2),t.usePort(d.port1,!1,s);const u=setTimeout(()=>{n.delete(u),!l&&(yt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d.port1.removeEventListener("message",f),t.useWindow(s))},Kl);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(N)?.addDispose(()=>{for(const s of n)clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var Yl=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Xl(e){return Yl.test(e)||e.indexOf("//")===0}function rt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Jl(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function cr(e,t){const n=e==null||e===""?"./":String(e);if(Xl(n))return rt(n);const r=t??Jl();if(!r)return rt(n);try{return rt(new URL(n,r).href)}catch{return rt(n)}}function Ql(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?cr(window.__useblocks__.publicPath):cr("/")}var Zl=()=>"",ed=()=>"d62ebebc";function ro(e){const t=e?"iframe-eblock":"iframe",n=Zl();if(n){const o=n.replace(/\/?$/,"/");return Xn(`${o}${t}.html`,qe())}const r=ed(),i=`${Ql().replace(/\/?$/,"/")}iframe/`;return Xn(`${i}${t}${r?`.${r}`:""}.html`,qe())}var ur="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function tn(e){return/^file:/i.test(String(e||"").trim())}function td(e){return tn(e)?`${ur} allow-same-origin`:ur}var nd="em:module-body-ack";function rd(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 xn(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 id(e,t){const n=xn(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 od(e,t){const n=xn(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 sd(e){try{const t=await fetch(e);return t.ok?await t.blob():void 0}catch{return}}function ad(e){const t=new Map,n=r=>{const i=rd(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 ld(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(id(o,e))}catch{}}function dd(e){try{return tn(new URL(e,window.location.href).href)}catch{return tn(window.location.href)}}function cd(e){X(e);const t=ro(!1);if(dd(t))return;const n=ad({canvasSrc:t,origin:window.location.href,fetchBody:sd}),r=xn(t);r&&n.warm([r]);const i={"js/iframe-eblock.js":["js/discussHandlers.Ced_gtP0.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.Ced_gtP0.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.Ced_gtP0.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(od(i,t)):ld(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:nd,for:d.result},"*"),n.take(d.data?.url??"").then(f=>{l.postMessage({operationId:d.result,data:f??null},"*")}))};window.addEventListener("message",o),e.getInstance(N)?.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,ud=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Oe=/<style\b[^>]*>[\s\S]*?<\/style>/gi,fr=/display:\s*none\s*!important/gi,fd=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,pd=/\s*height\s*:\s*100%\s*!important\s*;?/gi,hd=/height\s*:\s*100%\s*!important/i,md=[".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 gd(e){return fr.lastIndex=0,(e.match(fr)||[]).length}function io(e){const t=e.trim(),n=gd(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=md.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 vd(e){Oe.lastIndex=0;for(const t of e.matchAll(Oe))if(io(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function bd(e){let t=!1;return Oe.lastIndex=0,{html:e.replace(Oe,n=>io(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Ed(e){return Ae.lastIndex=0,Ae.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||vd(e)}function yd(e){if(!Ed(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(ud,""),t=!0);const r=bd(n);return n=r.html,t=t||r.found,{html:n,found:t}}function _d(e){return!e||!hd.test(e)?e:(Oe.lastIndex=0,e.replace(Oe,t=>t.replace(fd,(n,r,i,o)=>`${r}${i.replace(pd,"")}${o}`)))}function oo(e){const t=yd(e.replaceAll(`\r
|
|
1001
|
+
`)}function Il({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:d,pageLoadTs:l=wl()}){let f=null,u=!1,v=!1,b=0,y={emailId:e,historyLoaded:!1,isRecovering:!1},I=null;const g=new Promise(C=>{I=C}),E=C=>{y={...y,...C},o(y)},w=C=>{b+=1,E({applied:{phase:C,seq:b}})},S=()=>{f?.timer&&clearTimeout(f.timer),f=null},A=C=>{if(!v){if(I){const x=I;I=null,x(C),C.revision&&w(C.phase);return}s(C)&&C.revision&&w(C.phase)}},h=()=>{if(!f||v)return;const C=f.phase==="fast",x=C?vl:El,B=C?yl:_l;f.timer=setTimeout(()=>{const U=f;if(!(!U||v)){if(U.attempts+=1,_(),C&&U.attempts>=B){const{pending:W}=U;rt(e),E({isRecovering:!1}),A({revision:{html:W.html,common_styles:W.common_styles,subject:W.subject,preheader:W.preheader},phase:"timeout"}),u=!0,U.phase="bg",U.attempts=0,h();return}if(!C&&U.attempts>=B){rt(e),S(),E({isRecovering:!1}),u=!0;return}h()}},x),f.timer.unref?.()},c=C=>{f={phase:"fast",attempts:0,pending:C,timer:null},E({isRecovering:!0}),h()},a=(C,x)=>Ri(C.autosave,x===void 0?{}:{freshSince:x})?C.autosave:null,p=C=>{if(v)return;if(E({historyLoaded:!0,latestRevisionAt:C.latestAt!==void 0&&Number.isFinite(C.latestAt)?C.latestAt:void 0}),n&&f){const U=a(C,f.pending.sentAt);if(!U)return;const W=f.phase==="fast"?"found":"bg";rt(e),S(),E({isRecovering:!1}),u=!0,A({revision:U,phase:W});return}if(u)return;const x=n?gl(e):null,B=x&&(x.sentAt<l||!Sl(x.html,i()))?x:null;if(B){const U=a(C,B.sentAt);if(U){rt(e),u=!0,A({revision:U,phase:"found"});return}c(B);return}u=!0,A({revision:a(C),phase:"normal"})},m=C=>{v||(d?.(C),y.historyLoaded||(E({historyLoaded:!1,latestRevisionAt:void 0}),R()),!f&&A({revision:null,phase:"normal"}))},_=()=>t(e).then(p).catch(m);let T,D=!1;const R=()=>{D||f||v||(D=!0,T=setTimeout(()=>{T=void 0,!v&&!y.historyLoaded&&_()},bl))},O=()=>{v||(E({historyLoaded:!1,latestRevisionAt:void 0}),A({revision:null,phase:"normal"}))};return r?r().then(C=>C?_():O()):_(),{verdict:()=>g,dispose(){v=!0,T!==void 0&&(clearTimeout(T),T=void 0),S()}}}function Tl({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const d=Il({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:l,phase:f})=>{const u=lr(l);return s?.(u)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:l})=>lr(l)),watch(l){return s=l,()=>{s=null,d.dispose()}}}}function qi(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){ml(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function Al(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=await t.updateEmail(n,r);return await e.updateEmail(n,r),i}}}var $i=L("CurrentUser"),zi={};function Vi(e){return e.getOrCreateInstance($i,()=>ke(zi))}function Ki(e){return e?.getInstance($i)?.get()??zi}function Wi(e){return e?.getInstance(we)?.get()??{}}var Cl=1.5;function Rl(e){return!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=Cl*e.autosaveTimeoutMs?"none":"revision"}var Pl=4;function Dl(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=()=>n().autosaveTimeoutMs*2**Math.min(o(),Pl),d=()=>{const w=t();if(!w||w.isDisposed())return"none";const{latestRevisionAt:S,snapshotVersion:A,...h}=n();return Rl({...h,isDirty:w.isDirty(),isNew:w.isNew(),isReady:w.isReady(),latestRevisionAgeMs:S!=null?Date.now()-S:void 0,isSnapshotSent:A!=null&&A===w.get().version})},l=()=>{const w=t();if(!w||w.isDisposed())return!1;if(!w.isDirty())return w.isNew();const{snapshotVersion:S}=n();return!(S!=null&&S===w.get().version)};let f,u,v,b,y=!1;const I=()=>{u=void 0;const w=t();if(!w||w.isDisposed())return;if(w.get().docId!==f){g();return}const S=d();S==="create"?r():S==="revision"?i():l()&&(f=w.get().docId,u=setTimeout(I,s()))},g=()=>{const w=t();y||!w||u!==void 0||d()==="none"&&!l()||(f=w.get().docId,u=setTimeout(I,s()))},E=()=>{const w=t();w!==v&&(b?.(),v=w,b=w?.subscribe(g),u!==void 0&&(clearTimeout(u),u=void 0))};return E(),g(),{refresh:()=>{y||(E(),g())},stop:()=>{y=!0,b?.(),b=void 0,v=void 0,u!==void 0&&(clearTimeout(u),u=void 0)}}}var Yi=L("documentSession.autosaveUiFacts"),Xi={isUserBusy:!1,saveContext:{}};function Ol(e){return e.getOrCreateInstance(Yi,()=>ke(Xi))}function cr(e){return e?.getInstance(Yi)?.get()??Xi}var xl=1e4;function Ll(e,t){const n=()=>{const l=t.current(),f=l?.get().serverId??void 0,u=me(t.sessionKey()),v=t.recoveryFacts(),b=v?.emailId===f?v:void 0,y=t.revisionFacts(),I=b?.latestRevisionAt,g=y?.lastRevisionAt,E=Ki(e).profile;return{isInited:u||l?.get().attributes.is_inited===!0,isEnabled:!!E?.autosaves,isHistoryLoaded:b?.historyLoaded===!0,isUserBusy:cr(e).isUserBusy,autosaveTimeoutMs:Wi(e).autosaveTimeout||xl,latestRevisionAt:I!==void 0||g!==void 0?Math.max(I??0,g??0):void 0,snapshotVersion:y?.snapshotVersion}},r=()=>{const l=cr(e).saveContext;return{...l,project:l.project??t.current()?.get().attributes.project}},i=Dl({readDocument:()=>t.current(),readEnvironment:n,readFailures:()=>t.saveState().failures,onCreate:()=>{me(t.sessionKey())||t.save("materialize",r())},onRevision:()=>{t.save("snapshot",{project:r().project})}}),o=t.subscribe(i.refresh),s=Vi(e).watch(()=>i.refresh()),d=Ol(e).watch(()=>i.refresh());return()=>{o(),s.dispose(),d.dispose(),i.stop()}}var ur=12e3;function ve(e){return e.getOrCreateInstance(Dn,()=>{const t=sl({resolveAdapters:(r,i)=>Nl(r,e,i),resolveWritePort:()=>Ji(e),resolveHistoryPort:r=>me(r)?Zi(e):Qi(e),resolveTerms:()=>ul(e),canEdit:r=>ha(e,r),notifyBeforeSave:_a(e),timeoutMs:ur,onAdapterError:(r,i)=>{i instanceof Error&&i.message,wt(i,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=Ll(e,t);return e.getInstance(F)?.addDispose(n),t})}function Ln(e){return e?.getInstance(Dn)}function Ji(e){const t=ll(e);return t?Mn(e)?Al(t,Se(e).email(e)):t:Se(e).email(e)}function Ml(e){return Gi(e)!==void 0||Bi(e)}function Qi(e){const t=Gi(e);return t?Mn(e)?(z("port:history:server-backed"),qi(t,Se(e).history(e))):(z("port:history:integrator"),t):(z("port:history:rest (порт не зарегистрирован)"),Se(e).history(e))}function Zi(e){const t=Hi(e);return t?Mn(e)?(z("port:block-history:server-backed"),qi(t,Se(e).blockHistory(e))):(z("port:block-history:integrator"),t):(z("port:block-history:rest (порт не зарегистрирован)"),Se(e).blockHistory(e))}function kl(e){return Hi(e)!==void 0||Bi(e)}function Mn(e){return vi(e)}function Nl({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>xi(e),required:!0}):n&&s.push(al(Ji(i),n)),t&&s.push({id:"plugin",load:()=>Li(t)});const d=me(r);return wa(n)&&(d?kl(i):Ml(i))&&s.push(Tl({port:d?Zi(i):Qi(i),revisionServiceEnabled:vi(i),...!d&&ma(i)?{isHistoryAvailable:()=>ga(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),s}function X(e){return e.getOrCreateInstance(Ye,()=>new Xe)}var eo=new WeakMap,rn=new WeakMap;function ue(e){return eo.get(e)??0}function to(e,t){let n=rn.get(e);return n||(n=new Set,rn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Fl(e){eo.set(e,ue(e)+1),rn.get(e)?.forEach(t=>t())}function jl(e){const t=ve(e),n=X(e).addListener(N.APPLICATION_HAS_AMP,r=>{Be(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(F)?.addDispose(()=>n.dispose())}function Bl(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Ul(e){const t=e.fetchImpl??((o,s)=>fetch(o,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,i=o=>{try{const s=new URL(o,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:i,async load(o){if(!i(o))return;const s=!r.has(o);r.add(o);try{const d=await t(o,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!d.ok)return;const l=await d.blob();return Bl(l)?l:void 0}catch{return}}}}var _e={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Hl(e){const t={maxBytes:e.maxBytes??_e.maxBytes,maxImageBytes:e.maxImageBytes??_e.maxImageBytes,ttlMs:e.ttlMs??_e.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const d=v=>{const b=r.get(v);b&&(s-=b.bytes,r.delete(v))},l=v=>t.ttlMs<=0||n()-v.storedAt<t.ttlMs,f=()=>{if(s<=t.maxBytes)return;const v=[...r.entries()].sort((b,y)=>b[1].usedAt-y[1].usedAt);for(const[b]of v){if(s<=t.maxBytes)return;d(b)}},u=(v,b)=>{b.size>t.maxImageBytes||(r.set(v,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,f())};return{async get(v){const b=r.get(v);if(b&&l(b))return b.usedAt=n(),o.hits+=1,b.blob;b&&d(v);const y=i.get(v);if(y!==void 0)return y;o.loads+=1;const I=(async()=>{try{const g=await e.load(v);return g?u(v,g):o.failures+=1,g}catch{o.failures+=1;return}finally{i.delete(v)}})();return i.set(v,I),I},forget(v){d(v),i.delete(v)},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var Gl=["emcdn.ru","scr.emcdn.ru"];function ql(e){const t=String(e??"").trim();if(!t)return"";try{return new URL(t.includes("//")?t:`https://${t}`).hostname}catch{return t.split("/")[0].split(":")[0]}}function $l(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const d=ql(s);d&&o.add(d)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function fr(e){const t=e??{},n=t.isPlugin!==!0?Gl:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],..._e};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:$l(i.sourceHosts,n),maxBytes:i.maxBytes??_e.maxBytes,maxImageBytes:i.maxImageBytes??_e.maxImageBytes,ttlMs:i.ttlMs??_e.ttlMs}}function zl(e){const t=X(e),n=e.getInstance(we);let r=fr(n?.get());const i=Ul({sourceHosts:()=>r.sourceHosts}),o=Hl({load:I=>i.load(I),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),s=()=>{t.send(N.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},d=t.onInit(()=>s()),l=n?.watch(()=>{const I=fr(n.get()),g=JSON.stringify(I)!==JSON.stringify(r);r=I,I.enabled||o.clear(),g&&t.isInited()&&s()}),f={asked:0,served:0,refused:0},u=[],v=(I,g)=>(f.refused+=1,u.push({url:I,reason:g}),u.length>20&&u.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...f},refusals:[...u],store:o.stats()})}),y=t.addListenerAsync(N.APPLICATION_CANVAS_IMAGE_GET,async I=>{const g=I?.url??"";if(f.asked+=1,!r.enabled||!g)return v(g,"disabled");if(!i.accepts(g))return v(g,"host");I.fresh&&o.forget(g);const E=await o.get(g);return E?(f.served+=1,{blob:E}):v(g,"load-failed")});e.getInstance(F)?.addDispose(()=>{d.dispose(),l?.dispose(),y.dispose(),o.clear(),delete b.__emmCanvasImages__})}var Vl=2e3;function Kl(e){const t=X(e),n=new Set,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;const d=new MessageChannel;let l=!1;const f=v=>{v.data?.operationId==="em:port-ready"&&(l=!0,d.port1.removeEventListener("message",f),t.drainWindow(s))};d.port1.addEventListener("message",f),t.sendPort(s,d.port2),t.usePort(d.port1,!1,s);const u=setTimeout(()=>{n.delete(u),!l&&(wt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d.port1.removeEventListener("message",f),t.useWindow(s))},Vl);n.add(u)},i=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),o=t.onInit(()=>r());e.getInstance(F)?.addDispose(()=>{for(const s of n)clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var Wl=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Yl(e){return Wl.test(e)||e.indexOf("//")===0}function it(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Xl(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function pr(e,t){const n=e==null||e===""?"./":String(e);if(Yl(n))return it(n);const r=t??Xl();if(!r)return it(n);try{return it(new URL(n,r).href)}catch{return it(n)}}function Jl(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?pr(window.__useblocks__.publicPath):pr("/")}var Ql=()=>"",Zl=()=>"46f9d75a";function no(e){const t=e?"iframe-eblock":"iframe",n=Ql();if(n){const o=n.replace(/\/?$/,"/");return Zn(`${o}${t}.html`,$e())}const r=Zl(),i=`${Jl().replace(/\/?$/,"/")}iframe/`;return Zn(`${i}${t}${r?`.${r}`:""}.html`,$e())}var hr="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function on(e){return/^file:/i.test(String(e||"").trim())}function ed(e){return on(e)?`${hr} allow-same-origin`:hr}var td="em:module-body-ack";function nd(e,t,n){try{const r=new URL("./",new URL(t,n)).href,i=new URL(e,r).href;return i.startsWith(r)?i:void 0}catch{return}}function kn(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.[0-9a-f]{6,})?\.html$/.exec(t);return n?`js/${n[1]}.body.js`:void 0}function rd(e,t){const n=kn(t)?.replace(/^js\/|\.body\.js$/g,""),r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function id(e,t){const n=kn(t)?.replace(/\.body\.js$/,".js");if(!n||!(n in e))return[];const r=new Set([n]),i=[n],o=[];for(;i.length>0;)for(const s of e[i.shift()]??[])r.has(s)||(r.add(s),o.push(s),i.push(s));return o}async function od(e){try{const t=await fetch(e);return t.ok?await t.blob():void 0}catch{return}}function sd(e){const t=new Map,n=r=>{const i=nd(r,e.canvasSrc,e.origin);if(!i)return;const o=t.get(i);if(o!==void 0)return o;const s=e.fetchBody(i);return t.set(i,s),s};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r){for(const i of r)n(i)},reset(){t.clear()},get size(){return t.size}}}async function ad(e,t,n){try{const r=new URL(".vite/manifest.json",new URL("./",new URL(e,t))).href,i=await fetch(r);if(!i.ok)return;const o=await i.json();n(rd(o,e))}catch{}}function ld(e){try{return on(new URL(e,window.location.href).href)}catch{return on(window.location.href)}}function dd(e){X(e);const t=no(!1);if(ld(t))return;const n=sd({canvasSrc:t,origin:window.location.href,fetchBody:od}),r=kn(t);r&&n.warm([r]);const i={"js/iframe-eblock.js":["js/discussHandlers.C5qc-xPl.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.C5qc-xPl.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.C5qc-xPl.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};i?n.warm(id(i,t)):ad(t,window.location.href,s=>n.warm(s));const o=s=>{const d=s.data;if(!d||d.operationId!=="em:module-body"||!d.result)return;const l=s.source;l&&(l.postMessage({operationId:td,for:d.result},"*"),n.take(d.data?.url??"").then(f=>{l.postMessage({operationId:d.result,data:f??null},"*")}))};window.addEventListener("message",o),e.getInstance(F)?.addDispose(()=>{window.removeEventListener("message",o),n.reset()})}var Ae=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,cd=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Oe=/<style\b[^>]*>[\s\S]*?<\/style>/gi,mr=/display:\s*none\s*!important/gi,ud=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,fd=/\s*height\s*:\s*100%\s*!important\s*;?/gi,pd=/height\s*:\s*100%\s*!important/i,hd=[".socialshare,",".advertisment,",".adHolder,",".adsbygoogle-noablate","#ab_adblock","#popmechanic-snippet","filter_ads_by_classname","clever-core-ads","--gn-ov-ad-height","pub_728x90.text-ad.textAd","html-load.com/player","content-loader.com/player",".adblock","#advblock","body { overflow: visible!important; }"];function md(e){return mr.lastIndex=0,(e.match(mr)||[]).length}function ro(e){const t=e.trim(),n=md(t);if(n===0)return!1;if(t.includes(".advertisment,")&&t.includes(".adHolder,")&&(t.includes(".socialshare,")||n>=3||t.length>2e3))return!0;const r=hd.filter(i=>t.includes(i)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function gd(e){Oe.lastIndex=0;for(const t of e.matchAll(Oe))if(ro(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function vd(e){let t=!1;return Oe.lastIndex=0,{html:e.replace(Oe,n=>ro(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function bd(e){return Ae.lastIndex=0,Ae.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||gd(e)}function yd(e){if(!bd(e))return{html:e,found:!1};let t=!1,n=e;Ae.lastIndex=0,Ae.test(n)&&(Ae.lastIndex=0,n=n.replace(Ae,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(cd,""),t=!0);const r=vd(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Ed(e){return!e||!pd.test(e)?e:(Oe.lastIndex=0,e.replace(Oe,t=>t.replace(ud,(n,r,i,o)=>`${r}${i.replace(fd,"")}${o}`)))}function io(e){const t=yd(e.replaceAll(`\r
|
|
1002
1002
|
`,`
|
|
1003
|
-
`));return{html:_d(t.html),hasBrowserExtensionArtifacts:t.found}}function nn(e){return e?.getContent()??""}function so(e,t){e?.mutate({content:Di(t)},{source:"remote"})}function ao(e){return x(e)}function ie(e,t){return e.getOrCreateInstance(t,()=>new pe)}function K(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 wd=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}},Sd=class{_activeRequest=null;_pending=new Map;_listeners=new Set;getActiveShowRequest(){return this._activeRequest}onShowRequested(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}requestShow(e,t,n){return this._rejectPending(Q("Superseded by newer show()")),n.aborted?Promise.reject(Q(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new wd(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(Q(n.reason))})};n.addEventListener("abort",s,{once:!0});const d=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:d});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Id(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Td(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Ii(e),n=Ti(e),r=Ea(e.sandbox);t<n+r}var lo=class{_controller=new AbortController;_externalSignalDisposable=new Z;_sessionChangeListeners=new Set;_showRegistry=new Sd;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Ii(this._timeouts)}getSandboxTimeoutMs(e){return Si(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Ti(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=Id(this._timeouts,e.timeouts),Td(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}abort(e){const t=e??Q("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Z}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Z,this._showRegistry.rejectAll(Q("Init session replaced")),this._controller.signal.aborted||this._controller.abort(Q("Init session replaced")),this._controller=new AbortController,this._emitSessionReplaced()}_emitSessionReplaced(){for(const e of this._sessionChangeListeners)e()}_linkExternalSignal(e){if(!e)return;if(e.aborted){this._controller.signal.aborted||(this._controller.abort(e.reason??Q()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??Q()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Ln=(()=>{const e=new lo;return e.configure({}),e})(),Ad=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 Cd(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 Rd(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(q(n),new Promise((r,i)=>{let o=!1,s,d;const l=u=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),d?.dispose(),n?.removeEventListener("abort",f),u())},f=()=>{l(()=>i(Q(n?.reason)))};if(d=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>i(new Ad(t)))},t)),n?.addEventListener("abort",f)}))}var Pd=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 Dd(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 Pd(n,t)))},t),e.then(l=>{d(()=>r(l))},l=>{d(()=>i(l))})})}var Od=2,it=Symbol("sandbox:frame-replaced");function ae(e,t,n,r,i,o,s){const d=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??Rn[t],f=()=>{let I=Dd(e.sendAsync(n,r),l,d);return I=En(I,o?.signal),Ue(d,I,i)};if(t==="INIT_START"&&Cd(e)){const I=o?.getSandboxReadyTimeoutMs()??2e4,g=e,y=w=>{const S=Rd(g,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(Od)}if(!s)return f();const u=s.getGeneration();let v;const b=new Promise((I,g)=>{v=s.onChange(()=>{s.getGeneration()!==u&&g(it)})}),E=f();return E.catch(()=>{}),Promise.race([E,b]).finally(()=>v?.()).catch(I=>{throw I===it&&{...i},I})}var xd=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Ld=200;function Md(e=new Set){const t=new Set;return(n,r)=>{if(!xd.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>=Ld&&t.clear(),t.add(i))}}function kd(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Md()}}var Nd=kd();function ke(e){return e?.getInstance(Ps)??Nd}function Fd(e){const t=ve(e),n=X(e),r=()=>e.getInstance(De)??Ln;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",k.SANDBOX_INIT_START,{guid:A},void 0,h),a())return;const{html:m,hasBrowserExtensionArtifacts:_}=oo(nn(S));if(_&&ie(e,F.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),so(S,m),await ae(n,"SET_ENTITY",k.SANDBOX_SET_ENTITY,rn(nn(S),A,ke(e).editorPolicy,S.get().version),void 0,h),a())return;await ae(n,"INITED",k.SANDBOX_INITED,{guid:A},void 0,h),i=A,o=p}finally{s=!1}},f=()=>me(t.sessionKey())?t.current():void 0,u=()=>{if(d||s)return;const S=f(),A=S?.get().docId;if(!S||!A||i===A&&o===ue(n)||!S.isReady())return;const h=r();h.signal.aborted||l(S,A,h).catch(()=>{})};let v=!1;const b=()=>{v||d||(v=!0,queueMicrotask(()=>{v=!1,u()}))};let E,I;const g=()=>{const S=f(),A=S?.get().docId;A!==I&&(E?.(),I=A,E=S?.subscribe(b)),b()},y=t.subscribe(g),w=no(n,b);g(),e.getInstance(N)?.addDispose(()=>{d=!0,w(),E?.(),y()})}var jd=200;function Bd({startVersion:e,limit:t=jd}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const d=n.filter(f=>f.version>s);i(s);let l=o;for(const f of d){if(f.fromCanvas||f.contentReplaced||!f.changes)return null;const u=f.changes,v=[];for(const b of l){const E=Da(b.range,u,"after");if(!E)return null;v.push({range:E,text:b.text})}l=v}return l}}}function Ud(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 Hd(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Ud(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Gd(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Mn=x("canvas.sandboxFill");function co(e){return e.getInstance(Mn)?.pipeline.isEventsLocked()===!0}function Ot(e){yt(e,{origin:"canvas-channel"})}function qd(e){const t=ve(e),n=X(e);let r;const i=(l,f)=>{const u=l.get().docId;let v=!1,b=null,E=null;const I=Bd({startVersion:l.get().version});let g=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(k.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(k.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev}).catch(Ot),n.sendAsync(k.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=Ha(c);let{edits:_}=c;if(m.baseRev!==null){const C=I.rebase(_,m.baseRev);if(!C){yt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),w([],m.changeId);return}_=C}const T=l.get().version;try{v=!0,b=m.changeId;const C=Hd(_,l.getContent());p===!1?f.applyWithoutHistory(C):l.mutate({changes:C},{source:co(e)?"system":"user"})}finally{v=!1,b=null}l.get().version===T&&m.baseRev!==null&&w([],m.changeId)},A=l.subscribe(({changes:c,version:a})=>{const p=l.getContent(),m=!c?.length&&p!==g;if(g=p,I.record({version:a,changes:c,contentReplaced:m,fromCanvas:v}),!c?.length)return;const _=Gd(c);v?w(_,b):y(_,a).catch(Ot)}),h=n.addListener(k.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(N)?.addDispose(()=>{r?.(),d()})}var $d=300,zd=15e3,pr="em-canvas-busy-style";function Vd(){if(document.getElementById(pr))return;const e=document.createElement("style");e.id=pr,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function Kd(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(){Vd(),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 Wd=8e3;function Yd(){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 Xd=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 Jd(e,t,n,r,i){const o=n.readyTimeoutMs??Wd,s=document.createElement("div");s.dataset.canvasHost=e,r&&(s.dataset.canvasPlace=r),s.style.position="fixed",s.style.overflow="hidden",s.style.visibility="hidden";const d=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(d)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=d,s.appendChild(l),t.appendChild(s),n.mark?.("created"),i||n.onCreated?.(l);const f=new Z;let u=!1,v=!1,b,E,I,g;const y=()=>{clearTimeout(g),g=setTimeout(()=>{v||(v=!0,E?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},w=()=>u?(I=Promise.resolve(),v=!0,I):(v=!1,I=new Promise((L,H)=>{b=L,E=H}),y(),I),S=()=>{if(clearTimeout(g),u=!0,v){I=Promise.resolve();return}v=!0,n.mark?.("loaded"),b?.()};l.addEventListener("load",S),f.addDispose(()=>{clearTimeout(g),l.removeEventListener("load",S)});let A;const h=()=>{A??=n.bindResizer?.(l)};let c=null,a=null,p;const m=()=>{if(!c){s.style.visibility="hidden",l.removeAttribute("id");return}n.elementId&&(l.id=n.elementId);const L=c.getBoundingClientRect(),H=a?.isConnected?a:Xd(c),U=H?H.getBoundingClientRect():null,Y=U?Math.max(L.top,U.top):L.top,be=U?Math.min(L.bottom,U.bottom):L.bottom,Qe=Math.max(0,be-Y);s.style.visibility=Qe>0?"visible":"hidden",s.style.left=`${L.left}px`,s.style.top=`${Y}px`,s.style.width=`${L.width}px`,s.style.height=`${Qe}px`,l.style.transform=`translateY(${L.top-Y}px)`};let _="",T="",C=0,P;const j=()=>{if(!c){P=void 0;return}P=window.requestAnimationFrame(j);const L=c.getBoundingClientRect(),H=a?.isConnected?a.getBoundingClientRect():void 0,U=`${Math.round(L.left)}:${Math.round(L.top)}:${Math.round(L.width)}:${Math.round(L.height)}:${H?`${Math.round(H.top)}:${Math.round(H.height)}`:"-"}`;U!==_&&(_=U,m());const Y=l.getBoundingClientRect().height;Y>0&&Y!==C&&(C=Y,c.style.height=`${Y}px`);const be=getComputedStyle(c).pointerEvents;be!==T&&(T=be,s.style.pointerEvents=be)},R=()=>{P===void 0&&c&&(P=window.requestAnimationFrame(j))},O=()=>{P!==void 0&&(window.cancelAnimationFrame(P),P=void 0)},z=()=>m();let B=[];const W=(L,H)=>{if(a=H,L&&B.length>0){const U=B;B=[],U.forEach(Y=>Y())}if(L===c){m();return}if(p?.disconnect(),p=void 0,c&&c.style.removeProperty("height"),_="",C=0,T="",c=L,!L){O(),m();return}n.onShown?.(l);try{if(typeof ResizeObserver=="function"){const U=new ResizeObserver(m);typeof U.observe=="function"&&(p=U,p.observe(L))}}catch{p=void 0}m(),h(),R()};window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),f.addDispose(()=>{p?.disconnect(),P!==void 0&&window.cancelAnimationFrame(P),window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)});const de=L=>{u=!1,L&&n.onReload?.(l);let H;v||I===void 0?H=w():(y(),H=I);try{l.contentWindow?.location.reload()}catch{l.src=d}return H};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(L=>{B.push(L)})},alignTo(L,H){W(L,H??null)},scrollBy(L,H){for(let U=c?.parentElement??null;U;U=U.parentElement){const Y=getComputedStyle(U);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&U.scrollHeight>U.clientHeight){U.scrollBy({left:L,top:H,behavior:"instant"});return}}window.scrollBy({left:L,top:H,behavior:"instant"})},resize(){A?.resize()},dispose(){W(null,null),A?.dispose(),f.dispose(),s.remove()}}}function Qd(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,v)=>u==="email"?`email:${v??n}`:u;let o,s=[];const d=()=>{s.forEach(u=>clearTimeout(u)),s=[],o?.remove(),o=void 0},l=new Map,f=(u,v,b)=>{const E=i(u,v),I=t.get(E);if(I)return I;const g=e.resolveMount();if(!g)return Yd();const y=Jd(u,g,e,u==="email"?v??n:void 0,b);return t.set(E,y),y};return{get:u=>f(u),current:u=>f(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>f("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const v=t.get(i("email"));n=r();const b=l.get("email");u.alignTo(b?.slot??null,b?.clip??null),v?.alignTo(null)},alignSurface(u,v,b){l.set(u,{slot:v,clip:b??null}),(v?f(u):t.get(i(u)))?.alignTo(v,b??null)},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const v of t.values())if(v.element.contentWindow===u)return v}},busy(u){d();const v=u?e.resolveMount():void 0;if(!v)return;const b=Kd(v);o=b,s=[setTimeout(()=>b.showSpinner(),$d),setTimeout(d,zd)]},dispose(){d(),t.forEach(u=>u.dispose()),t.clear(),l.clear(),n="a"}}}var Zd=x("canvas.resizerBinder"),on=x("canvas.service"),ec={created:J.canvasCreated,loaded:J.canvasLoaded};function tc(e,t){if(e.getInstance(on))return;const n=Qd({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:td,elementId:t.elementId,bindResizer:i=>e.getInstance(Zd)?.(i),onCreated:i=>ct(e,i,"fresh"),onReload:i=>ct(e,i,"fresh"),onShown:i=>ct(e,i,"switch"),mark:i=>t.mark?.(ec[i])}),r=X(e).addListener(k.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(on,n),e.getInstance(N)?.addDispose(()=>{r.dispose(),n.dispose()})}function ct(e,t,n){const r=X(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),jl(r))}function nc(e,t){ct(e,t,"promote")}function rc(e,t){const n=t.contentWindow;n&&X(e).greet(n)}function ic(e,t){const n=t.contentWindow;n&&X(e).forget(n)}function fe(e){return e.getInstance(on)}function oc(e){const t=X(e),n=()=>fe(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(k.RELOAD,async()=>{await n()?.reload()}),i=t.addListener(s=>{s.data?.operation===k.SANDBOX_RESIZED&&n()?.resize()}),o=K(e,F.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(N)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose()})}var wm=x("HeadlessMode"),sc=x("HiddenMount");function ac(e){return e.getOrCreateInstance(sc,()=>Me(!1))}function hr(){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 lc(e){const t=e.getInstance(oe);let n,r;e.getInstance(N)?.addDispose(()=>{r?.remove(),r=void 0}),tc(e,{resolveMount:()=>n,resolveSrc:o=>ro(o==="block"),elementId:"email_iframe",mark:o=>$(o)}),t?.watch(o=>{if(n)return;const s=o?.element;if(s instanceof HTMLElement)n=s;else if(o!==void 0)n=r??=hr();else return;fe(e)?.get("email")});let i;e.getInstance(N)?.addDispose(()=>{i?.remove(),i=void 0}),ac(e).watch(o=>{const s=fe(e);if(s){if(o){i??=hr(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var uo=x("canvas.headerFlow"),mr=["subject","preheader"],dc=3e3,cc={subject:k.SANDBOX_SUBJECT_UPDATE,preheader:k.SANDBOX_PREHEADER_UPDATE};function uc(e){const t=ve(e),n=X(e),r=g=>g?"remote":co(e)?"system":"user",i=(g,{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?.[g]&&!S&&w!==h[g])return;S&&t.endForcedHeaders();const c=A.get().attributes[g]??"";d=!0;try{mt(A,{[g]:w},{source:r(S)})}finally{d=!1}o[g]=w,ie(e,F.ON_HEADER_APPLIED_ID).fire({field:g,value:w,forced:!!S,isGenerated:w!==c&&!!w})};let o={},s,d=!1,l=Promise.resolve();const f=(g,y,w)=>{l=n.sendAsync(cc[g],{value:y,guid:je(t)?.get().docId,...w?{force:!0,echo:!0}:{}}).catch(S=>{})};let u;e.inject(uo,{whenDelivered:async()=>{await l},reassert:g=>{const y=je(t),w=mr.filter(S=>g[S]);if(!(!y||w.length===0)){d=!0;try{mt(y,Object.fromEntries(w.map(S=>[S,g[S]])),{source:"system"})}finally{d=!1}t.beginForcedHeaders({subject:g.subject??"",preheader:g.preheader??""}),clearTimeout(u),u=setTimeout(()=>t.endForcedHeaders(),dc);for(const S of w)o[S]=g[S],f(S,g[S],!0)}}});const v=()=>{s?.(),s=void 0;const g=je(t);if(!g){o={};return}const y=g.get().attributes;o={subject:y.subject,preheader:y.preheader},s=g.subscribe(({source:w})=>{if(d)return;const S=g.get().attributes,A=t.forcedHeaders();for(const h of mr){const c=S[h];c!==o[h]&&(o[h]=c,f(h,c??"",w==="system"&&A?.[h]!==void 0))}})};v();const b=t.subscribe(v),E=n.addListenerAsync(k.APPLICATION_SUBJECT_UPDATE,g=>i("subject",g)),I=n.addListenerAsync(k.APPLICATION_PREHEADER_UPDATE,g=>i("preheader",g));e.getInstance(N)?.addDispose(()=>{E.dispose(),I.dispose(),b(),s?.(),clearTimeout(u)})}function gr(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];gr(i)&&gr(o)?n[r]=sn(o,i):i!==void 0&&(n[r]=i)}return n}function fc(e,t){const n=_n;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 pc(){const e=window.localStorage.getItem(bt.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?ws:Fs;return e&&e!=="system"?e:t}function hc(){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 mc(e){const{config:t}=e;return{operation:k.UPDATE_PREVIEW,theme:e.theme,commonStyles:fc(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 gc(e){const t=X(e),n=e.getInstance(we),r=e.getInstance(oe),i=ve(e);let o,s="";const d=()=>{const w=n?.get()??{},S=mc({config:w,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:pc(),codeMode:hc(),appName:"useblocks"}),A=JSON.stringify(S);A!==s&&(s=A,t.send(S))},l=t.onInit(()=>{s="",d()}),f=()=>{t.isInited()&&d()},u=n?.watch(f),v=r?.watch(w=>{o=w?.commonStyles,f()});let b;const E=()=>{b?.(),b=i.current()?.subscribe(f),f()};E();const I=i.subscribe(E),g=matchMedia(Ts),y=()=>f();g.addEventListener("change",y),e.getInstance(N)?.addDispose(()=>{l.dispose(),u?.dispose(),v?.dispose(),b?.(),I(),g.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 v=o.find(b=>s(u,b));v?f.push({prev:u,next:v}):l.push(u)}for(const u of o)i.find(v=>s(u,v))||d.push(u);return{added:d,removed:l,exists:f}}e.diff=r})(an||(an={}));function vc(e,t){return e.type===t.type&&e.key===t.key}function bc(e){const t=X(e),n=()=>e.getServices(Te)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(k.SANDBOX_ADD_EXTENSIONS,r)}),o=us(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,vc);if(r=l,u.length){if(u.some(v=>v.type==="script")){t.send(k.RELOAD);return}t.send(k.SANDBOX_REMOVE_EXTENSIONS,u.map(v=>v.key))}f.length&&t.send(k.SANDBOX_ADD_EXTENSIONS,f)});e.getInstance(N)?.addDispose(()=>{i.dispose(),s?.dispose()})}var Ec=x("prewarm.editorVisible");function yc(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function _c(e={}){const t=e.paint??yc;let n=!1,r=!1,i=!1,o=!1,s=!1;const d=[],l=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,$(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 wc(e){return e.getOrCreateInstance(Ec,()=>_c())}var Sc=500,Ic=500,Tc=5e3;function Ac(e){const t=e.quietMs??Sc,n=e.floorMs??Ic,r=e.ceilingMs??Tc;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 Cc({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 fo="self-init:";function Rc(e){return e.startsWith(fo)}function po(e,t){const n=e.getActiveShowRequest();return Rc(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Pc(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",k.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>ae(n,"INITED",k.SANDBOX_INITED,{guid:d().renderGuid},void 0,r()),async sendContent(){const f=d(),{html:u,hasBrowserExtensionArtifacts:v}=oo(f?.html||"");v&&e.events.browserExtensionDetected(),so(e.readDocument(),u),i=u,await ae(n,"SET_ENTITY",k.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",k.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",k.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",k.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(!po(t(),f)){t().getActiveShowRequest()?.showId;return}const v=d();v.id,v.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 Dc(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,d;const l=Pc({...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)},v=()=>{d?.abort(),d=void 0};let b;const E=()=>{const y=t().signal;y!==b&&(b?.removeEventListener("abort",v),b=y,y.addEventListener("abort",v))};async function I(y,w){const S=++s;v(),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()&&po(t(),y)&&t().failShow(y,T),T}finally{g(y,w,p,{superseded:A(),sessionGeneration:c,contentApplied:m,sandboxInitedAcked:_,commit:a()})}}function g(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,v(),n=!1,b?.removeEventListener("abort",v),b=void 0}}}function Oc(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:ho(e,n)}function ho(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function xc(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=u=>{const v=n(),b=i();if(!Oc(v,u,b)){u.showId,u.navId,u.emailId,v?.id,v?.showId,v?.renderGuid;return}u.showId,v?.id,v?.renderGuid,t.markFilled(o()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{s(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&s(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=o();if(t.filledGeneration()===u)return;const v=n(),b=i();if(!v?.renderGuid||!ho(v,b))return;const E=`${fo}${v.renderGuid}`;t.markFilled(u),t.markCorrelation(E);const I=r()?.isReady()===!0;v.id,v.renderGuid,(I?g=>t.refill(g):g=>t.fill(g))(E).catch(()=>{t.lastCorrelation()===E&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id}}}function Lc(e){return e??""}function Mc(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function kc(e){const t=ve(e),n=X(e),r=()=>me(t.sessionKey())?void 0:t.current(),i=()=>{const D=r();return Cc({attributes:D?.get().attributes??{},readContent:()=>D?.getContent(),docId:D?.get().docId,hasSession:!!D,serverId:D?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(De)??Ln;let s={},d=!1;const l=e.getInstance(oe)?.watch(D=>{d=!!D?.element});let f=!1,u=!1,v=!1,b=0;const E=()=>{const D=fe(e);if(!D)return;const V=++b,G=D.spare();return G&&ic(e,G.element),(G?G.reloadQuietly():D.ensureSpare()?.ready())?.then(()=>{if(V!==b)return;f=!0;const ne=D.spare();ne&&rc(e,ne.element),v&&(v=!1,T(),W())})},I=Ac({run:()=>{v||E()?.catch(()=>{})}}),g=()=>{wc(e).noteContentShown(),!f&&!v&&I.start()};let y=!1;const A=Dc({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const D=fe(e);return y&&D&&(y=!1,I.start()),d?D?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:D=>{const V=fe(e),G=V?.spare()?.element.contentWindow;u&&V&&G&&D===G&&(u=!1,V.promote(),V.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:D=>{ie(e,F.WILL_EMAIL_INIT_ID).fire(D)},inited:D=>{g(),ie(e,F.ON_EMAIL_INIT_ID).fire(D)},contentChanged:D=>{ie(e,F.ON_CONTENT_CHANGED_ID).fire(D)},emailChanged:D=>{ie(e,F.ON_EMAIL_CHANGED_ID).fire(D)},browserExtensionDetected:()=>{ie(e,F.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),h=xc({pipeline:A,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>ue(n)});let c="",a="",p="";const m=D=>D.length>0;let _="none";const T=()=>{const D=fe(e)?.spare();D&&(n.send({operation:k.SANDBOX_LOCK_EDIT,data:!0}),f=!1,u=!0,nc(e,D.element))},C=(D,V)=>{const G=fe(e);if(!G)return!0;const ne=G.spare(),Ee=ne&&f?"spare":"prepare";if(_=Ee,G.busy(!0),ne&&f)return T(),!0;I.cancel(),n.send({operation:k.SANDBOX_LOCK_EDIT,data:!0});const ye=E();if(ye===void 0)return _="reload",G.busy(!1),G.peek("email")?.reload(),!0;v=!0;const Tt=b;return ye.catch(()=>{!v||Tt!==b||(v=!1,_="reload",G.busy(!1),G.peek("email")?.reload())}),!1},P=()=>{be(),A.noteSandboxGeneration(ue(n));const D=i(),V=Mc(D?.renderGuid,D?.showId,D?.id,s.emailId),G=Lc(D?.renderGuid);if(G!==a){const ye=m(a),Tt=a;a=G,ye&&C(Tt,G)}if(v)return;V!==c&&(c=V,h.showRequestIdentityChanged());const ne=r(),Ee=`${V}|${ne?.get().docId??""}|${ue(n)}`;Ee!==p&&ne?.isReady()===!0&&(p=Ee,h.selfInitChanged()),h.saasChanged(),z()};let j=!1,R="",O="";const z=()=>{const D=i();if(!D?.renderGuid)return;const V=A.channel.readContent(),G=JSON.stringify([D.preheader,D.common_styles,D.meta,D.subject,D.utm_parameters?.utm_campaign??"",D.utm_parameters?.utm_content??"",D.utm_parameters?.utm_medium??"",D.utm_parameters?.utm_source??"",D.utm_parameters?.utm_term??""]),ne=j&&V!==O,Ee=j&&G!==R;if(j=!0,O=V,R=G,A.isEventsLocked())return;const ye={...D,id:s.isTemplate||D.isNew?void 0:D.id,html:V};if(ne){ie(e,F.ON_CONTENT_CHANGED_ID).fire(V),ie(e,F.ON_EMAIL_CHANGED_ID).fire(ye);return}Ee&&D.is_inited&&ie(e,F.ON_EMAIL_CHANGED_ID).fire(ye)};let B=!1;const W=()=>{B||(B=!0,queueMicrotask(()=>{B=!1,P()}))};e.inject(Mn,{pipeline:A,setRoute:D=>{D.emailId===s.emailId&&!!D.isTemplate==!!s.isTemplate||(s=D,W())}});let de,L;const H=()=>{const D=r()?.get().docId;D!==L&&(de?.(),L=D,de=r()?.subscribe(W)),W()};let U,Y;const be=()=>{const D=e.getInstance(De);!D||D===U||(Y?.(),U=D,Y=D.onShowRequested(V=>h.showRequested(V)))},Qe=n.addListener(D=>{D.data?.operation===k.SANDBOX_RESIZED&&I.notify()}),Xo=t.subscribe(H),Jo=no(n,W);H(),e.getInstance(N)?.addDispose(()=>{l?.dispose(),Y?.(),Jo(),Xo(),de?.(),Qe.dispose(),I.cancel(),A.stop()})}function Nc(){return Ms!=="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},Fc={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}},vr=ln,jc=["freeUserBlocks","blocks"],mo={};function Bc(e){mo=e}var go=e=>jc.includes(e)?vr:mo[e]??vr,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},Uc={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},Hc={...dn,config:{...dn.config,imageCenterFileManagerView:!1}};Bc({pro:Fc,editor:Uc,simple:Nc()?dn:Hc,freeUserBlocks:ln,blocks:ln});var br=new Set;function Gc(){return window.localStorage.getItem(bt.em_color_scheme)??void 0}function qc(e){return br.add(e),e(Gc()),{dispose(){br.delete(e)}}}function kn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function $c(e,t){return t.modeDefaults(kn(e,t.fallbackMode))}function zc(e,t){const n=kn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Vc(e,t){const n=kn(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Kc(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Wc(e){return os(e.map(t=>t?.resourceProxy))}function Yc(e){return rs(e.map(t=>t?.resourceProxyPolicy))}function Xc(e){return gs(e.map(t=>t?.backendProxy))}function Jc(e){return li(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Qc(e,t){return[e.base,$c(e,t),e.profile,e.serverSide,zc(e,t.fallbackMode),e.user,Vc(e,t.fallbackMode),e.local]}function xt(e,t){const n=Qc(e,t),r=li(n),i=Kc(n);i!==void 0&&(r.fileManager=i);const o=Wc(n);o!==void 0&&(r.resourceProxy=o);const s=Yc(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const d=Xc(n);d!==void 0&&(r.backendProxy=d);const l=Jc(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}var Zc=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Er(e){return e==="server"?"serverSide":e}function eu({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 v(b,E){r[Er(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(Zc.map(E=>[E,b[E]]))},merge(b,E){v(E,{...r[Er(E)],...b})},replace(b,E){v(E,b)},setMode(b){r.user={...r.user,mode:b},f()},setAdvancedConfigs(b){r.advancedConfigs=b,f()},serverAbsent(b){u({kind:"absent",reason:b})},applyServerResponse(b){o.kind==="pending"&&v("server",{...r.serverSide,...b})},dispose(){clearTimeout(l)}}}var tu=5e3,nu="blocks";function ru(){return{...go(nu)?.config,mergeTags:void 0}}function iu(e,t){e.getInstance(oe)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function ou(e,t){let n;Ki(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 su(e,t){let n=null;const r=qc(i=>{const o=typeof i=="string"&&i?i:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(N)?.addDisposable(r)}async function au(e,t){if(e.getInstance(An)===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 lu(e){e.injectFactory(we,(t,n)=>{if(n)return n;const r=eu({base:ru(),env:{modeDefaults:i=>go(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:tu});return iu(e,r),ou(e,r),su(e,r),au(e,r),e.getInstance(N)?.addDisposable(r),r},!0)}var Re=class extends Z{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function M(e,t,n){const r=ns(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 du=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Jt;this.handleDestroy=M(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{}}},Nn=x("DestroyableService");function cu(e){e.injectFactory(Nn,()=>{const t=e.getInstance(N);if(!t)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new du({lifetime:t,options:e.getInstance(oe),getInstance:()=>e.getInstance(Et),release:()=>Os(e.getInstance(As)??e)})},!0)}function uu(e){const t=e.getInstance(Nn);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var fu=1e3;function vo(e,t,n=fu,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(!vo(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];vo(i,o)||(n[r]=i)}return n}var pu=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail не ответил за ${e}ms — письмо не сохранено`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},hu=({source:e,emailtags:t,group:n,tags:r,...i})=>i,mu=()=>Ai();async function gu({emails:e},t){const n=mu();let r;try{return await Promise.race([e.notifySave(t),new Promise((i,o)=>{r=setTimeout(()=>{const s=new pu(n);t.value.id,o(s)},n)})])}finally{r!==void 0&&clearTimeout(r)}}function vu(e){const{emails:t}=e,n=async(r,i)=>{const o=hu(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),d=s?{...s,...o}:o,l=await gu(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,bu=({source:e,emailtags:t,group:n,tags:r,...i})=>i;function Eu({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 $a(await n(r,1))},async saveAutosave(r,i){const o=bu(i);return await e.create({...o,parent:r,modified:new Date().toString()})}}}var yu=class extends Bs{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}},_u=class extends pe{};var yr=class extends Z{_items=new Map;_onChangeEmitter=new _s;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 wu(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let d=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(f=>{for(const u of l){const v=f[u],b=t[u];return u==="id"||typeof v!="string"?v===b:typeof b=="string"&&v.startsWith(b)}return!0}),d=e.length}return r&&(e=e.sort((l,f)=>(l[r]>f[r]?1:f[r]>l[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:d,total:s,totalPages:Math.ceil(d/o)}}function Su(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 Iu(e,t){return _r(e)&&_r(t)?String(e)===String(t):e===t}function _r(e){return typeof e=="string"||typeof e=="number"}var Tu=class extends Z{_cache=new yr;_readEmitter=new pe;_saveEmitter=this.addDisposable(new yu);_removeEmitter=this.addDisposable(new _u);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new Z);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new yr),i=n.addDisposable(new pe);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const l=Su(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||Iu(f,o)});return wu(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=x(e);return n=>n.getOrCreateInstance(t,()=>new Tu)}function Au(e){const t=e.getInstance(N);if(!t)throw new Error("Failed");return t}function wr(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Cu(e,t,n){return e&&!wr(t)&&wr(e)?{...n,meta:e.meta}:n}var bo=Xe("plugin.dataSource.emails"),Eo=Xe("plugin.dataSource.emailRevisions"),Sr=x("emailDocuments.provided");function Ru(e){const t=bo(e),n=Eo(e),r=n.byForeignKey("parent");return e.getInstance(Sr)?{emails:t,emailRevisions:n}:(e.inject(Sr,!0),cl(e,vu({emails:t})),hl(e,Eu({revisions:n,revisionsByEmail:r})),Au(e).addDisposable(t.onSave(({prev:i,patch:o,value:s})=>Cu(i,o,s),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function Ir(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 Pu(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Du="po",ot=null;function Ou(){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([Du],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function xu(){return ot===null&&(ot=Ou().catch(e=>{throw ot=null,e})),ot}async function yo(e){if(typeof e=="object")return Fn(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Lu(t):Mu(t)}function Fn(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Lu(e){try{return Fn(JSON.parse(e))}catch{return}}var Tr=!1;async function Mu(e){try{return Fn((await xu()).parsePoCatalog(e))}catch{Tr||(Tr=!0);return}}var ku="em_locale",Nu="em_ant_locale",Fu="locale",ju="ant_locale";function jn(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function _o(e,t){const n=jn(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Bu(){return jn("em_locale")??_o(Fu,"em_locale")}function Ar(e){try{localStorage.setItem(ku,JSON.stringify(e))}catch{}}function Uu(){return jn("em_ant_locale")??_o(ju,"em_ant_locale")}function Hu(e,t){try{localStorage.setItem(Nu,JSON.stringify({id:e,data:t}))}catch{}}var Gu=8e3;function qu(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 $u(e){const t=Bu(),n=Uu();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??Gu),u=y=>y!==s;let v;async function b(y,w){if(n?.id===y&&n.data&&d({antd:n.data}),!v)return;const S=await v(y).catch(()=>{});!S||u(w)||(d({antd:S}),Hu(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 yo(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){Pu("em_locale")&&d({catalog:void 0}),l();return}if(Ir(t,A)&&(!i||i.catalog===t?.data)){l();return}if(i?.entry&&r.catalog===i.catalog&&Ir(i.entry,A)){Ar(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&&qu(i.catalog,h.data)||d({catalog:h.data}),Ar({id:y,time:A.updatedAt||Math.floor(Date.now()/1e3),hash:A.contentHash,data:h.data})),l()}}async function g(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),g(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){v=y,r.id&&b(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(f)}}var zu=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})},Vu=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:o,baseUrl:s,cancelToken:d,...l})=>{const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(l,f),v=i&&this.toQueryString(i),b=this.contentFormatters[r||"application/json"],E=o||u.format;return this.customFetch(`${s||this.baseUrl||""}${n}${v?`?${v}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(d?this.createAbortSignal(d):u.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async I=>{const g=I;g.data=null,g.error=null;const y=E?I.clone():I,w=E?await y[E]().then(S=>(g.ok?g.data=S:g.error=S,g)).catch(S=>(g.error=S,g)):g;return d&&this.abortControllers.delete(d),w})}},Ku=x("rest.v2.transport"),Cr=Symbol("rest.v2.secureRequest");function Wu(e){return e.getOrCreateInstance(Ku,()=>{const t=e.getInstance(ai)?.execute||fetch;return new Vu({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[Cr]:!0}),customFetch:(n,r={})=>{const{[Cr]:i,...o}=r;return t(n,{...o,[ls]:i!==!0})}})})}function Yu(e,t){const n=Wu(e);return Object.assign({},...t.map(r=>new r(n)))}function Rr(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function wo(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Rr(n.details,"wp_code")??n.code,message:Rr(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 So(e){return!e.ok||!!e.error}function Xu(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Io(){return Xu(bt.em_translations_v2)??!0}function Ju(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Qu(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Zu(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:Ju(r[1])}),t},[]):[]}function ef(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Qu(n.updated_at),contentHash:n.content_hash}),t),[])}function To(e){return Yu(e,[zu])}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 yo(e)??null}}async function tf(e){if(Io())try{const n=await To(e).localesList();return So(n)?{error:wo(n)}:{data:ef(n.data)}}catch(n){return vt(n)}const t=ci(e,[vi]);try{const n=await t.get_translations2({file:"react_app"});return cn(n)?un(n):{data:Zu(n.data)}}catch(n){return vt(n)}}async function nf(e,t){if(Io())try{const r=await To(e).jsonList({locale:t});return So(r)?{error:wo(r)}:Mt(r.data)}catch(r){return vt(r)}const n=ci(e,[vi]);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=x("locale.service");function rf(e){if(e.getInstance($e))return;const t=$u({readList:()=>tf(e),readCatalog:n=>nf(e,n),askHost:async n=>(await ie(e,F.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(he)});e.inject($e,t),e.getInstance(N)?.addDispose(()=>t.dispose())}function of(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(N)?.addDisposable(r)}var sf="user_id",af="project_id",Pr=x("rest.identityHeadersProvided");function lf(e){if(e.getInstance(Pr))return;e.inject(Pr,!0);let t;e.getInstance(oe)?.watch(n=>{t=n}),e.addService(wn,{execute(n,r){if(r?.public)return;const i=t?.user?.id??Wi(e).profile?.id;i!=null&&i!==""&&n.headers.set(sf,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(af,String(o))}})}function df(e){if(!e)return!1;try{return e.getInstance(he)!==void 0}catch{return!1}}var cf="Invalid standaloneKey.",Sm=x("StandaloneMockGuard");function uf(){const e=new Error(cf);return e.name="InvalidStandaloneKeyError",e}function ff(e){e.addService(wn,{execute:()=>{if(df(e))throw uf()}})}function pf(e){ys(e),ff(e)}function hf(e){const t=new lo;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(N);r&&i?.addDisposable(r),i?.addDispose(()=>{t.abort()})}var mf=Xe("plugin.dataSource.blocks"),gf=Xe("plugin.dataSource.blockRevisions"),vf=Xe("plugin.dataSource.comments"),bf=ao(),Ef=ao(),Ao=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
1003
|
+
`));return{html:Ed(t.html),hasBrowserExtensionArtifacts:t.found}}function sn(e){return e?.getContent()??""}function oo(e,t){e?.mutate({content:Pi(t)},{source:"remote"})}function so(e){return L(e)}function ie(e,t){return e.getOrCreateInstance(t,()=>new pe)}function K(e,t){return e.getOrCreateInstance(t,()=>new pe).event}function an(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var _d=class extends Error{showId;constructor(e,t){super(`[useblocks] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},wd=class{_activeRequest=null;_pending=new Map;_listeners=new Set;getActiveShowRequest(){return this._activeRequest}onShowRequested(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}requestShow(e,t,n){return this._rejectPending(Q("Superseded by newer show()")),n.aborted?Promise.reject(Q(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new _d(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(Q(n.reason))})};n.addEventListener("abort",s,{once:!0});const d=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:d});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Sd(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Id(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Si(e),n=Ii(e),r=ba(e.sandbox);t<n+r}var ao=class{_controller=new AbortController;_externalSignalDisposable=new Z;_sessionChangeListeners=new Set;_showRegistry=new wd;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Si(this._timeouts)}getSandboxTimeoutMs(e){return wi(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Ii(this._timeouts)}bumpGeneration(){this._generation+=1}getActiveShowRequest(){return this._showRegistry.getActiveShowRequest()}onShowRequested(e){return this._showRegistry.onShowRequested(e)}requestShow(e){return this._showRegistry.requestShow(e,this.contentReadyTimeoutMs,this._controller.signal)}completeShow(e){this._showRegistry.completeShow(e)}hasPendingShow(e){return this._showRegistry.hasPendingShow(e)}failShow(e,t){this._showRegistry.failShow(e,t)}rejectAllPendingShows(e){this._showRegistry.rejectAll(e)}onSessionReplaced(e){return this._sessionChangeListeners.add(e),()=>{this._sessionChangeListeners.delete(e)}}configure(e){e.timeouts!==void 0&&(this._timeouts=Sd(this._timeouts,e.timeouts),Id(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}abort(e){const t=e??Q("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Z}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Z,this._showRegistry.rejectAll(Q("Init session replaced")),this._controller.signal.aborted||this._controller.abort(Q("Init session replaced")),this._controller=new AbortController,this._emitSessionReplaced()}_emitSessionReplaced(){for(const e of this._sessionChangeListeners)e()}_linkExternalSignal(e){if(!e)return;if(e.aborted){this._controller.signal.aborted||(this._controller.abort(e.reason??Q()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??Q()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Nn=(()=>{const e=new ao;return e.configure({}),e})(),Td=class extends Error{label;timeoutMs;constructor(e){super(`[sandbox:ready] iframe handshake timed out after ${e}ms`),this.name="SandboxReadyTimeoutError",this.label="sandbox:ready",this.timeoutMs=e}};function Ad(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.isInited=="function"&&typeof t.getTarget=="function"&&typeof t.onInit=="function"}function Cd(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():($(n),new Promise((r,i)=>{let o=!1,s,d;const l=u=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),d?.dispose(),n?.removeEventListener("abort",f),u())},f=()=>{l(()=>i(Q(n?.reason)))};if(d=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>i(new Td(t)))},t)),n?.addEventListener("abort",f)}))}var Rd=class extends Error{label;timeoutMs;constructor(e,t){super(`[${e}] timed out after ${t}ms`),this.name="OperationTimeoutError",this.label=e,this.timeoutMs=t}};function Pd(e,t,n){return t<=0?e:new Promise((r,i)=>{let o=!1,s;const d=l=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{d(()=>i(new Rd(n,t)))},t),e.then(l=>{d(()=>r(l))},l=>{d(()=>i(l))})})}var Dd=2,ot=Symbol("sandbox:frame-replaced");function ae(e,t,n,r,i,o,s){const d=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??On[t],f=()=>{let I=Pd(e.sendAsync(n,r),l,d);return I=ht(I,o?.signal),He(d,I,i)};if(t==="INIT_START"&&Ad(e)){const I=o?.getSandboxReadyTimeoutMs()??2e4,g=e,E=w=>{const S=Cd(g,I,o?.signal);return He("sandbox:INIT_START:ready-wait",S,i).then(()=>{if(!s||w<=0)return f();const A=s.getGeneration();let h;const c=new Promise((p,m)=>{h=s.onChange(()=>{s.getGeneration()!==A&&m(ot)})}),a=f();return a.catch(()=>{}),Promise.race([a,c]).finally(()=>h?.()).catch(p=>{if(p!==ot)throw p;return{...i},E(w-1)})})};return E(Dd)}if(!s)return f();const u=s.getGeneration();let v;const b=new Promise((I,g)=>{v=s.onChange(()=>{s.getGeneration()!==u&&g(ot)})}),y=f();return y.catch(()=>{}),Promise.race([y,b]).finally(()=>v?.()).catch(I=>{throw I===ot&&{...i},I})}var Od=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],xd=200;function Ld(e=new Set){const t=new Set;return(n,r)=>{if(!Od.some(([o,s])=>!e.has(o)&&s.test(n)))return;const i=r??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=xd&&t.clear(),t.add(i))}}function Md(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Ld()}}var kd=Md();function Ne(e){return e?.getInstance(Rs)??kd}function Nd(e){const t=ve(e),n=X(e),r=()=>e.getInstance(De)??Nn;let i,o,s=!1,d=!1;const l=async(S,A,h)=>{const c=h.generation,a=()=>h.generation!==c||h.signal.aborted||t.current()!==S||d,p=ue(n);s=!0;try{if(await ae(n,"INIT_START",N.SANDBOX_INIT_START,{guid:A},void 0,h),a())return;const{html:m,hasBrowserExtensionArtifacts:_}=io(sn(S));if(_&&ie(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),oo(S,m),await ae(n,"SET_ENTITY",N.SANDBOX_SET_ENTITY,an(sn(S),A,Ne(e).editorPolicy,S.get().version),void 0,h),a())return;await ae(n,"INITED",N.SANDBOX_INITED,{guid:A},void 0,h),i=A,o=p}finally{s=!1}},f=()=>me(t.sessionKey())?t.current():void 0,u=()=>{if(d||s)return;const S=f(),A=S?.get().docId;if(!S||!A||i===A&&o===ue(n)||!S.isReady())return;const h=r();h.signal.aborted||l(S,A,h).catch(()=>{})};let v=!1;const b=()=>{v||d||(v=!0,queueMicrotask(()=>{v=!1,u()}))};let y,I;const g=()=>{const S=f(),A=S?.get().docId;A!==I&&(y?.(),I=A,y=S?.subscribe(b)),b()},E=t.subscribe(g),w=to(n,b);g(),e.getInstance(F)?.addDispose(()=>{d=!0,w(),y?.(),E()})}var Fd=200;function jd({startVersion:e,limit:t=Fd}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const d=n.filter(f=>f.version>s);i(s);let l=o;for(const f of d){if(f.fromCanvas||f.contentReplaced||!f.changes)return null;const u=f.changes,v=[];for(const b of l){const y=Pa(b.range,u,"after");if(!y)return null;v.push({range:y,text:b.text})}l=v}return l}}}function Bd(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new re(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Ud(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Bd(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Hd(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Fn=L("canvas.sandboxFill");function lo(e){return e.getInstance(Fn)?.pipeline.isEventsLocked()===!0}function Lt(e){wt(e,{origin:"canvas-channel"})}function Gd(e){const t=ve(e),n=X(e);let r;const i=(l,f)=>{const u=l.get().docId;let v=!1,b=null,y=null;const I=jd({startVersion:l.get().version});let g=l.getContent();const E=async(c,a)=>{if(y){y.push({edits:c,rev:a});return}y=[{edits:c,rev:a}];try{do{const p=y.splice(0,y.length);await n.sendAsync(N.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev})}while(y.length)}finally{y=null}},w=(c,a)=>{const p=y?.splice(0,y.length)??[];p.length&&n.sendAsync(N.SANDBOX_UPDATE_ENTITY,{edits:p.map(m=>m.edits),guid:u,rev:p[p.length-1].rev}).catch(Lt),n.sendAsync(N.SANDBOX_UPDATE_ENTITY,{edits:[c],guid:u,rev:l.get().version,...a!==null?{changeId:a}:{}}).catch(Lt)},S=c=>{const{guid:a,pushUndoStop:p}=c;if(a!==u)return;const m=Ua(c);let{edits:_}=c;if(m.baseRev!==null){const D=I.rebase(_,m.baseRev);if(!D){wt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),w([],m.changeId);return}_=D}const T=l.get().version;try{v=!0,b=m.changeId;const D=Ud(_,l.getContent());p===!1?f.applyWithoutHistory(D):l.mutate({changes:D},{source:lo(e)?"system":"user"})}finally{v=!1,b=null}l.get().version===T&&m.baseRev!==null&&w([],m.changeId)},A=l.subscribe(({changes:c,version:a})=>{const p=l.getContent(),m=!c?.length&&p!==g;if(g=p,I.record({version:a,changes:c,contentReplaced:m,fromCanvas:v}),!c?.length)return;const _=Hd(c);v?w(_,b):E(_,a).catch(Lt)}),h=n.addListener(N.APPLICATION_UPDATE_ENTITY,S);return()=>{A(),h.dispose()}};let o;const s=()=>{const l=t.current(),f=t.history(),u=l?.get().docId;u!==o&&(r?.(),r=void 0,o=u,l&&f&&(r=i(l,f)))},d=t.subscribe(s);s(),e.getInstance(F)?.addDispose(()=>{r?.(),d()})}var qd=300,$d=15e3,gr="em-canvas-busy-style";function zd(){if(document.getElementById(gr))return;const e=document.createElement("style");e.id=gr,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function Vd(e){const t=e.getBoundingClientRect(),n=document.createElement("div");return n.setAttribute("aria-busy","true"),Object.assign(n.style,{position:"fixed",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,cursor:"progress",display:"flex",alignItems:"center",justifyContent:"center"}),e.appendChild(n),{showSpinner(){zd(),n.style.background="rgba(128, 128, 128, 0.15)";const r=document.createElement("div");Object.assign(r.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),n.appendChild(r)},remove:()=>n.remove()}}var Kd=8e3;function Wd(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,whenShown:()=>Promise.resolve(),alignTo:()=>{},resize:()=>{},dispose:()=>{}}}var Yd=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="hidden")return t}return null};function Xd(e,t,n,r,i){const o=n.readyTimeoutMs??Kd,s=document.createElement("div");s.dataset.canvasHost=e,r&&(s.dataset.canvasPlace=r),s.style.position="fixed",s.style.overflow="hidden",s.style.visibility="hidden";const d=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(d)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=d,s.appendChild(l),t.appendChild(s),n.mark?.("created"),i||n.onCreated?.(l);const f=new Z;let u=!1,v=!1,b,y,I,g;const E=()=>{clearTimeout(g),g=setTimeout(()=>{v||(v=!0,y?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},w=()=>u?(I=Promise.resolve(),v=!0,I):(v=!1,I=new Promise((M,G)=>{b=M,y=G}),E(),I),S=()=>{if(clearTimeout(g),u=!0,v){I=Promise.resolve();return}v=!0,n.mark?.("loaded"),b?.()};l.addEventListener("load",S),f.addDispose(()=>{clearTimeout(g),l.removeEventListener("load",S)});let A;const h=()=>{A??=n.bindResizer?.(l)};let c=null,a=null,p;const m=()=>{if(!c){s.style.visibility="hidden",l.removeAttribute("id");return}n.elementId&&(l.id=n.elementId);const M=c.getBoundingClientRect(),G=a?.isConnected?a:Yd(c),H=G?G.getBoundingClientRect():null,Y=H?Math.max(M.top,H.top):M.top,be=H?Math.min(M.bottom,H.bottom):M.bottom,Ze=Math.max(0,be-Y);s.style.visibility=Ze>0?"visible":"hidden",s.style.left=`${M.left}px`,s.style.top=`${Y}px`,s.style.width=`${M.width}px`,s.style.height=`${Ze}px`,l.style.transform=`translateY(${M.top-Y}px)`};let _="",T="",D=0,R;const O=()=>{if(!c){R=void 0;return}R=window.requestAnimationFrame(O);const M=c.getBoundingClientRect(),G=a?.isConnected?a.getBoundingClientRect():void 0,H=`${Math.round(M.left)}:${Math.round(M.top)}:${Math.round(M.width)}:${Math.round(M.height)}:${G?`${Math.round(G.top)}:${Math.round(G.height)}`:"-"}`;H!==_&&(_=H,m());const Y=l.getBoundingClientRect().height;Y>0&&Y!==D&&(D=Y,c.style.height=`${Y}px`);const be=getComputedStyle(c).pointerEvents;be!==T&&(T=be,s.style.pointerEvents=be)},C=()=>{R===void 0&&c&&(R=window.requestAnimationFrame(O))},x=()=>{R!==void 0&&(window.cancelAnimationFrame(R),R=void 0)},B=()=>m();let U=[];const W=(M,G)=>{if(a=G,M&&U.length>0){const H=U;U=[],H.forEach(Y=>Y())}if(M===c){m();return}if(p?.disconnect(),p=void 0,c&&c.style.removeProperty("height"),_="",D=0,T="",c=M,!M){x(),m();return}n.onShown?.(l);try{if(typeof ResizeObserver=="function"){const H=new ResizeObserver(m);typeof H.observe=="function"&&(p=H,p.observe(M))}}catch{p=void 0}m(),h(),C()};window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),f.addDispose(()=>{p?.disconnect(),R!==void 0&&window.cancelAnimationFrame(R),window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)});const de=M=>{u=!1,M&&n.onReload?.(l);let G;v||I===void 0?G=w():(E(),G=I);try{l.contentWindow?.location.reload()}catch{l.src=d}return G};return{element:l,ready(){return I??w()},reload:()=>de(!0),reloadQuietly:()=>de(!1),get shown(){return c!==null},whenShown(){return c!==null?Promise.resolve():new Promise(M=>{U.push(M)})},alignTo(M,G){W(M,G??null)},scrollBy(M,G){for(let H=c?.parentElement??null;H;H=H.parentElement){const Y=getComputedStyle(H);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&H.scrollHeight>H.clientHeight){H.scrollBy({left:M,top:G,behavior:"instant"});return}}window.scrollBy({left:M,top:G,behavior:"instant"})},resize(){A?.resize()},dispose(){W(null,null),A?.dispose(),f.dispose(),s.remove()}}}function Jd(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,v)=>u==="email"?`email:${v??n}`:u;let o,s=[];const d=()=>{s.forEach(u=>clearTimeout(u)),s=[],o?.remove(),o=void 0},l=new Map,f=(u,v,b)=>{const y=i(u,v),I=t.get(y);if(I)return I;const g=e.resolveMount();if(!g)return Wd();const E=Xd(u,g,e,u==="email"?v??n:void 0,b);return t.set(y,E),E};return{get:u=>f(u),current:u=>f(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>f("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const v=t.get(i("email"));n=r();const b=l.get("email");u.alignTo(b?.slot??null,b?.clip??null),v?.alignTo(null)},alignSurface(u,v,b){l.set(u,{slot:v,clip:b??null}),(v?f(u):t.get(i(u)))?.alignTo(v,b??null)},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const v of t.values())if(v.element.contentWindow===u)return v}},busy(u){d();const v=u?e.resolveMount():void 0;if(!v)return;const b=Vd(v);o=b,s=[setTimeout(()=>b.showSpinner(),qd),setTimeout(d,$d)]},dispose(){d(),t.forEach(u=>u.dispose()),t.clear(),l.clear(),n="a"}}}var Qd=L("canvas.resizerBinder"),ln=L("canvas.service"),Zd={created:J.canvasCreated,loaded:J.canvasLoaded};function ec(e,t){if(e.getInstance(ln))return;const n=Jd({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:ed,elementId:t.elementId,bindResizer:i=>e.getInstance(Qd)?.(i),onCreated:i=>ut(e,i,"fresh"),onReload:i=>ut(e,i,"fresh"),onShown:i=>ut(e,i,"switch"),mark:i=>t.mark?.(Zd[i])}),r=X(e).addListener(N.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(ln,n),e.getInstance(F)?.addDispose(()=>{r.dispose(),n.dispose()})}function ut(e,t,n){const r=X(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),Fl(r))}function tc(e,t){ut(e,t,"promote")}function nc(e,t){const n=t.contentWindow;n&&X(e).greet(n)}function rc(e,t){const n=t.contentWindow;n&&X(e).forget(n)}function fe(e){return e.getInstance(ln)}function ic(e){const t=X(e),n=()=>fe(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(N.RELOAD,async()=>{await n()?.reload()}),i=t.addListener(s=>{s.data?.operation===N.SANDBOX_RESIZED&&n()?.resize()}),o=K(e,j.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(F)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose()})}var Am=L("HeadlessMode"),oc=L("HiddenMount");function sc(e){return e.getOrCreateInstance(oc,()=>ke(!1))}function vr(){const e=document.createElement("div");return e.dataset.canvasOffscreen="true",e.style.position="absolute",e.style.left="-10000px",e.style.top="-10000px",e.style.width="1600px",e.style.height="1000px",document.body.appendChild(e),e}function ac(e){const t=e.getInstance(oe);let n,r;e.getInstance(F)?.addDispose(()=>{r?.remove(),r=void 0}),ec(e,{resolveMount:()=>n,resolveSrc:o=>no(o==="block"),elementId:"email_iframe",mark:o=>z(o)}),t?.watch(o=>{if(n)return;const s=o?.element;if(s instanceof HTMLElement)n=s;else if(o!==void 0)n=r??=vr();else return;fe(e)?.get("email")});let i;e.getInstance(F)?.addDispose(()=>{i?.remove(),i=void 0}),sc(e).watch(o=>{const s=fe(e);if(s){if(o){i??=vr(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var co=L("canvas.headerFlow"),br=["subject","preheader"],lc=3e3,dc={subject:N.SANDBOX_SUBJECT_UPDATE,preheader:N.SANDBOX_PREHEADER_UPDATE};function cc(e){const t=ve(e),n=X(e),r=g=>g?"remote":lo(e)?"system":"user",i=(g,{guid:E,value:w,forced:S})=>{const A=Be(t);if(!A||typeof w!="string"||E&&E!==A.get().docId)return;const h=t.forcedHeaders();if(h?.[g]&&!S&&w!==h[g])return;S&&t.endForcedHeaders();const c=A.get().attributes[g]??"";d=!0;try{vt(A,{[g]:w},{source:r(S)})}finally{d=!1}o[g]=w,ie(e,j.ON_HEADER_APPLIED_ID).fire({field:g,value:w,forced:!!S,isGenerated:w!==c&&!!w})};let o={},s,d=!1,l=Promise.resolve();const f=(g,E,w)=>{l=n.sendAsync(dc[g],{value:E,guid:Be(t)?.get().docId,...w?{force:!0,echo:!0}:{}}).catch(S=>{})};let u;e.inject(co,{whenDelivered:async()=>{await l},reassert:g=>{const E=Be(t),w=br.filter(S=>g[S]);if(!(!E||w.length===0)){d=!0;try{vt(E,Object.fromEntries(w.map(S=>[S,g[S]])),{source:"system"})}finally{d=!1}t.beginForcedHeaders({subject:g.subject??"",preheader:g.preheader??""}),clearTimeout(u),u=setTimeout(()=>t.endForcedHeaders(),lc);for(const S of w)o[S]=g[S],f(S,g[S],!0)}}});const v=()=>{s?.(),s=void 0;const g=Be(t);if(!g){o={};return}const E=g.get().attributes;o={subject:E.subject,preheader:E.preheader},s=g.subscribe(({source:w})=>{if(d)return;const S=g.get().attributes,A=t.forcedHeaders();for(const h of br){const c=S[h];c!==o[h]&&(o[h]=c,f(h,c??"",w==="system"&&A?.[h]!==void 0))}})};v();const b=t.subscribe(v),y=n.addListenerAsync(N.APPLICATION_SUBJECT_UPDATE,g=>i("subject",g)),I=n.addListenerAsync(N.APPLICATION_PREHEADER_UPDATE,g=>i("preheader",g));e.getInstance(F)?.addDispose(()=>{y.dispose(),I.dispose(),b(),s?.(),clearTimeout(u)})}function yr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function dn(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];yr(i)&&yr(o)?n[r]=dn(o,i):i!==void 0&&(n[r]=i)}return n}function uc(e,t){const n=Sn;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const i=JSON.parse(r);if(i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length>0)return dn(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?dn(n,t):n}function fc(){const e=window.localStorage.getItem(Et.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?_s:Ns;return e&&e!=="system"?e:t}function pc(){const e=window.localStorage.getItem(Et.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function hc(e){const{config:t}=e;return{operation:N.UPDATE_PREVIEW,theme:e.theme,commonStyles:uc(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}function mc(e){const t=X(e),n=e.getInstance(we),r=e.getInstance(oe),i=ve(e);let o,s="";const d=()=>{const w=n?.get()??{},S=hc({config:w,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:fc(),codeMode:pc(),appName:"useblocks"}),A=JSON.stringify(S);A!==s&&(s=A,t.send(S))},l=t.onInit(()=>{s="",d()}),f=()=>{t.isInited()&&d()},u=n?.watch(f),v=r?.watch(w=>{o=w?.commonStyles,f()});let b;const y=()=>{b?.(),b=i.current()?.subscribe(f),f()};y();const I=i.subscribe(y),g=matchMedia(Is),E=()=>f();g.addEventListener("change",E),e.getInstance(F)?.addDispose(()=>{l.dispose(),u?.dispose(),v?.dispose(),b?.(),I(),g.removeEventListener("change",E)})}var cn;(function(e){function t(i,o,s=(d,l)=>d===l){if(i===o)return!0;if(i.length!==o.length)return!1;for(let d=0;d<i.length;d++)if(!s(i[d],o[d]))return!1;return!0}e.isEqual=t;function n(i,o=s=>s){const s=new Set;return i.filter(d=>{const l=o(d);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(i=[],o=[],s=(d,l)=>d===l){const d=[],l=[],f=[];for(const u of i){const v=o.find(b=>s(u,b));v?f.push({prev:u,next:v}):l.push(u)}for(const u of o)i.find(v=>s(u,v))||d.push(u);return{added:d,removed:l,exists:f}}e.diff=r})(cn||(cn={}));function gc(e,t){return e.type===t.type&&e.key===t.key}function vc(e){const t=X(e),n=()=>e.getServices(Te)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(N.SANDBOX_ADD_EXTENSIONS,r)}),o=cs(Te),s=e.onInject(d=>{if(d!==o)return;const l=n();if(!t.isInited()){r=l;return}const{added:f,removed:u}=cn.diff(r,l,gc);if(r=l,u.length){if(u.some(v=>v.type==="script")){t.send(N.RELOAD);return}t.send(N.SANDBOX_REMOVE_EXTENSIONS,u.map(v=>v.key))}f.length&&t.send(N.SANDBOX_ADD_EXTENSIONS,f)});e.getInstance(F)?.addDispose(()=>{i.dispose(),s?.dispose()})}var bc=L("prewarm.editorVisible");function yc(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Ec(e={}){const t=e.paint??yc;let n=!1,r=!1,i=!1,o=!1,s=!1;const d=[],l=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,z(J.editorVisible);for(const f of d.splice(0))f()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){i=!0,l()},whenVisible(f){if(s){f();return}d.push(f)},contentShown:()=>i}}function _c(e){return e.getOrCreateInstance(bc,()=>Ec())}var wc=500,Sc=500,Ic=5e3;function Tc(e){const t=e.quietMs??wc,n=e.floorMs??Sc,r=e.ceilingMs??Ic;let i,o,s=0;const d=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},l=()=>{d(),e.run()},f=()=>{clearTimeout(i);const u=n-(Date.now()-s);i=setTimeout(l,Math.max(t,u))};return{start(){d(),s=Date.now(),o=setTimeout(l,r),f()},notify(){i!==void 0&&f()},cancel:d}}function Ac({attributes:e,readContent:t,docId:n,hasSession:r,serverId:i,show:o}){if(!r)return;const s={id:i??void 0,renderGuid:n,showId:o?.id,isNew:i==null,showToken:o?.token},d={...e,...s};return Object.defineProperty(d,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),d}var uo="self-init:";function Cc(e){return e.startsWith(uo)}function fo(e,t){const n=e.getActiveShowRequest();return Cc(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Rc(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t();let i="";const o=()=>e.readDocument()?sn(e.readDocument()):i,s=()=>Ne(e.container).editorPolicy,d=()=>e.readEmail(),l=()=>{const f=d();return{...f,id:e.isTemplate()||f.isNew?void 0:f.id,html:o()}};return{readContent:o,publicEmail:l,sendInitStart:()=>ae(n,"INIT_START",N.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>ae(n,"INITED",N.SANDBOX_INITED,{guid:d().renderGuid},void 0,r()),async sendContent(){const f=d(),{html:u,hasBrowserExtensionArtifacts:v}=io(f?.html||"");v&&e.events.browserExtensionDetected(),oo(e.readDocument(),u),i=u,await ae(n,"SET_ENTITY",N.SANDBOX_SET_ENTITY,an(o(),f.renderGuid,s(),e.readDocument()?.get().version),{guid:f.renderGuid,emailId:f.id??null},r())},refreshContent:()=>ae(n,"SET_ENTITY",N.SANDBOX_SET_ENTITY,an(o(),d().renderGuid,s(),e.readDocument()?.get().version),void 0,r()),sendPreheader:async()=>{const f=d();if(f.preheader!==void 0)return ae(n,"PREHEADER",N.SANDBOX_PREHEADER_UPDATE,{value:f.preheader,guid:f.renderGuid,force:!0},void 0,r())},sendSubject:async()=>{const f=d();if(f.subject!==void 0)return ae(n,"SUBJECT",N.SANDBOX_SUBJECT_UPDATE,{value:f.subject,guid:f.renderGuid,force:!0},void 0,r())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:f=>e.showFilled?.(f),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(l()),fireInit(f,u){if(!fo(t(),f)){t().getActiveShowRequest()?.showId;return}const v=d();v.id,v.renderGuid,t().completeShow(f),vt(e.readDocument(),{is_inited:!0},{source:"system"});const b=l();return u&&(b.reset=!0),e.events.inited(b)},fireEmailChanged(){e.events.emailChanged(l())},fireContentChanged(){e.events.contentChanged(o())}}}function Pc(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,d;const l=Rc({...e,waitScope:()=>({getSandboxTimeoutMs:E=>t().getSandboxTimeoutMs(E),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:d?.signal??t().signal})});let f;const u=(E,w)=>{if(f===E)return;f=E;const S=s;setTimeout(()=>{s!==S||t().signal.aborted||I(E,w).catch(()=>{})},0)},v=()=>{d?.abort(),d=void 0};let b;const y=()=>{const E=t().signal;E!==b&&(b?.removeEventListener("abort",v),b=E,E.addEventListener("abort",v))};async function I(E,w){const S=++s;v(),d=new AbortController,y();const A=()=>s!==S,h=l.readTarget(),c=t().generation,a=()=>c===t().generation&&!t().signal.aborted,p=w?"init:reset-":"init:";if(!w){const T=l.publicEmail();T?.id,T?.renderGuid,T?.preheader}let m=!1,_=!1;try{n=!0,await l.sendInitStart(),l.fireWillInit(),await(w?l.refreshContent():l.sendContent()),m=!0,w||l.publicEmail()?.id;try{await l.sendPreheader()}catch(T){`${p}`,String(T)}try{await l.sendSubject()}catch(T){`${p}`,String(T)}if(A()||l.showFilled(h),await l.sendInited(),_=!0,i===E){const T=e.readSandboxGeneration?.()??o;T!==void 0&&(r=T)}await l.revealFilled()}catch(T){throw A()||(`${p}`,{...e.describeSurface?.(),error:String(T)},void 0),!A()&&fo(t(),E)&&t().failShow(E,T),T}finally{g(E,w,p,{superseded:A(),sessionGeneration:c,contentApplied:m,sandboxInitedAcked:_,commit:a()})}}function g(E,w,S,A){const{superseded:h,contentApplied:c,sandboxInitedAcked:a}=A;if(h){`${S}`;return}a&&A.commit?l.fireInit(E,w||void 0):a?(`${S}`,A.sessionGeneration,t().generation,t().signal.aborted,void 0):c?(`${S}`,void 0):(`${S}`,void 0),n=!1,d=void 0,!a&&i===E&&(i=void 0,r===o&&(r=void 0)),!a&&c&&u(E,w)}return{channel:l,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:E=>{r=E},lastCorrelation:()=>i,markCorrelation:E=>{i=E},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:E=>{o=E},fill:E=>I(E,!1),refill:E=>I(E,!0),stop:()=>{s+=1,v(),n=!1,b?.removeEventListener("abort",v),b=void 0}}}function Dc(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const r=t.emailId??t.navId;return r!=null&&String(e.id??"")!==String(r)?!1:po(e,n)}function po(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Oc(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=u=>{const v=n(),b=i();if(!Dc(v,u,b)){u.showId,u.navId,u.emailId,v?.id,v?.showId,v?.renderGuid;return}u.showId,v?.id,v?.renderGuid,t.markFilled(o()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{s(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&s(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=o();if(t.filledGeneration()===u)return;const v=n(),b=i();if(!v?.renderGuid||!po(v,b))return;const y=`${uo}${v.renderGuid}`;t.markFilled(u),t.markCorrelation(y);const I=r()?.isReady()===!0;v.id,v.renderGuid,(I?g=>t.refill(g):g=>t.fill(g))(y).catch(()=>{t.lastCorrelation()===y&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id}}}function xc(e){return e??""}function Lc(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Mc(e){const t=ve(e),n=X(e),r=()=>me(t.sessionKey())?void 0:t.current(),i=()=>{const P=r();return Ac({attributes:P?.get().attributes??{},readContent:()=>P?.getContent(),docId:P?.get().docId,hasSession:!!P,serverId:P?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(De)??Nn;let s={},d=!1;const l=e.getInstance(oe)?.watch(P=>{d=!!P?.element});let f=!1,u=!1,v=!1,b=0;const y=()=>{const P=fe(e);if(!P)return;const V=++b,q=P.spare();return q&&rc(e,q.element),(q?q.reloadQuietly():P.ensureSpare()?.ready())?.then(()=>{if(V!==b)return;f=!0;const ne=P.spare();ne&&nc(e,ne.element),v&&(v=!1,T(),W())})},I=Tc({run:()=>{v||y()?.catch(()=>{})}}),g=()=>{_c(e).noteContentShown(),!f&&!v&&I.start()};let E=!1;const A=Pc({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const P=fe(e);return E&&P&&(E=!1,I.start()),d?P?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:P=>{const V=fe(e),q=V?.spare()?.element.contentWindow;u&&V&&q&&P===q&&(u=!1,V.promote(),V.busy(!1),E=!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>ue(n),describeSurface:()=>({canvasPath:_,promoted:u,spareClean:f,handshake:n.isInited(),generation:ue(n)}),events:{willInit:P=>{ie(e,j.WILL_EMAIL_INIT_ID).fire(P)},inited:P=>{g(),ie(e,j.ON_EMAIL_INIT_ID).fire(P)},contentChanged:P=>{ie(e,j.ON_CONTENT_CHANGED_ID).fire(P)},emailChanged:P=>{ie(e,j.ON_EMAIL_CHANGED_ID).fire(P)},browserExtensionDetected:()=>{ie(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),h=Oc({pipeline:A,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>ue(n)});let c="",a="",p="";const m=P=>P.length>0;let _="none";const T=()=>{const P=fe(e)?.spare();P&&(n.send({operation:N.SANDBOX_LOCK_EDIT,data:!0}),f=!1,u=!0,tc(e,P.element))},D=(P,V)=>{const q=fe(e);if(!q)return!0;const ne=q.spare(),ye=ne&&f?"spare":"prepare";if(_=ye,q.busy(!0),ne&&f)return T(),!0;I.cancel(),n.send({operation:N.SANDBOX_LOCK_EDIT,data:!0});const Ee=y();if(Ee===void 0)return _="reload",q.busy(!1),q.peek("email")?.reload(),!0;v=!0;const Ct=b;return Ee.catch(()=>{!v||Ct!==b||(v=!1,_="reload",q.busy(!1),q.peek("email")?.reload())}),!1},R=()=>{be(),A.noteSandboxGeneration(ue(n));const P=i(),V=Lc(P?.renderGuid,P?.showId,P?.id,s.emailId),q=xc(P?.renderGuid);if(q!==a){const Ee=m(a),Ct=a;a=q,Ee&&D(Ct,q)}if(v)return;V!==c&&(c=V,h.showRequestIdentityChanged());const ne=r(),ye=`${V}|${ne?.get().docId??""}|${ue(n)}`;ye!==p&&ne?.isReady()===!0&&(p=ye,h.selfInitChanged()),h.saasChanged(),B()};let O=!1,C="",x="";const B=()=>{const P=i();if(!P?.renderGuid)return;const V=A.channel.readContent(),q=JSON.stringify([P.preheader,P.common_styles,P.meta,P.subject,P.utm_parameters?.utm_campaign??"",P.utm_parameters?.utm_content??"",P.utm_parameters?.utm_medium??"",P.utm_parameters?.utm_source??"",P.utm_parameters?.utm_term??""]),ne=O&&V!==x,ye=O&&q!==C;if(O=!0,x=V,C=q,A.isEventsLocked())return;const Ee={...P,id:s.isTemplate||P.isNew?void 0:P.id,html:V};if(ne){ie(e,j.ON_CONTENT_CHANGED_ID).fire(V),ie(e,j.ON_EMAIL_CHANGED_ID).fire(Ee);return}ye&&P.is_inited&&ie(e,j.ON_EMAIL_CHANGED_ID).fire(Ee)};let U=!1;const W=()=>{U||(U=!0,queueMicrotask(()=>{U=!1,R()}))};e.inject(Fn,{pipeline:A,setRoute:P=>{P.emailId===s.emailId&&!!P.isTemplate==!!s.isTemplate||(s=P,W())}});let de,M;const G=()=>{const P=r()?.get().docId;P!==M&&(de?.(),M=P,de=r()?.subscribe(W)),W()};let H,Y;const be=()=>{const P=e.getInstance(De);!P||P===H||(Y?.(),H=P,Y=P.onShowRequested(V=>h.showRequested(V)))},Ze=n.addListener(P=>{P.data?.operation===N.SANDBOX_RESIZED&&I.notify()}),Yo=t.subscribe(G),Xo=to(n,W);G(),e.getInstance(F)?.addDispose(()=>{l?.dispose(),Y?.(),Xo(),Yo(),de?.(),Ze.dispose(),I.cancel(),A.stop()})}function kc(){return Ls!=="useblocks"}var un={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Nc={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},Er=un,Fc=["freeUserBlocks","blocks"],ho={};function jc(e){ho=e}var mo=e=>Fc.includes(e)?Er:ho[e]??Er,fn={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},Bc={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Uc={...fn,config:{...fn.config,imageCenterFileManagerView:!1}};jc({pro:Nc,editor:Bc,simple:kc()?fn:Uc,freeUserBlocks:un,blocks:un});var _r=new Set;function Hc(){return window.localStorage.getItem(Et.em_color_scheme)??void 0}function Gc(e){return _r.add(e),e(Hc()),{dispose(){_r.delete(e)}}}function jn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function qc(e,t){return t.modeDefaults(jn(e,t.fallbackMode))}function $c(e,t){const n=jn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function zc(e,t){const n=jn(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Vc(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Kc(e){return is(e.map(t=>t?.resourceProxy))}function Wc(e){return ns(e.map(t=>t?.resourceProxyPolicy))}function Yc(e){return ms(e.map(t=>t?.backendProxy))}function Xc(e){return li(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Jc(e,t){return[e.base,qc(e,t),e.profile,e.serverSide,$c(e,t.fallbackMode),e.user,zc(e,t.fallbackMode),e.local]}function Mt(e,t){const n=Jc(e,t),r=li(n),i=Vc(n);i!==void 0&&(r.fileManager=i);const o=Kc(n);o!==void 0&&(r.resourceProxy=o);const s=Wc(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const d=Yc(n);d!==void 0&&(r.backendProxy=d);const l=Xc(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}var Qc=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function wr(e){return e==="server"?"serverSide":e}function Zc({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=ke();let o={kind:"pending"},s;const d=new Promise(b=>{s=b}),l=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function f(){o.kind!=="pending"&&i.set(Mt(r,e))}function u(b){if(o.kind!=="pending")return;clearTimeout(l),o=b;const y=Mt(r,e);i.set(y),s(y)}function v(b,y){r[wr(b)]=y,b==="server"&&o.kind==="pending"?u({kind:"applied"}):f()}return{watch:b=>i.watch(b),select:b=>i.select(b),get:()=>i.get(),ready:()=>d,state:()=>o,layers:()=>({...r}),bootstrap(){const b=Mt(r,e);return Object.fromEntries(Qc.map(y=>[y,b[y]]))},merge(b,y){v(y,{...r[wr(y)],...b})},replace(b,y){v(y,b)},setMode(b){r.user={...r.user,mode:b},f()},setAdvancedConfigs(b){r.advancedConfigs=b,f()},serverAbsent(b){u({kind:"absent",reason:b})},applyServerResponse(b){o.kind==="pending"&&v("server",{...r.serverSide,...b})},dispose(){clearTimeout(l)}}}var eu=5e3,tu="blocks";function nu(){return{...mo(tu)?.config,mergeTags:void 0}}function ru(e,t){e.getInstance(oe)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function iu(e,t){let n;Vi(e).watch(({profile:r})=>{const i=`${r?.theme??""}|${r?.locale??""}`;if(i===n)return;n=i;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function ou(e,t){let n=null;const r=Gc(i=>{const o=typeof i=="string"&&i?i:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(F)?.addDisposable(r)}async function su(e,t){if(e.getInstance(Pn)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Pe);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function au(e){e.injectFactory(we,(t,n)=>{if(n)return n;const r=Zc({base:nu(),env:{modeDefaults:i=>mo(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:eu});return ru(e,r),iu(e,r),ou(e,r),su(e,r),e.getInstance(F)?.addDisposable(r),r},!0)}var Re=class extends Z{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function k(e,t,n){const r=ts(e);return(i,o,s)=>{const d=r(async l=>{const f=t?t(l):l;s&&i.bind(s);const u=await i(f);return n?n(u):u},o,s);return()=>d.dispose()}}var lu=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new en;this.handleDestroy=k(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Re(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},Bn=L("DestroyableService");function du(e){e.injectFactory(Bn,()=>{const t=e.getInstance(F);if(!t)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new lu({lifetime:t,options:e.getInstance(oe),getInstance:()=>e.getInstance(_t),release:()=>Ds(e.getInstance(Ts)??e)})},!0)}function cu(e){const t=e.getInstance(Bn);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var uu=1e3;function go(e,t,n=uu,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const s of i)if(!go(e[s],t[s],n,r+1))return!1;return!0}return!1}function Ge(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const i=t[r],o=e[r];go(i,o)||(n[r]=i)}return n}var fu=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail не ответил за ${e}ms — письмо не сохранено`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},pu=({source:e,emailtags:t,group:n,tags:r,...i})=>i,hu=()=>Ti();async function mu({emails:e},t){const n=hu();let r;try{return await Promise.race([e.notifySave(t),new Promise((i,o)=>{r=setTimeout(()=>{const s=new fu(n);t.value.id,o(s)},n)})])}finally{r!==void 0&&clearTimeout(r)}}function gu(e){const{emails:t}=e,n=async(r,i)=>{const o=pu(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),d=s?{...s,...o}:o,l=await mu(e,{prev:s,patch:s?Ge(s,o):o,value:d,source:i.source??""}),f=String(l.id??r??le()),u=l.id===void 0?{...l,id:f}:l;return await t.cache.addOrUpdate(f,()=>u)};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const i=await n(void 0,r);return i?.renderGuid?i:{...i,renderGuid:le()}},async updateEmail(r,i){return await n(r,i)}}}var kt=20,vu=({source:e,emailtags:t,group:n,tags:r,...i})=>i;function bu({revisions:e,revisionsByEmail:t}){const n=async(r,i)=>(t.clear(),await t.get(r,{page:i}),(await e.cache.values()??[]).filter(o=>String(o?.parent)===String(r)));return{async readRevisions(r,i=1){const o=await n(r,i);return{revisions:o.slice(kt*(i-1),kt*i),page:i,hasMore:o.length>kt*i}},async readAutosave(r){return qa(await n(r,1))},async saveAutosave(r,i){const o=vu(i);return await e.create({...o,parent:r,modified:new Date().toString()})}}}var yu=class extends js{async execute([e],t){for(const n of t){const r=await n(e);r&&(r.id===void 0&&(r.id=e.value.id),e.value=r)}return e.value}},Eu=class extends pe{};var Sr=class extends Z{_items=new Map;_onChangeEmitter=new Es;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const i=await t(n);return mt(n,i)||this._onChangeEmitter.fire(),i}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([i,o])=>i)),r=(await this.entries()).filter(([i,o])=>!n.has(i));for(const[i,o]of e)t.push(this.addOrUpdate(i,()=>o)),n.add(i);for(const[i]of r)t.push(this.remove(i));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function _u(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let d=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(f=>{for(const u of l){const v=f[u],b=t[u];return u==="id"||typeof v!="string"?v===b:typeof b=="string"&&v.startsWith(b)}return!0}),d=e.length}return r&&(e=e.sort((l,f)=>(l[r]>f[r]?1:f[r]>l[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:d,total:s,totalPages:Math.ceil(d/o)}}function wu(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const i=t.get(r.id)||{};t.set(r.id,{...i,...r})}return[...t].map(([n,r])=>r)}function Su(e,t){return Ir(e)&&Ir(t)?String(e)===String(t):e===t}function Ir(e){return typeof e=="string"||typeof e=="number"}var Iu=class extends Z{_cache=new Sr;_readEmitter=new pe;_saveEmitter=this.addDisposable(new yu);_removeEmitter=this.addDisposable(new Eu);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new Z);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Sr),i=n.addDisposable(new pe);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const l=wu(await i.fire(o))||[];for(const f of l)f[e]=o,await this._cache.add(f.id,f);return l}catch{return[]}});const d=(await this._cache.values()||[]).filter(l=>{const f=l[e];return f==null||Su(f,o)});return _u(d,s)},first(o,s={}){return t.get(o,{...s,page:1,pageSize:1}).then(({data:d})=>d[0])},handleRead:i.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=le()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async i=>{const o=i?{...i,...t}:t;if(!r)return t=i?Ge(i,t):t,await this._saveEmitter.fire({prev:i,patch:t,value:o,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Je(e){const t=L(e);return n=>n.getOrCreateInstance(t,()=>new Iu)}function Tu(e){const t=e.getInstance(F);if(!t)throw new Error("Failed");return t}function Tr(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Au(e,t,n){return e&&!Tr(t)&&Tr(e)?{...n,meta:e.meta}:n}var vo=Je("plugin.dataSource.emails"),bo=Je("plugin.dataSource.emailRevisions"),Ar=L("emailDocuments.provided");function Cu(e){const t=vo(e),n=bo(e),r=n.byForeignKey("parent");return e.getInstance(Ar)?{emails:t,emailRevisions:n}:(e.inject(Ar,!0),dl(e,gu({emails:t})),pl(e,bu({revisions:n,revisionsByEmail:r})),Tu(e).addDisposable(t.onSave(({prev:i,patch:o,value:s})=>Au(i,o,s),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function Cr(e,t){return!e?.data||!t||e.id!==t.locale?!1:t.contentHash?e.hash===t.contentHash:t.updatedAt>0&&t.updatedAt<=e.time}function Ru(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Pu="po",st=null;function Du(){const e=typeof window.__useblocks__<"u"?window.__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([Pu],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Ou(){return st===null&&(st=Du().catch(e=>{throw st=null,e})),st}async function yo(e){if(typeof e=="object")return Un(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?xu(t):Lu(t)}function Un(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function xu(e){try{return Un(JSON.parse(e))}catch{return}}var Rr=!1;async function Lu(e){try{return Un((await Ou()).parsePoCatalog(e))}catch{Rr||(Rr=!0);return}}var Mu="em_locale",ku="em_ant_locale",Nu="locale",Fu="ant_locale";function Hn(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Eo(e,t){const n=Hn(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function ju(){return Hn("em_locale")??Eo(Nu,"em_locale")}function Pr(e){try{localStorage.setItem(Mu,JSON.stringify(e))}catch{}}function Bu(){return Hn("em_ant_locale")??Eo(Fu,"em_ant_locale")}function Uu(e,t){try{localStorage.setItem(ku,JSON.stringify({id:e,data:t}))}catch{}}var Hu=8e3;function Gu(e,t){const n=e,r=t,i=Object.keys(n).filter(o=>o!=="");return i.length!==Object.keys(r).filter(o=>o!=="").length?!1:i.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function qu(e){const t=ju(),n=Bu();let r={ready:!1},i;const o=ke(r);let s=0;const d=E=>{r={...r,...E},o.set(r)},l=()=>{r.ready||d({ready:!0})},f=setTimeout(l,e.unlockAfterMs??Hu),u=E=>E!==s;let v;async function b(E,w){if(n?.id===E&&n.data&&d({antd:n.data}),!v)return;const S=await v(E).catch(()=>{});!S||u(w)||(d({antd:S}),Uu(E,S))}async function y(E,w){const S=await e.askHost(E).catch(()=>null);if(u(w))return!0;if(S==null)return!1;const A=await yo(S);return u(w)||(A&&d({catalog:A}),l()),!0}async function I(E,w){const S=await e.readList();if(u(w))return;if("error"in S){d({failure:{kind:"GET_LOCALES_ERROR",error:S.error}}),l();return}const A=S.data.find(c=>c.locale===E);if(!A){Ru("em_locale")&&d({catalog:void 0}),l();return}if(Cr(t,A)&&(!i||i.catalog===t?.data)){l();return}if(i?.entry&&r.catalog===i.catalog&&Cr(i.entry,A)){Pr(i.entry),l();return}const h=await e.readCatalog(E);if(!u(w)){if("error"in h){d({failure:{kind:"GET_LOCALE_ERROR",error:h.error}}),l();return}h.data&&(i?.id===E&&r.catalog===i.catalog&&Gu(i.catalog,h.data)||d({catalog:h.data}),Pr({id:E,time:A.updatedAt||Math.floor(Date.now()/1e3),hash:A.contentHash,data:h.data})),l()}}async function g(E,w){if(!await y(E,w)){if(!u(w)&&(i?.id===E&&r.catalog===i.catalog||E==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await I(E,w)}}return{set(E){if(!E||E===r.id)return;const w=s+=1;d({id:E,failure:void 0});const S=i?.id===E&&r.catalog===i.catalog;(i&&!S&&r.catalog===i.catalog||E==="en_US"&&r.catalog)&&d({catalog:void 0}),t?.id===E&&t.data&&(d({catalog:t.data}),l()),b(E,w),g(E,w)},prime(E,w,S){r.id||r.catalog||!w||(i=t?.id===E&&t.data&&(!S||t.time>=S.time)?{id:E,catalog:t.data}:{id:E,catalog:w,entry:S?{id:E,time:S.time,hash:S.hash,data:w}:void 0},d({catalog:i.catalog}))},useAntdLoader(E){v=E,r.id&&b(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(f)}}var $u=class{http;constructor(e){this.http=e}jsonList=({locale:e},t={})=>this.http.request({path:`/translations/${e}.json`,method:"GET",format:"json",...t});getTranslations=({locale:e},t={})=>this.http.request({path:`/translations/${e}.po`,method:"GET",...t});localesList=(e={})=>this.http.request({path:"/translations/locales",method:"GET",format:"json",...e})},zu=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:o,baseUrl:s,cancelToken:d,...l})=>{const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(l,f),v=i&&this.toQueryString(i),b=this.contentFormatters[r||"application/json"],y=o||u.format;return this.customFetch(`${s||this.baseUrl||""}${n}${v?`?${v}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(d?this.createAbortSignal(d):u.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async I=>{const g=I;g.data=null,g.error=null;const E=y?I.clone():I,w=y?await E[y]().then(S=>(g.ok?g.data=S:g.error=S,g)).catch(S=>(g.error=S,g)):g;return d&&this.abortControllers.delete(d),w})}},Vu=L("rest.v2.transport"),Dr=Symbol("rest.v2.secureRequest");function Ku(e){return e.getOrCreateInstance(Vu,()=>{const t=e.getInstance(ai)?.execute||fetch;return new zu({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[Dr]:!0}),customFetch:(n,r={})=>{const{[Dr]:i,...o}=r;return t(n,{...o,[as]:i!==!0})}})})}function Wu(e,t){const n=Ku(e);return Object.assign({},...t.map(r=>new r(n)))}function Or(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function _o(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Or(n.details,"wp_code")??n.code,message:Or(n.details,"wp_message")??n.message,details:n.details}}:t&&typeof t=="object"?{status:e.status,data:t}:{status:e.status,data:{message:e.statusText||"request failed"}}}function wo(e){return!e.ok||!!e.error}function Yu(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function So(){return Yu(Et.em_translations_v2)??!0}function Xu(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Ju(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Qu(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],i=r[0];return typeof i=="string"&&i!==""&&t.push({locale:i,updatedAt:Xu(r[1])}),t},[]):[]}function Zu(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Ju(n.updated_at),contentHash:n.content_hash}),t),[])}function Io(e){return Wu(e,[$u])}function yt(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function pn(e){return!e.ok||e.error!=null}function hn(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Nt(e){return{data:await yo(e)??null}}async function ef(e){if(So())try{const n=await Io(e).localesList();return wo(n)?{error:_o(n)}:{data:Zu(n.data)}}catch(n){return yt(n)}const t=ci(e,[gi]);try{const n=await t.get_translations2({file:"react_app"});return pn(n)?hn(n):{data:Qu(n.data)}}catch(n){return yt(n)}}async function tf(e,t){if(So())try{const r=await Io(e).jsonList({locale:t});return wo(r)?{error:_o(r)}:Nt(r.data)}catch(r){return yt(r)}const n=ci(e,[gi]);try{const r=await n.get_translations3({id:t,file:"react_app"});return pn(r)?hn(r):Nt(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return pn(r)?hn(r):Nt(r.data)}catch(r){return yt(r)}}}var ze=L("locale.service");function nf(e){if(e.getInstance(ze))return;const t=qu({readList:()=>ef(e),readCatalog:n=>tf(e,n),askHost:async n=>(await ie(e,j.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(he)});e.inject(ze,t),e.getInstance(F)?.addDispose(()=>t.dispose())}function rf(e){const t=e.getInstance(we);if(!t)return;const n=e.getInstance(ze);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i));e.getInstance(F)?.addDisposable(r)}var of="user_id",sf="project_id",xr=L("rest.identityHeadersProvided");function af(e){if(e.getInstance(xr))return;e.inject(xr,!0);let t;e.getInstance(oe)?.watch(n=>{t=n}),e.addService(Tn,{execute(n,r){if(r?.public)return;const i=t?.user?.id??Ki(e).profile?.id;i!=null&&i!==""&&n.headers.set(of,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(sf,String(o))}})}function lf(e){if(!e)return!1;try{return e.getInstance(he)!==void 0}catch{return!1}}var df="Invalid standaloneKey.",Cm=L("StandaloneMockGuard");function cf(){const e=new Error(df);return e.name="InvalidStandaloneKeyError",e}function uf(e){e.addService(Tn,{execute:()=>{if(lf(e))throw cf()}})}function ff(e){ys(e),uf(e)}function pf(e){const t=new ao;e.inject(De,t);let n;const r=e.getInstance(oe)?.watch(o=>{o&&(o.signal!==void 0&&(n=o.signal),t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...n!==void 0?{signal:n}:{}}))}),i=e.getInstance(F);r&&i?.addDisposable(r),i?.addDispose(()=>{t.abort()})}var hf=Je("plugin.dataSource.blocks"),mf=Je("plugin.dataSource.blockRevisions"),gf=Je("plugin.dataSource.comments"),vf=so(),bf=so(),To=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
1004
1004
|
<html>
|
|
1005
1005
|
<head>
|
|
1006
1006
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
@@ -1041,10 +1041,10 @@ import{t as si}from"./static/esm/50fbfdf6.js";import{$ as Qo,A as Zo,At as le,B
|
|
|
1041
1041
|
</tr>
|
|
1042
1042
|
</table>
|
|
1043
1043
|
</body>
|
|
1044
|
-
</html>`;function yf(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:
|
|
1044
|
+
</html>`;function yf(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:To,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var Ef=L("CurrentProject"),_f={};function St(e){return e?.getInstance(Ef)?.get()??_f}function Ao(e){const t=St(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Co=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function wf(e){return!Object.keys(e).some(t=>Co.has(t))}function Sf(e){const t={},n={};for(const[r,i]of Object.entries(e))Co.has(r)?t[r]=i:n[r]=i;return{showOptions:t,misplacedEmailFields:n}}function Lr(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function It(e){return{emails:vo(e),blocks:hf(e),emailRevisions:bo(e),blocksRevision:mf(e),comments:gf(e)}}function If(e){const t=Object.values(It(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Gn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(wf(e))return{email:Lr(e)};{const{showOptions:n,misplacedEmailFields:r}=Sf(e),i=Object.keys(r);t&&i.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Lr({...r,...o})}}}function Ro(e){return Ln(e)?.current()}function ft(e){return Ro(e)?.getContent()}function Tf(e,t){const n=t??yf(),r=Ro(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:ft(e)??n.html}:n}async function Ft(e){return(await e.getInstanceAsync(Pe))?.project}function xe({code:e,project:t,...n},r){const i=ge(n),o=Ao(r),s=Ne(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...i,...e?{html:s.toEditorForm(e)}:{},...o===void 0?{}:{project:o},utm_parameters:i.utm_parameters||{},_embedded:void 0}}function ee({html:e,renderGuid:t,showToken:n,showId:r,...i},o){const{requested:s}=St(o),d=Wi(o);return ge({...i,code:Ne(o).toOutputForm(e),project:s===void 0?i.project:s,utm_parameters:d.UTMEnabled?i.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0})}function mn(e){return e==null?"":e.replaceAll(`\r
|
|
1045
1045
|
`,`
|
|
1046
|
-
`)}function Or(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Cf(e,t,n,r){const i=Rf(e,t,n,r);return i===void 0}function Rf(e,t,n,r){const{email:i}=Bn(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=Dn(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=Or(fn(n??d.getContent()));if(o.html!==void 0&&Or(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 xr(e,t){const{email:n}=Bn(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 Pf(e,t){const n={...e};return delete n.id,{...n,...t}}function Df(e){return e.html?e:{...e,html:Ao}}function Be({code:e,project:t,...n},r,i){const o=i??Co(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 Do(e){return Dn(e)?.current()?.get().serverId??void 0}function pn(e,t,n){return n===void 0&&(n=e.post===void 0?Do(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?Do(n):t.parent),{...t,...e?{html:e}:{},parent:r}}function Lr({html:e,...t},n){return ge({...t,code:e,guid:void 0,compiled:ge({html:e,ampHtml:e&&""})})}var Of=x("emailTemplate.reads");async function xf(e,t){try{return await Se(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message;return}}function Lf(e,t){const n=e.getOrCreateInstance(Of,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=xf(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var Mf="EXTERNAL";function kf(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"сохранение не состоялось")}var Nf="email_id",Ff=class extends Z{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_dataSources;_eventLock;_queue=Ns();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=wt(t),this._eventLock=Tf(t);const n=K(e,F.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(wn,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Nf,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(De)??Ln}_throwIfDestroyed(){if(this.isDisposed())throw Tn()}async getTemplateEmail(e){const t=await Lf(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await 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 v=u;if(u!==void 0){const b=await o.get(u);f={...b??{},...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d}}else{v=n??le();const b=await o.get(v);f={...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d},delete f.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(f=Pf(b,f))}return u===void 0&&(f=Df(f)),await s.addOrUpdate(v,()=>f),f}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==xr(this._container,e))return!1;const n=ut(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=xr(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(q(n.signal),Cf(this._container,e,ut(this._container),this._prevCommand?.id)||this._isRepeatOfLastShow(e))return;const r=Bn(e);r.email.id,this._prevCommand?.id;let i,o="",s=0,d=!1,l,f=Promise.resolve(),u,v=!1;try{this._eventLock.suspendChange();const{email:b,blocks:E,autosaves:I,comments:g,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));q(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(g)),m.push(this.setEmailRevisions(I,String(b.id)))),m.push(this.setEmail(b,Number(y),A===void 0?String(h):void 0,s,o)),await Ue("setEmail+blocks+revisions",Promise.all(m),{emailId:A??String(h),showId:o,targetShowToken:s}),q(n.signal);const _=await this._dataSources.emails.get(String(h)),T=ve(this._container),C={id:o,token:s};A===void 0?u=T.startNewDraft(_??S,{patch:S,show:C}):p?u=T.reload(A,{email:_??S,patch:S,show:C}):T.sessionKey()===Fe(A)?u=T.show(S,C):u=T.open(A,{email:_??S,patch:S,show:C});const P=!!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}),v=!0,String(h),d=!0}catch(b){l=b,v&&o&&n.failShow(o,b),String(b)}finally{this._eventLock.resumeChange()}if(!d)throw l instanceof Error?l:new Error(`[useblocks] show() setup failed: ${String(l??"unknown error")}`);return Ue("show-init-deferred",Promise.all([f,u?.whenReady().catch(b=>{if(b instanceof ht){const E=Fi(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();q(e.signal);const t=ve(this._container),n=await t.save("publish",{source:Mf});if(q(e.signal),!n)throw kf(t.saveState().error);return ee(Af(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function jf(e){return String(e).replace(/"/g,""")}function Bf(e=new Date){const t=n=>String(n).padStart(2,"0");return String(e.getFullYear())+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function Uf(e){const t=/<(table|tr|div)(\s[^>]*)>/gi;let n;for(;(n=t.exec(e))!==null;){const r=n[2]??"";if(/\bem\s*=\s*["']block["']/i.test(r))return{full:n[0],index:n.index}}return null}function Mr(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=jf(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function Hf(e,t,n){if(!e?.trim()||!t)return e;const r=Uf(e);if(!r)return e;const i=String(t),o=Bf(n??new Date);let{full:s,index:d}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=Mr(s,"em-block-id",i)),s=Mr(s,"em-block-version",o),e.slice(0,d)+s+e.slice(d+l)}function Gf(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function qf(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Gf(e)}}function Nt(e,t){return t?qf(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Oo=["title","slug","type","tags","blocktags","modified","author","lock","subject","description","excerpt","status","is_template","link","renderGuid","date","date_gmt","modified_gmt","comment_status","ping_status","template","related_email","project_title","project_author","isAmp","meta"],$f=[...Oo,"html","id","project","password"],Im=new Set(["html",...Oo,"global_block","project"]);function zf(e){if(!e||typeof e!="object")return{};const t={};e.id!=null&&e.id!==""&&(t.id=String(e.id)),e.title!=null&&e.title!==""&&(t.title=e.title),e.slug!=null&&e.slug!==""&&(t.slug=e.slug),e.type!=null&&e.type!==""&&(t.type=e.type),e.tags!=null&&(t.tags=e.tags),e.blocktags!=null&&(t.blocktags=e.blocktags),e.modified!=null&&e.modified!==""&&(t.modified=e.modified),e.author!=null&&e.author!==""&&(t.author=String(e.author)),e.lock!=null&&(t.lock=e.lock),e.subject!=null&&e.subject!==""&&(t.subject=e.subject),e.description!=null&&e.description!==""&&(t.description=e.description),e.excerpt!=null&&e.excerpt!==""&&(t.excerpt=e.excerpt),e.status!=null&&e.status!==""&&(t.status=e.status),e.is_template!=null&&(t.is_template=e.is_template),e.link!=null&&e.link!==""&&(t.link=e.link),e.renderGuid!=null&&e.renderGuid!==""&&(t.renderGuid=e.renderGuid),e.date!=null&&e.date!==""&&(t.date=e.date),e.date_gmt!=null&&e.date_gmt!==""&&(t.date_gmt=e.date_gmt),e.modified_gmt!=null&&e.modified_gmt!==""&&(t.modified_gmt=e.modified_gmt),e.comment_status!=null&&e.comment_status!==""&&(t.comment_status=e.comment_status),e.ping_status!=null&&e.ping_status!==""&&(t.ping_status=e.ping_status),e.template!=null&&e.template!==""&&(t.template=e.template),e.related_email!=null&&e.related_email!==""&&(t.related_email=e.related_email),e.project_title!=null&&e.project_title!==""&&(t.project_title=e.project_title),e.project_author!=null&&e.project_author!==""&&(t.project_author=e.project_author),e.isAmp!=null&&(t.isAmp=e.isAmp),e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object"&&(t.meta=e.meta);const n=new Set($f),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Vf(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...zf(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var mn=new WeakMap;function Kf(e){let t=mn.get(e);return t||(t={byId:new Map,fallback:[]},mn.set(e,t)),t}function Wf(e){mn.delete(e)}function Yf(e,t){const{byId:n,fallback:r}=Kf(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,d=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&d)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function Xf(e,t){const{blocks:n}=wt(e);return await n.cache.getIfPresent(t)??void 0}async function Jf(e,t){if(!t.blockId)return;const n=await Xf(e,t.blockId);if(n)return Vf(n,t)}async function Qf(e,t){const n=Yf(e,t);if(n)return Nt(e,n);const r=await Jf(t,e);return r?Nt(e,r):Nt(e,void 0)}var Zf=vs("application_block_inserted"),ep=-1e3,kr=new WeakSet;function tp(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.type=="string"||typeof t.name=="string"||typeof t.blockId=="string"||typeof t.project=="string"||typeof t.project=="number"}function np(e){if(!e||kr.has(e))return;kr.add(e);const t=new Z,n=X(e);return t.addDisposable(n.addListenerAsyncPipe(Zf,async(r,i)=>{const o=tp(r)?await Qf(r,e):r;return i?i(o):o},ep)),t.addDisposable({dispose:()=>{Wf(e)}}),t}var Nr=100,rp=class extends Z{_container;_events;constructor(e){super(),this._container=e;const t=np(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=wt(e),o=K(e,F.ON_SHARE_ID),s=K(e,F.ON_SHOW_PREVIEW_ID),d=K(e,F.ON_EMAIL_CLONE_ID),l=K(e,F.ON_CODE_VALIDATE_ID),f=K(e,F.ON_SUBJECT_CHANGED_ID),u=K(e,F.ON_EMAIL_CHANGED_ID),v=K(e,F.ON_PREHEADER_CHANGED_ID),b=K(e,F.ON_SAVEBUTTON_CLICK_ID),E=K(e,F.ON_NEXTBUTTON_CLICK_ID),I=K(e,F.ON_SEND_LIVEPREVIEW_ID),g=K(e,F.ON_SEND_TESTEMAIL_ID),y=K(e,Ef),w=K(e,F.ON_CONTENT_CHANGED_ID),S=K(e,bf),A=K(e,F.ON_PREVIOUSBUTTON_CLICK_ID),h=K(e,F.ON_SEND_EMAIL_MODAL_ID),c=ms(K(e,F.ON_EMAIL_INIT_ID),a=>!a.reset);return{handlePreheaderChanged:M(v),handleSubjectChanged:M(f),handleValidate:M(l),handleReadEmail:M(n.handlerRead,a=>a,a=>a&&xe(a,e)),handleSaveEmail:M(n.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?ee(a,e):void 0;return{prev:T,patch:He(T,ee(p,e)),value:ee(m,e),source:_}},a=>a?xe(a,e):void 0),handleRemoveEmail:M(n.onRemove,({value:a,source:p})=>({value:ee(a,e),source:p}),()=>{}),handleReadCommonBlocks:M(y,a=>a.project,a=>a?.map(p=>Be(p,e))),handleReadTemplateBlocks:M(S,a=>a,a=>a?.map(p=>Be(p,e))),handleReadBlocks:M(t.byForeignKey("project").handleRead,a=>_t(e).requested||String(a),a=>a?.map(p=>Be(p,e))),handleSaveBlock:M(t.onSave,function({prev:a,patch:p,value:m,source:_}){const T=m.global_block===!0&&m.id&&typeof m.html=="string"?{...m,html:Hf(m.html,String(m.id))}:m,C=a?st(a,e):void 0;return{prev:C,patch:He(C,st(p,e)),value:st(T,e),source:_}},a=>a?Be(a,e):void 0),handleRemoveBlock:M(t.onRemove,({value:a,source:p})=>({value:st(a,e),source:p}),()=>{}),handleReadComments:M(r.byForeignKey("post").handleRead,a=>a,a=>a?.map(p=>pn(p,e))),handleSaveComment:M(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:M(r.onRemove,({value:a,source:p})=>({value:at(a,e),source:p}),()=>{}),handleReadEmailRevisions:M(i.byForeignKey("parent").handleRead,a=>a,a=>a?.map(p=>hn(p,e))),handleEmailAutosave:M(i.onSave,function({prev:a,patch:p,value:m,source:_}){return{value:Lr(m,e),source:_}},a=>a?hn(a,e):void 0),handleRemoveEmailAutoSave:M(i.onRemove,({value:a,source:p})=>({value:Lr(a,e),source:p}),()=>{}),handleEmailChanged:M(Wn(u,Nr),a=>ee(a,e)),handleEmailInit:M(c,a=>ee(a,e)),handlePreviousButtonClick:M(A,a=>ee(a,e)),handleNextButtonClick:M(E,a=>ee(a,e)),handleSaveButtonClick:M(b,a=>ee(a,e)),handleHtmlChanged:M(Wn(w,Nr)),handleTestEmailSend:M(g,({html:a,...p})=>({...p,code:a,compiled:{html:a,ampHtml:""}})),handleTestEmailModal:M(h,a=>ee(a,e)),handleCloneEmail:M(d,a=>ee(a,e)),handleShareEmail:M(o),handlePreviewEmail:M(s),handleLivePreviewEmail:M(I)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new Re(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},ip=x("DataController"),op=x("DataEvents");function xo(e){return e.getOrCreateInstance(ip,()=>{const t=new Ff(e);return e.getInstance(N)?.addDisposable(t),t})}function Lo(e){return e.getOrCreateInstance(op,()=>new rp(e))}var sp=x("plugin.startupShow");function ap(e){const t=xo(e),n=Lo(e),r=e.getInstance(oe),i=e.getInstance(N),o={current:Promise.resolve()};e.inject(sp,o);const s=r?.watch(l=>{l&&n.setOptions(l)}),d=r?.select(l=>l?.content).watch(l=>{l!==void 0&&($(J.showStart),o.current=(async()=>{try{await t.show(l)}catch{}finally{$(J.showEnd)}})())});s&&i?.addDisposable(s),d&&i?.addDisposable(d)}function lp(e){const t=xo(e);return{...Lo(e).get(),show(n){return $(J.showStart),t.show(n).finally(()=>$(J.showEnd))},save(){return t.save()}}}var dp=[{name:"rest.client",setup:pf},{name:"auth.oauth",setup:Cs},{name:"rest.identityHeaders",setup:lf},{name:"lifetime.destroyable",provides:[Nn],setup:cu},{name:"appInit",provides:[Pe,An],setup:ua},{name:"config",provides:[we],setup:lu},{name:"email.documents",setup:Ru},{name:"show.initPipeline",provides:[De],setup:hf},{name:"show",setup:ap},{name:"locale.service",provides:[$e],setup:rf},{name:"locale.fromConfig",awaits:{services:[we,$e]},setup:of},{name:"canvas.early",setup:lc},{name:"canvas.previewSettings",setup:gc},{name:"canvas.sandboxExtensions",setup:bc},{name:"canvas.headerSync",provides:[uo],setup:uc},{name:"canvas.ampSync",setup:Bl},{name:"canvas.moduleBridge",setup:cd},{name:"canvas.port",setup:Wl},{name:"canvas.images",setup:Vl},{name:"canvas.edits",setup:qd},{name:"canvas.blockContent",setup:Fd},{name:"canvas.sandboxFill",provides:[Mn],setup:kc},{name:"canvas.reactions",setup:oc}],cp=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function up(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function fp(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function Mo(e){const t=up(e),n=[],r=new Set,i=[],o=new Set,s=d=>{if(!r.has(d)){if(o.has(d)){const l=i.indexOf(d);throw new cp([...i.slice(l),d].map(f=>f.name))}o.add(d),i.push(d);for(const l of fp(d,t))s(l);i.pop(),o.delete(d),r.add(d),n.push(d)}};for(const d of e)s(d);return n}var Fr;function Un(e){const t=e.getInstance(oe);if(t)return t;e.getInstance(N)||e.inject(N,new Z);const n=Me();e.inject(oe,n),Fr??=Mo(dp);for(const r of Fr)r.setup(e);return n}function pp(e){}var hp=[{name:"save.previewFollow",setup:pp}],jr=x("plugin.lateUnitsInstalled");function mp(e){if(!e.getInstance(jr)){e.inject(jr,!0);for(const t of Mo(hp))t.setup(e)}}function gp(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function vp(e){if(!e)return;const t=ui(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(r=>typeof r=="string"?r.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(r=>/^project_\d+$/.test(r))?.replace(/^project_/,"")||void 0}var bp=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(xs,Promise.resolve(l||""));const f=vp(l);if(!f)return;e.inject(Is,f);const u=e.getInstance(Pe),v=u?await u.catch(()=>{}):void 0;e.inject(Pe,Promise.resolve(gp(f,v)))}catch{}}}});function Ep(e,t){if(e.getInstance(Vn))return;e.inject(Vn,!0);const n=yn(e,F.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function yp(e){e.getInstance(Ss)||e.inject(he,void 0)}function St(e){return String(e.standaloneKey||"").trim()||void 0}function _p(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function Hn(e){return _p(e)?!!St(e):!1}function It(e){return!!St(e)&&!Hn(e)}var wp=Le(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!It(r)){t&&(yp(e),Hn(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(N);s&&Ep(e,s)}}}),Sp=Le(e=>{const t=e.getInstance(N),n=yn(e,di),r=M(n),i=t.addDisposable(new Re(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),Ip=Le(e=>{const t=e.getInstance(N),n=t.addDisposable(new pe),r=t.addDisposable(new pe),i=pi(e,Qo),o=M(n.event),s=M(r.event),d=M(i.event),l=t.addDisposable(new Re(o)),f=t.addDisposable(new Re(s)),u=t.addDisposable(new Re(d));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:d},async setOptions(v){l.setListener(v.handleSetOptions),f.setListener(v.handleOptionsChanged),u.setListener(v.handleConfigChanged),await n.fire(v),await r.fire(v)},dispose(){}}}),Ft,ko="core";function Tp(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([ko],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Ap(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Je().then(()=>{}):t([ko],e)}function Je(){return Ft===void 0&&(Ft=Tp().then(e=>(qe()&&e.installDiagnostics().catch(t=>{}),e))),Ft}var jt=null,Bt=null;async function Cp(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Gn(){return jt||(jt=Je().then(()=>{})),jt}function No(e){return Bt||(Bt=Cp(e)),Bt}function Rp(){return No(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Pp(e){return Promise.all([Gn(),No(e)]).then(()=>{})}function Dp(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Br(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Ap(t?{priority:t}:void 0)).then(()=>n?Gn():void 0).catch(()=>{})}function Op(e){const t=Dp(e);if(t==="eager")Br(e);else if(t==="idle"){const n=()=>Br(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Fo="PluginRegistry";function xp(e=Ds()){return e.getOrCreateInstance(Fo,()=>new Vs)}var Lp=new Ks(()=>xp()),Mp=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(Fo);t||(t=new zs(i,o,{ensureHostRuntimeReady:Rp}),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}}}),jo=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},kp=x("ELEMENT_INSERT_HTML_PIPELINE"),Np=x("BLOCK_INSERT_HTML_PIPELINE"),Fp="application_block_inserted",jp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Np,()=>new jo).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(Fp,i,t)}},Bp=x("ComponentRegistry"),Ur;function ze(e,t=Bp){const n=ft.getInstance(t);if(n)return n;if(!Ur)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return ft.getOrCreateInstance(t,Ur)}var Up=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(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(kp,()=>new jo).add(e,t??0,n)}handleInject(e,t,n){return Ce(this._container,fs).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Hp=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 Gp(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var qp=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ce(t,ds),this._closeModalEmitter=Ce(t,ss),this._updateModalEmitter=Ce(t,ps)}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(Gp({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},$p=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),n())},s=d=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),r(d))};this._resolveLoaded=o,this._rejectLoaded=s}),this.ready=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),n())},s=d=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),r(d))};this._resolveReady=o,this._rejectReady=s})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},zp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(We,()=>new Ye)}_createScriptHandle(e,t){const n=this._messageService.addListener(es,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new $p(t,n);return r}registerSandboxCSS(e){return this._container.addService(Te,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Te,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},Vp=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function gn(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Vp.has(t)}function Bo(){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:${Bo()}`}function Ht(e,t){return{type:e,props:t}}function Kp(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!gn(e)}function Hr(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(Kp(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 Wp=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=ze(this._container),n=s=>this._trackRegistration(s),r=Hr(t,e.content,n),i=e.advancedTabs?.map(s=>({...s,content:Hr(t,s.content,n)})),o=e.instanceKey??Bo();Ce(this._container,zn).fire({...e,content:r,advancedTabs:i,instanceKey:o,type:cs})}closeSettingsPanel(){this._clearPanelRegistrations(),Ce(this._container,zn).fire(null)}},Uo={SandboxScriptApi:zp,ElementsApi:Up,BlocksApi:jp,MessageService:Hp,SettingsPanelApi:Wp,ModalApi:qp};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 te={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},Yp={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},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},Gr={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Ie={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:te.border,borderRadius:te.borderRadius,textAlign:"center",padding:te.padding},qr={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:te.padding},$t={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:te.border,borderRadius:te.borderRadiusCards};function Xp(e){return{...Yp,...e}}function Jp(e){return{...qt,...e,bold:e?.bold??qt.bold,italic:e?.italic??qt.italic}}function Qp(e){return{...Gr,...e,underline:e?.underline??Gr.underline}}function Zp(e){return{...Ie,...e,bold:e?.bold??Ie.bold,italic:e?.italic??Ie.italic,border:{...Ie.border,...e?.border},borderRadius:{...Ie.borderRadius,...e?.borderRadius},padding:{...Ie.padding,...e?.padding}}}function eh(e){return{...qr,...e,padding:{...qr.padding,...e?.padding}}}function th(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 $r(e){let t={..._n};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Vt(e){return{text:Xp(e.text),headings:Jp(e.headings),links:Qp(e.links),buttons:Zp(e.buttons),block:eh(e.block),cards:th(e.cards)}}var zr=x("EmailSettingsPort"),nh=1e4,Ho=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(zr);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($r(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(zr),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===k.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!==k.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Vt(r.data?.settings?.commonStyles??{..._n}),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=nh){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=$r(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:te.border,borderRadius:te.borderRadius,padding:te.padding})),e.block!==void 0&&(n.block=Gt(n.block||{},e.block,["padding"],{padding:te.padding})),e.cards!==void 0&&(n.cards=Gt(n.cards||{},e.cards,["border","borderRadius"],{border:te.border,borderRadius:te.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)}},rh={...Uo,EmailSettingsApi:Ho},ih={...Uo},Tm={...ih,EmailSettingsApi:Ho},oh={...rh};function sh(){Lp.addAll(oh)}var ah=[Le(()=>{sh()}),Sp,Ip,wp,Rs,bp,ks];async function lh(){return(await Je()).asyncMixins}var dh=Mp,ch=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await lh()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(Et);Object.assign(o,t.instance||{});for(const s of e.getInstance(fi)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},uh=Es([...ah]);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 Vr=x("NotificationService");function fh(e){const t=Kt(),n=Kt(),r=Kt();return e.getInstance(N)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Vr).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(Vr);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(i)}}}var ph=[uu,lp,fh];function hh(e,t=ph){const n=Un(e);mp(e);const r=uh(e),i=dh(e),o=ch(e),s={...r.instance,...i.instance,...o.instance};for(const l of t)Object.assign(s,l(e));let d=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const f=d&&n.get()===l;d=!1,f||n.set(l),await i.setOptions(l),await o.setOptions(l)}}}var mh=class{_storage=Object.create(null);get(e){const t=this._storage[e];return t&&(!t.expires||t.expires<Date.now())?t.value:""}set(e,t,n){this._storage[e]={value:t,expires:n.expires?n.expires*1e3+Date.now():void 0}}remove(e){delete this._storage[e]}},gh="editor-runtime.react.copies",Wt=8;function Ve(e){return e&&typeof e=="object"?e:void 0}function Kr(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 vh(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 bh(e,t,n){return e.package===t&&e.version===n}function Eh({ourReact:e,entries:t,packageName:n,version:r}){const i=Kr(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const d of t){const l=Ve(d);if(!l||!bh(l,n,r))continue;const f=Kr(l.react);!f||f===i||s.has(f)||(s.add(f),o.push({package:n,version:r,reactVersion:vh(l.react),react:l.react}))}return o}function yh({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
|
|
1046
|
+
`)}function Mr(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Af(e,t,n,r){const i=Cf(e,t,n,r);return i===void 0}function Cf(e,t,n,r){const{email:i}=Gn(t,!1),o=xe(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const d=Ln(e)?.current();if(!d)return"no-session";const l=d.get(),f=l.attributes;if(l.serverId!==s)return"document-id";if(f.is_inited!==!0)return"not-inited";const u=Mr(mn(n??d.getContent()));if(o.html!==void 0&&Mr(mn(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==f.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==f.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==f.common_styles)return"common_styles"}function kr(e,t){const{email:n}=Gn(t,!1),r=xe(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:mn(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Rf(e,t){const n={...e};return delete n.id,{...n,...t}}function Pf(e){return e.html?e:{...e,html:To}}function Ue({code:e,project:t,...n},r,i){const o=i??Ao(r);return{...n,...e?{html:Ne(r).toEditorForm(e)}:{},renderGuid:le(),...o===void 0?{}:{project:o}}}function at({html:e,renderGuid:t,...n},r){const{requested:i}=St(r);return ge({...n,code:Ne(r).toOutputForm(e),project:i===void 0?n.project:i,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function Po(e){return Ln(e)?.current()?.get().serverId??void 0}function gn(e,t,n){return n===void 0&&(n=e.post===void 0?Po(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function lt(e,t){return ge({...e,link:void 0,comment_status:void 0})}function vn({code:e,...t},n,r){return r===void 0&&(r=t.parent===void 0?Po(n):t.parent),{...t,...e?{html:e}:{},parent:r}}function Nr({html:e,...t},n){return ge({...t,code:e,guid:void 0,compiled:ge({html:e,ampHtml:e&&""})})}var bn=L("NotificationService"),Df=L("emailTemplate.reads");async function Of(e,t){try{return await Se(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,xf(e,t,n);return}}function xf(e,t,n){e.getInstanceAsync(bn).then(()=>{In(e,j.ON_NOTIFICATION).fire({type:"error",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{})}function Lf(e,t){const n=e.getOrCreateInstance(Df,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=Of(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var Mf="EXTERNAL";function kf(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"сохранение не состоялось")}var Nf="email_id",Ff=class extends Z{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_dataSources;_eventLock;_queue=ks();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=It(t),this._eventLock=If(t);const n=K(e,j.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(Tn,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Nf,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(De)??Nn}_throwIfDestroyed(){if(this.isDisposed())throw Rn()}async getTemplateEmail(e){const t=await Lf(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Ft(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Ue(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,vn(i,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,gn(i,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,i){const o=this._dataSources.emails,s=o.cache,d=await Ft(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let f=xe(e,this._container);const u=f.id;let v=u;if(u!==void 0){const b=await o.get(u);f={...b??{},...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d}}else{v=n??le();const b=await o.get(v);f={...f,renderGuid:b?.renderGuid??le(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:d},delete f.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(f=Rf(b,f))}return u===void 0&&(f=Pf(f)),await s.addOrUpdate(v,()=>f),f}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==kr(this._container,e))return!1;const n=ft(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=kr(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:ft(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&t!==this._showRequests){this._showRequests;return}if(!e)return;const n=this._getInitPipeline();if($(n.signal),Af(this._container,e,ft(this._container),this._prevCommand?.id)||this._isRepeatOfLastShow(e))return;const r=Gn(e);r.email.id,this._prevCommand?.id;let i,o="",s=0,d=!1,l,f=Promise.resolve(),u,v=!1;try{this._eventLock.suspendChange();const{email:b,blocks:y,autosaves:I,comments:g,templateId:E,reload:w}=r;i=b.id;const S=xe(b,this._container),A=S.id,h=A??le(),c=await He("getProject",Ft(this._container));$(n.signal),o=le();const a={isNew:A===void 0,id:String(h),project:c},p=w===!0&&A!==void 0;p&&(await this._dataSources.emails.remove(String(A),{silent:!0}),String(A)),s=++this._showToken,String(h);const m=[];m.push(this.setBlocks(y)),b.id!==void 0&&(m.push(this.setComments(g)),m.push(this.setEmailRevisions(I,String(b.id)))),m.push(this.setEmail(b,Number(E),A===void 0?String(h):void 0,s,o)),await He("setEmail+blocks+revisions",Promise.all(m),{emailId:A??String(h),showId:o,targetShowToken:s}),$(n.signal);const _=await this._dataSources.emails.get(String(h)),T=ve(this._container),D={id:o,token:s};A===void 0?u=T.startNewDraft(_??S,{patch:S,show:D}):p?u=T.reload(A,{email:_??S,patch:S,show:D}):T.sessionKey()===je(A)?u=T.show(S,D):u=T.open(A,{email:_??S,patch:S,show:D});const R=!!this._prevCommand&&mt(this._prevCommand,a);a.id,!this._prevCommand||mt(this._prevCommand,a),this._prevCommand?.id,this._rememberShow(a),f=n.requestShow({showId:o,navId:String(h),emailId:A,isNew:A===void 0}),v=!0,String(h),d=!0}catch(b){l=b,v&&o&&n.failShow(o,b),String(b)}finally{this._eventLock.resumeChange()}if(!d)throw l instanceof Error?l:new Error(`[useblocks] show() setup failed: ${String(l??"unknown error")}`);return He("show-init-deferred",Promise.all([f,u?.whenReady().catch(b=>{if(b instanceof gt){const y=Ni(b);throw y?new Error(`[useblocks] show(): email open failed (${y})`,{cause:b}):b}})??Promise.resolve()]).then(()=>{}),{showId:o,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();$(e.signal);const t=ve(this._container),n=await t.save("publish",{source:Mf});if($(e.signal),!n)throw kf(t.saveState().error);return ee(Tf(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function jf(e){return String(e).replace(/"/g,""")}function Bf(e=new Date){const t=n=>String(n).padStart(2,"0");return String(e.getFullYear())+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function Uf(e){const t=/<(table|tr|div)(\s[^>]*)>/gi;let n;for(;(n=t.exec(e))!==null;){const r=n[2]??"";if(/\bem\s*=\s*["']block["']/i.test(r))return{full:n[0],index:n.index}}return null}function Fr(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=jf(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function Hf(e,t,n){if(!e?.trim()||!t)return e;const r=Uf(e);if(!r)return e;const i=String(t),o=Bf(n??new Date);let{full:s,index:d}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=Fr(s,"em-block-id",i)),s=Fr(s,"em-block-version",o),e.slice(0,d)+s+e.slice(d+l)}function Gf(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function qf(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Gf(e)}}function jt(e,t){return t?qf(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Do=["title","slug","type","tags","blocktags","modified","author","lock","subject","description","excerpt","status","is_template","link","renderGuid","date","date_gmt","modified_gmt","comment_status","ping_status","template","related_email","project_title","project_author","isAmp","meta"],$f=[...Do,"html","id","project","password"],Rm=new Set(["html",...Do,"global_block","project"]);function zf(e){if(!e||typeof e!="object")return{};const t={};e.id!=null&&e.id!==""&&(t.id=String(e.id)),e.title!=null&&e.title!==""&&(t.title=e.title),e.slug!=null&&e.slug!==""&&(t.slug=e.slug),e.type!=null&&e.type!==""&&(t.type=e.type),e.tags!=null&&(t.tags=e.tags),e.blocktags!=null&&(t.blocktags=e.blocktags),e.modified!=null&&e.modified!==""&&(t.modified=e.modified),e.author!=null&&e.author!==""&&(t.author=String(e.author)),e.lock!=null&&(t.lock=e.lock),e.subject!=null&&e.subject!==""&&(t.subject=e.subject),e.description!=null&&e.description!==""&&(t.description=e.description),e.excerpt!=null&&e.excerpt!==""&&(t.excerpt=e.excerpt),e.status!=null&&e.status!==""&&(t.status=e.status),e.is_template!=null&&(t.is_template=e.is_template),e.link!=null&&e.link!==""&&(t.link=e.link),e.renderGuid!=null&&e.renderGuid!==""&&(t.renderGuid=e.renderGuid),e.date!=null&&e.date!==""&&(t.date=e.date),e.date_gmt!=null&&e.date_gmt!==""&&(t.date_gmt=e.date_gmt),e.modified_gmt!=null&&e.modified_gmt!==""&&(t.modified_gmt=e.modified_gmt),e.comment_status!=null&&e.comment_status!==""&&(t.comment_status=e.comment_status),e.ping_status!=null&&e.ping_status!==""&&(t.ping_status=e.ping_status),e.template!=null&&e.template!==""&&(t.template=e.template),e.related_email!=null&&e.related_email!==""&&(t.related_email=e.related_email),e.project_title!=null&&e.project_title!==""&&(t.project_title=e.project_title),e.project_author!=null&&e.project_author!==""&&(t.project_author=e.project_author),e.isAmp!=null&&(t.isAmp=e.isAmp),e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object"&&(t.meta=e.meta);const n=new Set($f),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Vf(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...zf(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var yn=new WeakMap;function Kf(e){let t=yn.get(e);return t||(t={byId:new Map,fallback:[]},yn.set(e,t)),t}function Wf(e){yn.delete(e)}function Yf(e,t){const{byId:n,fallback:r}=Kf(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,d=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&d)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function Xf(e,t){const{blocks:n}=It(e);return await n.cache.getIfPresent(t)??void 0}async function Jf(e,t){if(!t.blockId)return;const n=await Xf(e,t.blockId);if(n)return Vf(n,t)}async function Qf(e,t){const n=Yf(e,t);if(n)return jt(e,n);const r=await Jf(t,e);return r?jt(e,r):jt(e,void 0)}var Zf=gs("application_block_inserted"),ep=-1e3,jr=new WeakSet;function tp(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.type=="string"||typeof t.name=="string"||typeof t.blockId=="string"||typeof t.project=="string"||typeof t.project=="number"}function np(e){if(!e||jr.has(e))return;jr.add(e);const t=new Z,n=X(e);return t.addDisposable(n.addListenerAsyncPipe(Zf,async(r,i)=>{const o=tp(r)?await Qf(r,e):r;return i?i(o):o},ep)),t.addDisposable({dispose:()=>{Wf(e)}}),t}var Br=100,rp=class extends Z{_container;_events;constructor(e){super(),this._container=e;const t=np(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=It(e),o=K(e,j.ON_SHARE_ID),s=K(e,j.ON_SHOW_PREVIEW_ID),d=K(e,j.ON_EMAIL_CLONE_ID),l=K(e,j.ON_CODE_VALIDATE_ID),f=K(e,j.ON_SUBJECT_CHANGED_ID),u=K(e,j.ON_EMAIL_CHANGED_ID),v=K(e,j.ON_PREHEADER_CHANGED_ID),b=K(e,j.ON_SAVEBUTTON_CLICK_ID),y=K(e,j.ON_NEXTBUTTON_CLICK_ID),I=K(e,j.ON_SEND_LIVEPREVIEW_ID),g=K(e,j.ON_SEND_TESTEMAIL_ID),E=K(e,bf),w=K(e,j.ON_CONTENT_CHANGED_ID),S=K(e,vf),A=K(e,j.ON_PREVIOUSBUTTON_CLICK_ID),h=K(e,j.ON_SEND_EMAIL_MODAL_ID),c=hs(K(e,j.ON_EMAIL_INIT_ID),a=>!a.reset);return{handlePreheaderChanged:k(v),handleSubjectChanged:k(f),handleValidate:k(l),handleReadEmail:k(n.handlerRead,a=>a,a=>a&&xe(a,e)),handleSaveEmail:k(n.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?ee(a,e):void 0;return{prev:T,patch:Ge(T,ee(p,e)),value:ee(m,e),source:_}},a=>a?xe(a,e):void 0),handleRemoveEmail:k(n.onRemove,({value:a,source:p})=>({value:ee(a,e),source:p}),()=>{}),handleReadCommonBlocks:k(E,a=>a.project,a=>a?.map(p=>Ue(p,e))),handleReadTemplateBlocks:k(S,a=>a,a=>a?.map(p=>Ue(p,e))),handleReadBlocks:k(t.byForeignKey("project").handleRead,a=>St(e).requested||String(a),a=>a?.map(p=>Ue(p,e))),handleSaveBlock:k(t.onSave,function({prev:a,patch:p,value:m,source:_}){const T=m.global_block===!0&&m.id&&typeof m.html=="string"?{...m,html:Hf(m.html,String(m.id))}:m,D=a?at(a,e):void 0;return{prev:D,patch:Ge(D,at(p,e)),value:at(T,e),source:_}},a=>a?Ue(a,e):void 0),handleRemoveBlock:k(t.onRemove,({value:a,source:p})=>({value:at(a,e),source:p}),()=>{}),handleReadComments:k(r.byForeignKey("post").handleRead,a=>a,a=>a?.map(p=>gn(p,e))),handleSaveComment:k(r.onSave,function({prev:a,patch:p,value:m,source:_}){const T=a?lt(a,e):void 0;return{prev:T,patch:Ge(T,lt(p,e)),value:lt(m,e),source:_}},a=>a?gn(a,e):void 0),handleRemoveComment:k(r.onRemove,({value:a,source:p})=>({value:lt(a,e),source:p}),()=>{}),handleReadEmailRevisions:k(i.byForeignKey("parent").handleRead,a=>a,a=>a?.map(p=>vn(p,e))),handleEmailAutosave:k(i.onSave,function({prev:a,patch:p,value:m,source:_}){return{value:Nr(m,e),source:_}},a=>a?vn(a,e):void 0),handleRemoveEmailAutoSave:k(i.onRemove,({value:a,source:p})=>({value:Nr(a,e),source:p}),()=>{}),handleEmailChanged:k(Jn(u,Br),a=>ee(a,e)),handleEmailInit:k(c,a=>ee(a,e)),handlePreviousButtonClick:k(A,a=>ee(a,e)),handleNextButtonClick:k(y,a=>ee(a,e)),handleSaveButtonClick:k(b,a=>ee(a,e)),handleHtmlChanged:k(Jn(w,Br)),handleTestEmailSend:k(g,({html:a,...p})=>({...p,code:a,compiled:{html:a,ampHtml:""}})),handleTestEmailModal:k(h,a=>ee(a,e)),handleCloneEmail:k(d,a=>ee(a,e)),handleShareEmail:k(o),handlePreviewEmail:k(s),handleLivePreviewEmail:k(I)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new Re(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},ip=L("DataController"),op=L("DataEvents");function Oo(e){return e.getOrCreateInstance(ip,()=>{const t=new Ff(e);return e.getInstance(F)?.addDisposable(t),t})}function xo(e){return e.getOrCreateInstance(op,()=>new rp(e))}var sp=L("plugin.startupShow");function ap(e){const t=Oo(e),n=xo(e),r=e.getInstance(oe),i=e.getInstance(F),o={current:Promise.resolve()};e.inject(sp,o);const s=r?.watch(l=>{l&&n.setOptions(l)}),d=r?.select(l=>l?.content).watch(l=>{l!==void 0&&(z(J.showStart),o.current=(async()=>{try{await t.show(l)}catch{}finally{z(J.showEnd)}})())});s&&i?.addDisposable(s),d&&i?.addDisposable(d)}function lp(e){const t=Oo(e);return{...xo(e).get(),show(n){return z(J.showStart),t.show(n).finally(()=>z(J.showEnd))},save(){return t.save()}}}var dp=[{name:"rest.client",setup:ff},{name:"auth.oauth",setup:As},{name:"rest.identityHeaders",setup:af},{name:"lifetime.destroyable",provides:[Bn],setup:du},{name:"appInit",provides:[Pe,Pn],setup:ca},{name:"config",provides:[we],setup:au},{name:"email.documents",setup:Cu},{name:"show.initPipeline",provides:[De],setup:pf},{name:"show",setup:ap},{name:"locale.service",provides:[ze],setup:nf},{name:"locale.fromConfig",awaits:{services:[we,ze]},setup:rf},{name:"canvas.early",setup:ac},{name:"canvas.previewSettings",setup:mc},{name:"canvas.sandboxExtensions",setup:vc},{name:"canvas.headerSync",provides:[co],setup:cc},{name:"canvas.ampSync",setup:jl},{name:"canvas.moduleBridge",setup:dd},{name:"canvas.port",setup:Kl},{name:"canvas.images",setup:zl},{name:"canvas.edits",setup:Gd},{name:"canvas.blockContent",setup:Nd},{name:"canvas.sandboxFill",provides:[Fn],setup:Mc},{name:"canvas.reactions",setup:ic}],cp=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function up(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function fp(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function Lo(e){const t=up(e),n=[],r=new Set,i=[],o=new Set,s=d=>{if(!r.has(d)){if(o.has(d)){const l=i.indexOf(d);throw new cp([...i.slice(l),d].map(f=>f.name))}o.add(d),i.push(d);for(const l of fp(d,t))s(l);i.pop(),o.delete(d),r.add(d),n.push(d)}};for(const d of e)s(d);return n}var Ur;function qn(e){const t=e.getInstance(oe);if(t)return t;e.getInstance(F)||e.inject(F,new Z);const n=ke();e.inject(oe,n),Ur??=Lo(dp);for(const r of Ur)r.setup(e);return n}function pp(e){}var hp=[{name:"save.previewFollow",setup:pp}],Hr=L("plugin.lateUnitsInstalled");function mp(e){if(!e.getInstance(Hr)){e.inject(Hr,!0);for(const t of Lo(hp))t.setup(e)}}function gp(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function vp(e){if(!e)return;const t=ui(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(r=>typeof r=="string"?r.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(r=>/^project_\d+$/.test(r))?.replace(/^project_/,"")||void 0}var bp=Me(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!mt(t,i.user),d=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(he)||!i.getAuthToken)&&!(!o&&!s&&!d))try{const l=await i.getAuthToken(i.user,i.project);e.inject(Os,Promise.resolve(l||""));const f=vp(l);if(!f)return;e.inject(Ss,f);const u=e.getInstance(Pe),v=u?await u.catch(()=>{}):void 0;e.inject(Pe,Promise.resolve(gp(f,v)))}catch{}}}});function yp(e,t){if(e.getInstance(Yn))return;e.inject(Yn,!0);const n=wn(e,j.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function Ep(e){e.getInstance(ws)||e.inject(he,void 0)}function Tt(e){return String(e.standaloneKey||"").trim()||void 0}function _p(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function $n(e){return _p(e)?!!Tt(e):!1}function At(e){return!!Tt(e)&&!$n(e)}var wp=Me(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!At(r)){t&&(Ep(e),$n(r)),t=void 0;return}const o=Tt(r);if(!o||t===o&&e.getInstance(he))return;t=o,e.inject(he,o);const s=e.getInstance(F);s&&yp(e,s)}}}),Sp=Me(e=>{const t=e.getInstance(F),n=wn(e,di),r=k(n),i=t.addDisposable(new Re(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),Ip=Me(e=>{const t=e.getInstance(F),n=t.addDisposable(new pe),r=t.addDisposable(new pe),i=In(e,Jo),o=k(n.event),s=k(r.event),d=k(i.event),l=t.addDisposable(new Re(o)),f=t.addDisposable(new Re(s)),u=t.addDisposable(new Re(d));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:d},async setOptions(v){l.setListener(v.handleSetOptions),f.setListener(v.handleOptionsChanged),u.setListener(v.handleConfigChanged),await n.fire(v),await r.fire(v)},dispose(){}}}),Bt,Mo="core";function Tp(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Mo],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Ap(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Qe().then(()=>{}):t([Mo],e)}function Qe(){return Bt===void 0&&(Bt=Tp().then(e=>($e()&&e.installDiagnostics().catch(t=>{}),e))),Bt}var Ut=null,Ht=null;async function Cp(e){typeof e?.prefetch=="function"&&await e.prefetch()}function zn(){return Ut||(Ut=Qe().then(()=>{})),Ut}function ko(e){return Ht||(Ht=Cp(e)),Ht}function Rp(){return ko(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Pp(e){return Promise.all([zn(),ko(e)]).then(()=>{})}function Dp(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Gr(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Ap(t?{priority:t}:void 0)).then(()=>n?zn():void 0).catch(()=>{})}function Op(e){const t=Dp(e);if(t==="eager")Gr(e);else if(t==="idle"){const n=()=>Gr(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var No="PluginRegistry";function xp(e=Ps()){return e.getOrCreateInstance(No,()=>new zs)}var Lp=new Vs(()=>xp()),Mp=Me(e=>{let t;function n(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(r){const i=e.getInstance(_t),o=e.getInstance(No);t||(t=new $s(i,o,{ensureHostRuntimeReady:Rp}),e.inject(Zt,t));const s=r?.plugins||[];i&&await t.setPlugins(s)},instance:{use(r){return typeof r=="function"?n().useByCtor(r):n().useByKey(r)},useAsync(r){return n().useAsync(r)},waitPlugin(r){return n().waitFor(r)}},dispose(){t?.dispose(),t=void 0}}}),Fo=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},kp=L("ELEMENT_INSERT_HTML_PIPELINE"),Np=L("BLOCK_INSERT_HTML_PIPELINE"),Fp="application_block_inserted",jp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Np,()=>new Fo).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Ye,()=>new Xe),i=n?e.bind(n):e;return r.addListener(Fp,i,t)}},Bp=L("ComponentRegistry"),qr;function Ve(e,t=Bp){const n=pt.getInstance(t);if(n)return n;if(!qr)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return pt.getOrCreateInstance(t,qr)}var Up=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(et,{execute:n=>{t.dispose(),e(n.value.map(r=>({name:r.name,html:r.html})))}})})}update(e,t){const n=this._container,r=Ve(n);return n.addService(et,{execute:i=>{const o=i.value.find(s=>s.name===e);if(o){const{icon:s,title:d,fallbackTooltip:l,...f}=t;s&&(o.icon=r.getReactNode(s)),d&&(o.title=r.getReactNode(d)),l&&(o.fallbackTooltip=r.getReactNode(l)),Object.assign(o,f)}}})}delete(e){this._container.addService(et,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container,r=Ve(n);return n.addService(et,{execute:i=>{i.value.splice(t??i.value.length,0,{...e,title:r.getReactNode(e.title),icon:r.getReactNode(e.icon),fallbackTooltip:r.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(kp,()=>new Fo).add(e,t??0,n)}handleInject(e,t,n){return Ce(this._container,us).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Hp=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Ye,()=>new Xe)}send(e,t,n){this._messageService.send(e,t,n)}sendAsync(e,t,n=!0){return this._messageService.sendAsync(e,t,n)}addListener(e,t,n){return this._messageService.addListener(e,t,n)}addListenerAsync(e,t,n=0){return this._messageService.addListenerAsync(e,t,n)}onInit(e,t=!0,n=0){return this._messageService.onInit(e,t,n)}isInited(){return this._messageService.isInited()}};function Gp(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var qp=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ce(t,ls),this._closeModalEmitter=Ce(t,os),this._updateModalEmitter=Ce(t,fs)}get _container(){return this._context.container}show(e){const t=Ve(this._container),n=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r=e.modalProps;return this._showModalEmitter.fire({...e,content:t.getReactNode(e.content),title:t.getReactNode(e.title),id:n,modalProps:r?{...r,footer:t.getReactNode(r.footer),okText:t.getReactNode(r.okText),cancelText:t.getReactNode(r.cancelText),closeIcon:t.getReactNode(r.closeIcon)}:void 0}),n}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=Ve(this._container),r=t.modalProps;this._updateModalEmitter.fire(Gp({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},$p=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),n())},s=d=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),r(d))};this._resolveLoaded=o,this._rejectLoaded=s}),this.ready=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),n())},s=d=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),r(d))};this._resolveReady=o,this._rejectReady=s})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},zp=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Ye,()=>new Xe)}_createScriptHandle(e,t){const n=this._messageService.addListener(Zo,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new $p(t,n);return r}registerSandboxCSS(e){return this._container.addService(Te,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Te,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Te,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},Vp=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function En(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Vp.has(t)}function jo(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}return`nohwcrypto-${Date.now()}`}function Gt(){return`__settingsPanel:${jo()}`}function qt(e,t){return{type:e,props:t}}function Kp(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!En(e)}function $r(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(En(t)){const r=Gt();return n(e.add(r,t)),qt(r,{})}if(typeof t=="function"){const r=Gt();return n(e.add(r,t)),qt(r,{})}if(Kp(t)){const r=t.type;if(typeof r=="string")return t;if(En(r)||typeof r=="function"){const i=Gt();return n(e.add(i,r)),qt(i,t.props)}return t}return t}var Wp=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=Ve(this._container),n=s=>this._trackRegistration(s),r=$r(t,e.content,n),i=e.advancedTabs?.map(s=>({...s,content:$r(t,s.content,n)})),o=e.instanceKey??jo();Ce(this._container,Wn).fire({...e,content:r,advancedTabs:i,instanceKey:o,type:ds})}closeSettingsPanel(){this._clearPanelRegistrations(),Ce(this._container,Wn).fire(null)}},Bo={SandboxScriptApi:zp,ElementsApi:Up,BlocksApi:jp,MessageService:Hp,SettingsPanelApi:Wp,ModalApi:qp};function $t(e,t,n,r={}){const i=Object.assign({},e);for(const[o,s]of Object.entries(t))if(s!==void 0)if(n.includes(o)&&typeof s=="object"&&s!==null){const d=i[o],l=r[o]??{};i[o]=Object.assign({},typeof d=="object"&&d!==null?d:l,s)}else i[o]=s;return i}var te={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},Yp={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},zt={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:24,fontSizeDim:"px",lineHeight:32,lineHeightDim:"px",color:"#333333",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},zr={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Ie={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:te.border,borderRadius:te.borderRadius,textAlign:"center",padding:te.padding},Vr={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:te.padding},Vt={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:te.border,borderRadius:te.borderRadiusCards};function Xp(e){return{...Yp,...e}}function Jp(e){return{...zt,...e,bold:e?.bold??zt.bold,italic:e?.italic??zt.italic}}function Qp(e){return{...zr,...e,underline:e?.underline??zr.underline}}function Zp(e){return{...Ie,...e,bold:e?.bold??Ie.bold,italic:e?.italic??Ie.italic,border:{...Ie.border,...e?.border},borderRadius:{...Ie.borderRadius,...e?.borderRadius},padding:{...Ie.padding,...e?.padding}}}function eh(e){return{...Vr,...e,padding:{...Vr.padding,...e?.padding}}}function th(e){return{...Vt,...e,border:{...Vt.border,...e?.border},borderRadius:{...Vt.borderRadius,...e?.borderRadius}}}function Kt(e={}){return{backgroundColor:e.backgroundColor||"",backgroundImage:(e.backgroundImage||[]).map(t=>({type:"url",value:t?.value||""})),backgroundPositionX:e.backgroundPositionX||"",backgroundPositionY:e.backgroundPositionY||"",backgroundRepeat:e.backgroundRepeat||"",backgroundSize:e.backgroundSize||"",backgroundColorContent:e.backgroundColorContent||"",textStrong:e.textStrong||!1,textItalic:e.textItalic||!1,textUnderline:e.textUnderline||!1,width:e.width,responsive:e.responsive}}function Kr(e){let t={...Sn};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Wt(e){return{text:Xp(e.text),headings:Jp(e.headings),links:Qp(e.links),buttons:Zp(e.buttons),block:eh(e.block),cards:th(e.cards)}}var Wr=L("EmailSettingsPort"),nh=1e4,Uo=class{_editor;_layoutSettingsChanged=new en;_contentStylesChanged=new en;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(Wr);if(!t)throw new Error("[extensions] настройки письма ещё не загружены — работа с UI начинается с init()");return t}_getCurrentLayoutSettings(){return Kt(this._settings().read())}_getCurrentContentStyles(){const e=Pt(this._editor.container)?.current()?.get().attributes.common_styles;return Wt(Kr(e))}_getLayoutSnapshot(e){return JSON.stringify(e)}_getContentSnapshot(e){return JSON.stringify(e)}async _ensureMessageSubscription(){if(!this._messageSubscription){if(this._messageSubscriptionPromise)return this._messageSubscriptionPromise;this._messageSubscriptionPromise=(async()=>{if(await this._editor.container.getInstanceAsync(Wr),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Ye,()=>new Xe),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const i=r?.data,o=i?.operation;if(o===N.APPLICATION_EMAIL_SETTINGS_SET){const l=Kt(i?.settings),f=this._getLayoutSnapshot(l);f!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=f,this._layoutSettingsChanged.fire(l));return}if(o!==N.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Wt(r.data?.settings?.commonStyles??{...Sn}),d=this._getContentSnapshot(s);d!==this._prevContentSnapshot&&(this._prevContentSnapshot=d,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=Kt(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=nh){const t=Pt(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,i=wn(r,j.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,d;const l=()=>{d&&(clearTimeout(d),d=void 0)},f=i(()=>{s||(s=!0,l(),f.dispose(),o())});d=setTimeout(()=>{s||(s=!0,f.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Pt(this._editor.container)?.current();if(!t)return;const n=Kr(t.get().attributes.common_styles);e.text!==void 0&&(n.text={...n.text||{},...e.text}),e.headings!==void 0&&(n.headings={...n.headings||{},...e.headings}),e.links!==void 0&&(n.links={...n.links||{},...e.links}),e.buttons!==void 0&&(n.buttons=$t(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:te.border,borderRadius:te.borderRadius,padding:te.padding})),e.block!==void 0&&(n.block=$t(n.block||{},e.block,["padding"],{padding:te.padding})),e.cards!==void 0&&(n.cards=$t(n.cards||{},e.cards,["border","borderRadius"],{border:te.border,borderRadius:te.borderRadiusCards}));const r=JSON.stringify(n);vt(t,{common_styles:r}),this._settings().markAppearanceChanged();const i=Wt(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},rh={...Bo,EmailSettingsApi:Uo},ih={...Bo},Pm={...ih,EmailSettingsApi:Uo},oh={...rh};function sh(){Lp.addAll(oh)}var ah=[Me(()=>{sh()}),Sp,Ip,wp,Cs,bp,Ms];async function lh(){return(await Qe()).asyncMixins}var dh=Mp,ch=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await lh()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(_t);Object.assign(o,t.instance||{});for(const s of e.getInstance(fi)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},uh=bs([...ah]);function Yt(){let e,t=!1;const n=new Map,r=new Map;function i(){for(const o of r.values())o();r.clear()}return{event(o,s,d){const l=Symbol("subscription");return t||(n.set(l,{listener:o,priority:s,thisArg:d}),e&&r.set(l,e(o,s,d))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(o){i(),e=o;for(const[s,{listener:d,priority:l,thisArg:f}]of n)r.set(s,o(d,l,f))},dispose(){t=!0,i(),n.clear(),e=void 0}}}function fh(e){const t=Yt(),n=Yt(),r=Yt();return e.getInstance(F)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(bn).then(i=>{t.attach(i.onNotify),n.attach(i.onError),r.attach(i.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(i){const o=e.getInstance(bn);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(i)}}}var ph=[cu,lp,fh];function hh(e,t=ph){const n=qn(e);mp(e);const r=uh(e),i=dh(e),o=ch(e),s={...r.instance,...i.instance,...o.instance};for(const l of t)Object.assign(s,l(e));let d=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const f=d&&n.get()===l;d=!1,f||n.set(l),await i.setOptions(l),await o.setOptions(l)}}}var mh=class{_storage=Object.create(null);get(e){const t=this._storage[e];return t&&(!t.expires||t.expires<Date.now())?t.value:""}set(e,t,n){this._storage[e]={value:t,expires:n.expires?n.expires*1e3+Date.now():void 0}}remove(e){delete this._storage[e]}},gh="editor-runtime.react.copies",Xt=8;function Ke(e){return e&&typeof e=="object"?e:void 0}function Yr(e){const t=Ke(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Ke(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function vh(e){const t=Ke(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Ke(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function bh(e,t,n){return e.package===t&&e.version===n}function yh({ourReact:e,entries:t,packageName:n,version:r}){const i=Yr(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const d of t){const l=Ke(d);if(!l||!bh(l,n,r))continue;const f=Yr(l.react);!f||f===i||s.has(f)||(s.add(f),o.push({package:n,version:r,reactVersion:vh(l.react),react:l.react}))}return o}function Eh({packageName:e,copies:t}){const n=[`[${e}] A second copy of React is on this page (singleton invariant broken).`,`The editor runs on its own React, the plugin got another one from ${e}/runtime/react.`,`This shows up as "Cannot read properties of null (reading 'useState')" and takes down the whole`,"editor, not just the plugin panel: plugin components render inside the editor tree.","","Found:"];for(const r of t.slice(0,Xt))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Xt&&n.push(` …and ${t.length-Xt} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
|
|
1047
|
+
`)}var Xr=new Set;function _h({packageName:e="useblocks",version:t="1.1.85-dev.7",log:n=r=>{}}={}){const r=i=>{try{const o=globalThis[Symbol.for(gh)],s=yh({ourReact:i,entries:o,packageName:e,version:t}).filter(d=>!Xr.has(d.react));if(!s.length)return;s.forEach(d=>Xr.add(d.react)),n(Eh({packageName:e,copies:s}))}catch{}};try{const i=Cn()?.modules?.React;if(i&&typeof i.then=="function"){i.then(r,()=>{});return}r(i)}catch{}}async function wh(e,t,n){$(e.signal);const r=t??pt.createChild();qn(r);const i=r.getInstance(F);async function o(){r.inject(Qo,new mh),_h();const s=hh(r),d={...s.instance,container:r,async reset(l){if($(l.signal),i.isDisposed())throw Rn();return await s.setOptions(l),d}};r.inject(_t,d);try{if(n?.onInstance?.(d),await s.setOptions(e),$(e.signal),i.isDisposed()||await r.getInstance(Zt)?.activate(),e.devTools)try{const l=r.getInstance(Zt);l&&await(await Qe()).initDevTools(r,l)}catch{}return $(e.signal),In(r,di).fire(d),d}catch(l){throw i.dispose(),l}}try{return await ht(o(),e.signal)}catch(s){throw i.isDisposed()||i.dispose(),s}}var We=new WeakMap;function Sh(e){return e?We.get(e):void 0}function Ho(e){try{e.getInstance(F)?.dispose()}catch{}try{e.dispose()}catch{}}function Ih(e,t){if(!e)return;const n=We.get(e);n&&n!==t&&Ho(n),We.set(e,t)}function Th(e,t){e&&We.get(e)===t&&We.delete(e)}function Ah(e){const t=pt.createChild();return At(e)&&t.inject(he,Tt(e)),t}var qe=new WeakMap,Ch="data-useblocks-config-styles";function Rh(e){return typeof e=="string"?e.trim():""}function Jr(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Ph(e,t,n){if(!e||typeof document>"u")return null;const r=Rh(t),i=qe.get(e),o=n||e;if(!r)return i&&(i.remove(),qe.delete(e)),null;if(i)return i.textContent!==r&&(i.textContent=r),(i.parentNode!==o||i!==o.firstChild)&&Jr(o,i),i;const s=document.createElement("style");return s.setAttribute(Ch,"true"),s.textContent=r,Jr(o,s),qe.set(e,s),s}function Dh(e){if(!e)return;const t=qe.get(e);t&&(t.remove(),qe.delete(e))}function Go(){return!1}var Oh=`
|
|
1048
1048
|
.blocks-app-initial-spinner-wrapper {
|
|
1049
1049
|
width: 100%;
|
|
1050
1050
|
height: 100%;
|
|
@@ -1073,7 +1073,7 @@ import{t as si}from"./static/esm/50fbfdf6.js";import{$ as Qo,A as Zo,At as le,B
|
|
|
1073
1073
|
100% {
|
|
1074
1074
|
transform: rotate(360deg);
|
|
1075
1075
|
}
|
|
1076
|
-
}`;function xh(){return()=>{}}function Lh(e,t){if(!qo()||!e||typeof document>"u")return xh();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=Oh,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function Mh(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function kh({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const d=o().catch(l=>{throw n.has(i)||(n.add(i),r(l)),Mh(l)||t.delete(i),l});return t.set(i,d),d},clear(){t.clear(),n.clear()},size(){return t.size}}}var qn=kh();function $o(){qn.clear()}ts(()=>qn.clear());var Xr=new WeakMap,Jr=new WeakMap;function Nh(e,t){let n=Jr.get(t);n||(n=new Map,Jr.set(t,n));const r=n.get(e);if(r!==void 0)return r;const i=t.getInstance(ai),o=Us({baseUrl:e,customFetch:i?.execute??fetch},t);return n.set(e,o),o}function $n(e){return hs(e)}function Fh(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function jh(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function Bh(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}function Uh(e,t){return async({baseUrl:n})=>{const r=$n(n);if(!r)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json"});if(e.getAuthToken&&!await Bh(e))throw jh();const o=t();if(!o)throw new Error("[Loader] appInit requires the instance container");const s=new gi(Nh(r,o)),d={headers:Object.fromEntries(i.entries()),credentials:"same-origin",failoverAttemptTimeout:Hn(e)||void 0},l=await s.app_init_create({},d);if(!l.ok)throw Fh(l.status,l.statusText);return l.data}}function Hh(e){return JSON.stringify({baseUrl:$n(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Gh(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function qh(e){return t=>qn.run(Hh(t),()=>($("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>$("appInit:end",{kind:"network"}))))}function $h(e,t){if(It(e)||!e.appInit&&!$n(e.baseUrl)||!Gh(e))return e;const n=e.appInit??Uh(e,t);let r=Xr.get(n);return r||(r=qh(n),Xr.set(n,r)),{...e,appInit:r}}var zo=0;function zh(){return zo}function Vh(){zo+=1,$o()}var Qr=new WeakMap,Zr=new WeakMap,Kh=3e4;function Wh(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function Yh(e,t){try{const n=ui(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+Kh}function Xh(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=Wh(r,i);if(o)return n.delete(s),t.delete(s),$o(),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&&($("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,i,o)).then(f=>{const u=String(f||"").trim();return u&&n.set(s,{token:f,expiresAtMs:Yh(u,Date.now())}),f}).finally(()=>{$("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function Jh(e){if(It(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Qr.get(t);const r=zh();return(!n||Zr.get(t)!==r)&&(n=Xh(t),Qr.set(t,n),Zr.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var vn=new WeakMap;function ei(e){const t=(vn.get(e)??0)+1;return vn.set(e,t),t}function Qh(e,t){return vn.get(e)===t}var Zh=new Set(["setConfig","updateConfig","show","save","getEmailSnapshot","getEmail","compileEmail","getBlocks","getEmailRevisions","getComments","validateCode","reset","useAsync"]),em=new Set(["setEmailMeta","setBlockMeta","notify"]),Vo=new Map([["getConfig","await `ready` first"],["use","use `useAsync()` or await `ready` first"],["container","await `ready` first"],["undoRedoService","await `ready` first"]]);function ti(e){if(/^handle[A-Z]/.test(e))return"event";if(Zh.has(e))return"async";if(em.has(e))return"queued";if(e==="getElement")return"element";if(e==="getCodeErrors")return"codeErrors";if(Vo.has(e))return"notReady"}function tm(e){return Vo.get(e)??"await `ready` first"}function ni(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}function nm(e,t){let n,r=0,i="pending",o,s,d;const l=new Set,f=[];let u,v;const b=new Promise((C,P)=>{u=C,v=P});b.catch(()=>{});const E=C=>n?.[C],I=C=>{const P=E(C.name);C.dispose||typeof P!="function"||(C.dispose=P(...C.args))},g=()=>l.forEach(I),y=()=>{for(const C of l)C.dispose?.(),C.dispose=void 0},w=()=>g(),S=()=>{d?.delete(w),d=void 0},A=()=>{y(),l.clear(),S(),f.length=0,n=void 0},h=()=>i==="failed"?o:Tn(),c=(C,P,j)=>{if(i==="failed"||i==="destroyed")throw h();const R=E(C);if(typeof R!="function")throw ni(C);return R.apply(j,P)},a=()=>i==="ready"?Promise.resolve():i==="pending"?b:Promise.reject(h()),p=(C,P)=>{if(i==="failed"||i==="destroyed")throw h();if(i==="ready"&&typeof E(C)!="function")throw ni(C);const j={name:C,args:P};return l.add(j),I(j),()=>{l.delete(j),j.dispose?.(),j.dispose=void 0}},m=()=>{const C=e.element;return C!==void 0&&typeof C!="string"?C:void 0},_=new Proxy({},{get(C,P,j){if(typeof P!="string"||P==="then")return;const R=ti(P);if(R==="event")return(...O)=>p(P,O);if(n&&P in n)return Reflect.get(n,P,j);switch(R){case"async":return(...O)=>a().then(()=>c(P,O,j));case"queued":return(...O)=>{if(i!=="pending")return c(P,O,j);f.push({name:P,args:O})};case"element":return m;case"codeErrors":return()=>[];case"notReady":throw new Error(`[emailmaker] \`${P}\` is not available before the editor is ready: ${tm(P)}`);default:return P in Object.prototype?Reflect.get(Object.prototype,P,j):void 0}},has(C,P){return typeof P!="string"?!1:n!==void 0&&P in n||ti(P)!==void 0}}),T=Object.create(_);return Object.defineProperty(T,"ready",{get:()=>s,enumerable:!0}),Object.defineProperty(T,"destroy",{enumerable:!0,value:()=>{if(i==="destroyed"||i==="failed")return;if(i==="pending"){i="destroyed",s?.catch(()=>{}),t(Q("[emailmaker] editor was destroyed before it was ready"));return}const C=n!==void 0&&Qh(n,r),P=n;i="destroyed",A(),C&&P?.destroy()}}),{handle:T,bind:C=>{n!==C&&(y(),S(),n=C,g(),i==="pending"&&(d=C.container.getOrCreateInstance(fi,()=>new Set),d.add(w)))},settle:()=>{const C=n;if(i==="destroyed"){A(),C&&(ei(C),C.destroy());const P=Q("[emailmaker] editor was destroyed before it was ready");throw o=P,v(P),P}C&&(r=ei(C)),i="ready",S();for(const P of f.splice(0))try{c(P.name,P.args,T)}catch(j){queueMicrotask(()=>{throw j})}u()},fail:C=>{i!=="destroyed"&&(i="failed",o=C),A(),v(C)},setReady:C=>{s=C}}}var Ko="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function rm(){return Q(Ko)}function im(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ko}function om(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 sm(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 om(n,()=>{n.id,o.abort(rm())},i),Sn(r,o.signal)}var Wo="Superseded by newer init() on the same mount element";function ri(){return Q(Wo)}function am(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Wo}var lt=new Map,dt=new WeakMap;function lm(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function dm(e){if(!e)return{release:()=>{}};const t=lm(e);dt.get(e)?.abort(ri()),t&<.get(t)?.abort(ri());const n=new AbortController;return dt.set(e,n),t&<.set(t,n),{signal:n.signal,release:()=>{dt.get(e)===n&&dt.delete(e),t&<.get(t)===n&<.delete(t)}}}var Am=si({FileManagerApiError:()=>cm}),cm=class Yo 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,Yo)}},Cm=si({mapHttpStatusToErrorCode:()=>is});function um(e,t){return{...e,element:t}}function bn(){return()=>{}}function fm(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?bn():(Ph(t,e.config?.styles,t),()=>{Dh(t)})}function pm(e){if(!qo()||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=Lh(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function ii(e){return e instanceof DOMException&&e.name==="AbortError"}function oi(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 Rm="1.1.85-dev.6";async function Pm(e){await Pp(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function Dm(e){return hm(e).ready}function hm(e){$(J.initStart);const t=new AbortController,n=Sn(e.signal,t.signal),r=nm(e,o=>t.abort(o)),i=mm({...e,signal:n},r.bind).then(()=>($(J.initEnd),r.settle(),r.handle),o=>{throw r.fail(o),o});return r.setReady(i),r.handle}async function mm(e,t){q(e.signal);const n=new Z;let r;try{const i=await Ls(e.element,n,e.signal),o=sm({hostElementOption:e.element,resolvedElement:i,externalSignal:e.signal,disposable:n}),s=dm(i);r=s.release;const d=Sn(o,s.signal);return q(d),await En(gm(e,i,t,d),d)}finally{r?.(),n.dispose()}}async function gm(e,t,n,r){q(r),Vh();const i=um(e,t),o=Jh(i);let s;const d=$h(o,()=>s),l=r!=null?{...d,signal:r}:d;if(t){const E=ce.get(t);if(E){let I;try{I=await E,q(r)}catch(g){if(q(r),Yt(t,E),ii(g))throw g;I=void 0}if(I)if(I.getElement()===t)try{return s=Sh(t),n(I),await I.reset(l)}catch(g){if(q(r),am(g)||im(g)||ii(g)&&r?.aborted)throw g;Yt(t,E,I),oi(I)}else Yt(t,E,I),oi(I)}}q(r);const f=fm(d),u=pm(d),v=r!=null?{...u.options,signal:r}:u.options;let b;try{s=Ah(v),Ih(t,s),Un(s).set(v),await Gn(),$(J.coreReady),q(r),q(r),b=wh(v,s,{onInstance:n}),t&&ce.set(t,b);const E=await b;if(r?.aborted&&(E.destroy(),q(r)),t)if(ce.get(t)===b)ce.set(t,E);else throw E.destroy(),q(r),Q(r?.reason);return E}catch(E){throw f(),u.cleanup(),s&&(Go(s),Th(t,s)),t&&b&&ce.get(t)===b&&ce.delete(t),E}}async function Om(e){return(await Je()).parseAMP(e)}typeof window<"u"&&(qe()&&sa(),Op(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{Ko as ELEMENT_DETACHED_ABORT_MESSAGE,Wo as SUPERSEDED_INIT_ABORT_MESSAGE,hm as create,Am as errors,Cm as helpers,Dm as init,im as isElementDetachedError,am as isSupersededInitError,Om as parseAMP,Lp as pluginRegistry,Pm as preload,Rm as version};
|
|
1076
|
+
}`;function xh(){return()=>{}}function Lh(e,t){if(!Go()||!e||typeof document>"u")return xh();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=Oh,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function Mh(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function kh({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const d=o().catch(l=>{throw n.has(i)||(n.add(i),r(l)),Mh(l)||t.delete(i),l});return t.set(i,d),d},clear(){t.clear(),n.clear()},size(){return t.size}}}var Vn=kh();function qo(){Vn.clear()}es(()=>Vn.clear());var Qr=new WeakMap,Zr=new WeakMap;function Nh(e,t){let n=Zr.get(t);n||(n=new Map,Zr.set(t,n));const r=n.get(e);if(r!==void 0)return r;const i=t.getInstance(ai),o=Bs({baseUrl:e,customFetch:i?.execute??fetch},t);return n.set(e,o),o}function Kn(e){return ps(e)}function Fh(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function jh(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function Bh(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}function Uh(e,t){return async({baseUrl:n})=>{const r=Kn(n);if(!r)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json"});if(e.getAuthToken&&!await Bh(e))throw jh();const o=t();if(!o)throw new Error("[Loader] appInit requires the instance container");const s=new mi(Nh(r,o)),d={headers:Object.fromEntries(i.entries()),credentials:"same-origin",failoverAttemptTimeout:$n(e)||void 0},l=await s.app_init_create({},d);if(!l.ok)throw Fh(l.status,l.statusText);return l.data}}function Hh(e){return JSON.stringify({baseUrl:Kn(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Gh(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function qh(e){return t=>Vn.run(Hh(t),()=>(z("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>z("appInit:end",{kind:"network"}))))}function $h(e,t){if(At(e)||!e.appInit&&!Kn(e.baseUrl)||!Gh(e))return e;const n=e.appInit??Uh(e,t);let r=Qr.get(n);return r||(r=qh(n),Qr.set(n,r)),{...e,appInit:r}}var $o=0;function zh(){return $o}function Vh(){$o+=1,qo()}var ei=new WeakMap,ti=new WeakMap,Kh=3e4;function Wh(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function Yh(e,t){try{const n=ui(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+Kh}function Xh(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=Wh(r,i);if(o)return n.delete(s),t.delete(s),qo(),e(r,i,o);const d=n.get(s);if(d&&!t.has(s)){if(d.expiresAtMs>Date.now())return d.token;n.delete(s)}let l=t.get(s);return l===void 0&&(z("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,i,o)).then(f=>{const u=String(f||"").trim();return u&&n.set(s,{token:f,expiresAtMs:Yh(u,Date.now())}),f}).finally(()=>{z("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function Jh(e){if(At(e))return e;const t=e.getAuthToken;if(!t)return e;let n=ei.get(t);const r=zh();return(!n||ti.get(t)!==r)&&(n=Xh(t),ei.set(t,n),ti.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var Le=new WeakMap;function Jt(e){const t=(Le.get(e)??0)+1;return Le.set(e,t),t}function Qh(e,t,n){Le.get(e)===t&&Le.set(e,n)}function ni(e,t){return Le.get(e)===t}function Zh(e){return Le.get(e)??0}var em=new Set(["setConfig","updateConfig","show","save","getEmailSnapshot","getEmail","compileEmail","getBlocks","getEmailRevisions","getComments","validateCode","reset","useAsync"]),tm=new Set(["setEmailMeta","setBlockMeta","notify"]),zo=new Map([["getConfig","await `ready` first"],["use","use `useAsync()` or await `ready` first"],["container","await `ready` first"],["undoRedoService","await `ready` first"]]);function ri(e){if(/^handle[A-Z]/.test(e))return"event";if(em.has(e))return"async";if(tm.has(e))return"queued";if(e==="getElement")return"element";if(e==="getCodeErrors")return"codeErrors";if(zo.has(e))return"notReady"}function nm(e){return zo.get(e)??"await `ready` first"}function ii(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}function rm(e,t){let n,r=0,i,o="pending",s,d,l;const f=new Set,u=[];let v,b;const y=new Promise((R,O)=>{v=R,b=O});y.catch(()=>{});const I=R=>n?.[R],g=R=>{const O=I(R.name);R.dispose||typeof O!="function"||(R.dispose=O(...R.args))},E=()=>f.forEach(g),w=()=>{for(const R of f)R.dispose?.(),R.dispose=void 0},S=()=>E(),A=()=>{l?.delete(S),l=void 0},h=()=>{w(),f.clear(),A(),u.length=0,n=void 0},c=()=>o==="failed"?s:Rn(),a=(R,O,C)=>{if(o==="failed"||o==="destroyed")throw c();const x=I(R);if(typeof x!="function")throw ii(R);return x.apply(C,O)},p=()=>o==="ready"?Promise.resolve():o==="pending"?y:Promise.reject(c()),m=(R,O)=>{if(o==="failed"||o==="destroyed")throw c();if(o==="ready"&&typeof I(R)!="function")throw ii(R);const C={name:R,args:O};return f.add(C),g(C),()=>{f.delete(C),C.dispose?.(),C.dispose=void 0}},_=()=>{const R=e.element;return R!==void 0&&typeof R!="string"?R:void 0},T=new Proxy({},{get(R,O,C){if(typeof O!="string"||O==="then")return;const x=ri(O);if(x==="event")return(...B)=>m(O,B);if(n&&O in n)return Reflect.get(n,O,C);switch(x){case"async":return(...B)=>p().then(()=>a(O,B,C));case"queued":return(...B)=>{if(o!=="pending")return a(O,B,C);u.push({name:O,args:B})};case"element":return _;case"codeErrors":return()=>[];case"notReady":throw new Error(`[emailmaker] \`${O}\` is not available before the editor is ready: ${nm(O)}`);default:return O in Object.prototype?Reflect.get(Object.prototype,O,C):void 0}},has(R,O){return typeof O!="string"?!1:n!==void 0&&O in n||ri(O)!==void 0}}),D=Object.create(T);return Object.defineProperty(D,"ready",{get:()=>d,enumerable:!0}),Object.defineProperty(D,"destroy",{enumerable:!0,value:()=>{if(o==="destroyed"||o==="failed")return;if(o==="pending"){const C=i!==void 0&&n!==void 0&&ni(n,r),x=n;o="destroyed",d?.catch(()=>{}),t(Q("[emailmaker] editor was destroyed before it was ready")),C&&(h(),x?.destroy());return}const R=n!==void 0&&ni(n,r),O=n;o="destroyed",h(),R&&O?.destroy()}}),{handle:D,bind:(R,O)=>{O?.adopt&&o==="pending"&&i===void 0?(i=Zh(R),r=Jt(R)):!O?.adopt&&n!==R&&(i=void 0),n!==R&&(w(),A(),n=R,E(),o==="pending"&&(l=R.container.getOrCreateInstance(fi,()=>new Set),l.add(S)))},settle:()=>{const R=n;if(o==="destroyed"){h(),R&&(Jt(R),R.destroy());const O=Q("[emailmaker] editor was destroyed before it was ready");throw s=O,b(O),O}R&&i===void 0&&(r=Jt(R)),o="ready",A();for(const O of u.splice(0))try{a(O.name,O.args,D)}catch(C){queueMicrotask(()=>{throw C})}v()},fail:R=>{o!=="destroyed"&&(o="failed",s=R,n&&i!==void 0&&Qh(n,r,i)),h(),b(R)},setReady:R=>{d=R}}}var Vo="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function im(){return Q(Vo)}function om(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Vo}function sm(e,t,n){if(typeof document>"u")return;let r=!1,i;const o=()=>{r=!0,i?.disconnect(),i=void 0},s=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(s);return}i=new MutationObserver(()=>{e.isConnected||s()});let d=e.parentNode;for(;d;)i.observe(d,{childList:!0}),d=d.parentNode}function am(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:i}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return sm(n,()=>{n.id,o.abort(im())},i),An(r,o.signal)}var Ko="Superseded by newer init() on the same mount element";function lm(){return Q(Ko)}function dm(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ko}var dt=new Map,ct=new WeakMap;function cm(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function um(e){if(!e)return{previous:Promise.resolve(),release:()=>{}};const t=cm(e),n=t?dt.get(t):void 0;n&&n.element!==e&&n.controller.abort(lm());const r=ct.get(e)??Promise.resolve();let i;const o=new Promise(l=>{i=l});ct.set(e,o);const s=new AbortController,d={element:e,controller:s};return t&&dt.set(t,d),{signal:s.signal,previous:r,release:()=>{i(),ct.get(e)===o&&ct.delete(e),t&&dt.get(t)===d&&dt.delete(t)}}}var Dm=si({FileManagerApiError:()=>fm}),fm=class Wo extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,i){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,Wo)}},Om=si({mapHttpStatusToErrorCode:()=>rs});function pm(e,t){return{...e,element:t}}function _n(){return()=>{}}function hm(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?_n():(Ph(t,e.config?.styles,t),()=>{Dh(t)})}function mm(e){if(!Go()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:_n()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:_n()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=Lh(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function gm(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function vm(e){return e instanceof DOMException&&e.name==="AbortError"}function oi(e){try{e.destroy()}catch{}}function Qt(e,...t){const n=ce.get(e);t.some(r=>r!==void 0&&r===n)&&ce.delete(e)}var xm="1.1.85-dev.7";async function Lm(e){await Pp(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function Mm(e){return bm(e).ready}function bm(e){z(J.initStart);const t=new AbortController,n=An(e.signal,t.signal),r=rm(e,o=>t.abort(o)),i=ym({...e,signal:n},r.bind).then(()=>(z(J.initEnd),r.settle(),r.handle),o=>{throw r.fail(o),o});return r.setReady(i),r.handle}async function ym(e,t){$(e.signal);const n=new Z;let r,i;try{const o=await xs(e.element,n,e.signal),s=am({hostElementOption:e.element,resolvedElement:o,externalSignal:e.signal,disposable:n}),d=um(o);r=d.release;const l=An(s,d.signal);return $(l),await ht(d.previous,l),i=Em(e,o,t,l),await ht(i,l)}finally{const o=r;i!==void 0&&o?i.then(o,o):o?.(),n.dispose()}}async function Em(e,t,n,r){$(r),Vh();const i=pm(e,t),o=Jh(i);let s;const d=$h(o,()=>s),l=r!=null?{...d,signal:r}:d;if(t){const y=ce.get(t);if(y){let I;try{I=await y,$(r)}catch{$(r),Qt(t,y),I=void 0}if(I)if(I.getElement()===t)try{return s=Sh(t),n(I,{adopt:!0}),await I.reset(gm(e,l))}catch(g){if($(r),dm(g)||om(g)||vm(g)&&r?.aborted)throw g;Qt(t,y,I),oi(I)}else Qt(t,y,I),oi(I)}}$(r);const f=hm(d),u=mm(d),v=r!=null?{...u.options,signal:r}:u.options;let b;try{s=Ah(v),Ih(t,s),qn(s).set(v),await zn(),z(J.coreReady),$(r),$(r),b=wh(v,s,{onInstance:n}),t&&ce.set(t,b);const y=await b;if(r?.aborted&&(y.destroy(),$(r)),t)if(ce.get(t)===b)ce.set(t,y);else throw y.destroy(),$(r),Q(r?.reason);return y}catch(y){throw f(),u.cleanup(),s&&(Ho(s),Th(t,s)),t&&b&&ce.get(t)===b&&ce.delete(t),y}}async function km(e){return(await Qe()).parseAMP(e)}typeof window<"u"&&($e()&&oa(),Op(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{Vo as ELEMENT_DETACHED_ABORT_MESSAGE,Ko as SUPERSEDED_INIT_ABORT_MESSAGE,bm as create,Dm as errors,Om as helpers,Mm as init,om as isElementDetachedError,dm as isSupersededInitError,km as parseAMP,Lp as pluginRegistry,Lm as preload,xm as version};
|
|
1077
1077
|
|
|
1078
1078
|
|
|
1079
|
-
window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/175b5b0f.js":[],"static/core/1bdeb37f.js":[],"static/core/23f020c5.js":[],"static/core/284b592e.js":[],"static/core/
|
|
1079
|
+
window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/175b5b0f.js":[],"static/core/1bdeb37f.js":[],"static/core/23f020c5.js":[],"static/core/284b592e.js":[],"static/core/3fd50a29.js":[],"static/core/48da14fd.js":[],"static/core/4c8d0155.js":[],"static/core/51a46897.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/53bcd609.js":["__delivery__/libs"],"static/core/5db1f013.js":["static/core/175b5b0f.js","__delivery__/libs"],"static/core/60aa31a3.js":[],"static/core/60f7aa8d.js":[],"static/core/6561b34a.js":[],"static/core/6a939bac.js":[],"static/core/6ff64eea.js":[],"static/core/740a4f32.js":[],"static/core/74c1d64b.js":["static/core/e2699a48.js"],"static/core/77d63e01.js":["static/core/53bcd609.js","__delivery__/libs"],"static/core/78b1e678.js":["static/core/d2bb1c0d.js","static/core/5db1f013.js","static/core/b49f995f.js","static/core/77d63e01.js","__delivery__/libs"],"static/core/7b850506.js":[],"static/core/7d627bff.js":[],"static/core/7f91ed03.js":["static/core/e2699a48.js","static/core/6a939bac.js","static/core/c28968c1.js"],"static/core/8035d07f.js":[],"static/core/991b35ff.js":[],"static/core/9ea82ab5.js":["static/core/6a939bac.js"],"static/core/a5996860.js":["static/core/175b5b0f.js"],"static/core/ac50dfd1.js":[],"static/core/b49f995f.js":["static/core/5db1f013.js","__delivery__/libs"],"static/core/c28968c1.js":["static/core/6a939bac.js"],"static/core/d2bb1c0d.js":[],"static/core/e2699a48.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/ea93d0cd.js":["static/core/b49f995f.js","static/core/53bcd609.js","__delivery__/libs","static/core/5db1f013.js"],"static/core/ec4827f1.js":[],"static/core/ec93b234.js":["static/core/175b5b0f.js","static/core/5db1f013.js","__delivery__/libs"],"static/core/fb2fe2db.js":[],"static/core/fc390885.js":[],"static/core/fdfb1e94.js":["static/core/d2bb1c0d.js","static/core/5db1f013.js","__delivery__/libs"],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"compat-globals.js":["static/esm/50fbfdf6.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/50fbfdf6.js","static/esm/ff1698e6.js"],"static/esm/50fbfdf6.js":[],"static/esm/ff1698e6.js":[]},"bundles":{"static/core/53bcd609.js":["static/core/9281699f.js","static/core/41a7e33c.js","static/core/52b6b918.js","static/core/a669ca97.js"],"static/core/74c1d64b.js":["static/core/a71c4cd8.js"],"static/core/ec93b234.js":["static/core/4d436d7d.js"],"static/core/77d63e01.js":["static/core/a73da823.js"],"static/core/ea93d0cd.js":["static/core/488a89dc.js"],"core":["static/core/2ff39ddf.js","static/core/8782e9bb.js","static/core/10c6144f.js","static/core/cb7d16ff.js","static/core/68612347.js"]}});
|