@emailmaker/emailmaker 1.3.3 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/emailmaker-core.33f5584d.js +859 -0
  3. package/emailmaker-esm.js +11 -11
  4. package/{emailmaker-po.a4e11bd0.js → emailmaker-po.33f5584d.js} +1 -1
  5. package/emailmaker.d.ts +4 -1
  6. package/emailmaker.js +12 -12
  7. package/iframe/.vite/manifest.json +4 -4
  8. package/iframe/css/sandbox-dark.css +2 -9
  9. package/iframe/css/sandbox-light.css +2 -9
  10. package/iframe/css/sandbox.css +7 -23
  11. package/iframe/{iframe-eblock.a4e11bd0.html → iframe-eblock.33f5584d.html} +2 -2
  12. package/iframe/{iframe.a4e11bd0.html → iframe.33f5584d.html} +2 -2
  13. package/iframe/js/{elMarkupHelper.Dc_IFMml.js → elMarkupHelper.B6dyF9UI.js} +74 -74
  14. package/iframe/js/{iframe-eblock.body.a4e11bd0.js → iframe-eblock.body.33f5584d.js} +1 -1
  15. package/iframe/js/iframe-eblock.js +2 -2
  16. package/iframe/js/{iframe.body.a4e11bd0.js → iframe.body.33f5584d.js} +10 -10
  17. package/iframe/js/iframe.js +2 -2
  18. package/package.json +1 -1
  19. package/runtime/react/index.js +1 -1
  20. package/static/core/{892bb74e.js → 19f19adb.js} +1 -1
  21. package/static/core/{1d705ef4.js → 239be344.js} +1 -1
  22. package/static/core/{1c5fcd3e.js → 294defd8.js} +1 -1
  23. package/static/core/{462ebf44.js → 2cee0217.js} +1 -1
  24. package/static/core/{64c240c3.js → 2fbd0ef8.js} +1 -1
  25. package/static/core/{ec552634.js → 3320a3fd.js} +1 -1
  26. package/static/core/{e70683db.js → 3a0fc0cb.js} +1 -1
  27. package/static/core/{5c396b20.js → 423efc66.js} +1 -1
  28. package/static/core/{b0c57adf.js → 42f18479.js} +1 -1
  29. package/static/core/{7c519fb4.js → 4a259bd9.js} +1 -1
  30. package/static/core/{cd998f60.js → 4ee64f35.js} +1 -1
  31. package/static/core/{2f2b6a03.js → 4fd85bc9.js} +2 -2
  32. package/static/core/{c16f27f8.js → 5150fae0.js} +2 -2
  33. package/static/core/{76d1e927.js → 5913ff80.js} +1 -1
  34. package/static/core/{762d0d48.js → 64c425bf.js} +1 -1
  35. package/static/core/{44ad0bec.js → 65db94be.js} +1 -1
  36. package/static/core/{5b124cab.js → 78663aeb.js} +1 -1
  37. package/static/core/{1708db7c.js → 89df46ff.js} +1 -1
  38. package/static/core/{b9f59067.js → 90aedd7b.js} +1 -1
  39. package/static/core/97ab9fc2.js +2 -0
  40. package/static/core/{6dfc3524.js → 99be02b7.js} +1 -1
  41. package/static/core/{9c4c7364.js → a74cc07c.js} +1 -1
  42. package/static/core/c2fc9f27.js +1 -0
  43. package/static/core/{32a14159.js → c8c233fb.js} +1 -1
  44. package/static/core/{a30b0fae.js → d4b8f1e0.js} +1 -1
  45. package/static/core/{e123b734.js → d7e61b4c.js} +1 -1
  46. package/static/core/{8608a2b9.js → e21f8693.js} +1 -1
  47. package/static/core/{a4d994c7.js → f52ad95a.js} +14 -14
  48. package/static/esm/9610f2de.js +1 -0
  49. package/static/esm/f76c9d9d.js +1 -1
  50. package/static/umd-runtime/{runtime.C95Dj7XR.js → runtime.ylG9Pc4W.js} +1 -1
  51. package/vendor/@emailmaker/ui-kit/package.json +1 -1
  52. package/vite/pluginDev/index.cjs +10 -2
  53. package/vite/pluginDev/index.js +10 -2
  54. package/webpack/pluginDev/index.cjs +10 -1
  55. package/webpack/pluginDev/index.js +10 -1
  56. package/emailmaker-core.a4e11bd0.js +0 -859
  57. package/static/core/0c2b284d.js +0 -1
  58. package/static/core/aa75c19b.js +0 -2
  59. package/static/esm/74f083c2.js +0 -1
package/emailmaker.js CHANGED
@@ -1014,7 +1014,7 @@ var __amdEnv = window.__emailmaker__ || (window.__emailmaker__ = {});
1014
1014
 
1015
1015
 
1016
1016
  // Configure AMD loader
1017
- __amdEnv.require.config({ baseUrl: "./", paths: {"core":"emailmaker-core.a4e11bd0.js","monaco":"static/monaco/index.CCINpETE.js","po":"emailmaker-po.a4e11bd0.js","static/umd-runtime/delivery-libs.js":"static/umd-runtime/delivery-libs.eFZaeVgo.js","static/umd-runtime/runtime.js":"static/umd-runtime/runtime.C95Dj7XR.js","static/umd-runtime/ui-kit-icons.js":"static/umd-runtime/ui-kit-icons.CSCUi7bp.js","static/umd-runtime/ui-kit.js":"static/umd-runtime/ui-kit.nmR1Bl60.js"} });
1017
+ __amdEnv.require.config({ baseUrl: "./", paths: {"core":"emailmaker-core.33f5584d.js","monaco":"static/monaco/index.CCINpETE.js","po":"emailmaker-po.33f5584d.js","static/umd-runtime/delivery-libs.js":"static/umd-runtime/delivery-libs.eFZaeVgo.js","static/umd-runtime/runtime.js":"static/umd-runtime/runtime.ylG9Pc4W.js","static/umd-runtime/ui-kit-icons.js":"static/umd-runtime/ui-kit-icons.CSCUi7bp.js","static/umd-runtime/ui-kit.js":"static/umd-runtime/ui-kit.nmR1Bl60.js"} });
1018
1018
 
1019
1019
  // PublicPath (script detection: entry script lookup → document.currentScript)
1020
1020
  if (!__emailmaker__.publicPath) {
@@ -1362,7 +1362,7 @@ if (!ns.assetUrl) {
1362
1362
  }
1363
1363
 
1364
1364
  if (!ns.version) {
1365
- ns.version = "1.3.3";
1365
+ ns.version = "1.3.5";
1366
1366
  }
1367
1367
 
1368
1368
  var modules = ns.modules = Object.create(null);
@@ -2093,20 +2093,20 @@ if (typeof ns.define === 'function') {
2093
2093
  __emailmaker__.define("static/umd/790cf6cb.js",["require","exports","module"],function(y,_,w){var p=Object.create,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,b=Object.getOwnPropertyNames,f=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,O=(e,r)=>()=>(r||(e((r={exports:{}}).exports,r),e=null),r.exports),v=(e,r)=>{let t={};for(var u in e)a(t,u,{get:e[u],enumerable:!0});return r||a(t,Symbol.toStringTag,{value:"Module"}),t},P=(e,r,t,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(var c=b(r),l=0,j=c.length,n;l<j;l++)n=c[l],!o.call(e,n)&&n!==t&&a(e,n,{get:(s=>r[s]).bind(null,n),enumerable:!(u=i(r,n))||u.enumerable});return e},g=(e,r,t)=>(t=e!=null?p(f(e)):{},P(r||!e||!e.__esModule||!o.call(e,"default")?a(t,"default",{value:e,enumerable:!0}):t,e));Object.defineProperty(_,"__commonJSMin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_,"__exportAll",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_,"__toESM",{enumerable:!0,get:function(){return g}})});
2094
2094
 
2095
2095
 
2096
- __emailmaker__.define("static/umd/17c59c44.js",["require","exports","module"],function(jn,a,Fn){var g=class ct{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof ct&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const r=this._inner.indexOf(t);r>=0&&this._inner.splice(r,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function M(e){return`service_container_${e}`}var P=new Set,X;function ut(){if(!X)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,se.prototype.getInstanceAsync),e.stack}function W(e){P.delete(e)&&X?.end(e)}var se=class oe extends g{_parent;_injectCallbacks=[];_injections=Object.create(null);_runCallbacks(t){[...this._injectCallbacks].forEach(r=>r(t))}constructor(t=null){super(),this._parent=t,t&&this.addDisposable(t.onInject(r=>this._runCallbacks(r)))}onInject=t=>(this._injectCallbacks.push(t),{dispose:()=>{const r=this._injectCallbacks.indexOf(t);r>=0&&this._injectCallbacks.splice(r,1)}});inject(t,r){this._injections[t]=()=>r,this._runCallbacks(t)}injectFactory(t,r,n){const i=this._injections[t];let o=typeof i=="function"?i():i;const s=this._injections[t]=()=>(o=r(this,o),o);n&&s(),this._runCallbacks(t)}_find(t,r=!0){return this._injections[t]||r&&this._parent?._find(t)}_onInject(t,r,n=new g){return n.addDisposable(this.onInject(i=>{t===i&&!n.isDisposed()&&(n.dispose(),r(this.getInstance(i)))})),this._parent&&n.addDisposable(this._parent._onInject(t,r,n)),this.addDisposable(n),n}getInstance(t,r=!0){const n=this._find(t,r);if(typeof n=="function")return n()}getOrCreateInstance(t,r){const n=this._find(t);if(typeof n=="function")return n();const i=r(this);return this.inject(t,i),i}getInstanceAsync(t){const r=this._find(t);if(typeof r=="function")return Promise.resolve(r());const n=ut();return new Promise((i,o)=>{const s={id:String(t),startedAt:Date.now(),origin:n,container:this,reject:o};P.add(s),X?.start(s),this._onInject(t,()=>{W(s),i(this.getInstance(t))})})}failPendingWaits(t){for(const r of Array.from(P))r.container===this&&(W(r),r.reject(t))}pendingWaits(){return[...P].filter(t=>t.container===this)}addService(t,r){const n=M(t);this.injectFactory(n,(o,s=[])=>s.indexOf(r)<0?[...s,r]:s);const i=new g;return i.addDispose(()=>{this.injectFactory(n,(o,s=[])=>s.filter(c=>c!==r))}),i}addServiceFactory(t,r,n){const i=M(t);let o;this.injectFactory(i,(c,u=[])=>(o=r(c,o),o===void 0?u:u.indexOf(o)<0?[...u,o]:u),n);const s=new g;return s.addDispose(()=>{this.injectFactory(i,(c,u=[])=>o===void 0?u:u.filter(_=>_!==o))}),s}getServices(t){const r=M(t);return[...this.getInstance(r,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new oe(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const r=this._parent?.getOrCreateIsolatedContainer(t);return new oe(r)})}remove(t){const r=this._injections;delete r[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(P))t.container===this&&W(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function $(e){return e.startsWith("__")?e:`__${e}__`}function _t(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=$(e),r=globalThis;return r[t]??={}}function lt(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function dt(e){if(e)return $(e);const t="emailmaker".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return $(t)}function ae(e){const t=dt(e),r=_t(t);if(lt(r.container))return r.container;const n=new se(null);return r.container=n,n}function ft(e){return ae(e)}function Et(){let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let n=Math.random()*16;return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),(r==="x"?n:n&3|8).toString(16)})}function ce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Et()}function f(e=ce()){return e}function ue(){return"umd".trim()||"unknown"}function pt(e){if(typeof globalThis>"u")return;const t=ue(),r=globalThis[e]??{};globalThis[e]=r;const n=r.__diagnostics??={},i=n.diModuleEval??={evalCount:0,records:[]};i.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),i.evalCount+=1}function ht(){const e="emailmaker".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function Ot(e,t){if(pt(t),typeof globalThis>"u")return e;const r=ue(),n=globalThis,i=n[t]=n[t]||{},o=i.__diagnostics=i.__diagnostics||{},s=o.dependencyResolver=o.dependencyResolver||{entries:[]},c={container:e,source:"packages/runtime-core/di/index.ts",buildSource:r,timestamp:Date.now(),stack:new Error().stack};return s.entries.push(c),e}var B;function mt(){if(B)return B;const e=ht();return B=Ot(ae(e),e),B}var K=new Proxy({},{get(e,t,r){const n=mt(),i=Reflect.get(n,t,r);return typeof i=="function"?i.bind(n):i}});function At(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}function S(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e===void 0?"The operation was aborted.":typeof e=="string"?e:e instanceof Error?e.message:String(e);return new DOMException(t,"AbortError")}function gt(e){return e instanceof DOMException&&e.name==="AbortError"}function q(e){if(e?.aborted)throw S(e.reason)}function It(e,t){return t?(t.aborted&&e.catch(()=>{}),q(t),new Promise((r,n)=>{const i=()=>{o(),n(S(t.reason))},o=()=>{t.removeEventListener("abort",i)};t.addEventListener("abort",i),e.then(s=>{o(),r(s)},s=>{o(),n(s)})})):e}var _e=class extends g{_options;_listeners=[];constructor(e={}){super(),this._options=e}getListeners(e){return this._listeners.flatMap(([t])=>typeof t=="function"?t:t.getListeners(e))}hasListeners(){for(const[e]of this._listeners){if(typeof e=="function")return!0;const t=e;if(typeof t.hasListeners=="function"){if(t.hasListeners())return!0;continue}return!0}return!1}_addListener(e,t=0,r){if(this.isDisposed())return{dispose:()=>{}};const n=this._listeners,i=this._options;r&&typeof e=="function"&&(e=e.bind(r));const o=n.findIndex(([,c])=>c<t),s=[e,t];return n.splice(o>=0?o:n.length,0,s),n.length===1&&i.onFirstListenerAdd&&i.onFirstListenerAdd(),{dispose:()=>{const c=n.indexOf(s);c>=0&&(n.splice(c,1),!n.length&&i.onLastListenerRemove&&i.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,r)=>{const n=this._addListener((...i)=>(n?.dispose(),r?e.call(r,...i):e(...i)),t);return n};un=e=>{const t=this._listeners.findIndex(([r])=>r===e);t>=0&&(this._listeners.splice(t,1),this._listeners.length===0&&this._options.onLastListenerRemove&&this._options.onLastListenerRemove())};dispose(){this._listeners.splice(0,this._listeners.length),this._options.onLastListenerRemove&&this._options.onLastListenerRemove(),super.dispose()}},b=class extends _e{execute(e,t){for(const r of t)try{r(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},Tt=class extends b{execute([e],t){for(const r of t)try{r(e)}catch{}}},St=class extends b{_suspendCounter=0;_wasFired=!1;execute([e],t){if(this._suspendCounter)this._wasFired=!0;else for(const r of t)try{r(e)}catch{}}suspend(){this._suspendCounter++}resume(){--this._suspendCounter===0&&this._wasFired&&(this.fire(),this._wasFired=!1)}},j=class extends b{async execute([e],t){const r=[];for(const n of t)try{r.push(await n(e))}catch{}return r}async fireSettled(e){const t={results:[],errors:[]};if(this.isDisposed())return t;for(const r of this.getListeners([e]))try{t.results.push(await r(e))}catch(n){t.errors.push(n)}return t}};function bt(e,t=0){const r=new _e,n=e(r,t);return n&&r.addDisposable(n),r.event}function Dt(e,t,r=0){const n=new b,i=e((...o)=>{if(t(...o))return n.fire(...o)},r);return i&&n.addDisposable(i),n.event}function Nt(e,t=0,r=0){const n=new b;let i,o;const s=e((...c)=>{o=c,i||(i=setTimeout(()=>{o&&n.fire(...o),i=void 0},t))},r);return s&&n.addDisposable(s),n.event}function yt(e,t){return e.getOrCreateInstance(t,()=>new j)}function d(e){return f(e)}var Y;(function(e){e.BEFORE_SAVE_EMAIL=d("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=d("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=d("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=d("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=d("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=d("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=d("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=d("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=d("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=d("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=d("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=d("events.ON_EMAIL_CHANGED_ID"),e.ON_BLOCK_CHANGED_ID=d("events.ON_BLOCK_CHANGED_ID"),e.ON_BLOCK_OPEN_ID=d("events.ON_BLOCK_OPEN_ID"),e.ON_BLOCK_CLOSE_ID=d("events.ON_BLOCK_CLOSE_ID"),e.OPEN_BLOCK_REQUEST_ID=d("events.OPEN_BLOCK_REQUEST_ID"),e.ON_BLOCK_SAVEBUTTON_CLICK_ID=d("events.ON_BLOCK_SAVEBUTTON_CLICK_ID"),e.ON_BLOCK_CLONE_ID=d("events.ON_BLOCK_CLONE_ID"),e.ON_CHUNKS_LOADED=d("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=d("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=d("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=d("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=d("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=d("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=d("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_ANALYTICS_EVENT=d("events.ON_ANALYTICS_EVENT"),e.ON_NOTIFICATION=d("events.ON_NOTIFICATION"),e.READ_LOCALE=d("events.READ_LOCALE"),e.ON_TRANSLATE_ID=d("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=d("events.ON_CODE_VALIDATE_ID"),e.ON_IMPORT_VALIDATE_ID=d("events.ON_IMPORT_VALIDATE_ID"),e.UPLOAD_EVENT_ID=d("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=d("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=d("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=d("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=d("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=d("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=d("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=d("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=d("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=d("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=d("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=d("events.AI_TEXT_STREAM_ID")})(Y||(Y={}));function Pt(e,t){return e.getOrCreateInstance(t,()=>new j).event}function Ct(e,t){return e.getOrCreateInstance(t,()=>new j)}var vt=f("plugin.app"),Lt=f("plugin.disposable"),Rt=f("InitPipelineContext"),wt=f("plugin.instance"),Mt=f("plugin.lateSurfaceListeners"),le=f("plugin.optionsSource"),Bt=f("plugin.store"),de=f("ConfigSource"),jt=f("plugin.standalone.project"),fe=f("plugin.standalone.bootstrapToken"),xn=f("plugin.element"),Ee=f("plugin.securityModule"),Ft=f("plugin.standalone.activated"),xt=f("plugin.standalone.fileProxyRegistered"),z=f("plugin.jwt.token"),C=f("plugin.jwt.error"),kt=f("PluginCollection"),Ut=d("APP_LOAD_EVENT"),Ht=d("CONFIG_CHANGED_EVENT");function Gt(e,t=window){return{peer:e,send(r){e.postMessage(r,"*")},subscribe(r){const n=i=>{r({data:i.data,source:i.source,ports:i.ports})};return t.addEventListener("message",n),{dispose:()=>t.removeEventListener("message",n)}},close(){}}}function Vt(e){let t=!1;return{peer:e,send(r){e.postMessage(r)},subscribe(r){const n=i=>{r({data:i.data,source:e})};return e.addEventListener("message",n),t||(t=!0,e.start()),{dispose:()=>e.removeEventListener("message",n)}},close(){e.close()}}}function Xt(e){return e}function Wt(e){return e&&typeof e=="object"}function pe(e,t){return e&&typeof e=="object"&&e.operationId===t}var T="INIT_MESSAGE",he="em:port-ready",$t="em:window-drained",F="";function Oe(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var Kt=class extends g{_listeners=Object.create(null);addListenerAsync=(e,t,r=0,n)=>{const i=this._listeners[e]||(this._listeners[e]=[]);n&&typeof t=="function"&&(t=t.bind(n));const o=i.findIndex(([c,u])=>r<=u),s=[t,r];return this.isDisposed()||i.splice(o>=0?o:i.length,0,s),{dispose(){const c=i.indexOf(s);c>=0&&i.splice(c,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const r=this._listeners[e]||(this._listeners[e]=[]);let n;for(let i=0;i<r.length;i++){const o=r[i][0],s=n;n=c=>o(c,s)}if(n)return n(t)}};addListener=(e,t,r=0)=>this.addListenerAsync(e,(n,i)=>{try{t(n)}catch{}return i&&i(n)},r)},qt=class extends g{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_portSendHeld=new WeakSet;_inited=!1;_emitter=this.addDisposable(new Kt);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;_outgoingObservers=new Set;_offTargetListeners=new Map;constructor(e,t){super(),this._singleton=t,this._transport=Gt({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(T,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(T))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,r=t.data,n=t.source,i=r?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&n&&r?.operationId==="em:window-drained"){this._ports.has(n)&&this._drained.add(n);return}if(o&&n&&this._drained.has(n))return;if(n&&n!==this._target&&this._greeted.has(n)&&pe(r,T)){this._greeted.delete(n),this._handshaken.add(n),this._postMessage(n,{operationId:T,data:{}}),i&&this.usePort(i,!0,n);return}const s=t.source===this.target||this._isCurrentPort(t.source);if(s||this._notifyOffTarget(r?.operationId,t.source),Wt(r)&&s||this._singleton&&pe(r,T)){if(i&&s){const l=this._target;Promise.resolve().then(()=>this.usePort(i,!0,l))}const c=this._emitter.fireAsync(r.operationId||F,r.operationId===void 0?t:r.data),u=r.result,_=r.error;u&&_&&Promise.resolve(c).then(l=>this._sendMessage(u,l),l=>this._sendMessage(_,l))}};setTarget(e){if(this._target!==e){if(this._target=e,!e){this._inited=!1;return}if(this._handshaken.has(e)){this._inited=!0,this._emitter.fireAsync(T,void 0);return}this._inited=!1,this._postMessage(e,{operationId:T,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:T,data:{},port:!0},[t])}observeOutgoing(e){return this._outgoingObservers.add(e),{dispose:()=>{this._outgoingObservers.delete(e)}}}_notifyOutgoing(e,t){for(const r of Array.from(this._outgoingObservers))try{r(e,t)}catch{}}addOffTargetListener(e,t){let r=this._offTargetListeners.get(e);return r||(r=new Set,this._offTargetListeners.set(e,r)),r.add(t),{dispose:()=>{r.delete(t)}}}_notifyOffTarget(e,t){const r=typeof e=="string"?this._offTargetListeners.get(e):void 0,n=r?.size?this._knownPeer(t):void 0;if(!(!r||!n))for(const i of Array.from(r))try{i(n)}catch{}}_knownPeer(e){for(const[r,n]of this._ports)if(n.transport.peer===e)return r;const t=e;return typeof e=="object"&&e!==null&&(this._handshaken.has(t)||this._greeted.has(t))?t:void 0}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}sendNow(e){const t=this._target;return!this._inited||!t?!1:(this._postMessage(t,e),!0)}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:T,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,r=this._target){if(!r||this._ports.has(r))return;const n=Vt(e),i=n.subscribe(this._onTransportMessage);this._ports.set(r,{transport:n,subscription:i}),t&&(n.send({operationId:he,data:{}}),this.drainWindow(r))}holdPort(e=this._target){!e||!this._ports.has(e)||(this._portSendHeld.add(e),this._drained.delete(e))}resumePort(e=this._target){e&&this._portSendHeld.delete(e)}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)&&!this._portSendHeld.has(this._target)}hasPort(e,t){const r=this._ports.get(e);return r!==void 0&&(t===void 0||r.transport.peer===t)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e),this._portSendHeld.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:$t,data:{}},"*")}isWindowDrained(e){return this._drained.has(e)}_isPortSource(e){for(const t of this._ports.values())if(t.transport.peer===e)return!0;return!1}_isCurrentPort(e){return this._target!==void 0&&this._ports.get(this._target)?.transport.peer===e}getTarget(){return this._target}get target(){return this._target}_postMessage(e,t,r){let n=t;this._outgoingFilter&&!r?.length&&(n="data"in t?{...t,data:this._outgoingFilter(t.data)}:this._outgoingFilter(t));try{const i=this._ports.get(e);if(i&&!this._portSendHeld.has(e)){i.transport.send(n);return}if(r?.length){e.postMessage(n,"*",r);return}e.postMessage(n,"*")}catch(i){if(i?.name==="DataCloneError"){const o=typeof n?.data=="object"&&n?.data!==null?n.data:void 0}throw i}}_sendMessage(e,t,r=!0){if(!r&&!this.isInited())return;e&&this._notifyOutgoing(e,t);const n=this.addDisposable(this.onInit(i=>{const o=e?{operationId:e,data:t}:t;try{this._postMessage(i,{...o})}finally{n.dispose()}}))}send(e,t,r){return typeof e=="string"?this._sendMessage(e,t,r):this._sendMessage(F,e,t)}sendAsync(e,t,r=!0){if(!r&&!this.isInited())return Promise.resolve();this._notifyOutgoing(e,t);const n=Oe(),i=Oe();return new Promise((o,s)=>{const c=this.addDisposable(new g);c.addDisposable(this.onInit(u=>{try{this._postMessage(u,{operationId:e,data:t,result:n,error:i})}catch(_){c.dispose(),s(_);return}c.addDisposable(this._onMessage(n,_=>{o(_),c.dispose()})),c.addDisposable(this._onMessage(i,_=>{s(_),c.dispose()}))}))})}_onMessage(e,t,r=0){return this._emitter.addListener(e,t,r)}addListener(e,t,r){return t?this._onMessage(e,t,r):this._onMessage(F,e)}addListenerAsyncPipe(e,t,r=0){return this._emitter.addListenerAsync(e,t,r)}addListenerAsync(e,t,r=0){return this._emitter.addListenerAsync(e,async(n,i)=>{const o=await t(n);return i?i(n):o},r)}isInited(){return this._inited}get inited(){return this._inited}onInit(e,t=!0,r=0){const n=this.addDisposable(new g);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?n.addDisposable(this.onInit(e,t,r)):e(this._target)}):n.addDisposable(this._onMessage(T,()=>{e(this._target)},r)),n}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function v(e){return f(e)}var Yt=f("extensions.atomsHandlers"),zt=v("HANDLE_ATOM_INSERT"),Jt=f("HeadlessMode"),Qt=f("extensions.sandboxExtensions"),Zt="SANDBOX_EXTENSION_SCRIPT_STATUS",er=f("MESSAGE_SERVICE"),tr=v("SETTINGS_PANEL_EVENT"),rr="advanced",nr=v("MODAL_SHOW_EVENT"),ir=v("MODAL_CLOSE_EVENT"),or=v("MODAL_UPDATE_EVENT"),kn=f("client"),Un=f("v2_client"),Hn=f("ai_client"),sr=f("app.cookieManager"),Gn=f("app.storageProvider"),Vn=f("image-blob-resolver"),ar=f("template-directives"),cr=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),ur=class{baseUrl="https://api.emailmaker.ru/wp-json";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(r=>this.encodeQueryParam(t,r)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(r=>typeof t[r]<"u").map(r=>Array.isArray(t[r])?this.addArrayQueryParam(t,r):this.addQueryParam(t,r)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce((t,r)=>{const n=e[r];return t.append(r,n instanceof Blob?n:typeof n=="object"&&n!==null?JSON.stringify(n):`${n}`),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 r=this.abortControllers.get(e);return r?r.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};async request({body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:c,extraQuery:u,proxyHandler:_,...l}){const E=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},h=this.mergeRequestParams(l,E);u&&(i=i?{...i,...u}:u);const p=i&&this.toQueryString(i),A=this.contentFormatters[n||"application/json"],O=o||h.format,G=`${s||this.baseUrl||""}${r}${p?`?${p}`:""}`,Mn=_?_(G,{body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:c,extraQuery:u,proxyHandler:_,...l}):G,st=new Request(Mn,{...h,headers:{...h.headers||{},...n&&n!=="multipart/form-data"?{"Content-Type":n}:{}},signal:(c?this.createAbortSignal(c):h.signal)||null,body:typeof e>"u"||e===null?null:A(e)});return this.customFetch(st).then(async at=>{const I=at;I.data=null,I.error=null,I.meta={request:st,response:I};const Bn=O?await at[O]().then(V=>(I.ok?I.data=V:I.error={data:V},I)).catch(V=>(I.error=V,I)):I;return c&&this.abortControllers.delete(c),Bn})}},_r=f("prewarm.networkActivity");function lr(){let e=0;const t=new Set,r=()=>{t.forEach(n=>n())};return{begin(){e+=1,r();let n=!1;return()=>{n||(n=!0,e-=1,r())}},inFlight:()=>e,watch(n){return t.add(n),()=>t.delete(n)}}}function dr(e){return e.getOrCreateInstance(_r,()=>lr())}var me=Symbol("rest.publicRequest"),x=f("rest.requestHandler"),fr=f("rest.responseHandler"),J=f("rest.customFetch"),Er=(e,t)=>fetch(e,t),Q=f("rest_transport"),pr=e=>{e.inject(J,{execute:async(t,r={})=>{const n=e.getServices(x),i={public:r[me]===!0},o=dr(e).begin();try{let s=t instanceof Request?t:new Request(t,r);for(const _ of n){const l=await _.execute(s,i);l instanceof Request&&(s=l)}let c=await fetch(s);const u=e.getServices(fr);for(const _ of u)c=await _.execute(c,s);return c}finally{o()}}})};function hr(e,t){const r=e.getInstance(Q);if(!r)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(n=>new n(r)))}var Or="INJECTION";function mr(e){return e.getState}function Ar(e){if(!mr(e)){e.dispose();return}const t=e.getState()[Or];t&&(K.getInstance(t)?.dispose(),K.remove(t))}function gr(e,t){for(const r of e)if(r&&t in r)return r[t]}function Ae(e){return Object.assign({},...e)}var ge=["generic","stockImages","emFiles","cdn"];function Z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ie(e){return!Z(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>ge.includes(t))}function Te(e){return e.length===0?[]:e.length===1?e[0]:e}function Se(e){let t=!1,r=[];for(const n of e)if(n!==void 0){if(t=!0,Array.isArray(n)){r=[...n,...r];continue}r=[n,...r]}if(t)return Te(r)}function Ir(e){return Z(e)&&("value"in e||"replace"in e)}function be(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function Tr(e){let t=!1,r=[],n=!1;for(const o of e)if(o!==void 0){if(Ir(o)){t=!0,o.replace&&(r=[],n=!0),o.value!==void 0&&(r=be(r,o.value),n=!0);continue}r=be(r,o),n=!0}const i=n?Te(r):void 0;if(!t)return i;if(i!==void 0)return{value:i}}function Sr(e){const t=e.filter(n=>n!==void 0);if(t.length===0)return;if(!t.some(n=>Ie(n)))return Se(t);const r={};for(const n of ge){const i=Tr(e.map(o=>{if(o!==void 0)return Ie(o)?o[n]:n==="generic"?o:void 0}));i!==void 0&&(r[n]=i)}return Object.keys(r).length>0?r:void 0}function br(e){return Se(e)}function Dr(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(Z(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function Nr(e,t){const r=[...e],n=new Set(r.map(i=>i.toLowerCase()));for(const i of t){const o=i.trim().replace(/:\d+$/,"");if(!o)continue;const s=o.toLowerCase();n.has(s)||(n.add(s),r.push(o))}return r}function yr(e){let t=[],r=!1;for(const n of e){const i=Dr(n);i&&(r=!0,i.replace&&(t=[]),t=Nr(t,i.hosts))}return r?t:void 0}function Pr(e){const t=e.filter(i=>i!==void 0);if(t.length===0)return;const r=Ae(t.map(({directHosts:i,...o})=>o)),n=yr(t.map(i=>i?.directHosts));return n!==void 0&&(r.directHosts=n),r}function ee(e){return e?.backendProxy}function L(e){return e.replace(/\/$/,"")}function De(e){return/^https?:\/\//i.test(e)}function Ne(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Cr(e){const t=new Set;return e.filter(r=>!r.url||t.has(r.url)?!1:(t.add(r.url),!0))}function vr(e){const t=ee(e);return t?[t]:[]}function Lr(e){return{proxyEmFiles:!0,proxyAi:!1}}function Rr(e,t){const r=Lr(t),n=t?.backendProxyPolicy;switch(e){case"emFiles":return n?.proxyEmFiles??r.proxyEmFiles;case"ai":return n?.proxyAi??r.proxyAi;default:return!0}}var wr={url:".+",url_encoded:".+",origin:"https?:\\/\\/[^\\/?#]+",origin_encoded:".+",proxy_url:"https?:\\/\\/[^\\/?#]+",proxy_url_encoded:".+",path:"[^?#]*",pathname:"[^?#]*",path_with_slash:"\\/[^?#]*",pathname_with_slash:"\\/[^?#]*",query:"[^#]*",search:"\\?[^#]*",hash:"#.*",fragment:".*",pathname_after_wp_json:"[^?#]*",pathname_after_wp_json_with_slash:"\\/[^?#]*",rest_namespace:"[^/?#]*",rest_version:"[^/?#]*",rest_route:"[^?#]*",rest_route_with_slash:"\\/[^?#]*"};function Mr(e){const t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(n,i)=>(t.push(i),`(${wr[i]||".+"})`));return{regex:new RegExp(`^${r}$`,"i"),tokens:t}}function Br(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function jr(e,t){if(Br(t))return e;try{const r=new URL(e);return`${r.origin}${r.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function Fr(e,t,r){if(r.endsWith("_encoded"))return!0;const n=e.slice(0,t),i=n.lastIndexOf("#"),o=n.lastIndexOf("?"),s=n.lastIndexOf("&"),c=n.lastIndexOf("=");return c>Math.max(o,s)&&c>i}function xr(e){try{const t=new URL(e),r=t.pathname.replace(/^\/+/,""),n=t.search.replace(/^\?/,""),i=t.hash.replace(/^#/,""),o=r.replace(/^wp-json\/?/i,""),s=o?`/${o}`:"/",c=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),u=c?.[1]||"",_=c?.[2]||"",l=c?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:r,pathname:r,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:n,search:t.search,hash:t.hash,fragment:i,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:s,rest_namespace:u,rest_version:_,rest_route:l,rest_route_with_slash:l?`/${l}`:"/"}}catch{return}}function te(e,t){if(!e)return{};if(Array.isArray(e)){for(const c of e){const u=te(c,t);if(u!==void 0)return u}return}if(e==="*")return{};const r=jr(t,e),{regex:n,tokens:i}=Mr(e),o=n.exec(r);if(!o)return;const s={};return i.forEach((c,u)=>{s[`matched_${c}`]=o[u+1]||""}),s}function k(e,t,r={}){const n=xr(t);if(!n)return t;const i={...n,...r};let o="",s=0;const c=/\{([a-z_]+)\}/gi;let u;for(;u=c.exec(e);){o+=e.slice(s,u.index);const _=i[u[1]]??"",l=Fr(e,u.index,u[1])?encodeURIComponent(_):_;o+=l,s=u.index+u[0].length}o+=e.slice(s);try{const _=new URL(o),l=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&l.search&&l.searchParams.forEach((E,h)=>{_.searchParams.has(h)||_.searchParams.append(h,E)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&l.hash&&!_.hash&&(_.hash=l.hash),_.toString()}catch{return o}}function ye(e,t){try{const r=new URL(t);return`${L(e)}/${r.pathname.replace(/^\//,"")}${r.search}${r.hash}`}catch{return t}}function Pe(e,t){const r=L(e);return t?De(t)?t:t.startsWith("?")||t.startsWith("#")?`${r}${t}`:`${r}${t.startsWith("/")?"":"/"}${t}`:r}function Ce(e,t,r,n){const i=e.match;return i?Array.isArray(i)?i.some(o=>Ce({...e,match:o},t,r,n)):typeof i=="function"?!!i({url:t,method:n,requestType:r}):i==="*"?!0:te(i,t)!==void 0:!0}function kr(e,t,r,n="generic"){if(e==null)return[];const i=Array.isArray(e)?e:[e],o=[];return i.forEach((s,c)=>{if(!s)return;if(typeof s=="string"){const E=s.includes("{")&&s.includes("}")?k(s,t):ye(s,t);o.push({key:`backend:${c}`,url:E,source:"resource"});return}if(!Ne(s)||!("rewrite"in s))return;const u=s;if(!Ce(u,t,n,r))return;const _=typeof u.match=="string"||Array.isArray(u.match)?te(u.match,t)||{}:{},l=typeof u.proxyBase=="string"&&u.proxyBase.trim()?u.proxyBase.trim():void 0;(Array.isArray(u.rewrite)?u.rewrite:[u.rewrite]).filter(Boolean).forEach((E,h)=>{const p=typeof E=="function"?(()=>{const A=E({url:t,proxyBase:l,method:r,requestType:n,..._}),O=l&&!De(A)?Pe(l,A):A;return O.includes("{")&&O.includes("}")?k(O,t,_):O})():l?k(Pe(l,E),t,_):E.includes("{")&&E.includes("}")?k(E,t,_):ye(E,t);o.push({key:`backend:${u.id||"rule"}:${c}:${h}`,url:p,source:"resource"})})}),Cr(o)}function Ur(e){try{const t=new URL(e);return/(?:^|\/)wp-json\/em-files\/v\d+(?:\/|$)/i.test(t.pathname)?"emFiles":/(?:^|\/)wp-json\/ai-generator\/v\d+(?:\/|$)/i.test(t.pathname)?"ai":"generic"}catch{return"generic"}}function Hr(e,t=[]){return e==null||(Array.isArray(e)?e:[e]).forEach(r=>{if(r){if(typeof r=="string"){const n=r.split("{")[0]?.trim();n&&t.push(L(n));return}!Ne(r)||!("rewrite"in r)||(typeof r.proxyBase=="string"&&r.proxyBase.trim()&&t.push(L(r.proxyBase.trim())),(Array.isArray(r.rewrite)?r.rewrite:[r.rewrite]).forEach(n=>{if(typeof n!="string")return;const i=n.split("{")[0]?.trim();i&&t.push(L(i))}))}}),t}function Gr(e,t){return vr(t).flatMap(r=>Hr(r)).filter(Boolean).some(r=>r&&e.startsWith(r))}function Vr(e,t){return!!ee(t)&&Rr(e,t)}function Xr(e,t={}){const r=t.requestType||Ur(e);return Vr(r,t.config)?kr(ee(t.config),e,t.method,r):[]}function Wr(e,t={}){return Gr(e,t.config)?[e]:Xr(e,t).map(r=>r.url)}function D(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function ve(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const r=t.find(o=>o.aborted);if(r)return r;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const n=new AbortController,i=o=>{n.signal.aborted||n.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>i(o),{once:!0});return n.signal}var Le=3e5,Re=15e3,m=null,we=!1;function $r(){return!0}function Kr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return Le;const t=Number(e);return Number.isFinite(t)&&t>0?t:Le}function qr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return Re;const t=Number(e);return Number.isFinite(t)&&t>0?t:Re}function Yr(){const e="https://app.emailmaker.ru/api/".trim();return e?D(e):void 0}function zr(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const r=JSON.parse(t);if(!Array.isArray(r))throw new Error("expected JSON array");return r.map(n=>String(n).trim()).filter(Boolean)}catch{return we||(we=!0),[]}return t.split(",").map(r=>r.trim()).filter(Boolean)}function Jr(e){const t=new Set,r=[];for(const n of e){const i=D(n);t.has(i)||(t.add(i),r.push(i))}return r}function Me(e){const t=String(e||"").trim();return t?D(t):Yr()}function Be(e,t=[]){return e?Jr([e,...t]).slice(0,3):[]}function je(){return zr(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function Qr(e=Date.now()){return m?e-m.switchedAt>=Kr():!0}function Fe(e=Date.now()){m&&Qr(e)&&(m=null)}function N(e){if(!$r())return!1;const t=Me(e);if(!t)return!1;const r=je();return r.length===0?!1:Be(t,r).length>1}function R(e){const t=Me(e);if(!t)return[];const r=je();return r.length===0?[t]:Be(t,r)}function U(e){const t=R(e);if(t.length===0)return"";if(Fe(),m){const r=t.indexOf(m.activeUrl);if(r>=0)return t[r]}return t[0]}function xe(e){const t=R(e);if(t.length<=1||(Fe(),!m||!t.includes(m.activeUrl)))return t;const r=m.activeUrl;return[r,...t.filter(n=>n!==r)]}function ke(e){return U(e)||void 0}function Ue(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const r=qr(),n=new AbortController;let i;const o=setTimeout(()=>{i=Zr(r),n.abort(i)},r);return{signal:ve(t,n.signal),timeoutError:()=>i,done:()=>clearTimeout(o)}}function Zr(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const r=new Error(t);return r.name="TimeoutError",r}function He(e){return e===502||e===503||e===504}function Ge(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var Ve;function en(e){Ve=e}function H(e,t){if(!N(t))return;const r=R(t);if(r.length<=1)return;const n=r.indexOf(D(e));if(n<0)return;const i=n+1;if(i>=r.length)return;const o=r[i],s=m?.activeUrl;m={activeUrl:o,switchedAt:Date.now()},s!==o&&Ve?.()}function Xe(e,t){if(!N(t))return;const r=D(e),n=R(t);if(n.includes(r)){if(r===n[0]){m=null;return}m?.activeUrl!==r&&(m={activeUrl:r,switchedAt:Date.now()})}}function We(){m=null}var tn=e=>{const t=new FormData,r=(n,i,o)=>{if(i!=null){if(i instanceof Blob){n.append(o,i);return}if(Array.isArray(i)){i.forEach((s,c)=>{const u=o?`${o}[${c}]`:`${c}`;r(n,s,u)});return}if(typeof i=="object"){Object.keys(i).forEach(s=>{const c=i[s],u=o?`${o}[${s}]`:s;r(n,c,u)});return}n.append(o,String(i))}};return r(t,e),t},rn={baseUrl:D("https://app.emailmaker.ru/api/"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},y=new Map;function nn(e){const t=e?.getInstance(de);return t?t.get()??t.bootstrap():void 0}var on=class extends ur{container;constructor(e={},t){super(e),this.container=t}buildRequestUrl(e){const{path:t,baseUrl:r,extraQuery:n}=e;let{query:i}=e;n&&(i=i?{...i,...n}:n);const o=i&&this.toQueryString(i);return`${r||this.baseUrl||""}${t}${o?`?${o}`:""}`}buildRequestKey(e,t){return`${t.toUpperCase()} ${e}`}getBackendProxyCandidates(e,t){const r=nn(this.container),n=this.container?.getInstance(Ee)!==void 0,i=Wr(e,{config:r,method:t,standalone:n}),o=i.length>0?i:[e],s=this.buildRequestKey(e,t),c=y.get(s);return!c||!o.includes(c)?o:[c,...o.filter(u=>u!==c)]}shouldRetryResponse(e){return e.status===502||e.status===503||e.status===504}resolveFailoverBaseUrl(){return String(this.baseUrl||"").trim()||void 0}async requestOnOrigin(e,t,r=!1){const n={...e,baseUrl:t},i=this.buildRequestUrl(n),o=n.method||"GET",s=this.buildRequestKey(i,o),c=this.getBackendProxyCandidates(i,o);let u,_;for(const l of c){const E=p=>p===i?l:p,h=r?Ue(e.signal):void 0;try{const p=await super.request({...n,proxyHandler:E,...h?{signal:h.signal}:{}});if(!p.ok&&this.shouldRetryResponse(p)&&l!==c[c.length-1]){_=p,y.get(s)===l&&y.delete(s);continue}return y.set(s,l),p}catch(p){y.get(s)===l&&y.delete(s);const A=h?.timeoutError();if(A)throw A;if(u=p,(p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p}finally{h?.done()}}if(_)return _;throw u instanceof Error?u:new Error("Backend proxy chain failed")}async request(e){const t=String(e.baseUrl||"").trim();if(t)return this.requestOnOrigin(e,t);const r=this.resolveFailoverBaseUrl(),n=N(r),i=e.failoverAttemptTimeout??n,o=n?xe(r):r?[U(r)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let s,c;for(let u=0;u<o.length;u++){const _=o[u],l=u===o.length-1;try{const E=await this.requestOnOrigin(e,_,i);if(!E.ok&&He(E.status)){if(c=E,!l){H(_,r);continue}break}return E.ok&&Xe(_,r),E}catch(E){if(!Ge(E))throw E;s=E,l||H(_,r)}}if(n&&We(),c)return c;throw s instanceof Error?s:new Error("API origin failover chain failed")}};function sn(e={},t){const r=new on({...rn,...e},t);return r.contentFormatters["multipart/form-data"]=tn,r}var $e=f("rest.clientFactory"),an=e=>{pr(e);const t=sn({customFetch:e.getInstance(J)?.execute??Er},e);e.inject(Q,t)},Ke;(function(e){const t="https://racs.emcdn.ru/v3";function r(i,o){const s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(o)};return fetch(`${t}?resource=${i}&dataset=${document.location.hostname}`,s)}e.post=r;async function n(i,o=0){const s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:`{"filter":{},"limit":${o}}`};return await(await fetch(`${t}/get?resource=${i}&dataset=${document.location.hostname}`,s)).json()}e.getAll=n})(Ke||(Ke={}));function w(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const r=Array.isArray(e),n=Array.isArray(t);if(r){if(!n)return!1;const c=e.length;if(t.length!==c)return!1;for(let u=0;u<c;u++)if(!w(e[u],t[u]))return!1}else if(n)return!1;const i=Object.keys(e),o=Object.keys(t),s=i.length;if(s!==o.length)return!1;for(let c=0;c<s;c++){const u=i[c];if(!t.hasOwnProperty(u)||!w(e[u],t[u]))return!1}}return!0}function cn(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),r=atob(t),n=new Uint8Array(r.length);for(let i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return new TextDecoder().decode(n)}function qe(e){const[t,r,n]=e.split("."),i=JSON.parse(cn(r));return{exp:i.exp,createdAt:i.iat,data:i}}var re=f("plugin.auth.token"),Ye=new WeakMap,un=3e4;function _n(e){let t;try{t=qe(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+un}function ln(e,t,r,n){const i=Ye.get(e);i&&(i.stale=!0);const o={stale:!1};Ye.set(e,o),e.injectFactory(re,async(s,c)=>{if(o.stale)return"";try{let u=await c||void 0;if(!u){const _=e.getInstance(fe);_&&(u=await _)}return t?!u||_n(u)?await t(r,n,u):u:""}catch{return""}},!0)}var ze=f("auth.oauthProvided"),Je=new WeakMap;function Qe(e,t){const r=Je.get(e)??{applied:!1};(!r.applied||r.getAuthToken!==t.getAuthToken||!w(r.user,t.user)||r.project!==t.project)&&(Je.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),ln(e,t.getAuthToken,t.user,t.project))}function Ze(e){if(e.getInstance(ze))return;e.inject(ze,!0);let t;e.getInstance(le)?.watch(r=>{t=r}),e.addService(x,{execute:async(r,n)=>{if(n?.public||!t?.getAuthToken)return;e.getInstance(re)===void 0&&Qe(e,t);const i=await e.getInstanceAsync(re);i&&r.headers.set("authorization",`Bearer ${i}`)}})}function dn(e,t){if(e===t)return;let r=0;const n=Math.min(e.length,t.length);for(;r<n&&e[r]===t[r];)r++;let i=e.length,o=t.length;for(;i>r&&o>r&&e[i-1]===t[o-1];)i--,o--;return{start:r,fromEnd:i,toEnd:o}}function fn(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),16777619);return{length:e.length,hash:t>>>0}}var En={theme:"canvas_fact_theme",flags:"canvas_fact_flags",commonStyles:"canvas_fact_common_styles",lockEditor:"canvas_fact_lock_editor",codeMode:"canvas_fact_code_mode",appName:"canvas_fact_app_name",previewPage:"canvas_fact_preview_page",viewport:"canvas_fact_viewport"},pn={text:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, 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},links:{color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, 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:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},textAlign:"center",padding:{all:null,top:null,right:null,bottom:null,left:null}},block:{backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null}}},et="ERROR",hn="useblocks",On={em_token:"em_access_token",em_refresh_token:"em_refresh_token",em_admin_token:"em_admin_access_token",em_admin_refresh_token:"em_admin_refresh_token",em_impersonation:"em_impersonation",em_elements_view:"em_elements_view",em_new_block:"em_new_block",em_new_email:"em_new_email",em_id:"em_id",em_name:"em_name",em_email:"em_email",em_locale:"em_locale",em_carrotquest_hash:"em_carrotquest_hash",em_ducalis_hash:"em_ducalis_hash",em_email_subscription_consent:"em_email_subscription_consent",em_folder:"em_folder",promocode:"promocode",em_active_tab:"em_active_tab"},mn={em_color_scheme:"em_color_scheme",em_code_mode_pane_sizes:"em_code_mode_pane_sizes",em_preview_pane_sizes:"em_preview_pane_sizes",em_default_sizes:"em_default_sizes",em_pane_sizes:"em_pane_sizes",em_test_emails:"em_test_emails",em_menu_is_locked:"em_menu_is_locked",em_code_mode_settings:"em_code_mode_settings",em_folder_is_open:"em_folder_is_open",em_active_tab:"em_active_tab",em_ai_settings:"em_ai_settings",em_last_active_page:"em_last_active_page",em_layout_convert_never_suggest:"em_layout_convert_never_suggest",em_filemanager_v2:"em_filemanager_v2",em_projects_v2:"em_projects_v2",em_translations_v2:"em_translations_v2",em_emails_v2:"em_emails_v2",em_blocks_v2:"em_blocks_v2",em_revisions_v2:"em_revisions_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_guest_locale:"em_guest_locale"},An="light",gn="dark",In="system",Tn="(prefers-color-scheme: dark)",Sn=15e3,bn=3e3,Dn={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_EDITOR:"update_editor",UPDATE_EDITOR_POSITION:"update_editor_position",UPDATE_SIDE_MENU_EDITOR:"update_side_menu_editor",SAVE_EMAIL:"saveEmail",SANDBOX_ELEMENT_SETTINGS_SET:"sandbox_element_settings_set",SANDBOX_IMAGE_RESET:"sandbox_image_reset",SANDBOX_NATIVE_IMAGE_DROP_CLEAR:"sandbox_native-image-drop-clear",SANDBOX_EMAIL_SETTINGS_SET:"sandbox_email_settings_set",SANDBOX_BLOCK_SETTINGS_SET:"sandbox_block_settings_set",SANDBOX_ELEMENT_PARENT_GET:"sandbox_element_parent_get",SANDBOX_ELEMENT_PARENT_TABLE_GET:"sandbox_element_parent_table_get",SANDBOX_ELEMENT_PREV_GET:"sandbox_element_prev_get",SANDBOX_ELEMENT_NEXT_GET:"sandbox_element_next_get",SANDBOX_ELEMENT_REMOVE:"sandbox_element_remove",SANDBOX_ELEMENT_ACTIVE_RESET:"sandbox_element_active_reset",SANDBOX_ELEMENT_ACTIVE_SET:"sandbox_element_active_set",SANDBOX_ELEMENT_HOVER_SET:"sandbox_element_hover_set",SANDBOX_ELEMENT_IMG_LINK:"sandbox_element_img_link",SANDBOX_ELEMENT_TEXT:"sandbox_element_text",SANDBOX_EMAIL_CONTENT_GET:"sandbox_email_content_get",SANDBOX_SET_POSITION_TO_IMG:"sandbox_set_position_to_img",SANDBOX_SET_POSITION_TO_LINK:"sandbox_set_position_to_link",SANDBOX_ACCORDION_ADD_SECTION:"sandbox_accordion_add_section",SANDBOX_ACCORDION_REMOVE_SECTION:"sandbox_accordion_remove_section",APPLICATION_FOCUS_IN_IFRAME:"application_focus_in_iframe",APPLICATION_EMAIL_SETTINGS_SET:"application_email_settings_set",APPLICATION_BLOCK_SETTINGS_SET:"application_block_settings_set",APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",_APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",APPLICATION_ELEMENT_SETTINGS_CLOSE:"application_element_settings_close",APPLICATION_ACTION:"application_action",APPLICATION_EBLOCK_ADD:"application_eblock_add",SANDBOX_EBLOCK_SET_EM_BLOCK_ID:"sandbox_eblock_set_em_block_id",SANDBOX_EBLOCK_CLEAR_EM_BLOCK_ID:"sandbox_eblock_clear_em_block_id",SANDBOX_GLOBAL_BLOCK_REPLACE:"sandbox_global_block_replace",APPLICATION_SCROLL_TO:"application_scroll-to",APPLICATION_SCROLL_BLOCK_SHOW:"application_scroll-block-show",APPLICATION_SCROLL_BLOCK_HIDE:"application_scroll-block-hide",APPLICATION_DISCUSS_SET_ID:"application_discuss_set_id",APPLICATION_DISCUSS_GET_COMMENT:"application_discuss_get_comment",APPLICATION_DISCUSS_NO_COMMENT:"application_discuss_no_comment",APPLICATION_DISCUSS_SAVE_TARGET:"application_discuss_save_target",APPLICATION_IFRAME_SET_HEIGHT:"application_iframe_set_height",APPLICATION_COMMON_STYLES_UPDATE:"application_commonStyles_update",APPLICATION_EMAIL_CONTENT_GET:"application_email_content_get",APPLICATION_OPEN_IMAGE_AI_POPUP:"application_open-image-ai-popup",APPLICATION_OPEN_IMAGE_UPLOAD_POPUP:"application_open-image-upload-popup",APPLICATION_OPEN_IMAGE_EDIT_POPUP:"application_open-image-edit-popup",APPLICATION_OPEN_IMAGE_GIF_POPUP:"application_open-image-gif-popup",APPLICATION_OPEN_IMAGE_STOCK_POPUP:"application_open-image-stock-popup",APPLICATION_CLOSE_IMAGE_EDIT_POPUP:"application_close-image-edit-popup",APPLICATION_NATIVE_IMAGE_DROP:"application_native-image-drop",APPLICATION_SUBJECT_UPDATE:"application_subject_update",APPLICATION_PREHEADER_UPDATE:"application_preheader_update",APPLICATION_DOMPARSER_ERROR:"application_domparser_error",APPLICATION_SYNC_DRIFT:"application_sync_drift",APPLICATION_UPDATE_ENTITY:"application_update_entity",APPLICATION_IFRAME_DRAG_EVENT:"application_iframe_drag_event",APPLICATION_HAS_AMP:"application_has_amp",APPLICATION_CANVAS_IMAGE_GET:"application_canvas_image_get",APPLICATION_PREVIEW_ALERT_SHOW:"application_preview_alert_show",APPLICATION_ATOM_INSERTED:"application_atom_inserted",APPLICATION_TEMPLATE_NOT_EM_ALERT_SHOW:"application_template_not_em_alert_show",SANDBOX_IFRAME_SETSIZE:"sandbox_iframe-setsize",SANDBOX_BLOCK_INSERT:"sandbox_block-insert",SANDBOX_ATOM_INSERT:"sandbox_atom-insert",SANDBOX_DRAG_CANCEL:"sandbox_drag-cancel",UPDATE_EDITOR_POSITION_FROM_EDITOR:"update_position_from_editor",UPDATE_EDITOR_POSITION_FROM_IFRAME:"update_position_from_iframe",SANDBOX_CHANGE_PREVIEW:"sandbox_change_preview",APPLICATION_CHANGE_PREVIEW:"application_change_preview",SANDBOX_LOCK_EDIT:"sandbox_lock_edit",SANDBOX_FLOATBLOCK_ADD:"sandbox_floatBlock_add",SANDBOX_FLOATBLOCK_REMOVE:"sandbox_floatBlock_remove",SANDBOX_FLOATBLOCK_COPY:"sandbox_floatBlock_copy",SANDBOX_FLOATBLOCK_SWAP:"sandbox_floatBlock_swap",EDITOR_CHANGE_FOCUS:"editor_change_focus",SANDBOX_RESIZED:"sandbox_resized",SANDBOX_LOCK_DISCUSS:"sandbox_lock_discuss",SANDBOX_DISCUSS_SET_TARGET:"sandbox_discuss_set_target",SANDBOX_DISCUSS_REMOVE_TARGET:"sandbox_discuss_remove_target",SANDBOX_DISCUSS_RESET:"sandbox_discuss_reset",SANDBOX_DISCUSS_GET_TARGET:"sandbox_discuss_get_target",SANDBOX_READY:"SANDBOX_READY",SANDBOX_FLOATBLOCK_WRAP:"sandbox_floatblock_wrap",SANDBOX_FLOATBLOCK_DIR:"sandbox_floatblock_dir",SANDBOX_SUBJECT_UPDATE:"sandbox_subject_update",SANDBOX_PREHEADER_UPDATE:"sandbox_preheader_update",SANDBOX_DRAG_EVENT:"sandbox_drag_event",SANDBOX_WHEEL:"sandbox_wheel",SANDBOX_TRANSLATIONS:"sandbox_send_translations",SANDBOX_SET_THEME_VARIABLES:"sandbox_send_theme_variables",SANDBOX_SET_PROJECT_FONTS:"sandbox_set_project_fonts",SANDBOX_CANVAS_IMAGE_CACHE_SETUP:"sandbox_canvas_image_cache_setup",SANDBOX_SET_ENTITY:"sandbox_set_entity",SANDBOX_INIT_START:"sandbox_init_start",SANDBOX_INITED:"sandbox_inited",SANDBOX_UPDATE_ENTITY:"sandbox_update_entity",RELOAD:"reload",SANDBOX_ADD_EXTENSIONS:"sandbox_add_extensions",SANDBOX_REMOVE_EXTENSIONS:"sandbox_remove_extensions",SANDBOX_ADD_SCRIPT:"sandbox_add_script",SANDBOX_IS_EMAIL_EMPTY:"sandbox_is_email_empty",SANDBOX_SWITCH_THEME:"sandbox_switch_theme",SANDBOX_CANVAS_HEALTH:"sandbox_canvas_health",SANDBOX_CANVAS_SYNCED:"sandbox_canvas_synced"},Nn={language:"html",detectIndentation:!1,wordWrap:"on",wrappingIndent:"same",smoothScrolling:!0,automaticLayout:!0,tabSize:2,indentSize:2},tt=e=>{const t={current:Promise.resolve(),state:e,decorate:(r,n)=>(n&&(r=r.bind(n)),function(...i){const o=t.current.then(()=>r(...i));return t.current=o.then(s=>{t.state=s},s=>{}),o})};return t};function ne(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function yn(e){return t=>{const r={},n=[];for(const s of e)n.push(s(t));for(const s of n)Object.assign(r,s.instance);return{instance:r,setOptions:async s=>{for(const c of n)await c.setOptions(s)},dispose:()=>{for(const s of n)s.dispose()}}}}function Pn(e=et){const t=new Error(e);return t.name="AuthPipelineError",t}async function rt(e,t,r,n){const i=n?.attemptTimeout??N(r),o=N(r)?xe(r):R(r).length>0?[U(r)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const s=e.startsWith("/")?e:`/${e}`;let c,u;for(let _=0;_<o.length;_++){const l=o[_],E=_===o.length-1,h=i?Ue(t.signal):void 0;try{const p=await fetch(`${l}${s}`,{...t,...h?{signal:h.signal}:{}});if(!p.ok&&He(p.status)){if(c=p,!E){H(l,r);continue}break}return p.ok&&Xe(l,r),p}catch(p){const A=h?.timeoutError();if(!A&&!Ge(p))throw p;u=A||p,E||H(l,r)}finally{h?.done()}}if(N(r)&&We(),c)return c;throw u instanceof Error?u:new Error("[apiOriginFailover] fetch chain failed")}function nt(e){e.inject(C,void 0),e.inject(z,void 0)}var Cn=ne(e=>{let t,r;const n=tt();return e.addService(x,{execute:n.decorate(async(i,o)=>{if(o?.public||!t)return;const s=String(e.getInstance(z)||"").trim();if(s){i.headers.append("authorization",`Bearer ${s}`);return}if(!e.getInstance(C))try{const c=e.getInstance($e),u=String(c?.getOptions()?.baseUrl||"").trim(),_=ke(r||u||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const l=await rt("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},_);if(!l.ok)throw new Error(`JWT auth failed: ${l.status}`);const E=await l.json(),h=String(E.token||"").trim();if(!h)throw new Error("JWT auth failed: empty token");e.inject(C,void 0),e.inject(z,h),i.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(C,et),Pn()}})}),{setOptions(i){const o=i.jwtAuth,s=String(i.baseUrl||"").trim()||void 0,c=!w(o,t),u=s!==r;if(t=o,r=s,!o){nt(e);return}c||u?nt(e):e.inject(C,void 0)}}}),vn=ne(e=>(Ze(e),{setOptions(t){Qe(e,t)}}));function Ln(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function ie(e,t=document){try{const n=t.querySelector(e);if(n)return n}catch{return null}const r=t.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;if(!i)continue;const o=ie(e,i);if(o)return o}return null}function it(e,t=[]){const r=e.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;i&&(t.push(i),it(i,t))}return t}function Rn(e,t,r){if(e.isConnected)return e;const n=e.id?.trim();return n?ot(`#${Ln(n)}`,t,r):Promise.reject(S("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function ot(e,t,r){if(q(r),typeof e<"u"){if(typeof e=="string"){const n=e,i=ie(n);if(i)return i;const o=t.addDisposable(new g);return new Promise((s,c)=>{const u=O=>{o.dispose(),O()},_=()=>{u(()=>c(S(r?.reason)))};if(r?.aborted){_();return}r?.addEventListener("abort",_),o.addDispose(()=>r?.removeEventListener("abort",_));const l=document.body??document.documentElement;if(!l){u(()=>c(S("Document is not ready to observe mount element")));return}const E=new Set,h=new MutationObserver(()=>{const O=ie(n);if(O){u(()=>s(O));return}A()}),p=O=>{E.has(O)||(E.add(O),h.observe(O,{attributes:!0,childList:!0,subtree:!0}))},A=()=>{const O=document.documentElement;if(O)for(const G of it(O))p(G)};p(l),A(),o.addDispose(()=>h.disconnect())})}return e instanceof Element?Rn(e,t,r):e}return e}var wn=new Map;Object.defineProperty(a,"ADVANCED_SETTINGS_PANEL",{enumerable:!0,get:function(){return rr}}),Object.defineProperty(a,"APP_COOKIES",{enumerable:!0,get:function(){return On}}),Object.defineProperty(a,"APP_ID",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(a,"APP_LOAD_EVENT_ID",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(a,"ATOMS_HANDLERS_ID",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(a,"AsyncEmitter",{enumerable:!0,get:function(){return j}}),Object.defineProperty(a,"BaseEmitter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(a,"CANVAS_ECHO_LOST_AFTER_MS",{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(a,"CANVAS_ECHO_RECOVERY_WAIT_MS",{enumerable:!0,get:function(){return bn}}),Object.defineProperty(a,"CANVAS_FACTS",{enumerable:!0,get:function(){return En}}),Object.defineProperty(a,"COMMON_STYLES",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(a,"CONFIG_CHANGED_EVENT_ID",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(a,"CONFIG_SOURCE_ID",{enumerable:!0,get:function(){return de}}),Object.defineProperty(a,"COOKIE_MANAGER_ID",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(a,"CUSTOM_FETCH_ID",{enumerable:!0,get:function(){return J}}),Object.defineProperty(a,"CUSTOM_MESSAGE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(a,"ContentType",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(a,"DARK",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(a,"DISPOSABLE_ID",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(a,"DependencyResolver",{enumerable:!0,get:function(){return K}}),Object.defineProperty(a,"Disposable",{enumerable:!0,get:function(){return g}}),Object.defineProperty(a,"ELEMENT_MAP",{enumerable:!0,get:function(){return wn}}),Object.defineProperty(a,"EVENT_TYPES",{enumerable:!0,get:function(){return Dn}}),Object.defineProperty(a,"Emitter",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(a,"HANDLE_ATOM_INSERT_ID",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(a,"HEADLESS_MODE_ID",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(a,"INIT_PIPELINE_ID",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(a,"INSTANCE_ID",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(a,"JWTMixin",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(a,"LATE_SURFACE_LISTENERS_ID",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(a,"LIGHT",{enumerable:!0,get:function(){return An}}),Object.defineProperty(a,"LOCAL_STORAGE_ITEMS",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(a,"MESSAGE_SERVICE_ID",{enumerable:!0,get:function(){return er}}),Object.defineProperty(a,"MODAL_CLOSE_EVENT",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(a,"MODAL_SHOW_EVENT",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(a,"MODAL_UPDATE_EVENT",{enumerable:!0,get:function(){return or}}),Object.defineProperty(a,"MONACO_EDITOR_OPTIONS",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(a,"MessageService",{enumerable:!0,get:function(){return qt}}),Object.defineProperty(a,"OAuthMixin",{enumerable:!0,get:function(){return vn}}),Object.defineProperty(a,"OPTIONS_SOURCE_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(a,"PLUGIN_COLLECTION_ID",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(a,"PORT_READY",{enumerable:!0,get:function(){return he}}),Object.defineProperty(a,"PREFERS_COLOR_SCHEME_DARK",{enumerable:!0,get:function(){return Tn}}),Object.defineProperty(a,"PUBLIC_REQUEST",{enumerable:!0,get:function(){return me}}),Object.defineProperty(a,"REQUEST_HANDLER_ID",{enumerable:!0,get:function(){return x}}),Object.defineProperty(a,"REST_CLIENT_FACTORY_ID",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(a,"REST_TRANSPORT_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(a,"SANDBOX_EXTENSIONS_ID",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(a,"SANDBOX_EXTENSION_SCRIPT_STATUS_ID",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(a,"SECURITY_MODULE_ID",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(a,"SETTINGS_PANEL_EVENT",{enumerable:!0,get:function(){return tr}}),Object.defineProperty(a,"STANDALONE_ACTIVATED_ID",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(a,"STANDALONE_BOOTSTRAP_TOKEN_ID",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(a,"STANDALONE_FILE_PROXY_REGISTERED_ID",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(a,"STANDALONE_PROJECT_ID",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(a,"STORE_ID",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(a,"SYSTEM",{enumerable:!0,get:function(){return In}}),Object.defineProperty(a,"Signal",{enumerable:!0,get:function(){return St}}),Object.defineProperty(a,"TEMPLATE_DIRECTIVES_ID",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(a,"USEBLOCKS",{enumerable:!0,get:function(){return hn}}),Object.defineProperty(a,"combineMixins",{enumerable:!0,get:function(){return yn}}),Object.defineProperty(a,"composeAbortSignals",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(a,"createAbortError",{enumerable:!0,get:function(){return S}}),Object.defineProperty(a,"createIdentifier",{enumerable:!0,get:function(){return Xt}}),Object.defineProperty(a,"createIdentifier$1",{enumerable:!0,get:function(){return f}}),Object.defineProperty(a,"createQueue",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(a,"debounce",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(a,"decodeJwt",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(a,"deepEqual",{enumerable:!0,get:function(){return w}}),Object.defineProperty(a,"defineMixin",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(a,"events",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(a,"fetchWithApiOriginFailover",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(a,"filter",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(a,"findTextDiffBounds",{enumerable:!0,get:function(){return dn}}),Object.defineProperty(a,"generateUUID",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(a,"getActiveBaseUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(a,"getApi",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(a,"getEmitter",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(a,"getEmitter$1",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(a,"getEvent",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(a,"getServiceContainerId",{enumerable:!0,get:function(){return M}}),Object.defineProperty(a,"isAbortError",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(a,"mapHttpStatusToErrorCode",{enumerable:!0,get:function(){return At}}),Object.defineProperty(a,"mergeBackendProxyLayers",{enumerable:!0,get:function(){return br}}),Object.defineProperty(a,"mergeResourceProxyLayers",{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(a,"mergeResourceProxyPolicyLayers",{enumerable:!0,get:function(){return Pr}}),Object.defineProperty(a,"mergeShallowConfigLayers",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(a,"pickKey",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(a,"provideOAuth",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(a,"raceWithAbortSignal",{enumerable:!0,get:function(){return It}}),Object.defineProperty(a,"registerRestTransport",{enumerable:!0,get:function(){return an}}),Object.defineProperty(a,"releaseContainer",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(a,"resolveContainer",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(a,"resolveExplicitApiBaseUrl",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(a,"setApiOriginFailoverHook",{enumerable:!0,get:function(){return en}}),Object.defineProperty(a,"snapshot",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(a,"textFingerprint",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(a,"throwIfAborted",{enumerable:!0,get:function(){return q}}),Object.defineProperty(a,"waitForElement",{enumerable:!0,get:function(){return ot}})});
2096
+ __emailmaker__.define("static/umd/de747b3f.js",["require","exports","module"],function(Fn,a,xn){var A=class _t{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof _t&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const r=this._inner.indexOf(t);r>=0&&this._inner.splice(r,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function j(e){return`service_container_${e}`}var P=new Set,W;function lt(){if(!W)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,K.prototype.getInstanceAsync),e.stack}function $(e){P.delete(e)&&W?.end(e)}var K=class se extends A{_parent;_injectCallbacks=[];_injections=Object.create(null);_runCallbacks(t){[...this._injectCallbacks].forEach(r=>r(t))}constructor(t=null){super(),this._parent=t,t&&this.addDisposable(t.onInject(r=>this._runCallbacks(r)))}onInject=t=>(this._injectCallbacks.push(t),{dispose:()=>{const r=this._injectCallbacks.indexOf(t);r>=0&&this._injectCallbacks.splice(r,1)}});inject(t,r){this._injections[t]=()=>r,this._runCallbacks(t)}injectFactory(t,r,n){const i=this._injections[t];let o=typeof i=="function"?i():i;const s=this._injections[t]=()=>(o=r(this,o),o);n&&s(),this._runCallbacks(t)}_find(t,r=!0){return this._injections[t]||r&&this._parent?._find(t)}_onInject(t,r,n=new A){return n.addDisposable(this.onInject(i=>{t===i&&!n.isDisposed()&&(n.dispose(),r(this.getInstance(i)))})),this._parent&&n.addDisposable(this._parent._onInject(t,r,n)),this.addDisposable(n),n}getInstance(t,r=!0){const n=this._find(t,r);if(typeof n=="function")return n()}getOrCreateInstance(t,r){const n=this._find(t);if(typeof n=="function")return n();const i=r(this);return this.inject(t,i),i}getInstanceAsync(t){const r=this._find(t);if(typeof r=="function")return Promise.resolve(r());const n=lt();return new Promise((i,o)=>{const s={id:String(t),startedAt:Date.now(),origin:n,container:this,reject:o};P.add(s),W?.start(s),this._onInject(t,()=>{$(s),i(this.getInstance(t))})})}failPendingWaits(t){for(const r of Array.from(P))r.container===this&&($(r),r.reject(t))}pendingWaits(){return[...P].filter(t=>t.container===this)}addService(t,r){const n=j(t);this.injectFactory(n,(o,s=[])=>s.indexOf(r)<0?[...s,r]:s);const i=new A;return i.addDispose(()=>{this.injectFactory(n,(o,s=[])=>s.filter(c=>c!==r))}),i}addServiceFactory(t,r,n){const i=j(t);let o;this.injectFactory(i,(c,u=[])=>(o=r(c,o),o===void 0?u:u.indexOf(o)<0?[...u,o]:u),n);const s=new A;return s.addDispose(()=>{this.injectFactory(i,(c,u=[])=>o===void 0?u:u.filter(_=>_!==o))}),s}getServices(t){const r=j(t);return[...this.getInstance(r,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new se(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const r=this._parent?.getOrCreateIsolatedContainer(t);return new se(r)})}remove(t){const r=this._injections;delete r[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(P))t.container===this&&$(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function q(e){return e.startsWith("__")?e:`__${e}__`}function dt(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=q(e),r=globalThis;return r[t]??={}}function ft(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function Et(e){if(e)return q(e);const t="emailmaker".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return q(t)}function ae(e){const t=Et(e),r=dt(t);if(ft(r.container))return r.container;const n=new K(null);return r.container=n,n}function pt(e){return ae(e)}function ht(){let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let n=Math.random()*16;return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),(r==="x"?n:n&3|8).toString(16)})}function ce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():ht()}function f(e=ce()){return e}function ue(){return"umd".trim()||"unknown"}function Ot(e){if(typeof globalThis>"u")return;const t=ue(),r=globalThis[e]??{};globalThis[e]=r;const n=r.__diagnostics??={},i=n.diModuleEval??={evalCount:0,records:[]};i.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),i.evalCount+=1}function mt(){const e="emailmaker".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function gt(e,t){if(Ot(t),typeof globalThis>"u")return e;const r=ue(),n=globalThis,i=n[t]=n[t]||{},o=i.__diagnostics=i.__diagnostics||{},s=o.dependencyResolver=o.dependencyResolver||{entries:[]},c={container:e,source:"packages/runtime-core/di/index.ts",buildSource:r,timestamp:Date.now(),stack:new Error().stack};return s.entries.push(c),e}var B;function At(){if(B)return B;const e=mt();return B=gt(ae(e),e),B}var C=new Proxy({},{get(e,t,r){const n=At(),i=Reflect.get(n,t,r);return typeof i=="function"?i.bind(n):i}});function It(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}function S(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e===void 0?"The operation was aborted.":typeof e=="string"?e:e instanceof Error?e.message:String(e);return new DOMException(t,"AbortError")}function Tt(e){return e instanceof DOMException&&e.name==="AbortError"}function Y(e){if(e?.aborted)throw S(e.reason)}function St(e,t){return t?(t.aborted&&e.catch(()=>{}),Y(t),new Promise((r,n)=>{const i=()=>{o(),n(S(t.reason))},o=()=>{t.removeEventListener("abort",i)};t.addEventListener("abort",i),e.then(s=>{o(),r(s)},s=>{o(),n(s)})})):e}var _e=class extends A{_options;_listeners=[];constructor(e={}){super(),this._options=e}getListeners(e){return this._listeners.flatMap(([t])=>typeof t=="function"?t:t.getListeners(e))}hasListeners(){for(const[e]of this._listeners){if(typeof e=="function")return!0;const t=e;if(typeof t.hasListeners=="function"){if(t.hasListeners())return!0;continue}return!0}return!1}_addListener(e,t=0,r){if(this.isDisposed())return{dispose:()=>{}};const n=this._listeners,i=this._options;r&&typeof e=="function"&&(e=e.bind(r));const o=n.findIndex(([,c])=>c<t),s=[e,t];return n.splice(o>=0?o:n.length,0,s),n.length===1&&i.onFirstListenerAdd&&i.onFirstListenerAdd(),{dispose:()=>{const c=n.indexOf(s);c>=0&&(n.splice(c,1),!n.length&&i.onLastListenerRemove&&i.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,r)=>{const n=this._addListener((...i)=>(n?.dispose(),r?e.call(r,...i):e(...i)),t);return n};un=e=>{const t=this._listeners.findIndex(([r])=>r===e);t>=0&&(this._listeners.splice(t,1),this._listeners.length===0&&this._options.onLastListenerRemove&&this._options.onLastListenerRemove())};dispose(){this._listeners.splice(0,this._listeners.length),this._options.onLastListenerRemove&&this._options.onLastListenerRemove(),super.dispose()}},b=class extends _e{execute(e,t){for(const r of t)try{r(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},bt=class extends b{execute([e],t){for(const r of t)try{r(e)}catch{}}},Dt=class extends b{_suspendCounter=0;_wasFired=!1;execute([e],t){if(this._suspendCounter)this._wasFired=!0;else for(const r of t)try{r(e)}catch{}}suspend(){this._suspendCounter++}resume(){--this._suspendCounter===0&&this._wasFired&&(this.fire(),this._wasFired=!1)}},F=class extends b{async execute([e],t){const r=[];for(const n of t)try{r.push(await n(e))}catch{}return r}async fireSettled(e){const t={results:[],errors:[]};if(this.isDisposed())return t;for(const r of this.getListeners([e]))try{t.results.push(await r(e))}catch(n){t.errors.push(n)}return t}};function Nt(e,t=0){const r=new _e,n=e(r,t);return n&&r.addDisposable(n),r.event}function yt(e,t,r=0){const n=new b,i=e((...o)=>{if(t(...o))return n.fire(...o)},r);return i&&n.addDisposable(i),n.event}function Pt(e,t=0,r=0){const n=new b;let i,o;const s=e((...c)=>{o=c,i||(i=setTimeout(()=>{o&&n.fire(...o),i=void 0},t))},r);return s&&n.addDisposable(s),n.event}function Ct(e,t){return e.getOrCreateInstance(t,()=>new F)}function d(e){return f(e)}var z;(function(e){e.BEFORE_SAVE_EMAIL=d("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=d("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=d("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=d("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=d("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=d("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=d("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=d("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=d("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=d("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=d("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=d("events.ON_EMAIL_CHANGED_ID"),e.ON_BLOCK_CHANGED_ID=d("events.ON_BLOCK_CHANGED_ID"),e.ON_BLOCK_OPEN_ID=d("events.ON_BLOCK_OPEN_ID"),e.ON_BLOCK_CLOSE_ID=d("events.ON_BLOCK_CLOSE_ID"),e.OPEN_BLOCK_REQUEST_ID=d("events.OPEN_BLOCK_REQUEST_ID"),e.ON_BLOCK_SAVEBUTTON_CLICK_ID=d("events.ON_BLOCK_SAVEBUTTON_CLICK_ID"),e.ON_BLOCK_CLONE_ID=d("events.ON_BLOCK_CLONE_ID"),e.ON_CHUNKS_LOADED=d("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=d("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=d("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=d("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=d("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=d("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=d("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_ANALYTICS_EVENT=d("events.ON_ANALYTICS_EVENT"),e.ON_NOTIFICATION=d("events.ON_NOTIFICATION"),e.READ_LOCALE=d("events.READ_LOCALE"),e.ON_TRANSLATE_ID=d("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=d("events.ON_CODE_VALIDATE_ID"),e.ON_IMPORT_VALIDATE_ID=d("events.ON_IMPORT_VALIDATE_ID"),e.UPLOAD_EVENT_ID=d("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=d("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=d("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=d("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=d("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=d("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=d("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=d("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=d("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=d("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=d("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=d("events.AI_TEXT_STREAM_ID")})(z||(z={}));function vt(e,t){return e.getOrCreateInstance(t,()=>new F).event}function Lt(e,t){return e.getOrCreateInstance(t,()=>new F)}var Rt=f("plugin.app"),wt=f("plugin.disposable"),Mt=f("InitPipelineContext"),jt=f("plugin.instance"),Bt=f("plugin.lateSurfaceListeners"),le=f("plugin.optionsSource"),Ft=f("plugin.store"),de=f("ConfigSource"),xt=f("plugin.standalone.project"),fe=f("plugin.standalone.bootstrapToken"),kn=f("plugin.element"),Ee=f("plugin.securityModule"),kt=f("plugin.standalone.activated"),Ut=f("plugin.standalone.fileProxyRegistered"),J=f("plugin.jwt.token"),v=f("plugin.jwt.error"),Ht=f("PluginCollection"),Gt=d("APP_LOAD_EVENT"),Vt=d("CONFIG_CHANGED_EVENT");function Xt(e,t=window){return{peer:e,send(r){e.postMessage(r,"*")},subscribe(r){const n=i=>{r({data:i.data,source:i.source,ports:i.ports})};return t.addEventListener("message",n),{dispose:()=>t.removeEventListener("message",n)}},close(){}}}function Wt(e){let t=!1;return{peer:e,send(r){e.postMessage(r)},subscribe(r){const n=i=>{r({data:i.data,source:e})};return e.addEventListener("message",n),t||(t=!0,e.start()),{dispose:()=>e.removeEventListener("message",n)}},close(){e.close()}}}function $t(e){return e}function Kt(e){return e&&typeof e=="object"}function pe(e,t){return e&&typeof e=="object"&&e.operationId===t}var T="INIT_MESSAGE",he="em:port-ready",qt="em:window-drained",x="";function Oe(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var Yt=class extends A{_listeners=Object.create(null);addListenerAsync=(e,t,r=0,n)=>{const i=this._listeners[e]||(this._listeners[e]=[]);n&&typeof t=="function"&&(t=t.bind(n));const o=i.findIndex(([c,u])=>r<=u),s=[t,r];return this.isDisposed()||i.splice(o>=0?o:i.length,0,s),{dispose(){const c=i.indexOf(s);c>=0&&i.splice(c,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const r=this._listeners[e]||(this._listeners[e]=[]);let n;for(let i=0;i<r.length;i++){const o=r[i][0],s=n;n=c=>o(c,s)}if(n)return n(t)}};addListener=(e,t,r=0)=>this.addListenerAsync(e,(n,i)=>{try{t(n)}catch{}return i&&i(n)},r)},zt=class extends A{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_portSendHeld=new WeakSet;_inited=!1;_emitter=this.addDisposable(new Yt);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;_outgoingObservers=new Set;_offTargetListeners=new Map;constructor(e,t){super(),this._singleton=t,this._transport=Xt({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(T,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(T))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,r=t.data,n=t.source,i=r?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&n&&r?.operationId==="em:window-drained"){this._ports.has(n)&&this._drained.add(n);return}if(o&&n&&this._drained.has(n))return;if(n&&n!==this._target&&this._greeted.has(n)&&pe(r,T)){this._greeted.delete(n),this._handshaken.add(n),this._postMessage(n,{operationId:T,data:{}}),i&&this.usePort(i,!0,n);return}const s=t.source===this.target||this._isCurrentPort(t.source);if(s||this._notifyOffTarget(r?.operationId,t.source),Kt(r)&&s||this._singleton&&pe(r,T)){if(i&&s){const l=this._target;Promise.resolve().then(()=>this.usePort(i,!0,l))}const c=this._emitter.fireAsync(r.operationId||x,r.operationId===void 0?t:r.data),u=r.result,_=r.error;u&&_&&Promise.resolve(c).then(l=>this._sendMessage(u,l),l=>this._sendMessage(_,l))}};setTarget(e){if(this._target!==e){if(this._target=e,!e){this._inited=!1;return}if(this._handshaken.has(e)){this._inited=!0,this._emitter.fireAsync(T,void 0);return}this._inited=!1,this._postMessage(e,{operationId:T,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:T,data:{},port:!0},[t])}observeOutgoing(e){return this._outgoingObservers.add(e),{dispose:()=>{this._outgoingObservers.delete(e)}}}_notifyOutgoing(e,t){for(const r of Array.from(this._outgoingObservers))try{r(e,t)}catch{}}addOffTargetListener(e,t){let r=this._offTargetListeners.get(e);return r||(r=new Set,this._offTargetListeners.set(e,r)),r.add(t),{dispose:()=>{r.delete(t)}}}_notifyOffTarget(e,t){const r=typeof e=="string"?this._offTargetListeners.get(e):void 0,n=r?.size?this._knownPeer(t):void 0;if(!(!r||!n))for(const i of Array.from(r))try{i(n)}catch{}}_knownPeer(e){for(const[r,n]of this._ports)if(n.transport.peer===e)return r;const t=e;return typeof e=="object"&&e!==null&&(this._handshaken.has(t)||this._greeted.has(t))?t:void 0}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}sendNow(e){const t=this._target;return!this._inited||!t?!1:(this._postMessage(t,e),!0)}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:T,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,r=this._target){if(!r||this._ports.has(r))return;const n=Wt(e),i=n.subscribe(this._onTransportMessage);this._ports.set(r,{transport:n,subscription:i}),t&&(n.send({operationId:he,data:{}}),this.drainWindow(r))}holdPort(e=this._target){!e||!this._ports.has(e)||(this._portSendHeld.add(e),this._drained.delete(e))}resumePort(e=this._target){e&&this._portSendHeld.delete(e)}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)&&!this._portSendHeld.has(this._target)}hasPort(e,t){const r=this._ports.get(e);return r!==void 0&&(t===void 0||r.transport.peer===t)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e),this._portSendHeld.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:qt,data:{}},"*")}isWindowDrained(e){return this._drained.has(e)}_isPortSource(e){for(const t of this._ports.values())if(t.transport.peer===e)return!0;return!1}_isCurrentPort(e){return this._target!==void 0&&this._ports.get(this._target)?.transport.peer===e}getTarget(){return this._target}get target(){return this._target}_postMessage(e,t,r){let n=t;this._outgoingFilter&&!r?.length&&(n="data"in t?{...t,data:this._outgoingFilter(t.data)}:this._outgoingFilter(t));try{const i=this._ports.get(e);if(i&&!this._portSendHeld.has(e)){i.transport.send(n);return}if(r?.length){e.postMessage(n,"*",r);return}e.postMessage(n,"*")}catch(i){if(i?.name==="DataCloneError"){const o=typeof n?.data=="object"&&n?.data!==null?n.data:void 0}throw i}}_sendMessage(e,t,r=!0){if(!r&&!this.isInited())return;e&&this._notifyOutgoing(e,t);const n=this.addDisposable(this.onInit(i=>{const o=e?{operationId:e,data:t}:t;try{this._postMessage(i,{...o})}finally{n.dispose()}}))}send(e,t,r){return typeof e=="string"?this._sendMessage(e,t,r):this._sendMessage(x,e,t)}sendAsync(e,t,r=!0){if(!r&&!this.isInited())return Promise.resolve();this._notifyOutgoing(e,t);const n=Oe(),i=Oe();return new Promise((o,s)=>{const c=this.addDisposable(new A);c.addDisposable(this.onInit(u=>{try{this._postMessage(u,{operationId:e,data:t,result:n,error:i})}catch(_){c.dispose(),s(_);return}c.addDisposable(this._onMessage(n,_=>{o(_),c.dispose()})),c.addDisposable(this._onMessage(i,_=>{s(_),c.dispose()}))}))})}_onMessage(e,t,r=0){return this._emitter.addListener(e,t,r)}addListener(e,t,r){return t?this._onMessage(e,t,r):this._onMessage(x,e)}addListenerAsyncPipe(e,t,r=0){return this._emitter.addListenerAsync(e,t,r)}addListenerAsync(e,t,r=0){return this._emitter.addListenerAsync(e,async(n,i)=>{const o=await t(n);return i?i(n):o},r)}isInited(){return this._inited}get inited(){return this._inited}onInit(e,t=!0,r=0){const n=this.addDisposable(new A);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?n.addDisposable(this.onInit(e,t,r)):e(this._target)}):n.addDisposable(this._onMessage(T,()=>{e(this._target)},r)),n}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function L(e){return f(e)}var Jt=f("extensions.atomsHandlers"),Qt=L("HANDLE_ATOM_INSERT"),Zt=f("HeadlessMode"),er=f("extensions.sandboxExtensions"),tr="SANDBOX_EXTENSION_SCRIPT_STATUS",rr=f("MESSAGE_SERVICE"),nr=L("SETTINGS_PANEL_EVENT"),ir="advanced",or=L("MODAL_SHOW_EVENT"),sr=L("MODAL_CLOSE_EVENT"),ar=L("MODAL_UPDATE_EVENT"),Un=f("client"),Hn=f("v2_client"),Gn=f("ai_client"),cr=f("app.cookieManager"),Vn=f("app.storageProvider"),Xn=f("image-blob-resolver"),ur=f("template-directives"),_r=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),lr=class{baseUrl="https://api.emailmaker.ru/wp-json";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(r=>this.encodeQueryParam(t,r)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(r=>typeof t[r]<"u").map(r=>Array.isArray(t[r])?this.addArrayQueryParam(t,r):this.addQueryParam(t,r)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce((t,r)=>{const n=e[r];return t.append(r,n instanceof Blob?n:typeof n=="object"&&n!==null?JSON.stringify(n):`${n}`),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 r=this.abortControllers.get(e);return r?r.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};async request({body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:c,extraQuery:u,proxyHandler:_,...l}){const E=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},h=this.mergeRequestParams(l,E);u&&(i=i?{...i,...u}:u);const p=i&&this.toQueryString(i),g=this.contentFormatters[n||"application/json"],O=o||h.format,V=`${s||this.baseUrl||""}${r}${p?`?${p}`:""}`,jn=_?_(V,{body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:c,extraQuery:u,proxyHandler:_,...l}):V,ct=new Request(jn,{...h,headers:{...h.headers||{},...n&&n!=="multipart/form-data"?{"Content-Type":n}:{}},signal:(c?this.createAbortSignal(c):h.signal)||null,body:typeof e>"u"||e===null?null:g(e)});return this.customFetch(ct).then(async ut=>{const I=ut;I.data=null,I.error=null,I.meta={request:ct,response:I};const Bn=O?await ut[O]().then(X=>(I.ok?I.data=X:I.error={data:X},I)).catch(X=>(I.error=X,I)):I;return c&&this.abortControllers.delete(c),Bn})}},dr=f("prewarm.networkActivity");function fr(){let e=0;const t=new Set,r=()=>{t.forEach(n=>n())};return{begin(){e+=1,r();let n=!1;return()=>{n||(n=!0,e-=1,r())}},inFlight:()=>e,watch(n){return t.add(n),()=>t.delete(n)}}}function Er(e){return e.getOrCreateInstance(dr,()=>fr())}var me=Symbol("rest.publicRequest"),k=f("rest.requestHandler"),pr=f("rest.responseHandler"),Q=f("rest.customFetch"),hr=(e,t)=>fetch(e,t),Z=f("rest_transport"),Or=e=>{e.inject(Q,{execute:async(t,r={})=>{const n=e.getServices(k),i={public:r[me]===!0},o=Er(e).begin();try{let s=t instanceof Request?t:new Request(t,r);for(const _ of n){const l=await _.execute(s,i);l instanceof Request&&(s=l)}let c=await fetch(s);const u=e.getServices(pr);for(const _ of u)c=await _.execute(c,s);return c}finally{o()}}})};function mr(e,t){const r=e.getInstance(Z);if(!r)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(n=>new n(r)))}var ge="INJECTION";function Ae(e){return e.getState}function gr(e){if(Ae(e)){const t=e.getState()[ge];return t&&C.getOrCreateInstance(t,()=>C.createChild())}else return e}function Ar(e){if(!Ae(e)){e.dispose();return}const t=e.getState()[ge];t&&(C.getInstance(t)?.dispose(),C.remove(t))}function Ir(e,t){for(const r of e)if(r&&t in r)return r[t]}function Ie(e){return Object.assign({},...e)}var Te=["generic","stockImages","emFiles","cdn"];function ee(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Se(e){return!ee(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Te.includes(t))}function be(e){return e.length===0?[]:e.length===1?e[0]:e}function De(e){let t=!1,r=[];for(const n of e)if(n!==void 0){if(t=!0,Array.isArray(n)){r=[...n,...r];continue}r=[n,...r]}if(t)return be(r)}function Tr(e){return ee(e)&&("value"in e||"replace"in e)}function Ne(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function Sr(e){let t=!1,r=[],n=!1;for(const o of e)if(o!==void 0){if(Tr(o)){t=!0,o.replace&&(r=[],n=!0),o.value!==void 0&&(r=Ne(r,o.value),n=!0);continue}r=Ne(r,o),n=!0}const i=n?be(r):void 0;if(!t)return i;if(i!==void 0)return{value:i}}function br(e){const t=e.filter(n=>n!==void 0);if(t.length===0)return;if(!t.some(n=>Se(n)))return De(t);const r={};for(const n of Te){const i=Sr(e.map(o=>{if(o!==void 0)return Se(o)?o[n]:n==="generic"?o:void 0}));i!==void 0&&(r[n]=i)}return Object.keys(r).length>0?r:void 0}function Dr(e){return De(e)}function Nr(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(ee(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function yr(e,t){const r=[...e],n=new Set(r.map(i=>i.toLowerCase()));for(const i of t){const o=i.trim().replace(/:\d+$/,"");if(!o)continue;const s=o.toLowerCase();n.has(s)||(n.add(s),r.push(o))}return r}function Pr(e){let t=[],r=!1;for(const n of e){const i=Nr(n);i&&(r=!0,i.replace&&(t=[]),t=yr(t,i.hosts))}return r?t:void 0}function Cr(e){const t=e.filter(i=>i!==void 0);if(t.length===0)return;const r=Ie(t.map(({directHosts:i,...o})=>o)),n=Pr(t.map(i=>i?.directHosts));return n!==void 0&&(r.directHosts=n),r}function te(e){return e?.backendProxy}function R(e){return e.replace(/\/$/,"")}function ye(e){return/^https?:\/\//i.test(e)}function Pe(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function vr(e){const t=new Set;return e.filter(r=>!r.url||t.has(r.url)?!1:(t.add(r.url),!0))}function Lr(e){const t=te(e);return t?[t]:[]}function Rr(e){return{proxyEmFiles:!0,proxyAi:!1}}function wr(e,t){const r=Rr(t),n=t?.backendProxyPolicy;switch(e){case"emFiles":return n?.proxyEmFiles??r.proxyEmFiles;case"ai":return n?.proxyAi??r.proxyAi;default:return!0}}var Mr={url:".+",url_encoded:".+",origin:"https?:\\/\\/[^\\/?#]+",origin_encoded:".+",proxy_url:"https?:\\/\\/[^\\/?#]+",proxy_url_encoded:".+",path:"[^?#]*",pathname:"[^?#]*",path_with_slash:"\\/[^?#]*",pathname_with_slash:"\\/[^?#]*",query:"[^#]*",search:"\\?[^#]*",hash:"#.*",fragment:".*",pathname_after_wp_json:"[^?#]*",pathname_after_wp_json_with_slash:"\\/[^?#]*",rest_namespace:"[^/?#]*",rest_version:"[^/?#]*",rest_route:"[^?#]*",rest_route_with_slash:"\\/[^?#]*"};function jr(e){const t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(n,i)=>(t.push(i),`(${Mr[i]||".+"})`));return{regex:new RegExp(`^${r}$`,"i"),tokens:t}}function Br(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function Fr(e,t){if(Br(t))return e;try{const r=new URL(e);return`${r.origin}${r.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function xr(e,t,r){if(r.endsWith("_encoded"))return!0;const n=e.slice(0,t),i=n.lastIndexOf("#"),o=n.lastIndexOf("?"),s=n.lastIndexOf("&"),c=n.lastIndexOf("=");return c>Math.max(o,s)&&c>i}function kr(e){try{const t=new URL(e),r=t.pathname.replace(/^\/+/,""),n=t.search.replace(/^\?/,""),i=t.hash.replace(/^#/,""),o=r.replace(/^wp-json\/?/i,""),s=o?`/${o}`:"/",c=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),u=c?.[1]||"",_=c?.[2]||"",l=c?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:r,pathname:r,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:n,search:t.search,hash:t.hash,fragment:i,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:s,rest_namespace:u,rest_version:_,rest_route:l,rest_route_with_slash:l?`/${l}`:"/"}}catch{return}}function re(e,t){if(!e)return{};if(Array.isArray(e)){for(const c of e){const u=re(c,t);if(u!==void 0)return u}return}if(e==="*")return{};const r=Fr(t,e),{regex:n,tokens:i}=jr(e),o=n.exec(r);if(!o)return;const s={};return i.forEach((c,u)=>{s[`matched_${c}`]=o[u+1]||""}),s}function U(e,t,r={}){const n=kr(t);if(!n)return t;const i={...n,...r};let o="",s=0;const c=/\{([a-z_]+)\}/gi;let u;for(;u=c.exec(e);){o+=e.slice(s,u.index);const _=i[u[1]]??"",l=xr(e,u.index,u[1])?encodeURIComponent(_):_;o+=l,s=u.index+u[0].length}o+=e.slice(s);try{const _=new URL(o),l=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&l.search&&l.searchParams.forEach((E,h)=>{_.searchParams.has(h)||_.searchParams.append(h,E)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&l.hash&&!_.hash&&(_.hash=l.hash),_.toString()}catch{return o}}function Ce(e,t){try{const r=new URL(t);return`${R(e)}/${r.pathname.replace(/^\//,"")}${r.search}${r.hash}`}catch{return t}}function ve(e,t){const r=R(e);return t?ye(t)?t:t.startsWith("?")||t.startsWith("#")?`${r}${t}`:`${r}${t.startsWith("/")?"":"/"}${t}`:r}function Le(e,t,r,n){const i=e.match;return i?Array.isArray(i)?i.some(o=>Le({...e,match:o},t,r,n)):typeof i=="function"?!!i({url:t,method:n,requestType:r}):i==="*"?!0:re(i,t)!==void 0:!0}function Ur(e,t,r,n="generic"){if(e==null)return[];const i=Array.isArray(e)?e:[e],o=[];return i.forEach((s,c)=>{if(!s)return;if(typeof s=="string"){const E=s.includes("{")&&s.includes("}")?U(s,t):Ce(s,t);o.push({key:`backend:${c}`,url:E,source:"resource"});return}if(!Pe(s)||!("rewrite"in s))return;const u=s;if(!Le(u,t,n,r))return;const _=typeof u.match=="string"||Array.isArray(u.match)?re(u.match,t)||{}:{},l=typeof u.proxyBase=="string"&&u.proxyBase.trim()?u.proxyBase.trim():void 0;(Array.isArray(u.rewrite)?u.rewrite:[u.rewrite]).filter(Boolean).forEach((E,h)=>{const p=typeof E=="function"?(()=>{const g=E({url:t,proxyBase:l,method:r,requestType:n,..._}),O=l&&!ye(g)?ve(l,g):g;return O.includes("{")&&O.includes("}")?U(O,t,_):O})():l?U(ve(l,E),t,_):E.includes("{")&&E.includes("}")?U(E,t,_):Ce(E,t);o.push({key:`backend:${u.id||"rule"}:${c}:${h}`,url:p,source:"resource"})})}),vr(o)}function Hr(e){try{const t=new URL(e);return/(?:^|\/)wp-json\/em-files\/v\d+(?:\/|$)/i.test(t.pathname)?"emFiles":/(?:^|\/)wp-json\/ai-generator\/v\d+(?:\/|$)/i.test(t.pathname)?"ai":"generic"}catch{return"generic"}}function Gr(e,t=[]){return e==null||(Array.isArray(e)?e:[e]).forEach(r=>{if(r){if(typeof r=="string"){const n=r.split("{")[0]?.trim();n&&t.push(R(n));return}!Pe(r)||!("rewrite"in r)||(typeof r.proxyBase=="string"&&r.proxyBase.trim()&&t.push(R(r.proxyBase.trim())),(Array.isArray(r.rewrite)?r.rewrite:[r.rewrite]).forEach(n=>{if(typeof n!="string")return;const i=n.split("{")[0]?.trim();i&&t.push(R(i))}))}}),t}function Vr(e,t){return Lr(t).flatMap(r=>Gr(r)).filter(Boolean).some(r=>r&&e.startsWith(r))}function Xr(e,t){return!!te(t)&&wr(e,t)}function Wr(e,t={}){const r=t.requestType||Hr(e);return Xr(r,t.config)?Ur(te(t.config),e,t.method,r):[]}function $r(e,t={}){return Vr(e,t.config)?[e]:Wr(e,t).map(r=>r.url)}function D(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function Re(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const r=t.find(o=>o.aborted);if(r)return r;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const n=new AbortController,i=o=>{n.signal.aborted||n.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>i(o),{once:!0});return n.signal}var we=3e5,Me=15e3,m=null,je=!1;function Kr(){return!0}function qr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return we;const t=Number(e);return Number.isFinite(t)&&t>0?t:we}function Yr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return Me;const t=Number(e);return Number.isFinite(t)&&t>0?t:Me}function zr(){const e="https://app.emailmaker.ru/api/".trim();return e?D(e):void 0}function Jr(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const r=JSON.parse(t);if(!Array.isArray(r))throw new Error("expected JSON array");return r.map(n=>String(n).trim()).filter(Boolean)}catch{return je||(je=!0),[]}return t.split(",").map(r=>r.trim()).filter(Boolean)}function Qr(e){const t=new Set,r=[];for(const n of e){const i=D(n);t.has(i)||(t.add(i),r.push(i))}return r}function Be(e){const t=String(e||"").trim();return t?D(t):zr()}function Fe(e,t=[]){return e?Qr([e,...t]).slice(0,3):[]}function xe(){return Jr(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function Zr(e=Date.now()){return m?e-m.switchedAt>=qr():!0}function ke(e=Date.now()){m&&Zr(e)&&(m=null)}function N(e){if(!Kr())return!1;const t=Be(e);if(!t)return!1;const r=xe();return r.length===0?!1:Fe(t,r).length>1}function w(e){const t=Be(e);if(!t)return[];const r=xe();return r.length===0?[t]:Fe(t,r)}function H(e){const t=w(e);if(t.length===0)return"";if(ke(),m){const r=t.indexOf(m.activeUrl);if(r>=0)return t[r]}return t[0]}function Ue(e){const t=w(e);if(t.length<=1||(ke(),!m||!t.includes(m.activeUrl)))return t;const r=m.activeUrl;return[r,...t.filter(n=>n!==r)]}function He(e){return H(e)||void 0}function Ge(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const r=Yr(),n=new AbortController;let i;const o=setTimeout(()=>{i=en(r),n.abort(i)},r);return{signal:Re(t,n.signal),timeoutError:()=>i,done:()=>clearTimeout(o)}}function en(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const r=new Error(t);return r.name="TimeoutError",r}function Ve(e){return e===502||e===503||e===504}function Xe(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var We;function tn(e){We=e}function G(e,t){if(!N(t))return;const r=w(t);if(r.length<=1)return;const n=r.indexOf(D(e));if(n<0)return;const i=n+1;if(i>=r.length)return;const o=r[i],s=m?.activeUrl;m={activeUrl:o,switchedAt:Date.now()},s!==o&&We?.()}function $e(e,t){if(!N(t))return;const r=D(e),n=w(t);if(n.includes(r)){if(r===n[0]){m=null;return}m?.activeUrl!==r&&(m={activeUrl:r,switchedAt:Date.now()})}}function Ke(){m=null}var rn=e=>{const t=new FormData,r=(n,i,o)=>{if(i!=null){if(i instanceof Blob){n.append(o,i);return}if(Array.isArray(i)){i.forEach((s,c)=>{const u=o?`${o}[${c}]`:`${c}`;r(n,s,u)});return}if(typeof i=="object"){Object.keys(i).forEach(s=>{const c=i[s],u=o?`${o}[${s}]`:s;r(n,c,u)});return}n.append(o,String(i))}};return r(t,e),t},nn={baseUrl:D("https://app.emailmaker.ru/api/"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},y=new Map;function on(e){const t=e?.getInstance(de);return t?t.get()??t.bootstrap():void 0}var sn=class extends lr{container;constructor(e={},t){super(e),this.container=t}buildRequestUrl(e){const{path:t,baseUrl:r,extraQuery:n}=e;let{query:i}=e;n&&(i=i?{...i,...n}:n);const o=i&&this.toQueryString(i);return`${r||this.baseUrl||""}${t}${o?`?${o}`:""}`}buildRequestKey(e,t){return`${t.toUpperCase()} ${e}`}getBackendProxyCandidates(e,t){const r=on(this.container),n=this.container?.getInstance(Ee)!==void 0,i=$r(e,{config:r,method:t,standalone:n}),o=i.length>0?i:[e],s=this.buildRequestKey(e,t),c=y.get(s);return!c||!o.includes(c)?o:[c,...o.filter(u=>u!==c)]}shouldRetryResponse(e){return e.status===502||e.status===503||e.status===504}resolveFailoverBaseUrl(){return String(this.baseUrl||"").trim()||void 0}async requestOnOrigin(e,t,r=!1){const n={...e,baseUrl:t},i=this.buildRequestUrl(n),o=n.method||"GET",s=this.buildRequestKey(i,o),c=this.getBackendProxyCandidates(i,o);let u,_;for(const l of c){const E=p=>p===i?l:p,h=r?Ge(e.signal):void 0;try{const p=await super.request({...n,proxyHandler:E,...h?{signal:h.signal}:{}});if(!p.ok&&this.shouldRetryResponse(p)&&l!==c[c.length-1]){_=p,y.get(s)===l&&y.delete(s);continue}return y.set(s,l),p}catch(p){y.get(s)===l&&y.delete(s);const g=h?.timeoutError();if(g)throw g;if(u=p,(p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p}finally{h?.done()}}if(_)return _;throw u instanceof Error?u:new Error("Backend proxy chain failed")}async request(e){const t=String(e.baseUrl||"").trim();if(t)return this.requestOnOrigin(e,t);const r=this.resolveFailoverBaseUrl(),n=N(r),i=e.failoverAttemptTimeout??n,o=n?Ue(r):r?[H(r)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let s,c;for(let u=0;u<o.length;u++){const _=o[u],l=u===o.length-1;try{const E=await this.requestOnOrigin(e,_,i);if(!E.ok&&Ve(E.status)){if(c=E,!l){G(_,r);continue}break}return E.ok&&$e(_,r),E}catch(E){if(!Xe(E))throw E;s=E,l||G(_,r)}}if(n&&Ke(),c)return c;throw s instanceof Error?s:new Error("API origin failover chain failed")}};function an(e={},t){const r=new sn({...nn,...e},t);return r.contentFormatters["multipart/form-data"]=rn,r}var qe=f("rest.clientFactory"),cn=e=>{Or(e);const t=an({customFetch:e.getInstance(Q)?.execute??hr},e);e.inject(Z,t)},Ye;(function(e){const t="https://racs.emcdn.ru/v3";function r(i,o){const s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(o)};return fetch(`${t}?resource=${i}&dataset=${document.location.hostname}`,s)}e.post=r;async function n(i,o=0){const s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:`{"filter":{},"limit":${o}}`};return await(await fetch(`${t}/get?resource=${i}&dataset=${document.location.hostname}`,s)).json()}e.getAll=n})(Ye||(Ye={}));function M(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const r=Array.isArray(e),n=Array.isArray(t);if(r){if(!n)return!1;const c=e.length;if(t.length!==c)return!1;for(let u=0;u<c;u++)if(!M(e[u],t[u]))return!1}else if(n)return!1;const i=Object.keys(e),o=Object.keys(t),s=i.length;if(s!==o.length)return!1;for(let c=0;c<s;c++){const u=i[c];if(!t.hasOwnProperty(u)||!M(e[u],t[u]))return!1}}return!0}function un(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),r=atob(t),n=new Uint8Array(r.length);for(let i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return new TextDecoder().decode(n)}function ze(e){const[t,r,n]=e.split("."),i=JSON.parse(un(r));return{exp:i.exp,createdAt:i.iat,data:i}}var ne=f("plugin.auth.token"),Je=new WeakMap,_n=3e4;function ln(e){let t;try{t=ze(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+_n}function dn(e,t,r,n){const i=Je.get(e);i&&(i.stale=!0);const o={stale:!1};Je.set(e,o),e.injectFactory(ne,async(s,c)=>{if(o.stale)return"";try{let u=await c||void 0;if(!u){const _=e.getInstance(fe);_&&(u=await _)}return t?!u||ln(u)?await t(r,n,u):u:""}catch{return""}},!0)}var Qe=f("auth.oauthProvided"),Ze=new WeakMap;function et(e,t){const r=Ze.get(e)??{applied:!1};(!r.applied||r.getAuthToken!==t.getAuthToken||!M(r.user,t.user)||r.project!==t.project)&&(Ze.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),dn(e,t.getAuthToken,t.user,t.project))}function tt(e){if(e.getInstance(Qe))return;e.inject(Qe,!0);let t;e.getInstance(le)?.watch(r=>{t=r}),e.addService(k,{execute:async(r,n)=>{if(n?.public||!t?.getAuthToken)return;e.getInstance(ne)===void 0&&et(e,t);const i=await e.getInstanceAsync(ne);i&&r.headers.set("authorization",`Bearer ${i}`)}})}function fn(e,t){if(e===t)return;let r=0;const n=Math.min(e.length,t.length);for(;r<n&&e[r]===t[r];)r++;let i=e.length,o=t.length;for(;i>r&&o>r&&e[i-1]===t[o-1];)i--,o--;return{start:r,fromEnd:i,toEnd:o}}function En(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),16777619);return{length:e.length,hash:t>>>0}}var pn={theme:"canvas_fact_theme",flags:"canvas_fact_flags",commonStyles:"canvas_fact_common_styles",lockEditor:"canvas_fact_lock_editor",codeMode:"canvas_fact_code_mode",appName:"canvas_fact_app_name",previewPage:"canvas_fact_preview_page",viewport:"canvas_fact_viewport"},hn={text:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, 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},links:{color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, 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:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},textAlign:"center",padding:{all:null,top:null,right:null,bottom:null,left:null}},block:{backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null}}},rt="ERROR",On="useblocks",mn={em_token:"em_access_token",em_refresh_token:"em_refresh_token",em_admin_token:"em_admin_access_token",em_admin_refresh_token:"em_admin_refresh_token",em_impersonation:"em_impersonation",em_elements_view:"em_elements_view",em_new_block:"em_new_block",em_new_email:"em_new_email",em_id:"em_id",em_name:"em_name",em_email:"em_email",em_locale:"em_locale",em_carrotquest_hash:"em_carrotquest_hash",em_ducalis_hash:"em_ducalis_hash",em_email_subscription_consent:"em_email_subscription_consent",em_folder:"em_folder",promocode:"promocode",em_active_tab:"em_active_tab"},gn={em_color_scheme:"em_color_scheme",em_code_mode_pane_sizes:"em_code_mode_pane_sizes",em_preview_pane_sizes:"em_preview_pane_sizes",em_default_sizes:"em_default_sizes",em_pane_sizes:"em_pane_sizes",em_test_emails:"em_test_emails",em_menu_is_locked:"em_menu_is_locked",em_code_mode_settings:"em_code_mode_settings",em_folder_is_open:"em_folder_is_open",em_active_tab:"em_active_tab",em_ai_settings:"em_ai_settings",em_last_active_page:"em_last_active_page",em_layout_convert_never_suggest:"em_layout_convert_never_suggest",em_filemanager_v2:"em_filemanager_v2",em_projects_v2:"em_projects_v2",em_translations_v2:"em_translations_v2",em_emails_v2:"em_emails_v2",em_blocks_v2:"em_blocks_v2",em_revisions_v2:"em_revisions_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_guest_locale:"em_guest_locale"},An="light",In="dark",Tn="system",Sn="(prefers-color-scheme: dark)",bn=15e3,Dn=3e3,Nn={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_EDITOR:"update_editor",UPDATE_EDITOR_POSITION:"update_editor_position",UPDATE_SIDE_MENU_EDITOR:"update_side_menu_editor",SAVE_EMAIL:"saveEmail",SANDBOX_ELEMENT_SETTINGS_SET:"sandbox_element_settings_set",SANDBOX_IMAGE_RESET:"sandbox_image_reset",SANDBOX_NATIVE_IMAGE_DROP_CLEAR:"sandbox_native-image-drop-clear",SANDBOX_EMAIL_SETTINGS_SET:"sandbox_email_settings_set",SANDBOX_BLOCK_SETTINGS_SET:"sandbox_block_settings_set",SANDBOX_ELEMENT_PARENT_GET:"sandbox_element_parent_get",SANDBOX_ELEMENT_PARENT_TABLE_GET:"sandbox_element_parent_table_get",SANDBOX_ELEMENT_PREV_GET:"sandbox_element_prev_get",SANDBOX_ELEMENT_NEXT_GET:"sandbox_element_next_get",SANDBOX_ELEMENT_REMOVE:"sandbox_element_remove",SANDBOX_ELEMENT_ACTIVE_RESET:"sandbox_element_active_reset",SANDBOX_ELEMENT_ACTIVE_SET:"sandbox_element_active_set",SANDBOX_ELEMENT_HOVER_SET:"sandbox_element_hover_set",SANDBOX_ELEMENT_IMG_LINK:"sandbox_element_img_link",SANDBOX_ELEMENT_TEXT:"sandbox_element_text",SANDBOX_EMAIL_CONTENT_GET:"sandbox_email_content_get",SANDBOX_SET_POSITION_TO_IMG:"sandbox_set_position_to_img",SANDBOX_SET_POSITION_TO_LINK:"sandbox_set_position_to_link",SANDBOX_ACCORDION_ADD_SECTION:"sandbox_accordion_add_section",SANDBOX_ACCORDION_REMOVE_SECTION:"sandbox_accordion_remove_section",APPLICATION_FOCUS_IN_IFRAME:"application_focus_in_iframe",APPLICATION_EMAIL_SETTINGS_SET:"application_email_settings_set",APPLICATION_BLOCK_SETTINGS_SET:"application_block_settings_set",APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",_APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",APPLICATION_ELEMENT_SETTINGS_CLOSE:"application_element_settings_close",APPLICATION_ACTION:"application_action",APPLICATION_EBLOCK_ADD:"application_eblock_add",SANDBOX_EBLOCK_SET_EM_BLOCK_ID:"sandbox_eblock_set_em_block_id",SANDBOX_EBLOCK_CLEAR_EM_BLOCK_ID:"sandbox_eblock_clear_em_block_id",SANDBOX_GLOBAL_BLOCK_REPLACE:"sandbox_global_block_replace",APPLICATION_SCROLL_TO:"application_scroll-to",APPLICATION_SCROLL_BLOCK_SHOW:"application_scroll-block-show",APPLICATION_SCROLL_BLOCK_HIDE:"application_scroll-block-hide",APPLICATION_DISCUSS_SET_ID:"application_discuss_set_id",APPLICATION_DISCUSS_GET_COMMENT:"application_discuss_get_comment",APPLICATION_DISCUSS_NO_COMMENT:"application_discuss_no_comment",APPLICATION_DISCUSS_SAVE_TARGET:"application_discuss_save_target",APPLICATION_IFRAME_SET_HEIGHT:"application_iframe_set_height",APPLICATION_COMMON_STYLES_UPDATE:"application_commonStyles_update",APPLICATION_EMAIL_CONTENT_GET:"application_email_content_get",APPLICATION_OPEN_IMAGE_AI_POPUP:"application_open-image-ai-popup",APPLICATION_OPEN_IMAGE_UPLOAD_POPUP:"application_open-image-upload-popup",APPLICATION_OPEN_IMAGE_EDIT_POPUP:"application_open-image-edit-popup",APPLICATION_OPEN_IMAGE_GIF_POPUP:"application_open-image-gif-popup",APPLICATION_OPEN_IMAGE_STOCK_POPUP:"application_open-image-stock-popup",APPLICATION_CLOSE_IMAGE_EDIT_POPUP:"application_close-image-edit-popup",APPLICATION_NATIVE_IMAGE_DROP:"application_native-image-drop",APPLICATION_SUBJECT_UPDATE:"application_subject_update",APPLICATION_PREHEADER_UPDATE:"application_preheader_update",APPLICATION_DOMPARSER_ERROR:"application_domparser_error",APPLICATION_SYNC_DRIFT:"application_sync_drift",APPLICATION_UPDATE_ENTITY:"application_update_entity",APPLICATION_IFRAME_DRAG_EVENT:"application_iframe_drag_event",APPLICATION_HAS_AMP:"application_has_amp",APPLICATION_CANVAS_IMAGE_GET:"application_canvas_image_get",APPLICATION_PREVIEW_ALERT_SHOW:"application_preview_alert_show",APPLICATION_ATOM_INSERTED:"application_atom_inserted",APPLICATION_TEMPLATE_NOT_EM_ALERT_SHOW:"application_template_not_em_alert_show",SANDBOX_IFRAME_SETSIZE:"sandbox_iframe-setsize",SANDBOX_BLOCK_INSERT:"sandbox_block-insert",SANDBOX_ATOM_INSERT:"sandbox_atom-insert",SANDBOX_DRAG_CANCEL:"sandbox_drag-cancel",UPDATE_EDITOR_POSITION_FROM_EDITOR:"update_position_from_editor",UPDATE_EDITOR_POSITION_FROM_IFRAME:"update_position_from_iframe",SANDBOX_CHANGE_PREVIEW:"sandbox_change_preview",APPLICATION_CHANGE_PREVIEW:"application_change_preview",SANDBOX_LOCK_EDIT:"sandbox_lock_edit",SANDBOX_FLOATBLOCK_ADD:"sandbox_floatBlock_add",SANDBOX_FLOATBLOCK_REMOVE:"sandbox_floatBlock_remove",SANDBOX_FLOATBLOCK_COPY:"sandbox_floatBlock_copy",SANDBOX_FLOATBLOCK_SWAP:"sandbox_floatBlock_swap",EDITOR_CHANGE_FOCUS:"editor_change_focus",SANDBOX_RESIZED:"sandbox_resized",SANDBOX_LOCK_DISCUSS:"sandbox_lock_discuss",SANDBOX_DISCUSS_SET_TARGET:"sandbox_discuss_set_target",SANDBOX_DISCUSS_REMOVE_TARGET:"sandbox_discuss_remove_target",SANDBOX_DISCUSS_RESET:"sandbox_discuss_reset",SANDBOX_DISCUSS_GET_TARGET:"sandbox_discuss_get_target",SANDBOX_READY:"SANDBOX_READY",SANDBOX_FLOATBLOCK_WRAP:"sandbox_floatblock_wrap",SANDBOX_FLOATBLOCK_DIR:"sandbox_floatblock_dir",SANDBOX_SUBJECT_UPDATE:"sandbox_subject_update",SANDBOX_PREHEADER_UPDATE:"sandbox_preheader_update",SANDBOX_DRAG_EVENT:"sandbox_drag_event",SANDBOX_WHEEL:"sandbox_wheel",SANDBOX_TRANSLATIONS:"sandbox_send_translations",SANDBOX_SET_THEME_VARIABLES:"sandbox_send_theme_variables",SANDBOX_SET_PROJECT_FONTS:"sandbox_set_project_fonts",SANDBOX_CANVAS_IMAGE_CACHE_SETUP:"sandbox_canvas_image_cache_setup",SANDBOX_SET_ENTITY:"sandbox_set_entity",SANDBOX_INIT_START:"sandbox_init_start",SANDBOX_INITED:"sandbox_inited",SANDBOX_UPDATE_ENTITY:"sandbox_update_entity",RELOAD:"reload",SANDBOX_ADD_EXTENSIONS:"sandbox_add_extensions",SANDBOX_REMOVE_EXTENSIONS:"sandbox_remove_extensions",SANDBOX_ADD_SCRIPT:"sandbox_add_script",SANDBOX_IS_EMAIL_EMPTY:"sandbox_is_email_empty",SANDBOX_SWITCH_THEME:"sandbox_switch_theme",SANDBOX_CANVAS_HEALTH:"sandbox_canvas_health",SANDBOX_CANVAS_SYNCED:"sandbox_canvas_synced"},yn={language:"html",detectIndentation:!1,wordWrap:"on",wrappingIndent:"same",smoothScrolling:!0,automaticLayout:!0,tabSize:2,indentSize:2},nt=e=>{const t={current:Promise.resolve(),state:e,decorate:(r,n)=>(n&&(r=r.bind(n)),function(...i){const o=t.current.then(()=>r(...i));return t.current=o.then(s=>{t.state=s},s=>{}),o})};return t};function ie(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function Pn(e){return t=>{const r={},n=[];for(const s of e)n.push(s(t));for(const s of n)Object.assign(r,s.instance);return{instance:r,setOptions:async s=>{for(const c of n)await c.setOptions(s)},dispose:()=>{for(const s of n)s.dispose()}}}}function Cn(e=rt){const t=new Error(e);return t.name="AuthPipelineError",t}async function it(e,t,r,n){const i=n?.attemptTimeout??N(r),o=N(r)?Ue(r):w(r).length>0?[H(r)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const s=e.startsWith("/")?e:`/${e}`;let c,u;for(let _=0;_<o.length;_++){const l=o[_],E=_===o.length-1,h=i?Ge(t.signal):void 0;try{const p=await fetch(`${l}${s}`,{...t,...h?{signal:h.signal}:{}});if(!p.ok&&Ve(p.status)){if(c=p,!E){G(l,r);continue}break}return p.ok&&$e(l,r),p}catch(p){const g=h?.timeoutError();if(!g&&!Xe(p))throw p;u=g||p,E||G(l,r)}finally{h?.done()}}if(N(r)&&Ke(),c)return c;throw u instanceof Error?u:new Error("[apiOriginFailover] fetch chain failed")}function ot(e){e.inject(v,void 0),e.inject(J,void 0)}var vn=ie(e=>{let t,r;const n=nt();return e.addService(k,{execute:n.decorate(async(i,o)=>{if(o?.public||!t)return;const s=String(e.getInstance(J)||"").trim();if(s){i.headers.append("authorization",`Bearer ${s}`);return}if(!e.getInstance(v))try{const c=e.getInstance(qe),u=String(c?.getOptions()?.baseUrl||"").trim(),_=He(r||u||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const l=await it("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},_);if(!l.ok)throw new Error(`JWT auth failed: ${l.status}`);const E=await l.json(),h=String(E.token||"").trim();if(!h)throw new Error("JWT auth failed: empty token");e.inject(v,void 0),e.inject(J,h),i.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(v,rt),Cn()}})}),{setOptions(i){const o=i.jwtAuth,s=String(i.baseUrl||"").trim()||void 0,c=!M(o,t),u=s!==r;if(t=o,r=s,!o){ot(e);return}c||u?ot(e):e.inject(v,void 0)}}}),Ln=ie(e=>(tt(e),{setOptions(t){et(e,t)}}));function Rn(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function oe(e,t=document){try{const n=t.querySelector(e);if(n)return n}catch{return null}const r=t.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;if(!i)continue;const o=oe(e,i);if(o)return o}return null}function st(e,t=[]){const r=e.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;i&&(t.push(i),st(i,t))}return t}function wn(e,t,r){if(e.isConnected)return e;const n=e.id?.trim();return n?at(`#${Rn(n)}`,t,r):Promise.reject(S("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function at(e,t,r){if(Y(r),typeof e<"u"){if(typeof e=="string"){const n=e,i=oe(n);if(i)return i;const o=t.addDisposable(new A);return new Promise((s,c)=>{const u=O=>{o.dispose(),O()},_=()=>{u(()=>c(S(r?.reason)))};if(r?.aborted){_();return}r?.addEventListener("abort",_),o.addDispose(()=>r?.removeEventListener("abort",_));const l=document.body??document.documentElement;if(!l){u(()=>c(S("Document is not ready to observe mount element")));return}const E=new Set,h=new MutationObserver(()=>{const O=oe(n);if(O){u(()=>s(O));return}g()}),p=O=>{E.has(O)||(E.add(O),h.observe(O,{attributes:!0,childList:!0,subtree:!0}))},g=()=>{const O=document.documentElement;if(O)for(const V of st(O))p(V)};p(l),g(),o.addDispose(()=>h.disconnect())})}return e instanceof Element?wn(e,t,r):e}return e}var Mn=new Map;Object.defineProperty(a,"ADVANCED_SETTINGS_PANEL",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(a,"APP_COOKIES",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(a,"APP_ID",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(a,"APP_LOAD_EVENT_ID",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(a,"ATOMS_HANDLERS_ID",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(a,"AsyncEmitter",{enumerable:!0,get:function(){return F}}),Object.defineProperty(a,"BaseEmitter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(a,"CANVAS_ECHO_LOST_AFTER_MS",{enumerable:!0,get:function(){return bn}}),Object.defineProperty(a,"CANVAS_ECHO_RECOVERY_WAIT_MS",{enumerable:!0,get:function(){return Dn}}),Object.defineProperty(a,"CANVAS_FACTS",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(a,"COMMON_STYLES",{enumerable:!0,get:function(){return hn}}),Object.defineProperty(a,"CONFIG_CHANGED_EVENT_ID",{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(a,"CONFIG_SOURCE_ID",{enumerable:!0,get:function(){return de}}),Object.defineProperty(a,"COOKIE_MANAGER_ID",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(a,"CUSTOM_FETCH_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(a,"CUSTOM_MESSAGE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(a,"Container",{enumerable:!0,get:function(){return K}}),Object.defineProperty(a,"ContentType",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(a,"DARK",{enumerable:!0,get:function(){return In}}),Object.defineProperty(a,"DISPOSABLE_ID",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(a,"DependencyResolver",{enumerable:!0,get:function(){return C}}),Object.defineProperty(a,"Disposable",{enumerable:!0,get:function(){return A}}),Object.defineProperty(a,"ELEMENT_MAP",{enumerable:!0,get:function(){return Mn}}),Object.defineProperty(a,"EVENT_TYPES",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(a,"Emitter",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(a,"HANDLE_ATOM_INSERT_ID",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(a,"HEADLESS_MODE_ID",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(a,"INIT_PIPELINE_ID",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(a,"INSTANCE_ID",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(a,"JWTMixin",{enumerable:!0,get:function(){return vn}}),Object.defineProperty(a,"LATE_SURFACE_LISTENERS_ID",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(a,"LIGHT",{enumerable:!0,get:function(){return An}}),Object.defineProperty(a,"LOCAL_STORAGE_ITEMS",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(a,"MESSAGE_SERVICE_ID",{enumerable:!0,get:function(){return rr}}),Object.defineProperty(a,"MODAL_CLOSE_EVENT",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(a,"MODAL_SHOW_EVENT",{enumerable:!0,get:function(){return or}}),Object.defineProperty(a,"MODAL_UPDATE_EVENT",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(a,"MONACO_EDITOR_OPTIONS",{enumerable:!0,get:function(){return yn}}),Object.defineProperty(a,"MessageService",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(a,"OAuthMixin",{enumerable:!0,get:function(){return Ln}}),Object.defineProperty(a,"OPTIONS_SOURCE_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(a,"PLUGIN_COLLECTION_ID",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(a,"PORT_READY",{enumerable:!0,get:function(){return he}}),Object.defineProperty(a,"PREFERS_COLOR_SCHEME_DARK",{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(a,"PUBLIC_REQUEST",{enumerable:!0,get:function(){return me}}),Object.defineProperty(a,"REQUEST_HANDLER_ID",{enumerable:!0,get:function(){return k}}),Object.defineProperty(a,"REST_CLIENT_FACTORY_ID",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(a,"REST_TRANSPORT_ID",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(a,"SANDBOX_EXTENSIONS_ID",{enumerable:!0,get:function(){return er}}),Object.defineProperty(a,"SANDBOX_EXTENSION_SCRIPT_STATUS_ID",{enumerable:!0,get:function(){return tr}}),Object.defineProperty(a,"SECURITY_MODULE_ID",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(a,"SETTINGS_PANEL_EVENT",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(a,"STANDALONE_ACTIVATED_ID",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(a,"STANDALONE_BOOTSTRAP_TOKEN_ID",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(a,"STANDALONE_FILE_PROXY_REGISTERED_ID",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(a,"STANDALONE_PROJECT_ID",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(a,"STORE_ID",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(a,"SYSTEM",{enumerable:!0,get:function(){return Tn}}),Object.defineProperty(a,"Signal",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(a,"TEMPLATE_DIRECTIVES_ID",{enumerable:!0,get:function(){return ur}}),Object.defineProperty(a,"USEBLOCKS",{enumerable:!0,get:function(){return On}}),Object.defineProperty(a,"combineMixins",{enumerable:!0,get:function(){return Pn}}),Object.defineProperty(a,"composeAbortSignals",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(a,"createAbortError",{enumerable:!0,get:function(){return S}}),Object.defineProperty(a,"createIdentifier",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(a,"createIdentifier$1",{enumerable:!0,get:function(){return f}}),Object.defineProperty(a,"createQueue",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(a,"debounce",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(a,"decodeJwt",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(a,"deepEqual",{enumerable:!0,get:function(){return M}}),Object.defineProperty(a,"defineMixin",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(a,"events",{enumerable:!0,get:function(){return z}}),Object.defineProperty(a,"fetchWithApiOriginFailover",{enumerable:!0,get:function(){return it}}),Object.defineProperty(a,"filter",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(a,"findTextDiffBounds",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(a,"generateUUID",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(a,"getActiveBaseUrl",{enumerable:!0,get:function(){return H}}),Object.defineProperty(a,"getApi",{enumerable:!0,get:function(){return mr}}),Object.defineProperty(a,"getContainer",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(a,"getEmitter",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(a,"getEmitter$1",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(a,"getEvent",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(a,"getServiceContainerId",{enumerable:!0,get:function(){return j}}),Object.defineProperty(a,"isAbortError",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(a,"mapHttpStatusToErrorCode",{enumerable:!0,get:function(){return It}}),Object.defineProperty(a,"mergeBackendProxyLayers",{enumerable:!0,get:function(){return Dr}}),Object.defineProperty(a,"mergeResourceProxyLayers",{enumerable:!0,get:function(){return br}}),Object.defineProperty(a,"mergeResourceProxyPolicyLayers",{enumerable:!0,get:function(){return Cr}}),Object.defineProperty(a,"mergeShallowConfigLayers",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(a,"pickKey",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(a,"provideOAuth",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(a,"raceWithAbortSignal",{enumerable:!0,get:function(){return St}}),Object.defineProperty(a,"registerRestTransport",{enumerable:!0,get:function(){return cn}}),Object.defineProperty(a,"releaseContainer",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(a,"resolveContainer",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(a,"resolveExplicitApiBaseUrl",{enumerable:!0,get:function(){return He}}),Object.defineProperty(a,"setApiOriginFailoverHook",{enumerable:!0,get:function(){return tn}}),Object.defineProperty(a,"snapshot",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(a,"textFingerprint",{enumerable:!0,get:function(){return En}}),Object.defineProperty(a,"throwIfAborted",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(a,"waitForElement",{enumerable:!0,get:function(){return at}})});
2097
2097
 
2098
2098
 
2099
2099
  __emailmaker__.define("static/umd/b3ebeaee.js",["require","exports","module"],function(f,l,m){var v=(function(){const e=typeof document<"u"&&document.createElement("link").relList;return e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"})(),k=function(n,e){return new URL(n,e).href},h={},c=function(e,E,P){let p=Promise.resolve();if(0)var R,w;function i(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return p.then(r=>{for(const t of r||[])t.status==="rejected"&&i(t.reason);return e().catch(i)})};Object.defineProperty(l,"__vitePreload",{enumerable:!0,get:function(){return c}})});
2100
2100
 
2101
2101
 
2102
- __emailmaker__.define("emailmaker.js",["require","exports","module","static/umd/790cf6cb.js","static/umd/17c59c44.js","static/umd/b3ebeaee.js"],function(Rt,he,sS){Object.defineProperties(he,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Tn=Rt("./static/umd/790cf6cb.js"),l=Rt("./static/umd/17c59c44.js"),$l=Rt("./static/umd/b3ebeaee.js");var Hl=new Function("url","return import(url)");function Vl(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Cn(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function So(e){return e.type==="umd"||e.resolve==="registry"}var Gl="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function Wl(e){const t=Array.isArray(e)?e[0]:e;return Cn(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Yl(e,t){const n=Wl(e),r=Cn(e)?e:void 0,o=t instanceof Error?t.message:String(t),s=r&&So(r)&&!/compat/iu.test(o)?` ${Gl}`:"",i=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${s}`);return i.cause=t,{name:n,url:r?.url,error:i}}function ql(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}function iS(e){return e}var Kl=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(Cn(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(So(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Hl(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let o;const s=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):ql(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},i=()=>window.removeEventListener("error",s);window.addEventListener("error",s),r.onload=()=>{if(i(),o){n(o);return}t()},r.onerror=()=>{i(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const o=await this._resolveOrSkip(r);if(!o)continue;const s=this._createOrSkip(o.ctor,o.options);s&&!n.has(s)&&(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const i of e){const a=await this._resolveOrSkip(i);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((i,a)=>{t.has(a)||r.push({key:a,plugin:i})});for(let i=r.length-1;i>=0;i--){const{key:a,plugin:c}=r[i];await this._initializingPlugins.get(c),await this._disposePlugin(c,c.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(c),this._resolveMap.delete(c),this._initializingPlugins.delete(c),this._initializedPlugins.delete(c);const d=this._creationOrder.indexOf(c);d>=0&&this._creationOrder.splice(d,1)}const o=[],s=new Set;for(const{ctor:i,options:a}of n){const c=this._createOrSkip(i,a);c&&!s.has(c)&&(s.add(c),o.push(c))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let s,i=!1;const a=()=>{i||(i=!0,s&&clearTimeout(s),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(s=setTimeout(()=>{i||(i=!0,this._pluginRegistry.off(e,a),o(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),o=this._createPluginInstance(e,r),s=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:s}),o.required?.(),this._map.set(n,o),this._creationOrder.push(o),this._setupReadyPromise(o)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Yl(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return Vl(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const o of t){if(this._initializedPlugins.has(o))continue;const s=this._initializingPlugins.get(o);if(s){n.add(s);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const s of r)this._initializingPlugins.set(s,o);n.add(o),o.finally(()=>{for(const s of r)this._initializingPlugins.get(s)===o&&this._initializingPlugins.delete(s)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const o=this._options.openEarlyWindow?.();try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(s){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:s})}finally{o?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(o){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:o})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},zl=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const o of n)try{o.callback(t)}catch{}const r=n.filter(o=>!o.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(o=>(t.ctor=o,t.loading=void 0,this._notifyListeners(e,o),o));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!1};return r.push(o),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!0};return r.push(o),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(o=>o.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Xl=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()}},yo=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 Jl(e,t){return t+e}function Ql(){return typeof performance>"u"?Date.now():Jl(performance.now(),performance.timeOrigin)}var Zl="emailmaker:diagnostics",ec="diagnostics",tc="diagnostics";function wo(e,t){return t?`${e}${e.includes("?")?"&":"?"}${tc}=1`:e}var An;function nc(){try{const e=new URLSearchParams(window.location.search).get(ec);return e===null?void 0:e!=="0"}catch{return}}function rc(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function oc(){try{const e=window.localStorage.getItem(Zl);return e===null?void 0:e==="1"}catch{return}}function rt(){return An===void 0&&(An=typeof window>"u"?!1:nc()??rc()??oc()??!1),An}function sc(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var ce={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"},aS=Object.values(ce),lS=[ce.canvasPainted,ce.canvasSettled,ce.appVisible,ce.editorVisible],ic=5e3,ac=3e3,Io="diagnosticsStore",kt,ot;function To(){return{marks:new yo(ic),resources:new yo(ac)}}function Co(){if(ot)return ot;const e=Dn();return e?(ot=e[Io]??kt??To(),e[Io]=ot,kt=void 0,ot):(kt??=To(),kt)}function te(e,t){rt()&&Co().marks.push({phase:e,at:Ql(),...t})}function Dn(){if(typeof __emailmaker__<"u"&&__emailmaker__)return __emailmaker__;if(typeof window>"u")return;const e=window[sc()];return e!==null&&typeof e=="object"?e:void 0}function lc(e){const t=e.length,n=Co();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function cc(){const e=Dn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:lc(e.diagnosticsBuffer)}var dc="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function we(){const e=new Error(dc);return e.name="DestroyedInstanceError",e}function uc(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Pn(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const s=e,i=t;return s.length===i.length&&s.every((a,c)=>Pn(a,i[c]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&Pn(e[s],t[s]))}function Ao(e,t){const n={watch(r){let o,s=!1;return e.watch(i=>{const a=t(i);s&&Pn(o,a)||(o=a,s=!0,r(a))})},select(r){return Ao(n,r)}};return n}function fe(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(s){t=s,n=!0;for(const i of Array.from(r))i(s)},watch(s){return r.add(s),n&&s(t),{dispose:()=>r.delete(s)}},select(s){return Ao(o,s)}};return o}var fc=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:l.ContentType.UrlEncoded,...t})},Do=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 pc(e){return String(e||"").trim()||void 0}var hc=class extends l.Disposable{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=pc(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)}},On=l.createIdentifier$1("AppInitService");function mc(e){return async()=>{const t=await e();return(await new fc(t).app_init_create({})).data}}function gc(e){e.injectFactory(On,(t,n)=>{if(n)return n;const r=new hc({options:e.getInstance(l.OPTIONS_SOURCE_ID),isStandalone:()=>!!e.getInstance(l.SECURITY_MODULE_ID),resolveRestBaseUrl:o=>o?l.getActiveBaseUrl(o):l.getActiveBaseUrl()||void 0,setRestBaseUrl:o=>{e.getInstance(l.REST_CLIENT_FACTORY_ID)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:mc(()=>e.getInstanceAsync(l.REST_TRANSPORT_ID)),publish:o=>{e.inject(l.APP_ID,o)}});return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var Rn=l.createIdentifier$1("documentSession.emailDocuments");function Ve(e){return e?.getInstance(Rn)}var vc=l.createIdentifier$1("RevisionServiceFlag");function Po(e){return e.getOrCreateInstance(vc,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Oo(e){return Po(e).isEnabled()}var Ec=l.createIdentifier$1("EmailRightsResolver");function _c(e,t){const n=e.getInstance(Ec);return n?n(t):!0}var kn={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Ro=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],ko=2e4,bc=Ro.reduce((e,t)=>e+kn[t],0),No=ko+bc+3e3;function Sc(e){return Ro.reduce((t,n)=>t+Lo(n,e),0)}function Lo(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:kn[e]}function Mo(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:No}function xo(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:ko}function st(e=No){return e+3e3}var cS="[show-pipeline]";function Fo(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}function dS(e,t){}var yc=()=>st();function wc(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function Ic(e){return t=>wc(e.getOrCreateInstance(l.events.BEFORE_SAVE_EMAIL,()=>new l.AsyncEmitter).fire(t),yc())}var De=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},Bo=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[emailmaker] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Nt=class extends Error{timeoutMs;constructor(e,t="handleSaveEmail",n="email"){super(`[emailmaker] ${t} did not respond within ${e}ms — the ${n} was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function le(e){return e.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}var jo=new WeakMap,Nn=new WeakMap;function me(e){return jo.get(e)??0}function Lt(e,t){let n=Nn.get(e);return n||(n=new Set,Nn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Tc(e){jo.set(e,me(e)+1),Nn.get(e)?.forEach(t=>t())}function Ln(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var Cc=l.createIdentifier$1("documentSession.canvasReceipts");function Ac(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const o={guid:n,version:r};return e=o,()=>{e===o&&(e=void 0)}},note(n,r){const o=Ln(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(o,n)}},read(n){if(!e)return;const{scope:r}=t,o={guid:e.guid,rev:e.version()};return r.originId!==null?{...o,changeId:t.changeId,originId:r.originId}:{...o,changeId:r.generation===n?t.changeId:0}}}}function Uo(e){return e.getOrCreateInstance(Cc,Ac)}var Dc=2e3,Pc=l.CANVAS_ECHO_LOST_AFTER_MS+l.CANVAS_ECHO_RECOVERY_WAIT_MS+Dc;function Oc(e,t=Pc){return async()=>{const n=le(e);let r;const o=new Promise(s=>{r=setTimeout(()=>s("silent"),t)});try{const s=Uo(e).read(me(n)),i=await Promise.race([n.sendAsync(l.EVENT_TYPES.SANDBOX_CANVAS_SYNCED,s?{applied:s}:void 0,!1),o]);if(i==="silent"||i&&!i.synced)throw i==="silent"||i?.unsent,new De("canvas-not-synced")}finally{clearTimeout(r)}}}var Rc="em_autosave_pending",uS=6e4;function Mt(e){return`${Rc}_${e}`}function Mn(e,t){try{return sessionStorage.setItem(Mt(e),JSON.stringify(t)),!0}catch{return!1}}function xt(e){try{const t=sessionStorage.getItem(Mt(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Mt(e)),null):n}catch{return null}}function Pe(e){try{sessionStorage.removeItem(Mt(e))}catch{}}function xn(e){return`block:${e}`}function $o(e,t){return t?xn(e):e}function Fn(e,t){(xt(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&Pe(e)}function kc(e){return e!=null&&e!==""}function Ho(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var Vo;function Nc(){return Ho(l.LOCAL_STORAGE_ITEMS.em_revisions_v2)??!0}function Lc(){return Vo??=Nc(),Vo}function Ge(e){return Oo(e)&&Lc()}function Mc(){return!1}var Go;function it(e,t){return Go?.capture(e,t)}function xc(e,t){return Go?.captureMessage(e,t)}var Fc=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Bc=200;function Wo(e=new Set){const t=new Set;return(n,r)=>{if(!Fc.some(([s,i])=>!e.has(s)&&i.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=Bc&&t.clear(),t.add(o))}}function Yo(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Wo()}}var jc=Yo();function Ie(e){return e?.getInstance(l.TEMPLATE_DIRECTIVES_ID)??jc}function Uc(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Ft(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Ee=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} "${Ft(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Ft(this.oldText)}")`:`(replace@${this.oldPosition} "${Ft(this.oldText)}" with "${Ft(this.newText)}")`}};function qo(e,t){return e===null||e.length===0?t:new $c(e,t).compress()}var $c=class ye{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[c,d]=ye._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(c),o=d;continue}if(r.newPosition<o.oldPosition){const[c,d]=ye._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(c),r=d;continue}let i,a;if(o.oldEnd===r.newEnd)i=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[c,d]=ye._splitPrev(r,o.oldLength);i=c,a=o,r=d,o=this._getCurr(++n)}else{const[c,d]=ye._splitCurr(o,r.newLength);i=r,a=c,r=this._getPrev(++t),o=d}this._result[this._resultLen++]=new Ee(i.oldPosition,i.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const s=ye._merge(this._result);return ye._removeNoOps(s)}_acceptCurr(t){this._result[this._resultLen++]=ye._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++]=ye._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 Ee(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Ee(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),o=t.newText.substr(n);return[new Ee(t.oldPosition,t.oldText,t.newPosition,r),new Ee(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new Ee(t.oldPosition,r,t.newPosition,t.newText),new Ee(t.oldPosition+n,o,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,o=t[0];for(let s=1;s<t.length;s++){const i=t[s];o.oldEnd===i.oldPosition?o=new Ee(o.oldPosition,o.oldText+i.oldText,o.newPosition,o.newText+i.newText):(n[r++]=o,o=i)}return n[r++]=o,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let o=0;o<t.length;o++){const s=t[o];s.oldText!==s.newText&&(n[r++]=s)}return n}};function Hc(e){return new Ee(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Vc(e){return e.map(Hc)}function Ko(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Gc(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const o=t[r];n=n.slice(0,o.oldPosition)+o.newText+n.slice(o.oldEnd)}return n}function Wc(e,t,n){let r=0;const o=e.start===e.end;for(const s of t){const i=s.newLength-s.oldLength;if(s.oldLength===0){const a=s.oldPosition;if(o&&a===e.start)r+=n==="after"?i:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=i)}continue}if(o){if(e.start>=s.oldEnd)r+=i;else if(e.start>s.oldPosition)return null;continue}if(e.start>=s.oldEnd)r+=i;else if(e.end>s.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var Oe=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},zo=0,Yc=Math.random().toString(36).slice(2,8);function qc(){return zo+=1,`doc-${Yc}-${zo}`}function Kc(e){const t=e.createBuffer(),n=e.docId??qc();let r=e.serverId??null,o=0,s=null,i=e.attributes??{};const a=new Set;let c=!1,d=!1,u;const p=new Set;let m=null;const h=()=>(m?.version!==o&&(m={version:o,value:t.read()}),m.value),_=S=>Object.entries(S).some(([v,b])=>i[v]!==b);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:s,attributes:i}),getContent:h,mutate(S,{source:v}){if(c)return o;const b=S.changes?.length?S.changes:void 0,D=b?Gc(h(),b):S.content!==void 0?S.content:void 0,j=D!==void 0&&D!==h(),x=S.attributes!==void 0&&_(S.attributes);if(!j&&!x)return o;const C=!(o>(s??-1)),I=x?Object.keys(S.attributes).filter(A=>i[A]!==S.attributes[A]):[];j&&t.write(D),x&&(i={...i,...S.attributes}),o+=1,v!=="user"&&C&&(s=o);const R={source:v,version:o,changes:b,...j?{content:!0}:{},...I.length>0?{attributes:I}:{}};return a.forEach(A=>A(R)),o},markSaved(S,v){const b={serverId:r,savedVersion:s};v!==void 0&&(r=v),(s===null||S>s)&&(s=S),(b.serverId!==r||b.savedVersion!==s)&&a.forEach(D=>D({source:"system",version:o}))},markUnsaved(){c||s===null||s<o||(s=o-1,a.forEach(S=>S({source:"system",version:o})))},markReady(){d||u!==void 0||(d=!0,p.forEach(S=>S.resolve()),p.clear(),a.forEach(S=>S({source:"system",version:o})))},isReady:()=>d,markFailed(S){d||u!==void 0||c||(u=S,p.forEach(v=>v.reject(new Oe(S))),p.clear(),a.forEach(v=>v({source:"system",version:o})))},failure:()=>u,whenReady(){return d?Promise.resolve():u!==void 0?Promise.reject(new Oe(u)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((S,v)=>{p.add({resolve:S,reject:v})})},subscribe(S){return a.add(S),()=>a.delete(S)},isNew:()=>r===null,isDirty:()=>o>(s??-1),isDisposed:()=>c,dispose(){c=!0,p.forEach(S=>S.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),p.clear(),a.clear(),t.dispose()}}}var zc=500,Xc=100,Bn=0;function Xo(e,t){let n=0;for(const r of t){if(r.oldPosition>e||r.oldPosition===e&&r.oldLength>0)break;if(r.oldEnd>e)return r.newEnd;n=r.newEnd-r.oldEnd}return e+n}function Jc(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function Qc(e,t){const n=e?.after;return n?{...e,after:{start:Xo(n.start,t),end:Xo(n.end,t)}}:e}function Zc(e,t={}){const n=t.groupIntervalMs??zc,r=t.maxSteps??Xc,o=t.now??(()=>0);let s=[],i=0,a=Bn+=1,c=null,d,u,p,m=!1,h=!1,_=!1,S=!1;const v=new Set,b=()=>v.forEach(w=>w()),D=(w,P)=>{if(w.length){_=!0;try{e.mutate({changes:w},{source:P})}finally{_=!1}}},j=w=>D(w,"user"),x=w=>{const P=d?.from??o();if(h&&c!==null&&m===(d!==void 0)&&P>=c&&P-c<n){const k=s[i-1];s[i-1]={changes:qo(k.changes,w),selection:Jc(k.selection,u)}}else s=s.slice(0,i),s.push({changes:w,selection:u}),i=s.length,h=!0,s.length>r&&(s=s.slice(s.length-r),i=s.length,a=Bn+=1);c=d?.to??P,m=d!==void 0,b()},C=()=>{h=!1,c=null},I=w=>{if(!w.length)return;const P=s.length>i;if(P&&(s=s.slice(0,i)),i>0){const k=s[i-1];s[i-1]={changes:qo(k.changes,w),selection:Qc(k.selection,w)}}C(),P&&b()},R=e.subscribe(({source:w,changes:P})=>{if(!(S||_||!P?.length)){if(w==="remote"){A();return}if(w!=="user"){I(P);return}x(P)}}),A=()=>{s=[],i=0,C(),a=Bn+=1,b()},O=(w,P)=>{p=P;try{j(w)}finally{p=void 0}},L=(w=!1)=>{if(i===0)return!1;const P=s[i-1],k=Vc(P.changes);return Ko(e.getContent(),k)?(O(k,w?{kind:"undo",selection:P.selection?.before}:void 0),i-=1,C(),!0):(s=s.slice(0,i-1),i=s.length,C(),b(),!1)};return{recordAt(w,P,k){const F=d,E=u;d=w,u=k;try{return P()}finally{d=F,u=E}},activeMove:()=>p,canUndo:()=>i>0,canRedo:()=>i<s.length,undo(){L(!0)&&b(),C()},redo(){if(i>=s.length){C();return}const w=s[i];if(!Ko(e.getContent(),w.changes)){s=s.slice(0,i),C(),b();return}O(w.changes,{kind:"redo",selection:w.selection?.after}),i+=1,C(),b()},clear:A,closeGroup:C,applyWithoutHistory(w){const P=e.get().version;if(D(w,"system"),e.get().version===P){C();return}I(w)},getPast:w=>s.slice(0,i).reverse().slice(0,w).map(P=>P.changes),getFuture:w=>s.slice(i).reverse().slice(0,w).map(P=>P.changes),createSnapshot:()=>({stackId:a,index:i}),restoreSnapshot(w){if(w.stackId!==a||w.index>i)return!1;for(;i>w.index;)if(!L())return b(),!1;return b(),!0},subscribe(w){return v.add(w),()=>v.delete(w)},dispose(){S=!0,R(),v.clear(),s=[],i=0}}}var ed=["edit","move","resize","insert"];function jn(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function td(e){return typeof e=="string"?e:null}function nd(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function rd(e){return ed.includes(e)?e:null}function od(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:td(t.originId),changeId:jn(t.changeId),rev:jn(t.rev),baseRev:jn(t.baseRev),expected:nd(t.expected),intent:rd(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var Jo=new WeakMap,Qo=new WeakMap;function sd(e,t){Qo.set(e,t)}function id(e,t){const n=(Jo.get(e)??Promise.resolve()).then(t,t);return Jo.set(e,n.catch(()=>{})),n}function ad(e,t){return Qo.get(e)?.(t)??id(e,t)}var at=new Map,Zo=new Map;function ld(e){return at.set(e,(at.get(e)??0)+1),()=>{const t=(at.get(e)??1)-1;if(t>0){at.set(e,t);return}at.delete(e);const n=Zo.get(e);Zo.delete(e),n?.forEach(r=>r())}}var Un=e=>e.replace(/\r\n?/g,`
2103
- `),cd=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function $n(e){return typeof e=="string"&&cd.test(e)}var dd=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function ud(){return typeof navigator<"u"&&navigator.onLine===!1}function fd(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const o=r.data;typeof r.data=="object"&&o.error!=null&&t.push(o.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function es(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return es(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function pd(e){return ud()?!0:fd(e).some(es)}var ts=new WeakSet,ns=new WeakMap;function rs(e){typeof e=="object"&&e!==null&&ts.add(e)}function hd(e,t){typeof e=="object"&&e!==null&&ns.set(e,t)}function md(e){return typeof e=="object"&&e!==null?ns.get(e):void 0}function gd(e){return e instanceof Nt||e instanceof Bo||typeof e=="object"&&e!==null&&ts.has(e)}function vd(e){return e instanceof De||os(e)||e instanceof dd||gd(e)}function os(e){return Hn(e)?.v2Error?.data?.code==="blocks.block_locked"}function ss(e){return Hn(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function Hn(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function Ed(e){if(e instanceof De)return e.reason==="canvas-not-synced";if(vd(e))return!1;const t=Hn(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?ss(e):!0}return pd(e)||ss(e)}var is="draft";function We(e){return e==null||e===""?is:String(e)}function Bt(e){return e==null||e===""?`${Vn}${is}`:`${Vn}${String(e)}`}var Vn="block:";function Z(e){return e?.startsWith(Vn)===!0}function Ye(e){return Z(e.sessionKey())?void 0:e.current()}function fS(e,t){}function Re(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return te(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(te(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const s=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw l.isAbortError(o)?(`${e}`,{...n}):(`${e}`,{error:Fo(o),...n},void 0),o})}var pS=5e3,_d=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function bd(e){const t=e?.trim()??"";if(!_d.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function lt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Gn(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Sd(e,t={}){const n=lt((e??[]).filter(r=>r?.html?.trim()));return Gn(n,t)?n:null}function yd(e,t){const n=Date.parse(lt(e)?.modified??""),r=Sd(e),o=Date.parse(r?.modified??""),s=t===void 0||Number.isFinite(o)&&o>t,i=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:s?r:null,...i.length?{latestAt:Math.max(...i)}:{}}}function as(e,t,n){const r=lt((e??[]).filter(c=>c?.html?.trim())),o=Date.parse(r?.modified??""),s=Date.parse(lt((n??[]).filter(c=>c?.html?.trim()))?.modified??""),i=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(s>o),a=[Date.parse(lt(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:i&&Gn(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function wd({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var ls=["recovery","plugin","rest"],Id=["subject","preheader"];function Td(e){let t={},n;for(let o=ls.length-1;o>=0;o--){const s=e.get(ls[o]);s&&(s.attributes&&(t={...t,...s.attributes}),s.content!==void 0&&(n=s.content))}const r=e.get("plugin")?.attributes;for(const o of Id){const s=r?.[o];typeof s=="string"&&s!==""&&(t={...t,[o]:s})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function jt(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Un(t.content):void 0,o=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...o?{changes:[new Ee(0,n,0,r)]}:{}},{source:"remote"})}var Wn=e=>typeof e=="string"?e.trim():"";function Cd(e,t,n,r){const{version:o,attributes:s}=e.get(),i=s,a=r==="snapshot"||r==="anchor",c=a?i.author:void 0,d=a?i.date_gmt:void 0,u=Wn(i.title)||Wn(i.subject)||Wn(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:u,subject:i.subject,preheader:i.preheader,description:i.description,common_styles:i.common_styles||"",meta:i.meta,utm_parameters:i.utm_parameters,parent_email:i.parent_email,is_template:i.is_template||!1,is_inited:i.is_inited,tags:i.tags,emailtags:i.emailtags,group:i.group,projectCategories:i.projectCategories,renderGuid:e.get().docId,project:t.project??i.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...c!=null&&c!==""?{author:c}:{},...d?{excerpt:d}:{}}}}var Ad=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Dd(e){const t={};for(const n of Ad)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Pd(e,t,n,r,o,s){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(o);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,o):t.saveAutosave(r,o,s==null?void 0:{wpId:s})}function be(e,t=!1){const n={};for(const r of Object.keys(e)){let o=e[r];o!==void 0&&!(typeof o=="number"&&Number.isNaN(o))&&(t&&typeof o=="object"&&o!==null&&(o=be(o)),n[r]=o)}return n}function Od(e){return typeof e=="string"&&e.includes("autosave")}var Rd=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function cs(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Rd.has(t))):{}}function qe(e,t,n={}){e&&e.mutate({attributes:kd(e.get().attributes,t)},{source:n.source??"user"})}function kd(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Yn(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Nd(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function ds(e){if(!e)return null;const t=cs(e);return e.common_styles!==void 0&&(t.common_styles=Nd(e.common_styles)),Yn(e.html,t)}function us(e){return e?Yn(e.html,be(cs(e))):null}var Ld=["common_styles","subject","preheader","meta"];function fs(e){if(!e?.html?.trim())return null;const t={};for(const n of Ld)Md(n,e[n])&&(t[n]=e[n]);return Yn(e.html,t)}function Md(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 xd=["modified","lock","wpId","secretHash"];function ps(e){if(!e)return null;const t={};for(const n of xd)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Fd=10,Bd=(e,t)=>e.key===t.key&&jd(e.serverId,t.serverId),jd=(e,t)=>e==null||e===t;function Ud(e){return typeof e?.then=="function"}var hs=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},ms=e=>{e.request.serverId!=null&&!Ut(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},$d=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),Ut=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),gs=(e,t)=>t?.content!==void 0&&wd({hasUnsavedUserEdit:Ut(e)})==="skip",vs=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},Hd=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),Vd=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent(),e.userTouched.clear(),e.document.get().docId))},Gd=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,s])=>e.attributes[o]!==s)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Wd=e=>{const t=Td(e.reports),n=Gd(e.lastMerged,t);e.lastMerged=t,e.broughtContent=$t(t.content)??e.broughtContent,n&&(jt(e.document,n),ms(e))},qn=(e,t)=>{if(!e.ready&&!Ut(e)){Wd(e);return}e.broughtContent=$t(t?.content)??e.broughtContent,jt(e.document,t)},$t=e=>e===void 0?void 0:Un(e),Yd=(e,t)=>t.content===void 0||$t(t.content)!==e.broughtContent||!Ut(e)?t:{...t,content:void 0},qd=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 Kd(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:s,canEdit:i,notifyBeforeSave:a,awaitCanvasSynced:c,savedEchoForm:d=f=>f,queuesOutsideWrites:u,onAdapterError:p,onTimeout:m}=e;let h,_;const S=new Set,v=new Set,b=()=>S.forEach(f=>f()),D=(f,g)=>{if(!(f.closed||f.ready)){if(f.error!==void 0){f.document.markFailed(f.error),f.document.get().docId;return}ms(f),f.ready=!0,f.document.markReady(),f.document.get().docId,[...f.reports.keys()]}},j=(f,g,T)=>{p?.(g.id,T),!(!g.required||f.closed)&&(f.error=T,f.document.get().docId,g.id,b())},x=(f,g)=>{const T=new Set(g.map(V=>V.id));g.forEach(V=>{V.watch&&f.watchers.push(V.watch(G=>f.closed?!1:f.ready&&(gs(f,G)||f.contentShown===!0&&G?.content!==void 0)?(f.document.get().docId,V.id,!1):(G&&f.reports.set(V.id,G),qn(f,G),G?.content!==void 0&&(f.showFill=void 0),!0)))});const M=(V,G)=>{if(!f.closed){if(!V.required&&gs(f,G)){f.document.get().docId,V.id,V.loaded?.(!1);return}G&&(f.reports.set(V.id,G),V.id==="plugin"&&vs(f,G)),qn(f,G),V.loaded?.(G!==null)}},$=()=>{T.size>0||f.closed||(hs(f),D(f,[]))},Y=[];if(g.forEach(V=>{let G;try{G=V.load()}catch(Q){j(f,V,Q),T.delete(V.id);return}if(Ud(G)){Y.push({id:V.id,required:V.required,load:()=>G,...V.loaded?{loaded:Q=>V.loaded?.(Q)}:{}});return}M(V,G),T.delete(V.id)}),Y.length===0){$();return}f.timer=setTimeout(()=>{f.timer=void 0,m?.([...T]),f.document.get().docId,[...T],D(f,[...T])},n),f.timer.unref?.(),Y.forEach(V=>{V.load().then(G=>M(V,G)).catch(G=>{j(f,V,G)}).finally(()=>{T.delete(V.id),$()})})},C=async(f,g,T)=>{if(T==="snapshot"||T==="anchor")return;const M=s?.();if(M)return M.resolve({project:g.project??f.project,tags:(f.tags??[]).map($=>({name:$}))})},I=f=>{if(f.lock===!0&&i?.(f)===!1)return new De("locked");const g=f.tags?.length??0,T=f.emailtags?.length??0;if(Math.max(g,T)>Fd)return new De("too-many-tags")},R=(f,g)=>{const T=f.document.get().serverId;T!=null&&(f.createKey=void 0),!(g||T==null)&&(f.recoveryFacts={emailId:T,historyLoaded:!0,isRecovering:!1},Z(f.request.key)||(f.request={...f.request,key:We(T),serverId:T}))},A=(f,g,T)=>{if(f.closed||T?.id==null)return;const M=f.document.get().serverId,$=M!=null;$&&M!==String(T.id)||(f.document.markSaved(g,String(T.id)),R(f,$),f.document.get().serverId,b())},O=(f,g,T)=>{if(!(g==="materialize"||g==="publish"&&f.document.get().serverId==null))return T;const M=f.createKey,$=M&&M.project===T.project?M:{key:l.generateUUID(),project:T.project};return f.createKey=$,{...T,idempotencyKey:$.key}},L=async(f,g,T)=>{try{await f.document.whenReady()}catch(Q){return f.saveError=Q,f.saveFailures+=1,f.failedIntent=g,f.saveFailures,!1}if(f.closed)return!1;const M=I(f.document.get().attributes);if(M)return f.saveError=M,f.saveFailures+=1,f.failedIntent=g,M.reason,b(),!1;if(a&&(await a(qd(f)).catch(()=>{}),f.closed))return!1;if(c){try{await c()}catch(Q){return f.saveError=Q,f.saveFailures+=1,f.failedIntent=g,f.saveFailures,b(),!1}if(f.closed)return!1}if($d(f))return g==="snapshot"||(f.saveError=new De("empty-content"),f.saveFailures+=1,f.failedIntent=g,b()),!1;let $;try{$=await C(f.document.get().attributes,T,g)}catch(Q){return f.saveError=Q,f.saveFailures+=1,f.failedIntent=g,f.saveFailures,b(),!1}if(f.closed)return!1;const{payload:Y,version:V}=Cd(f.document,T,$,g),G=O(f,g,Y);f.document.get().docId;try{const Q=f.document.get().serverId!=null,N=await Pd(r(),o(f.request.key),g,f.document.get().serverId,G,f.document.get().attributes.wpId);if(f.closed)return!0;let z;if(g==="snapshot"||g==="anchor"){const ee=N?.modified!=null?Date.parse(N.modified):NaN;z=Number.isFinite(ee)?ee:Date.now(),f.snapshotVersion=V,f.lastRevisionAt=z}else{f.document.markSaved(V,N?.id!=null?String(N.id):void 0),f.savedContent=G.html;const ee=N;jt(f.document,ps(ee&&{wpId:ee.wpId,secretHash:ee.secretHash})),f.broughtContent=$t(d(G.html))}R(f,Q),f.saveError=void 0,f.saveFailures=0,f.failedIntent=void 0,f.document.get().serverId,b();const X={intent:g,serverId:f.document.get().serverId,created:!Q,...z!==void 0?{revisionAt:z}:{}};return v.forEach(ee=>ee(X)),!0}catch(Q){return(g==="publish"||g==="materialize")&&md(Q)?.then(N=>A(f,V,N)),f.saveError=Q,f.saveFailures+=1,f.failedIntent=g,f.saveFailures,b(),!1}},w=f=>{f.closed=!0,f.watchers.forEach(g=>g()),f.watchers=[],hs(f),f.history.dispose(),f.document.dispose()},P=()=>{h&&(w(h),h=void 0)},k=()=>{_&&(w(_),_=void 0)},F=(f,g,T)=>{let M=!1;g.show&&(f.show?.id!==g.show.id||f.show.token!==g.show.token)&&(f.show=g.show,M=!0,{docId:f.document.get().docId,...g.show});const $=T==="show"?us(g.patch):null;if($){f.reports.set("plugin",$),vs(f,$);const Y=Yd(f,$);qn(f,Y),Vd(f,Y)}M&&b()},E=(f,g={})=>U(h,f,g),y=()=>h&&Z(h.request.key??"")?_:h,B=f=>({error:f?.saveError,failures:f?.saveFailures??0,saving:f?.saving===!0,failedIntent:f?.failedIntent}),U=(f,g,T)=>!f||f.closed||g==="materialize"&&f.document.get().serverId!=null?Promise.resolve(!1):f.saving?g==="snapshot"||g==="materialize"?Promise.resolve(!1):(f.inFlight??Promise.resolve(!1)).then(()=>U(f,g,T)):(f.saving=!0,b(),f.inFlight=L(f,g,T).finally(()=>W(f)),f.inFlight),W=f=>{f.saving=!1,f.inFlight=void 0,h===f&&!f.closed&&b()},ie=(f,g)=>{if(f.closed)return g();if(f.saving)return(f.inFlight??Promise.resolve(!1)).then(()=>ie(f,g));f.saving=!0,b();const T=Promise.resolve().then(g);return f.inFlight=T.then(()=>!0,()=>!1).finally(()=>W(f)),T},re=(f,g)=>{const T=f.document.get().serverId,M=T==null?void 0:ld(T);return ie(f,g).finally(M)},q=(f,g="open",T=!1)=>{if(h&&!h.closed&&g!=="new"&&Bd(h.request,f))return F(h,f,g),h.document;P(),T||k();const M=Kc({createBuffer:()=>Uc(""),serverId:f.serverId??null}),$={request:f,show:f.show,document:M,history:Zc(M,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return h=$,sd(M,Y=>u?.($.request.key)===!0?re($,Y):void 0),$.watchers.push(Hd($)),M.get().docId,f.serverId,x($,t(f,{publishRecoveryFacts(Y){$.closed||($.recoveryFacts=Y,b())},readShownContent:()=>$.closed?null:$.document.getContent(),readWpId:()=>$.closed?void 0:$.document.get().attributes.wpId})),b(),M},K=(f,g,T)=>({key:Z(f)?f:Bt(f),serverId:g?.id!=null?String(g.id):null,email:g,show:T});return{openWith:q,open:(f,g={})=>q({key:We(f),serverId:f,email:g.email,patch:g.patch,show:g.show},"open"),openDraft:(f,g={})=>q({key:We(void 0),serverId:null,email:f,patch:g.patch,show:g.show},"open"),startNewDraft:(f,g={})=>q({key:We(void 0),serverId:null,email:f,patch:g.patch,show:g.show},"new"),reload:(f,g={})=>q({key:We(f),serverId:f,email:g.email,patch:g.patch,show:g.show},"new"),openBlock:(f,g,T)=>q(K(f,g,T),"open"),reloadBlock:(f,g,T)=>q(K(f,g,T),"new"),openBlockOver:(f,g)=>{const T=K(f,g);return h&&!h.closed&&h.request.key===T.key?h.document:(h&&!h.closed&&!Z(h.request.key)&&(k(),_=h,h=void 0),q(T,"open",!0))},resumeSuspended:()=>{if(_)return P(),h=_,_=void 0,b(),h.document},hasSuspended:()=>!!_,suspendedDocument:()=>_?.document,show:(f,g)=>{const T=h;if(!(!T||T.closed))return q({...T.request,patch:f,show:g},"show")},current:()=>h?.document,noteServerFacts:({serverId:f,block:g},T)=>{const M=h;!M||M.closed||M.request.serverId!==f||Z(M.request.key??"")===g&&jt(M.document,ps(T))},save:E,saveEmail:(f,g={})=>U(y(),f,g),saveState:()=>B(h),emailSaveState:()=>B(y()),revisionFacts(){if(!h)return;const f=h.revisionFactsSnapshot;return f&&f.snapshotVersion===h.snapshotVersion&&f.lastRevisionAt===h.lastRevisionAt?f:(h.revisionFactsSnapshot={snapshotVersion:h.snapshotVersion,lastRevisionAt:h.lastRevisionAt},h.revisionFactsSnapshot)},recoveryFacts:()=>h?.recoveryFacts,history:()=>h?.history,forcedHeaders:()=>h?.forcedHeaders,beginForcedHeaders(f){h&&!h.closed&&(h.forcedHeaders=f)},endForcedHeaders(){for(const f of[h,_])f&&(f.forcedHeaders=void 0)},onSaved(f){return v.add(f),()=>v.delete(f)},showFacts:()=>h?.show,shownHeaders:()=>({...h?.shownHeaders}),showFill:()=>h?.showFill,beginShowFill(f){h&&!h.closed&&(h.showFill={showId:f,codeEdits:0})},noteCodeEdit(){h?.showFill&&(h.showFill.codeEdits+=1)},endShowFill(f){for(const g of[h,_])g?.showFill?.showId===f&&(g.showFill=void 0)},sessionKey:()=>h?.request.key,openError:()=>h?.error,subscribe(f){return S.add(f),()=>S.delete(f)},close(){!h&&!_||(P(),k(),b())}}}var Kn=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function zn(e){if(e instanceof Kn)return e.reason;if(e instanceof Oe)return zn(e.reason)}function zd(e){const t=e instanceof Oe?e.reason:e;return t instanceof Kn&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Xd(e){const t=zn(e);return t!==void 0&&t!=="unavailable"}function Jd(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Kn("not-found");return ds(n)}}}var Es=l.createIdentifier$1("EmailPort");function Qd(e){return e.getInstance(Es)}function Zd(e,t){e.inject(Es,t)}var _s=l.createIdentifier$1("documentSession.restEmailPortFactories");function bs(e){return e.getInstance(_s)!==void 0}function ke(e){const t=e.getInstance(_s);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var eu=l.createIdentifier$1("EmailTermsResolver");function tu(e){return e.getInstance(eu)}var Ss=l.createIdentifier$1("EmailHistoryPort"),nu=l.createIdentifier$1("BlockHistoryPort");function ys(e){return e.getInstance(nu)}function ws(e){return e.getInstance(Ss)}function ru(e,t){e.inject(Ss,t)}var ou=2e3,su=5e3,iu=5,au=5e3,lu=4;function cu(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Ht(e,t){return e==null||t==null?!1:e.replaceAll(`\r
2102
+ __emailmaker__.define("emailmaker.js",["require","exports","module","static/umd/790cf6cb.js","static/umd/de747b3f.js","static/umd/b3ebeaee.js"],function(Ut,he,ow){Object.defineProperties(he,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Gn=Ut("./static/umd/790cf6cb.js"),c=Ut("./static/umd/de747b3f.js"),jl=Ut("./static/umd/b3ebeaee.js");var Ul=new Function("url","return import(url)");function $l(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Wn(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Ys(e){return e.type==="umd"||e.resolve==="registry"}var Vl="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function Hl(e){const t=Array.isArray(e)?e[0]:e;return Wn(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Gl(e,t){const n=Hl(e),r=Wn(e)?e:void 0,s=t instanceof Error?t.message:String(t),o=r&&Ys(r)&&!/compat/iu.test(s)?` ${Vl}`:"",i=new Error(`Plugin "${n}" was skipped: it failed to load. ${s}${o}`);return i.cause=t,{name:n,url:r?.url,error:i}}function Wl(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}function iw(e){return e}var Yl=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(Wn(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(Ys(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Ul(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let s;const o=a=>{s||(a.filename===r.src?s=this._scriptExecutionError(e,a.error??a.message):Wl(a)&&(s=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},i=()=>window.removeEventListener("error",o);window.addEventListener("error",o),r.onload=()=>{if(i(),s){n(s);return}t()},r.onerror=()=>{i(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const s=await this._resolveOrSkip(r);if(!s)continue;const o=this._createOrSkip(s.ctor,s.options);o&&!n.has(o)&&(n.add(o),t.push(o))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const i of e){const a=await this._resolveOrSkip(i);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((i,a)=>{t.has(a)||r.push({key:a,plugin:i})});for(let i=r.length-1;i>=0;i--){const{key:a,plugin:l}=r[i];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const d=this._creationOrder.indexOf(l);d>=0&&this._creationOrder.splice(d,1)}const s=[],o=new Set;for(const{ctor:i,options:a}of n){const l=this._createOrSkip(i,a);l&&!o.has(l)&&(o.add(l),s.push(l))}this._activated&&await this._startPluginsBatch(s)}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,s)=>{let o,i=!1;const a=()=>{i||(i=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(o=setTimeout(()=>{i||(i=!0,this._pluginRegistry.off(e,a),s(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),s=this._createPluginInstance(e,r),o=s.constructor.name;this._emitLifecycle({type:"created",plugin:s,name:o}),s.required?.(),this._map.set(n,s),this._creationOrder.push(s),this._setupReadyPromise(s)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Gl(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return $l(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const s of t){if(this._initializedPlugins.has(s))continue;const o=this._initializingPlugins.get(s);if(o){n.add(o);continue}r.push(s)}if(r.length>0){const s=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,s);n.add(s),s.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===s&&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});const s=this._options.openEarlyWindow?.();try{await this._callSync(n,r,"init"),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(o){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:o})}finally{s?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await this._callSync(n,r,"afterInit"),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(s){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:s})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}_callSync(e,t,n){this._emitLifecycle({type:`${n}:enter`,plugin:e,name:t});try{return e[n]?.()}finally{this._emitLifecycle({type:`${n}:leave`,plugin:e,name:t})}}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},ql=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 s of n)try{s.callback(t)}catch{}const r=n.filter(s=>!s.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(s=>(t.ctor=s,t.loading=void 0,this._notifyListeners(e,s),s));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 s={callback:t,once:!1};return r.push(s),{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 s={callback:t,once:!0};return r.push(s),{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(s=>s.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)}}}},Kl=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()}},qs=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 zl(e,t){return t+e}function Xl(){return typeof performance>"u"?Date.now():zl(performance.now(),performance.timeOrigin)}var Jl="emailmaker:diagnostics",Ql="diagnostics",Zl="diagnostics";function Ks(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Zl}=1`:e}var Yn;function ed(){try{const e=new URLSearchParams(window.location.search).get(Ql);return e===null?void 0:e!=="0"}catch{return}}function td(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function nd(){try{const e=window.localStorage.getItem(Jl);return e===null?void 0:e==="1"}catch{return}}function dt(){return Yn===void 0&&(Yn=typeof window>"u"?!1:ed()??td()??nd()??!1),Yn}function rd(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var de={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"},aw=Object.values(de),cw=[de.canvasPainted,de.canvasSettled,de.appVisible,de.editorVisible],sd=5e3,od=3e3,zs="diagnosticsStore",$t,ut;function Xs(){return{marks:new qs(sd),resources:new qs(od)}}function Js(){if(ut)return ut;const e=qn();return e?(ut=e[zs]??$t??Xs(),e[zs]=ut,$t=void 0,ut):($t??=Xs(),$t)}function te(e,t){dt()&&Js().marks.push({phase:e,at:Xl(),...t})}function qn(){if(typeof __emailmaker__<"u"&&__emailmaker__)return __emailmaker__;if(typeof window>"u")return;const e=window[rd()];return e!==null&&typeof e=="object"?e:void 0}function id(e){const t=e.length,n=Js();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function ad(){const e=qn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:id(e.diagnosticsBuffer)}var cd="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Ae(){const e=new Error(cd);return e.name="DestroyedInstanceError",e}function ld(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Kn(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,i=t;return o.length===i.length&&o.every((a,l)=>Kn(a,i[l]))}const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&Kn(e[o],t[o]))}function Qs(e,t){const n={watch(r){let s,o=!1;return e.watch(i=>{const a=t(i);o&&Kn(s,a)||(s=a,o=!0,r(a))})},select(r){return Qs(n,r)}};return n}function ie(...e){let t=e[0],n=e.length>0;const r=new Set,s={get(){return n?t:void 0},set(o){t=o,n=!0;for(const i of Array.from(r))i(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return Qs(s,o)}};return s}var dd=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:c.ContentType.UrlEncoded,...t})},Zs=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 ud(e){return String(e||"").trim()||void 0}var fd=class extends c.Disposable{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=ud(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)}},zn=c.createIdentifier$1("AppInitService");function pd(e){return async()=>{const t=await e();return(await new dd(t).app_init_create({})).data}}function hd(e){e.injectFactory(zn,(t,n)=>{if(n)return n;const r=new fd({options:e.getInstance(c.OPTIONS_SOURCE_ID),isStandalone:()=>!!e.getInstance(c.SECURITY_MODULE_ID),resolveRestBaseUrl:s=>s?c.getActiveBaseUrl(s):c.getActiveBaseUrl()||void 0,setRestBaseUrl:s=>{e.getInstance(c.REST_CLIENT_FACTORY_ID)?.setOptions(s?{baseUrl:s}:{})},fallbackAppInit:pd(()=>e.getInstanceAsync(c.REST_TRANSPORT_ID)),publish:s=>{e.inject(c.APP_ID,s)}});return e.getInstance(c.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var Vt=c.createIdentifier$1("documentSession.emailDocuments");function Ke(e){return e?.getInstance(Vt)}var md=c.createIdentifier$1("RevisionServiceFlag");function eo(e){return e.getOrCreateInstance(md,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function to(e){return eo(e).isEnabled()}var no=c.createIdentifier$1("EmailRightsResolver");function gd(e,t){return e.onInject(n=>{n===no&&t()})}function ro(e,t){const n=e.getInstance(no);return n?n(t):!0}var Xn={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},so=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],oo=2e4,vd=so.reduce((e,t)=>e+Xn[t],0),io=oo+vd+3e3;function Ed(e){return so.reduce((t,n)=>t+ao(n,e),0)}function ao(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:Xn[e]}function co(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:io}function lo(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:oo}function ft(e=io){return e+3e3}var lw="[show-pipeline]";function uo(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}function dw(e,t){}var _d=()=>ft();function bd(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function yd(e){return t=>bd(e.getOrCreateInstance(c.events.BEFORE_SAVE_EMAIL,()=>new c.AsyncEmitter).fire(t),_d())}var fo=Symbol.for("emailmaker.saveRefusedError"),po=Symbol.for("emailmaker.integratorSaveTimeoutError");function ho(e,t,n,r){return e!==t?Function.prototype[Symbol.hasInstance].call(e,r):typeof r=="object"&&r!==null&&n in r}var Oe=class xl extends Error{reason;static[Symbol.hasInstance](t){return ho(this,xl,fo,t)}constructor(t){super(`[emailmaker] save refused: ${t}`),this.name="SaveRefusedError",this.reason=t,Object.defineProperty(this,fo,{value:!0})}},mo=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[emailmaker] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Ht=class Fl extends Error{timeoutMs;static[Symbol.hasInstance](t){return ho(this,Fl,po,t)}constructor(t,n="handleSaveEmail",r="email"){super(`[emailmaker] ${n} did not respond within ${t}ms — the ${r} was not saved`),this.timeoutMs=t,this.name="IntegratorSaveTimeoutError",Object.defineProperty(this,po,{value:!0})}};function le(e){return e.getOrCreateInstance(c.MESSAGE_SERVICE_ID,()=>new c.MessageService)}var go=new WeakMap,Jn=new WeakMap;function me(e){return go.get(e)??0}function Gt(e,t){let n=Jn.get(e);return n||(n=new Set,Jn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Sd(e){go.set(e,me(e)+1),Jn.get(e)?.forEach(t=>t())}function Qn(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var wd=c.createIdentifier$1("documentSession.canvasReceipts");function Id(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const s={guid:n,version:r};return e=s,()=>{e===s&&(e=void 0)}},note(n,r){const s=Qn(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(s,n)}},read(n){if(!e)return;const{scope:r}=t,s={guid:e.guid,rev:e.version()};return r.originId!==null?{...s,changeId:t.changeId,originId:r.originId}:{...s,changeId:r.generation===n?t.changeId:0}}}}function vo(e){return e.getOrCreateInstance(wd,Id)}var Td=2e3,Cd=c.CANVAS_ECHO_LOST_AFTER_MS+c.CANVAS_ECHO_RECOVERY_WAIT_MS+Td;function Ad(e,t=Cd){return async()=>{const n=le(e);let r;const s=new Promise(o=>{r=setTimeout(()=>o("silent"),t)});try{const o=vo(e).read(me(n)),i=await Promise.race([n.sendAsync(c.EVENT_TYPES.SANDBOX_CANVAS_SYNCED,o?{applied:o}:void 0,!1),s]);if(i==="silent"||i&&!i.synced)throw i==="silent"||i?.unsent,new Oe("canvas-not-synced")}finally{clearTimeout(r)}}}var Od="em_autosave_pending",uw=6e4;function Wt(e){return`${Od}_${e}`}function Zn(e,t){try{return sessionStorage.setItem(Wt(e),JSON.stringify(t)),!0}catch{return!1}}function Yt(e){try{const t=sessionStorage.getItem(Wt(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Wt(e)),null):n}catch{return null}}function Ne(e){try{sessionStorage.removeItem(Wt(e))}catch{}}function er(e){return`block:${e}`}function Eo(e,t){return t?er(e):e}function tr(e,t){(Yt(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&Ne(e)}function Dd(e){return e!=null&&e!==""}function _o(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var bo;function Pd(){return _o(c.LOCAL_STORAGE_ITEMS.em_revisions_v2)??!0}function Rd(){return bo??=Pd(),bo}function ze(e){return to(e)&&Rd()}function kd(){return!1}var yo;function pt(e,t){return yo?.capture(e,t)}function Nd(e,t){return yo?.captureMessage(e,t)}var Ld=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Md=200;function So(e=new Set){const t=new Set;return(n,r)=>{if(!Ld.some(([o,i])=>!e.has(o)&&i.test(n)))return;const s=r??`new:${n.length}:${n.slice(0,200)}`;t.has(s)||(t.size>=Md&&t.clear(),t.add(s))}}function wo(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:So()}}var xd=wo();function De(e){return e?.getInstance(c.TEMPLATE_DIRECTIVES_ID)??xd}function Fd(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function qt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var _e=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} "${qt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${qt(this.oldText)}")`:`(replace@${this.oldPosition} "${qt(this.oldText)}" with "${qt(this.newText)}")`}};function Io(e,t){return e===null||e.length===0?t:new Bd(e,t).compress()}var Bd=class Ce{_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),s=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(s===null)break;this._acceptCurr(s),s=this._getCurr(++n);continue}if(s===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(s.oldEnd<=r.newPosition){this._acceptCurr(s),s=this._getCurr(++n);continue}if(r.newEnd<=s.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(s.oldPosition<r.newPosition){const[l,d]=Ce._splitCurr(s,r.newPosition-s.oldPosition);this._acceptCurr(l),s=d;continue}if(r.newPosition<s.oldPosition){const[l,d]=Ce._splitPrev(r,s.oldPosition-r.newPosition);this._acceptPrev(l),r=d;continue}let i,a;if(s.oldEnd===r.newEnd)i=r,a=s,r=this._getPrev(++t),s=this._getCurr(++n);else if(s.oldEnd<r.newEnd){const[l,d]=Ce._splitPrev(r,s.oldLength);i=l,a=s,r=d,s=this._getCurr(++n)}else{const[l,d]=Ce._splitCurr(s,r.newLength);i=r,a=l,r=this._getPrev(++t),s=d}this._result[this._resultLen++]=new _e(i.oldPosition,i.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const o=Ce._merge(this._result);return Ce._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=Ce._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++]=Ce._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 _e(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new _e(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),s=t.newText.substr(n);return[new _e(t.oldPosition,t.oldText,t.newPosition,r),new _e(t.oldEnd,"",t.newPosition+n,s)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),s=t.oldText.substr(n);return[new _e(t.oldPosition,r,t.newPosition,t.newText),new _e(t.oldPosition+n,s,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,s=t[0];for(let o=1;o<t.length;o++){const i=t[o];s.oldEnd===i.oldPosition?s=new _e(s.oldPosition,s.oldText+i.oldText,s.newPosition,s.newText+i.newText):(n[r++]=s,s=i)}return n[r++]=s,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let s=0;s<t.length;s++){const o=t[s];o.oldText!==o.newText&&(n[r++]=o)}return n}};function jd(e){return new _e(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Ud(e){return e.map(jd)}function To(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function $d(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const s=t[r];n=n.slice(0,s.oldPosition)+s.newText+n.slice(s.oldEnd)}return n}function Vd(e,t,n){let r=0;const s=e.start===e.end;for(const o of t){const i=o.newLength-o.oldLength;if(o.oldLength===0){const a=o.oldPosition;if(s&&a===e.start)r+=n==="after"?i:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=i)}continue}if(s){if(e.start>=o.oldEnd)r+=i;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=i;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var Le=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Co=0,Hd=Math.random().toString(36).slice(2,8);function Gd(){return Co+=1,`doc-${Hd}-${Co}`}function Wd(e){const t=e.createBuffer(),n=e.docId??Gd();let r=e.serverId??null,s=0,o=null,i=e.attributes??{};const a=new Set;let l=!1,d=!1,u;const p=new Set;let h=null;const m=()=>(h?.version!==s&&(h={version:s,value:t.read()}),h.value),_=y=>Object.entries(y).some(([v,b])=>i[v]!==b);return{get:()=>({docId:n,serverId:r,version:s,savedVersion:o,attributes:i}),getContent:m,mutate(y,{source:v}){if(l)return s;const b=y.changes?.length?y.changes:void 0,O=b?$d(m(),b):y.content!==void 0?y.content:void 0,j=O!==void 0&&O!==m(),x=y.attributes!==void 0&&_(y.attributes);if(!j&&!x)return s;const C=!(s>(o??-1)),I=x?Object.keys(y.attributes).filter(A=>i[A]!==y.attributes[A]):[];j&&t.write(O),x&&(i={...i,...y.attributes}),s+=1,v!=="user"&&C&&(o=s);const R={source:v,version:s,changes:b,...j?{content:!0}:{},...I.length>0?{attributes:I}:{}};return a.forEach(A=>A(R)),s},markSaved(y,v){const b={serverId:r,savedVersion:o};v!==void 0&&(r=v),(o===null||y>o)&&(o=y),(b.serverId!==r||b.savedVersion!==o)&&a.forEach(O=>O({source:"system",version:s}))},markUnsaved(){l||o===null||o<s||(o=s-1,a.forEach(y=>y({source:"system",version:s})))},markReady(){d||u!==void 0||(d=!0,p.forEach(y=>y.resolve()),p.clear(),a.forEach(y=>y({source:"system",version:s})))},isReady:()=>d,markFailed(y){d||u!==void 0||l||(u=y,p.forEach(v=>v.reject(new Le(y))),p.clear(),a.forEach(v=>v({source:"system",version:s})))},failure:()=>u,whenReady(){return d?Promise.resolve():u!==void 0?Promise.reject(new Le(u)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((y,v)=>{p.add({resolve:y,reject:v})})},subscribe(y){return a.add(y),()=>a.delete(y)},isNew:()=>r===null,isDirty:()=>s>(o??-1),isDisposed:()=>l,dispose(){l=!0,p.forEach(y=>y.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),p.clear(),a.clear(),t.dispose()}}}var Yd=500,qd=100,nr=0;function Ao(e,t){let n=0;for(const r of t){if(r.oldPosition>e||r.oldPosition===e&&r.oldLength>0)break;if(r.oldEnd>e)return r.newEnd;n=r.newEnd-r.oldEnd}return e+n}function Kd(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function zd(e,t){const n=e?.after;return n?{...e,after:{start:Ao(n.start,t),end:Ao(n.end,t)}}:e}function Xd(e,t={}){const n=t.groupIntervalMs??Yd,r=t.maxSteps??qd,s=t.now??(()=>0);let o=[],i=0,a=nr+=1,l=null,d,u,p,h=!1,m=!1,_=!1,y=!1;const v=new Set,b=()=>v.forEach(S=>S()),O=(S,D)=>{if(S.length){_=!0;try{e.mutate({changes:S},{source:D})}finally{_=!1}}},j=S=>O(S,"user"),x=S=>{const D=d?.from??s();if(m&&l!==null&&h===(d!==void 0)&&D>=l&&D-l<n){const k=o[i-1];o[i-1]={changes:Io(k.changes,S),selection:Kd(k.selection,u)}}else o=o.slice(0,i),o.push({changes:S,selection:u}),i=o.length,m=!0,o.length>r&&(o=o.slice(o.length-r),i=o.length,a=nr+=1);l=d?.to??D,h=d!==void 0,b()},C=()=>{m=!1,l=null},I=S=>{if(!S.length)return;const D=o.length>i;if(D&&(o=o.slice(0,i)),i>0){const k=o[i-1];o[i-1]={changes:Io(k.changes,S),selection:zd(k.selection,S)}}C(),D&&b()},R=e.subscribe(({source:S,changes:D})=>{if(!(y||_||!D?.length)){if(S==="remote"){A();return}if(S!=="user"){I(D);return}x(D)}}),A=()=>{o=[],i=0,C(),a=nr+=1,b()},P=(S,D)=>{p=D;try{j(S)}finally{p=void 0}},L=(S=!1)=>{if(i===0)return!1;const D=o[i-1],k=Ud(D.changes);return To(e.getContent(),k)?(P(k,S?{kind:"undo",selection:D.selection?.before}:void 0),i-=1,C(),!0):(o=o.slice(0,i-1),i=o.length,C(),b(),!1)};return{recordAt(S,D,k){const F=d,E=u;d=S,u=k;try{return D()}finally{d=F,u=E}},activeMove:()=>p,canUndo:()=>i>0,canRedo:()=>i<o.length,undo(){L(!0)&&b(),C()},redo(){if(i>=o.length){C();return}const S=o[i];if(!To(e.getContent(),S.changes)){o=o.slice(0,i),C(),b();return}P(S.changes,{kind:"redo",selection:S.selection?.after}),i+=1,C(),b()},clear:A,closeGroup:C,applyWithoutHistory(S){const D=e.get().version;if(O(S,"system"),e.get().version===D){C();return}I(S)},getPast:S=>o.slice(0,i).reverse().slice(0,S).map(D=>D.changes),getFuture:S=>o.slice(i).reverse().slice(0,S).map(D=>D.changes),createSnapshot:()=>({stackId:a,index:i}),restoreSnapshot(S){if(S.stackId!==a||S.index>i)return!1;for(;i>S.index;)if(!L())return b(),!1;return b(),!0},subscribe(S){return v.add(S),()=>v.delete(S)},dispose(){y=!0,R(),v.clear(),o=[],i=0}}}var Jd=["edit","move","resize","insert"];function rr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Qd(e){return typeof e=="string"?e:null}function Zd(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function eu(e){return Jd.includes(e)?e:null}function tu(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Qd(t.originId),changeId:rr(t.changeId),rev:rr(t.rev),baseRev:rr(t.baseRev),expected:Zd(t.expected),intent:eu(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var Oo=Symbol.for("emailmaker.blockSaveFlight"),Do=Symbol.for("emailmaker.blockSaveSessionQueue"),sr=new WeakMap;function Po(e,t){return Object.isExtensible(e)||t in e?e[t]:sr.get(e)?.get(t)}function Ro(e,t,n){if(t in e||Object.isExtensible(e)){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return}const r=sr.get(e)??new Map;r.set(t,n),sr.set(e,r)}function nu(e,t){Ro(e,Do,t)}function ru(e,t){const n=(Po(e,Oo)??Promise.resolve()).then(t,t);return Ro(e,Oo,n.catch(()=>{})),n}function su(e,t){return Po(e,Do)?.(t)??ru(e,t)}var ht=new Map,ko=new Map;function ou(e){return ht.set(e,(ht.get(e)??0)+1),()=>{const t=(ht.get(e)??1)-1;if(t>0){ht.set(e,t);return}ht.delete(e);const n=ko.get(e);ko.delete(e),n?.forEach(r=>r())}}var or=e=>e.replace(/\r\n?/g,`
2103
+ `),iu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function ir(e){return typeof e=="string"&&iu.test(e)}var au=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function cu(){return typeof navigator<"u"&&navigator.onLine===!1}function lu(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const s=r.data;typeof r.data=="object"&&s.error!=null&&t.push(s.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function No(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return No(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function du(e){return cu()?!0:lu(e).some(No)}var Lo=new WeakSet,Mo=new WeakMap;function xo(e){typeof e=="object"&&e!==null&&Lo.add(e)}function uu(e,t){typeof e=="object"&&e!==null&&Mo.set(e,t)}function fu(e){return typeof e=="object"&&e!==null?Mo.get(e):void 0}function pu(e){return e instanceof Ht||e instanceof mo||typeof e=="object"&&e!==null&&Lo.has(e)}function hu(e){return e instanceof Oe||Fo(e)||e instanceof au||pu(e)}function Fo(e){return ar(e)?.v2Error?.data?.code==="blocks.block_locked"}function Bo(e){return ar(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function ar(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function mu(e){if(e instanceof Oe)return e.reason==="canvas-not-synced";if(hu(e))return!1;const t=ar(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?Bo(e):!0}return du(e)||Bo(e)}var jo="draft";function Xe(e){return e==null||e===""?jo:String(e)}function Kt(e){return e==null||e===""?`${cr}${jo}`:`${cr}${String(e)}`}var cr="block:";function J(e){return e?.startsWith(cr)===!0}function Je(e){return J(e.sessionKey())?void 0:e.current()}function fw(e,t){}function Me(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return te(`show:gate:${e}`,{kind:"wait"}),t.then(s=>(te(`show:gate:${e}:end`,{kind:"wait"}),s),s=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw c.isAbortError(s)?(`${e}`,{...n}):(`${e}`,{error:uo(s),...n},void 0),s})}var pw=5e3,gu=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function vu(e){const t=e?.trim()??"";if(!gu.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function mt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function lr(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Eu(e,t={}){const n=mt((e??[]).filter(r=>r?.html?.trim()));return lr(n,t)?n:null}function _u(e,t){const n=Date.parse(mt(e)?.modified??""),r=Eu(e),s=Date.parse(r?.modified??""),o=t===void 0||Number.isFinite(s)&&s>t,i=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:o?r:null,...i.length?{latestAt:Math.max(...i)}:{}}}function Uo(e,t,n){const r=mt((e??[]).filter(l=>l?.html?.trim())),s=Date.parse(r?.modified??""),o=Date.parse(mt((n??[]).filter(l=>l?.html?.trim()))?.modified??""),i=r&&Number.isFinite(s)&&(t===void 0||s>t)&&!(o>s),a=[Date.parse(mt(e??[])?.modified??""),t??NaN].filter(l=>Number.isFinite(l));return{autosave:i&&lr(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function bu({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var $o=["recovery","plugin","rest"],yu=["subject","preheader"];function Su(e){let t={},n;for(let s=$o.length-1;s>=0;s--){const o=e.get($o[s]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const s of yu){const o=r?.[s];typeof o=="string"&&o!==""&&(t={...t,[s]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function zt(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?or(t.content):void 0,s=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...s?{changes:[new _e(0,n,0,r)]}:{}},{source:"remote"})}var dr=e=>typeof e=="string"?e.trim():"";function wu(e,t,n,r){const{version:s,attributes:o}=e.get(),i=o,a=r==="snapshot"||r==="anchor",l=a?i.author:void 0,d=a?i.date_gmt:void 0,u=dr(i.title)||dr(i.subject)||dr(t.fallbackTitle);return{version:s,payload:{html:e.getContent(),title:u,subject:i.subject,preheader:i.preheader,description:i.description,common_styles:i.common_styles||"",meta:i.meta,utm_parameters:i.utm_parameters,parent_email:i.parent_email,is_template:i.is_template||!1,is_inited:i.is_inited,tags:i.tags,emailtags:i.emailtags,group:i.group,projectCategories:i.projectCategories,renderGuid:e.get().docId,project:t.project??i.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...l!=null&&l!==""?{author:l}:{},...d?{excerpt:d}:{}}}}var Iu=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Tu(e){const t={};for(const n of Iu)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Cu(e,t,n,r,s,o){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(s);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,s):t.saveAutosave(r,s,o==null?void 0:{wpId:o})}function we(e,t=!1){const n={};for(const r of Object.keys(e)){let s=e[r];s!==void 0&&!(typeof s=="number"&&Number.isNaN(s))&&(t&&typeof s=="object"&&s!==null&&(s=we(s)),n[r]=s)}return n}function Au(e){return typeof e=="string"&&e.includes("autosave")}var Ou=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Vo(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Ou.has(t))):{}}function Qe(e,t,n={}){e&&e.mutate({attributes:Du(e.get().attributes,t)},{source:n.source??"user"})}function Du(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function ur(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Pu(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Ho(e){if(!e)return null;const t=Vo(e);return e.common_styles!==void 0&&(t.common_styles=Pu(e.common_styles)),ur(e.html,t)}function Go(e){return e?ur(e.html,we(Vo(e))):null}var Ru=["common_styles","subject","preheader","meta"];function Wo(e){if(!e?.html?.trim())return null;const t={};for(const n of Ru)ku(n,e[n])&&(t[n]=e[n]);return ur(e.html,t)}function ku(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 Nu=["modified","lock","wpId","secretHash"];function Yo(e){if(!e)return null;const t={};for(const n of Nu)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Lu=10,Mu=(e,t)=>e.key===t.key&&xu(e.serverId,t.serverId),xu=(e,t)=>e==null||e===t;function Fu(e){return typeof e?.then=="function"}var qo=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Ko=e=>{e.request.serverId!=null&&!Xt(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},Bu=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),Xt=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),zo=(e,t)=>t?.content!==void 0&&bu({hasUnsavedUserEdit:Xt(e)})==="skip",Xo=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},ju=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),Uu=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent(),e.userTouched.clear(),e.document.get().docId))},$u=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([s,o])=>e.attributes[s]!==o)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Vu=e=>{const t=Su(e.reports),n=$u(e.lastMerged,t);e.lastMerged=t,e.broughtContent=Jt(t.content)??e.broughtContent,n&&(zt(e.document,n),Ko(e))},fr=(e,t)=>{if(!e.ready&&!Xt(e)){Vu(e);return}e.broughtContent=Jt(t?.content)??e.broughtContent,zt(e.document,t)},Jt=e=>e===void 0?void 0:or(e),Hu=(e,t)=>t.content===void 0||Jt(t.content)!==e.broughtContent||!Xt(e)?t:{...t,content:void 0},Gu=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 Wu(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:s,resolveTerms:o,canEdit:i,notifyBeforeSave:a,awaitCanvasSynced:l,savedEchoForm:d=f=>f,queuesOutsideWrites:u,onAdapterError:p,onTimeout:h}=e;let m,_;const y=new Set,v=new Set,b=()=>y.forEach(f=>f()),O=(f,g)=>{if(!(f.closed||f.ready)){if(f.error!==void 0){f.document.markFailed(f.error),f.document.get().docId;return}Ko(f),f.ready=!0,f.document.markReady(),f.document.get().docId,[...f.reports.keys()]}},j=(f,g,T)=>{p?.(g.id,T),!(!g.required||f.closed)&&(f.error=T,f.document.get().docId,g.id,b())},x=(f,g)=>{const T=new Set(g.map(H=>H.id));g.forEach(H=>{H.watch&&f.watchers.push(H.watch(G=>f.closed?!1:f.ready&&(zo(f,G)||f.contentShown===!0&&G?.content!==void 0)?(f.document.get().docId,H.id,!1):(G&&f.reports.set(H.id,G),fr(f,G),G?.content!==void 0&&(f.showFill=void 0),!0)))});const M=(H,G)=>{if(!f.closed){if(!H.required&&zo(f,G)){f.document.get().docId,H.id,H.loaded?.(!1);return}G&&(f.reports.set(H.id,G),H.id==="plugin"&&Xo(f,G)),fr(f,G),H.loaded?.(G!==null)}},$=()=>{T.size>0||f.closed||(qo(f),O(f,[]))},Y=[];if(g.forEach(H=>{let G;try{G=H.load()}catch(Z){j(f,H,Z),T.delete(H.id);return}if(Fu(G)){Y.push({id:H.id,required:H.required,load:()=>G,...H.loaded?{loaded:Z=>H.loaded?.(Z)}:{}});return}M(H,G),T.delete(H.id)}),Y.length===0){$();return}f.timer=setTimeout(()=>{f.timer=void 0,h?.([...T]),f.document.get().docId,[...T],O(f,[...T])},n),f.timer.unref?.(),Y.forEach(H=>{H.load().then(G=>M(H,G)).catch(G=>{j(f,H,G)}).finally(()=>{T.delete(H.id),$()})})},C=async(f,g,T)=>{if(T==="snapshot"||T==="anchor")return;const M=o?.();if(M)return M.resolve({project:g.project??f.project,tags:(f.tags??[]).map($=>({name:$}))})},I=f=>{if(f.lock===!0&&i?.(f)===!1)return new Oe("locked");const g=f.tags?.length??0,T=f.emailtags?.length??0;if(Math.max(g,T)>Lu)return new Oe("too-many-tags")},R=(f,g)=>{const T=f.document.get().serverId;T!=null&&(f.createKey=void 0),!(g||T==null)&&(f.recoveryFacts={emailId:T,historyLoaded:!0,isRecovering:!1},J(f.request.key)||(f.request={...f.request,key:Xe(T),serverId:T}))},A=(f,g,T)=>{if(f.closed||T?.id==null)return;const M=f.document.get().serverId,$=M!=null;$&&M!==String(T.id)||(f.document.markSaved(g,String(T.id)),R(f,$),f.document.get().serverId,b())},P=(f,g,T)=>{if(!(g==="materialize"||g==="publish"&&f.document.get().serverId==null))return T;const M=f.createKey,$=M&&M.project===T.project?M:{key:c.generateUUID(),project:T.project};return f.createKey=$,{...T,idempotencyKey:$.key}},L=async(f,g,T)=>{try{await f.document.whenReady()}catch(Z){return f.saveError=Z,f.saveFailures+=1,f.failedIntent=g,f.saveFailures,!1}if(f.closed)return!1;const M=I(f.document.get().attributes);if(M)return f.saveError=M,f.saveFailures+=1,f.failedIntent=g,M.reason,b(),!1;if(a&&(await a(Gu(f)).catch(()=>{}),f.closed))return!1;if(l){try{await l()}catch(Z){return f.saveError=Z,f.saveFailures+=1,f.failedIntent=g,f.saveFailures,b(),!1}if(f.closed)return!1}if(Bu(f))return g==="snapshot"||(f.saveError=new Oe("empty-content"),f.saveFailures+=1,f.failedIntent=g,b()),!1;let $;try{$=await C(f.document.get().attributes,T,g)}catch(Z){return f.saveError=Z,f.saveFailures+=1,f.failedIntent=g,f.saveFailures,b(),!1}if(f.closed)return!1;const{payload:Y,version:H}=wu(f.document,T,$,g),G=P(f,g,Y);f.document.get().docId;try{const Z=f.document.get().serverId!=null,N=await Cu(r(),s(f.request.key),g,f.document.get().serverId,G,f.document.get().attributes.wpId);if(f.closed)return!0;let z;if(g==="snapshot"||g==="anchor"){const ee=N?.modified!=null?Date.parse(N.modified):NaN;z=Number.isFinite(ee)?ee:Date.now(),f.snapshotVersion=H,f.lastRevisionAt=z}else{f.document.markSaved(H,N?.id!=null?String(N.id):void 0),f.savedContent=G.html;const ee=N;zt(f.document,Yo(ee&&{wpId:ee.wpId,secretHash:ee.secretHash})),f.broughtContent=Jt(d(G.html))}R(f,Z),f.saveError=void 0,f.saveFailures=0,f.failedIntent=void 0,f.document.get().serverId,b();const X={intent:g,serverId:f.document.get().serverId,created:!Z,...z!==void 0?{revisionAt:z}:{}};return v.forEach(ee=>ee(X)),!0}catch(Z){return(g==="publish"||g==="materialize")&&fu(Z)?.then(N=>A(f,H,N)),f.saveError=Z,f.saveFailures+=1,f.failedIntent=g,f.saveFailures,b(),!1}},S=f=>{f.closed=!0,f.watchers.forEach(g=>g()),f.watchers=[],qo(f),f.history.dispose(),f.document.dispose()},D=()=>{m&&(S(m),m=void 0)},k=()=>{_&&(S(_),_=void 0)},F=(f,g,T)=>{let M=!1;g.show&&(f.show?.id!==g.show.id||f.show.token!==g.show.token)&&(f.show=g.show,M=!0,{docId:f.document.get().docId,...g.show});const $=T==="show"?Go(g.patch):null;if($){f.reports.set("plugin",$),Xo(f,$);const Y=Hu(f,$);fr(f,Y),Uu(f,Y)}M&&b()},E=(f,g={})=>U(m,f,g),w=()=>m&&J(m.request.key??"")?_:m,B=f=>({error:f?.saveError,failures:f?.saveFailures??0,saving:f?.saving===!0,failedIntent:f?.failedIntent}),U=(f,g,T)=>!f||f.closed||g==="materialize"&&f.document.get().serverId!=null?Promise.resolve(!1):f.saving?g==="snapshot"||g==="materialize"?Promise.resolve(!1):(f.inFlight??Promise.resolve(!1)).then(()=>U(f,g,T)):(f.saving=!0,b(),f.inFlight=L(f,g,T).finally(()=>W(f)),f.inFlight),W=f=>{f.saving=!1,f.inFlight=void 0,m===f&&!f.closed&&b()},ae=(f,g)=>{if(f.closed)return g();if(f.saving)return(f.inFlight??Promise.resolve(!1)).then(()=>ae(f,g));f.saving=!0,b();const T=Promise.resolve().then(g);return f.inFlight=T.then(()=>!0,()=>!1).finally(()=>W(f)),T},re=(f,g)=>{const T=f.document.get().serverId,M=T==null?void 0:ou(T);return ae(f,g).finally(M)},q=(f,g="open",T=!1)=>{if(m&&!m.closed&&g!=="new"&&Mu(m.request,f))return F(m,f,g),m.document;D(),T||k();const M=Wd({createBuffer:()=>Fd(""),serverId:f.serverId??null}),$={request:f,show:f.show,document:M,history:Xd(M,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return m=$,nu(M,Y=>u?.($.request.key)===!0?re($,Y):void 0),$.watchers.push(ju($)),M.get().docId,f.serverId,x($,t(f,{publishRecoveryFacts(Y){$.closed||($.recoveryFacts=Y,b())},readShownContent:()=>$.closed?null:$.document.getContent(),readWpId:()=>$.closed?void 0:$.document.get().attributes.wpId})),b(),M},K=(f,g,T)=>({key:J(f)?f:Kt(f),serverId:g?.id!=null?String(g.id):null,email:g,show:T});return{openWith:q,open:(f,g={})=>q({key:Xe(f),serverId:f,email:g.email,patch:g.patch,show:g.show},"open"),openDraft:(f,g={})=>q({key:Xe(void 0),serverId:null,email:f,patch:g.patch,show:g.show},"open"),startNewDraft:(f,g={})=>q({key:Xe(void 0),serverId:null,email:f,patch:g.patch,show:g.show},"new"),reload:(f,g={})=>q({key:Xe(f),serverId:f,email:g.email,patch:g.patch,show:g.show},"new"),openBlock:(f,g,T)=>q(K(f,g,T),"open"),reloadBlock:(f,g,T)=>q(K(f,g,T),"new"),openBlockOver:(f,g)=>{const T=K(f,g);return m&&!m.closed&&m.request.key===T.key?m.document:(m&&!m.closed&&!J(m.request.key)&&(k(),_=m,m=void 0),q(T,"open",!0))},resumeSuspended:()=>{if(_)return D(),m=_,_=void 0,b(),m.document},hasSuspended:()=>!!_,suspendedDocument:()=>_?.document,show:(f,g)=>{const T=m;if(!(!T||T.closed))return q({...T.request,patch:f,show:g},"show")},current:()=>m?.document,noteServerFacts:({serverId:f,block:g},T)=>{const M=m;!M||M.closed||M.request.serverId!==f||J(M.request.key??"")===g&&zt(M.document,Yo(T))},save:E,saveEmail:(f,g={})=>U(w(),f,g),saveState:()=>B(m),emailSaveState:()=>B(w()),revisionFacts(){if(!m)return;const f=m.revisionFactsSnapshot;return f&&f.snapshotVersion===m.snapshotVersion&&f.lastRevisionAt===m.lastRevisionAt?f:(m.revisionFactsSnapshot={snapshotVersion:m.snapshotVersion,lastRevisionAt:m.lastRevisionAt},m.revisionFactsSnapshot)},recoveryFacts:()=>m?.recoveryFacts,history:()=>m?.history,forcedHeaders:()=>m?.forcedHeaders,beginForcedHeaders(f){m&&!m.closed&&(m.forcedHeaders=f)},endForcedHeaders(){for(const f of[m,_])f&&(f.forcedHeaders=void 0)},onSaved(f){return v.add(f),()=>v.delete(f)},showFacts:()=>m?.show,shownHeaders:()=>({...m?.shownHeaders}),showFill:()=>m?.showFill,beginShowFill(f){m&&!m.closed&&(m.showFill={showId:f,codeEdits:0})},noteCodeEdit(){m?.showFill&&(m.showFill.codeEdits+=1)},endShowFill(f){for(const g of[m,_])g?.showFill?.showId===f&&(g.showFill=void 0)},sessionKey:()=>m?.request.key,openError:()=>m?.error,subscribe(f){return y.add(f),()=>y.delete(f)},close(){!m&&!_||(D(),k(),b())}}}var pr=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function hr(e){if(e instanceof pr)return e.reason;if(e instanceof Le)return hr(e.reason)}function Yu(e){const t=e instanceof Le?e.reason:e;return t instanceof pr&&t.reason==="unavailable"&&t.cause instanceof TypeError}function qu(e){const t=hr(e);return t!==void 0&&t!=="unavailable"}function Ku(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new pr("not-found");return Ho(n)}}}var Jo=c.createIdentifier$1("EmailPort");function zu(e){return e.getInstance(Jo)}function Xu(e,t){e.inject(Jo,t)}var Qo=c.createIdentifier$1("documentSession.restEmailPortFactories");function Zo(e){return e.getInstance(Qo)!==void 0}function xe(e){const t=e.getInstance(Qo);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Ju=c.createIdentifier$1("EmailTermsResolver");function Qu(e){return e.getInstance(Ju)}var ei=c.createIdentifier$1("EmailHistoryPort"),Zu=c.createIdentifier$1("BlockHistoryPort");function ti(e){return e.getInstance(Zu)}function ni(e){return e.getInstance(ei)}function ef(e,t){e.inject(ei,t)}var tf=2e3,nf=5e3,rf=5,sf=5e3,of=4;function af(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Qt(e,t){return e==null||t==null?!1:e.replaceAll(`\r
2104
2104
  `,`
2105
2105
  `)===t.replaceAll(`\r
2106
2106
  `,`
2107
- `)}function Vt(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function ct(e,t){return Gn(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function du(e,t,n){const{latest:r}=e,o=Ht(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(s=>Ht(s,r.html))?o?{revision:null,phase:"normal"}:{revision:Vt(t),phase:"timeout"}:o?{revision:ct(e),phase:"normal"}:Ht(t.html,r.html)?{revision:Vt(t),phase:"found"}:{revision:ct(e),phase:"normal"}}function uu({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:o=!1,readShownContent:s,onFacts:i,onLate:a,onError:c,pageLoadTs:d=cu()}){const u=r??e;let p=null,m=!1,h=!1,_=0,S={emailId:e,historyLoaded:!1,isRecovering:!1},v=null;const b=new Promise(E=>{v=E}),D=E=>{S={...S,...E},i(S)};let j;const x=E=>{_+=1,D({applied:{phase:E,seq:_}})},C=()=>{p?.timer&&clearTimeout(p.timer),p=null},I=E=>{if(!h){if(v){const y=v;v=null,y(E),j=E.revision?E.phase:void 0;return}a(E)&&E.revision&&x(E.phase)}},R=()=>{if(!p||h)return;const E=p.phase==="fast",y=E?ou:au,B=E?iu:lu;p.timer=setTimeout(()=>{const U=p;if(!(!U||h)){if(U.attempts+=1,w(),E&&U.attempts>=B){const{pending:W}=U;Pe(u),D({isRecovering:!1}),I({revision:Vt(W),phase:"timeout"}),m=!0,U.phase="bg",U.attempts=0,R();return}if(!E&&U.attempts>=B){Pe(u),C(),D({isRecovering:!1}),m=!0;return}R()}},y),p.timer.unref?.()},A=E=>{p={phase:"fast",attempts:0,pending:E,timer:null},D({isRecovering:!0}),R()},O=E=>{if(h)return;if(D({historyLoaded:!0,latestRevisionAt:E.latestAt!==void 0&&Number.isFinite(E.latestAt)?E.latestAt:void 0}),n&&p){const U=ct(E,p.pending.sentAt);if(!U)return;const W=p.phase==="fast"?"found":"bg";Pe(u),C(),D({isRecovering:!1}),m=!0,I({revision:U,phase:W});return}if(m)return;const y=n?xt(u):null,B=y&&(y.sentAt<d||!Ht(y.html,s()))?y:null;if(B){if(o&&(B.baseRevisionId!==void 0||B.baseOpen)){Pe(u),m=!0,I(du(E,B,s()));return}const U=ct(E,B.sentAt);if(U){Pe(u),m=!0,I({revision:U,phase:"found"});return}if(o){if(Pe(u),m=!0,E.latestAt!==void 0&&E.latestAt>B.sentAt+5e3){I({revision:null,phase:"normal"});return}I({revision:Vt(B),phase:"timeout"});return}A(B);return}m=!0,I({revision:ct(E),phase:"normal"})},L=E=>{h||(c?.(E),S.historyLoaded||(D({historyLoaded:!1,latestRevisionAt:void 0}),F()),!p&&I({revision:null,phase:"normal"}))},w=()=>t(e).then(O).catch(L);let P,k=!1;const F=()=>{k||p||h||(k=!0,P=setTimeout(()=>{P=void 0,!h&&!S.historyLoaded&&w()},su))};return w(),{verdict:()=>b,confirmVerdict(E){const y=j;j=void 0,E&&y!==void 0&&!h&&x(y)},dispose(){h=!0,P!==void 0&&(clearTimeout(P),P=void 0),C()}}}function fu({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:o,wpId:s,readShownContent:i,onFacts:a}){let c=null;const d=uu({emailId:o,readAutosave:u=>s?e.readAutosave(u,{wpId:s()}):e.readAutosave(u),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:i,onFacts:a,onLate:({revision:u,phase:p})=>{const m=fs(u);return c?.(m)??!1},onError:u=>{u instanceof Error&&u.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:u})=>fs(u)),loaded(u){d.confirmVerdict(u)},watch(u){return c=u,()=>{c=null,d.dispose()}}}}var pu=5e3,hu=l.createIdentifier$1("plugin.knownRevisions");function Ke(e){return e.getOrCreateInstance(hu,()=>new Map)}function Xn(e,t,n,r){const o=n?.get(t)??[],s=o.filter(i=>i!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...o.length>Is?{baseOpen:!0}:s.length?{baseHtmls:s}:{}}}var mu=l.createIdentifier$1("plugin.uncertainWrites"),Is=3;function dt(e){return e.getOrCreateInstance(mu,()=>new Map)}function gu(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>Is||e.set(t,[...r,n])}function Ts(e,t){Mn(e,t)||!t.baseHtmls||Mn(e,{...t,baseHtmls:void 0,baseOpen:!0})}function Gt(e,t,n,r=!1){const o=xt(e);!n||o?.sentAt!==t||!(r||o.baseOpen||o.baseHtmls)||Mn(e,{...o,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function Cs(e,t,n,r){(xt(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||Ts(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var vu=/(?:Z|[+-]\d{2}:?\d{2})$/i;function Eu(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",o=vu.test(r)?Date.parse(r):NaN;return!Number.isFinite(o)||o>=t-pu}function As(e,t,{pendingKey:n=i=>i,knownRevisions:r=new Map,uncertainWrites:o,synchronousHistory:s=!1}={}){return{readRevisions:(i,a,c)=>t.readRevisions(i,a,c),readRevision:(i,a,c)=>t.readRevision?t.readRevision(i,a,c):Promise.resolve(null),readAutosave:(i,a)=>t.readAutosave(i,a),async saveAutosave(i,a,c){const d=n(i),u=Date.now();Ts(d,{sentAt:u,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...Xn(r,d,o,a.html??"")});const p=await t.saveAutosave(i,a,c),m=p?.id;return Eu(p,u)?Gt(d,u,m):m&&s&&(p.isAutosave===!0?Fn(d,u):Gt(d,u,m,!0)),await e.saveAutosave(i,a),p}}}function _u(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,o){const s=Date.now();n&&Cs(r,o,s,Xn(n.knownRevisions,r,n.uncertainWrites,o.html??""));const i=await t.updateEmail(r,o);return n&&Gt(r,s,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,o),Fn(r,s),i&&{...i,id:r}}}}var Ds=l.createIdentifier$1("CurrentUser"),Ps={};function Jn(e){return e.getOrCreateInstance(Ds,()=>fe(Ps))}function Os(e){return e?.getInstance(Ds)?.get()??Ps}var Rs=l.createIdentifier$1("HeadlessMode");function ks(e){return e.getOrCreateInstance(Rs,()=>fe(!1))}function bu(e){return e?.getInstance(Rs)?.get()??!1}var Su=l.createIdentifier$1("HiddenMount");function yu(e){return e.getOrCreateInstance(Su,()=>fe(!1))}function wu(e){if(!e)return!1;try{return!!l.decodeJwt(e).data?.act_as}catch{return!1}}function Iu(e){return wu(e?.getInstance(l.COOKIE_MANAGER_ID)?.get(l.APP_COOKIES.em_token))}function Ns(e){return e?.getInstance(l.CONFIG_SOURCE_ID)?.get()??{}}function Wt(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Tu(e,t){return t.modeDefaults(Wt(e,t.fallbackMode))}function Ls(e,t){const n=Wt(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Ms(e,t){const n=Wt(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function Cu(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Au(e){return l.mergeResourceProxyLayers(e.map(t=>t?.resourceProxy))}function Du(e){return l.mergeResourceProxyPolicyLayers(e.map(t=>t?.resourceProxyPolicy))}function Pu(e){return l.mergeBackendProxyLayers(e.map(t=>t?.backendProxy))}function Ou(e){return l.mergeShallowConfigLayers(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Ru(e,t){return[e.base,Tu(e,t),e.profile,e.serverSide,Ls(e,t.fallbackMode),e.local,e.user,Ms(e,t.fallbackMode)]}function Qn(e,t){const n=Ru(e,t),r=l.mergeShallowConfigLayers(n),o=Cu(n);o!==void 0&&(r.fileManager=o);const s=Au(n);s!==void 0&&(r.resourceProxy=s);const i=Du(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const a=Pu(n);a!==void 0&&(r.backendProxy=a);const c=Ou(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function ku(e,t,n){const r=Ls(e,n),o=Ms(e,n);return l.pickKey([o,e.user,r,e.serverSide],t)}var Nu=1.5;function Lu(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=Nu*e.autosaveTimeoutMs?"none":"revision"}var hS=5,mS=3;function Mu(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,s=e.readFailures??(()=>0),i=e.readFailureRetryable??(()=>!0);let a;const c=O=>a!==void 0&&a.version===O.get().version?s()-a.failuresAtStart:0,d=O=>{const L=c(O);if(L<=0)return!1;const w=n().retryMaxAttempts??5;return!i()||L>w},u=()=>{const{autosaveTimeoutMs:O,retryIntervalMs:L}=n(),w=t();return w!==void 0&&c(w)>0&&L!==void 0&&L>0?L:O},p=O=>O.isNew()&&s()>=3,m=()=>{const O=t();if(!O||O.isDisposed()||d(O))return"none";const{latestRevisionAt:L,snapshotVersion:w,...P}=n(),k=Date.now(),F=Lu({...P,isDirty:O.isDirty(),isNew:O.isNew(),isReady:O.isReady(),latestRevisionAgeMs:L!=null&&L<=k?k-L:void 0,isSnapshotSent:w!=null&&w===O.get().version});return F==="create"&&p(O)?"none":F},h=()=>{const O=t();if(!O||O.isDisposed()||p(O)||d(O)||n().isHeadless)return!1;if(!O.isDirty())return O.isNew();const{snapshotVersion:L}=n();return!(L!=null&&L===O.get().version)};let _,S=0,v=0,b,D,j,x=!1;const C=()=>{b=void 0;const O=t();if(!O||O.isDisposed())return;if(O.get().docId!==_){I();return}const L=m();L!=="none"&&a?.version!==O.get().version&&(a={version:O.get().version,failuresAtStart:s()}),L==="create"?r():L==="revision"?o():h()&&(_=O.get().docId,S=u(),v=s(),b=setTimeout(C,S))},I=()=>{const O=t();if(x||!O)return;const L=a?.version===O.get().version&&v!==s();b!==void 0&&(S!==u()||L)&&(clearTimeout(b),b=void 0),!(b!==void 0||m()==="none"&&!h())&&(_=O.get().docId,S=u(),v=s(),b=setTimeout(C,S))},R=O=>{const L=t();O.source==="user"?a=void 0:a&&L&&(a.version=L.get().version),O.source==="user"&&b!==void 0&&(clearTimeout(b),b=void 0),I()},A=()=>{const O=t();O!==D&&(j?.(),D=O,a=void 0,j=O?.subscribe(R),b!==void 0&&(clearTimeout(b),b=void 0))};return A(),I(),{refresh:()=>{x||(A(),I())},stop:()=>{x=!0,j?.(),j=void 0,D=void 0,b!==void 0&&(clearTimeout(b),b=void 0)}}}var xs=l.createIdentifier$1("documentSession.autosaveUiFacts"),Fs={isUserBusy:!1,saveContext:{}};function xu(e){return e.getOrCreateInstance(xs,()=>fe(Fs))}function Zn(e){return e?.getInstance(xs)?.get()??Fs}function Bs(e){return Zn(e).saveContext.fallbackTitle||"Untitled email."}var Fu=1e4,Bu=3e4;function ju(e,t){const n=m=>{const h=e.getInstance(l.CONFIG_SOURCE_ID)?.layers?.(),_=h?ku(h,m):void 0;return typeof _=="number"&&_>=0?_:void 0};let r;const o=m=>{const{error:h,failures:_}=t.saveState();return os(h)?(r?.failures!==_&&(r={failures:_,saved:m??null}),r.saved===(m??null)):(r=void 0,!1)},s=()=>{const m=t.current(),h=m?.get().serverId??void 0,_=Z(t.sessionKey()),S=t.recoveryFacts(),v=S?.emailId===h?S:void 0,b=t.revisionFacts(),D=v?.latestRevisionAt,j=b?.lastRevisionAt,x=Os(e).profile;return{isInited:_||m?.get().attributes.is_inited===!0,isEnabled:!!x?.autosaves&&!Iu(e)&&!o(m?.get().savedVersion),isHistoryLoaded:v?.historyLoaded===!0,isUserBusy:Zn(e).isUserBusy,isHeadless:bu(e),autosaveTimeoutMs:Ns(e).autosaveTimeout||Fu,latestRevisionAt:D!==void 0||j!==void 0?Math.max(D??0,j??0):void 0,snapshotVersion:b?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Bu,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},i=()=>{const m=Zn(e).saveContext;return{...m,project:m.project??t.current()?.get().attributes.project,fallbackTitle:Bs(e)}},a=Mu({readDocument:()=>t.current(),readEnvironment:s,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>Ed(t.saveState().error),onCreate:()=>{Z(t.sessionKey())||t.save("materialize",i())},onRevision:()=>{t.save("snapshot",{project:i().project})}}),c=t.subscribe(()=>{o(t.current()?.get().savedVersion),a.refresh()}),d=Jn(e).watch(()=>a.refresh()),u=xu(e).watch(()=>a.refresh()),p=ks(e).watch(()=>a.refresh());return()=>{c(),d.dispose(),u.dispose(),p.dispose(),a.stop()}}var js=12e3;function de(e){return e.getOrCreateInstance(Rn,()=>{const t=Kd({resolveAdapters:(r,o)=>Hu(r,e,o),resolveWritePort:()=>Us(e),resolveHistoryPort:r=>Z(r)?Hs(e):$s(e),resolveTerms:()=>tu(e),canEdit:r=>_c(e,r),notifyBeforeSave:Ic(e),awaitCanvasSynced:Oc(e),savedEchoForm:r=>{const o=Ie(e);return o.toEditorForm(o.toOutputForm(r))},queuesOutsideWrites:r=>Z(r)&&(Mc()||Ge(e)),timeoutMs:js,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const s=Xd(o),i=zd(o);it(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(s),network_failure:String(i)},level:s||i?"warning":"error"})},onTimeout:r=>{}}),n=ju(e,t);return e.getInstance(l.DISPOSABLE_ID)?.addDispose(n),t})}function Ne(e){return e?.getInstance(Rn)}function Us(e){const t=Qd(e);return t?Yt(e)?_u(t,ke(e).email(e),Ge(e)?{knownRevisions:Ke(e),uncertainWrites:dt(e)}:void 0):t:ke(e).email(e)}function Uu(e){return ws(e)!==void 0||bs(e)}function $s(e){const t=ws(e);return t?Yt(e)?(te("port:history:server-backed"),As(t,ke(e).history(e),{knownRevisions:Ke(e),uncertainWrites:dt(e),synchronousHistory:Ge(e)})):(te("port:history:integrator"),t):(te("port:history:rest (порт не зарегистрирован)"),ke(e).history(e))}function Hs(e){const t=ys(e);return t?Yt(e)?(te("port:block-history:server-backed"),As(t,ke(e).blockHistory(e),{pendingKey:xn,knownRevisions:Ke(e),uncertainWrites:dt(e),synchronousHistory:Ge(e)})):(te("port:block-history:integrator"),t):(te("port:block-history:rest (порт не зарегистрирован)"),ke(e).blockHistory(e))}function $u(e){return ys(e)!==void 0||bs(e)}function Yt(e){return Oo(e)}function Hu({email:e,patch:t,serverId:n,key:r},o,s){const i=[];e?i.push({id:"rest",load:()=>ds(e),required:!0}):n&&i.push(Jd(Us(o),n)),t&&i.push({id:"plugin",load:()=>us(t)});const a=Z(r);return kc(n)&&(a?$u(o):Uu(o))&&i.push(fu({port:a?Hs(o):$s(o),revisionServiceEnabled:Yt(o),pendingKey:$o(n,a),historyIsSynchronous:Ge(o),emailId:n,wpId:()=>s.readWpId(),readShownContent:()=>s.readShownContent(),onFacts:c=>s.publishRecoveryFacts(c)})),i}function Vu(e){const t=de(e),n=le(e).addListener(l.EVENT_TYPES.APPLICATION_HAS_AMP,r=>{Ye(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>n.dispose())}function Gu(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Wu(e){const t=e.fetchImpl??((s,i)=>fetch(s,i)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=s=>{try{const i=new URL(s,window.location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?!1:i.hostname===n()||e.sourceHosts().includes(i.hostname)}catch{return!1}};return{accepts:o,async load(s){if(!o(s))return;const i=!r.has(s);r.add(s);try{const a=await t(s,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return Gu(c)?c:void 0}catch{return}}}}var Le={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Yu(e){const t={maxBytes:e.maxBytes??Le.maxBytes,maxImageBytes:e.maxImageBytes??Le.maxImageBytes,ttlMs:e.ttlMs??Le.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,s={hits:0,loads:0,failures:0};let i=0;const a=p=>{const m=r.get(p);m&&(i-=m.bytes,r.delete(p))},c=p=>t.ttlMs<=0||n()-p.storedAt<t.ttlMs,d=()=>{if(i<=t.maxBytes)return;const p=[...r.entries()].sort((m,h)=>m[1].usedAt-h[1].usedAt);for(const[m]of p){if(i<=t.maxBytes)return;a(m)}},u=(p,m)=>{m.size>t.maxImageBytes||(r.set(p,{blob:m,bytes:m.size,storedAt:n(),usedAt:n()}),i+=m.size,d())};return{async get(p){const m=r.get(p);if(m&&c(m))return m.usedAt=n(),s.hits+=1,m.blob;m&&a(p);const h=o.get(p);if(h!==void 0)return h;s.loads+=1;const _=(async()=>{try{const S=await e.load(p);return S?u(p,S):s.failures+=1,S}catch{s.failures+=1;return}finally{o.delete(p)}})();return o.set(p,_),_},forget(p){a(p),o.delete(p)},configure(p){Object.assign(t,{maxBytes:p.maxBytes??t.maxBytes,maxImageBytes:p.maxImageBytes??t.maxImageBytes,ttlMs:p.ttlMs??t.ttlMs});for(const[m,h]of r)h.bytes>t.maxImageBytes&&a(m);d()},clear(){r.clear(),o.clear(),i=0},stats(){return{entries:r.size,bytes:i,...s}}}}var qu=["emcdn.ru","scr.emcdn.ru"];function Ku(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 zu(e,t){const n=(r,o)=>{const s=new Set(o?t:[]);for(const i of r){const a=Ku(i);a&&s.add(a)}return[...s]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Xu(e){const t=e??{},n=t.isPlugin!==!0?qu:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Le};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:zu(o.sourceHosts,n),maxBytes:o.maxBytes??Le.maxBytes,maxImageBytes:o.maxImageBytes??Le.maxImageBytes,ttlMs:o.ttlMs??Le.ttlMs}}function Ju(e){const t=le(e),n=e.getInstance(l.CONFIG_SOURCE_ID),r=()=>Xu({...n?.get(),isPlugin:!0});let o=r();const s=Wu({sourceHosts:()=>o.sourceHosts}),i=Yu({load:S=>s.load(S),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(l.EVENT_TYPES.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},c=t.onInit(()=>a()),d=n?.watch(()=>{const S=r(),v=JSON.stringify(S)!==JSON.stringify(o);o=S,i.configure(S),S.enabled||i.clear(),v&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},p=[],m=(S,v)=>(u.refused+=1,p.push({url:S,reason:v}),p.length>20&&p.shift(),{refused:!0}),h=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...u},refusals:[...p],store:i.stats()})}),_=t.addListenerAsync(l.EVENT_TYPES.APPLICATION_CANVAS_IMAGE_GET,async S=>{const v=S?.url??"";if(u.asked+=1,!o.enabled||!v)return m(v,"disabled");if(!s.accepts(v))return m(v,"host");S.fresh&&i.forget(v);const b=await i.get(v);return b?(u.served+=1,{blob:b}):m(v,"load-failed")});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{c.dispose(),d?.dispose(),_.dispose(),i.clear(),delete h.__emmCanvasImages__})}var Qu=2e3;function Zu(e){const t=le(e),n=new Map,r=()=>{const i=t.getTarget();if(!i||t.hasPort(i))return;clearTimeout(n.get(i));const a=new MessageChannel;let c=!1,d=!1;const u=m=>{m.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",u),d&&t.resumePort(i),t.drainWindow(i))};a.port1.addEventListener("message",u),t.sendPort(i,a.port2),t.usePort(a.port1,!1,i);const p=setTimeout(()=>{n.get(i)===p&&n.delete(i),!(c||!t.hasPort(i,a.port1))&&(it(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d=!0,t.holdPort(i))},Qu);n.set(i,p)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const i=t.getTarget();return{usesPort:t.usesPort,windowDrained:i?t.isWindowDrained(i):!1}}}),s=t.onInit(()=>r());e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{for(const i of n.values())clearTimeout(i);s.dispose(),delete o.__emmCanvasPort__})}var ef=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function tf(e){return ef.test(e)||e.indexOf("//")===0}function qt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function nf(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Vs(e,t){const n=e==null||e===""?"./":String(e);if(tf(n))return qt(n);const r=t??nf();if(!r)return qt(n);try{return qt(new URL(n,r).href)}catch{return qt(n)}}function rf(){return typeof __emailmaker__<"u"&&__emailmaker__?.publicPath?Vs(__emailmaker__.publicPath):Vs("/")}var of=()=>"",sf=()=>"a4e11bd0";function af(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function Gs(e){const t=e?"iframe-eblock":"iframe",n=of();if(n){const s=af(n,window.location).replace(/\/?$/,"/");return wo(`${s}${t}.html`,rt())}const r=sf(),o=`${rf().replace(/\/?$/,"/")}iframe/`;return wo(`${o}${t}${r?`.${r}`:""}.html`,rt())}var Ws="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function er(e){return/^file:/i.test(String(e||"").trim())}function lf(e){return er(e)?`${Ws} allow-same-origin`:Ws}var gS="em:module-body",cf="em:module-body-ack";function df(e,t,n){try{const r=new URL("./",new URL(t,n)).href,o=new URL(e,r).href;return o.startsWith(r)?o:void 0}catch{return}}function tr(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function uf(e){const t=tr(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function ff(e,t){const n=tr(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function pf(e,t){const n=tr(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),s=[r],i=[];for(;s.length>0;)for(const a of e[s.shift()]??[])o.has(a)||(o.add(a),i.push(a),s.push(a));return i}var hf=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function mf(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&hf.test(t[t.length-2])}async function gf(e,t){const n=mf(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function vf(e){const t=new Map,n=(r,o)=>{const s=df(r,e.canvasSrc,e.origin);if(!s)return;const i=t.get(s);if(i!==void 0)return i;const a=e.fetchBody(s,o);return t.set(s,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const s of r)n(s,o)},reset(){t.clear()},get size(){return t.size}}}var Se;function Ef(e){try{return er(new URL(e,window.location.href).href)}catch{return er(window.location.href)}}function Ys(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof __emailmaker__<"u"&&__emailmaker__?.preload?.canvasCrossOrigin===!0}var _f=()=>Promise.resolve(void 0);function qs(){const e=Gs(!1);if(!Ef(e)){if(!Se||Se.canvasSrc!==e){const t=Ys(e)?gf:_f;Se={canvasSrc:e,store:vf({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Se.store}}async function bf(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const o=await r.json();t(ff(o,e))}catch{}}function nr(e){const t=qs();if(!t||!Se||Se.warmed||!Ys(Se.canvasSrc))return;Se.warmed=!0;const{canvasSrc:n}=Se,r=uf(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.Dc_IFMml.js"],"js/iframe.js":["js/elMarkupHelper.Dc_IFMml.js"],"js/darkreader.CLd5EML2.js":[],"js/elMarkupHelper.Dc_IFMml.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.Mun9CrLC.js":[]};o?t.warm(pf(o,n),e):bf(n,s=>t.warm(s,e))}function Sf(e){const t=qs();if(!t)return;nr();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const s=r.source;s&&(s.postMessage({operationId:cf,for:o.result},"*"),t.take(o.data?.url??"").then(i=>{s.postMessage({operationId:o.result,data:i??null},"*")}))};window.addEventListener("message",n),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{window.removeEventListener("message",n)})}var ze=/<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,yf=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Xe=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Ks=/display:\s*none\s*!important/gi,wf=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,If=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Tf=/height\s*:\s*100%\s*!important/i,Cf=[".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 Af(e){return Ks.lastIndex=0,(e.match(Ks)||[]).length}function zs(e){const t=e.trim(),n=Af(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=Cf.filter(o=>t.includes(o)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function Df(e){Xe.lastIndex=0;for(const t of e.matchAll(Xe))if(zs(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Pf(e){let t=!1;return Xe.lastIndex=0,{html:e.replace(Xe,n=>zs(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Of(e){return ze.lastIndex=0,ze.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Df(e)}function Rf(e){if(!Of(e))return{html:e,found:!1};let t=!1,n=e;ze.lastIndex=0,ze.test(n)&&(ze.lastIndex=0,n=n.replace(ze,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(yf,""),t=!0);const r=Pf(n);return n=r.html,t=t||r.found,{html:n,found:t}}function kf(e){return!e||!Tf.test(e)?e:(Xe.lastIndex=0,e.replace(Xe,t=>t.replace(wf,(n,r,o,s)=>`${r}${o.replace(If,"")}${s}`)))}function Xs(e){const t=Rf(e.replaceAll(`\r
2107
+ `)}function Zt(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function gt(e,t){return lr(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function cf(e,t,n){const{latest:r}=e,s=Qt(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(o=>Qt(o,r.html))?s?{revision:null,phase:"normal"}:{revision:Zt(t),phase:"timeout"}:s?{revision:gt(e),phase:"normal"}:Qt(t.html,r.html)?{revision:Zt(t),phase:"found"}:{revision:gt(e),phase:"normal"}}function lf({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:s=!1,readShownContent:o,onFacts:i,onLate:a,onError:l,pageLoadTs:d=af()}){const u=r??e;let p=null,h=!1,m=!1,_=0,y={emailId:e,historyLoaded:!1,isRecovering:!1},v=null;const b=new Promise(E=>{v=E}),O=E=>{y={...y,...E},i(y)};let j;const x=E=>{_+=1,O({applied:{phase:E,seq:_}})},C=()=>{p?.timer&&clearTimeout(p.timer),p=null},I=E=>{if(!m){if(v){const w=v;v=null,w(E),j=E.revision?E.phase:void 0;return}a(E)&&E.revision&&x(E.phase)}},R=()=>{if(!p||m)return;const E=p.phase==="fast",w=E?tf:sf,B=E?rf:of;p.timer=setTimeout(()=>{const U=p;if(!(!U||m)){if(U.attempts+=1,S(),E&&U.attempts>=B){const{pending:W}=U;Ne(u),O({isRecovering:!1}),I({revision:Zt(W),phase:"timeout"}),h=!0,U.phase="bg",U.attempts=0,R();return}if(!E&&U.attempts>=B){Ne(u),C(),O({isRecovering:!1}),h=!0;return}R()}},w),p.timer.unref?.()},A=E=>{p={phase:"fast",attempts:0,pending:E,timer:null},O({isRecovering:!0}),R()},P=E=>{if(m)return;if(O({historyLoaded:!0,latestRevisionAt:E.latestAt!==void 0&&Number.isFinite(E.latestAt)?E.latestAt:void 0}),n&&p){const U=gt(E,p.pending.sentAt);if(!U)return;const W=p.phase==="fast"?"found":"bg";Ne(u),C(),O({isRecovering:!1}),h=!0,I({revision:U,phase:W});return}if(h)return;const w=n?Yt(u):null,B=w&&(w.sentAt<d||!Qt(w.html,o()))?w:null;if(B){if(s&&(B.baseRevisionId!==void 0||B.baseOpen)){Ne(u),h=!0,I(cf(E,B,o()));return}const U=gt(E,B.sentAt);if(U){Ne(u),h=!0,I({revision:U,phase:"found"});return}if(s){if(Ne(u),h=!0,E.latestAt!==void 0&&E.latestAt>B.sentAt+5e3){I({revision:null,phase:"normal"});return}I({revision:Zt(B),phase:"timeout"});return}A(B);return}h=!0,I({revision:gt(E),phase:"normal"})},L=E=>{m||(l?.(E),y.historyLoaded||(O({historyLoaded:!1,latestRevisionAt:void 0}),F()),!p&&I({revision:null,phase:"normal"}))},S=()=>t(e).then(P).catch(L);let D,k=!1;const F=()=>{k||p||m||(k=!0,D=setTimeout(()=>{D=void 0,!m&&!y.historyLoaded&&S()},nf))};return S(),{verdict:()=>b,confirmVerdict(E){const w=j;j=void 0,E&&w!==void 0&&!m&&x(w)},dispose(){m=!0,D!==void 0&&(clearTimeout(D),D=void 0),C()}}}function df({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:s,wpId:o,readShownContent:i,onFacts:a}){let l=null;const d=lf({emailId:s,readAutosave:u=>o?e.readAutosave(u,{wpId:o()}):e.readAutosave(u),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:i,onFacts:a,onLate:({revision:u,phase:p})=>{const h=Wo(u);return l?.(h)??!1},onError:u=>{u instanceof Error&&u.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:u})=>Wo(u)),loaded(u){d.confirmVerdict(u)},watch(u){return l=u,()=>{l=null,d.dispose()}}}}var uf=5e3,ff=c.createIdentifier$1("plugin.knownRevisions");function Ze(e){return e.getOrCreateInstance(ff,()=>new Map)}function mr(e,t,n,r){const s=n?.get(t)??[],o=s.filter(i=>i!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...s.length>ri?{baseOpen:!0}:o.length?{baseHtmls:o}:{}}}var pf=c.createIdentifier$1("plugin.uncertainWrites"),ri=3;function vt(e){return e.getOrCreateInstance(pf,()=>new Map)}function hf(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>ri||e.set(t,[...r,n])}function si(e,t){Zn(e,t)||!t.baseHtmls||Zn(e,{...t,baseHtmls:void 0,baseOpen:!0})}function en(e,t,n,r=!1){const s=Yt(e);!n||s?.sentAt!==t||!(r||s.baseOpen||s.baseHtmls)||Zn(e,{...s,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function oi(e,t,n,r){(Yt(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||si(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var mf=/(?:Z|[+-]\d{2}:?\d{2})$/i;function gf(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",s=mf.test(r)?Date.parse(r):NaN;return!Number.isFinite(s)||s>=t-uf}function ii(e,t,{pendingKey:n=i=>i,knownRevisions:r=new Map,uncertainWrites:s,synchronousHistory:o=!1}={}){return{readRevisions:(i,a,l)=>t.readRevisions(i,a,l),readRevision:(i,a,l)=>t.readRevision?t.readRevision(i,a,l):Promise.resolve(null),readAutosave:(i,a)=>t.readAutosave(i,a),async saveAutosave(i,a,l){const d=n(i),u=Date.now();si(d,{sentAt:u,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...mr(r,d,s,a.html??"")});const p=await t.saveAutosave(i,a,l),h=p?.id;return gf(p,u)?en(d,u,h):h&&o&&(p.isAutosave===!0?tr(d,u):en(d,u,h,!0)),await e.saveAutosave(i,a),p}}}function vf(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,s){const o=Date.now();n&&oi(r,s,o,mr(n.knownRevisions,r,n.uncertainWrites,s.html??""));const i=await t.updateEmail(r,s);return n&&en(r,o,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,s),tr(r,o),i&&{...i,id:r}}}}var ai=c.createIdentifier$1("CurrentUser"),ci={};function gr(e){return e.getOrCreateInstance(ai,()=>ie(ci))}function li(e){return e?.getInstance(ai)?.get()??ci}var di=c.createIdentifier$1("HeadlessMode");function vr(e){return e.getOrCreateInstance(di,()=>ie(!1))}function Ef(e){return e?.getInstance(di)?.get()??!1}var _f=c.createIdentifier$1("HiddenMount");function bf(e){return e.getOrCreateInstance(_f,()=>ie(!1))}function yf(e){if(!e)return!1;try{return!!c.decodeJwt(e).data?.act_as}catch{return!1}}function Sf(e){return yf(e?.getInstance(c.COOKIE_MANAGER_ID)?.get(c.APP_COOKIES.em_token))}var wf="SAVE_BUTTON",If="AUTOSAVE",Tf=Symbol.for("emailmaker.saveNotified"),Cf=c.createIdentifier$1("helpers.saveListeners");function Af(e,t="email"){return(e.getInstance(Cf)?.[t]??0)>0}function ui(e){return e?.getInstance(c.CONFIG_SOURCE_ID)?.get()??{}}function tn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Of(e,t){return t.modeDefaults(tn(e,t.fallbackMode))}function fi(e,t){const n=tn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function pi(e,t){const n=tn(e,t),r=e.user?.advancedConfigs?.[n],s=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...s}}function Df(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Pf(e){return c.mergeResourceProxyLayers(e.map(t=>t?.resourceProxy))}function Rf(e){return c.mergeResourceProxyPolicyLayers(e.map(t=>t?.resourceProxyPolicy))}function kf(e){return c.mergeBackendProxyLayers(e.map(t=>t?.backendProxy))}function Nf(e){return c.mergeShallowConfigLayers(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Lf(e,t){return[e.base,Of(e,t),e.profile,e.serverSide,fi(e,t.fallbackMode),e.local,e.user,pi(e,t.fallbackMode)]}function Er(e,t){const n=Lf(e,t),r=c.mergeShallowConfigLayers(n),s=Df(n);s!==void 0&&(r.fileManager=s);const o=Pf(n);o!==void 0&&(r.resourceProxy=o);const i=Rf(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const a=kf(n);a!==void 0&&(r.backendProxy=a);const l=Nf(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}function Mf(e,t,n){const r=fi(e,n),s=pi(e,n);return c.pickKey([s,e.user,r,e.serverSide],t)}var xf=1.5;function Ff(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=xf*e.autosaveTimeoutMs?"none":"revision"}var hw=5,mw=3,Bf=1e4;function jf(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:s}=e,o=e.readFailures??(()=>0),i=e.readFailureRetryable??(()=>!0);let a;const l=P=>a!==void 0&&a.version===P.get().version?o()-a.failuresAtStart:0,d=P=>{const L=l(P);if(L<=0)return!1;const S=n().retryMaxAttempts??5;return!i()||L>S},u=()=>{const{autosaveTimeoutMs:P,retryIntervalMs:L}=n(),S=t();return S!==void 0&&l(S)>0&&L!==void 0&&L>0?L:S?.isNew()?Bf:P},p=P=>P.isNew()&&o()>=3,h=()=>{const P=t();if(!P||P.isDisposed()||d(P))return"none";const{latestRevisionAt:L,snapshotVersion:S,...D}=n(),k=Date.now(),F=Ff({...D,isDirty:P.isDirty(),isNew:P.isNew(),isReady:P.isReady(),latestRevisionAgeMs:L!=null&&L<=k?k-L:void 0,isSnapshotSent:S!=null&&S===P.get().version});return F==="create"&&p(P)?"none":F},m=()=>{const P=t();if(!P||P.isDisposed()||p(P)||d(P)||n().isHeadless)return!1;if(!P.isDirty())return P.isNew();const{snapshotVersion:L}=n();return!(L!=null&&L===P.get().version)};let _,y=0,v=0,b,O,j,x=!1;const C=()=>{b=void 0;const P=t();if(!P||P.isDisposed())return;if(P.get().docId!==_){I();return}const L=h();L!=="none"&&a?.version!==P.get().version&&(a={version:P.get().version,failuresAtStart:o()}),L==="create"?r():L==="revision"?s():m()&&(_=P.get().docId,y=u(),v=o(),b=setTimeout(C,y))},I=()=>{const P=t();if(x||!P)return;const L=a?.version===P.get().version&&v!==o();b!==void 0&&(y!==u()||L)&&(clearTimeout(b),b=void 0),!(b!==void 0||h()==="none"&&!m())&&(_=P.get().docId,y=u(),v=o(),b=setTimeout(C,y))},R=P=>{const L=t();P.source==="user"?a=void 0:a&&L&&(a.version=L.get().version),P.source==="user"&&b!==void 0&&(clearTimeout(b),b=void 0),I()},A=()=>{const P=t();P!==O&&(j?.(),O=P,a=void 0,j=P?.subscribe(R),b!==void 0&&(clearTimeout(b),b=void 0))};return A(),I(),{refresh:()=>{x||(A(),I())},stop:()=>{x=!0,j?.(),j=void 0,O=void 0,b!==void 0&&(clearTimeout(b),b=void 0)}}}var hi=c.createIdentifier$1("documentSession.autosaveUiFacts"),mi={isUserBusy:!1,saveContext:{}};function Uf(e){return e.getOrCreateInstance(hi,()=>ie(mi))}function _r(e){return e?.getInstance(hi)?.get()??mi}function gi(e){return _r(e).saveContext.fallbackTitle||"Untitled email."}var $f=1e4,Vf=3e4;function Hf(e,t){const n=h=>{const m=e.getInstance(c.CONFIG_SOURCE_ID)?.layers?.(),_=m?Mf(m,h):void 0;return typeof _=="number"&&_>=0?_:void 0};let r;const s=h=>{const{error:m,failures:_}=t.saveState();return Fo(m)?(r?.failures!==_&&(r={failures:_,saved:h??null}),r.saved===(h??null)):(r=void 0,!1)},o=()=>{const h=t.current(),m=h?.get().serverId??void 0,_=J(t.sessionKey()),y=t.recoveryFacts(),v=y?.emailId===m?y:void 0,b=t.revisionFacts(),O=v?.latestRevisionAt,j=b?.lastRevisionAt,x=li(e).profile;return{isInited:_||h?.get().attributes.is_inited===!0,isEnabled:!!x?.autosaves&&!Sf(e)&&!s(h?.get().savedVersion),isHistoryLoaded:v?.historyLoaded===!0,isUserBusy:_r(e).isUserBusy,isHeadless:Ef(e),autosaveTimeoutMs:ui(e).autosaveTimeout||$f,latestRevisionAt:O!==void 0||j!==void 0?Math.max(O??0,j??0):void 0,snapshotVersion:b?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Vf,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},i=()=>{const h=_r(e).saveContext;return{...h,project:h.project??t.current()?.get().attributes.project,fallbackTitle:gi(e)}},a=jf({readDocument:()=>t.current(),readEnvironment:o,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>mu(t.saveState().error),onCreate:()=>{J(t.sessionKey())||t.save("materialize",{...i(),source:If})},onRevision:()=>{t.save("snapshot",{project:i().project})}}),l=t.subscribe(()=>{s(t.current()?.get().savedVersion),a.refresh()}),d=gr(e).watch(()=>a.refresh()),u=Uf(e).watch(()=>a.refresh()),p=vr(e).watch(()=>a.refresh());return()=>{l(),d.dispose(),u.dispose(),p.dispose(),a.stop()}}var vi=12e3;function ue(e){return e.getOrCreateInstance(Vt,()=>{const t=Wu({resolveAdapters:(r,s)=>Yf(r,e,s),resolveWritePort:()=>Ei(e),resolveHistoryPort:r=>J(r)?bi(e):_i(e),resolveTerms:()=>Qu(e),canEdit:r=>ro(e,r),notifyBeforeSave:yd(e),awaitCanvasSynced:Ad(e),savedEchoForm:r=>{const s=De(e);return s.toEditorForm(s.toOutputForm(r))},queuesOutsideWrites:r=>J(r)&&(kd()||ze(e)),timeoutMs:vi,onAdapterError:(r,s)=>{s instanceof Error&&s.message;const o=qu(s),i=Yu(s);pt(s,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(o),network_failure:String(i)},level:o||i?"warning":"error"})},onTimeout:r=>{}}),n=Hf(e,t);return e.getInstance(c.DISPOSABLE_ID)?.addDispose(n),t})}function Se(e){return e?.getInstance(Vt)}function Ei(e){const t=zu(e);return t?nn(e)?vf(t,xe(e).email(e),ze(e)?{knownRevisions:Ze(e),uncertainWrites:vt(e)}:void 0):t:xe(e).email(e)}function Gf(e){return ni(e)!==void 0||Zo(e)}function _i(e){const t=ni(e);return t?nn(e)?(te("port:history:server-backed"),ii(t,xe(e).history(e),{knownRevisions:Ze(e),uncertainWrites:vt(e),synchronousHistory:ze(e)})):(te("port:history:integrator"),t):(te("port:history:rest (порт не зарегистрирован)"),xe(e).history(e))}function bi(e){const t=ti(e);return t?nn(e)?(te("port:block-history:server-backed"),ii(t,xe(e).blockHistory(e),{pendingKey:er,knownRevisions:Ze(e),uncertainWrites:vt(e),synchronousHistory:ze(e)})):(te("port:block-history:integrator"),t):(te("port:block-history:rest (порт не зарегистрирован)"),xe(e).blockHistory(e))}function Wf(e){return ti(e)!==void 0||Zo(e)}function nn(e){return to(e)}function Yf({email:e,patch:t,serverId:n,key:r},s,o){const i=[];e?i.push({id:"rest",load:()=>Ho(e),required:!0}):n&&i.push(Ku(Ei(s),n)),t&&i.push({id:"plugin",load:()=>Go(t)});const a=J(r);return Dd(n)&&(a?Wf(s):Gf(s))&&i.push(df({port:a?bi(s):_i(s),revisionServiceEnabled:nn(s),pendingKey:Eo(n,a),historyIsSynchronous:ze(s),emailId:n,wpId:()=>o.readWpId(),readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),i}function qf(e){const t=ue(e),n=le(e).addListener(c.EVENT_TYPES.APPLICATION_HAS_AMP,r=>{Je(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>n.dispose())}function Kf(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function zf(e){const t=e.fetchImpl??((o,i)=>fetch(o,i)),n=e.pageHost??(()=>window.location.hostname),r=new Set,s=o=>{try{const i=new URL(o,window.location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?!1:i.hostname===n()||e.sourceHosts().includes(i.hostname)}catch{return!1}};return{accepts:s,async load(o){if(!s(o))return;const i=!r.has(o);r.add(o);try{const a=await t(o,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!a.ok)return;const l=await a.blob();return Kf(l)?l:void 0}catch{return}}}}var Fe={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Xf(e){const t={maxBytes:e.maxBytes??Fe.maxBytes,maxImageBytes:e.maxImageBytes??Fe.maxImageBytes,ttlMs:e.ttlMs??Fe.ttlMs},n=e.now??(()=>Date.now()),r=new Map,s=new Map,o={hits:0,loads:0,failures:0};let i=0;const a=p=>{const h=r.get(p);h&&(i-=h.bytes,r.delete(p))},l=p=>t.ttlMs<=0||n()-p.storedAt<t.ttlMs,d=()=>{if(i<=t.maxBytes)return;const p=[...r.entries()].sort((h,m)=>h[1].usedAt-m[1].usedAt);for(const[h]of p){if(i<=t.maxBytes)return;a(h)}},u=(p,h)=>{h.size>t.maxImageBytes||(r.set(p,{blob:h,bytes:h.size,storedAt:n(),usedAt:n()}),i+=h.size,d())};return{async get(p){const h=r.get(p);if(h&&l(h))return h.usedAt=n(),o.hits+=1,h.blob;h&&a(p);const m=s.get(p);if(m!==void 0)return m;o.loads+=1;const _=(async()=>{try{const y=await e.load(p);return y?u(p,y):o.failures+=1,y}catch{o.failures+=1;return}finally{s.delete(p)}})();return s.set(p,_),_},forget(p){a(p),s.delete(p)},configure(p){Object.assign(t,{maxBytes:p.maxBytes??t.maxBytes,maxImageBytes:p.maxImageBytes??t.maxImageBytes,ttlMs:p.ttlMs??t.ttlMs});for(const[h,m]of r)m.bytes>t.maxImageBytes&&a(h);d()},clear(){r.clear(),s.clear(),i=0},stats(){return{entries:r.size,bytes:i,...o}}}}var Jf=["emcdn.ru","scr.emcdn.ru"];function Qf(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 Zf(e,t){const n=(r,s)=>{const o=new Set(s?t:[]);for(const i of r){const a=Qf(i);a&&o.add(a)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function ep(e){const t=e??{},n=t.isPlugin!==!0?Jf:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Fe};const s=r===!0||r===void 0?{}:r;return{enabled:s.enabled!==!1,sourceHosts:Zf(s.sourceHosts,n),maxBytes:s.maxBytes??Fe.maxBytes,maxImageBytes:s.maxImageBytes??Fe.maxImageBytes,ttlMs:s.ttlMs??Fe.ttlMs}}function tp(e){const t=le(e),n=e.getInstance(c.CONFIG_SOURCE_ID),r=()=>ep({...n?.get(),isPlugin:!0});let s=r();const o=zf({sourceHosts:()=>s.sourceHosts}),i=Xf({load:y=>o.load(y),maxBytes:s.maxBytes,maxImageBytes:s.maxImageBytes,ttlMs:s.ttlMs}),a=()=>{t.send(c.EVENT_TYPES.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:s.enabled,sourceHosts:[...s.sourceHosts]})},l=t.onInit(()=>a()),d=n?.watch(()=>{const y=r(),v=JSON.stringify(y)!==JSON.stringify(s);s=y,i.configure(y),y.enabled||i.clear(),v&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},p=[],h=(y,v)=>(u.refused+=1,p.push({url:y,reason:v}),p.length>20&&p.shift(),{refused:!0}),m=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:s,counters:{...u},refusals:[...p],store:i.stats()})}),_=t.addListenerAsync(c.EVENT_TYPES.APPLICATION_CANVAS_IMAGE_GET,async y=>{const v=y?.url??"";if(u.asked+=1,!s.enabled||!v)return h(v,"disabled");if(!o.accepts(v))return h(v,"host");y.fresh&&i.forget(v);const b=await i.get(v);return b?(u.served+=1,{blob:b}):h(v,"load-failed")});e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{l.dispose(),d?.dispose(),_.dispose(),i.clear(),delete m.__emmCanvasImages__})}var np=2e3;function rp(e){const t=le(e),n=new Map,r=()=>{const i=t.getTarget();if(!i||t.hasPort(i))return;clearTimeout(n.get(i));const a=new MessageChannel;let l=!1,d=!1;const u=h=>{h.data?.operationId==="em:port-ready"&&(l=!0,a.port1.removeEventListener("message",u),d&&t.resumePort(i),t.drainWindow(i))};a.port1.addEventListener("message",u),t.sendPort(i,a.port2),t.usePort(a.port1,!1,i);const p=setTimeout(()=>{n.get(i)===p&&n.delete(i),!(l||!t.hasPort(i,a.port1))&&(pt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d=!0,t.holdPort(i))},np);n.set(i,p)},s=Object.assign(globalThis,{__emmCanvasPort__:()=>{const i=t.getTarget();return{usesPort:t.usesPort,windowDrained:i?t.isWindowDrained(i):!1}}}),o=t.onInit(()=>r());e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{for(const i of n.values())clearTimeout(i);o.dispose(),delete s.__emmCanvasPort__})}var sp=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function op(e){return sp.test(e)||e.indexOf("//")===0}function rn(e){return e&&(e.endsWith("/")?e:`${e}/`)}function ip(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function yi(e,t){const n=e==null||e===""?"./":String(e);if(op(n))return rn(n);const r=t??ip();if(!r)return rn(n);try{return rn(new URL(n,r).href)}catch{return rn(n)}}function ap(){return typeof __emailmaker__<"u"&&__emailmaker__?.publicPath?yi(__emailmaker__.publicPath):yi("/")}var cp=()=>"",lp=()=>"33f5584d";function dp(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function Si(e){const t=e?"iframe-eblock":"iframe",n=cp();if(n){const o=dp(n,window.location).replace(/\/?$/,"/");return Ks(`${o}${t}.html`,dt())}const r=lp(),s=`${ap().replace(/\/?$/,"/")}iframe/`;return Ks(`${s}${t}${r?`.${r}`:""}.html`,dt())}var wi="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function br(e){return/^file:/i.test(String(e||"").trim())}function up(e){return br(e)?`${wi} allow-same-origin`:wi}var gw="em:module-body",fp="em:module-body-ack";function pp(e,t,n){try{const r=new URL("./",new URL(t,n)).href,s=new URL(e,r).href;return s.startsWith(r)?s:void 0}catch{return}}function yr(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function hp(e){const t=yr(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function mp(e,t){const n=yr(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(s=>e[s]?.file).filter(s=>!!s):[]}function gp(e,t){const n=yr(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const s=new Set([r]),o=[r],i=[];for(;o.length>0;)for(const a of e[o.shift()]??[])s.has(a)||(s.add(a),i.push(a),o.push(a));return i}var vp=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Ep(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&vp.test(t[t.length-2])}async function _p(e,t){const n=Ep(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function bp(e){const t=new Map,n=(r,s)=>{const o=pp(r,e.canvasSrc,e.origin);if(!o)return;const i=t.get(o);if(i!==void 0)return i;const a=e.fetchBody(o,s);return t.set(o,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,s){for(const o of r)n(o,s)},reset(){t.clear()},get size(){return t.size}}}var Ie;function yp(e){try{return br(new URL(e,window.location.href).href)}catch{return br(window.location.href)}}function Ii(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof __emailmaker__<"u"&&__emailmaker__?.preload?.canvasCrossOrigin===!0}var Sp=()=>Promise.resolve(void 0);function Ti(){const e=Si(!1);if(!yp(e)){if(!Ie||Ie.canvasSrc!==e){const t=Ii(e)?_p:Sp;Ie={canvasSrc:e,store:bp({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Ie.store}}async function wp(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const s=await r.json();t(mp(s,e))}catch{}}function Sr(e){const t=Ti();if(!t||!Ie||Ie.warmed||!Ii(Ie.canvasSrc))return;Ie.warmed=!0;const{canvasSrc:n}=Ie,r=hp(n);r&&t.warm([r],e);const s={"js/iframe-eblock.js":["js/elMarkupHelper.B6dyF9UI.js"],"js/iframe.js":["js/elMarkupHelper.B6dyF9UI.js"],"js/darkreader.CLd5EML2.js":[],"js/elMarkupHelper.B6dyF9UI.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.Mun9CrLC.js":[]};s?t.warm(gp(s,n),e):wp(n,o=>t.warm(o,e))}function Ip(e){const t=Ti();if(!t)return;Sr();const n=r=>{const s=r.data;if(!s||s.operationId!=="em:module-body"||!s.result)return;const o=r.source;o&&(o.postMessage({operationId:fp,for:s.result},"*"),t.take(s.data?.url??"").then(i=>{o.postMessage({operationId:s.result,data:i??null},"*")}))};window.addEventListener("message",n),e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{window.removeEventListener("message",n)})}var et=/<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,Tp=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,tt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Ci=/display:\s*none\s*!important/gi,Cp=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,Ap=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Op=/height\s*:\s*100%\s*!important/i,Dp=[".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 Pp(e){return Ci.lastIndex=0,(e.match(Ci)||[]).length}function Ai(e){const t=e.trim(),n=Pp(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=Dp.filter(s=>t.includes(s)).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 Rp(e){tt.lastIndex=0;for(const t of e.matchAll(tt))if(Ai(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function kp(e){let t=!1;return tt.lastIndex=0,{html:e.replace(tt,n=>Ai(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Np(e){return et.lastIndex=0,et.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Rp(e)}function Lp(e){if(!Np(e))return{html:e,found:!1};let t=!1,n=e;et.lastIndex=0,et.test(n)&&(et.lastIndex=0,n=n.replace(et,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(Tp,""),t=!0);const r=kp(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Mp(e){return!e||!Op.test(e)?e:(tt.lastIndex=0,e.replace(tt,t=>t.replace(Cp,(n,r,s,o)=>`${r}${s.replace(Ap,"")}${o}`)))}function Oi(e){const t=Lp(e.replaceAll(`\r
2108
2108
  `,`
2109
- `));return{html:kf(t.html),hasBrowserExtensionArtifacts:t.found}}function ut(e){return e?.getContent()??""}function Js(e,t){e?.mutate({content:Un(t)},{source:"remote"})}function Kt(e){return l.createIdentifier$1(e)}function ue(e,t){return e.getOrCreateInstance(t,()=>new l.AsyncEmitter)}function J(e,t){return e.getOrCreateInstance(t,()=>new l.AsyncEmitter).event}function zt(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Nf=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 Lf(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 Mf(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(l.throwIfAborted(n),new Promise((r,o)=>{let s=!1,i,a;const c=u=>{s||(s=!0,i!==void 0&&(clearTimeout(i),i=void 0),a?.dispose(),n?.removeEventListener("abort",d),u())},d=()=>{c(()=>o(l.createAbortError(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&c(()=>r())}),e.isInited()&&e.getTarget()){c(()=>r());return}t>0&&(i=setTimeout(()=>{c(()=>o(new Nf(t)))},t)),n?.addEventListener("abort",d)}))}var xf=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 Ff(e,t,n){return t<=0?e:new Promise((r,o)=>{let s=!1,i;const a=c=>{s||(s=!0,i!==void 0&&(clearTimeout(i),i=void 0),c())};i=setTimeout(()=>{a(()=>o(new xf(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>o(c))})})}var Bf=2,ft=Symbol("sandbox:frame-replaced");function Qs(e){return e===ft}function Me(e,t,n,r,o,s,i){const a=`sandbox:${t}`,c=s?.getSandboxTimeoutMs(t)??kn[t],d=()=>{let _=Ff(e.sendAsync(n,r),c,a);return _=l.raceWithAbortSignal(_,s?.signal),Re(a,_,o)};if(t==="INIT_START"&&Lf(e)){const _=s?.getSandboxReadyTimeoutMs()??2e4,S=e,v=b=>{const D=Mf(S,_,s?.signal);return Re("sandbox:INIT_START:ready-wait",D,o).then(()=>{if(!i||b<=0)return d();const j=i.getGeneration();let x;const C=new Promise((R,A)=>{x=i.onChange(()=>{i.getGeneration()!==j&&A(ft)})}),I=d();return I.catch(()=>{}),Promise.race([I,C]).finally(()=>x?.()).catch(R=>{if(R!==ft)throw R;return{...o},v(b-1)})})};return v(Bf)}if(!i)return d();const u=i.getGeneration();let p;const m=new Promise((_,S)=>{p=i.onChange(()=>{i.getGeneration()!==u&&S(ft)})}),h=d();return h.catch(()=>{}),Promise.race([h,m]).finally(()=>p?.()).catch(_=>{throw _===ft&&{...o},_})}var Zs="self-init:";function jf(e){return e.startsWith(Zs)}function rr(e,t){const n=e.getActiveShowRequest();return jf(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Uf(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let s="",i;const a=_=>{i={target:e.readTarget?.(),docId:_}},c=()=>e.readDocument()?ut(e.readDocument()):s,d=()=>Ie(e.container).editorPolicy,u=()=>e.readEmail(),p=()=>{const _=u();return{..._,id:e.isTemplate()||_.isNew?void 0:_.id,html:c()}};let m=!1;const h={readContent:c,publicEmail:p,sendInitStart:()=>Me(n,"INIT_START",l.EVENT_TYPES.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>Me(n,"INITED",l.EVENT_TYPES.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),o()),async sendContent(){const _=u(),{html:S,hasBrowserExtensionArtifacts:v}=Xs(_?.html||"");v&&e.events.browserExtensionDetected(),Js(e.readDocument(),S),s=S,a(_.renderGuid),await Me(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,zt(c(),_.renderGuid,d(),e.readDocument()?.get().version),{guid:_.renderGuid,emailId:_.id??null},r(),o())},refreshContent:()=>(a(u().renderGuid),Me(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,zt(c(),u().renderGuid,d(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const _=u();if(_.preheader!==void 0)return Me(n,"PREHEADER",l.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:_.preheader,guid:_.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const _=u();if(_.subject!==void 0)return Me(n,"SUBJECT",l.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:_.subject,guid:_.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:_=>e.showFilled?.(_),noteFilled:(_,S)=>e.noteFilled?.(_,S),contentSent:()=>i,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(p()),fireInit(_,S){if(!rr(t(),_)){t().getActiveShowRequest()?.showId;return}const v=u();v.id,v.renderGuid,t().completeShow(_);const b=e.readDocument();qe(b,{is_inited:!0},{source:"system"});const D=()=>{const x=p();S&&(x.reset=!0);const C=e.events.inited(x);return S||(m&&h.fireEmailChanged(),m=!0),C};if(!b||b.isReady())return D();const{docId:j}=b.get();return b.whenReady().then(()=>e.readDocument()?.get().docId===j?D():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(p())},fireContentChanged(){e.events.contentChanged(c())}};return h}var $f=class extends Error{showId;constructor(e,t){super(`[emailmaker] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},Hf=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(l.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(l.createAbortError(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const s=setTimeout(()=>{this._settle(e.showId,()=>{o(new $f(e.showId,t))})},t);s.unref?.();const i=()=>{this._settle(e.showId,()=>{o(l.createAbortError(n.reason))})};n.addEventListener("abort",i,{once:!0});const a=()=>{clearTimeout(s),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:s,dispose:a});for(const c of this._listeners)c(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Vf(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Gf(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Mo(e),n=xo(e),r=Sc(e.sandbox);t<n+r}var ei=class{_controller=new AbortController;_externalSignalDisposable=new l.Disposable;_sessionChangeListeners=new Set;_showRegistry=new Hf;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Mo(this._timeouts)}getSandboxTimeoutMs(e){return Lo(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return xo(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=Vf(this._timeouts,e.timeouts),Gf(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new l.Disposable,this._linkExternalSignal(e)}abort(e){const t=e??l.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new l.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new l.Disposable,this._showRegistry.rejectAll(l.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(l.createAbortError("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??l.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??l.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},or=(()=>{const e=new ei;return e.configure({}),e})();function xe(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function Fe(e){return!e||e==="none"}function Wf(e){const t=e.contain??"",n=e.willChange??"";return!Fe(e.transform)||!Fe(e.perspective)||!Fe(e.filter)||!Fe(e.backdropFilter)||!Fe(e.translate)||!Fe(e.rotate)||!Fe(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function ti(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function Yf(e){const t=[],n=document.documentElement,r=ti(getComputedStyle(n)),o=r.x||r.y;let s="none";const i=getComputedStyle(e).position;(i==="absolute"||i==="fixed")&&(s=i);for(let a=xe(e);a&&a!==n;a=xe(a)){const c=getComputedStyle(a),d=s==="none"||Wf(c)||s==="absolute"&&!!c.position&&c.position!=="static",u=a===document.body&&!o;if(d){s="none";const p=u?{x:!1,y:!1}:ti(c);(p.x||p.y)&&t.push({node:a,...p})}(c.position==="absolute"||c.position==="fixed")&&(s==="none"||c.position==="fixed")&&(s=c.position==="fixed"?"fixed":"absolute")}return t}function ni(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function Xt(e){return Number.parseFloat(e)||0}function sr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=ni(e),o=Xt(n.borderLeftWidth),s=Xt(n.borderTopWidth),i=Xt(n.borderRightWidth),a=Xt(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-i):0,d=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-s-a):0;return{left:t.left+o*r.x,top:t.top+s*r.y,right:t.right-(i+c)*r.x,bottom:t.bottom-(a+d)*r.y}}function qf(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(s,i,a)=>{i&&(r.left=Math.max(r.left,s.left),r.right=Math.min(r.right,s.right)),a&&(r.top=Math.max(r.top,s.top),r.bottom=Math.min(r.bottom,s.bottom))};return t.forEach(s=>o(sr(s.node),s.x,s.y)),n&&o(sr(n),!0,!0),r}var ir={originX:0,originY:0,scaleX:1,scaleY:1};function Jt(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function ri(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,o=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*o,scaleX:r,scaleY:o}}function oi(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var Kf=1e3;function zf(e){const{slot:t,own:n}=e;let r,o=0,s=!1;const i=()=>{if(r=void 0,!s){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(i))}},a=()=>{!s&&r===void 0&&(r=window.requestAnimationFrame(i))},c=()=>{o=performance.now()+Kf,a()},d=[window],u=[document.documentElement];for(let v=t;v;v=xe(v)){const b=v.getRootNode();b instanceof ShadowRoot&&!d.includes(b)&&(d.push(b),u.push(b))}const p=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];d.forEach(v=>p.forEach(([b,D])=>v.addEventListener(b,D,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const m=typeof MutationObserver=="function"?new MutationObserver(v=>{v.some(b=>!n.contains(b.target))&&a()}):void 0;u.forEach(v=>m?.observe(v,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let h;try{if(typeof ResizeObserver=="function"){const v=new ResizeObserver(a);typeof v.observe=="function"&&(h=v)}}catch{h=void 0}let _=[];return{schedule:a,observe:v=>{!h||v.length===_.length&&v.every((b,D)=>b===_[D])||(h.disconnect(),_=v,v.forEach(b=>h?.observe(b)))},dispose(){s=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),d.forEach(v=>p.forEach(([b,D])=>v.removeEventListener(b,D,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),m?.disconnect(),h?.disconnect()}}}var Xf="pluginZoom",Jf=/^(?:ant|vscode|monaco|docs)-/;function Qf(e){return Jf.test(e)}function Zf(){const e="em".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var ep=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function tp(){return ep}var np=new Set;function rp(e,t,n=np){return e.startsWith(`${t}-`)?!1:!Qf(e)&&!n.has(e)}function op(e,t){return`--${t}-${e}`}function si(e){const t=Zf();return rp(e,t,tp())?op(e,t):`--${e}`}function sp(e,t){const n=si(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function ii(e,t){return sp(e,t)}var ai=300,li=15e3,ip=5e3,ci="em-canvas-busy-style";function ap(){if(document.getElementById(ci))return;const e=document.createElement("style");e.id=ci,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var lp="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function cp(e){const t=ii("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(si("colorPrimary")).trim()||t}function di(e){ap();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",lp),n.appendChild(r);const o=document.createElement("span");return o.setAttribute("role","img"),o.setAttribute("aria-label","loading"),o.setAttribute("style",`display:inline-flex;color:${cp(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function dp(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),s=Math.min(r.right,e.right,n.width),i=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return s<=o||a<=i?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+s)/2-e.left,y:(i+a)/2-e.top}}function up(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const o={left:n.left,top:n.top,right:n.right,bottom:n.bottom},s=r.getBoundingClientRect();if(s.width>0&&!oi({left:s.left,top:s.top,width:s.width,height:s.height},o)){const i=Jt(o,ri(s,Jt(o,ir),ir));Object.assign(r.style,{left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const i=dp(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(di(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function ar(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(di(e))},ai);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var fp=8e3;function pp(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function hp(e,t){for(let n=xe(e);n;n=xe(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",s=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(i=>Je(i)>0);if(o&&s)return n;if(n===t)return null}return null}function Je(e){return Number.parseFloat(e)||0}function Qt(e,t){return Math.abs(e-t)<=1}function mp(e){const t=getComputedStyle(e),n=Je(t.borderTopWidth),r=Je(t.borderRightWidth),o=Je(t.borderBottomWidth),s=Je(t.borderLeftWidth),i=(a,c,d)=>Math.max(0,Je(a)-Math.max(c,d));return{...sr(e),radii:[i(t.borderTopLeftRadius,n,s),i(t.borderTopRightRadius,n,r),i(t.borderBottomRightRadius,o,r),i(t.borderBottomLeftRadius,o,s)]}}function gp(e,t){const n=Qt(t.top,e.top),r=Qt(t.bottom,e.bottom),o=Qt(t.left,e.left),s=Qt(t.right,e.right),i=[n&&o?e.radii[0]:0,n&&s?e.radii[1]:0,r&&s?e.radii[2]:0,r&&o?e.radii[3]:0];return i.every(a=>a===0)?"":i.map(a=>`${a}px`).join(" ")}function vp(e,t,n,r,o,s){const i=n.readyTimeoutMs??fp,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden",a.style.setProperty("zoom",ii(Xf,"1"));const c=n.resolveSrc(e),d=document.createElement("iframe");d.setAttribute("sandbox",n.resolveSandbox(c)),d.setAttribute("allow","clipboard-read; clipboard-write"),d.setAttribute("title","Email content"),d.style.width="100%",d.style.border="0",d.style.display="block",d.style.minHeight="600px",d.src=c,a.appendChild(d),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(d);const u=new l.Disposable;let p=!1,m,h=!1,_,S,v,b;const D=()=>{clearTimeout(b),b=setTimeout(()=>{h||(h=!0,S?.(new Error(`[canvas] ${e}: документ не загрузился за ${i} мс`)))},i)},j=()=>p?(v=Promise.resolve(),h=!0,v):(h=!1,v=new Promise((f,g)=>{_=f,S=g}),D(),v),x=()=>{if(clearTimeout(b),p=!0,h){v=Promise.resolve();return}h=!0,n.mark?.("loaded"),_?.()};d.addEventListener("load",x),u.addDispose(()=>{clearTimeout(b),d.removeEventListener("load",x)});let C;const I=()=>{C??=n.bindResizer?.(d)},R=()=>{C?.dispose(),C=void 0};let A=null,O=null,L,w=ir,P="",k="",F=0;const E=f=>{const g=JSON.stringify(f);return g===P?!1:(P=g,a.style.visibility=f.visibility,a.style.left=`${f.css.left}px`,a.style.top=`${f.css.top}px`,a.style.width=`${f.css.width}px`,a.style.height=`${f.css.height}px`,a.style.borderRadius=f.radius,d.style.width=f.elementWidth>0?`${f.elementWidth}px`:"100%",d.style.transform=f.shiftX!==0?`translate(${f.shiftX}px, ${f.shiftY}px)`:`translateY(${f.shiftY}px)`,!0)};let y=!1;const B=()=>{if(!A)return P="",a.style.visibility="hidden",d.removeAttribute("id"),!1;n.elementId&&(d.id=n.elementId);const f=A.getBoundingClientRect(),g=Yf(A),T=O?.isConnected?O:null;L?.observe([A,d,...g.map(se=>se.node),...T?[T]:[]]);const M=qf(f,g,T),$=Math.max(0,M.right-M.left),Y=Math.max(0,M.bottom-M.top),V=getComputedStyle(A).visibility==="visible",G=$<=0||Y<=0,Q=G?{left:M.left,top:M.top,right:M.left,bottom:M.top}:M,N=G?null:hp(A,T??g[0]?.node??null),z=N?gp(mp(N),Q):"",X=se=>E({visibility:V&&!y?"":"hidden",css:Jt(Q,se),elementWidth:f.width/se.scaleX,shiftX:(f.left-Q.left)/se.scaleX,shiftY:(f.top-Q.top)/se.scaleY,radius:z});let ee=X(w);if(!G){const se=a.getBoundingClientRect();se.width>0&&!oi({left:se.left,top:se.top,width:se.width,height:se.height},Q)&&(w=ri(se,Jt(Q,w),w),ee=X(w)||ee)}return ee},U=()=>{if(!A)return!1;let f=B();const g=d.getBoundingClientRect().height;g>0&&g!==F&&(F=g,A.style.height=`${g/ni(A).y}px`,f=!0);const T=getComputedStyle(A).pointerEvents;return T!==k&&(k=T,a.style.pointerEvents=T),f},W=()=>{L?.dispose(),L=void 0},ie=f=>{L=zf({slot:f,own:a,measure:U,onDetached:W})};let re=[];const q=(f,g)=>{if(O=g,f&&re.length>0){const T=re;re=[],T.forEach(M=>M())}if(f===A){f&&!L&&ie(f),U();return}if(W(),A&&A.style.removeProperty("height"),P="",F=0,k="",A=f,!f){B(),R();return}n.onShown?.(d),ie(f),U(),I()};u.addDispose(W);const K=f=>{p=!1,m=void 0,s?.(),f&&n.onReload?.(d);let g;h||v===void 0?g=j():(D(),g=v);try{d.contentWindow?.location.reload()}catch{d.src=c}return g};return{element:d,ready(){return v??j()},reload:()=>K(!0),reloadQuietly:()=>K(!1),followReload:()=>{m=void 0,s?.(),n.onReload?.(d)},moveTo(f){if(a.parentNode===f)return v??j();p=!1,m=void 0,s?.();let g;return h||v===void 0?g=j():(D(),g=v),f.appendChild(a),n.onReload?.(d),P="",L?.schedule(),g},get shown(){return A!==null},get slot(){return A},whenShown(){return A!==null?Promise.resolve():new Promise(f=>{re.push(f)})},get filled(){return m},noteFilled(f){m=f},alignTo(f,g){q(f,g??null)},hold(f){y!==f&&(y=f,B())},scrollBy(f,g){let T=f,M=g;for(let $=A?xe(A):null;$;$=xe($)){if(Math.abs(T)<1&&Math.abs(M)<1)return;const Y=getComputedStyle($);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&$.scrollHeight>$.clientHeight){const V=$.scrollTop,G=$.scrollLeft;$.scrollBy({left:T,top:M,behavior:"instant"}),T-=$.scrollLeft-G,M-=$.scrollTop-V}}(Math.abs(T)>=1||Math.abs(M)>=1)&&window.scrollBy({left:T,top:M,behavior:"instant"})},resize(){C?.resize()},dispose(){q(null,null),R(),u.dispose(),a.remove()}}}function Ep(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(w,P)=>w==="email"?`email:${P??n}`:w,s=new Map;let i,a=[],c=!1,d,u,p=!1,m,h,_="shown",S=0,v,b,D;const j=w=>u!==void 0&&w.filled!==void 0&&w.filled!==u,x=()=>{v=void 0;const w=m;!p||!w||u===void 0||b===u||!j(w)||(b=u,e.onForeignDocument?.({wanted:u,filled:w.filled,role:_,heldMs:Date.now()-S}))},C=()=>{p=!1,m=void 0,h=void 0,clearTimeout(v),v=void 0},I=(w,P)=>{const k=s.get("email"),F=k?.slot??null;return w&&F&&j(w)?(w.alignTo(null),p||(p=!0,S=Date.now(),v=setTimeout(x,ip)),_=P,m=w,!(i!==void 0||c)&&h!==w&&(h=w,e.onShown?.(w.element)),!d&&!i&&(d=ar(F)),!1):(p&&(C(),d?.remove(),d=void 0),w?.alignTo(F,k?.clip??null),!0)},R=()=>{p&&!c&&I(t.get(o("email")),"shown")},A=()=>{a.forEach(w=>clearTimeout(w)),a=[],i?.remove(),i=void 0,d?.remove(),d=void 0,(c||p)&&(c=!1,I(t.get(o("email")),"shown"))},O=(w,P,k)=>{const F=o(w,P),E=t.get(F);if(E)return E;const y=e.resolveMount();if(!y)return pp();const B=vp(w,y,e,w==="email"?P??n:void 0,k,w==="email"?()=>R():void 0);return t.set(F,B),B},L={get:w=>O(w),current:w=>O(w),peek:w=>t.get(o(w)),spare:()=>t.get(o("email",r())),ensureSpare:()=>O("email",r(),!0),promote(){const w=t.get(o("email",r()));if(!w)return;const P=t.get(o("email"));n=r(),D=void 0,I(w,"spare"),P?.alignTo(null)},alignSurface(w,P,k){const F=s.get(w);if(s.set(w,{slot:P,clip:k??null}),w==="email"&&c){d?.remove(),d=P?ar(P):void 0;return}const E=P?O(w):t.get(o(w));if(w!=="email"){E?.alignTo(P,k??null);return}if(!P){D=F?.slot&&E?.shown?{slot:F.slot,handle:E}:void 0,p&&(C(),d?.remove(),d=void 0),E?.alignTo(null);return}const y=D?.slot===P&&D.handle===E;if(D=void 0,F?.slot===P&&E?.shown||y){E?.alignTo(P,k??null);return}I(E,"shown")},want(w){u=w,w!==void 0&&R()},noteFilled(w,P){const k=L.byWindow(w);k&&(k.noteFilled(P),k===t.get(o("email"))&&R())},visible(){for(const w of t.values())if(w.shown)return w},byWindow(w){if(w){for(const P of t.values())if(P.element.contentWindow===w)return P}},busy(w){if(A(),!w)return;if(!L.visible()){c=!0,d?.remove(),d=void 0;const F=s.get("email");F?.slot&&(d=ar(F.slot)),a=[setTimeout(A,li)];return}const P=e.resolveMount();if(!P)return;const k=up(P,()=>L.visible()?.element.parentElement?.getBoundingClientRect()??null);i=k,a=[setTimeout(()=>k.showSpinner(),ai),setTimeout(A,li)]},remount(w){A();const P=o("email");t.forEach((k,F)=>{if(F===P){k.moveTo(w).catch(()=>{});return}k.dispose(),t.delete(F)})},dispose(){u=void 0,c=!1,C(),D=void 0,A(),t.forEach(w=>w.dispose()),t.clear(),s.clear(),n="a",u=void 0,b=void 0}};return L}var _p=l.createIdentifier$1("canvas.resizerBinder"),lr=l.createIdentifier$1("canvas.service"),bp={created:ce.canvasCreated,loaded:ce.canvasLoaded},ui=new WeakMap;function cr(e){return ui.get(e)??0}function Sp(e,t){if(e.getInstance(lr))return;const n=Ep({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:lf,elementId:t.elementId,bindResizer:o=>e.getInstance(_p)?.(o),onCreated:o=>pt(e,o,"fresh"),onReload:o=>{ui.set(o,cr(o)+1),pt(e,o,"fresh")},onShown:o=>{const s=n.byWindow(le(e).getTarget());s&&s.element!==o&&fi(s.element)===fi(o)||pt(e,o,"switch")},mark:o=>t.mark?.(bp[o]),onForeignDocument:o=>{({...o},xc("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:o.role},contexts:{canvasIdentity:{...o,path:window.location.pathname}}}))}}),r=le(e).addListener(l.EVENT_TYPES.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(lr,n),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),n.dispose()})}function fi(e){return e.parentElement?.dataset.canvasHost}function pt(e,t,n){const r=le(e),o=t.contentWindow;if(!o)return;const s=r.getTarget()===o;s&&n==="switch"||(n==="fresh"&&(r.forget(o),s&&r.setTarget(void 0)),r.setTarget(o),Tc(r))}function yp(e,t){pt(e,t,"promote")}function wp(e,t){pt(e,t,"switch")}function Ip(e,t){const n=t.contentWindow;n&&le(e).greet(n)}function pi(e,t){const n=t.contentWindow;n&&le(e).forget(n)}function Tp(e,t){const n=ae(e)?.byWindow(t)?.element;if(!n)return;const r=cr(n);return()=>cr(n)!==r}function ae(e){return e.getInstance(lr)}function hi({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:s}){if(!r)return;const i={id:o??void 0,renderGuid:n,showId:s?.id,isNew:o==null,showToken:s?.token},a={...e,...i};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Zt(e){return{...hi({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function en(e){const t=de(e),n=t.current();if(!n||!Z(t.sessionKey()))return;const r=Zt(n),o=n.isDirty();ue(e,l.events.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function Cp(e){const t=de(e);return!t.current()||!Z(t.sessionKey())?!1:(en(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Ap(e){const t=de(e),n=le(e),r=()=>e.getInstance(l.INIT_PIPELINE_ID)??or;let o,s,i=!1,a=!1,c,d;const u=k=>Zt(k),p=()=>{const k=j(),F=k?.get().docId;if(!k||!F||F!==c||i)return;const E=k.get().version;E!==d&&(d=E,ue(e,l.events.ON_BLOCK_CHANGED_ID).fire(u(k)))};let m;const h=k=>{const F=t.showFacts();!F||F.id===m||!rr(k,F.id)||(m=F.id,k.completeShow(F.id))},_=async(k,F,E)=>{const y=E.generation,B=()=>E.generation!==y||E.signal.aborted||t.current()!==k||a,U=me(n);let W;const ie=new Promise(q=>{W=Lt(n,()=>q("regenerated"))}),re=async(...q)=>await Promise.race([Me(...q).then(()=>"sent"),ie])==="sent";i=!0;try{if(!await re(n,"INIT_START",l.EVENT_TYPES.SANDBOX_INIT_START,{guid:F},void 0,E)||B())return;const{html:q,hasBrowserExtensionArtifacts:K}=Xs(ut(k));if(K&&ue(e,l.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Js(k,q),!await re(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,zt(ut(k),F,Ie(e).editorPolicy,k.get().version),void 0,E)||B()||!await re(n,"INITED",l.EVENT_TYPES.SANDBOX_INITED,{guid:F},void 0,E)||B())return;o=F,s=U,x(),d=k.get().version,c!==F&&(c=F,ue(e,l.events.ON_BLOCK_INIT_ID).fire(u(k))),h(E)}finally{W?.(),i=!1,me(n)!==U&&R()}};let S,v,b;const D=()=>{const k=ae(e)?.peek("block");return k?.reload?(k.reload().catch(()=>{}),!0):!1},j=()=>Z(t.sessionKey())?t.current():void 0,x=()=>{const k=j()?.get().docId,F=!k||b===k||o===k&&s===me(n);ae(e)?.peek("block")?.hold(!F)},C=()=>{if(a||(x(),p(),i))return;const k=j(),F=k?.get().docId;if(!k||!F)return;if(o===F&&s===me(n)){h(r());return}if(!k.isReady())return;const E=r();E.signal.aborted||o!==void 0&&o!==F&&S!==F&&(S=F,D())||_(k,F,E).catch(()=>{if(!(a||t.current()!==k)){if(v!==F){v=F,D();return}b=F,x()}})};let I=!1;const R=()=>{I||a||(I=!0,queueMicrotask(()=>{I=!1,C()}))};let A,O;const L=()=>{const k=j(),F=k?.get().docId;F!==O&&(A?.(),O=F,A=k?.subscribe(R)),x(),R()},w=t.subscribe(L),P=Lt(n,()=>{x(),R()});L(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{a=!0,P(),A?.(),w()})}function Dp(e){const t=de(e);let n="email";const r=()=>{if(!t.current())return;const s=Z(t.sessionKey())?"block":"email",i=ae(e);if(s===n||!i)return;n=s;const a=i.peek(s);if(a){wp(e,a.element);return}i.get(s)},o=t.subscribe(r);e.getInstance(l.DISPOSABLE_ID)?.addDispose(o)}var Pp=200;function Op({startVersion:e,limit:t=Pp}){let n=[],r=e;const o=s=>{n=n.filter(i=>i.version>s),r=Math.max(r,s)};return{record(s){!s.changes?.length&&!s.contentReplaced||(n.push(s),n.length>t&&o(n[n.length-t-1].version))},rebase(s,i){if(i<r)return null;const a=n.filter(d=>d.version>i);o(i);let c=s;for(const d of a){if(d.contentReplaced||!d.changes)return null;const u=d.changes,p=[];for(const m of c){if(d.fromCanvas&&u.some(_=>m.range.start<=_.oldEnd&&m.range.end>=_.oldPosition))return null;const h=Wc(m.range,u,"after");if(!h)return null;p.push({range:h,text:m.text})}c=p}return c}}}function Rp(e,t){let n=0;return e.map(({start:r,end:o,text:s})=>{const i=new Ee(r,t.slice(r,o),r+n,s);return n+=s.length-(o-r),i})}function kp(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return Rp(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function Np(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Lp=32;function Mp(e=Lp){const t=new Map;return{find(n,r){const o=t.get(n);return o&&Ln(o.scope,r)?o.echo:void 0},remember(n,r,o){t.delete(n),t.set(n,{scope:r,echo:o}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>Ln(r.scope,n)).map(r=>r.echo)}}}function xp(e,t){const n=l.findTextDiffBounds(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var dr=l.createIdentifier$1("canvas.sandboxFill");function mi(e){return e.getInstance(dr)?.pipeline.isEventsLocked()===!0}var vS=.2,Fp=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,Bp=/<\/?[a-zA-Z]/g;function gi(e){return e.match(Bp)?.length??0}function vi(e){return[...e.matchAll(Fp)].map(t=>[t.index,t.index+t[0].length])}function ur(e,t,n){let r=0,o=0;for(const[s,i]of n){for(;o<t.length&&t[o][1]<=s;)o++;let a=s;for(let c=o;c<t.length&&t[c][0]<i;c++)r+=gi(e.substring(a,Math.max(a,t[c][0]))),a=Math.max(a,t[c][1]);r+=gi(e.substring(Math.min(a,i),i))}return r}function jp(e,t){const n=[...t].sort((c,d)=>c.oldPosition-d.oldPosition||c.oldEnd-d.oldEnd),r=[],o=[],s=[];let i=0,a=0;for(const c of n){const d=e.substring(i,c.oldPosition);r.push(d,c.newText),a+=d.length,o.push([c.oldPosition,c.oldEnd]),s.push([a,a+c.newText.length]),a+=c.newText.length,i=c.oldEnd}return r.push(e.substring(i)),{next:r.join(""),removed:o,inserted:s}}function Up(e,t){if(e.reduce((i,a)=>i+a.oldLength,0)<=200)return null;const n=vi(t),r=jp(t,e),o=ur(t,n,r.removed)-ur(r.next,vi(r.next),r.inserted),s=ur(t,n,[[0,t.length]]);return o>100&&o>s*.2?{removed:o,total:s}:null}function Be(e){it(e,{origin:"canvas-channel"})}var $p=100;function Hp(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===l.EVENT_TYPES.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function Vp(e){const t=de(e),n=le(e);let r;const o=(c,d)=>{const u=c.get().docId;let p=!1,m=null,h=null,_;const S=Op({startVersion:c.get().version});let v=c.getContent();const b=Mp(),D=Uo(e),j=D.open(u,()=>c.get().version);let x=!1;const C=g=>({generation:me(n),originId:g});let I=C(null),R=!0;const A=(g,T)=>{!R||t.current()!==c||(it(T,{origin:"canvas-channel"}),h?.splice(0,h.length),n.sendAsync(l.EVENT_TYPES.SANDBOX_SET_ENTITY,zt(ut(c),u,Ie(e).editorPolicy,c.get().version)).catch(Be))},O=g=>{const T=g[g.length-1],M=[...g].reverse().find(V=>V.answer?.actionId!==void 0)?.answer?.actionId,$=T.answer?.selection,Y=M!==void 0||$?{...M!==void 0?{actionId:M}:{},...$?{selection:$}:{}}:void 0;return{edits:g.map(V=>V.edits),guid:u,rev:T.rev,...Y?{historyAnswer:Y}:{}}},L=()=>{const g=d.activeMove(),T=g&&_?.action===g.kind?_:void 0;if(T&&(_=void 0),!(!T&&!g?.selection))return{...T?{actionId:T.actionId}:{},...g?.selection?{selection:g.selection}:{}}},w=g=>{P({edits:[],rev:c.get().version,answer:{actionId:g.actionId}}).catch(Be)},P=async g=>{if(h){h.push(g);return}h=[g];try{do await n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,O(h.splice(0,h.length)));while(h.length)}catch(T){A("app edits failed to reach the canvas",T)}finally{h=null}},k=g=>{g.length&&n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,O(g)).catch(Be)},F=(g,T)=>{x=!0,k(h?.splice(0,h.length)??[]);const M={edits:[g],guid:u,rev:c.get().version,...T!==null?{changeId:T}:{}};T!==null&&b.remember(T,I,M),n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,M).catch(Be)},E=new Set,y=(g,T,M)=>{F([],M);const{length:$,hash:Y}=l.textFingerprint(JSON.stringify(T.map(Q=>[Q.oldText,Q.newText]))),V=`${$}:${Y}`;if(E.has(V))return;E.add(V);const G=new Error(`canvas service batch removes ${g.removed} of ${g.total} tags`);A("canvas service batch removes a large part of the email",G)},B=({changeId:g,baseRev:T})=>{!x&&(g!==null||T!==null)&&F([],g)},U=g=>{if(g.guid!==u)return;const T=od(g);x=!1,I=C(T.originId);try{W(g,T)}catch(M){B(T),A("canvas batch failed to apply",M)}finally{B(T),T.changeId!==null&&D.note(T.changeId,I)}},W=(g,T)=>{const{pushUndoStop:M}=g,$=T.changeId!==null?b.find(T.changeId,I):void 0;if($){x=!0,n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,$).catch(Be);return}let{edits:Y,selection:V}=g;if(T.baseRev!==null){const G=S.rebase(Y,T.baseRev);if(!G){it(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),F([],T.changeId);return}G!==Y&&(V=void 0),Y=G}try{p=!0,m=T.changeId;const G=kp(Y,c.getContent());if(M===!1){const Q=Up(G,c.getContent());if(Q){y(Q,G,T.changeId);return}d.applyWithoutHistory(G)}else d.recordAt(g.typedAt,()=>c.mutate({changes:G},{source:mi(e)?"system":"user"}),V),g.closesStep&&d.closeGroup()}finally{p=!1,m=null}},ie=c.subscribe(({changes:g,version:T})=>{const M=c.getContent(),$=!g?.length&&M!==v;if(v=M,S.record({version:T,changes:g,contentReplaced:$,fromCanvas:p}),!g?.length)return;const Y=Np(g);p?F(Y,m):P({edits:Y,rev:T,answer:L()}).catch(Be)}),re=n.addListener(l.EVENT_TYPES.APPLICATION_UPDATE_ENTITY,U),q=n.addListenerAsyncPipe(l.CUSTOM_MESSAGE,(g,T)=>{_=Hp(g);try{return T?.(g)}finally{const M=_;_=void 0,M&&w(M)}},$p),K=(g,T,{reportId:M,dropsCovered:$})=>{const Y=h?.splice(0,h.length)??[];n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:[xp(g,T)],guid:u,rev:c.get().version,resync:{textFingerprint:l.textFingerprint(T),reportId:M}}).catch(V=>A("canvas resync edit failed to reach the canvas",V)),$&&k(Y)},f=n.addListener(l.EVENT_TYPES.APPLICATION_SYNC_DRIFT,g=>{if(!((g.reason==="echo-timeout"||g.reason==="resync-failed")&&g.guid!==void 0&&g.guid!==u)){if(g.reason==="resync-failed"){A("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(g.reason==="echo-timeout"){const{textFingerprint:T}=g,M=ut(c),$=l.textFingerprint(M);if(T?.length===$.length&&T.hash===$.hash){b.echoes(C(g.originId??null)).forEach(V=>{n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,V).catch(Be)}),g.reportId!==void 0&&K(M,M,g);return}const Y=new Error(`canvas echo timeout, ${g.unsent??0} edits unsent`);if(g.canvasText===void 0){A("canvas lost the echo of its batch",Y);return}K(g.canvasText,M,g)}}});return()=>{R=!1,j(),ie(),re.dispose(),q.dispose(),f.dispose()}};let s;const i=()=>{const c=t.current(),d=t.history(),u=c?.get().docId;u!==s&&(r?.(),r=void 0,s=u,c&&d&&(r=o(c,d)))},a=t.subscribe(i);i(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r?.(),a()})}function Gp(e){const t=le(e),n=()=>ae(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(l.EVENT_TYPES.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(l.EVENT_TYPES.RELOAD,a=>{const c=ae(e)?.byWindow(a);c&&pi(e,c.element)}),s=t.addListener(a=>{a.data?.operation===l.EVENT_TYPES.SANDBOX_RESIZED&&n()?.resize()}),i=J(e,l.events.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),o.dispose(),s.dispose(),i.dispose()})}function Ei(){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 Wp(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID);let n,r;e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r?.remove(),r=void 0}),Sp(e,{resolveMount:()=>n,resolveSrc:s=>Gs(s==="block"),elementId:"email_iframe",mark:s=>te(s)}),t?.watch(s=>{const i=s?.element;if(n&&i instanceof HTMLElement&&i!==n){n=i,ae(e)?.remount(i),r?.remove(),r=void 0;return}if(!n){if(i instanceof HTMLElement)n=i;else if(s!==void 0){n=r??=Ei(),ae(e)?.alignSurface("email",r,r);return}else return;ae(e)?.get("email")}});let o;e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{o?.remove(),o=void 0}),yu(e).watch(s=>{const i=ae(e);if(i){if(s){o??=Ei(),i.alignSurface("email",o,o);return}o&&(i.alignSurface("email",null),o.remove(),o=void 0)}})}var fr=l.createIdentifier$1("canvas.headerFlow"),_i=["subject","preheader"],bi=3e3,Yp=3,qp={subject:l.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,preheader:l.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE};function Kp(e){const t=de(e),n=le(e),r=C=>C?"remote":mi(e)?"system":"user",o=(C,{guid:I,value:R,forced:A})=>{const O=Ye(t);if(!O||typeof R!="string"||I&&I!==O.get().docId)return;const L=t.forcedHeaders();if(L?.[C]!==void 0&&!A&&R!==L[C])return;const w=O.get().attributes[C];if(!A&&h(C,R,w))return;const P=!A&&p.delete(C);A&&(v.delete(C),v.size===0&&t.endForcedHeaders()),c=!0;try{qe(O,{[C]:R},{source:P?"system":r(A)})}finally{c=!1}s[C]=R};let s={},i,a,c=!1,d=Promise.resolve();const u={},p=new Map,m=(C,I)=>{s[C]=I;const R={};p.set(C,R);const A=()=>{p.get(C)===R&&p.delete(C)};_(C,I,{force:!0}).then(A),setTimeout(A,bi)},h=(C,I,R)=>{const A=t.showFill();if(!A||typeof R!="string")return!1;const O=u[C]?.showId===A.showId?u[C]:void 0;return I===R?(u[C]=O??{showId:A.showId,codeEdits:A.codeEdits,corrections:0},!1):O&&A.codeEdits>O.codeEdits&&I!==O.stale?!1:((!O||I===O.stale&&O.corrections<Yp)&&(u[C]={showId:A.showId,stale:I,codeEdits:A.codeEdits,corrections:(O?.corrections??0)+1},m(C,R)),!0)},_=(C,I,{force:R=!1,echo:A=!1,undoStep:O=!1})=>(d=n.sendAsync(qp[C],{value:I,guid:Ye(t)?.get().docId,...R?{force:!0}:{},...A?{echo:!0}:{},...O?{undoStep:!0}:{}}).catch(L=>{}),d);let S;const v=new Set;e.inject(fr,{whenDelivered:async()=>{await d},reassert:C=>{const I=Ye(t),R=_i.filter(A=>typeof C[A]=="string");if(!(!I||R.length===0)){c=!0;try{qe(I,Object.fromEntries(R.map(A=>[A,C[A]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(R.map(A=>[A,C[A]]))),clearTimeout(S),S=setTimeout(()=>{v.clear(),t.endForcedHeaders()},bi),v.clear();for(const A of R)v.add(A);for(const A of R)s[A]=C[A],_(A,C[A],{force:!0,echo:!0})}}});const b=()=>{i?.(),i=void 0;const C=Ye(t);if(C!==a&&p.clear(),a=C,!C){s={};return}const I=C.get().attributes;s={subject:I.subject,preheader:I.preheader},i=C.subscribe(({source:R})=>{if(c)return;const A=C.get().attributes,O=t.forcedHeaders();for(const L of _i){const w=A[L];if(w===s[L])continue;s[L]=w,p.delete(L);const P=R==="system"&&O?.[L]!==void 0;_(L,w??"",{force:P,echo:P,undoStep:R==="user"})}})};b();const D=t.subscribe(b),j=n.addListenerAsync(l.EVENT_TYPES.APPLICATION_SUBJECT_UPDATE,C=>o("subject",C)),x=n.addListenerAsync(l.EVENT_TYPES.APPLICATION_PREHEADER_UPDATE,C=>o("preheader",C));e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{j.dispose(),x.dispose(),D(),i?.(),clearTimeout(S)})}function zp(e){const t=de(e);let n={document:void 0,seq:0};const r=()=>{const s=t.recoveryFacts(),i=Ye(t);if(!s?.applied||!i||String(s.emailId)!==String(i.get().serverId)||(n.document!==i&&(n={document:i,seq:0}),s.applied.seq<=n.seq))return;n={document:i,seq:s.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(fr)?.reassert(a)},o=t.subscribe(r);e.getInstance(l.DISPOSABLE_ID)?.addDispose(o)}function Xp(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?l.DARK:l.LIGHT}function Jp(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function Qp(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Si(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function pr(e,t){const n={...e};for(const r of Object.keys(t)){const o=t[r],s=e[r];Si(o)&&Si(s)?n[r]=pr(s,o):o!==void 0&&(n[r]=o)}return n}function Zp(e,t){const n=l.COMMON_STYLES;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const o=JSON.parse(r);if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0)return pr(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?pr(n,t):n}var eh=fe(void 0),yi=eh,wi=l.createIdentifier$1("CodeMode");function Ii(){let e;try{const t=window.localStorage?.getItem(l.LOCAL_STORAGE_ITEMS.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function th(e){try{window.localStorage?.setItem(l.LOCAL_STORAGE_ITEMS.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function hr(e){return e.getOrCreateInstance(wi,()=>{const t=fe(Ii());return t.watch(th),t})}function Ti(e){return e?.getInstance(wi)?.get()??Ii()}function mr(e,t){const n=hr(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function nh(e,t){const n=hr(e);n.set({...n.get(),direction:t})}var rh=l.createIdentifier$1("DefaultCommonStyles");function Ci(e){return e.getOrCreateInstance(rh,()=>fe(void 0))}function oh(e,t){Ci(e).set(t)}var sh=l.createIdentifier$1("CanvasViewport"),ih=l.createIdentifier$1("CanvasPreviewPage");function Te(e,t,n){let r,o;const s=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==o&&(o=c,e.send(t,r.value))},i=n.watch(c=>{r={value:c},s()}),a=e.onInit(()=>{o=void 0,s()});return{dispose(){i.dispose(),a.dispose()}}}function tn(e){const t=fe(e());return{source:t,refresh:()=>t.set(e())}}function ah(e){const t=le(e),n=e.getInstance(l.CONFIG_SOURCE_ID),r=e.getInstance(l.OPTIONS_SOURCE_ID),o=de(e),s=hr(e),i=matchMedia(l.PREFERS_COLOR_SCHEME_DARK),a=()=>n?.get()??{};let c;const d=tn(()=>Xp(yi.get()??a().theme,i.matches)),u=tn(()=>Jp(a(),Z(o.sessionKey()))),p=tn(()=>a().lockEditor),m=tn(()=>Zp(o.current()?.get().attributes?.common_styles,c)),h=e.getOrCreateInstance(sh,()=>fe()),_=e.getOrCreateInstance(ih,()=>fe()),S=[Te(t,l.CANVAS_FACTS.theme,d.source),Te(t,l.CANVAS_FACTS.flags,u.source),Te(t,l.CANVAS_FACTS.lockEditor,p.source),Te(t,l.CANVAS_FACTS.commonStyles,m.source),Te(t,l.CANVAS_FACTS.codeMode,s.select(Qp)),Te(t,l.CANVAS_FACTS.appName,fe("emailmaker")),Te(t,l.CANVAS_FACTS.previewPage,_),Te(t,l.CANVAS_FACTS.viewport,h)],v=()=>{d.refresh(),u.refresh(),p.refresh()},b=n?.watch(v),D=Ci(e).watch(O=>{c=O,m.refresh()}),j=r?.watch(O=>{O&&"commonStyles"in O&&(c=O.commonStyles),m.refresh()});let x;const C=()=>{x?.(),x=o.current()?.subscribe(()=>m.refresh()),m.refresh(),u.refresh()};C();const I=o.subscribe(C),R=()=>d.refresh();i.addEventListener("change",R);const A=yi.watch(()=>d.refresh());e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{S.forEach(O=>O.dispose()),b?.dispose(),D.dispose(),j?.dispose(),x?.(),I(),i.removeEventListener("change",R),A.dispose()})}var gr;(function(e){function t(o,s,i=(a,c)=>a===c){if(o===s)return!0;if(o.length!==s.length)return!1;for(let a=0;a<o.length;a++)if(!i(o[a],s[a]))return!1;return!0}e.isEqual=t;function n(o,s=i=>i){const i=new Set;return o.filter(a=>{const c=s(a);return i.has(c)?!1:(i.add(c),!0)})}e.unique=n;function r(o=[],s=[],i=(a,c)=>a===c){const a=[],c=[],d=[];for(const u of o){const p=s.find(m=>i(u,m));p?d.push({prev:u,next:p}):c.push(u)}for(const u of s)o.find(p=>i(u,p))||a.push(u);return{added:a,removed:c,exists:d}}e.diff=r})(gr||(gr={}));function lh(e,t){return e.type===t.type&&e.key===t.key}function ch(e){const t=le(e),n=()=>e.getServices(l.SANDBOX_EXTENSIONS_ID)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(l.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,r)}),s=l.getServiceContainerId(l.SANDBOX_EXTENSIONS_ID),i=e.onInject(a=>{if(a!==s)return;const c=n();if(!t.isInited()){r=c;return}const{added:d,removed:u}=gr.diff(r,c,lh);if(r=c,u.length){if(u.some(p=>p.type==="script")){t.send(l.EVENT_TYPES.RELOAD);return}t.send(l.EVENT_TYPES.SANDBOX_REMOVE_EXTENSIONS,u.map(p=>p.key))}d.length&&t.send(l.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,d)});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{o.dispose(),i?.dispose()})}var dh=new Set([...Object.values(l.EVENT_TYPES).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID)]);function uh(e){return e.length>0&&!e.startsWith("em:")&&!dh.has(e)}function fh(e){const t=le(e),n=new Map;let r=!1,o=-1,s=new Set;const i=d=>(d!==o&&(o=d,s=new Set),s),a=t.observeOutgoing((d,u)=>{if(!r||!uh(d))return;const p=me(t);n.set(d,{data:u,generation:p,scripts:new Set(i(p))})}),c=t.addListener(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID,d=>{if(d.phase!=="ready"||d.status!=="success")return;r=!0;const u=me(t),p=i(u);p.add(d.key);for(const[m,h]of n)h.generation===u||![...h.scripts].every(_=>p.has(_))||(h.generation=u,t.send(l.createIdentifier(m),h.data))});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{a.dispose(),c.dispose()})}var ph=l.createIdentifier$1("prewarm.editorVisible");function hh(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function mh(e={}){const t=e.paint??hh;let n=!1,r=!1,o=!1,s=!1,i=!1;const a=[],c=()=>{i||s||!n||!r||!o||(s=!0,t(()=>{i=!0,te(ce.editorVisible);for(const d of a.splice(0))d()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){o=!0,c()},whenVisible(d){if(i){d();return}a.push(d)},contentShown:()=>o}}function gh(e){return e.getOrCreateInstance(ph,()=>mh())}var vh=500,Eh=500,_h=5e3;function bh(e){const t=e.quietMs??vh,n=e.floorMs??Eh,r=e.ceilingMs??_h;let o,s,i=0;const a=()=>{clearTimeout(o),clearTimeout(s),o=void 0,s=void 0},c=()=>{a(),e.run()},d=()=>{clearTimeout(o);const u=n-(Date.now()-i);o=setTimeout(c,Math.max(t,u))};return{start(){a(),i=Date.now(),s=setTimeout(c,r),d()},notify(){o!==void 0&&d()},cancel:a}}var Sh=2;function Ai(){return new Error("[sandbox] document reloaded during fill")}function yh(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function vr(e){try{e()}catch{}}function wh(e){let t;return vr(()=>{t=e()}),{stage:n=>vr(()=>t?.stage(n)),end:(n,r)=>vr(()=>t?.end(n,r))}}function Ih(e){const t=()=>e.initPipeline();let n=!1,r,o,s,i=0,a,c;const d=()=>{const I=e.readTarget?.(),R=e.readSandboxGeneration?.();return I===void 0||R===void 0?void 0:{target:I,generation:R}},u=()=>{const I=d();return I&&{...I,canvasReplaced:e.trackDocument?.(I.target)}},p=I=>{if(I?.canvasReplaced?.())return!0;const R=d();return I!==void 0&&R?.target===I.target&&R.generation!==I.generation},h=Uf({...e,waitScope:()=>({getSandboxTimeoutMs:I=>t().getSandboxTimeoutMs(I),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const I=c;if(!(!I||!e.onSandboxGenerationChange))return{getGeneration:()=>d()?.generation??I.generation,onChange:R=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===I.target||I.canvasReplaced?.())&&R()})??(()=>{})}}});let _;const S=(I,R)=>{if(_===I)return;_=I;const A=i;setTimeout(()=>{i!==A||t().signal.aborted||j(I,R).catch(()=>{})},0)},v=()=>{a?.abort(),a=void 0};let b;const D=()=>{const I=t().signal;I!==b&&(b?.removeEventListener("abort",v),b=I,I.addEventListener("abort",v))};async function j(I,R,A=0){const O=++i;v(),a=new AbortController,c=void 0,D();const L=()=>i!==O,w=h.readTarget(),P=t().generation,k=()=>P===t().generation&&!t().signal.aborted,F=R?"init:reset-":"init:",E=wh(()=>e.observeShow?.(yh(I,R,e.readEmail())));if(!R){const q=h.publicEmail();q?.id,q?.renderGuid,q?.preheader}let y=!1,B=!1,U,W=!1;const ie=()=>{if(p(U))throw Ai()},re=()=>{if(L())throw l.createAbortError("Fill superseded")};try{n=!0,await h.sendInitStart(),re(),U=u(),c=U,A===0&&h.fireWillInit(),await(R||A>0?h.refreshContent():h.sendContent()),y=!0,re(),ie();const q=h.contentSent();h.noteFilled(q?.target,q?.docId),E.stage("content"),R||h.publicEmail()?.id;try{await h.sendPreheader()}catch(K){if(Qs(K)||L())throw K;`${F}`,String(K)}re();try{await h.sendSubject()}catch(K){if(Qs(K)||L())throw K;`${F}`,String(K)}if(re(),ie(),h.showFilled(w),await h.sendInited(),re(),ie(),B=!0,o===I){const K=e.readSandboxGeneration?.()??s;K!==void 0&&(r=K)}E.stage("reveal"),await h.revealFilled(),ie(),E.end("revealed")}catch(q){const K=!L()&&k()&&p(U),f=K?Ai():void 0,g=f??q,T=K&&A<Sh?C(I,R,A+1):void 0;W=K&&T===void 0;const M=L()?void 0:{showId:I,contentApplied:y,sandboxInitedAcked:B,superseded:!1,...e.describeSurface?.(),error:String(f??q)};M&&(`${F}`,void 0);const $=!L()&&e.recoverFailedFill?.(w)===!0;if(E.end(L()?"superseded":$?"recovered":l.isAbortError(g)||!k()?"aborted":"failed",M),!$&&!L()&&rr(t(),I)&&t().failShow(I,g),T!==void 0)return T;throw g}finally{x(I,R,F,{superseded:L(),sessionGeneration:P,contentApplied:y,sandboxInitedAcked:B&&!W,retry:!W,commit:k()})}}function x(I,R,A,O){const{superseded:L,contentApplied:w,sandboxInitedAcked:P}=O;if(L){`${A}`;return}P&&O.commit?h.fireInit(I,R||void 0):P?(`${A}`,O.sessionGeneration,t().generation,t().signal.aborted,void 0):w?(`${A}`,void 0):(`${A}`,void 0),n=!1,a=void 0,!P&&o===I&&(o=void 0,r===s&&(r=void 0)),!P&&w&&O.retry&&S(I,R)}function C(I,R,A){return j(I,R,A)}return{channel:h,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:I=>{r=I},lastCorrelation:()=>o,markCorrelation:I=>{o=I},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:I=>{s=I},fill:I=>j(I,!1),refill:I=>j(I,!0),stop:()=>{i+=1,v(),n=!1,b?.removeEventListener("abort",v),b=void 0}}}function Th(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:Di(e,n)}function Di(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Ch(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:s}=e,i=u=>{const p=n(),m=o();if(!Th(p,u,m)){u.showId,u.navId,u.emailId,p?.id,p?.showId,p?.renderGuid;return}u.showId,p?.id,p?.renderGuid,t.markFilled(s()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{i(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&i(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=s();if(t.filledGeneration()===u)return;const p=n(),m=o();if(!p?.renderGuid||!Di(p,m))return;const h=`${Zs}${p.renderGuid}`;t.markFilled(u),t.markCorrelation(h);const _=r()?.isReady()===!0;p.id,p.renderGuid,(_?S=>t.refill(S):S=>t.fill(S))(h).catch(()=>{t.lastCorrelation()===h&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var Ah=l.createIdentifier$1("canvas.health");function Dh(e){return e??""}function Ph(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Pi(e){return e.length>0}function Oh(e){const t=de(e),n=le(e),r=()=>Z(t.sessionKey())?void 0:t.current(),o=()=>{const N=r();return hi({attributes:N?.get().attributes??{},readContent:()=>N?.getContent(),docId:N?.get().docId,hasSession:!!N,serverId:N?.get().serverId,show:t.showFacts()})},s=()=>e.getInstance(l.INIT_PIPELINE_ID)??or;let i={},a=!1;const c=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(N=>{a=!!N?.element});let d=!1,u=!1,p=!1,m=0;const h=()=>{const N=ae(e);if(!N)return;const z=++m,X=N.spare();return X&&pi(e,X.element),(X?X.reloadQuietly():N.ensureSpare()?.ready())?.then(()=>{if(z!==m)return;d=!0;const ee=N.spare();ee&&Ip(e,ee.element),p&&(p=!1,P(),K())})},_=bh({run:()=>{p||h()?.catch(()=>{})}}),S=()=>{gh(e).noteContentShown(),!d&&!p&&_.start()};let v=!1;const b=N=>{const z=ae(e),X=z?.spare()?.element.contentWindow;u&&z&&X&&N===X&&(u=!1,z.promote(),z.busy(!1),v=!0)};let D=!1;const C=Ih({container:e,messageService:n,initPipeline:s,readDocument:r,readEmail:o,revealFilled:()=>{const N=ae(e);return v&&N&&(v=!1,_.start()),a?N?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:b,noteFilled:(N,z)=>ae(e)?.noteFilled(N,z),recoverFailedFill:N=>{const z=ae(e),X=z?.spare()?.element.contentWindow;return!u||!z||!X||N!==X?!1:(u=!1,d=!1,L="reload",z.busy(!1),z.peek("email")?.reload(),D=!0,K(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>me(n),onSandboxGenerationChange:N=>Lt(n,N),trackDocument:N=>Tp(e,N),observeShow:N=>e.getInstance(Ah)?.begin(N),describeSurface:()=>({canvasPath:L,promoted:u,spareClean:d,handshake:n.isInited(),generation:me(n)}),events:{willInit:N=>{ue(e,l.events.WILL_EMAIL_INIT_ID).fire(N)},inited:N=>{S(),ue(e,l.events.ON_EMAIL_INIT_ID).fire(N)},contentChanged:N=>{ue(e,l.events.ON_CONTENT_CHANGED_ID).fire(N)},emailChanged:N=>{ue(e,l.events.ON_EMAIL_CHANGED_ID).fire(N)},browserExtensionDetected:()=>{ue(e,l.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),I=Ch({pipeline:C,initPipeline:s,readEmail:o,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>me(n)});let R="",A="",O="",L="none";const w=()=>{const N=ae(e)?.spare()?.element.contentWindow;N&&n.getTarget()===N||n.sendNow({operation:l.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0})},P=()=>{const N=ae(e)?.spare();N&&(w(),d=!1,u=!0,yp(e,N.element))},k=(N,z)=>{const X=ae(e);if(!X)return!0;const ee=X.spare(),se=ee&&d?"spare":"prepare";if(L=se,X.busy(!0),ee&&d)return P(),!0;_.cancel(),w();const He=h();if(He===void 0)return L="reload",X.busy(!1),X.peek("email")?.reload(),!0;p=!0;const Ae=m;return He.catch(()=>{!p||Ae!==m||(p=!1,L="reload",X.busy(!1),X.peek("email")?.reload())}),!1},F=()=>{if(Z(t.sessionKey()))return;Y(),C.noteSandboxGeneration(me(n));const N=o(),z=Ph(N?.renderGuid,N?.showId,N?.id,i.emailId),X=Dh(N?.renderGuid);if(X!==A){const He=A;A=X;const Ae=ae(e)?.peek("email")?.filled,oS=Ae!==void 0&&Ae!==X;Pi(X)&&(Pi(He)||oS)&&k(He||(Ae??""),X)}if(p)return;(z!==R||D)&&(D=!1,R=z,I.showRequestIdentityChanged());const ee=r(),se=`${z}|${ee?.get().docId??""}|${me(n)}`;se!==O&&ee?.isReady()===!0&&(O=se,I.selfInitChanged()),I.saasChanged(),re()};let E=!1,y="",B="",U=!1,W=!1;const ie=N=>{N.source==="user"?W=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(U=!0),K()},re=()=>{const N=o();if(!N?.renderGuid)return;const z=C.channel.readContent(),X=JSON.stringify([N.preheader,N.common_styles,N.meta,N.subject,N.utm_parameters?.utm_campaign??"",N.utm_parameters?.utm_content??"",N.utm_parameters?.utm_medium??"",N.utm_parameters?.utm_source??"",N.utm_parameters?.utm_term??""]),ee=E&&z!==B,se=E&&X!==y;E=!0,B=z,y=X;const He=U&&!W;if(U=!1,W=!1,C.isEventsLocked()||He)return;const Ae={...N,id:i.isTemplate||N.isNew?void 0:N.id,html:z};if(ee){ue(e,l.events.ON_CONTENT_CHANGED_ID).fire(z),ue(e,l.events.ON_EMAIL_CHANGED_ID).fire(Ae);return}se&&N.is_inited&&ue(e,l.events.ON_EMAIL_CHANGED_ID).fire(Ae)};let q=!1;const K=()=>{q||(q=!0,queueMicrotask(()=>{q=!1,F()}))};e.inject(dr,{pipeline:C,setRoute:N=>{N.emailId===i.emailId&&!!N.isTemplate==!!i.isTemplate||(i=N,K())}});let f,g;const T=()=>{const N=r()?.get().docId;N!==g&&(f?.(),g=N,f=r()?.subscribe(ie)),K()};let M,$;const Y=()=>{const N=e.getInstance(l.INIT_PIPELINE_ID);!N||N===M||($?.(),M=N,$=N.onShowRequested(z=>I.showRequested(z)))},V=n.addListener(N=>{N.data?.operation===l.EVENT_TYPES.SANDBOX_RESIZED&&_.notify()}),G=t.subscribe(T),Q=Lt(n,K);T(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{c?.dispose(),$?.(),Q(),G(),f?.(),V.dispose(),_.cancel(),C.stop()})}function Rh(){return l.USEBLOCKS!=="emailmaker"}var kh={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Oi={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},Ri=Oi,Nh=["pro"],Er={};function Lh(e){Er=e}var ki=e=>Nh.includes(e)?Ri:Er[e]??Er.editor??Ri,_r={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},Mh={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},xh={..._r,config:{..._r.config,imageCenterFileManagerView:!1}};Lh({pro:Oi,editor:Mh,simple:Rh()?_r:xh,blocks:kh});function Fh(e,t,n=e.getInstance(l.CONFIG_SOURCE_ID)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Ti(e).isCodeMode&&mr(e,!1)}function Bh(e){e.getInstance(l.STANDALONE_ACTIVATED_ID)||e.inject(l.SECURITY_MODULE_ID,void 0)}function nn(e){return String(e.standaloneKey||"").trim()||void 0}function jh(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function br(e){return jh(e)?!!nn(e):!1}function ht(e){return!!nn(e)&&!br(e)}var Uh=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Ni(e){return e==="server"?"serverSide":e}function $h({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=fe();let s={kind:"pending"},i;const a=new Promise(m=>{i=m}),c=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function d(){s.kind!=="pending"&&o.set(Qn(r,e))}function u(m){if(s.kind!=="pending")return;clearTimeout(c),s=m;const h=Qn(r,e);o.set(h),i(h)}function p(m,h){r[Ni(m)]=h,m==="server"&&s.kind==="pending"?u({kind:"applied"}):d()}return{watch:m=>o.watch(m),select:m=>o.select(m),get:()=>o.get(),ready:()=>a,state:()=>s,layers:()=>({...r}),bootstrap(){const m=Qn(r,e);return Object.fromEntries(Uh.map(h=>[h,m[h]]))},merge(m,h){p(h,{...r[Ni(h)],...m})},replace(m,h){p(h,m)},setMode(m){r.user={...r.user,mode:m},d()},setAdvancedConfigs(m){r.advancedConfigs=m,d()},serverAbsent(m){u({kind:"absent",reason:m})},applyServerResponse(m){s.kind==="pending"&&p("server",{...r.serverSide,...m})},dispose(){clearTimeout(c)}}}var Hh=5e3,ES="pro";function Vh(){return{...ki("pro")?.config,mergeTags:void 0}}function Gh(e,t){e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},o=t.layers().user.mode;t.replace(r.mode===void 0&&o!==void 0?{...r,mode:o}:r,"user")})}function Wh(e,t){let n;Jn(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const s={};r?.theme&&(s.theme=r.theme),r?.locale&&(s.locale=r.locale),t.replace(s,"profile")})}function Yh(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function qh(e,t){let n,r=!1,o;const s=a=>{o??=Wt(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Fh(e,a,t)},i=Jn(e).watch(({profile:a})=>{const c=a?.email_builder_config,d=Yh(c);if(d===void 0||c===n)return;const u=n===void 0;n=c,!(u&&r)&&s(d)});e.getInstance(l.DISPOSABLE_ID)?.addDisposable(i),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,s(c)})}var Li="замкнутый контур: app_init не выполняется";function Kh(e,t){if(e.getInstance(l.SECURITY_MODULE_ID)){t.serverAbsent(Li);return}const n=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(r=>{ht(r)&&t.serverAbsent(Li)});n&&e.getInstance(l.DISPOSABLE_ID)?.addDisposable(n)}async function zh(e,t){if(e.getInstance(On)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(l.APP_ID);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function Xh(e){e.injectFactory(l.CONFIG_SOURCE_ID,(t,n)=>{if(n)return n;const r=$h({base:Vh(),env:{modeDefaults:o=>ki(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Hh});return Gh(e,r),Wh(e,r),qh(e,r),Kh(e,r),zh(e,r),e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var Qe=class extends l.Disposable{_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 H(e,t,n){const r=l.snapshot(e);return(o,s,i)=>{const a=r(async c=>{const d=t?t(c):c;i&&o.bind(i);const u=await o(d);return n?n(u):u},s,i);return()=>a.dispose()}}var Jh=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new l.Emitter;this.handleDestroy=H(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Qe(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{}}},Sr=l.createIdentifier$1("DestroyableService");function Qh(e){e.injectFactory(Sr,(t,n)=>{if(n)return n;const r=e.getInstance(l.DISPOSABLE_ID);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Jh({lifetime:r,options:e.getInstance(l.OPTIONS_SOURCE_ID),getInstance:()=>e.getInstance(l.INSTANCE_ID),release:()=>l.releaseContainer(e.getInstance(l.STORE_ID)??e)})},!0)}function Zh(e){const t=e.getInstance(Sr);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var em=1e3;function Mi(e,t,n=em,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;for(const i of o)if(!Mi(e[i],t[i],n,r+1))return!1;return!0}return!1}function mt(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const o=t[r],s=e[r];Mi(o,s)||(n[r]=o)}return n}var tm=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function nm(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function rm({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??st();let s;try{const i=e.notifySave(n);return await Promise.race([i,new Promise((a,c)=>{s=setTimeout(()=>{const d=new Nt(o);n.value.id,hd(d,nm(i,r)),c(d)},o)})])}catch(i){throw rs(i),i}finally{s!==void 0&&clearTimeout(s)}}function om(e){const{emails:t}=e,n=async(r,o)=>{const s=tm(o),i=r===void 0?void 0:await t.cache.getIfPresent(r),a=i?{...i,...s}:s,c=i?mt(i,s):s,d=u=>{const p=String(u.id??r??l.generateUUID()),m=u.id===void 0?{...u,id:p}:u;return t.cache.addOrUpdate(p,()=>m)};return await d(await rm(e,{prev:i,patch:c,value:a,source:o.source??""},d))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const o=await n(void 0,r);return o?.renderGuid?o:{...o,renderGuid:l.generateUUID()}},async updateEmail(r,o){return await n(r,o)}}}var yr=20;function sm(e){const t=im(e);return e.saveTimeoutMs?am(t,e.saveTimeoutMs):t}function im({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:s}){const i=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(d=>String(d?.parent)===String(a)));return{async readRevisions(a,c=1){const d=await i(a,c);return{revisions:d.slice(yr*(c-1),yr*c),page:c,hasMore:d.length>yr*c}},async readAutosave(a){const c=await r?.(a)??NaN,d=Number.isFinite(c)?c:void 0,u=await n?.(a);if(!u?.asked)return yd(await i(a,1),d);if(!u.revision)return as([],d);const p={...u.revision,parent:a,isAutosave:!0};return as([p],d,await i(a,1))},async saveAutosave(a,c){const d=await o?.(a),u=s?.();return await e.create({...Dd(c),...d!==void 0?{author:d}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function am(e,t,n){return{...e,async saveAutosave(r,o){const s=t();if(s===void 0)return e.saveAutosave(r,o);let i;try{return await Promise.race([e.saveAutosave(r,o),new Promise((a,c)=>{i=setTimeout(()=>c(new Bo(s,n)),s)})])}catch(a){throw rs(a),a}finally{i!==void 0&&clearTimeout(i)}}}}var lm=class extends l.BaseEmitter{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}},cm=class extends l.AsyncEmitter{};function _S(e){return e}var xi=class extends l.Disposable{_items=new Map;_onChangeEmitter=new l.Signal;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const o=await t(n);return l.deepEqual(n,o)||this._onChangeEmitter.fire(),o}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([o,s])=>o)),r=(await this.entries()).filter(([o,s])=>!n.has(o));for(const[o,s]of e)t.push(this.addOrUpdate(o,()=>s)),n.add(o);for(const[o]of r)t.push(this.remove(o));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function dm(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:s=20}={}){const i=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(d=>{for(const u of c){const p=d[u],m=t[u];return u==="id"||typeof p!="string"?p===m:typeof m=="string"&&p.startsWith(m)}return!0}),a=e.length}return r&&(e=e.sort((c,d)=>(c[r]>d[r]?1:d[r]>c[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(s*(o-1),s*o)),{data:e,filteredTotal:a,total:i,totalPages:Math.ceil(a/s)}}function um(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const o=t.get(r.id)||{};t.set(r.id,{...o,...r})}return[...t].map(([n,r])=>r)}function fm(e,t){return Fi(e)&&Fi(t)?String(e)===String(t):e===t}function Fi(e){return typeof e=="string"||typeof e=="number"}var pm=class extends l.Disposable{_cache=new xi;_readEmitter=new l.AsyncEmitter;_saveEmitter=this.addDisposable(new lm);_removeEmitter=this.addDisposable(new cm);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new l.Disposable);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new xi),o=n.addDisposable(new l.AsyncEmitter);t=this._foreignCache[e]={get:async(s,i={})=>{await r.getOrCreate(s,async()=>{try{const c=um(await o.fire(s))||[];for(const d of c)d[e]=s,await this._cache.add(d.id,d);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const d=c[e];return d==null||fm(d,s)});return dm(a,i)},first(s,i={}){return t.get(s,{...i,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:o.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=l.generateUUID()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async o=>{const s=o?{...o,...t}:t;if(!r)return t=o?mt(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:s,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function gt(e){const t=l.createIdentifier$1(e);return n=>n.getOrCreateInstance(t,()=>new pm)}function Bi(e){const t=e.getInstance(l.DISPOSABLE_ID);if(!t)throw new Error("Failed");return t}function ji(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function rn(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function hm(e,t,n){return e&&!ji(t)&&ji(e)?{...n,meta:e.meta}:n}var mm=l.createIdentifier$1("CurrentProject"),gm={};function vt(e){return e?.getInstance(mm)?.get()??gm}function wr(e){const t=vt(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Ui=gt("plugin.dataSource.emails"),$i=gt("plugin.dataSource.emailRevisions"),Hi=Kt("plugin.readEmailAutosave"),Vi=l.createIdentifier$1("emailDocuments.provided");function vm(e){const t=Ui(e),n=$i(e),r=n.byForeignKey("parent");if(e.getInstance(Vi))return{emails:t,emailRevisions:n};e.inject(Vi,!0);const o=()=>st(e.getInstance(l.INIT_PIPELINE_ID)?.contentReadyTimeoutMs),s=om({emails:t,saveTimeoutMs:o}),i=new Map,a=(c,d)=>u=>{const p=u?.id??d;return(typeof p=="string"||typeof p=="number")&&i.set(String(p),c),u};return Zd(e,{...s,createEmail:c=>s.createEmail(c).then(a(Date.now())),updateEmail:(c,d)=>s.updateEmail(c,d).then(a(Date.now(),c))}),ru(e,sm({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const d=await ue(e,Hi).fire(c);return d.length===0?{asked:!1}:{asked:!0,revision:d[0]??null}},savedAt:async c=>{const d=bd((await t.cache.getIfPresent(c))?.modified),u=i.get(String(c))??NaN;return Number.isFinite(u)&&!(d>=u)?u:d},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:o,integratorProject:()=>vt(e).requested})),Bi(e).addDisposable(t.onSave(({prev:c,patch:d,value:u})=>hm(c,d,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Gi(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 Em(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var _m="po",on=null;function bm(){const e=typeof __emailmaker__<"u"?__emailmaker__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([_m],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Sm(){return on===null&&(on=bm().catch(e=>{throw on=null,e})),on}async function Wi(e){if(typeof e=="object")return Ir(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?ym(t):wm(t)}function Ir(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function ym(e){try{return Ir(JSON.parse(e))}catch{return}}var Yi=!1;async function wm(e){try{return Ir((await Sm()).parsePoCatalog(e))}catch{Yi||(Yi=!0);return}}var Im="em_locale",Tm="em_ant_locale",Cm="locale",Am="ant_locale";function Tr(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function qi(e,t){const n=Tr(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Dm(){return Tr("em_locale")??qi(Cm,"em_locale")}function Ki(e){try{localStorage.setItem(Im,JSON.stringify(e))}catch{}}function Pm(){return Tr("em_ant_locale")??qi(Am,"em_ant_locale")}function Om(e,t){try{localStorage.setItem(Tm,JSON.stringify({id:e,data:t}))}catch{}}var bS="en_US",Rm=8e3;function km(e,t){const n=e,r=t,o=Object.keys(n).filter(s=>s!=="");return o.length!==Object.keys(r).filter(s=>s!=="").length?!1:o.every(s=>JSON.stringify(n[s])===JSON.stringify(r[s]))}function Nm(e){const t=Dm(),n=Pm();let r={ready:!1},o;const s=fe(r);let i=0;const a=v=>{r={...r,...v},s.set(r)},c=()=>{r.ready||a({ready:!0})},d=setTimeout(c,e.unlockAfterMs??Rm),u=v=>v!==i;let p;async function m(v,b){if(n?.id===v&&n.data&&a({antd:n.data}),!p)return;const D=await p(v).catch(()=>{});!D||u(b)||(a({antd:D}),Om(v,D))}async function h(v,b){const D=await e.askHost(v).catch(()=>null);if(u(b))return!0;if(D==null)return!1;const j=await Wi(D);return u(b)||(j&&a({catalog:j}),c()),!0}async function _(v,b){const D=await e.readList();if(u(b))return;if("error"in D){a({failure:{kind:"GET_LOCALES_ERROR",error:D.error}}),c();return}const j=D.data.find(C=>C.locale===v);if(!j){Em("em_locale")&&a({catalog:void 0}),c();return}if(Gi(t,j)&&(!o||o.catalog===t?.data)){c();return}if(o?.entry&&r.catalog===o.catalog&&Gi(o.entry,j)){Ki(o.entry),c();return}const x=await e.readCatalog(v);if(!u(b)){if("error"in x){a({failure:{kind:"GET_LOCALE_ERROR",error:x.error}}),c();return}x.data&&(o?.id===v&&r.catalog===o.catalog&&km(o.catalog,x.data)||a({catalog:x.data}),Ki({id:v,time:j.updatedAt||Math.floor(Date.now()/1e3),hash:j.contentHash,data:x.data})),c()}}async function S(v,b){if(!await h(v,b)){if(!u(b)&&(o?.id===v&&r.catalog===o.catalog||v==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await _(v,b)}}return{set(v){if(!v||v===r.id)return;const b=i+=1;a({id:v,failure:void 0});const D=o?.id===v&&r.catalog===o.catalog;(o&&!D&&r.catalog===o.catalog||v==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===v&&t.data&&(a({catalog:t.data}),c()),m(v,b),S(v,b)},prime(v,b,D){r.id&&r.id!==v||r.catalog||!b||(o=t?.id===v&&t.data&&(!D||t.time>=D.time)?{id:v,catalog:t.data}:{id:v,catalog:b,entry:D?{id:v,time:D.time,hash:D.hash,data:b}:void 0},a({catalog:o.catalog}))},useAntdLoader(v){p=v,r.id&&m(r.id,i)},state:s,snapshot:()=>r,dispose:()=>clearTimeout(d)}}var Lm=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})},zi=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),Mm=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:o,format:s,baseUrl:i,cancelToken:a,...c})=>{const d=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,d),p=o&&this.toQueryString(o),m=this.contentFormatters[r||"application/json"],h=s||u.format;return this.customFetch(`${i||this.baseUrl||""}${n}${p?`?${p}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):u.signal)||null,body:typeof e>"u"||e===null?null:m(e)}).then(async _=>{const S=_;S.data=null,S.error=null;const v=h?_.clone():_,b=h?await v[h]().then(D=>(S.ok?S.data=D:S.error=D,S)).catch(D=>(S.error=D,S)):S;return a&&this.abortControllers.delete(a),b})}},xm=l.createIdentifier$1("rest.v2.transport"),Xi=Symbol("rest.v2.secureRequest");function Fm(e){return e.getOrCreateInstance(xm,()=>{const t=e.getInstance(l.CUSTOM_FETCH_ID)?.execute||fetch;return new Mm({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[Xi]:!0}),customFetch:(n,r={})=>{const{[Xi]:o,...s}=r;return t(n,{...s,[l.PUBLIC_REQUEST]:o!==!0})}})})}function Ji(e,t){const n=Fm(e);return Object.assign({},...t.map(r=>new r(n)))}function Qi(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function sn(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Qi(n.details,"wp_code")??n.code,message:Qi(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 Zi(e){return!e.ok||!!e.error}function ea(){return Ho(l.LOCAL_STORAGE_ITEMS.em_translations_v2)??!0}function Bm(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function jm(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Um(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],o=r[0];return typeof o=="string"&&o!==""&&t.push({locale:o,updatedAt:Bm(r[1])}),t},[]):[]}function $m(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:jm(n.updated_at),contentHash:n.content_hash}),t),[])}function ta(e){return Ji(e,[Lm])}function an(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Cr(e){return!e.ok||e.error!=null}function Ar(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Dr(e){return{data:await Wi(e)??null}}async function Hm(e){if(ea())try{const n=await ta(e).localesList();return Zi(n)?{error:sn(n)}:{data:$m(n.data)}}catch(n){return an(n)}const t=l.getApi(e,[Do]);try{const n=await t.get_translations2({file:"react_app"});return Cr(n)?Ar(n):{data:Um(n.data)}}catch(n){return an(n)}}async function Vm(e,t){if(ea())try{const r=await ta(e).jsonList({locale:t});return Zi(r)?{error:sn(r)}:Dr(r.data)}catch(r){return an(r)}const n=l.getApi(e,[Do]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Cr(r)?Ar(r):Dr(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Cr(r)?Ar(r):Dr(r.data)}catch(r){return an(r)}}}var ln=new WeakMap;function Gm(e){const t=ln.get(e);if(t!==void 0)return t;const n=Hm(e).then(r=>("error"in r&&ln.delete(e),r),r=>{throw ln.delete(e),r});return ln.set(e,n),n}var Ze=l.createIdentifier$1("locale.service");function Wm(e){if(e.getInstance(Ze))return;const t=Nm({readList:()=>Gm(e),readCatalog:n=>Vm(e,n),askHost:async n=>(await ue(e,l.events.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(l.SECURITY_MODULE_ID)});e.inject(Ze,t),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>t.dispose())}function Ym(e){const t=e.getInstance(l.CONFIG_SOURCE_ID);if(!t)return;const n=e.getInstance(Ze);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"ru_RU"));e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r)}var qm="user_id",Km="project_id",na=l.createIdentifier$1("rest.identityHeadersProvided");function zm(e){if(e.getInstance(na))return;e.inject(na,!0);let t;e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(n=>{t=n}),e.addService(l.REQUEST_HANDLER_ID,{execute(n,r){if(r?.public)return;const o=t?.user?.id??Os(e).profile?.id;o!=null&&o!==""&&n.headers.set(qm,String(o));const s=t?.project;s!=null&&s!==""&&n.headers.set(Km,String(s))}})}function Xm(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function Jm(e){return e.id??Xm(e.catalog)}function Qm(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function Zm(e){return Qm(e||"en_US")}var eg="Accept-Language",ra=l.createIdentifier$1("rest.localeHeaderProvided");function tg(e){e.getInstance(ra)||(e.inject(ra,!0),e.addService(l.REQUEST_HANDLER_ID,{execute(t){const n=e.getInstance(Ze)?.snapshot();t.headers.set(eg,Zm(n&&Jm(n)))}}))}function ng(e){if(!e)return!1;try{return e.getInstance(l.SECURITY_MODULE_ID)!==void 0}catch{return!1}}var rg="Invalid standaloneKey.",SS=l.createIdentifier$1("StandaloneMockGuard");function og(){const e=new Error(rg);return e.name="InvalidStandaloneKeyError",e}function sg(e){e.addService(l.REQUEST_HANDLER_ID,{execute:()=>{if(ng(e))throw og()}})}function ig(e){l.registerRestTransport(e),sg(e)}function ag(e){const t=new ei;e.inject(l.INIT_PIPELINE_ID,t);const n=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(o=>{if(!o)return;const s=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...s!==void 0?{signal:s}:{}})}),r=e.getInstance(l.DISPOSABLE_ID);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var oa=gt("plugin.dataSource.blocks"),lg=gt("plugin.dataSource.blockRevisions"),cg=gt("plugin.dataSource.comments"),dg=Kt(),ug=Kt(),sa=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2109
+ `));return{html:Mp(t.html),hasBrowserExtensionArtifacts:t.found}}function Et(e){return e?.getContent()??""}function Di(e,t){e?.mutate({content:or(t)},{source:"remote"})}function sn(e){return c.createIdentifier$1(e)}function fe(e,t){return e.getOrCreateInstance(t,()=>new c.AsyncEmitter)}function Q(e,t){return e.getOrCreateInstance(t,()=>new c.AsyncEmitter).event}function on(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var xp=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 Fp(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 Bp(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(c.throwIfAborted(n),new Promise((r,s)=>{let o=!1,i,a;const l=u=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),a?.dispose(),n?.removeEventListener("abort",d),u())},d=()=>{l(()=>s(c.createAbortError(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(i=setTimeout(()=>{l(()=>s(new xp(t)))},t)),n?.addEventListener("abort",d)}))}var jp=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 Up(e,t,n){return t<=0?e:new Promise((r,s)=>{let o=!1,i;const a=l=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),l())};i=setTimeout(()=>{a(()=>s(new jp(n,t)))},t),e.then(l=>{a(()=>r(l))},l=>{a(()=>s(l))})})}var $p=2,_t=Symbol("sandbox:frame-replaced");function Pi(e){return e===_t}function Be(e,t,n,r,s,o,i){const a=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??Xn[t],d=()=>{let _=Up(e.sendAsync(n,r),l,a);return _=c.raceWithAbortSignal(_,o?.signal),Me(a,_,s)};if(t==="INIT_START"&&Fp(e)){const _=o?.getSandboxReadyTimeoutMs()??2e4,y=e,v=b=>{const O=Bp(y,_,o?.signal);return Me("sandbox:INIT_START:ready-wait",O,s).then(()=>{if(!i||b<=0)return d();const j=i.getGeneration();let x;const C=new Promise((R,A)=>{x=i.onChange(()=>{i.getGeneration()!==j&&A(_t)})}),I=d();return I.catch(()=>{}),Promise.race([I,C]).finally(()=>x?.()).catch(R=>{if(R!==_t)throw R;return{...s},v(b-1)})})};return v($p)}if(!i)return d();const u=i.getGeneration();let p;const h=new Promise((_,y)=>{p=i.onChange(()=>{i.getGeneration()!==u&&y(_t)})}),m=d();return m.catch(()=>{}),Promise.race([m,h]).finally(()=>p?.()).catch(_=>{throw _===_t&&{...s},_})}var Ri="self-init:";function Vp(e){return e.startsWith(Ri)}function wr(e,t){const n=e.getActiveShowRequest();return Vp(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Hp(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),s=()=>e.frameWatch?.();let o="",i;const a=_=>{i={target:e.readTarget?.(),docId:_}},l=()=>e.readDocument()?Et(e.readDocument()):o,d=()=>De(e.container).editorPolicy,u=()=>e.readEmail(),p=()=>{const _=u();return{..._,id:e.isTemplate()||_.isNew?void 0:_.id,html:l()}};let h=!1;const m={readContent:l,publicEmail:p,sendInitStart:()=>Be(n,"INIT_START",c.EVENT_TYPES.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>Be(n,"INITED",c.EVENT_TYPES.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),s()),async sendContent(){const _=u(),{html:y,hasBrowserExtensionArtifacts:v}=Oi(_?.html||"");v&&e.events.browserExtensionDetected(),Di(e.readDocument(),y),o=y,a(_.renderGuid),await Be(n,"SET_ENTITY",c.EVENT_TYPES.SANDBOX_SET_ENTITY,on(l(),_.renderGuid,d(),e.readDocument()?.get().version),{guid:_.renderGuid,emailId:_.id??null},r(),s())},refreshContent:()=>(a(u().renderGuid),Be(n,"SET_ENTITY",c.EVENT_TYPES.SANDBOX_SET_ENTITY,on(l(),u().renderGuid,d(),e.readDocument()?.get().version),void 0,r(),s())),sendPreheader:async()=>{const _=u();if(_.preheader!==void 0)return Be(n,"PREHEADER",c.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:_.preheader,guid:_.renderGuid,force:!0},void 0,r(),s())},sendSubject:async()=>{const _=u();if(_.subject!==void 0)return Be(n,"SUBJECT",c.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:_.subject,guid:_.renderGuid,force:!0},void 0,r(),s())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:_=>e.showFilled?.(_),noteFilled:(_,y)=>e.noteFilled?.(_,y),contentSent:()=>i,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(p()),fireInit(_,y){if(!wr(t(),_)){t().getActiveShowRequest()?.showId;return}const v=u();v.id,v.renderGuid,t().completeShow(_);const b=e.readDocument();Qe(b,{is_inited:!0},{source:"system"});const O=()=>{const x=p();y&&(x.reset=!0);const C=e.events.inited(x);return y||(h&&m.fireEmailChanged(),h=!0),C};if(!b||b.isReady())return O();const{docId:j}=b.get();return b.whenReady().then(()=>e.readDocument()?.get().docId===j?O():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(p())},fireContentChanged(){e.events.contentChanged(l())}};return m}var Gp=class extends Error{showId;constructor(e,t){super(`[emailmaker] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},Wp=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(c.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(c.createAbortError(n.reason)):(this._activeRequest=e,new Promise((r,s)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{s(new Gp(e.showId,t))})},t);o.unref?.();const i=()=>{this._settle(e.showId,()=>{s(c.createAbortError(n.reason))})};n.addEventListener("abort",i,{once:!0});const a=()=>{clearTimeout(o),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:s,timeoutId:o,dispose:a});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Yp(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function qp(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=co(e),n=lo(e),r=Ed(e.sandbox);t<n+r}var ki=class{_controller=new AbortController;_externalSignalDisposable=new c.Disposable;_sessionChangeListeners=new Set;_showRegistry=new Wp;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return co(this._timeouts)}getSandboxTimeoutMs(e){return ao(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return lo(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=Yp(this._timeouts,e.timeouts),qp(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new c.Disposable,this._linkExternalSignal(e)}abort(e){const t=e??c.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new c.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new c.Disposable,this._showRegistry.rejectAll(c.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(c.createAbortError("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??c.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??c.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Ir=(()=>{const e=new ki;return e.configure({}),e})();function je(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function Ue(e){return!e||e==="none"}function Kp(e){const t=e.contain??"",n=e.willChange??"";return!Ue(e.transform)||!Ue(e.perspective)||!Ue(e.filter)||!Ue(e.backdropFilter)||!Ue(e.translate)||!Ue(e.rotate)||!Ue(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Ni(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function zp(e){const t=[],n=document.documentElement,r=Ni(getComputedStyle(n)),s=r.x||r.y;let o="none";const i=getComputedStyle(e).position;(i==="absolute"||i==="fixed")&&(o=i);for(let a=je(e);a&&a!==n;a=je(a)){const l=getComputedStyle(a),d=o==="none"||Kp(l)||o==="absolute"&&!!l.position&&l.position!=="static",u=a===document.body&&!s;if(d){o="none";const p=u?{x:!1,y:!1}:Ni(l);(p.x||p.y)&&t.push({node:a,...p})}(l.position==="absolute"||l.position==="fixed")&&(o==="none"||l.position==="fixed")&&(o=l.position==="fixed"?"fixed":"absolute")}return t}function Li(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function an(e){return Number.parseFloat(e)||0}function Tr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=Li(e),s=an(n.borderLeftWidth),o=an(n.borderTopWidth),i=an(n.borderRightWidth),a=an(n.borderBottomWidth),l=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-s-i):0,d=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-o-a):0;return{left:t.left+s*r.x,top:t.top+o*r.y,right:t.right-(i+l)*r.x,bottom:t.bottom-(a+d)*r.y}}function Xp(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},s=(o,i,a)=>{i&&(r.left=Math.max(r.left,o.left),r.right=Math.min(r.right,o.right)),a&&(r.top=Math.max(r.top,o.top),r.bottom=Math.min(r.bottom,o.bottom))};return t.forEach(o=>s(Tr(o.node),o.x,o.y)),n&&s(Tr(n),!0,!0),r}var Cr={originX:0,originY:0,scaleX:1,scaleY:1};function cn(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function Mi(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,s=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*s,scaleX:r,scaleY:s}}function xi(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var Jp=1e3;function Qp(e){const{slot:t,own:n}=e;let r,s=0,o=!1;const i=()=>{if(r=void 0,!o){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<s)&&(r=window.requestAnimationFrame(i))}},a=()=>{!o&&r===void 0&&(r=window.requestAnimationFrame(i))},l=()=>{s=performance.now()+Jp,a()},d=[window],u=[document.documentElement];for(let v=t;v;v=je(v)){const b=v.getRootNode();b instanceof ShadowRoot&&!d.includes(b)&&(d.push(b),u.push(b))}const p=[["scroll",a],["load",a],["transitionrun",l],["transitionend",a],["transitioncancel",a],["animationstart",l],["animationend",a],["animationcancel",a]];d.forEach(v=>p.forEach(([b,O])=>v.addEventListener(b,O,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const h=typeof MutationObserver=="function"?new MutationObserver(v=>{v.some(b=>!n.contains(b.target))&&a()}):void 0;u.forEach(v=>h?.observe(v,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let m;try{if(typeof ResizeObserver=="function"){const v=new ResizeObserver(a);typeof v.observe=="function"&&(m=v)}}catch{m=void 0}let _=[];return{schedule:a,observe:v=>{!m||v.length===_.length&&v.every((b,O)=>b===_[O])||(m.disconnect(),_=v,v.forEach(b=>m?.observe(b)))},dispose(){o=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),d.forEach(v=>p.forEach(([b,O])=>v.removeEventListener(b,O,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),h?.disconnect(),m?.disconnect()}}}var Zp="pluginZoom",eh=/^(?:ant|vscode|monaco|docs)-/;function th(e){return eh.test(e)}function nh(){const e="em".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var rh=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function sh(){return rh}var oh=new Set;function ih(e,t,n=oh){return e.startsWith(`${t}-`)?!1:!th(e)&&!n.has(e)}function ah(e,t){return`--${t}-${e}`}function Fi(e){const t=nh();return ih(e,t,sh())?ah(e,t):`--${e}`}function ch(e,t){const n=Fi(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function Bi(e,t){return ch(e,t)}var ji=300,Ui=15e3,lh=5e3,$i="em-canvas-busy-style";function dh(){if(document.getElementById($i))return;const e=document.createElement("style");e.id=$i,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var uh="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function fh(e){const t=Bi("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(Fi("colorPrimary")).trim()||t}function Vi(e){dh();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",uh),n.appendChild(r);const s=document.createElement("span");return s.setAttribute("role","img"),s.setAttribute("aria-label","loading"),s.setAttribute("style",`display:inline-flex;color:${fh(e)};animation:em-canvas-busy-spin 1s linear infinite`),s.appendChild(n),s}function ph(e,t,n){const r=t??e,s=Math.max(r.left,e.left,0),o=Math.min(r.right,e.right,n.width),i=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return o<=s||a<=i?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(s+o)/2-e.left,y:(i+a)/2-e.top}}function hh(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const s={left:n.left,top:n.top,right:n.right,bottom:n.bottom},o=r.getBoundingClientRect();if(o.width>0&&!xi({left:o.left,top:o.top,width:o.width,height:o.height},s)){const i=cn(s,Mi(o,cn(s,Cr),Cr));Object.assign(r.style,{left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const i=ph(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(Vi(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Ar(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(Vi(e))},ji);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var mh=8e3;function gh(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function vh(e,t){for(let n=je(e);n;n=je(n)){const r=getComputedStyle(n),s=r.overflowX!=="visible"||r.overflowY!=="visible",o=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(i=>nt(i)>0);if(s&&o)return n;if(n===t)return null}return null}function nt(e){return Number.parseFloat(e)||0}function ln(e,t){return Math.abs(e-t)<=1}function Eh(e){const t=getComputedStyle(e),n=nt(t.borderTopWidth),r=nt(t.borderRightWidth),s=nt(t.borderBottomWidth),o=nt(t.borderLeftWidth),i=(a,l,d)=>Math.max(0,nt(a)-Math.max(l,d));return{...Tr(e),radii:[i(t.borderTopLeftRadius,n,o),i(t.borderTopRightRadius,n,r),i(t.borderBottomRightRadius,s,r),i(t.borderBottomLeftRadius,s,o)]}}function _h(e,t){const n=ln(t.top,e.top),r=ln(t.bottom,e.bottom),s=ln(t.left,e.left),o=ln(t.right,e.right),i=[n&&s?e.radii[0]:0,n&&o?e.radii[1]:0,r&&o?e.radii[2]:0,r&&s?e.radii[3]:0];return i.every(a=>a===0)?"":i.map(a=>`${a}px`).join(" ")}function bh(e,t,n,r,s,o){const i=n.readyTimeoutMs??mh,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden",a.style.setProperty("zoom",Bi(Zp,"1"));const l=n.resolveSrc(e),d=document.createElement("iframe");d.setAttribute("sandbox",n.resolveSandbox(l)),d.setAttribute("allow","clipboard-read; clipboard-write"),d.setAttribute("title","Email content"),d.style.width="100%",d.style.border="0",d.style.display="block",d.style.minHeight="600px",d.src=l,a.appendChild(d),t.appendChild(a),n.mark?.("created"),s||n.onCreated?.(d);const u=new c.Disposable;let p=!1,h,m=!1,_,y,v,b;const O=()=>{clearTimeout(b),b=setTimeout(()=>{m||(m=!0,y?.(new Error(`[canvas] ${e}: документ не загрузился за ${i} мс`)))},i)},j=()=>p?(v=Promise.resolve(),m=!0,v):(m=!1,v=new Promise((f,g)=>{_=f,y=g}),O(),v),x=()=>{if(clearTimeout(b),p=!0,m){v=Promise.resolve();return}m=!0,n.mark?.("loaded"),_?.()};d.addEventListener("load",x),u.addDispose(()=>{clearTimeout(b),d.removeEventListener("load",x)});let C;const I=()=>{C??=n.bindResizer?.(d)},R=()=>{C?.dispose(),C=void 0};let A=null,P=null,L,S=Cr,D="",k="",F=0;const E=f=>{const g=JSON.stringify(f);return g===D?!1:(D=g,a.style.visibility=f.visibility,a.style.left=`${f.css.left}px`,a.style.top=`${f.css.top}px`,a.style.width=`${f.css.width}px`,a.style.height=`${f.css.height}px`,a.style.borderRadius=f.radius,d.style.width=f.elementWidth>0?`${f.elementWidth}px`:"100%",d.style.transform=f.shiftX!==0?`translate(${f.shiftX}px, ${f.shiftY}px)`:`translateY(${f.shiftY}px)`,!0)};let w=!1;const B=()=>{if(!A)return D="",a.style.visibility="hidden",d.removeAttribute("id"),!1;n.elementId&&(d.id=n.elementId);const f=A.getBoundingClientRect(),g=zp(A),T=P?.isConnected?P:null;L?.observe([A,d,...g.map(oe=>oe.node),...T?[T]:[]]);const M=Xp(f,g,T),$=Math.max(0,M.right-M.left),Y=Math.max(0,M.bottom-M.top),H=getComputedStyle(A).visibility==="visible",G=$<=0||Y<=0,Z=G?{left:M.left,top:M.top,right:M.left,bottom:M.top}:M,N=G?null:vh(A,T??g[0]?.node??null),z=N?_h(Eh(N),Z):"",X=oe=>E({visibility:H&&!w?"":"hidden",css:cn(Z,oe),elementWidth:f.width/oe.scaleX,shiftX:(f.left-Z.left)/oe.scaleX,shiftY:(f.top-Z.top)/oe.scaleY,radius:z});let ee=X(S);if(!G){const oe=a.getBoundingClientRect();oe.width>0&&!xi({left:oe.left,top:oe.top,width:oe.width,height:oe.height},Z)&&(S=Mi(oe,cn(Z,S),S),ee=X(S)||ee)}return ee},U=()=>{if(!A)return!1;let f=B();const g=d.getBoundingClientRect().height;g>0&&g!==F&&(F=g,A.style.height=`${g/Li(A).y}px`,f=!0);const T=getComputedStyle(A).pointerEvents;return T!==k&&(k=T,a.style.pointerEvents=T),f},W=()=>{L?.dispose(),L=void 0},ae=f=>{L=Qp({slot:f,own:a,measure:U,onDetached:W})};let re=[];const q=(f,g)=>{if(P=g,f&&re.length>0){const T=re;re=[],T.forEach(M=>M())}if(f===A){f&&!L&&ae(f),U();return}if(W(),A&&A.style.removeProperty("height"),D="",F=0,k="",A=f,!f){B(),R();return}n.onShown?.(d),ae(f),U(),I()};u.addDispose(W);const K=f=>{p=!1,h=void 0,o?.(),f&&n.onReload?.(d);let g;m||v===void 0?g=j():(O(),g=v);try{d.contentWindow?.location.reload()}catch{d.src=l}return g};return{element:d,ready(){return v??j()},reload:()=>K(!0),reloadQuietly:()=>K(!1),followReload:()=>{h=void 0,o?.(),n.onReload?.(d)},moveTo(f){if(a.parentNode===f)return v??j();p=!1,h=void 0,o?.();let g;return m||v===void 0?g=j():(O(),g=v),f.appendChild(a),n.onReload?.(d),D="",L?.schedule(),g},get shown(){return A!==null},get slot(){return A},whenShown(){return A!==null?Promise.resolve():new Promise(f=>{re.push(f)})},get filled(){return h},noteFilled(f){h=f},alignTo(f,g){q(f,g??null)},hold(f){w!==f&&(w=f,B())},scrollBy(f,g){let T=f,M=g;for(let $=A?je(A):null;$;$=je($)){if(Math.abs(T)<1&&Math.abs(M)<1)return;const Y=getComputedStyle($);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&$.scrollHeight>$.clientHeight){const H=$.scrollTop,G=$.scrollLeft;$.scrollBy({left:T,top:M,behavior:"instant"}),T-=$.scrollLeft-G,M-=$.scrollTop-H}}(Math.abs(T)>=1||Math.abs(M)>=1)&&window.scrollBy({left:T,top:M,behavior:"instant"})},resize(){C?.resize()},dispose(){q(null,null),R(),u.dispose(),a.remove()}}}function yh(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",s=(S,D)=>S==="email"?`email:${D??n}`:S,o=new Map;let i,a=[],l=!1,d,u,p=!1,h,m,_="shown",y=0,v,b,O;const j=S=>u!==void 0&&S.filled!==void 0&&S.filled!==u,x=()=>{v=void 0;const S=h;!p||!S||u===void 0||b===u||!j(S)||(b=u,e.onForeignDocument?.({wanted:u,filled:S.filled,role:_,heldMs:Date.now()-y}))},C=()=>{p=!1,h=void 0,m=void 0,clearTimeout(v),v=void 0},I=(S,D)=>{const k=o.get("email"),F=k?.slot??null;return S&&F&&j(S)?(S.alignTo(null),p||(p=!0,y=Date.now(),v=setTimeout(x,lh)),_=D,h=S,!(i!==void 0||l)&&m!==S&&(m=S,e.onShown?.(S.element)),!d&&!i&&(d=Ar(F)),!1):(p&&(C(),d?.remove(),d=void 0),S?.alignTo(F,k?.clip??null),!0)},R=()=>{p&&!l&&I(t.get(s("email")),"shown")},A=()=>{a.forEach(S=>clearTimeout(S)),a=[],i?.remove(),i=void 0,d?.remove(),d=void 0,(l||p)&&(l=!1,I(t.get(s("email")),"shown"))},P=(S,D,k)=>{const F=s(S,D),E=t.get(F);if(E)return E;const w=e.resolveMount();if(!w)return gh();const B=bh(S,w,e,S==="email"?D??n:void 0,k,S==="email"?()=>R():void 0);return t.set(F,B),B},L={get:S=>P(S),current:S=>P(S),peek:S=>t.get(s(S)),spare:()=>t.get(s("email",r())),ensureSpare:()=>P("email",r(),!0),promote(){const S=t.get(s("email",r()));if(!S)return;const D=t.get(s("email"));n=r(),O=void 0,I(S,"spare"),D?.alignTo(null)},alignSurface(S,D,k){const F=o.get(S);if(o.set(S,{slot:D,clip:k??null}),S==="email"&&l){d?.remove(),d=D?Ar(D):void 0;return}const E=D?P(S):t.get(s(S));if(S!=="email"){E?.alignTo(D,k??null);return}if(!D){O=F?.slot&&E?.shown?{slot:F.slot,handle:E}:void 0,p&&(C(),d?.remove(),d=void 0),E?.alignTo(null);return}const w=O?.slot===D&&O.handle===E;if(O=void 0,F?.slot===D&&E?.shown||w){E?.alignTo(D,k??null);return}I(E,"shown")},want(S){u=S,S!==void 0&&R()},noteFilled(S,D){const k=L.byWindow(S);k&&(k.noteFilled(D),k===t.get(s("email"))&&R())},visible(){for(const S of t.values())if(S.shown)return S},byWindow(S){if(S){for(const D of t.values())if(D.element.contentWindow===S)return D}},busy(S){if(A(),!S)return;if(!L.visible()){l=!0,d?.remove(),d=void 0;const F=o.get("email");F?.slot&&(d=Ar(F.slot)),a=[setTimeout(A,Ui)];return}const D=e.resolveMount();if(!D)return;const k=hh(D,()=>L.visible()?.element.parentElement?.getBoundingClientRect()??null);i=k,a=[setTimeout(()=>k.showSpinner(),ji),setTimeout(A,Ui)]},remount(S){A();const D=s("email");t.forEach((k,F)=>{if(F===D){k.moveTo(S).catch(()=>{});return}k.dispose(),t.delete(F)})},dispose(){u=void 0,l=!1,C(),O=void 0,A(),t.forEach(S=>S.dispose()),t.clear(),o.clear(),n="a",u=void 0,b=void 0}};return L}var Sh=c.createIdentifier$1("canvas.resizerBinder"),Or=c.createIdentifier$1("canvas.service"),wh={created:de.canvasCreated,loaded:de.canvasLoaded},Hi=new WeakMap;function Dr(e){return Hi.get(e)??0}function Ih(e,t){if(e.getInstance(Or))return;const n=yh({resolveMount:()=>t.resolveMount(),resolveSrc:s=>t.resolveSrc(s),resolveSandbox:up,elementId:t.elementId,bindResizer:s=>e.getInstance(Sh)?.(s),onCreated:s=>bt(e,s,"fresh"),onReload:s=>{Hi.set(s,Dr(s)+1),bt(e,s,"fresh")},onShown:s=>{const o=n.byWindow(le(e).getTarget());o&&o.element!==s&&Gi(o.element)===Gi(s)||bt(e,s,"switch")},mark:s=>t.mark?.(wh[s]),onForeignDocument:s=>{({...s},Nd("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:s.role},contexts:{canvasIdentity:{...s,path:window.location.pathname}}}))}}),r=le(e).addListener(c.EVENT_TYPES.SANDBOX_WHEEL,s=>{n.visible()?.scrollBy(s?.deltaX??0,s?.deltaY??0)});e.inject(Or,n),e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),n.dispose()})}function Gi(e){return e.parentElement?.dataset.canvasHost}function bt(e,t,n){const r=le(e),s=t.contentWindow;if(!s)return;const o=r.getTarget()===s;o&&n==="switch"||(n==="fresh"&&(r.forget(s),o&&r.setTarget(void 0)),r.setTarget(s),Sd(r))}function Th(e,t){bt(e,t,"promote")}function Ch(e,t){bt(e,t,"switch")}function Ah(e,t){const n=t.contentWindow;n&&le(e).greet(n)}function Wi(e,t){const n=t.contentWindow;n&&le(e).forget(n)}function Oh(e,t){const n=ce(e)?.byWindow(t)?.element;if(!n)return;const r=Dr(n);return()=>Dr(n)!==r}function ce(e){return e.getInstance(Or)}function Yi({attributes:e,readContent:t,docId:n,hasSession:r,serverId:s,show:o}){if(!r)return;const i={id:s??void 0,renderGuid:n,showId:o?.id,isNew:s==null,showToken:o?.token},a={...e,...i};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function dn(e){return{...Yi({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function un(e){const t=ue(e),n=t.current();if(!n||!J(t.sessionKey()))return;const r=dn(n),s=n.isDirty();fe(e,c.events.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:s})}function Dh(e){const t=ue(e);return!t.current()||!J(t.sessionKey())?!1:(un(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Ph(e){const t=ue(e),n=le(e),r=()=>e.getInstance(c.INIT_PIPELINE_ID)??Ir;let s,o,i=!1,a=!1,l,d;const u=k=>dn(k),p=()=>{const k=j(),F=k?.get().docId;if(!k||!F||F!==l||i)return;const E=k.get().version;E!==d&&(d=E,fe(e,c.events.ON_BLOCK_CHANGED_ID).fire(u(k)))};let h;const m=k=>{const F=t.showFacts();!F||F.id===h||!wr(k,F.id)||(h=F.id,k.completeShow(F.id))},_=async(k,F,E)=>{const w=E.generation,B=()=>E.generation!==w||E.signal.aborted||t.current()!==k||a,U=me(n);let W;const ae=new Promise(q=>{W=Gt(n,()=>q("regenerated"))}),re=async(...q)=>await Promise.race([Be(...q).then(()=>"sent"),ae])==="sent";i=!0;try{if(!await re(n,"INIT_START",c.EVENT_TYPES.SANDBOX_INIT_START,{guid:F},void 0,E)||B())return;const{html:q,hasBrowserExtensionArtifacts:K}=Oi(Et(k));if(K&&fe(e,c.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Di(k,q),!await re(n,"SET_ENTITY",c.EVENT_TYPES.SANDBOX_SET_ENTITY,on(Et(k),F,De(e).editorPolicy,k.get().version),void 0,E)||B()||!await re(n,"INITED",c.EVENT_TYPES.SANDBOX_INITED,{guid:F},void 0,E)||B())return;s=F,o=U,x(),d=k.get().version,l!==F&&(l=F,fe(e,c.events.ON_BLOCK_INIT_ID).fire(u(k))),m(E)}finally{W?.(),i=!1,me(n)!==U&&R()}};let y,v,b;const O=()=>{const k=ce(e)?.peek("block");return k?.reload?(k.reload().catch(()=>{}),!0):!1},j=()=>J(t.sessionKey())?t.current():void 0,x=()=>{const k=j()?.get().docId,F=!k||b===k||s===k&&o===me(n);ce(e)?.peek("block")?.hold(!F)},C=()=>{if(a||(x(),p(),i))return;const k=j(),F=k?.get().docId;if(!k||!F)return;if(s===F&&o===me(n)){m(r());return}if(!k.isReady())return;const E=r();E.signal.aborted||s!==void 0&&s!==F&&y!==F&&(y=F,O())||_(k,F,E).catch(()=>{if(!(a||t.current()!==k)){if(v!==F){v=F,O();return}b=F,x()}})};let I=!1;const R=()=>{I||a||(I=!0,queueMicrotask(()=>{I=!1,C()}))};let A,P;const L=()=>{const k=j(),F=k?.get().docId;F!==P&&(A?.(),P=F,A=k?.subscribe(R)),x(),R()},S=t.subscribe(L),D=Gt(n,()=>{x(),R()});L(),e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{a=!0,D(),A?.(),S()})}function Rh(e){const t=ue(e);let n="email";const r=()=>{if(!t.current())return;const o=J(t.sessionKey())?"block":"email",i=ce(e);if(o===n||!i)return;n=o;const a=i.peek(o);if(a){Ch(e,a.element);return}i.get(o)},s=t.subscribe(r);e.getInstance(c.DISPOSABLE_ID)?.addDispose(s)}var kh=200;function Nh({startVersion:e,limit:t=kh}){let n=[],r=e;const s=o=>{n=n.filter(i=>i.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&s(n[n.length-t-1].version))},rebase(o,i){if(i<r)return null;const a=n.filter(d=>d.version>i);s(i);let l=o;for(const d of a){if(d.contentReplaced||!d.changes)return null;const u=d.changes,p=[];for(const h of l){if(d.fromCanvas&&u.some(_=>h.range.start<=_.oldEnd&&h.range.end>=_.oldPosition))return null;const m=Vd(h.range,u,"after");if(!m)return null;p.push({range:m,text:h.text})}l=p}return l}}}function Lh(e,t){let n=0;return e.map(({start:r,end:s,text:o})=>{const i=new _e(r,t.slice(r,s),r+n,o);return n+=o.length-(s-r),i})}function Mh(e,t){const n=[...e].sort((r,s)=>r.range.start-s.range.start);return Lh(n.map(({range:r,text:s})=>({start:r.start,end:r.end,text:s})),t)}function xh(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Fh=32;function Bh(e=Fh){const t=new Map;return{find(n,r){const s=t.get(n);return s&&Qn(s.scope,r)?s.echo:void 0},remember(n,r,s){t.delete(n),t.set(n,{scope:r,echo:s}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>Qn(r.scope,n)).map(r=>r.echo)}}}function jh(e,t){const n=c.findTextDiffBounds(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var Pr=c.createIdentifier$1("canvas.sandboxFill");function qi(e){return e.getInstance(Pr)?.pipeline.isEventsLocked()===!0}var vw=.2,Uh=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,$h=/<\/?[a-zA-Z]/g;function Ki(e){return e.match($h)?.length??0}function zi(e){return[...e.matchAll(Uh)].map(t=>[t.index,t.index+t[0].length])}function Rr(e,t,n){let r=0,s=0;for(const[o,i]of n){for(;s<t.length&&t[s][1]<=o;)s++;let a=o;for(let l=s;l<t.length&&t[l][0]<i;l++)r+=Ki(e.substring(a,Math.max(a,t[l][0]))),a=Math.max(a,t[l][1]);r+=Ki(e.substring(Math.min(a,i),i))}return r}function Vh(e,t){const n=[...t].sort((l,d)=>l.oldPosition-d.oldPosition||l.oldEnd-d.oldEnd),r=[],s=[],o=[];let i=0,a=0;for(const l of n){const d=e.substring(i,l.oldPosition);r.push(d,l.newText),a+=d.length,s.push([l.oldPosition,l.oldEnd]),o.push([a,a+l.newText.length]),a+=l.newText.length,i=l.oldEnd}return r.push(e.substring(i)),{next:r.join(""),removed:s,inserted:o}}function Hh(e,t){if(e.reduce((i,a)=>i+a.oldLength,0)<=200)return null;const n=zi(t),r=Vh(t,e),s=Rr(t,n,r.removed)-Rr(r.next,zi(r.next),r.inserted),o=Rr(t,n,[[0,t.length]]);return s>100&&s>o*.2?{removed:s,total:o}:null}function $e(e){pt(e,{origin:"canvas-channel"})}var Gh=100;function Wh(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===c.EVENT_TYPES.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function Yh(e){const t=ue(e),n=le(e);let r;const s=(l,d)=>{const u=l.get().docId;let p=!1,h=null,m=null,_;const y=Nh({startVersion:l.get().version});let v=l.getContent();const b=Bh(),O=vo(e),j=O.open(u,()=>l.get().version);let x=!1;const C=g=>({generation:me(n),originId:g});let I=C(null),R=!0;const A=(g,T)=>{!R||t.current()!==l||(pt(T,{origin:"canvas-channel"}),m?.splice(0,m.length),n.sendAsync(c.EVENT_TYPES.SANDBOX_SET_ENTITY,on(Et(l),u,De(e).editorPolicy,l.get().version)).catch($e))},P=g=>{const T=g[g.length-1],M=[...g].reverse().find(H=>H.answer?.actionId!==void 0)?.answer?.actionId,$=T.answer?.selection,Y=M!==void 0||$?{...M!==void 0?{actionId:M}:{},...$?{selection:$}:{}}:void 0;return{edits:g.map(H=>H.edits),guid:u,rev:T.rev,...Y?{historyAnswer:Y}:{}}},L=()=>{const g=d.activeMove(),T=g&&_?.action===g.kind?_:void 0;if(T&&(_=void 0),!(!T&&!g?.selection))return{...T?{actionId:T.actionId}:{},...g?.selection?{selection:g.selection}:{}}},S=g=>{D({edits:[],rev:l.get().version,answer:{actionId:g.actionId}}).catch($e)},D=async g=>{if(m){m.push(g);return}m=[g];try{do await n.sendAsync(c.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,P(m.splice(0,m.length)));while(m.length)}catch(T){A("app edits failed to reach the canvas",T)}finally{m=null}},k=g=>{g.length&&n.sendAsync(c.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,P(g)).catch($e)},F=(g,T)=>{x=!0,k(m?.splice(0,m.length)??[]);const M={edits:[g],guid:u,rev:l.get().version,...T!==null?{changeId:T}:{}};T!==null&&b.remember(T,I,M),n.sendAsync(c.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,M).catch($e)},E=new Set,w=(g,T,M)=>{F([],M);const{length:$,hash:Y}=c.textFingerprint(JSON.stringify(T.map(Z=>[Z.oldText,Z.newText]))),H=`${$}:${Y}`;if(E.has(H))return;E.add(H);const G=new Error(`canvas service batch removes ${g.removed} of ${g.total} tags`);A("canvas service batch removes a large part of the email",G)},B=({changeId:g,baseRev:T})=>{!x&&(g!==null||T!==null)&&F([],g)},U=g=>{if(g.guid!==u)return;const T=tu(g);x=!1,I=C(T.originId);try{W(g,T)}catch(M){B(T),A("canvas batch failed to apply",M)}finally{B(T),T.changeId!==null&&O.note(T.changeId,I)}},W=(g,T)=>{const{pushUndoStop:M}=g,$=T.changeId!==null?b.find(T.changeId,I):void 0;if($){x=!0,n.sendAsync(c.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,$).catch($e);return}let{edits:Y,selection:H}=g;if(T.baseRev!==null){const G=y.rebase(Y,T.baseRev);if(!G){pt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),F([],T.changeId);return}G!==Y&&(H=void 0),Y=G}try{p=!0,h=T.changeId;const G=Mh(Y,l.getContent());if(M===!1){const Z=Hh(G,l.getContent());if(Z){w(Z,G,T.changeId);return}d.applyWithoutHistory(G)}else d.recordAt(g.typedAt,()=>l.mutate({changes:G},{source:qi(e)?"system":"user"}),H),g.closesStep&&d.closeGroup()}finally{p=!1,h=null}},ae=l.subscribe(({changes:g,version:T})=>{const M=l.getContent(),$=!g?.length&&M!==v;if(v=M,y.record({version:T,changes:g,contentReplaced:$,fromCanvas:p}),!g?.length)return;const Y=xh(g);p?F(Y,h):D({edits:Y,rev:T,answer:L()}).catch($e)}),re=n.addListener(c.EVENT_TYPES.APPLICATION_UPDATE_ENTITY,U),q=n.addListenerAsyncPipe(c.CUSTOM_MESSAGE,(g,T)=>{_=Wh(g);try{return T?.(g)}finally{const M=_;_=void 0,M&&S(M)}},Gh),K=(g,T,{reportId:M,dropsCovered:$})=>{const Y=m?.splice(0,m.length)??[];n.sendAsync(c.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:[jh(g,T)],guid:u,rev:l.get().version,resync:{textFingerprint:c.textFingerprint(T),reportId:M}}).catch(H=>A("canvas resync edit failed to reach the canvas",H)),$&&k(Y)},f=n.addListener(c.EVENT_TYPES.APPLICATION_SYNC_DRIFT,g=>{if(!((g.reason==="echo-timeout"||g.reason==="resync-failed")&&g.guid!==void 0&&g.guid!==u)){if(g.reason==="resync-failed"){A("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(g.reason==="echo-timeout"){const{textFingerprint:T}=g,M=Et(l),$=c.textFingerprint(M);if(T?.length===$.length&&T.hash===$.hash){b.echoes(C(g.originId??null)).forEach(H=>{n.sendAsync(c.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,H).catch($e)}),g.reportId!==void 0&&K(M,M,g);return}const Y=new Error(`canvas echo timeout, ${g.unsent??0} edits unsent`);if(g.canvasText===void 0){A("canvas lost the echo of its batch",Y);return}K(g.canvasText,M,g)}}});return()=>{R=!1,j(),ae(),re.dispose(),q.dispose(),f.dispose()}};let o;const i=()=>{const l=t.current(),d=t.history(),u=l?.get().docId;u!==o&&(r?.(),r=void 0,o=u,l&&d&&(r=s(l,d)))},a=t.subscribe(i);i(),e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{r?.(),a()})}function qh(e){const t=le(e),n=()=>ce(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(c.EVENT_TYPES.RELOAD,()=>{n()?.followReload()}),s=t.addOffTargetListener(c.EVENT_TYPES.RELOAD,a=>{const l=ce(e)?.byWindow(a);l&&Wi(e,l.element)}),o=t.addListener(a=>{a.data?.operation===c.EVENT_TYPES.SANDBOX_RESIZED&&n()?.resize()}),i=Q(e,c.events.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),s.dispose(),o.dispose(),i.dispose()})}function Xi(){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 Kh(e){const t=e.getInstance(c.OPTIONS_SOURCE_ID);let n,r;e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{r?.remove(),r=void 0}),Ih(e,{resolveMount:()=>n,resolveSrc:o=>Si(o==="block"),elementId:"email_iframe",mark:o=>te(o)}),t?.watch(o=>{const i=o?.element;if(n&&i instanceof HTMLElement&&i!==n){n=i,ce(e)?.remount(i),r?.remove(),r=void 0;return}if(!n){if(i instanceof HTMLElement)n=i;else if(o!==void 0){n=r??=Xi(),ce(e)?.alignSurface("email",r,r);return}else return;ce(e)?.get("email")}});let s;e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{s?.remove(),s=void 0}),bf(e).watch(o=>{const i=ce(e);if(i){if(o){s??=Xi(),i.alignSurface("email",s,s);return}s&&(i.alignSurface("email",null),s.remove(),s=void 0)}})}var kr=c.createIdentifier$1("canvas.headerFlow"),Ji=["subject","preheader"],Qi=3e3,zh=3,Xh={subject:c.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,preheader:c.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE};function Jh(e){const t=ue(e),n=le(e),r=C=>C?"remote":qi(e)?"system":"user",s=(C,{guid:I,value:R,forced:A})=>{const P=Je(t);if(!P||typeof R!="string"||I&&I!==P.get().docId)return;const L=t.forcedHeaders();if(L?.[C]!==void 0&&!A&&R!==L[C])return;const S=P.get().attributes[C];if(!A&&m(C,R,S))return;const D=!A&&p.delete(C);A&&(v.delete(C),v.size===0&&t.endForcedHeaders()),l=!0;try{Qe(P,{[C]:R},{source:D?"system":r(A)})}finally{l=!1}o[C]=R};let o={},i,a,l=!1,d=Promise.resolve();const u={},p=new Map,h=(C,I)=>{o[C]=I;const R={};p.set(C,R);const A=()=>{p.get(C)===R&&p.delete(C)};_(C,I,{force:!0}).then(A),setTimeout(A,Qi)},m=(C,I,R)=>{const A=t.showFill();if(!A||typeof R!="string")return!1;const P=u[C]?.showId===A.showId?u[C]:void 0;return I===R?(u[C]=P??{showId:A.showId,codeEdits:A.codeEdits,corrections:0},!1):P&&A.codeEdits>P.codeEdits&&I!==P.stale?!1:((!P||I===P.stale&&P.corrections<zh)&&(u[C]={showId:A.showId,stale:I,codeEdits:A.codeEdits,corrections:(P?.corrections??0)+1},h(C,R)),!0)},_=(C,I,{force:R=!1,echo:A=!1,undoStep:P=!1})=>(d=n.sendAsync(Xh[C],{value:I,guid:Je(t)?.get().docId,...R?{force:!0}:{},...A?{echo:!0}:{},...P?{undoStep:!0}:{}}).catch(L=>{}),d);let y;const v=new Set;e.inject(kr,{whenDelivered:async()=>{await d},reassert:C=>{const I=Je(t),R=Ji.filter(A=>typeof C[A]=="string");if(!(!I||R.length===0)){l=!0;try{Qe(I,Object.fromEntries(R.map(A=>[A,C[A]])),{source:"system"})}finally{l=!1}t.beginForcedHeaders(Object.fromEntries(R.map(A=>[A,C[A]]))),clearTimeout(y),y=setTimeout(()=>{v.clear(),t.endForcedHeaders()},Qi),v.clear();for(const A of R)v.add(A);for(const A of R)o[A]=C[A],_(A,C[A],{force:!0,echo:!0})}}});const b=()=>{i?.(),i=void 0;const C=Je(t);if(C!==a&&p.clear(),a=C,!C){o={};return}const I=C.get().attributes;o={subject:I.subject,preheader:I.preheader},i=C.subscribe(({source:R})=>{if(l)return;const A=C.get().attributes,P=t.forcedHeaders();for(const L of Ji){const S=A[L];if(S===o[L])continue;o[L]=S,p.delete(L);const D=R==="system"&&P?.[L]!==void 0;_(L,S??"",{force:D,echo:D,undoStep:R==="user"})}})};b();const O=t.subscribe(b),j=n.addListenerAsync(c.EVENT_TYPES.APPLICATION_SUBJECT_UPDATE,C=>s("subject",C)),x=n.addListenerAsync(c.EVENT_TYPES.APPLICATION_PREHEADER_UPDATE,C=>s("preheader",C));e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{j.dispose(),x.dispose(),O(),i?.(),clearTimeout(y)})}function Qh(e){const t=ue(e);let n={document:void 0,seq:0};const r=()=>{const o=t.recoveryFacts(),i=Je(t);if(!o?.applied||!i||String(o.emailId)!==String(i.get().serverId)||(n.document!==i&&(n={document:i,seq:0}),o.applied.seq<=n.seq))return;n={document:i,seq:o.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(kr)?.reassert(a)},s=t.subscribe(r);e.getInstance(c.DISPOSABLE_ID)?.addDispose(s)}function Zh(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?c.DARK:c.LIGHT}function em(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function tm(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Zi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Nr(e,t){const n={...e};for(const r of Object.keys(t)){const s=t[r],o=e[r];Zi(s)&&Zi(o)?n[r]=Nr(o,s):s!==void 0&&(n[r]=s)}return n}function nm(e,t){const n=c.COMMON_STYLES;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length>0)return Nr(n,s)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Nr(n,t):n}var rm=ie(void 0),ea=rm,ta=c.createIdentifier$1("CodeMode");function na(){let e;try{const t=window.localStorage?.getItem(c.LOCAL_STORAGE_ITEMS.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function sm(e){try{window.localStorage?.setItem(c.LOCAL_STORAGE_ITEMS.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function fn(e){return e.getOrCreateInstance(ta,()=>{const t=ie(na());return t.watch(sm),t})}function ra(e){return e?.getInstance(ta)?.get()??na()}function Lr(e,t){const n=fn(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function om(e,t){const n=fn(e);n.set({...n.get(),direction:t})}var im=c.createIdentifier$1("DefaultCommonStyles");function sa(e){return e.getOrCreateInstance(im,()=>ie(void 0))}function am(e,t){sa(e).set(t)}var cm=c.createIdentifier$1("CanvasViewport"),lm=c.createIdentifier$1("CanvasPreviewPage");function Pe(e,t,n){let r,s;const o=()=>{if(!r||!e.isInited())return;const l=r.value===void 0?"undefined":JSON.stringify(r.value);l!==s&&(s=l,e.send(t,r.value))},i=n.watch(l=>{r={value:l},o()}),a=e.onInit(()=>{s=void 0,o()});return{dispose(){i.dispose(),a.dispose()}}}function pn(e){const t=ie(e());return{source:t,refresh:()=>t.set(e())}}function dm(e){const t=le(e),n=e.getInstance(c.CONFIG_SOURCE_ID),r=e.getInstance(c.OPTIONS_SOURCE_ID),s=ue(e),o=fn(e),i=matchMedia(c.PREFERS_COLOR_SCHEME_DARK),a=()=>n?.get()??{};let l;const d=pn(()=>Zh(ea.get()??a().theme,i.matches)),u=pn(()=>em(a(),J(s.sessionKey()))),p=pn(()=>a().lockEditor),h=pn(()=>nm(s.current()?.get().attributes?.common_styles,l)),m=e.getOrCreateInstance(cm,()=>ie()),_=e.getOrCreateInstance(lm,()=>ie()),y=[Pe(t,c.CANVAS_FACTS.theme,d.source),Pe(t,c.CANVAS_FACTS.flags,u.source),Pe(t,c.CANVAS_FACTS.lockEditor,p.source),Pe(t,c.CANVAS_FACTS.commonStyles,h.source),Pe(t,c.CANVAS_FACTS.codeMode,o.select(tm)),Pe(t,c.CANVAS_FACTS.appName,ie("emailmaker")),Pe(t,c.CANVAS_FACTS.previewPage,_),Pe(t,c.CANVAS_FACTS.viewport,m)],v=()=>{d.refresh(),u.refresh(),p.refresh()},b=n?.watch(v),O=sa(e).watch(P=>{l=P,h.refresh()}),j=r?.watch(P=>{P&&"commonStyles"in P&&(l=P.commonStyles),h.refresh()});let x;const C=()=>{x?.(),x=s.current()?.subscribe(()=>h.refresh()),h.refresh(),u.refresh()};C();const I=s.subscribe(C),R=()=>d.refresh();i.addEventListener("change",R);const A=ea.watch(()=>d.refresh());e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{y.forEach(P=>P.dispose()),b?.dispose(),O.dispose(),j?.dispose(),x?.(),I(),i.removeEventListener("change",R),A.dispose()})}var Mr;(function(e){function t(s,o,i=(a,l)=>a===l){if(s===o)return!0;if(s.length!==o.length)return!1;for(let a=0;a<s.length;a++)if(!i(s[a],o[a]))return!1;return!0}e.isEqual=t;function n(s,o=i=>i){const i=new Set;return s.filter(a=>{const l=o(a);return i.has(l)?!1:(i.add(l),!0)})}e.unique=n;function r(s=[],o=[],i=(a,l)=>a===l){const a=[],l=[],d=[];for(const u of s){const p=o.find(h=>i(u,h));p?d.push({prev:u,next:p}):l.push(u)}for(const u of o)s.find(p=>i(u,p))||a.push(u);return{added:a,removed:l,exists:d}}e.diff=r})(Mr||(Mr={}));function um(e,t){return e.type===t.type&&e.key===t.key}function fm(e){const t=le(e),n=()=>e.getServices(c.SANDBOX_EXTENSIONS_ID)??[];let r=[];const s=t.onInit(()=>{r=n(),t.send(c.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,r)}),o=c.getServiceContainerId(c.SANDBOX_EXTENSIONS_ID),i=e.onInject(a=>{if(a!==o)return;const l=n();if(!t.isInited()){r=l;return}const{added:d,removed:u}=Mr.diff(r,l,um);if(r=l,u.length){if(u.some(p=>p.type==="script")){t.send(c.EVENT_TYPES.RELOAD);return}t.send(c.EVENT_TYPES.SANDBOX_REMOVE_EXTENSIONS,u.map(p=>p.key))}d.length&&t.send(c.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,d)});e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{s.dispose(),i?.dispose()})}var pm=new Set([...Object.values(c.EVENT_TYPES).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(c.SANDBOX_EXTENSION_SCRIPT_STATUS_ID)]);function hm(e){return e.length>0&&!e.startsWith("em:")&&!pm.has(e)}function mm(e){const t=le(e),n=new Map;let r=!1,s=-1,o=new Set;const i=d=>(d!==s&&(s=d,o=new Set),o),a=t.observeOutgoing((d,u)=>{if(!r||!hm(d))return;const p=me(t);n.set(d,{data:u,generation:p,scripts:new Set(i(p))})}),l=t.addListener(c.SANDBOX_EXTENSION_SCRIPT_STATUS_ID,d=>{if(d.phase!=="ready"||d.status!=="success")return;r=!0;const u=me(t),p=i(u);p.add(d.key);for(const[h,m]of n)m.generation===u||![...m.scripts].every(_=>p.has(_))||(m.generation=u,t.send(c.createIdentifier(h),m.data))});e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{a.dispose(),l.dispose()})}var gm=c.createIdentifier$1("prewarm.editorVisible");function vm(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Em(e={}){const t=e.paint??vm;let n=!1,r=!1,s=!1,o=!1,i=!1;const a=[],l=()=>{i||o||!n||!r||!s||(o=!0,t(()=>{i=!0,te(de.editorVisible);for(const d of a.splice(0))d()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){s=!0,l()},whenVisible(d){if(i){d();return}a.push(d)},contentShown:()=>s}}function _m(e){return e.getOrCreateInstance(gm,()=>Em())}var bm=500,ym=500,Sm=5e3;function wm(e){const t=e.quietMs??bm,n=e.floorMs??ym,r=e.ceilingMs??Sm;let s,o,i=0;const a=()=>{clearTimeout(s),clearTimeout(o),s=void 0,o=void 0},l=()=>{a(),e.run()},d=()=>{clearTimeout(s);const u=n-(Date.now()-i);s=setTimeout(l,Math.max(t,u))};return{start(){a(),i=Date.now(),o=setTimeout(l,r),d()},notify(){s!==void 0&&d()},cancel:a}}var Im=2;function oa(){return new Error("[sandbox] document reloaded during fill")}function Tm(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function xr(e){try{e()}catch{}}function Cm(e){let t;return xr(()=>{t=e()}),{stage:n=>xr(()=>t?.stage(n)),end:(n,r)=>xr(()=>t?.end(n,r))}}function Am(e){const t=()=>e.initPipeline();let n=!1,r,s,o,i=0,a,l;const d=()=>{const I=e.readTarget?.(),R=e.readSandboxGeneration?.();return I===void 0||R===void 0?void 0:{target:I,generation:R}},u=()=>{const I=d();return I&&{...I,canvasReplaced:e.trackDocument?.(I.target)}},p=I=>{if(I?.canvasReplaced?.())return!0;const R=d();return I!==void 0&&R?.target===I.target&&R.generation!==I.generation},m=Hp({...e,waitScope:()=>({getSandboxTimeoutMs:I=>t().getSandboxTimeoutMs(I),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const I=l;if(!(!I||!e.onSandboxGenerationChange))return{getGeneration:()=>d()?.generation??I.generation,onChange:R=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===I.target||I.canvasReplaced?.())&&R()})??(()=>{})}}});let _;const y=(I,R)=>{if(_===I)return;_=I;const A=i;setTimeout(()=>{i!==A||t().signal.aborted||j(I,R).catch(()=>{})},0)},v=()=>{a?.abort(),a=void 0};let b;const O=()=>{const I=t().signal;I!==b&&(b?.removeEventListener("abort",v),b=I,I.addEventListener("abort",v))};async function j(I,R,A=0){const P=++i;v(),a=new AbortController,l=void 0,O();const L=()=>i!==P,S=m.readTarget(),D=t().generation,k=()=>D===t().generation&&!t().signal.aborted,F=R?"init:reset-":"init:",E=Cm(()=>e.observeShow?.(Tm(I,R,e.readEmail())));if(!R){const q=m.publicEmail();q?.id,q?.renderGuid,q?.preheader}let w=!1,B=!1,U,W=!1;const ae=()=>{if(p(U))throw oa()},re=()=>{if(L())throw c.createAbortError("Fill superseded")};try{n=!0,await m.sendInitStart(),re(),U=u(),l=U,A===0&&m.fireWillInit(),await(R||A>0?m.refreshContent():m.sendContent()),w=!0,re(),ae();const q=m.contentSent();m.noteFilled(q?.target,q?.docId),E.stage("content"),R||m.publicEmail()?.id;try{await m.sendPreheader()}catch(K){if(Pi(K)||L())throw K;`${F}`,String(K)}re();try{await m.sendSubject()}catch(K){if(Pi(K)||L())throw K;`${F}`,String(K)}if(re(),ae(),m.showFilled(S),await m.sendInited(),re(),ae(),B=!0,s===I){const K=e.readSandboxGeneration?.()??o;K!==void 0&&(r=K)}E.stage("reveal"),await m.revealFilled(),ae(),E.end("revealed")}catch(q){const K=!L()&&k()&&p(U),f=K?oa():void 0,g=f??q,T=K&&A<Im?C(I,R,A+1):void 0;W=K&&T===void 0;const M=L()?void 0:{showId:I,contentApplied:w,sandboxInitedAcked:B,superseded:!1,...e.describeSurface?.(),error:String(f??q)};M&&(`${F}`,void 0);const $=!L()&&e.recoverFailedFill?.(S)===!0;if(E.end(L()?"superseded":$?"recovered":c.isAbortError(g)||!k()?"aborted":"failed",M),!$&&!L()&&wr(t(),I)&&t().failShow(I,g),T!==void 0)return T;throw g}finally{x(I,R,F,{superseded:L(),sessionGeneration:D,contentApplied:w,sandboxInitedAcked:B&&!W,retry:!W,commit:k()})}}function x(I,R,A,P){const{superseded:L,contentApplied:S,sandboxInitedAcked:D}=P;if(L){`${A}`;return}D&&P.commit?m.fireInit(I,R||void 0):D?(`${A}`,P.sessionGeneration,t().generation,t().signal.aborted,void 0):S?(`${A}`,void 0):(`${A}`,void 0),n=!1,a=void 0,!D&&s===I&&(s=void 0,r===o&&(r=void 0)),!D&&S&&P.retry&&y(I,R)}function C(I,R,A){return j(I,R,A)}return{channel:m,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:I=>{r=I},lastCorrelation:()=>s,markCorrelation:I=>{s=I},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:I=>{o=I},fill:I=>j(I,!1),refill:I=>j(I,!0),stop:()=>{i+=1,v(),n=!1,b?.removeEventListener("abort",v),b=void 0}}}function Om(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:ia(e,n)}function ia(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Dm(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:s,readSandboxGeneration:o}=e,i=u=>{const p=n(),h=s();if(!Om(p,u,h)){u.showId,u.navId,u.emailId,p?.id,p?.showId,p?.renderGuid;return}u.showId,p?.id,p?.renderGuid,t.markFilled(o()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{i(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&i(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=o();if(t.filledGeneration()===u)return;const p=n(),h=s();if(!p?.renderGuid||!ia(p,h))return;const m=`${Ri}${p.renderGuid}`;t.markFilled(u),t.markCorrelation(m);const _=r()?.isReady()===!0;p.id,p.renderGuid,(_?y=>t.refill(y):y=>t.fill(y))(m).catch(()=>{t.lastCorrelation()===m&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var Pm=c.createIdentifier$1("canvas.health");function Rm(e){return e??""}function km(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function aa(e){return e.length>0}function Nm(e){const t=ue(e),n=le(e),r=()=>J(t.sessionKey())?void 0:t.current(),s=()=>{const N=r();return Yi({attributes:N?.get().attributes??{},readContent:()=>N?.getContent(),docId:N?.get().docId,hasSession:!!N,serverId:N?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(c.INIT_PIPELINE_ID)??Ir;let i={},a=!1;const l=e.getInstance(c.OPTIONS_SOURCE_ID)?.watch(N=>{a=!!N?.element});let d=!1,u=!1,p=!1,h=0;const m=()=>{const N=ce(e);if(!N)return;const z=++h,X=N.spare();return X&&Wi(e,X.element),(X?X.reloadQuietly():N.ensureSpare()?.ready())?.then(()=>{if(z!==h)return;d=!0;const ee=N.spare();ee&&Ah(e,ee.element),p&&(p=!1,D(),K())})},_=wm({run:()=>{p||m()?.catch(()=>{})}}),y=()=>{_m(e).noteContentShown(),!d&&!p&&_.start()};let v=!1;const b=N=>{const z=ce(e),X=z?.spare()?.element.contentWindow;u&&z&&X&&N===X&&(u=!1,z.promote(),z.busy(!1),v=!0)};let O=!1;const C=Am({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:s,revealFilled:()=>{const N=ce(e);return v&&N&&(v=!1,_.start()),a?N?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:b,noteFilled:(N,z)=>ce(e)?.noteFilled(N,z),recoverFailedFill:N=>{const z=ce(e),X=z?.spare()?.element.contentWindow;return!u||!z||!X||N!==X?!1:(u=!1,d=!1,L="reload",z.busy(!1),z.peek("email")?.reload(),O=!0,K(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>me(n),onSandboxGenerationChange:N=>Gt(n,N),trackDocument:N=>Oh(e,N),observeShow:N=>e.getInstance(Pm)?.begin(N),describeSurface:()=>({canvasPath:L,promoted:u,spareClean:d,handshake:n.isInited(),generation:me(n)}),events:{willInit:N=>{fe(e,c.events.WILL_EMAIL_INIT_ID).fire(N)},inited:N=>{y(),fe(e,c.events.ON_EMAIL_INIT_ID).fire(N)},contentChanged:N=>{fe(e,c.events.ON_CONTENT_CHANGED_ID).fire(N)},emailChanged:N=>{fe(e,c.events.ON_EMAIL_CHANGED_ID).fire(N)},browserExtensionDetected:()=>{fe(e,c.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),I=Dm({pipeline:C,initPipeline:o,readEmail:s,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>me(n)});let R="",A="",P="",L="none";const S=()=>{const N=ce(e)?.spare()?.element.contentWindow;N&&n.getTarget()===N||n.sendNow({operation:c.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0})},D=()=>{const N=ce(e)?.spare();N&&(S(),d=!1,u=!0,Th(e,N.element))},k=(N,z)=>{const X=ce(e);if(!X)return!0;const ee=X.spare(),oe=ee&&d?"spare":"prepare";if(L=oe,X.busy(!0),ee&&d)return D(),!0;_.cancel(),S();const qe=m();if(qe===void 0)return L="reload",X.busy(!1),X.peek("email")?.reload(),!0;p=!0;const ke=h;return qe.catch(()=>{!p||ke!==h||(p=!1,L="reload",X.busy(!1),X.peek("email")?.reload())}),!1},F=()=>{if(J(t.sessionKey()))return;Y(),C.noteSandboxGeneration(me(n));const N=s(),z=km(N?.renderGuid,N?.showId,N?.id,i.emailId),X=Rm(N?.renderGuid);if(X!==A){const qe=A;A=X;const ke=ce(e)?.peek("email")?.filled,sw=ke!==void 0&&ke!==X;aa(X)&&(aa(qe)||sw)&&k(qe||(ke??""),X)}if(p)return;(z!==R||O)&&(O=!1,R=z,I.showRequestIdentityChanged());const ee=r(),oe=`${z}|${ee?.get().docId??""}|${me(n)}`;oe!==P&&ee?.isReady()===!0&&(P=oe,I.selfInitChanged()),I.saasChanged(),re()};let E=!1,w="",B="",U=!1,W=!1;const ae=N=>{N.source==="user"?W=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(U=!0),K()},re=()=>{const N=s();if(!N?.renderGuid)return;const z=C.channel.readContent(),X=JSON.stringify([N.preheader,N.common_styles,N.meta,N.subject,N.utm_parameters?.utm_campaign??"",N.utm_parameters?.utm_content??"",N.utm_parameters?.utm_medium??"",N.utm_parameters?.utm_source??"",N.utm_parameters?.utm_term??""]),ee=E&&z!==B,oe=E&&X!==w;E=!0,B=z,w=X;const qe=U&&!W;if(U=!1,W=!1,C.isEventsLocked()||qe)return;const ke={...N,id:i.isTemplate||N.isNew?void 0:N.id,html:z};if(ee){fe(e,c.events.ON_CONTENT_CHANGED_ID).fire(z),fe(e,c.events.ON_EMAIL_CHANGED_ID).fire(ke);return}oe&&N.is_inited&&fe(e,c.events.ON_EMAIL_CHANGED_ID).fire(ke)};let q=!1;const K=()=>{q||(q=!0,queueMicrotask(()=>{q=!1,F()}))};e.inject(Pr,{pipeline:C,setRoute:N=>{N.emailId===i.emailId&&!!N.isTemplate==!!i.isTemplate||(i=N,K())}});let f,g;const T=()=>{const N=r()?.get().docId;N!==g&&(f?.(),g=N,f=r()?.subscribe(ae)),K()};let M,$;const Y=()=>{const N=e.getInstance(c.INIT_PIPELINE_ID);!N||N===M||($?.(),M=N,$=N.onShowRequested(z=>I.showRequested(z)))},H=n.addListener(N=>{N.data?.operation===c.EVENT_TYPES.SANDBOX_RESIZED&&_.notify()}),G=t.subscribe(T),Z=Gt(n,K);T(),e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{l?.dispose(),$?.(),Z(),G(),f?.(),H.dispose(),_.cancel(),C.stop()})}function Lm(){return c.USEBLOCKS!=="emailmaker"}var Mm={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},ca={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},la=ca,xm=["pro"],Fr={};function Fm(e){Fr=e}var da=e=>xm.includes(e)?la:Fr[e]??Fr.editor??la,Br={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},Bm={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},jm={...Br,config:{...Br.config,imageCenterFileManagerView:!1}};Fm({pro:ca,editor:Bm,simple:Lm()?Br:jm,blocks:Mm});function Um(e,t,n=e.getInstance(c.CONFIG_SOURCE_ID)){n?.setMode(t),n?.get()?.codeEnabled===!1&&ra(e).isCodeMode&&Lr(e,!1)}function $m(e){e.getInstance(c.STANDALONE_ACTIVATED_ID)||e.inject(c.SECURITY_MODULE_ID,void 0)}function hn(e){return String(e.standaloneKey||"").trim()||void 0}function Vm(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function jr(e){return Vm(e)?!!hn(e):!1}function yt(e){return!!hn(e)&&!jr(e)}var Hm=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function ua(e){return e==="server"?"serverSide":e}function Gm({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},s=ie();let o={kind:"pending"},i;const a=new Promise(h=>{i=h}),l=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function d(){o.kind!=="pending"&&s.set(Er(r,e))}function u(h){if(o.kind!=="pending")return;clearTimeout(l),o=h;const m=Er(r,e);s.set(m),i(m)}function p(h,m){r[ua(h)]=m,h==="server"&&o.kind==="pending"?u({kind:"applied"}):d()}return{watch:h=>s.watch(h),select:h=>s.select(h),get:()=>s.get(),ready:()=>a,state:()=>o,layers:()=>({...r}),bootstrap(){const h=Er(r,e);return Object.fromEntries(Hm.map(m=>[m,h[m]]))},merge(h,m){p(m,{...r[ua(m)],...h})},replace(h,m){p(m,h)},setMode(h){r.user={...r.user,mode:h},d()},setAdvancedConfigs(h){r.advancedConfigs=h,d()},serverAbsent(h){u({kind:"absent",reason:h})},applyServerResponse(h){o.kind==="pending"&&p("server",{...r.serverSide,...h})},dispose(){clearTimeout(l)}}}var Wm=5e3,Ew="pro";function Ym(){return{...da("pro")?.config,mergeTags:void 0}}function qm(e,t){e.getInstance(c.OPTIONS_SOURCE_ID)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},s=t.layers().user.mode;t.replace(r.mode===void 0&&s!==void 0?{...r,mode:s}:r,"user")})}function Km(e,t){let n;gr(e).watch(({profile:r})=>{const s=`${r?.theme??""}|${r?.locale??""}`;if(s===n)return;n=s;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function zm(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Xm(e,t){let n,r=!1,s;const o=a=>{s??=tn(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Um(e,a,t)},i=gr(e).watch(({profile:a})=>{const l=a?.email_builder_config,d=zm(l);if(d===void 0||l===n)return;const u=n===void 0;n=l,!(u&&r)&&o(d)});e.getInstance(c.DISPOSABLE_ID)?.addDisposable(i),t.ready().then(a=>{if(!a.configSwither)return;const l=localStorage.getItem("configSwither")||(n===void 0?a.mode:s)||"editor";localStorage.setItem("configSwither",l),r=n===void 0,o(l)})}var fa="замкнутый контур: app_init не выполняется";function Jm(e,t){if(e.getInstance(c.SECURITY_MODULE_ID)){t.serverAbsent(fa);return}const n=e.getInstance(c.OPTIONS_SOURCE_ID)?.watch(r=>{yt(r)&&t.serverAbsent(fa)});n&&e.getInstance(c.DISPOSABLE_ID)?.addDisposable(n)}async function Qm(e,t){if(e.getInstance(zn)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(c.APP_ID);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function Zm(e){e.injectFactory(c.CONFIG_SOURCE_ID,(t,n)=>{if(n)return n;const r=Gm({base:Ym(),env:{modeDefaults:s=>da(s)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Wm});return qm(e,r),Km(e,r),Xm(e,r),Jm(e,r),Qm(e,r),e.getInstance(c.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var rt=class extends c.Disposable{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function V(e,t,n){const r=c.snapshot(e);return(s,o,i)=>{const a=r(async l=>{const d=t?t(l):l;i&&s.bind(i);const u=await s(d);return n?n(u):u},o,i);return()=>a.dispose()}}var eg=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new c.Emitter;this.handleDestroy=V(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new rt(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{}}},Ur=c.createIdentifier$1("DestroyableService");function tg(e){e.injectFactory(Ur,(t,n)=>{if(n)return n;const r=e.getInstance(c.DISPOSABLE_ID);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new eg({lifetime:r,options:e.getInstance(c.OPTIONS_SOURCE_ID),getInstance:()=>e.getInstance(c.INSTANCE_ID),release:()=>c.releaseContainer(e.getInstance(c.STORE_ID)??e)})},!0)}function ng(e){const t=e.getInstance(Ur);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var rg=1e3;function pa(e,t,n=rg,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 s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;for(const i of s)if(!pa(e[i],t[i],n,r+1))return!1;return!0}return!1}function St(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 s=t[r],o=e[r];pa(s,o)||(n[r]=s)}return n}var sg=({source:e,emailtags:t,group:n,tags:r,...s})=>s;async function og(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function ig({emails:e,saveTimeoutMs:t},n,r){const s=t?.()??ft();let o;try{const i=e.notifySave(n);return await Promise.race([i,new Promise((a,l)=>{o=setTimeout(()=>{const d=new Ht(s);n.value.id,uu(d,og(i,r)),l(d)},s)})])}catch(i){throw xo(i),i}finally{o!==void 0&&clearTimeout(o)}}function ag(e){const{emails:t}=e,n=async(r,s)=>{const o=sg(s),i=r===void 0?void 0:await t.cache.getIfPresent(r),a=i?{...i,...o}:o,l=i?St(i,o):o,d=u=>{const p=String(u.id??r??c.generateUUID()),h=u.id===void 0?{...u,id:p}:u;return t.cache.addOrUpdate(p,()=>h)};return await d(await ig(e,{prev:i,patch:l,value:a,source:s.source??""},d))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const s=await n(void 0,r);return s?.renderGuid?s:{...s,renderGuid:c.generateUUID()}},async updateEmail(r,s){return await n(r,s)}}}var $r=20;function cg(e){const t=lg(e);return e.saveTimeoutMs?dg(t,e.saveTimeoutMs):t}function lg({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:s,integratorProject:o}){const i=async(a,l)=>(t.clear(),await t.get(a,{page:l}),(await e.cache.values()??[]).filter(d=>String(d?.parent)===String(a)));return{async readRevisions(a,l=1){const d=await i(a,l);return{revisions:d.slice($r*(l-1),$r*l),page:l,hasMore:d.length>$r*l}},async readAutosave(a){const l=await r?.(a)??NaN,d=Number.isFinite(l)?l:void 0,u=await n?.(a);if(!u?.asked)return _u(await i(a,1),d);if(!u.revision)return Uo([],d);const p={...u.revision,parent:a,isAutosave:!0};return Uo([p],d,await i(a,1))},async saveAutosave(a,l){const d=await s?.(a),u=o?.();return await e.create({...Tu(l),...d!==void 0?{author:d}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function dg(e,t,n){return{...e,async saveAutosave(r,s){const o=t();if(o===void 0)return e.saveAutosave(r,s);let i;try{return await Promise.race([e.saveAutosave(r,s),new Promise((a,l)=>{i=setTimeout(()=>l(new mo(o,n)),o)})])}catch(a){throw xo(a),a}finally{i!==void 0&&clearTimeout(i)}}}}var ug=class extends c.BaseEmitter{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}},fg=class extends c.AsyncEmitter{};function _w(e){return e}var ha=class extends c.Disposable{_items=new Map;_onChangeEmitter=new c.Signal;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 s=await t(n);return c.deepEqual(n,s)||this._onChangeEmitter.fire(),s}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(([s,o])=>s)),r=(await this.entries()).filter(([s,o])=>!n.has(s));for(const[s,o]of e)t.push(this.addOrUpdate(s,()=>o)),n.add(s);for(const[s]of r)t.push(this.remove(s));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 pg(e,{filter:t,order:n="asc",orderBy:r,page:s,pageSize:o=20}={}){const i=e.length;let a=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(d=>{for(const u of l){const p=d[u],h=t[u];return u==="id"||typeof p!="string"?p===h:typeof h=="string"&&p.startsWith(h)}return!0}),a=e.length}return r&&(e=e.sort((l,d)=>(l[r]>d[r]?1:d[r]>l[r]?-1:0)*(n==="asc"?1:-1))),s!==void 0&&(e=e.slice(o*(s-1),o*s)),{data:e,filteredTotal:a,total:i,totalPages:Math.ceil(a/o)}}function hg(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 s=t.get(r.id)||{};t.set(r.id,{...s,...r})}return[...t].map(([n,r])=>r)}function mg(e,t){return ma(e)&&ma(t)?String(e)===String(t):e===t}function ma(e){return typeof e=="string"||typeof e=="number"}var gg=class extends c.Disposable{_cache=new ha;_readEmitter=new c.AsyncEmitter;_saveEmitter=this.addDisposable(new ug);_removeEmitter=this.addDisposable(new fg);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}async confirmedMissing(e){if(!this.hasReadHandler())return!1;const{results:t,errors:n}=await this._readEmitter.fireSettled(e);return!n.length&&!t.some(Boolean)}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new c.Disposable);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new ha),s=n.addDisposable(new c.AsyncEmitter);t=this._foreignCache[e]={get:async(o,i={})=>{await r.getOrCreate(o,async()=>{try{const l=hg(await s.fire(o))||[];for(const d of l)d[e]=o,await this._cache.add(d.id,d);return l}catch{return[]}});const a=(await this._cache.values()||[]).filter(l=>{const d=l[e];return d==null||mg(d,o)});return pg(a,i)},first(o,i={}){return t.get(o,{...i,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:s.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=c.generateUUID()),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 s=>{const o=s?{...s,...t}:t;if(!r)return t=s?St(s,t):t,await this._saveEmitter.fire({prev:s,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 wt(e){const t=c.createIdentifier$1(e);return n=>n.getOrCreateInstance(t,()=>new gg)}function ga(e){const t=e.getInstance(c.DISPOSABLE_ID);if(!t)throw new Error("Failed");return t}function va(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function mn(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function vg(e,t,n){return e&&!va(t)&&va(e)?{...n,meta:e.meta}:n}var Eg=c.createIdentifier$1("CurrentProject"),_g={};function It(e){return e?.getInstance(Eg)?.get()??_g}function Vr(e){const t=It(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Ea=wt("plugin.dataSource.emails"),_a=wt("plugin.dataSource.emailRevisions"),ba=sn("plugin.readEmailAutosave"),ya=c.createIdentifier$1("emailDocuments.provided");function bg(e){const t=Ea(e),n=_a(e),r=n.byForeignKey("parent");if(e.getInstance(ya))return{emails:t,emailRevisions:n};e.inject(ya,!0);const s=()=>ft(e.getInstance(c.INIT_PIPELINE_ID)?.contentReadyTimeoutMs),o=ag({emails:t,saveTimeoutMs:s}),i=new Map,a=(l,d)=>u=>{const p=u?.id??d;return(typeof p=="string"||typeof p=="number")&&i.set(String(p),l),u};return Xu(e,{...o,createEmail:l=>o.createEmail(l).then(a(Date.now())),updateEmail:(l,d)=>o.updateEmail(l,d).then(a(Date.now(),l))}),ef(e,cg({revisions:n,revisionsByEmail:r,readAutosave:async l=>{const d=await fe(e,ba).fire(l);return d.length===0?{asked:!1}:{asked:!0,revision:d[0]??null}},savedAt:async l=>{const d=vu((await t.cache.getIfPresent(l))?.modified),u=i.get(String(l))??NaN;return Number.isFinite(u)&&!(d>=u)?u:d},emailAuthor:async l=>(await t.cache.getIfPresent(l))?.author,saveTimeoutMs:s,integratorProject:()=>It(e).requested})),ga(e).addDisposable(t.onSave(({prev:l,patch:d,value:u})=>vg(l,d,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Sa(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 yg(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Sg="po",gn=null;function wg(){const e=typeof __emailmaker__<"u"?__emailmaker__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([Sg],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Ig(){return gn===null&&(gn=wg().catch(e=>{throw gn=null,e})),gn}async function wa(e){if(typeof e=="object")return Hr(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Tg(t):Cg(t)}function Hr(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Tg(e){try{return Hr(JSON.parse(e))}catch{return}}var Ia=!1;async function Cg(e){try{return Hr((await Ig()).parsePoCatalog(e))}catch{Ia||(Ia=!0);return}}var Ag="em_locale",Og="em_ant_locale",Dg="locale",Pg="ant_locale";function Gr(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Ta(e,t){const n=Gr(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Rg(){return Gr("em_locale")??Ta(Dg,"em_locale")}function Ca(e){try{localStorage.setItem(Ag,JSON.stringify(e))}catch{}}function kg(){return Gr("em_ant_locale")??Ta(Pg,"em_ant_locale")}function Ng(e,t){try{localStorage.setItem(Og,JSON.stringify({id:e,data:t}))}catch{}}var bw="en_US",Lg=8e3;function Mg(e,t){const n=e,r=t,s=Object.keys(n).filter(o=>o!=="");return s.length!==Object.keys(r).filter(o=>o!=="").length?!1:s.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function xg(e){const t=Rg(),n=kg();let r={ready:!1},s;const o=ie(r);let i=0;const a=v=>{r={...r,...v},o.set(r)},l=()=>{r.ready||a({ready:!0})},d=setTimeout(l,e.unlockAfterMs??Lg),u=v=>v!==i;let p;async function h(v,b){if(n?.id===v&&n.data&&a({antd:n.data}),!p)return;const O=await p(v).catch(()=>{});!O||u(b)||(a({antd:O}),Ng(v,O))}async function m(v,b){const O=await e.askHost(v).catch(()=>null);if(u(b))return!0;if(O==null)return!1;const j=await wa(O);return u(b)||(j&&a({catalog:j}),l()),!0}async function _(v,b){const O=await e.readList();if(u(b))return;if("error"in O){a({failure:{kind:"GET_LOCALES_ERROR",error:O.error}}),l();return}const j=O.data.find(C=>C.locale===v);if(!j){yg("em_locale")&&a({catalog:void 0}),l();return}if(Sa(t,j)&&(!s||s.catalog===t?.data)){l();return}if(s?.entry&&r.catalog===s.catalog&&Sa(s.entry,j)){Ca(s.entry),l();return}const x=await e.readCatalog(v);if(!u(b)){if("error"in x){a({failure:{kind:"GET_LOCALE_ERROR",error:x.error}}),l();return}x.data&&(s?.id===v&&r.catalog===s.catalog&&Mg(s.catalog,x.data)||a({catalog:x.data}),Ca({id:v,time:j.updatedAt||Math.floor(Date.now()/1e3),hash:j.contentHash,data:x.data})),l()}}async function y(v,b){if(!await m(v,b)){if(!u(b)&&(s?.id===v&&r.catalog===s.catalog||v==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await _(v,b)}}return{set(v){if(!v||v===r.id)return;const b=i+=1;a({id:v,failure:void 0});const O=s?.id===v&&r.catalog===s.catalog;(s&&!O&&r.catalog===s.catalog||v==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===v&&t.data&&(a({catalog:t.data}),l()),h(v,b),y(v,b)},prime(v,b,O){r.id&&r.id!==v||r.catalog||!b||(s=t?.id===v&&t.data&&(!O||t.time>=O.time)?{id:v,catalog:t.data}:{id:v,catalog:b,entry:O?{id:v,time:O.time,hash:O.hash,data:b}:void 0},a({catalog:s.catalog}))},useAntdLoader(v){p=v,r.id&&h(r.id,i)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(d)}}var Fg=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})},Aa=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),Bg=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:s,format:o,baseUrl:i,cancelToken:a,...l})=>{const d=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(l,d),p=s&&this.toQueryString(s),h=this.contentFormatters[r||"application/json"],m=o||u.format;return this.customFetch(`${i||this.baseUrl||""}${n}${p?`?${p}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):u.signal)||null,body:typeof e>"u"||e===null?null:h(e)}).then(async _=>{const y=_;y.data=null,y.error=null;const v=m?_.clone():_,b=m?await v[m]().then(O=>(y.ok?y.data=O:y.error=O,y)).catch(O=>(y.error=O,y)):y;return a&&this.abortControllers.delete(a),b})}},jg=c.createIdentifier$1("rest.v2.transport"),Oa=Symbol("rest.v2.secureRequest");function Ug(e){return e.getOrCreateInstance(jg,()=>{const t=e.getInstance(c.CUSTOM_FETCH_ID)?.execute||fetch;return new Bg({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[Oa]:!0}),customFetch:(n,r={})=>{const{[Oa]:s,...o}=r;return t(n,{...o,[c.PUBLIC_REQUEST]:s!==!0})}})})}function Da(e,t){const n=Ug(e);return Object.assign({},...t.map(r=>new r(n)))}function Pa(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function vn(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Pa(n.details,"wp_code")??n.code,message:Pa(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 Ra(e){return!e.ok||!!e.error}function ka(){return _o(c.LOCAL_STORAGE_ITEMS.em_translations_v2)??!0}function $g(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Vg(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Hg(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],s=r[0];return typeof s=="string"&&s!==""&&t.push({locale:s,updatedAt:$g(r[1])}),t},[]):[]}function Gg(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Vg(n.updated_at),contentHash:n.content_hash}),t),[])}function Na(e){return Da(e,[Fg])}function En(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Wr(e){return!e.ok||e.error!=null}function Yr(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function qr(e){return{data:await wa(e)??null}}async function Wg(e){if(ka())try{const n=await Na(e).localesList();return Ra(n)?{error:vn(n)}:{data:Gg(n.data)}}catch(n){return En(n)}const t=c.getApi(e,[Zs]);try{const n=await t.get_translations2({file:"react_app"});return Wr(n)?Yr(n):{data:Hg(n.data)}}catch(n){return En(n)}}async function Yg(e,t){if(ka())try{const r=await Na(e).jsonList({locale:t});return Ra(r)?{error:vn(r)}:qr(r.data)}catch(r){return En(r)}const n=c.getApi(e,[Zs]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Wr(r)?Yr(r):qr(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Wr(r)?Yr(r):qr(r.data)}catch(r){return En(r)}}}var _n=new WeakMap;function qg(e){const t=_n.get(e);if(t!==void 0)return t;const n=Wg(e).then(r=>("error"in r&&_n.delete(e),r),r=>{throw _n.delete(e),r});return _n.set(e,n),n}var st=c.createIdentifier$1("locale.service");function Kg(e){if(e.getInstance(st))return;const t=xg({readList:()=>qg(e),readCatalog:n=>Yg(e,n),askHost:async n=>(await fe(e,c.events.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(c.SECURITY_MODULE_ID)});e.inject(st,t),e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>t.dispose())}function zg(e){const t=e.getInstance(c.CONFIG_SOURCE_ID);if(!t)return;const n=e.getInstance(st);if(!n)return;const r=t.select(s=>s.locale).watch(s=>n.set(s||"ru_RU"));e.getInstance(c.DISPOSABLE_ID)?.addDisposable(r)}var Xg="user_id",Jg="project_id",La=c.createIdentifier$1("rest.identityHeadersProvided");function Qg(e){if(e.getInstance(La))return;e.inject(La,!0);let t;e.getInstance(c.OPTIONS_SOURCE_ID)?.watch(n=>{t=n}),e.addService(c.REQUEST_HANDLER_ID,{execute(n,r){if(r?.public)return;const s=t?.user?.id??li(e).profile?.id;s!=null&&s!==""&&n.headers.set(Xg,String(s));const o=t?.project;o!=null&&o!==""&&n.headers.set(Jg,String(o))}})}function Zg(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function ev(e){return e.id??Zg(e.catalog)}function tv(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function nv(e){return tv(e||"en_US")}var rv="Accept-Language",Ma=c.createIdentifier$1("rest.localeHeaderProvided");function sv(e){e.getInstance(Ma)||(e.inject(Ma,!0),e.addService(c.REQUEST_HANDLER_ID,{execute(t){const n=e.getInstance(st)?.snapshot();t.headers.set(rv,nv(n&&ev(n)))}}))}function ov(e){if(!e)return!1;try{return e.getInstance(c.SECURITY_MODULE_ID)!==void 0}catch{return!1}}var iv="Invalid standaloneKey.",yw=c.createIdentifier$1("StandaloneMockGuard");function av(){const e=new Error(iv);return e.name="InvalidStandaloneKeyError",e}function cv(e){e.addService(c.REQUEST_HANDLER_ID,{execute:()=>{if(ov(e))throw av()}})}function lv(e){c.registerRestTransport(e),cv(e)}function dv(e){const t=new ki;e.inject(c.INIT_PIPELINE_ID,t);const n=e.getInstance(c.OPTIONS_SOURCE_ID)?.watch(s=>{if(!s)return;const o=s.signal??t.externalSignal;t.configure({replaceSession:!0,...s.timeouts!==void 0?{timeouts:s.timeouts}:{},...o!==void 0?{signal:o}:{}})}),r=e.getInstance(c.DISPOSABLE_ID);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var xa=wt("plugin.dataSource.blocks"),uv=wt("plugin.dataSource.blockRevisions"),fv=wt("plugin.dataSource.comments"),pv=sn(),hv=sn(),Fa=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2110
2110
  <html>
2111
2111
  <head>
2112
2112
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -2147,10 +2147,10 @@ __emailmaker__.define("emailmaker.js",["require","exports","module","static/umd/
2147
2147
  </tr>
2148
2148
  </table>
2149
2149
  </body>
2150
- </html>`;function fg(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:sa,project:e?.id,project_title:e?.title??"",utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var ia=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function pg(e){return!Object.keys(e).some(t=>ia.has(t))}function hg(e){const t={},n={};for(const[r,o]of Object.entries(e))ia.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function aa(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function yS(e){}function cn(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function mg(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function Et(e){return{emails:Ui(e),blocks:oa(e),emailRevisions:$i(e),blocksRevision:lg(e),comments:cg(e)}}function gg(e){const t=Object.values(Et(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function dn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(pg(e))return{email:aa(e)};{const{showOptions:n,misplacedEmailFields:r}=hg(e),o=Object.keys(r);t&&o.length>0&&void 0;const s=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:aa({...r,...s})}}}function Pr(e){const t=Ne(e);return t&&Z(t.sessionKey())?t.suspendedDocument():t?.current()}function un(e){return Pr(e)?.getContent()}function la(e,t){const n=t??fg(),r=Pr(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:un(e)??n.html}:n}async function _t(e){return(await e.getInstanceAsync(l.APP_ID))?.project}async function ca(e){return wr(e)??await _t(e)}async function da(e,t){const n=oa(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(o=>o!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await ca(e),{filter:{id:t}})}function ua(e){if(!e)return;if(cn(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=dn(e,!1).email.id;return t==null?void 0:String(t)}function vg(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function Eg(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}async function _g(e,t,n){const r=st(e.getInstance(l.INIT_PIPELINE_ID)?.contentReadyTimeoutMs);let o;try{return await Promise.race([t,new Promise((s,i)=>{o=setTimeout(()=>{t.then(n,()=>{}),i(new Nt(r,"handleSaveBlock","block"))},r)})])}finally{clearTimeout(o)}}function et({code:e,project:t,...n},r){const o=be(n),s=wr(r),i=Ie(r);return e&&i.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:i.toEditorForm(e)}:{},...s===void 0?{}:{project:s},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function ge({html:e,renderGuid:t,showToken:n,showId:r,...o},s){const{requested:i}=vt(s),a=Ns(s);return be({...o,code:Ie(s).toOutputForm(e),project:i===void 0?o.project:i,utm_parameters:a.UTMEnabled?o.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0,secretHash:void 0})}function Or(e){return e==null?"":e.replaceAll(`\r
2150
+ </html>`;function mv(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:Fa,project:e?.id,project_title:e?.title??"",utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var Ba=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function gv(e){return!Object.keys(e).some(t=>Ba.has(t))}function vv(e){const t={},n={};for(const[r,s]of Object.entries(e))Ba.has(r)?t[r]=s:n[r]=s;return{showOptions:t,misplacedEmailFields:n}}function ja(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function Sw(e){}function bn(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function Ev(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function Tt(e){return{emails:Ea(e),blocks:xa(e),emailRevisions:_a(e),blocksRevision:uv(e),comments:fv(e)}}function _v(e){const t=Object.values(Tt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function yn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(gv(e))return{email:ja(e)};{const{showOptions:n,misplacedEmailFields:r}=vv(e),s=Object.keys(r);t&&s.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:ja({...r,...o})}}}function Kr(e){const t=Se(e);return t&&J(t.sessionKey())?t.suspendedDocument():t?.current()}function Sn(e){return Kr(e)?.getContent()}function Ua(e,t){const n=t??mv(),r=Kr(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:Sn(e)??n.html}:n}async function Ct(e){return(await e.getInstanceAsync(c.APP_ID))?.project}async function $a(e){return Vr(e)??await Ct(e)}async function Va(e,t){const n=xa(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(s=>s!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await $a(e),{filter:{id:t}})}function Ha(e){if(!e)return;if(bn(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=yn(e,!1).email.id;return t==null?void 0:String(t)}function bv(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function yv(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}async function Sv(e,t,n){const r=ft(e.getInstance(c.INIT_PIPELINE_ID)?.contentReadyTimeoutMs);let s;try{return await Promise.race([t,new Promise((o,i)=>{s=setTimeout(()=>{t.then(n,()=>{}),i(new Ht(r,"handleSaveBlock","block"))},r)})])}finally{clearTimeout(s)}}function ot({code:e,project:t,...n},r){const s=we(n),o=Vr(r),i=De(r);return e&&i.warnAboutUnconfiguredInput(e,n.id),{...s,...e?{html:i.toEditorForm(e)}:{},...o===void 0?{}:{project:o},..."utm_parameters"in s?{utm_parameters:s.utm_parameters||{}}:{},_embedded:void 0}}function ge({html:e,renderGuid:t,showToken:n,showId:r,...s},o){const{requested:i}=It(o),a=ui(o);return we({...s,code:De(o).toOutputForm(e),project:i===void 0?s.project:i,utm_parameters:a.UTMEnabled?s.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0,secretHash:void 0})}function zr(e){return e==null?"":e.replaceAll(`\r
2151
2151
  `,`
2152
- `)}function fa(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function bg(e,t,n,r){const o=Sg(e,t,n,r);return o===void 0}function Sg(e,t,n,r){if(cn(t))return"block";const{email:o}=dn(t,!1),s=et(o,e),i=s.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const a=Ne(e)?.current();if(!a)return"no-session";const c=a.get(),d=c.attributes;if(c.serverId!==i)return"document-id";if(d.is_inited!==!0)return"not-inited";const u=fa(Or(n??a.getContent()));if(s.html!==void 0&&fa(Or(s.html))!==u)return"html";if(s.subject!==void 0&&s.subject!==d.subject)return"subject";if(s.preheader!==void 0&&s.preheader!==d.preheader)return"preheader";if(s.common_styles!==void 0&&s.common_styles!==d.common_styles)return"common_styles"}function pa(e,t){if(cn(t))return;const{email:n}=dn(t,!1),r=et(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:Or(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function yg(e){return Array.isArray(e)?e.some(t=>$n(t)):$n(e)}function wg(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])yg(t[n])&&delete t[n];return t}function Ig(e,t){const n={...e};return delete n.id,{...n,...t}}function Tg(e){return e.html?e:{...e,html:sa}}function je({code:e,project:t,...n},r,o){const s=o??wr(r);return{...n,...e?{html:Ie(r).toEditorForm(e)}:{},renderGuid:l.generateUUID(),...s===void 0?{}:{project:s}}}function pe({html:e,renderGuid:t,...n},r){const{requested:o}=vt(r);return be({...n,code:Ie(r).toOutputForm(e),project:o===void 0?n.project:o,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function ha(e){return Ne(e)?.current()?.get().serverId??void 0}function Rr(e,t,n){return n===void 0&&(n=e.post===void 0?ha(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function bt(e,t){return be({...e,link:void 0,comment_status:void 0})}function fn({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?ha(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||Od(n.slug),parent:o}}function kr({html:e,isAutosave:t,...n},r){return be({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:be({html:e,ampHtml:e&&""})})}function pn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function ma({html:e,isAutosave:t,...n}){return be({...n,autosave:t?!0:void 0,code:e,guid:void 0})}function Cg(e){return String(e).replace(/"/g,"&quot;")}function Ag(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 ga(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 va(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),o=Cg(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function Ea(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function _a(e){if(!e?.trim())return{};const t=ga(e);return t?{emBlockId:Ea(t.full,"em-block-id"),emBlockVersion:Ea(t.full,"em-block-version")}:{}}function ba(e,t,n){if(!e?.trim()||!t)return e;const r=ga(e);if(!r)return e;const o=String(t),s=Ag(n??new Date);let{full:i,index:a}=r;const c=i.length;return/\bem-block-id\s*=/.test(i)||(i=va(i,"em-block-id",o)),i=va(i,"em-block-version",s),e.slice(0,a)+i+e.slice(a+c)}function Dg(e,t){const{emBlockId:n,emBlockVersion:r}=_a(e);return n&&r?e:ba(e,t)}var tt=l.createIdentifier$1("NotificationService"),Pg=l.createIdentifier$1("emailTemplate.reads");async function Og(e,t){try{const n=ke(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,kg(e,t,n);return}}var Rg=l.createIdentifier$1("emailTemplate.notifiedFailures");function kg(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(Rg,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(tt).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function Ng(e,t){const n=e.getOrCreateInstance(Pg,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=Og(e,t).then(s=>(s===void 0&&n.delete(t),s));return n.set(t,o),o}var Lg=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:zi.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:zi.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},wS=l.createIdentifier$1("projects.v2IdByWpId"),IS=l.createIdentifier$1("projects.wpIdByV2Id"),TS=l.createIdentifier$1("emails.v2SavedAtOnOpen"),CS=l.createIdentifier$1("emails.v2OpeningReads"),Nr=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function Mg(e,t){if(!t)throw new Nr(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new Nr(e,sn(t))}function xg(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var Fg=/^[A-Za-z0-9_-]{1,128}$/,Bg=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),Sa=new Set;function jg(e){return Fg.test(e)?!0:(Sa.has(e)||Sa.add(e),!1)}function Ug(e){return e&&!e.ok?String(sn(e).data.code??""):""}var ya=()=>({isAutosave:!1});function wa(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function $g(e,t){const n=new AbortController,r=st(e.getInstance(l.INIT_PIPELINE_ID)?.contentReadyTimeoutMs);let o;const s=new Promise((i,a)=>{o=setTimeout(()=>{n.abort(),a(new Nr("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),s])}finally{clearTimeout(o)}}function Hg(e,t){return $o(t,e==="block")}async function Vg(e,t,n,r,o){if(!jg(n))return ya();const s=Ke(e),i=dt(e),a=Hg(t,n);try{const c=await Gg(e,t,n,r,o);return c.id&&(s.set(a,c.id),i.delete(a)),c}catch(c){throw gu(i,a,r.html??""),c}}async function Gg(e,t,n,r,o){const s=Ji(e,[Lg]),i={entityId:n,...o?{autosave:!0}:{}},a=await $g(e,c=>t==="email"?s.emailsRevisionsCreate(i,wa(t,r),{signal:c}):s.blocksRevisionsCreate(i,wa(t,r),{signal:c}));return Bg.has(Ug(a))?ya():(Mg("обновление",a),xg(a.data??{}))}function Wg(e,t,n,r){return Vg(e,t,n,r,!1)}async function Yg(e,t,n){if(t==null||t===""||n===void 0||!Ge(e))return Ia;const r=Date.now(),o=xn(String(t));return Cs(o,{html:n},r,Xn(Ke(e),o,dt(e),n)),await Wg(e,"block",String(t),{html:n}),Gt(o,r,Ke(e).get(o)??void 0),()=>Fn(o,r)}function Ia(){}var Lr="EXTERNAL",Ta=Symbol("supersededShow");function qg(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var Kg="email_id";function Mr(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var zg=class extends l.Disposable{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=l.createQueue();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=Et(t),this._eventLock=gg(t);const n=J(e,l.events.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(J(e,l.events.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(l.REQUEST_HANDLER_ID,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Kg,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(l.INIT_PIPELINE_ID)??or}_throwIfDestroyed(){if(this.isDisposed())throw we()}async getTemplateEmail(e){const t=await Ng(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,wg(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await _t(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,je(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,fn(o,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,Rr(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const s=this._dataSources.emails,i=s.cache,a=await _t(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let d=et(e,this._container);const u=d.id;let p=u;if(u!==void 0){const m=await s.get(u);d={...m??{},...d,utm_parameters:d.utm_parameters??m?.utm_parameters??{},renderGuid:m?.renderGuid??l.generateUUID(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a}}else{p=n??l.generateUUID();const m=await s.get(p);d={...d,utm_parameters:d.utm_parameters??{},renderGuid:m?.renderGuid??l.generateUUID(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a},delete d.project}if(t){const m=await this.getTemplateEmail(String(t));m&&(d=Ig(m,d))}return u===void 0&&(d=Tg(d)),await i.setAll([[p,d]]),d}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==pa(this._container,e))return!1;const n=un(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=pa(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:un(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&vg({ticket:t,emailId:ua(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Ta;if(!e)return;const n=this._getInitPipeline();if(l.throwIfAborted(n.signal),cn(e))return this._showBlock(e,n);const r=Z(de(this._container).sessionKey()),o=Eg(e);if(!r&&!o&&bg(this._container,e,un(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const s=dn(e);s.email.id,this._prevCommand?.id;let i,a="",c=0,d=!1,u,p=Promise.resolve(),m,h=!1;try{this._eventLock.suspendChange();const{email:_,blocks:S,autosaves:v,comments:b,templateId:D,reload:j}=s;i=_.id;const x=et(_,this._container),C=x.id,I=C??l.generateUUID(),R=await Re("getProject",_t(this._container));l.throwIfAborted(n.signal),a=l.generateUUID();const A={isNew:C===void 0,id:String(I),project:R},O=j===!0&&C!==void 0;O&&(await this._dataSources.emails.remove(String(C),{silent:!0}),String(C)),c=++this._showToken,String(I);const L=[];L.push(this.setBlocks(S)),_.id!==void 0&&(L.push(this.setComments(b)),L.push(this.setEmailRevisions(v,String(_.id)))),L.push(this.setEmail(_,$n(D)?D:Number(D),C===void 0?String(I):void 0,c,a)),await Re("setEmail+blocks+revisions",Promise.all(L),{emailId:C??String(I),showId:a,targetShowToken:c}),l.throwIfAborted(n.signal);const w=await this._dataSources.emails.get(String(I)),P=de(this._container),k={id:a,token:c};if(r){en(this._container);const y=P.suspendedDocument()?.get().serverId;!O&&C!==void 0&&y!=null&&String(y)===String(C)&&P.resumeSuspended()}C===void 0?m=P.startNewDraft(w??x,{patch:x,show:k}):O?m=P.reload(C,{email:w??x,patch:x,show:k}):P.sessionKey()===We(C)?m=P.show(x,k):m=P.open(C,{email:w??x,patch:x,show:k}),P.beginShowFill(a);const F=!!this._prevCommand&&l.deepEqual(this._prevCommand,A);A.id,!this._prevCommand||l.deepEqual(this._prevCommand,A),this._prevCommand?.id,this._rememberShow(A),p=n.requestShow({showId:a,navId:String(I),emailId:C,isNew:C===void 0}),h=!0;const E=()=>P.endShowFill(a);Promise.allSettled([p,m.whenReady()]).then(E),String(I),d=!0}catch(_){u=_,h&&a&&n.failShow(a,_),a&&Ne(this._container)?.endShowFill(a),l.isAbortError(_)||(Fo(_),void 0)}finally{this._eventLock.resumeChange()}if(!d)throw u instanceof Error?u:new Error(`[emailmaker] show() setup failed: ${String(u??"unknown error")}`);return Re("show-init-deferred",Promise.all([p,m?.whenReady().catch(_=>{if(_ instanceof Oe){const S=zn(_);throw S?new Error(`[emailmaker] show(): email open failed (${S})`,{cause:_}):_}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:s,reload:i}=mg(e),a=l.generateUUID();let c=!1;try{await this.setBlocks(o),l.throwIfAborted(t.signal),i&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const d=n.id!==void 0&&n.id!==""?String(n.id):void 0,u=de(this._container);if(!i&&d!==void 0&&u.sessionKey()===Bt(d)){const D=Mr(n)?await this._storeShownBlock(n):void 0,j={id:a,token:++this._showToken},x=u.show(D,j),C=t.requestShow({showId:a,navId:d,emailId:void 0,isNew:!1});c=!0,await Re("show-block-init",Promise.all([C,x?.whenReady().catch(()=>{})]),{showId:a});return}const p=r||i?await da(this._container,String(n.id)):void 0,m=p&&(i||Mr(n))?await this._storeShownBlock({...pe(p,this._container),...n}):r||i?p:await this._storeShownBlock(n);if(l.throwIfAborted(t.signal),!m)throw new Error(`[emailmaker] show(): block ${String(n.id)} not found`);s!==void 0&&m.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(s.filter(D=>D.id!==void 0).map(D=>[D.id,pn(D,String(m.id))])),this._prevCommand=void 0,this._lastShow=void 0;const h=m.id!==void 0?String(m.id):l.generateUUID(),_={id:a,token:++this._showToken};en(this._container);const S=i?u.reloadBlock(h,m,_):u.openBlock(h,m,_);m.id;const v=t.requestShow({showId:a,navId:h,emailId:void 0,isNew:m.id===void 0});c=!0;const b=S.whenReady().catch(D=>{if(D instanceof Oe)throw D});await Re("show-block-init",Promise.all([v,b]),{showId:a})}catch(d){throw c&&t.failShow(a,d),d}}async _storeShownBlock(e){const t=je(e,this._container,await _t(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();l.throwIfAborted(e.signal);const t=de(this._container);if(Z(t.sessionKey())&&!t.hasSuspended())throw new Error("[emailmaker] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:Lr,fallbackTitle:Bs(this._container)});if(l.throwIfAborted(e.signal),!n)throw qg(t.emailSaveState().error);return ge(la(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=de(this._container),t=e.current();if(!t||!Z(e.sessionKey()))throw new Error("[emailmaker] saveBlock(): no open block");return ad(t,async()=>{await t.whenReady();const n=Zt(t),r=t.get().version,o=t.get().serverId,s=typeof n.global_block=="boolean"?n.global_block:o!=null&&_a(n.html??"").emBlockId===String(o),i=o!=null&&s?ba(n.html,String(o),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:i,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},c=this._dataSources.blocks,d=await Yg(this._container,t.get().serverId,a.html),u=t.get().serverId==null?c.create(a,{source:Lr}):c.update(String(t.get().serverId),a,{source:Lr}),p=await _g(this._container,u,m=>{m&&d(),m&&de(this._container).current()===t&&t.get().serverId==null&&m.id!==void 0&&t.markSaved(r,String(m.id))});if(!p)throw new Error("[emailmaker] save(): block was not saved");return d(),t.markSaved(r,p.id!==void 0?String(p.id):void 0),pe(p,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=ua(e);const n=this._queuedShow(e,t).then(r=>r===Ta?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),l.throwIfAborted(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=de(this._container);if(n!==void 0&&r.sessionKey()===Bt(n))return;const o=t.code===void 0&&n!==void 0?await da(this._container,n):void 0,s=o&&Mr(t)?await this._storeShownBlock({...pe(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!s)throw new Error(`[emailmaker] openBlock(): block ${String(n)} not found`);en(this._container);const i=r.openBlockOver(s.id!==void 0?String(s.id):l.generateUUID(),s);s.id,r.hasSuspended(),ue(this._container,l.events.ON_BLOCK_OPEN_ID).fire({block:s}),await i.whenReady().catch(a=>{if(a instanceof Oe)throw r.current()===i&&(ue(this._container,l.events.ON_BLOCK_CLOSE_ID).fire({block:s,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),Cp(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function Xg(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 Jg(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),o=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:o,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Xg(e)}}function xr(e,t){return t?Jg(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Ca=["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"],Qg=[...Ca,"html","id","project","password"],AS=new Set(["html",...Ca,"global_block","project"]);function Zg(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(Qg),r={};for(const o of Object.keys(e))n.has(o)||(r[o]=e[o]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function ev(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Zg(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 Fr=new WeakMap;function tv(e){let t=Fr.get(e);return t||(t={byId:new Map,fallback:[]},Fr.set(e,t)),t}function nv(e){Fr.delete(e)}function rv(e,t){const{byId:n,fallback:r}=tv(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const s=r.indexOf(o);return s>=0&&r.splice(s,1),o}return}for(let o=r.length-1;o>=0;o--){const s=r[o],i=e.name!=null&&e.name!==""&&s.name!=null&&s.name!==""&&s.name===e.name,a=e.type!=null&&e.type!==""&&s.insertFrom===e.type;if(i&&a)return r.splice(o,1),s.id!=null&&s.id!==""&&n.delete(String(s.id)),s}}async function ov(e,t){const{blocks:n}=Et(e);return await n.cache.getIfPresent(t)??void 0}async function sv(e,t){if(!t.blockId)return;const n=await ov(e,t.blockId);if(n)return ev(n,t)}async function iv(e,t){const n=rv(e,t);if(n)return xr(e,n);const r=await sv(t,e);return r?xr(e,r):xr(e,void 0)}var av=l.createIdentifier("application_block_inserted"),lv=-1e3,Aa=new WeakSet;function cv(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 dv(e){if(!e||Aa.has(e))return;Aa.add(e);const t=new l.Disposable,n=le(e);return t.addDisposable(n.addListenerAsyncPipe(av,async(r,o)=>{const s=cv(r)?await iv(r,e):r;return o?o(s):s},lv)),t.addDisposable({dispose:()=>{nv(e)}}),t}var uv=Kt("plugin.readBlockAutosave"),DS=l.createIdentifier$1("blockDocuments.provided"),Da=l.createIdentifier$1("plugin.earlyWindow");function fv(e){return e.getOrCreateInstance(Da,()=>({depth:0}))}function pv(e){const t=fv(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function Pa(e){return(e?.getInstance(Da)?.depth??0)>0}function Oa(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,s,i)=>{const a=e(o,s,i);if(r&&Pa(t)){const c=n;queueMicrotask(()=>{o.call(i,c)})}return a}}var Br=100,hv=class extends l.Disposable{_container;_events;constructor(e){super(),this._container=e;const t=dv(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:s}=Et(e),i=J(e,l.events.ON_SHARE_ID),a=J(e,l.events.ON_SHOW_PREVIEW_ID),c=J(e,l.events.ON_EMAIL_CLONE_ID),d=J(e,l.events.ON_BLOCK_OPEN_ID),u=J(e,l.events.ON_BLOCK_CLOSE_ID),p=J(e,l.events.ON_BLOCK_CLONE_ID),m=J(e,l.events.ON_BLOCK_INIT_ID),h=J(e,l.events.ON_BLOCK_CHANGED_ID),_=J(e,l.events.ON_CODE_VALIDATE_ID),S=J(e,l.events.ON_IMPORT_VALIDATE_ID),v=J(e,l.events.ON_SUBJECT_CHANGED_ID),b=J(e,l.events.ON_EMAIL_CHANGED_ID),D=J(e,l.events.ON_PREHEADER_CHANGED_ID),j=J(e,l.events.ON_SAVEBUTTON_CLICK_ID),x=J(e,l.events.ON_BLOCK_SAVEBUTTON_CLICK_ID),C=J(e,l.events.ON_NEXTBUTTON_CLICK_ID),I=J(e,l.events.ON_SEND_LIVEPREVIEW_ID),R=J(e,l.events.ON_SEND_TESTEMAIL_ID),A=J(e,ug),O=J(e,l.events.ON_CONTENT_CHANGED_ID),L=J(e,dg),w=J(e,l.events.ON_PREVIOUSBUTTON_CLICK_ID),P=J(e,l.events.ON_SEND_EMAIL_MODAL_ID),k=l.filter(J(e,l.events.ON_EMAIL_INIT_ID),E=>!E.reset),F=J(e,l.events.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:H(D),handleSubjectChanged:H(v),handleValidate:H(_),handleImportValidate:H(S),handleReadEmail:H(n.handlerRead,E=>E,E=>E&&et(E,e)),handleSaveEmail:H(n.onSave,function({prev:E,patch:y,value:B,source:U}){const W=E?ge(E,e):void 0;return{prev:W,patch:mt(W,ge(y,e)),value:ge(B,e),source:U}},E=>E?et(E,e):void 0),handleRemoveEmail:H(n.onRemove,({value:E,source:y})=>({value:ge(E,e),source:y}),()=>{}),handleReadCommonBlocks:H(A,E=>E.project,E=>E?.map(y=>je(y,e))),handleReadTemplateBlocks:H(L,E=>E,E=>E?.map(y=>je(y,e))),handleReadBlocks:H(t.byForeignKey("project").handleRead,E=>vt(e).requested||String(E),E=>E?.map(y=>je(y,e))),handleReadBlock:H(t.handlerRead,E=>E,E=>E?je(E,e):void 0),handleOpenBlock:H(d,({block:E})=>({block:pe(E,e)})),handleCloseBlock:H(u,({block:E,hasUnsavedChanges:y})=>({block:pe(E,e),hasUnsavedChanges:y})),handleCloneBlock:H(p,E=>pe(E,e)),handleSaveBlock:H(t.onSave,function({prev:E,patch:y,value:B,source:U}){const W=B.global_block===!0&&B.id&&typeof B.html=="string"?{...B,html:Dg(B.html,String(B.id))}:B,ie=E?pe(E,e):void 0;return{prev:ie,patch:mt(ie,pe(y,e)),value:pe(W,e),source:U}},E=>E?je(E,e):void 0),handleRemoveBlock:H(t.onRemove,({value:E,source:y})=>({value:pe(E,e),source:y}),()=>{}),handleReadComments:H(r.byForeignKey("post").handleRead,E=>E,E=>E?.map(y=>Rr(y,e))),handleSaveComment:H(r.onSave,function({prev:E,patch:y,value:B,source:U}){const W=E?bt(E,e):void 0;return{prev:W,patch:mt(W,bt(y,e)),value:bt(B,e),source:U}},E=>E?Rr(E,e):void 0),handleRemoveComment:H(r.onRemove,({value:E,source:y})=>({value:bt(E,e),source:y}),()=>{}),handleReadEmailRevisions:H(o.byForeignKey("parent").handleRead,E=>E,E=>E?.map(y=>fn(y,e))),handleReadEmailAutosave:H(J(e,Hi),E=>E,E=>E?fn(E,e):null),handleEmailAutosave:H(o.onSave,function({prev:E,patch:y,value:B,source:U}){return{value:kr(B,e),source:U}},E=>E?fn(E,e):void 0),handleRemoveEmailAutoSave:H(o.onRemove,({value:E,source:y})=>({value:kr(E,e),source:y}),()=>{}),handleReadBlockRevisions:H(s.byForeignKey("parent").handleRead,E=>E,E=>E?.map(y=>pn(y))),handleReadBlockAutosave:H(J(e,uv),E=>E,E=>E?pn(E):null),handleBlockAutosave:H(s.onSave,({value:E,source:y})=>({value:ma(E),source:y}),E=>E?pn(E):void 0),handleRemoveBlockAutoSave:H(s.onRemove,({value:E,source:y})=>({value:ma(E),source:y}),()=>{}),handleBlockInit:H(m,E=>pe(E,e)),handleBlockChanged:H(l.debounce(h,Br),E=>pe(E,e)),handleEmailChanged:H(l.debounce(b,Br),E=>ge(E,e)),handleEmailInit:Oa(H(k,E=>ge(E,e)),e),handlePreviousButtonClick:H(w,E=>ge(E,e)),handleNextButtonClick:H(C,E=>ge(E,e)),handleSaveButtonClick:H(j,E=>ge(E,e)),handleSaveBlockButtonClick:H(x,E=>pe(E,e)),handleHtmlChanged:H(l.debounce(O,Br)),handleTestEmailSend:H(R,({html:E,...y})=>({...y,code:E,compiled:{html:E,ampHtml:""}})),handleTestEmailModal:H(P,E=>ge(E,e)),handleCloneEmail:H(c,E=>ge(E,e)),handleShareEmail:H(i),handlePreviewEmail:H(a),handleLivePreviewEmail:H(I),handleAnalyticsEvent:H(F)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new Qe(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},mv=l.createIdentifier$1("DataController"),gv=l.createIdentifier$1("DataEvents");function Ra(e){return e.getOrCreateInstance(mv,()=>{const t=new zg(e);return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(t),t})}function ka(e){return e.getOrCreateInstance(gv,()=>new hv(e))}var vv=l.createIdentifier$1("plugin.pluginStart");function Na(e){return e.getOrCreateInstance(vv,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>t()),{done:n,finish:t}})}function Ev(e){return Na(e).done}function _v(e){const t=Na(e);return t.run===void 0&&(t.run=(e.getInstance(l.PLUGIN_COLLECTION_ID)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var bv=l.createIdentifier$1("plugin.startupShow");function Sv(e){const t=Ra(e),n=ka(e),r=e.getInstance(l.OPTIONS_SOURCE_ID),o=e.getInstance(l.DISPOSABLE_ID),s={current:Promise.resolve()};e.inject(bv,s);let i=!1;const a=r?.watch(d=>{d&&n.setOptions(d),i=(d?.plugins?.length??0)>0,s.current=s.current.catch(()=>{})}),c=r?.select(d=>d?.content).watch(d=>{if(d===void 0)return;const u=()=>(te(ce.showStart),t.show(d).finally(()=>te(ce.showEnd))),p=i?Ev(e).then(u):u();p.catch(()=>{}),s.current=p});a&&o?.addDisposable(a),c&&o?.addDisposable(c)}function yv(e){const t=Ra(e);return{...ka(e).get(),show(n){return te(ce.showStart),t.show(n).finally(()=>te(ce.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return te(ce.showStart),t.showBlock(n,r).finally(()=>te(ce.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function La(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function hn(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let s=t;s<e.length;s++){const i=e[s];if(o){o=!1;continue}if(i==="\\"){o=!0;continue}if(r){i===r&&(r="");continue}if(i==='"'||i==="'"){r=i;continue}if(i==="("){n++;continue}if(i===")"&&(n--,n<0))return!1}return n===0}function wv(e){return(t,n,r)=>hn(t)?e(t,n,r):!1}function Iv(e){return t=>hn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Tv(e){return(t,n,r)=>hn(t)?La(t)?e(t,n,r):t:!1}function Cv(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return hn(n)?La(n)?e(t):t:!1}}function Av(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function jr(e,t){const n=e.length;for(let r=0;r<n;r++){const o=e.charCodeAt(r);if(o===0||t==='"'&&o===34||t==="'"&&o===39||t===""&&(o===32||o===9||o===10||o===13||o===12||o===34||o===39||o===60||o===62||o===61||o===96))return!1}return!0}function Dv(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let s=0;s<e;s++){const i=r[s]%62;o+=t.charAt(i)}return o}var Pv=8,Ov=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=Dv(Pv),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},mn=new Ov;function Ma(e,t){return t!==void 0&&!jr(e,t)?`%|{${mn.getOrCreateByKey(e)}}|%`:e}function Rv(e){const t=mn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function oe(e,t,n){return t!==void 0?jr(e,t)?e:`%|{${mn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function kv(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ne(e){return e.startsWith("<!--")&&e.endsWith("-->")?kv(e.slice(4,-3)):e}function Nv(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const o=e.match(/\[%\s*([^%]*?)\s*%\]/);o&&(r=o[1]);const s=r.trim();return t.test(s)||n.test(s)}function Lv(e,t,n){return t!==void 0?jr(e,t)?e:`%|{${mn.getOrCreateByKey(e)}}|%`:n||Av(e)||Nv(e)?`<!--${e}-->`:e}var Ue=wv(oe),$e=Iv(ne),Mv=Tv(oe),xv=Cv(ne),xa=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",Rv),e.escape("@{","}",oe,!0).unescape("<!--@{","}-->",ne,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Ma,!0),e.escape("{{","}}",Ma,!0),e.createSyntax("brace-percent").escape("{%","%}",oe).unescape("<!--{%","%}-->",ne),e.createSyntax("brace-hash").escape("{#","#}",oe).unescape("<!--{#","#}-->",ne),e.createSyntax("proscript").escape("[%","%]",Lv,!0).unescape("<!--[%","%]-->",ne,!0),e.createSyntax("getresponse").escape("[[IF","]]",oe).escape("[[if","]]",oe).escape("[[ELSE]]","",oe).escape("[[else]]","",oe).escape("[[ENDIF]]","",oe).escape("[[endif]]","",oe).unescape("<!--[[IF","]]-->",ne).unescape("<!--[[if","]]-->",ne).unescape("<!--[[ELSE]]","-->",ne).unescape("<!--[[else]]","-->",ne).unescape("<!--[[ENDIF]]","-->",ne).unescape("<!--[[endif]]","-->",ne),e.createSyntax("expert-sender").escape("<if",">",oe).escape("</if",">",oe).escape("<else",">",oe).escape("</else",">",oe).escape("<var ",">",oe,!0).unescape("<!--<if ",">-->",ne).unescape("<!--</if",">-->",ne).unescape("<!--<else ",">-->",ne).unescape("<!--</else",">-->",ne).unescape("<!--<var",">-->",ne,!0),e.createSyntax("velocity").escape("#if",")",Ue).escape("#elseif",")",Ue).escape("#else","",oe).escape("#foreach",")",Ue).escape("#macro",")",Ue).escape("#set",")",Mv,!0).escape("#parse",")",Ue).escape("#include",")",Ue).escape("#evaluate",")",Ue).escape("#end","",oe).escape("#break","",oe).escape("#stop","",oe).unescape("<!--#macro","-->",$e).unescape("<!--#if","-->",$e).unescape("<!--#elseif","-->",$e).unescape("<!--#else","-->",ne).unescape("<!--#foreach","-->",$e).unescape("<!--#parse","-->",$e).unescape("<!--#include","-->",$e).unescape("<!--#evaluate","-->",$e).unescape("<!--#end","-->",ne).unescape("<!--#break","-->",ne).unescape("<!--#stop","-->",ne).unescape("<!--#set","-->",xv,!0),e.createSyntax("mailchimp").escape("*|","|*",oe).unescape("<!--*|","|*-->",ne)},Ur="bare",Fv=new Map;function Bv(e){return e?Fv.get(e)??Ur:Ur}var Fa=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function Ba(e){return Fa.includes(e)}function St(e){return e==="bare"||e==="html-comment"}function $r(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function jv(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!St(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[d,u]of[["output",r.output],["editor",r.editor]])if(u!==void 0&&!St(u))return t(`templateDirectives.${d}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!$r(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[d,u]of Object.entries(r.syntaxes))if(!(!Ba(d)||u===void 0||St(u))){if(!$r(u))return t(`templateDirectives.syntaxes.${d}: expected a form or an object, configuration ignored.`),n;for(const p of["output","editor"]){const m=u[p];if(m!==void 0&&!St(m))return t(`templateDirectives.syntaxes.${d}.${p}: unknown form "${String(m)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??Ur;let s=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),s=void 0);const i=[];if(r.syntaxes)for(const d of Object.keys(r.syntaxes)){if(!Ba(d)){t(`templateDirectives.syntaxes: unknown syntax id "${d}", entry ignored.`);continue}i.push(d)}else i.push(...Fa);const a={},c={};for(const d of i){const u=r.syntaxes?.[d],p=$r(u)?u:void 0,m=(St(u)?u:p?.output)??o;let h=p?.editor??s??m;m==="bare"&&h==="html-comment"&&(t(`templateDirectives.syntaxes.${d}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),h="bare"),a[d]=m,c[d]=h}return{output:a,editor:c}}function ja(e,t,n,r){for(let o=t;o<n;o++){const s=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?s===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(s)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):s==="<"?r.insideTag=!0:s===">"?r.insideTag=!1:r.insideTag&&(s==='"'||s==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=s,r.unquotedAttr=!1):r.insideTag&&/\S/.test(s)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(s)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function yt(e,t){return e.start<t.end&&t.start<e.end}function Ua(e,t,n,r,o=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const s=t.flatMap(u=>u.match(e).flatMap(p=>!Number.isInteger(p.start)||!Number.isInteger(p.end)||p.start<0||p.end>e.length||p.start>=p.end?[]:[{range:p,mapFn:u.mapFn,overrideBuiltins:u.overrideBuiltins,syntax:u.syntax,isVariable:u.isVariable}])).sort((u,p)=>u.range.start-p.range.start||u.range.end-p.range.end),i=[],a=o.slice().sort((u,p)=>u.start-p.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let d=0;for(const{range:u,mapFn:p,overrideBuiltins:m,syntax:h,isVariable:_}of s){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):ja(e,d,u.start,c),d=u.end,a.some(D=>yt(D,u)))continue;const S=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,v=e.substring(u.start,u.end),b=p(v,S,c.insideTag);b!==!1&&b!==v&&(i.push({range:u,text:b,overrideBuiltins:m,syntax:h,isVariable:_}),a.push(u))}return i.sort((u,p)=>u.range.start-p.range.start||u.range.end-p.range.end)}function Uv(e,t){const n=t.reduce((a,{mapFn:c,start:d,end:u,syntax:p,isVariable:m})=>(a[d]||(a[d]=[]),a[d].push({value:u,mapFn:c,syntax:p,isVariable:m}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),s=[];let i;for(;(i=o.exec(e))!==null;){const a=i[0];s.push({start:i.index,startToken:a,endTokens:n[a]})}return s}function Hr(e,t,n,r,o=!1){const s=[];if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return s;const i=Uv(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let d=0;d<i.length;d++){const{start:u,startToken:p,endTokens:m}=i[d];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):ja(e,c,u,a),c=u;const h=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let _=!1;for(const{mapFn:S,value:v,syntax:b,isVariable:D}of m){let j=u+p.length,x=e.indexOf(v,j);for(;x!==-1;){let C=x,I=u+p.length,R=0;for(;C!==-1;){const P=e.indexOf(p,I);if(P!==-1&&P<C)R++,I=P+p.length,C=e.indexOf(v,I);else if(R>0)R--,I=C+v.length,C=e.indexOf(v,I);else break}if(C<0)break;const A=C+v.length,O=e.substring(u,A),L=S(O,h,a.insideTag);if(L===!1){j=x+Math.max(v.length,1),x=e.indexOf(v,j);continue}(o||L!==O)&&s.push({range:{start:u,end:A},text:o?O:L,syntax:b,isVariable:D});const w=i.findIndex(({start:P})=>P>=A);w>d?d=w-1:d=i.length,_=!0;break}if(_)break}}return s}function gn(e,t){if(!t.length)return e;const n=t.slice().sort((o,s)=>s.range.start-o.range.start);let r=e;for(const{text:o,range:s}of n)r=r.slice(0,s.start)+o+r.slice(s.end);return r}var $v=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=xa){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,s,i){return t.push({start:r,end:o,mapFn:s,isVariable:i,syntax:this.syntax||r}),this},unescape(r,o,s,i){return n.push({start:r,end:o,mapFn:s,isVariable:i,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let o=!1;const s={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(i=>i!==n),this._unescapeMatchers=this._unescapeMatchers.filter(i=>i!==r))}};return this.addDisposable(s),s}_collectMappings(e,t,n){const r=Hr(e,this._escapes,t,n),o=Ua(e,this._escapeMatchers,t,n),s=o.filter(c=>c.overrideBuiltins).map(c=>c.range),i=r.filter(c=>!s.some(d=>yt(d,c.range))),a=o.filter(c=>c.overrideBuiltins||!i.some(d=>yt(c.range,d.range)));return[...i,...a].sort((c,d)=>c.range.start-d.range.start||c.range.end-d.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=Hr(e,this._unescapes,t),r=Ua(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),s=n.filter(a=>!o.some(c=>yt(c,a.range))),i=r.filter(a=>a.overrideBuiltins||!s.some(c=>yt(a.range,c.range)));return[...s,...i].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>Bv(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return Hr(e,this._escapes,t,n,!0)}getEscapedText(e,t){return gn(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return gn(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=s=>s===void 0?void 0:t[s],r=Object.values(t);let o=e;return r.includes("bare")&&(o=gn(o,this._collectRevertMappings(o).filter(s=>n(s.syntax)==="bare"))),r.includes("html-comment")&&(o=gn(o,this._collectMappings(o).filter(s=>!s.isVariable&&n(s.syntax)==="html-comment"&&s.text.startsWith("<!--")&&s.text.endsWith("-->")))),o}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}},$a="em___script",wt=`<${$a}`,Vr=`</${$a}>`;function Ha(e){return e.replace("<script",wt).replace("<\/script>",Vr)}var Va=new $v(e=>{e.escape("<script","<\/script>",t=>Ha(t)).unescape(wt,Vr,t=>t.replace(wt,"<script").replace(Vr,"<\/script>")),e.escape("<script","/>",t=>Ha(t)).unescape(wt,"/>",t=>t.replace(wt,"<script")),xa(e)});function Hv(e){const t=jv(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return Yo();const n=new Set(Object.keys(t.output).filter(o=>t.output[o]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:o=>Va.normalizeToPolicy(o,t.editor),toOutputForm:o=>Va.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Wo(r)}}function Vv(e){let t;e.injectFactory(l.TEMPLATE_DIRECTIVES_ID,()=>{const n=e.getInstance(l.CONFIG_SOURCE_ID)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:Hv(n)}),t.policy})}function PS(e){return e}var Gv=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function Wv(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function Yv(e,t){const n=[];for(const r of e.awaits?.services??[])for(const o of t.get(r)??[])o!==e&&n.push(o);return n}function Ga(e){const t=Wv(e),n=[],r=new Set,o=[],s=new Set,i=a=>{if(!r.has(a)){if(s.has(a)){const c=o.indexOf(a);throw new Gv([...o.slice(c),a].map(d=>d.name))}s.add(a),o.push(a);for(const c of Yv(a,t))i(c);o.pop(),s.delete(a),r.add(a),n.push(a)}};for(const a of e)i(a);return n}var qv=[{name:"rest.client",setup:ig},{name:"auth.oauth",setup:l.provideOAuth},{name:"rest.identityHeaders",setup:zm},{name:"rest.localeHeader",setup:tg},{name:"lifetime.destroyable",provides:[Sr],setup:Qh},{name:"appInit",provides:[l.APP_ID,On],setup:gc},{name:"config",provides:[l.CONFIG_SOURCE_ID],setup:Xh},{name:"templateDirectives",provides:[l.TEMPLATE_DIRECTIVES_ID],setup:Vv},{name:"email.documents",setup:vm},{name:"show.initPipeline",provides:[l.INIT_PIPELINE_ID],setup:ag},{name:"show",setup:Sv},{name:"locale.service",provides:[Ze],setup:Wm},{name:"locale.fromConfig",awaits:{services:[l.CONFIG_SOURCE_ID,Ze]},setup:Ym},{name:"canvas.early",setup:Wp},{name:"canvas.previewSettings",setup:ah},{name:"canvas.sandboxExtensions",setup:ch},{name:"canvas.sandboxScriptRelay",setup:fh},{name:"canvas.headerSync",provides:[fr],setup:Kp},{name:"canvas.headersAfterRecovery",setup:zp},{name:"canvas.ampSync",setup:Vu},{name:"canvas.moduleBridge",setup:Sf},{name:"canvas.port",setup:Zu},{name:"canvas.images",setup:Ju},{name:"canvas.edits",setup:Vp},{name:"canvas.surfaceFollowsSession",setup:Dp},{name:"canvas.blockContent",setup:Ap},{name:"canvas.sandboxFill",provides:[dr],setup:Oh},{name:"canvas.reactions",setup:Gp}],Wa;function Gr(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID);if(t)return t;e.getInstance(l.DISPOSABLE_ID)||e.inject(l.DISPOSABLE_ID,new l.Disposable);const n=fe();e.inject(l.OPTIONS_SOURCE_ID,n),Wa??=Ga(qv);for(const r of Wa)r.setup(e);return n}function Kv(e){}var zv=[{name:"save.previewFollow",setup:Kv}],Ya=l.createIdentifier$1("plugin.lateUnitsInstalled");function Xv(e){if(!e.getInstance(Ya)){e.inject(Ya,!0);for(const t of Ga(zv))t.setup(e)}}function Jv(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function Qv(e){if(!e)return;const t=l.decodeJwt(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 Zv=l.defineMixin(e=>{let t,n,r;return{async setOptions(o){const s=r!==o.getAuthToken,i=!l.deepEqual(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(l.SECURITY_MODULE_ID)||!o.getAuthToken)&&!(!s&&!i&&!a))try{const c=await o.getAuthToken(o.user,o.project);e.inject(l.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(c||""));const d=Qv(c);if(!d)return;e.inject(l.STANDALONE_PROJECT_ID,d);const u=e.getInstance(l.APP_ID),p=u?await u.catch(()=>{}):void 0;e.inject(l.APP_ID,Promise.resolve(Jv(d,p)))}catch{}}}});function eE(e,t){if(e.getInstance(l.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(l.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=l.getEvent(e,l.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var tE=l.defineMixin(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!ht(r)){t&&(Bh(e),br(r)),t=void 0;return}const s=nn(r);if(!s||t===s&&e.getInstance(l.SECURITY_MODULE_ID))return;t=s,e.inject(l.SECURITY_MODULE_ID,s);const i=e.getInstance(l.DISPOSABLE_ID);i&&eE(e,i)}}}),nE=l.defineMixin(e=>{const t=e.getInstance(l.DISPOSABLE_ID),n=l.getEvent(e,l.APP_LOAD_EVENT_ID),r=H(n),o=t.addDisposable(new Qe(r));return{setOptions({handleLoad:s}){o.setListener(s)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function qa(e,t,n=!0){const r=e,o=t;for(const s of Object.keys(o)){const i=o[s];i!=null&&(n&&typeof i=="object"?r[s]=qa(r[s]||{},i,!0):r[s]=i)}return e}async function rE(e){const t=(await $l.__vitePreload(()=>Promise.resolve().then(()=>Promise.resolve(Rt("./static/umd/3f12d6ff.js")).then(n=>Tn.__toESM(n.default))),void 0,{}.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var Ka=l.createIdentifier$1("EditorOptions"),Wr=l.MONACO_EDITOR_OPTIONS;function oE(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function sE(e){return e.getOrCreateInstance(Ka,()=>{const t=fe(Wr);let n=Wr.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(rE(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function iE(e){return e?.getInstance(Ka)?.get()??Wr}function aE(e,t={}){const n=sE(e);n.set(qa({...n.get()},oE(t)))}function lE(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function cE(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var dE=l.createIdentifier$1("plugin.publicConfig");function Yr(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.get()??{}}function za(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Xa(e){const t=Ti(e),n=Yr(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:cE(iE(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Ja(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.get()!==void 0}function uE(e){const t=l.createQueue(),n=ue(e,l.CONFIG_CHANGED_EVENT_ID);let r,o,s=!1;const i=async()=>{try{return e.getInstance(l.APP_ID)===void 0?{}:(await e.getInstanceAsync(l.APP_ID))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:p=!1}={})=>{await e.getInstance(l.CONFIG_SOURCE_ID)?.ready(),Po(e).set(Yr(e).revisionService===!0);const{codeModeDirection:m,editor:h}=Yr(e);h&&aE(e,lE(h)),m!==void 0&&!(p&&m===o)&&(o=m,m==="none"?mr(e,!1):(mr(e,!0),nh(e,m)))},c=async()=>{if(!Ja(e))return;const p=Xa(e),m=JSON.stringify(p);m!==r&&(r=m,await n.fire(p))},d=async p=>{const m=e.getInstance(l.CONFIG_SOURCE_ID),h={advancedConfigs:za(e).advancedConfigs,serverSide:await i(),user:p};m?.setAdvancedConfigs({...h.advancedConfigs,...h.user?.advancedConfigs});const _=m?.layers().user.mode;m?.replace(h.user?.mode===void 0&&_!==void 0?{...h.user,mode:_}:h.user,"user"),m?.replace(h.serverSide,"server"),await a(),await c()},u=p=>{const{commonStyles:m,...h}=p;return"commonStyles"in p&&oh(e,m===void 0?void 0:m),h};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:i,getConfig:()=>Ja(e)?Xa(e):{},setConfig:t.decorate(async p=>{await d(u(p))}),updateConfig:t.decorate(async p=>{const m=u(p);await d({...za(e).user,...m})}),announceAssembled(){s||(s=!0,e.getInstance(l.CONFIG_SOURCE_ID)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function Qa(e){return e.getOrCreateInstance(dE,()=>uE(e))}function fE(e){const t=Qa(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var pE=l.defineMixin(e=>{const t=e.getInstance(l.DISPOSABLE_ID),n=t.addDisposable(new l.AsyncEmitter),r=t.addDisposable(new l.AsyncEmitter),o=l.getEmitter(e,l.CONFIG_CHANGED_EVENT_ID),s=H(n.event),i=H(r.event),a=Oa(H(o.event),e),c=t.addDisposable(new Qe(s)),d=t.addDisposable(new Qe(i)),u=t.addDisposable(new Qe(a));return{instance:{handleSetOptions:s,handleOptionsChanged:i,handleConfigChanged:a},async setOptions(p){c.setListener(p.handleSetOptions),d.setListener(p.handleOptionsChanged),u.setListener(p.handleConfigChanged),Qa(e).announceAssembled(),await n.fire(p),await r.fire(p)},dispose(){}}}),qr,Za="core";function hE(){const e=__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Za],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function mE(e){const t=__emailmaker__?.require?.warm;return typeof t!="function"?It().then(()=>{}):t([Za],e)}function It(){return qr===void 0&&(qr=hE().then(e=>(rt()&&e.installDiagnostics().catch(t=>{}),e))),qr}var Kr=null,zr=null;async function gE(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Xr(){return Kr||(Kr=It().then(()=>{})),Kr}function el(e){return zr||(zr=gE(e)),zr}function vE(){return el(typeof __emailmaker__<"u"?__emailmaker__:void 0)}function EE(){const e=typeof __emailmaker__<"u"?__emailmaker__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function _E(e){return Promise.all([Xr(),el(e)]).then(()=>{})}function bE(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function tl(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>mE(t?{priority:t}:void 0)).then(()=>(nr(t?{priority:t}:void 0),n?Xr():void 0)).catch(()=>{})}function SE(e){const t=bE(e);if(t==="eager")tl(e);else if(t==="idle"){const n=()=>tl(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var nl="PluginRegistry";function yE(e=l.resolveContainer()){return e.getOrCreateInstance(nl,()=>new zl)}var rl=new Xl(()=>yE()),wE=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],IE=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],vn=new Map([...wE.map(e=>[e,"event"]),...IE.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),TE=new Map([["use","use `useAsync()` or await `ready` first"]]);function CE(e){return TE.get(e)??"await `ready` first"}var AE=new Set(["async","queued"]),DE=Symbol.for("emailmaker.earlyCtxPlaceholder");function ol(e){return e[DE]=!0,e}function PE(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${CE(e)}).`)}function OE(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function RE(e){return[...vn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function kE(e,t){for(const n of RE(e)){const r=vn.get(n);if(r!==void 0&&AE.has(r)){const o=async(...s)=>{await t;const i=e[n];if(typeof i!="function"||i===o)throw OE(n);return i.apply(e,s)};e[n]=ol(o);continue}e[n]=ol(()=>{throw PE(n)})}}function NE(e,t,n){e.getInstanceAsync(tt).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function LE(e,t){e.getInstanceAsync(tt).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var ME=l.defineMixin(e=>{let t;function n(){return new Promise(o=>{const s=e.getOrCreateInstance(l.LATE_SURFACE_LISTENERS_ID,()=>new Set),i=()=>{s.delete(i),o()};s.add(i)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const s=e.getInstance(l.INSTANCE_ID),i=e.getInstance(nl);if(!t){t=new Kl(s,i,{ensureHostRuntimeReady:vE,explainScriptFailure:EE,openEarlyWindow:()=>pv(e),reportLoadFailure:d=>LE(e,d)}),e.inject(l.PLUGIN_COLLECTION_ID,t);const c=t.onLifecycle(d=>{d.type==="create:error"&&NE(e,d.name,d.error)});e.getInstance(l.DISPOSABLE_ID)?.addDisposable(c)}const a=o?.plugins||[];s&&(ks(e),a.length>0&&kE(s,n()),await t.setPlugins(a))},instance:{use(o){return typeof o=="function"?r().useByCtor(o):r().useByKey(o)},useAsync(o){return r().useAsync(o)},waitPlugin(o){return r().waitFor(o)}},dispose(){t?.dispose(),t=void 0}}}),sl=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const o=this._listeners.indexOf(r);o>=0&&this._listeners.splice(o,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},xE=l.createIdentifier$1("ELEMENT_INSERT_HTML_PIPELINE"),FE=l.createIdentifier$1("BLOCK_INSERT_HTML_PIPELINE"),BE="application_block_inserted",jE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(FE,()=>new sl).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService),o=n?e.bind(n):e;return r.addListener(BE,o,t)}},Jr=l.createIdentifier$1("ComponentRegistry"),UE=l.createIdentifier$1("ComponentRegistryGate");function Qr(){return l.DependencyResolver.getOrCreateInstance(UE,()=>({pending:[]}))}function $E(e=Jr){return Qr().factory!==void 0||l.DependencyResolver.getInstance(e)!==void 0}function Zr(e,t,n=Jr){if($E(n)){t(En(e,n));return}Qr().pending.push(()=>t(En(e,n)))}function En(e,t=Jr){const n=l.DependencyResolver.getInstance(t);if(n)return n;const r=Qr().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return l.DependencyResolver.getOrCreateInstance(t,r)}var HE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=s=>{if(!n){n=!0;for(const i of t)i.dispose();e(s)}};t.push(this._container.addService(l.ATOMS_HANDLERS_ID,{execute:s=>{r(s.value.map(i=>({name:i.name,html:i.html})))}}));const o=this._container.getInstance(l.HEADLESS_MODE_ID)?.watch(s=>{s&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(l.ATOMS_HANDLERS_ID,{execute:r=>{const o=En(n),s=r.value.find(i=>i.name===e);if(s){const{icon:i,title:a,fallbackTooltip:c,...d}=t;i&&(s.icon=o.getReactNode(i)),a&&(s.title=o.getReactNode(a)),c&&(s.fallbackTooltip=o.getReactNode(c)),Object.assign(s,d)}}})}delete(e){this._container.addService(l.ATOMS_HANDLERS_ID,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService(l.ATOMS_HANDLERS_ID,{execute:r=>{const o=En(n);r.value.splice(t??r.value.length,0,{...e,title:o.getReactNode(e.title),icon:o.getReactNode(e.icon),fallbackTooltip:o.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(xE,()=>new sl).add(e,t??0,n)}handleInject(e,t,n){return l.getEmitter$1(this._container,l.HANDLE_ATOM_INSERT_ID).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},VE=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}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 GE(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function il(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var WE=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=l.getEmitter$1(t,l.MODAL_SHOW_EVENT),this._closeModalEmitter=l.getEmitter$1(t,l.MODAL_CLOSE_EVENT),this._updateModalEmitter=l.getEmitter$1(t,l.MODAL_UPDATE_EVENT)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Zr(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:il(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Zr(this._container,r=>{this._updateModalEmitter.fire(GE({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:il(r,n)}))})}};function _n(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var YE=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=o=>{this._loadedSettled||(this._loadedSettled=!0,r(o))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=o=>{this._readySettled||(this._readySettled=!0,r(o))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},qE=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}_createScriptHandle(e,t){const n=this._messageService.addListener(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID,o=>{if(o.key===e){if(o.phase==="load"&&o.status==="success"){r.resolveLoaded();return}if(o.phase==="ready"&&o.status==="success"){r.resolveReady();return}if(o.phase==="load"){r.rejectLoad(new Error(o.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(o.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new YE(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(l.SANDBOX_EXTENSIONS_ID,{..._n(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(l.SANDBOX_EXTENSIONS_ID,{..._n(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(l.SANDBOX_EXTENSIONS_ID,{..._n(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(l.SANDBOX_EXTENSIONS_ID,{..._n(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},KE=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function eo(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&KE.has(t)}function al(){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 to(){return`__settingsPanel:${al()}`}function no(e,t){return{type:e,props:t}}function zE(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!eo(e)}function ll(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(eo(t)){const r=to();return n(e.add(r,t)),no(r,{})}if(typeof t=="function"){const r=to();return n(e.add(r,t)),no(r,{})}if(zE(t)){const r=t.type;if(typeof r=="string")return t;if(eo(r)||typeof r=="function"){const o=to();return n(e.add(o,r)),no(o,t.props)}return t}return t}var XE=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??al();Zr(this._container,n=>{const r=i=>this._trackRegistration(i),o=ll(n,e.content,r),s=e.advancedTabs?.map(i=>({...i,content:ll(n,i.content,r)}));l.getEmitter$1(this._container,l.SETTINGS_PANEL_EVENT).fire({...e,content:o,advancedTabs:s,instanceKey:t,type:l.ADVANCED_SETTINGS_PANEL})})}closeSettingsPanel(){this._clearPanelRegistrations(),l.getEmitter$1(this._container,l.SETTINGS_PANEL_EVENT).fire(null)}},cl={SandboxScriptApi:qE,ElementsApi:HE,BlocksApi:jE,MessageService:VE,SettingsPanelApi:XE,ModalApi:WE};function ro(e,t,n,r={}){const o=Object.assign({},e);for(const[s,i]of Object.entries(t))if(i!==void 0)if(n.includes(s)&&typeof i=="object"&&i!==null){const a=o[s],c=r[s]??{};o[s]=Object.assign({},typeof a=="object"&&a!==null?a:c,i)}else o[s]=i;return o}var ve={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}},JE={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"},oo={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},dl={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},nt={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:ve.border,borderRadius:ve.borderRadius,textAlign:"center",padding:ve.padding},ul={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:ve.padding},so={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:ve.border,borderRadius:ve.borderRadiusCards};function QE(e){return{...JE,...e}}function ZE(e){return{...oo,...e,bold:e?.bold??oo.bold,italic:e?.italic??oo.italic}}function e_(e){return{...dl,...e,underline:e?.underline??dl.underline}}function t_(e){return{...nt,...e,bold:e?.bold??nt.bold,italic:e?.italic??nt.italic,border:{...nt.border,...e?.border},borderRadius:{...nt.borderRadius,...e?.borderRadius},padding:{...nt.padding,...e?.padding}}}function n_(e){return{...ul,...e,padding:{...ul.padding,...e?.padding}}}function r_(e){return{...so,...e,border:{...so.border,...e?.border},borderRadius:{...so.borderRadius,...e?.borderRadius}}}function io(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 fl(e){let t={...l.COMMON_STYLES};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function ao(e){return{text:QE(e.text),headings:ZE(e.headings),links:e_(e.links),buttons:t_(e.buttons),block:n_(e.block),cards:r_(e.cards)}}var pl=l.createIdentifier$1("EmailSettingsPort"),o_=1e4,hl=class{_editor;_layoutSettingsChanged=new l.Emitter;_contentStylesChanged=new l.Emitter;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!Pa(this._editor.container)||!Ve(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(pl);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return io(this._settings().read())}_getCurrentContentStyles(){const e=Ve(this._editor.container)?.current()?.get().attributes.common_styles;return ao(fl(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(pl),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const o=r?.data,s=o?.operation;if(s===l.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){const c=io(o?.settings),d=this._getLayoutSnapshot(c);d!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=d,this._layoutSettingsChanged.fire(c));return}if(s!==l.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE)return;const i=ao(r.data?.settings?.commonStyles??{...l.COMMON_STYLES}),a=this._getContentSnapshot(i);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(i))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=io(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=o_){const t=Ve(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,o=l.getEvent(r,l.events.ON_EMAIL_INIT_ID);return new Promise(s=>{let i=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},d=o(()=>{i||(i=!0,c(),d.dispose(),s())});a=setTimeout(()=>{i||(i=!0,d.dispose(),s())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Ve(this._editor.container)?.current();if(!t)return;const n=fl(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=ro(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:ve.border,borderRadius:ve.borderRadius,padding:ve.padding})),e.block!==void 0&&(n.block=ro(n.block||{},e.block,["padding"],{padding:ve.padding})),e.cards!==void 0&&(n.cards=ro(n.cards||{},e.cards,["border","borderRadius"],{border:ve.border,borderRadius:ve.borderRadiusCards}));const r=JSON.stringify(n);qe(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=ao(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},s_={...cl,EmailSettingsApi:hl},i_={...cl},OS={...i_,EmailSettingsApi:hl},a_={...s_};function l_(){rl.addAll(a_)}var c_=[l.defineMixin(()=>{l_()}),nE,pE,tE,l.JWTMixin,Zv,l.OAuthMixin];async function d_(){return(await It()).asyncMixins}var u_=ME,f_=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await d_()}catch(i){throw e.failPendingWaits(i),i}t=o(e);const s=await e.getInstanceAsync(l.INSTANCE_ID);Object.assign(s,t.instance||{});for(const i of e.getInstance(l.LATE_SURFACE_LISTENERS_ID)??[])i()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},p_=l.combineMixins([...c_]);function lo(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const s of r.values())s();r.clear()}return{event(s,i,a){const c=Symbol("subscription");return t||(n.set(c,{listener:s,priority:i,thisArg:a}),e&&r.set(c,e(s,i,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(s){o(),e=s;for(const[i,{listener:a,priority:c,thisArg:d}]of n)r.set(i,s(a,c,d))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function h_(e){const t=lo(),n=lo(),r=lo();return e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(tt).then(o=>{t.attach(o.onNotify),n.attach(o.onError),r.attach(o.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(o){const s=e.getInstance(tt);if(s){s.notify(o);return}e.getInstanceAsync(tt).then(i=>i.notify(o),()=>{})}}}var ml=l.createIdentifier$1("CodeErrors"),m_=[];function g_(e){return e?.getInstance(ml)?.get()??m_}function v_(e){return e?.getInstance(ml)!==void 0}var E_=class extends l.Disposable{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=Et(e),this.addDisposable(l.getEvent(e,l.events.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){const e=Ne(this._container);if(e&&Z(e.sessionKey())&&!e.hasSuspended())throw new Error("[emailmaker] no open email: only a block is shown");return la(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>pe(t,this._container))}async _readProjectBlocks(){const e=await ca(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>bt(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>kr(n,this._container))}async getEmailSnapshot(){return ge(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Ne(this._container),t=e?.current();return!e||!t||!Z(e.sessionKey())?null:(await t.whenReady(),pe(Zt(t),this._container))}setEmailMeta(e){const t=Pr(this._container);if(!t)return;const n=t.get().attributes.meta;qe(t,{meta:rn({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&rn(o,e))}setBlockMeta(e,t){const n=Ne(this._container);if(n?.sessionKey()===Bt(e)){const o=n.current();o&&qe(o,{meta:rn({meta:o.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,s=>s&&rn(s,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return v_(this._container)?g_(this._container):void 0}},__=l.createIdentifier$1("EmailDataController");function b_(e){return e.getOrCreateInstance(__,()=>{const t=new E_(e);return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(t),t})}function S_(e){const t=b_(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function y_(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function w_(e){let t;const n=Bi(e),r=l.getEvent(e,l.events.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:s})=>{t=s}));const o=()=>t?y_(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:s=>o()?.getPast(s)??[],getFuture:s=>o()?.getFuture(s)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:s=>o()?.restoreSnapshot(s)}}}var I_=l.createIdentifier$1("plugin.mountElement");function T_(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function C_(e){return e.getOrCreateInstance(I_,()=>{let t=!1,n;return{get:()=>t?n:T_(e),set(r){t=!0,n=r}}})}function A_(e){const t=C_(e);return{getElement:()=>t.get()}}function D_(e){return{handleLoadImage:H(l.getEvent(e,l.events.UPLOAD_EVENT_ID)),handleFileProxy:H(l.getEvent(e,l.events.FILE_PROXY_EVENT_ID)),handleUrlProxy:H(l.getEvent(e,l.events.PROXY_URL_EVENT_ID)),handleAITextRequest:H(l.getEvent(e,l.events.AI_TEXT_REQUEST_ID)),handleAIImageRequest:H(l.getEvent(e,l.events.AI_IMAGE_REQUEST_ID)),handleReadLocale:H(l.getEvent(e,l.events.READ_LOCALE)),handleLimitUsage:H(l.getEvent(e,l.events.ON_LIMIT_ID)),handleTranslate:H(l.getEvent(e,l.events.ON_TRANSLATE_ID))}}var P_=[Zh,yv,h_,fE,S_,w_,A_,D_];function O_(e,t=P_){const n=Gr(e);Xv(e);const r=p_(e),o=u_(e),s=f_(e),i={...r.instance,...o.instance,...s.instance};for(const c of t)Object.assign(i,c(e));let a=!0;return{instance:i,async setOptions(c){await r.setOptions(c);const d=a&&n.get()===c;a=!1,d||n.set(c),await o.setOptions(c),await s.setOptions(c)}}}function R_(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var k_=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]}},N_="editor-runtime.react.copies",co=8;function Tt(e){return e&&typeof e=="object"?e:void 0}function gl(e){const t=Tt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Tt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function L_(e){const t=Tt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Tt(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function M_(e,t,n){return e.package===t&&e.version===n}function x_({ourReact:e,entries:t,packageName:n,version:r}){const o=gl(e);if(!o||!Array.isArray(t))return[];const s=[],i=new Set;for(const a of t){const c=Tt(a);if(!c||!M_(c,n,r))continue;const d=gl(c.react);!d||d===o||i.has(d)||(i.add(d),s.push({package:n,version:r,reactVersion:L_(c.react),react:c.react}))}return s}function F_({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,co))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>co&&n.push(` …and ${t.length-co} 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(`
2153
- `)}var vl=new Set;function B_({packageName:e="@emailmaker/emailmaker",version:t="1.3.3",log:n=r=>{}}={}){const r=o=>{try{const s=globalThis[Symbol.for(N_)],i=x_({ourReact:o,entries:s,packageName:e,version:t}).filter(a=>!vl.has(a.react));if(!i.length)return;i.forEach(a=>vl.add(a.react)),n(F_({packageName:e,copies:i}))}catch{}};try{const o=Dn()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function j_(e,t,n){l.throwIfAborted(e.signal);const r=t??l.DependencyResolver.createChild();Gr(r);const o=r.getInstance(l.DISPOSABLE_ID);let s;async function i(){r.inject(l.COOKIE_MANAGER_ID,R_(new k_)),B_();const a=O_(r),c={...a.instance,container:r,get ready(){return s??Promise.resolve(c)},async reset(d){if(l.throwIfAborted(d.signal),o.isDisposed())throw we();return await a.setOptions(d),c}};r.inject(l.INSTANCE_ID,c);try{if(n?.onInstance?.(c),await a.setOptions(e),l.throwIfAborted(e.signal),o.isDisposed()||await _v(r),e.devTools)try{const d=r.getInstance(l.PLUGIN_COLLECTION_ID);d&&await(await It()).initDevTools(r,d)}catch{}return l.throwIfAborted(e.signal),l.getEmitter(r,l.APP_LOAD_EVENT_ID).fire(c),c}catch(d){throw o.dispose(),d}}try{return s=l.raceWithAbortSignal(i(),e.signal),s.catch(()=>{}),await s}catch(a){throw o.isDisposed()||o.dispose(),a}}var Ct=new WeakMap;function U_(e){return e?Ct.get(e):void 0}function El(e){try{e.getInstance(l.DISPOSABLE_ID)?.dispose()}catch{}try{e.dispose()}catch{}}function $_(e,t){if(!e)return;const n=Ct.get(e);n&&n!==t&&El(n),Ct.set(e,t)}function H_(e,t){e&&Ct.get(e)===t&&Ct.delete(e)}function V_(e){const t=l.DependencyResolver.createChild();return ht(e)&&t.inject(l.SECURITY_MODULE_ID,nn(e)),t}var At=new WeakMap,G_="data-emailmaker-config-styles";function W_(e){return typeof e=="string"?e.trim():""}function _l(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Y_(e,t,n){if(!e||typeof document>"u")return null;const r=W_(t),o=At.get(e),s=n||e;if(!r)return o&&(o.remove(),At.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==s||o!==s.firstChild)&&_l(s,o),o;const i=document.createElement("style");return i.setAttribute(G_,"true"),i.textContent=r,_l(s,i),At.set(e,i),i}function q_(e){if(!e)return;const t=At.get(e);t&&(t.remove(),At.delete(e))}var RS=!1;function bl(){return!1}var kS=28,K_=`
2152
+ `)}function Ga(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function wv(e,t,n,r){const s=Iv(e,t,n,r);return s===void 0}function Iv(e,t,n,r){if(bn(t))return"block";const{email:s}=yn(t,!1),o=ot(s,e),i=o.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const a=Se(e)?.current();if(!a)return"no-session";const l=a.get(),d=l.attributes;if(l.serverId!==i)return"document-id";if(d.is_inited!==!0)return"not-inited";const u=Ga(zr(n??a.getContent()));if(o.html!==void 0&&Ga(zr(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==d.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==d.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==d.common_styles)return"common_styles"}function Wa(e,t){if(bn(t))return;const{email:n}=yn(t,!1),r=ot(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:zr(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Tv(e){return Array.isArray(e)?e.some(t=>ir(t)):ir(e)}function Cv(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])Tv(t[n])&&delete t[n];return t}function Av(e,t){const n={...e};return delete n.id,{...n,...t}}function Ov(e){return e.html?e:{...e,html:Fa}}function Ve({code:e,project:t,...n},r,s){const o=s??Vr(r);return{...n,...e?{html:De(r).toEditorForm(e)}:{},renderGuid:c.generateUUID(),...o===void 0?{}:{project:o}}}function pe({html:e,renderGuid:t,...n},r){const{requested:s}=It(r);return we({...n,code:De(r).toOutputForm(e),project:s===void 0?n.project:s,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 Ya(e){return Se(e)?.current()?.get().serverId??void 0}function Xr(e,t,n){return n===void 0&&(n=e.post===void 0?Ya(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function At(e,t){return we({...e,link:void 0,comment_status:void 0})}function wn({code:e,autosave:t,...n},r,s){return s===void 0&&(s=n.parent===void 0?Ya(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||Au(n.slug),parent:s}}function Jr({html:e,isAutosave:t,...n},r){return we({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:we({html:e,ampHtml:e&&""})})}function In({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function qa({html:e,isAutosave:t,...n}){return we({...n,autosave:t?!0:void 0,code:e,guid:void 0})}function Dv(e){return String(e).replace(/"/g,"&quot;")}function Pv(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 Qr(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 Ka(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),s=Dv(n);return r.test(e)?e.replace(r,`${t}="${s}"`):e.replace(/>$/,` ${t}="${s}">`)}function za(e,t){return e.replace(new RegExp(`\\s+${t}\\s*=\\s*["'][^"']*["']`,"gi"),"")}function Xa(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function Ja(e){if(!e?.trim())return{};const t=Qr(e);return t?{emBlockId:Xa(t.full,"em-block-id"),emBlockVersion:Xa(t.full,"em-block-version")}:{}}function Qa(e,t,n){if(!e?.trim()||!t)return e;const r=Qr(e);if(!r)return e;const s=String(t),o=Pv(n??new Date);let{full:i,index:a}=r;const l=i.length;return/\bem-block-id\s*=/.test(i)||(i=Ka(i,"em-block-id",s)),i=Ka(i,"em-block-version",o),e.slice(0,a)+i+e.slice(a+l)}function Rv(e){const t=e?.trim()?Qr(e):null;if(!t)return e;const{full:n,index:r}=t,s=za(za(n,"em-block-id"),"em-block-version");return e.slice(0,r)+s+e.slice(r+n.length)}function kv(e,t){const{emBlockId:n,emBlockVersion:r}=Ja(e);return n&&r?e:Qa(e,t)}var it=c.createIdentifier$1("NotificationService"),Nv=c.createIdentifier$1("emailTemplate.reads");async function Lv(e,t){try{const n=xe(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,xv(e,t,n);return}}var Mv=c.createIdentifier$1("emailTemplate.notifiedFailures");function xv(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(Mv,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(it).then(()=>{c.getEmitter(e,c.events.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function Fv(e,t){const n=e.getOrCreateInstance(Nv,()=>new Map),r=n.get(t);if(r!==void 0)return r;const s=Lv(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,s),s}var Bv=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Aa.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Aa.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},ww=c.createIdentifier$1("projects.v2IdByWpId"),Iw=c.createIdentifier$1("projects.wpIdByV2Id"),Tw=c.createIdentifier$1("emails.v2SavedAtOnOpen"),Cw=c.createIdentifier$1("emails.v2OpeningReads"),Zr=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function jv(e,t){if(!t)throw new Zr(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new Zr(e,vn(t))}function Uv(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var $v=/^[A-Za-z0-9_-]{1,128}$/,Vv=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),Za=new Set;function Hv(e){return $v.test(e)?!0:(Za.has(e)||Za.add(e),!1)}function Gv(e){return e&&!e.ok?String(vn(e).data.code??""):""}var ec=()=>({isAutosave:!1});function tc(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function Wv(e,t){const n=new AbortController,r=ft(e.getInstance(c.INIT_PIPELINE_ID)?.contentReadyTimeoutMs);let s;const o=new Promise((i,a)=>{s=setTimeout(()=>{n.abort(),a(new Zr("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),o])}finally{clearTimeout(s)}}function Yv(e,t){return Eo(t,e==="block")}async function qv(e,t,n,r,s){if(!Hv(n))return ec();const o=Ze(e),i=vt(e),a=Yv(t,n);try{const l=await Kv(e,t,n,r,s);return l.id&&(o.set(a,l.id),i.delete(a)),l}catch(l){throw hf(i,a,r.html??""),l}}async function Kv(e,t,n,r,s){const o=Da(e,[Bv]),i={entityId:n,...s?{autosave:!0}:{}},a=await Wv(e,l=>t==="email"?o.emailsRevisionsCreate(i,tc(t,r),{signal:l}):o.blocksRevisionsCreate(i,tc(t,r),{signal:l}));return Vv.has(Gv(a))?ec():(jv("обновление",a),Uv(a.data??{}))}function zv(e,t,n,r){return qv(e,t,n,r,!1)}async function Xv(e,t,n){if(t==null||t===""||n===void 0||!ze(e))return nc;const r=Date.now(),s=er(String(t));return oi(s,{html:n},r,mr(Ze(e),s,vt(e),n)),await zv(e,"block",String(t),{html:n}),en(s,r,Ze(e).get(s)??void 0),()=>tr(s,r)}function nc(){}var es="EXTERNAL",rc=Symbol("supersededShow");function Jv(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var Qv="email_id";function ts(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var Zv=class extends c.Disposable{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=c.createQueue();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=Tt(t),this._eventLock=_v(t);const n=Q(e,c.events.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(Q(e,c.events.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(c.REQUEST_HANDLER_ID,{execute:(r,s)=>{!s?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Qv,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(c.INIT_PIPELINE_ID)??Ir}_throwIfDestroyed(){if(this.isDisposed())throw Ae()}async getTemplateEmail(e){const t=await Fv(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,Cv(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Ct(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Ve(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(s=>s.id!==void 0).map(s=>[s.id,wn(s,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(s=>s.id!==void 0).map(s=>[s.id,Xr(s,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,s){const o=this._dataSources.emails,i=o.cache,a=await Ct(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let d=ot(e,this._container);const u=d.id;let p=u;if(u!==void 0){const h=await o.get(u);d={...h??{},...d,utm_parameters:d.utm_parameters??h?.utm_parameters??{},renderGuid:h?.renderGuid??c.generateUUID(),...l>0?{showToken:l}:{},...s?{showId:s}:{},project:a}}else{p=n??c.generateUUID();const h=await o.get(p);d={...d,utm_parameters:d.utm_parameters??{},renderGuid:h?.renderGuid??c.generateUUID(),...l>0?{showToken:l}:{},...s?{showId:s}:{},project:a},delete d.project}if(t){const h=await this.getTemplateEmail(String(t));h&&(d=Av(h,d))}return u===void 0&&(d=Ov(d)),await i.setAll([[p,d]]),d}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Wa(this._container,e))return!1;const n=Sn(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Wa(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Sn(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&bv({ticket:t,emailId:Ha(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,rc;if(!e)return;const n=this._getInitPipeline();if(c.throwIfAborted(n.signal),bn(e))return this._showBlock(e,n);const r=J(ue(this._container).sessionKey()),s=yv(e);if(!r&&!s&&wv(this._container,e,Sn(this._container),this._prevCommand?.id)||!r&&!s&&this._isRepeatOfLastShow(e))return;const o=yn(e);o.email.id,this._prevCommand?.id;let i,a="",l=0,d=!1,u,p=Promise.resolve(),h,m=!1;try{this._eventLock.suspendChange();const{email:_,blocks:y,autosaves:v,comments:b,templateId:O,reload:j}=o;i=_.id;const x=ot(_,this._container),C=x.id,I=C??c.generateUUID(),R=await Me("getProject",Ct(this._container));c.throwIfAborted(n.signal),a=c.generateUUID();const A={isNew:C===void 0,id:String(I),project:R},P=j===!0&&C!==void 0;P&&(await this._dataSources.emails.remove(String(C),{silent:!0}),String(C)),l=++this._showToken,String(I);const L=[];L.push(this.setBlocks(y)),_.id!==void 0&&(L.push(this.setComments(b)),L.push(this.setEmailRevisions(v,String(_.id)))),L.push(this.setEmail(_,ir(O)?O:Number(O),C===void 0?String(I):void 0,l,a)),await Me("setEmail+blocks+revisions",Promise.all(L),{emailId:C??String(I),showId:a,targetShowToken:l}),c.throwIfAborted(n.signal);const S=await this._dataSources.emails.get(String(I)),D=ue(this._container),k={id:a,token:l};if(r){un(this._container);const w=D.suspendedDocument()?.get().serverId;!P&&C!==void 0&&w!=null&&String(w)===String(C)&&D.resumeSuspended()}C===void 0?h=D.startNewDraft(S??x,{patch:x,show:k}):P?h=D.reload(C,{email:S??x,patch:x,show:k}):D.sessionKey()===Xe(C)?h=D.show(x,k):h=D.open(C,{email:S??x,patch:x,show:k}),D.beginShowFill(a);const F=!!this._prevCommand&&c.deepEqual(this._prevCommand,A);A.id,!this._prevCommand||c.deepEqual(this._prevCommand,A),this._prevCommand?.id,this._rememberShow(A),p=n.requestShow({showId:a,navId:String(I),emailId:C,isNew:C===void 0}),m=!0;const E=()=>D.endShowFill(a);Promise.allSettled([p,h.whenReady()]).then(E),String(I),d=!0}catch(_){u=_,m&&a&&n.failShow(a,_),a&&Se(this._container)?.endShowFill(a),c.isAbortError(_)||(uo(_),void 0)}finally{this._eventLock.resumeChange()}if(!d)throw u instanceof Error?u:new Error(`[emailmaker] show() setup failed: ${String(u??"unknown error")}`);return Me("show-init-deferred",Promise.all([p,h?.whenReady().catch(_=>{if(_ instanceof Le){const y=hr(_);throw y?new Error(`[emailmaker] show(): email open failed (${y})`,{cause:_}):_}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:s,revisions:o,reload:i}=Ev(e),a=c.generateUUID();let l=!1;try{await this.setBlocks(s),c.throwIfAborted(t.signal),i&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const d=n.id!==void 0&&n.id!==""?String(n.id):void 0,u=ue(this._container);if(!i&&d!==void 0&&u.sessionKey()===Kt(d)){const O=ts(n)?await this._storeShownBlock(n):void 0,j={id:a,token:++this._showToken},x=u.show(O,j),C=t.requestShow({showId:a,navId:d,emailId:void 0,isNew:!1});l=!0,await Me("show-block-init",Promise.all([C,x?.whenReady().catch(()=>{})]),{showId:a});return}const p=r||i?await Va(this._container,String(n.id)):void 0,h=p&&(i||ts(n))?await this._storeShownBlock({...pe(p,this._container),...n}):r||i?p:await this._storeShownBlock(n);if(c.throwIfAborted(t.signal),!h)throw new Error(`[emailmaker] show(): block ${String(n.id)} not found`);o!==void 0&&h.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(o.filter(O=>O.id!==void 0).map(O=>[O.id,In(O,String(h.id))])),this._prevCommand=void 0,this._lastShow=void 0;const m=h.id!==void 0?String(h.id):c.generateUUID(),_={id:a,token:++this._showToken};un(this._container);const y=i?u.reloadBlock(m,h,_):u.openBlock(m,h,_);h.id;const v=t.requestShow({showId:a,navId:m,emailId:void 0,isNew:h.id===void 0});l=!0;const b=y.whenReady().catch(O=>{if(O instanceof Le)throw O});await Me("show-block-init",Promise.all([v,b]),{showId:a})}catch(d){throw l&&t.failShow(a,d),d}}async _storeShownBlock(e){const t=Ve(e,this._container,await Ct(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();c.throwIfAborted(e.signal);const t=ue(this._container);if(J(t.sessionKey())&&!t.hasSuspended())throw new Error("[emailmaker] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:es,fallbackTitle:gi(this._container)});if(c.throwIfAborted(e.signal),!n)throw Jv(t.emailSaveState().error);return ge(Ua(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=ue(this._container),t=e.current();if(!t||!J(e.sessionKey()))throw new Error("[emailmaker] saveBlock(): no open block");return su(t,async()=>{await t.whenReady();const n=dn(t),r=t.get().version,s=t.get().serverId,o=typeof n.global_block=="boolean"?n.global_block:s!=null&&Ja(n.html??"").emBlockId===String(s),i=s!=null&&o?Qa(n.html,String(s),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:i,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},l=this._dataSources.blocks,d=await Xv(this._container,t.get().serverId,a.html),u=t.get().serverId==null?l.create(a,{source:es}):l.update(String(t.get().serverId),a,{source:es}),p=await Sv(this._container,u,h=>{h&&d(),h&&ue(this._container).current()===t&&t.get().serverId==null&&h.id!==void 0&&t.markSaved(r,String(h.id))});if(!p)throw new Error("[emailmaker] save(): block was not saved");return d(),t.markSaved(r,p.id!==void 0?String(p.id):void 0),pe(p,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=Ha(e);const n=this._queuedShow(e,t).then(r=>r===rc?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),c.throwIfAborted(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=ue(this._container);if(n!==void 0&&r.sessionKey()===Kt(n))return;const s=t.code===void 0&&n!==void 0?await Va(this._container,n):void 0,o=s&&ts(t)?await this._storeShownBlock({...pe(s,this._container),...t}):t.code===void 0&&n!==void 0?s:await this._storeShownBlock(t);if(!o)throw new Error(`[emailmaker] openBlock(): block ${String(n)} not found`);un(this._container);const i=r.openBlockOver(o.id!==void 0?String(o.id):c.generateUUID(),o);o.id,r.hasSuspended(),fe(this._container,c.events.ON_BLOCK_OPEN_ID).fire({block:o}),await i.whenReady().catch(a=>{if(a instanceof Le)throw r.current()===i&&(fe(this._container,c.events.ON_BLOCK_CLOSE_ID).fire({block:o,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),Dh(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function eE(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 tE(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),s=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:s,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:eE(e)}}function ns(e,t){return t?tE(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var sc=["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"],nE=[...sc,"html","id","project","password"],Aw=new Set(["html",...sc,"global_block","project"]);function rE(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(nE),r={};for(const s of Object.keys(e))n.has(s)||(r[s]=e[s]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function sE(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...rE(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 rs=new WeakMap;function oE(e){let t=rs.get(e);return t||(t={byId:new Map,fallback:[]},rs.set(e,t)),t}function iE(e){rs.delete(e)}function aE(e,t){const{byId:n,fallback:r}=oE(t);if(e.blockId){const s=n.get(e.blockId);if(s){n.delete(e.blockId);const o=r.indexOf(s);return o>=0&&r.splice(o,1),s}return}for(let s=r.length-1;s>=0;s--){const o=r[s],i=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,a=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(i&&a)return r.splice(s,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function cE(e,t){const{blocks:n}=Tt(e);return await n.cache.getIfPresent(t)??void 0}async function lE(e,t){if(!t.blockId)return;const n=await cE(e,t.blockId);if(n)return sE(n,t)}async function dE(e,t){const n=aE(e,t);if(n)return ns(e,n);const r=await lE(t,e);return r?ns(e,r):ns(e,void 0)}var uE=c.createIdentifier("application_block_inserted"),fE=-1e3,oc=new WeakSet;function pE(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 hE(e){if(!e||oc.has(e))return;oc.add(e);const t=new c.Disposable,n=le(e);return t.addDisposable(n.addListenerAsyncPipe(uE,async(r,s)=>{const o=pE(r)?await dE(r,e):r;return s?s(o):o},fE)),t.addDisposable({dispose:()=>{iE(e)}}),t}var mE=sn("plugin.readBlockAutosave"),Ow=c.createIdentifier$1("blockDocuments.provided"),ic=c.createIdentifier$1("plugin.earlyWindow");function gE(e){return e.getOrCreateInstance(ic,()=>({depth:0}))}function vE(e){const t=gE(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function ac(e){return(e?.getInstance(ic)?.depth??0)>0}function cc(e,t){let n,r=!1;return e(s=>{n=s,r=!0}),(s,o,i)=>{const a=e(s,o,i);if(r&&ac(t)){const l=n;queueMicrotask(()=>{s.call(i,l)})}return a}}var ss=100,EE=class extends c.Disposable{_container;_events;constructor(e){super(),this._container=e;const t=hE(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:s,blocksRevision:o}=Tt(e),i=Q(e,c.events.ON_SHARE_ID),a=Q(e,c.events.ON_SHOW_PREVIEW_ID),l=Q(e,c.events.ON_EMAIL_CLONE_ID),d=Q(e,c.events.ON_BLOCK_OPEN_ID),u=Q(e,c.events.ON_BLOCK_CLOSE_ID),p=Q(e,c.events.ON_BLOCK_CLONE_ID),h=Q(e,c.events.ON_BLOCK_INIT_ID),m=Q(e,c.events.ON_BLOCK_CHANGED_ID),_=Q(e,c.events.ON_CODE_VALIDATE_ID),y=Q(e,c.events.ON_IMPORT_VALIDATE_ID),v=Q(e,c.events.ON_SUBJECT_CHANGED_ID),b=Q(e,c.events.ON_EMAIL_CHANGED_ID),O=Q(e,c.events.ON_PREHEADER_CHANGED_ID),j=Q(e,c.events.ON_SAVEBUTTON_CLICK_ID),x=Q(e,c.events.ON_BLOCK_SAVEBUTTON_CLICK_ID),C=Q(e,c.events.ON_NEXTBUTTON_CLICK_ID),I=Q(e,c.events.ON_SEND_LIVEPREVIEW_ID),R=Q(e,c.events.ON_SEND_TESTEMAIL_ID),A=Q(e,hv),P=Q(e,c.events.ON_CONTENT_CHANGED_ID),L=Q(e,pv),S=Q(e,c.events.ON_PREVIOUSBUTTON_CLICK_ID),D=Q(e,c.events.ON_SEND_EMAIL_MODAL_ID),k=c.filter(Q(e,c.events.ON_EMAIL_INIT_ID),E=>!E.reset),F=Q(e,c.events.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:V(O),handleSubjectChanged:V(v),handleValidate:V(_),handleImportValidate:V(y),handleReadEmail:V(n.handlerRead,E=>E,E=>E&&ot(E,e)),handleSaveEmail:V(n.onSave,function({prev:E,patch:w,value:B,source:U}){const W=E?ge(E,e):void 0;return{prev:W,patch:St(W,ge(w,e)),value:ge(B,e),source:U}},E=>E?ot(E,e):void 0),handleRemoveEmail:V(n.onRemove,({value:E,source:w})=>({value:ge(E,e),source:w}),()=>{}),handleReadCommonBlocks:V(A,E=>E.project,E=>E?.map(w=>Ve(w,e))),handleReadTemplateBlocks:V(L,E=>E,E=>E?.map(w=>Ve(w,e))),handleReadBlocks:V(t.byForeignKey("project").handleRead,E=>It(e).requested||String(E),E=>E?.map(w=>Ve(w,e))),handleReadBlock:V(t.handlerRead,E=>E,E=>E?Ve(E,e):void 0),handleOpenBlock:V(d,({block:E})=>({block:pe(E,e)})),handleCloseBlock:V(u,({block:E,hasUnsavedChanges:w})=>({block:pe(E,e),hasUnsavedChanges:w})),handleCloneBlock:V(p,E=>pe({...E,html:Rv(E.html)},e)),handleSaveBlock:V(t.onSave,function({prev:E,patch:w,value:B,source:U}){const W=B.global_block===!0&&B.id&&typeof B.html=="string"?{...B,html:kv(B.html,String(B.id))}:B,ae=E?pe(E,e):void 0;return{prev:ae,patch:St(ae,pe(w,e)),value:pe(W,e),source:U}},E=>E?Ve(E,e):void 0),handleRemoveBlock:V(t.onRemove,({value:E,source:w})=>({value:pe(E,e),source:w}),()=>{}),handleReadComments:V(r.byForeignKey("post").handleRead,E=>E,E=>E?.map(w=>Xr(w,e))),handleSaveComment:V(r.onSave,function({prev:E,patch:w,value:B,source:U}){const W=E?At(E,e):void 0;return{prev:W,patch:St(W,At(w,e)),value:At(B,e),source:U}},E=>E?Xr(E,e):void 0),handleRemoveComment:V(r.onRemove,({value:E,source:w})=>({value:At(E,e),source:w}),()=>{}),handleReadEmailRevisions:V(s.byForeignKey("parent").handleRead,E=>E,E=>E?.map(w=>wn(w,e))),handleReadEmailAutosave:V(Q(e,ba),E=>E,E=>E?wn(E,e):null),handleEmailAutosave:V(s.onSave,function({prev:E,patch:w,value:B,source:U}){return{value:Jr(B,e),source:U}},E=>E?wn(E,e):void 0),handleRemoveEmailAutoSave:V(s.onRemove,({value:E,source:w})=>({value:Jr(E,e),source:w}),()=>{}),handleReadBlockRevisions:V(o.byForeignKey("parent").handleRead,E=>E,E=>E?.map(w=>In(w))),handleReadBlockAutosave:V(Q(e,mE),E=>E,E=>E?In(E):null),handleBlockAutosave:V(o.onSave,({value:E,source:w})=>({value:qa(E),source:w}),E=>E?In(E):void 0),handleRemoveBlockAutoSave:V(o.onRemove,({value:E,source:w})=>({value:qa(E),source:w}),()=>{}),handleBlockInit:V(h,E=>pe(E,e)),handleBlockChanged:V(c.debounce(m,ss),E=>pe(E,e)),handleEmailChanged:V(c.debounce(b,ss),E=>ge(E,e)),handleEmailInit:cc(V(k,E=>ge(E,e)),e),handlePreviousButtonClick:V(S,E=>ge(E,e)),handleNextButtonClick:V(C,E=>ge(E,e)),handleSaveButtonClick:V(j,E=>ge(E,e)),handleSaveBlockButtonClick:V(x,E=>pe(E,e)),handleHtmlChanged:V(c.debounce(P,ss)),handleTestEmailSend:V(R,({html:E,...w})=>({...w,code:E,compiled:{html:E,ampHtml:""}})),handleTestEmailModal:V(D,E=>ge(E,e)),handleCloneEmail:V(l,E=>ge(E,e)),handleShareEmail:V(i),handlePreviewEmail:V(a),handleLivePreviewEmail:V(I),handleAnalyticsEvent:V(F)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new rt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},_E=c.createIdentifier$1("DataController"),bE=c.createIdentifier$1("DataEvents");function lc(e){return e.getOrCreateInstance(_E,()=>{const t=new Zv(e);return e.getInstance(c.DISPOSABLE_ID)?.addDisposable(t),t})}function dc(e){return e.getOrCreateInstance(bE,()=>new EE(e))}var yE=c.createIdentifier$1("plugin.pluginStart");function uc(e){return e.getOrCreateInstance(yE,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>t()),{done:n,finish:t}})}function SE(e){return uc(e).done}function wE(e){const t=uc(e);return t.run===void 0&&(t.run=(e.getInstance(c.PLUGIN_COLLECTION_ID)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var IE=c.createIdentifier$1("plugin.startupShow");function TE(e){const t=lc(e),n=dc(e),r=e.getInstance(c.OPTIONS_SOURCE_ID),s=e.getInstance(c.DISPOSABLE_ID),o={current:Promise.resolve()};e.inject(IE,o);let i=!1;const a=r?.watch(d=>{d&&n.setOptions(d),i=(d?.plugins?.length??0)>0,o.current=o.current.catch(()=>{})}),l=r?.select(d=>d?.content).watch(d=>{if(d===void 0)return;const u=()=>(te(de.showStart),t.show(d).finally(()=>te(de.showEnd))),p=i?SE(e).then(u):u();p.catch(()=>{}),o.current=p});a&&s?.addDisposable(a),l&&s?.addDisposable(l)}function CE(e){const t=lc(e);return{...dc(e).get(),show(n){return te(de.showStart),t.show(n).finally(()=>te(de.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return te(de.showStart),t.showBlock(n,r).finally(()=>te(de.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function fc(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Tn(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",s=!1;for(let o=t;o<e.length;o++){const i=e[o];if(s){s=!1;continue}if(i==="\\"){s=!0;continue}if(r){i===r&&(r="");continue}if(i==='"'||i==="'"){r=i;continue}if(i==="("){n++;continue}if(i===")"&&(n--,n<0))return!1}return n===0}function AE(e){return(t,n,r)=>Tn(t)?e(t,n,r):!1}function OE(e){return t=>Tn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function DE(e){return(t,n,r)=>Tn(t)?fc(t)?e(t,n,r):t:!1}function PE(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Tn(n)?fc(n)?e(t):t:!1}}function RE(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function os(e,t){const n=e.length;for(let r=0;r<n;r++){const s=e.charCodeAt(r);if(s===0||t==='"'&&s===34||t==="'"&&s===39||t===""&&(s===32||s===9||s===10||s===13||s===12||s===34||s===39||s===60||s===62||s===61||s===96))return!1}return!0}function kE(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let s="";for(let o=0;o<e;o++){const i=r[o]%62;s+=t.charAt(i)}return s}var NE=8,LE=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=kE(NE),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Cn=new LE;function pc(e,t){return t!==void 0&&!os(e,t)?`%|{${Cn.getOrCreateByKey(e)}}|%`:e}function ME(e){const t=Cn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function se(e,t,n){return t!==void 0?os(e,t)?e:`%|{${Cn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function xE(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ne(e){return e.startsWith("<!--")&&e.endsWith("-->")?xE(e.slice(4,-3)):e}function FE(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const s=e.match(/\[%\s*([^%]*?)\s*%\]/);s&&(r=s[1]);const o=r.trim();return t.test(o)||n.test(o)}function BE(e,t,n){return t!==void 0?os(e,t)?e:`%|{${Cn.getOrCreateByKey(e)}}|%`:n||RE(e)||FE(e)?`<!--${e}-->`:e}var He=AE(se),Ge=OE(ne),jE=DE(se),UE=PE(ne),hc=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",ME),e.escape("@{","}",se,!0).unescape("<!--@{","}-->",ne,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",pc,!0),e.escape("{{","}}",pc,!0),e.createSyntax("brace-percent").escape("{%","%}",se).unescape("<!--{%","%}-->",ne),e.createSyntax("brace-hash").escape("{#","#}",se).unescape("<!--{#","#}-->",ne),e.createSyntax("proscript").escape("[%","%]",BE,!0).unescape("<!--[%","%]-->",ne,!0),e.createSyntax("getresponse").escape("[[IF","]]",se).escape("[[if","]]",se).escape("[[ELSE]]","",se).escape("[[else]]","",se).escape("[[ENDIF]]","",se).escape("[[endif]]","",se).unescape("<!--[[IF","]]-->",ne).unescape("<!--[[if","]]-->",ne).unescape("<!--[[ELSE]]","-->",ne).unescape("<!--[[else]]","-->",ne).unescape("<!--[[ENDIF]]","-->",ne).unescape("<!--[[endif]]","-->",ne),e.createSyntax("expert-sender").escape("<if",">",se).escape("</if",">",se).escape("<else",">",se).escape("</else",">",se).escape("<var ",">",se,!0).unescape("<!--<if ",">-->",ne).unescape("<!--</if",">-->",ne).unescape("<!--<else ",">-->",ne).unescape("<!--</else",">-->",ne).unescape("<!--<var",">-->",ne,!0),e.createSyntax("velocity").escape("#if",")",He).escape("#elseif",")",He).escape("#else","",se).escape("#foreach",")",He).escape("#macro",")",He).escape("#set",")",jE,!0).escape("#parse",")",He).escape("#include",")",He).escape("#evaluate",")",He).escape("#end","",se).escape("#break","",se).escape("#stop","",se).unescape("<!--#macro","-->",Ge).unescape("<!--#if","-->",Ge).unescape("<!--#elseif","-->",Ge).unescape("<!--#else","-->",ne).unescape("<!--#foreach","-->",Ge).unescape("<!--#parse","-->",Ge).unescape("<!--#include","-->",Ge).unescape("<!--#evaluate","-->",Ge).unescape("<!--#end","-->",ne).unescape("<!--#break","-->",ne).unescape("<!--#stop","-->",ne).unescape("<!--#set","-->",UE,!0),e.createSyntax("mailchimp").escape("*|","|*",se).unescape("<!--*|","|*-->",ne)},is="bare",$E=new Map;function VE(e){return e?$E.get(e)??is:is}var mc=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function gc(e){return mc.includes(e)}function Ot(e){return e==="bare"||e==="html-comment"}function as(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function HE(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!Ot(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[d,u]of[["output",r.output],["editor",r.editor]])if(u!==void 0&&!Ot(u))return t(`templateDirectives.${d}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!as(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[d,u]of Object.entries(r.syntaxes))if(!(!gc(d)||u===void 0||Ot(u))){if(!as(u))return t(`templateDirectives.syntaxes.${d}: expected a form or an object, configuration ignored.`),n;for(const p of["output","editor"]){const h=u[p];if(h!==void 0&&!Ot(h))return t(`templateDirectives.syntaxes.${d}.${p}: unknown form "${String(h)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const s=r.output??is;let o=r.editor;s==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),o=void 0);const i=[];if(r.syntaxes)for(const d of Object.keys(r.syntaxes)){if(!gc(d)){t(`templateDirectives.syntaxes: unknown syntax id "${d}", entry ignored.`);continue}i.push(d)}else i.push(...mc);const a={},l={};for(const d of i){const u=r.syntaxes?.[d],p=as(u)?u:void 0,h=(Ot(u)?u:p?.output)??s;let m=p?.editor??o??h;h==="bare"&&m==="html-comment"&&(t(`templateDirectives.syntaxes.${d}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),m="bare"),a[d]=h,l[d]=m}return{output:a,editor:l}}function vc(e,t,n,r){for(let s=t;s<n;s++){const o=e[s];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?o===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(o)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):o==="<"?r.insideTag=!0:o===">"?r.insideTag=!1:r.insideTag&&(o==='"'||o==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=o,r.unquotedAttr=!1):r.insideTag&&/\S/.test(o)&&r.attributeQuoteChar===void 0&&e[s-1]==="="&&!['"',"'","`"].includes(o)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function Dt(e,t){return e.start<t.end&&t.start<e.end}function Ec(e,t,n,r,s=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const o=t.flatMap(u=>u.match(e).flatMap(p=>!Number.isInteger(p.start)||!Number.isInteger(p.end)||p.start<0||p.end>e.length||p.start>=p.end?[]:[{range:p,mapFn:u.mapFn,overrideBuiltins:u.overrideBuiltins,syntax:u.syntax,isVariable:u.isVariable}])).sort((u,p)=>u.range.start-p.range.start||u.range.end-p.range.end),i=[],a=s.slice().sort((u,p)=>u.start-p.start),l={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let d=0;for(const{range:u,mapFn:p,overrideBuiltins:h,syntax:m,isVariable:_}of o){if(r?(l.insideAttributeValue=!0,l.attributeQuoteChar='"'):vc(e,d,u.start,l),d=u.end,a.some(O=>Dt(O,u)))continue;const y=l.insideAttributeValue?l.attributeQuoteChar??"":void 0,v=e.substring(u.start,u.end),b=p(v,y,l.insideTag);b!==!1&&b!==v&&(i.push({range:u,text:b,overrideBuiltins:h,syntax:m,isVariable:_}),a.push(u))}return i.sort((u,p)=>u.range.start-p.range.start||u.range.end-p.range.end)}function GE(e,t){const n=t.reduce((a,{mapFn:l,start:d,end:u,syntax:p,isVariable:h})=>(a[d]||(a[d]=[]),a[d].push({value:u,mapFn:l,syntax:p,isVariable:h}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),s=new RegExp(r,"g"),o=[];let i;for(;(i=s.exec(e))!==null;){const a=i[0];o.push({start:i.index,startToken:a,endTokens:n[a]})}return o}function cs(e,t,n,r,s=!1){const o=[];if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return o;const i=GE(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(let d=0;d<i.length;d++){const{start:u,startToken:p,endTokens:h}=i[d];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):vc(e,l,u,a),l=u;const m=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let _=!1;for(const{mapFn:y,value:v,syntax:b,isVariable:O}of h){let j=u+p.length,x=e.indexOf(v,j);for(;x!==-1;){let C=x,I=u+p.length,R=0;for(;C!==-1;){const D=e.indexOf(p,I);if(D!==-1&&D<C)R++,I=D+p.length,C=e.indexOf(v,I);else if(R>0)R--,I=C+v.length,C=e.indexOf(v,I);else break}if(C<0)break;const A=C+v.length,P=e.substring(u,A),L=y(P,m,a.insideTag);if(L===!1){j=x+Math.max(v.length,1),x=e.indexOf(v,j);continue}(s||L!==P)&&o.push({range:{start:u,end:A},text:s?P:L,syntax:b,isVariable:O});const S=i.findIndex(({start:D})=>D>=A);S>d?d=S-1:d=i.length,_=!0;break}if(_)break}}return o}function An(e,t){if(!t.length)return e;const n=t.slice().sort((s,o)=>o.range.start-s.range.start);let r=e;for(const{text:s,range:o}of n)r=r.slice(0,o.start)+s+r.slice(o.end);return r}var WE=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=hc){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,s,o,i){return t.push({start:r,end:s,mapFn:o,isVariable:i,syntax:this.syntax||r}),this},unescape(r,s,o,i){return n.push({start:r,end:s,mapFn:o,isVariable:i,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let s=!1;const o={dispose:()=>{s||(s=!0,this._escapeMatchers=this._escapeMatchers.filter(i=>i!==n),this._unescapeMatchers=this._unescapeMatchers.filter(i=>i!==r))}};return this.addDisposable(o),o}_collectMappings(e,t,n){const r=cs(e,this._escapes,t,n),s=Ec(e,this._escapeMatchers,t,n),o=s.filter(l=>l.overrideBuiltins).map(l=>l.range),i=r.filter(l=>!o.some(d=>Dt(d,l.range))),a=s.filter(l=>l.overrideBuiltins||!i.some(d=>Dt(l.range,d.range)));return[...i,...a].sort((l,d)=>l.range.start-d.range.start||l.range.end-d.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=cs(e,this._unescapes,t),r=Ec(e,this._unescapeMatchers,t,!1),s=r.filter(a=>a.overrideBuiltins).map(a=>a.range),o=n.filter(a=>!s.some(l=>Dt(l,a.range))),i=r.filter(a=>a.overrideBuiltins||!o.some(l=>Dt(a.range,l.range)));return[...o,...i].sort((a,l)=>a.range.start-l.range.start||a.range.end-l.range.end)}getRevertMappings(e,t,n){const r=n?s=>s!==void 0&&n.has(s):s=>VE(s)==="html-comment";return this._collectRevertMappings(e,t).filter(s=>s.isVariable||!r(s.syntax))}getDetectedMappings(e,t,n){return cs(e,this._escapes,t,n,!0)}getEscapedText(e,t){return An(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return An(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=o=>o===void 0?void 0:t[o],r=Object.values(t);let s=e;return r.includes("bare")&&(s=An(s,this._collectRevertMappings(s).filter(o=>n(o.syntax)==="bare"))),r.includes("html-comment")&&(s=An(s,this._collectMappings(s).filter(o=>!o.isVariable&&n(o.syntax)==="html-comment"&&o.text.startsWith("<!--")&&o.text.endsWith("-->")))),s}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}},_c="em___script",Pt=`<${_c}`,ls=`</${_c}>`;function bc(e){return e.replace("<script",Pt).replace("<\/script>",ls)}var yc=new WE(e=>{e.escape("<script","<\/script>",t=>bc(t)).unescape(Pt,ls,t=>t.replace(Pt,"<script").replace(ls,"<\/script>")),e.escape("<script","/>",t=>bc(t)).unescape(Pt,"/>",t=>t.replace(Pt,"<script")),hc(e)});function YE(e){const t=HE(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return wo();const n=new Set(Object.keys(t.output).filter(s=>t.output[s]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:s=>yc.normalizeToPolicy(s,t.editor),toOutputForm:s=>yc.normalizeToPolicy(s,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:So(r)}}function qE(e){let t;e.injectFactory(c.TEMPLATE_DIRECTIVES_ID,()=>{const n=e.getInstance(c.CONFIG_SOURCE_ID)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:YE(n)}),t.policy})}function Dw(e){return e}var KE=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function zE(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const s=t.get(r)??[];s.push(n),t.set(r,s)}return t}function XE(e,t){const n=[];for(const r of e.awaits?.services??[])for(const s of t.get(r)??[])s!==e&&n.push(s);return n}function Sc(e){const t=zE(e),n=[],r=new Set,s=[],o=new Set,i=a=>{if(!r.has(a)){if(o.has(a)){const l=s.indexOf(a);throw new KE([...s.slice(l),a].map(d=>d.name))}o.add(a),s.push(a);for(const l of XE(a,t))i(l);s.pop(),o.delete(a),r.add(a),n.push(a)}};for(const a of e)i(a);return n}var JE=[{name:"rest.client",setup:lv},{name:"auth.oauth",setup:c.provideOAuth},{name:"rest.identityHeaders",setup:Qg},{name:"rest.localeHeader",setup:sv},{name:"lifetime.destroyable",provides:[Ur],setup:tg},{name:"appInit",provides:[c.APP_ID,zn],setup:hd},{name:"config",provides:[c.CONFIG_SOURCE_ID],setup:Zm},{name:"templateDirectives",provides:[c.TEMPLATE_DIRECTIVES_ID],setup:qE},{name:"email.documents",setup:bg},{name:"show.initPipeline",provides:[c.INIT_PIPELINE_ID],setup:dv},{name:"show",setup:TE},{name:"locale.service",provides:[st],setup:Kg},{name:"locale.fromConfig",awaits:{services:[c.CONFIG_SOURCE_ID,st]},setup:zg},{name:"canvas.early",setup:Kh},{name:"canvas.previewSettings",setup:dm},{name:"canvas.sandboxExtensions",setup:fm},{name:"canvas.sandboxScriptRelay",setup:mm},{name:"canvas.headerSync",provides:[kr],setup:Jh},{name:"canvas.headersAfterRecovery",setup:Qh},{name:"canvas.ampSync",setup:qf},{name:"canvas.moduleBridge",setup:Ip},{name:"canvas.port",setup:rp},{name:"canvas.images",setup:tp},{name:"canvas.edits",setup:Yh},{name:"canvas.surfaceFollowsSession",setup:Rh},{name:"canvas.blockContent",setup:Ph},{name:"canvas.sandboxFill",provides:[Pr],setup:Nm},{name:"canvas.reactions",setup:qh}],wc;function ds(e){const t=e.getInstance(c.OPTIONS_SOURCE_ID);if(t)return t;e.getInstance(c.DISPOSABLE_ID)||e.inject(c.DISPOSABLE_ID,new c.Disposable);const n=ie();e.inject(c.OPTIONS_SOURCE_ID,n),wc??=Sc(JE);for(const r of wc)r.setup(e);return n}function QE(e){}var ZE=[{name:"save.previewFollow",setup:QE}],Ic=c.createIdentifier$1("plugin.lateUnitsInstalled");function e_(e){if(!e.getInstance(Ic)){e.inject(Ic,!0);for(const t of Sc(ZE))t.setup(e)}}function t_(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function n_(e){if(!e)return;const t=c.decodeJwt(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 r_=c.defineMixin(e=>{let t,n,r;return{async setOptions(s){const o=r!==s.getAuthToken,i=!c.deepEqual(t,s.user),a=n!==s.project;if(r=s.getAuthToken,t=s.user,n=s.project,!(!e.getInstance(c.SECURITY_MODULE_ID)||!s.getAuthToken)&&!(!o&&!i&&!a))try{const l=await s.getAuthToken(s.user,s.project);e.inject(c.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(l||""));const d=n_(l);if(!d)return;e.inject(c.STANDALONE_PROJECT_ID,d);const u=e.getInstance(c.APP_ID),p=u?await u.catch(()=>{}):void 0;e.inject(c.APP_ID,Promise.resolve(t_(d,p)))}catch{}}}});function s_(e,t){if(e.getInstance(c.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(c.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=c.getEvent(e,c.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var o_=c.defineMixin(e=>{let t,n=!1;return{setOptions(r){const s=n;if(n=!0,!yt(r)){t&&($m(e),jr(r)),t=void 0;return}const o=hn(r);if(!o||t===o&&e.getInstance(c.SECURITY_MODULE_ID))return;t=o,e.inject(c.SECURITY_MODULE_ID,o);const i=e.getInstance(c.DISPOSABLE_ID);i&&s_(e,i)}}}),i_=c.defineMixin(e=>{const t=e.getInstance(c.DISPOSABLE_ID),n=c.getEvent(e,c.APP_LOAD_EVENT_ID),r=V(n),s=t.addDisposable(new rt(r));return{setOptions({handleLoad:o}){s.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function Tc(e,t,n=!0){const r=e,s=t;for(const o of Object.keys(s)){const i=s[o];i!=null&&(n&&typeof i=="object"?r[o]=Tc(r[o]||{},i,!0):r[o]=i)}return e}async function a_(e){const t=(await jl.__vitePreload(()=>Promise.resolve().then(()=>Promise.resolve(Ut("./static/umd/3f12d6ff.js")).then(n=>Gn.__toESM(n.default))),void 0,{}.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var Cc=c.createIdentifier$1("EditorOptions"),us=c.MONACO_EDITOR_OPTIONS;function c_(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function l_(e){return e.getOrCreateInstance(Cc,()=>{const t=ie(us);let n=us.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(a_(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function d_(e){return e?.getInstance(Cc)?.get()??us}function u_(e,t={}){const n=l_(e);n.set(Tc({...n.get()},c_(t)))}function f_(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function p_(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var h_=c.createIdentifier$1("plugin.publicConfig");function fs(e){return e.getInstance(c.CONFIG_SOURCE_ID)?.get()??{}}function Ac(e){return e.getInstance(c.CONFIG_SOURCE_ID)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Oc(e){const t=ra(e),n=fs(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:p_(d_(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Dc(e){return e.getInstance(c.CONFIG_SOURCE_ID)?.get()!==void 0}function m_(e){const t=c.createQueue(),n=fe(e,c.CONFIG_CHANGED_EVENT_ID);let r,s,o=!1;const i=async()=>{try{return e.getInstance(c.APP_ID)===void 0?{}:(await e.getInstanceAsync(c.APP_ID))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:p=!1}={})=>{await e.getInstance(c.CONFIG_SOURCE_ID)?.ready(),eo(e).set(fs(e).revisionService===!0);const{codeModeDirection:h,editor:m}=fs(e);m&&u_(e,f_(m)),h!==void 0&&!(p&&h===s)&&(s=h,h==="none"?Lr(e,!1):(Lr(e,!0),om(e,h)))},l=async()=>{if(!Dc(e))return;const p=Oc(e),h=JSON.stringify(p);h!==r&&(r=h,await n.fire(p))},d=async p=>{const h=e.getInstance(c.CONFIG_SOURCE_ID),m={advancedConfigs:Ac(e).advancedConfigs,serverSide:await i(),user:p};h?.setAdvancedConfigs({...m.advancedConfigs,...m.user?.advancedConfigs});const _=h?.layers().user.mode;h?.replace(m.user?.mode===void 0&&_!==void 0?{...m.user,mode:_}:m.user,"user"),h?.replace(m.serverSide,"server"),await a(),await l()},u=p=>{const{commonStyles:h,...m}=p;return"commonStyles"in p&&am(e,h===void 0?void 0:h),m};return{queue:t,reactToConfig:a,emitConfigChanged:l,resolveServerSideConfig:i,getConfig:()=>Dc(e)?Oc(e):{},setConfig:t.decorate(async p=>{await d(u(p))}),updateConfig:t.decorate(async p=>{const h=u(p);await d({...Ac(e).user,...h})}),announceAssembled(){o||(o=!0,e.getInstance(c.CONFIG_SOURCE_ID)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await l()})))}}}function Pc(e){return e.getOrCreateInstance(h_,()=>m_(e))}function g_(e){const t=Pc(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var v_=c.defineMixin(e=>{const t=e.getInstance(c.DISPOSABLE_ID),n=t.addDisposable(new c.AsyncEmitter),r=t.addDisposable(new c.AsyncEmitter),s=c.getEmitter(e,c.CONFIG_CHANGED_EVENT_ID),o=V(n.event),i=V(r.event),a=cc(V(s.event),e),l=t.addDisposable(new rt(o)),d=t.addDisposable(new rt(i)),u=t.addDisposable(new rt(a));return{instance:{handleSetOptions:o,handleOptionsChanged:i,handleConfigChanged:a},async setOptions(p){l.setListener(p.handleSetOptions),d.setListener(p.handleOptionsChanged),u.setListener(p.handleConfigChanged),Pc(e).announceAssembled(),await n.fire(p),await r.fire(p)},dispose(){}}}),ps,Rc="core";function E_(){const e=__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Rc],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function __(e){const t=__emailmaker__?.require?.warm;return typeof t!="function"?Rt().then(()=>{}):t([Rc],e)}function Rt(){return ps===void 0&&(ps=E_().then(e=>(dt()&&e.installDiagnostics().catch(t=>{}),e))),ps}var hs=null,ms=null;async function b_(e){typeof e?.prefetch=="function"&&await e.prefetch()}function gs(){return hs||(hs=Rt().then(()=>{})),hs}function kc(e){return ms||(ms=b_(e)),ms}function y_(){return kc(typeof __emailmaker__<"u"?__emailmaker__:void 0)}function S_(){const e=typeof __emailmaker__<"u"?__emailmaker__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function w_(e){return Promise.all([gs(),kc(e)]).then(()=>{})}function I_(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Nc(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>__(t?{priority:t}:void 0)).then(()=>(Sr(t?{priority:t}:void 0),n?gs():void 0)).catch(()=>{})}function T_(e){const t=I_(e);if(t==="eager")Nc(e);else if(t==="idle"){const n=()=>Nc(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Lc="PluginRegistry";function C_(e=c.resolveContainer()){return e.getOrCreateInstance(Lc,()=>new ql)}var Mc=new Kl(()=>C_());function Pw(e){}function ve(e,t){try{t()}catch{}}var xc=Symbol.for("emailmaker.result");function Fc(e){return Object.defineProperty(e,xc,{value:!0})}var at=(e=>Fc({ok:!0,value:e})),be=((e,t="")=>Fc({ok:!1,error:{code:e,message:t}}));function A_(e){return typeof e=="object"&&e!==null&&e[xc]===!0}var We=e=>({optional:!1,...e}),On={string:()=>We({kind:"string"}),number:()=>We({kind:"number"}),boolean:()=>We({kind:"boolean"}),enum:(...e)=>We({kind:"enum",values:e}),element:(...e)=>We({kind:"element",kinds:e}),array:e=>We({kind:"array",item:e}),object:e=>We({kind:"object",shape:e}),optional:e=>({...e,optional:!0})};function Bc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Dn(e,t,n){if(t===void 0)return e.optional?void 0:`"${n}" is required`;switch(e.kind){case"string":case"number":case"boolean":return typeof t===e.kind?void 0:`"${n}" must be a ${e.kind}`;case"enum":return e.values?.includes(t)?void 0:`"${n}" must be one of: ${e.values?.join(", ")}`;case"element":return t!==null&&(typeof t=="object"||typeof t=="string")?void 0:`"${n}" must be an element reference`;case"array":if(!Array.isArray(t))return`"${n}" must be an array`;for(let r=0;r<t.length;r+=1){const s=Dn(e.item,t[r],`${n}[${r}]`);if(s)return s}return;case"object":return Bc(t)?jc(e.shape,t,n):`"${n}" must be an object`}}function jc(e,t,n){for(const[r,s]of Object.entries(e??{})){const o=Dn(s,t[r],n?`${n}.${r}`:r);if(o)return o}}function O_(e,t,n){return e?Dn(e,t,n):void 0}function D_(e,t){if(!e)return;const n=e;return n.kind!=="object"?Dn(n,t,"arguments"):t!==void 0&&!Bc(t)?"arguments must be an object":jc(n.shape,t??{},"")}var P_=Symbol.for("emailmaker.domView");function R_(e){return typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.$$typeof=="symbol"}function k_(e){return typeof e=="object"&&e!==null&&typeof e[P_]=="function"}function Pn(e){const t={watch:e,select:n=>Pn(r=>{let s=!1,o;return t.watch(i=>{const a=n(i);s&&Object.is(o,a)||(s=!0,o=a,r(a))})})};return t}function N_(e){return Pn(t=>(t(e),{dispose:()=>{}}))}function L_(e,t){return Pn(n=>{let r=!1,s=!1,o;const i=()=>{if(!r)return;const l=t();s&&Object.is(o,l)||(s=!0,o=l,n(l))},a=e.map(l=>l.watch(i));return r=!0,i(),{dispose:()=>a.forEach(l=>l.dispose())}})}function ct(e){let t;return e.watch(n=>{t=n}).dispose(),t}var M_=Symbol.for("emailmaker.platform.hostError");function Ye(e,t){return Object.defineProperty(be(e,t),M_,{value:!0})}var x_={documentOpen:!1,selection:"none",codeMode:!1,readOnly:!1,headless:!1};function Rn(e,t){if(!e)return!0;if("any"in e)return e.any.some(r=>Rn(r,t));if("not"in e)return!Rn(e.not,t);const n={...x_,...t};return Object.entries(e).every(([r,s])=>n[r]===s)}var F_=class{_facts;_owners;_entries=new Map;_list=ie([]);_disposed=!1;constructor(e,t){this._facts=e,this._owners=t}get commands(){return this._list}has(e){return this._entries.has(e)}register(e,t,n,r={}){if(this._disposed)return`${e.name}`,{dispose:()=>{}};const s=Object.keys(t);for(const a of s){const l=this._entries.get(a);if(l)throw new Error(`Command "${a}" is already registered by "${l.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(typeof n[a]!="function")throw new Error(`Command "${a}" of "${e.name}" has no handler.`)}const o=s.map(a=>({id:a,owner:e,declaration:t[a],handler:n[a],enabled:r[a]??N_(!0),pending:new Set}));o.forEach(a=>this._entries.set(a.id,a)),this._publish();let i=!1;return{dispose:()=>{i||(i=!0,this._remove(o))}}}disposeOwner(e){this._remove(Array.from(this._entries.values()).filter(t=>t.owner===e))}disposeAll(){this._disposed=!0,this._remove(Array.from(this._entries.values()))}get disposed(){return this._disposed}async run(e,t,n){if(this._disposed)return Ye("unavailable",`Command "${e}" is not available: the editor was destroyed.`);const r=this._entries.get(e);if(!r)return Ye("notInstalled",`Command "${e}" is not installed in this host.`);if(!Rn(r.declaration.when,ct(this._facts)??{})||ct(r.enabled)===!1)return Ye("unavailable",`Command "${e}" is not available right now.`);const s=D_(r.declaration.args,t);if(s)return Ye("invalidArgs",`Command "${e}": ${s}.`);const o=new AbortController,i=new Promise(l=>{o.signal.addEventListener("abort",()=>l(be("aborted",`Command "${e}" was cancelled.`)),{once:!0})});r.pending.add(o);const a={signal:o.signal,caller:n.caller,run:(l,d)=>this.run(l,d,{caller:"plugin"})};try{return await Promise.race([this._execute(r,t??{},a),i])}finally{r.pending.delete(o)}}visible(e){return L_([this._list,this._facts],()=>{const t=this._entries.get(e);return t!==void 0&&Rn(t.declaration.when,ct(this._facts)??{})})}enabled(e){return Pn(t=>{let n,r;const s=i=>{i!==r&&(r=i,t(i))},o=this._list.watch(()=>{n?.dispose();const i=this._entries.get(e);n=i?i.enabled.watch(s):void 0,i||s(!1)});return{dispose:()=>{o.dispose(),n?.dispose()}}})}info(e){const t=this._entries.get(e);return t&&Uc(t)}async _execute(e,t,n){try{const r=e.handler,s=()=>r(t,n),o=await(this._owners?this._owners.execute(e.owner,s):s());return A_(o)?o:at(o)}catch(r){return be("internal",r instanceof Error?r.message:String(r))}}_remove(e){let t=!1;for(const n of e)this._entries.get(n.id)===n&&(this._entries.delete(n.id),t=!0),n.pending.forEach(r=>r.abort());t&&this._publish()}_publish(){this._list.set(Array.from(this._entries.values()).map(Uc))}};function Uc(e){const{title:t,description:n,icon:r}=e.declaration;return{id:e.id,owner:e.owner,title:t,description:n,icon:r}}function $c(e){const t=globalThis,n=Symbol.for(`emailmaker.platform.owner.${e}`);return t[n]??=Object.freeze({name:e})}var kn=$c("core"),Vc=$c("unknown"),Hc=Symbol.for("emailmaker.platform.builtInPlugin");function Gc(e){return Symbol.for(`emailmaker.platform.builtInKey.${e}`)}function vs(e){return Object.entries(e).forEach(([t,n])=>{typeof n=="function"&&(Object.defineProperty(n,Hc,{value:!0}),Object.defineProperty(n,Gc(t),{value:!0}))}),e}function B_(e,t){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Gc(t))}function j_(e){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Hc)}function Wc(e){return j_(e.constructor)}var U_=class{_owners=new WeakMap;_stack=[];_listeners=new Set;current(){return this._stack[this._stack.length-1]??Vc}execute(e,t){const n=e===kn?Vc:e;this._stack.push(n);try{return t()}finally{this._leave(n)}}onUnload(e){return this._listeners.add(e),{dispose:()=>this._listeners.delete(e)}}handle(e){const{plugin:t}=e;if(t)switch(e.type){case"init:enter":case"afterInit:enter":Wc(t)||this._stack.push(this._ownerOf(t,e.name));break;case"init:leave":case"afterInit:leave":Wc(t)||this._leave(this._ownerOf(t,e.name));break;case"dispose:start":{const n=this._owners.get(t);n&&(this._leave(n),this._owners.delete(t),Array.from(this._listeners).forEach(r=>r(n)));break}}}_ownerOf(e,t){let n=this._owners.get(e);return n||(n={name:t},this._owners.set(e,n)),n}_leave(e){const t=this._stack.lastIndexOf(e);t>=0&&this._stack.splice(t,1)}},Nn=["plugins"],$_={toolbar:{kind:"item",groups:["view","collaboration","document","plugins","primary"]},"menu:document":{kind:"item",groups:["document","plugins","access","danger"]},"menu:export":{kind:"item",groups:["formats","plugins","platforms"]},"menu:view":{kind:"item",groups:["preview","plugins","share"]},"menu:save":{kind:"item",groups:Nn},statusBar:{kind:"item",groups:["selection","document","plugins","collaboration"]},notices:{kind:"item",groups:Nn},sidebar:{kind:"view",groups:["content","collaboration","analysis","plugins","settings"]},dialog:{kind:"view",groups:Nn},documentSettings:{kind:"view",groups:Nn}},Es="plugins";function V_(e,t){const n=e.groups.indexOf(t);return n<0?e.groups.length:n}var Rw="1.0",H_=Symbol.for("emailmaker.viewHost"),_s={dispose:()=>{}},G_=class{_deps;apiVersion="1.0";_locations=new Map(Object.entries($_));_items=ie([]);_views=ie([]);_opened=ie([]);_viewById=new Map;_seq=0;_openedKey=0;_disposed=!1;constructor(e){this._deps=e,this._registerCoreCommands()}get opened(){return this._opened}registerLocation(e,t){if(this._locations.has(e))throw new Error(`Location "${e}" is already registered.`);return this._locations.set(e,t),{dispose:()=>{this._locations.get(e)===t&&this._locations.delete(e)}}}addItem(e,t){if(this._skipAfterDispose(e))return _s;const n=this._itemLocation(t.location,"item",e);if(!n)return _s;const r={seq:this._nextSeq(),owner:e,location:t.location,group:this._groupOf(n,t.group,t.location),order:t.order??0,item:t};return this._items.set([...this._items.get()??[],r]),{dispose:()=>this._removeItems(s=>s===r)}}addViews(e,t,n,r){if(this._skipAfterDispose(e))return _s;const s=Object.keys(t);for(const i of s){const a=this._viewById.get(i);if(a)throw new Error(`View "${i}" is already registered by "${a.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(!R_(n[i])&&!k_(n[i]))throw new Error(`View "${i}" of "${e.name}" has no component; pass a React component or domView(renderer).`)}const o=[];for(const i of s){const a=t[i],l=this._itemLocation(a.location,"view",e);if(l){const d=this._groupOf(l,a.group,a.location);o.push({seq:this._nextSeq(),id:i,owner:e,location:a.location,group:d,order:a.order??0,declaration:a,renderer:n[i],editor:r})}}return o.forEach(i=>this._viewById.set(i.id,i)),this._views.set([...this._views.get()??[],...o]),{dispose:()=>this._removeViews(i=>o.includes(i))}}open(e,t){if(this._disposed)return Promise.resolve(be("cancelled",`View "${e}" cannot open: the editor was destroyed.`));if(ct(this._deps.facts)?.headless)return Promise.resolve(Ye("unavailable",`View "${e}" cannot open: the editor has no interface.`));const n=this._viewById.get(e);if(!n)return Promise.resolve(Ye("notInstalled",`View "${e}" is not installed in this host.`));const r=O_(n.declaration.input,t,"input");return r?Promise.resolve(Ye("invalidArgs",`View "${e}": ${r}.`)):(this.close(e),new Promise(s=>{const o=new AbortController;let i=!1;const a=p=>{if(!i){i=!0;try{this._opened.set((this._opened.get()??[]).filter(h=>h!==u))}finally{o.abort(),s(p)}}},l=p=>a(at(p)),d={input:t,signal:o.signal,close:l};Object.defineProperty(d,H_,{value:this._viewHost(n)});const u={key:this._openedKey+=1,view:e,owner:n.owner,location:n.location,input:t,record:n,renderer:n.renderer,signal:o.signal,context:d,close:l,cancel:()=>a(be("cancelled",`View "${e}" was closed without a result.`))};this._opened.set([...this._opened.get()??[],u])}))}viewLocation(e){return this._viewById.get(e)?.location}close(e){(this._opened.get()??[]).filter(t=>t.view===e).forEach(t=>t.cancel())}items(e){return this._items.select(t=>this._sorted(t,e))}get allViews(){return this._views}views(e){return this._views.select(t=>this._sorted(t,e))}disposeOwner(e){ve("items",()=>this._removeItems(t=>t.owner===e)),ve("views",()=>this._removeViews(t=>t.owner===e))}disposeAll(){this._disposed=!0,ve("items",()=>this._removeItems(()=>!0)),ve("views",()=>this._removeViews(()=>!0))}supports(e,t){switch(e){case"service":return t==="Commands"||t==="Ui";case"location":return this._locations.has(t);case"command":return this._deps.commands.has(t);case"view":return this._viewById.has(t)}}_sorted(e,t){const n=this._locations.get(t),r=s=>n?V_(n,s.group):0;return e.filter(s=>s.location===t).sort((s,o)=>r(s)-r(o)||s.order-o.order||s.seq-o.seq)}_itemLocation(e,t,n){const r=this._locations.get(e);if(!r)`${n.name}${e}`;else if(r.kind!==t){`${n.name}`,`${e}${r.kind}`;return}return r}_groupOf(e,t,n){return t===void 0?Es:e.groups.includes(t)?t:(`${n}${t}${Es}`,Es)}_nextSeq(){return this._seq+=1,this._seq}_removeItems(e){const t=this._items.get()??[];t.some(e)&&this._items.set(t.filter(n=>!e(n)))}_removeViews(e){const t=this._views.get()??[],n=t.filter(e);if(n.length!==0){n.forEach(r=>this._viewById.delete(r.id));try{this._views.set(t.filter(r=>!e(r)))}finally{(this._opened.get()??[]).filter(r=>n.includes(r.record)).forEach(r=>ve(`close ${r.view}`,()=>r.cancel()))}}}_skipAfterDispose(e){return this._disposed&&(`${e.name}`,void 0),this._disposed}_viewHost(e){return{run:(t,n)=>this._deps.commands.run(t,n,{caller:"ui"}),editor:e.editor}}_registerCoreCommands(){this._deps.commands.register(kn,{"ui.openView":{title:"Open view",args:On.object({view:On.string()}),agent:!0},"ui.closeView":{title:"Close view",args:On.object({view:On.string()}),agent:!0}},{"ui.openView":e=>this.open(e.view,e.input),"ui.closeView":e=>(this.close(e.view),at())})}};function W_(){return ie({})}function kt(e,t){const n=e.get()??{};Object.keys(t).some(r=>n[r]!==t[r])&&e.set({...n,...t})}var Y_=c.createIdentifier$1("platform.ownerTracker"),q_=c.createIdentifier$1("platform.whenFacts"),K_=c.createIdentifier$1("platform.commandRegistry"),z_=c.createIdentifier$1("platform.uiService");function Nt(e){return e.getOrCreateInstance(Y_,()=>{const t=new U_;return t.onUnload(n=>{ve("commands",()=>Te(e).disposeOwner(n)),ve("ui",()=>Mn(e).disposeOwner(n))}),t})}function Ln(e){return e.getOrCreateInstance(q_,W_)}function X_(e){const{isDisposed:t}=e;return typeof t=="function"&&t.call(e)}function Yc(e){return e.getOrCreateInstance(K_,()=>new F_(Ln(e),Nt(e)))}function J_(e){return e.getOrCreateInstance(z_,()=>(Nt(e),new G_({commands:Yc(e),facts:Ln(e)})))}function qc(e){const t=Yc(e),n=J_(e);return!t.disposed&&X_(e)&&(ve("ui",()=>n.disposeAll()),ve("commands",()=>t.disposeAll())),{registry:t,ui:n}}function Te(e){return qc(e).registry}function Mn(e){return qc(e).ui}function Q_(e){const t=Te(e),n=Mn(e);return{dispose:()=>{ve("ui",()=>n.disposeAll()),ve("commands",()=>t.disposeAll())}}}function Z_(e,t){const n=Nt(e);return t.onLifecycle(r=>n.handle(r))}var eb=["Commands","Ui"];function tb(e,t){for(let n=e;typeof n=="function";n=Object.getPrototypeOf(n))if(B_(n,t))return!0;return!1}function nb(e,t){if(!tb(t,e)){const n=typeof t=="function"?t.name||"anonymous":typeof t}}function rb(e){const t=eb.map(n=>e.on(n,r=>nb(n,r)));return{dispose:()=>t.forEach(n=>n.dispose())}}var Kc=new WeakMap,zc=new WeakSet;function sb(e,t,n){const r=e.getInstance(c.DISPOSABLE_ID);if(r?.isDisposed()){ve("ui",()=>Mn(e).disposeAll()),ve("commands",()=>Te(e).disposeAll());return}Kc.get(e)?.dispose();const s=new c.Disposable([Z_(e,t),rb(n)]);Kc.set(e,s),r?.addDisposable(s),r&&!zc.has(e)&&(zc.add(e),r.addDisposable(Q_(e)))}function ob(e){return e?.lockEditor===!0}var Xc={text:"text",img:"image",a:"link",button:"button",div:"container",vindent:"spacer",video:"video",table:"table",customTable:"table",structure:"row",column:"column",td:"cell",var:"variable",countdown:"countdown",carousel:"carousel",accordion:"accordion",social:"social",floatBlock:"floatingBlock"};function ib(e){return typeof e=="string"&&Object.hasOwn(Xc,e)&&Xc[e]||"none"}function bs(e,t,n){let r,s;const o=()=>{const i=e.getInstance(t);return i===void 0||r?r!==void 0:(r=n(i),!0)};return o()||(s=e.onInject(i=>{i===t&&o()&&s?.dispose()})),{dispose:()=>{s?.dispose(),r?.dispose()}}}function ab(e){const t=Ln(e),n={editor:!1,document:!1},r=()=>kt(t,{readOnly:n.editor||n.document});r();const s=[vr(e).watch(o=>kt(t,{headless:o})),fn(e).watch(({isCodeMode:o})=>kt(t,{codeMode:o})),bs(e,c.CONFIG_SOURCE_ID,o=>o.watch(i=>{n.editor=ob(i),r()})),bs(e,Vt,o=>{let i,a;const l=()=>{const h=o.sessionKey(),m=h!==void 0&&!J(h)?o.current()?.get().attributes:void 0;n.document=m?.lock===!0&&!ro(e,m),r()},d=()=>{const h=o.sessionKey();kt(t,{documentOpen:h!==void 0,documentKind:h===void 0?void 0:J(h)?"block":"email"});const m=o.current();m!==i&&(a?.(),i=m,a=m?.subscribe(l)),l()};d();const u=o.subscribe(d),p=gd(e,l);return{dispose:()=>{u(),a?.(),p.dispose()}}})];return s.push(bs(e,c.STORE_ID,o=>{const i=()=>{const d=o.getState(),u=ct(t)?.documentKind==="block"?d.blockSlice:d.emailSlice;kt(t,{selection:ib(u?.elementSettings?.type)})};i();const a=t.select(d=>d?.documentKind).watch(i),l=o.subscribe(i);return{dispose:()=>{l(),a.dispose()}}})),{dispose:()=>s.forEach(o=>o.dispose())}}var cb=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],lb=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],xn=new Map([...cb.map(e=>[e,"event"]),...lb.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),db=new Map([["use","use `useAsync()` or await `ready` first"]]);function ub(e){return db.get(e)??"await `ready` first"}var fb=new Set(["async","queued"]),pb=Symbol.for("emailmaker.earlyCtxPlaceholder");function Jc(e){return e[pb]=!0,e}function hb(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${ub(e)}).`)}function mb(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function gb(e){return[...xn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function vb(e,t){for(const n of gb(e)){const r=xn.get(n);if(r!==void 0&&fb.has(r)){const s=async(...o)=>{await t;const i=e[n];if(typeof i!="function"||i===s)throw mb(n);return i.apply(e,o)};e[n]=Jc(s);continue}e[n]=Jc(()=>{throw hb(n)})}}function Eb(e,t,n){e.getInstanceAsync(it).then(()=>{c.getEmitter(e,c.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function _b(e,t){e.getInstanceAsync(it).then(()=>{c.getEmitter(e,c.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var bb=c.defineMixin(e=>{let t;function n(){return new Promise(s=>{const o=e.getOrCreateInstance(c.LATE_SURFACE_LISTENERS_ID,()=>new Set),i=()=>{o.delete(i),s()};o.add(i)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(s){const o=e.getInstance(c.INSTANCE_ID),i=e.getInstance(Lc);if(!t){t=new Yl(o,i,{ensureHostRuntimeReady:y_,explainScriptFailure:S_,openEarlyWindow:()=>vE(e),reportLoadFailure:d=>_b(e,d)}),e.inject(c.PLUGIN_COLLECTION_ID,t),sb(e,t,i);const l=t.onLifecycle(d=>{d.type==="create:error"&&Eb(e,d.name,d.error)});e.getInstance(c.DISPOSABLE_ID)?.addDisposable(l),e.getInstance(c.DISPOSABLE_ID)?.addDisposable(ab(e))}const a=s?.plugins||[];o&&(vr(e),a.length>0&&vb(o,n()),await t.setPlugins(a))},instance:{use(s){return typeof s=="function"?r().useByCtor(s):r().useByKey(s)},useAsync(s){return r().useAsync(s)},waitPlugin(s){return r().waitFor(s)}},dispose(){t?.dispose(),t=void 0}}}),Qc=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const s=this._listeners.indexOf(r);s>=0&&this._listeners.splice(s,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}},yb=c.createIdentifier$1("ELEMENT_INSERT_HTML_PIPELINE"),Sb=c.createIdentifier$1("BLOCK_INSERT_HTML_PIPELINE"),wb="application_block_inserted",Ib=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Sb,()=>new Qc).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(c.MESSAGE_SERVICE_ID,()=>new c.MessageService),s=n?e.bind(n):e;return r.addListener(wb,s,t)}},Tb=class{_context;constructor(e){this._context=e}register(e,t){const n=this._context.container,r=Nt(n).current(),s={},o={};for(const[i,a]of Object.entries(e)){const{run:l,...d}=a;if(typeof l!="function")throw new Error(`Command "${i}" of "${r.name}" has no \`run\`; declare it with defineCommand({ title, run }).`);s[i]=d,o[i]=l}return Te(n).register(r,s,o,t)}run(e,...t){return Te(this._context.container).run(e,t[0],{caller:"plugin"})}has(e){return Te(this._context.container).has(e)}},ys=c.createIdentifier$1("ComponentRegistry"),Cb=c.createIdentifier$1("ComponentRegistryGate");function Ss(){return c.DependencyResolver.getOrCreateInstance(Cb,()=>({pending:[]}))}function Ab(e=ys){return Ss().factory!==void 0||c.DependencyResolver.getInstance(e)!==void 0}function ws(e,t,n=ys){if(Ab(n)){t(Fn(e,n));return}Ss().pending.push(()=>t(Fn(e,n)))}function Fn(e,t=ys){const n=c.DependencyResolver.getInstance(t);if(n)return n;const r=Ss().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return c.DependencyResolver.getOrCreateInstance(t,r)}var Ob=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=o=>{if(!n){n=!0;for(const i of t)i.dispose();e(o)}};t.push(this._container.addService(c.ATOMS_HANDLERS_ID,{execute:o=>{r(o.value.map(i=>({name:i.name,html:i.html})))}}));const s=this._container.getInstance(c.HEADLESS_MODE_ID)?.watch(o=>{o&&r([])});s&&(n?s.dispose():t.push(s))})}update(e,t){const n=this._container;return n.addService(c.ATOMS_HANDLERS_ID,{execute:r=>{const s=Fn(n),o=r.value.find(i=>i.name===e);if(o){const{icon:i,title:a,fallbackTooltip:l,...d}=t;i&&(o.icon=s.getReactNode(i)),a&&(o.title=s.getReactNode(a)),l&&(o.fallbackTooltip=s.getReactNode(l)),Object.assign(o,d)}}})}delete(e){this._container.addService(c.ATOMS_HANDLERS_ID,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService(c.ATOMS_HANDLERS_ID,{execute:r=>{const s=Fn(n);r.value.splice(t??r.value.length,0,{...e,title:s.getReactNode(e.title),icon:s.getReactNode(e.icon),fallbackTooltip:s.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(yb,()=>new Qc).add(e,t??0,n)}handleInject(e,t,n){return c.getEmitter$1(this._container,c.HANDLE_ATOM_INSERT_ID).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Db=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(c.MESSAGE_SERVICE_ID,()=>new c.MessageService)}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 Pb(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Zc(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var Rb=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=c.getEmitter$1(t,c.MODAL_SHOW_EVENT),this._closeModalEmitter=c.getEmitter$1(t,c.MODAL_CLOSE_EVENT),this._updateModalEmitter=c.getEmitter$1(t,c.MODAL_UPDATE_EVENT)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return ws(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Zc(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;ws(this._container,r=>{const s=o=>o===void 0?void 0:r.getReactNode(o);this._updateModalEmitter.fire(Pb({...t,content:s(t.content),title:s(t.title),id:e,modalProps:Zc(r,n)}))})}};function Bn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var kb=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=s=>{this._loadedSettled||(this._loadedSettled=!0,r(s))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=s=>{this._readySettled||(this._readySettled=!0,r(s))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},Nb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(c.MESSAGE_SERVICE_ID,()=>new c.MessageService)}_createScriptHandle(e,t){const n=this._messageService.addListener(c.SANDBOX_EXTENSION_SCRIPT_STATUS_ID,s=>{if(s.key===e){if(s.phase==="load"&&s.status==="success"){r.resolveLoaded();return}if(s.phase==="ready"&&s.status==="success"){r.resolveReady();return}if(s.phase==="load"){r.rejectLoad(new Error(s.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(s.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new kb(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(c.SANDBOX_EXTENSIONS_ID,{...Bn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(c.SANDBOX_EXTENSIONS_ID,{...Bn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(c.SANDBOX_EXTENSIONS_ID,{...Bn(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(c.SANDBOX_EXTENSIONS_ID,{...Bn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},Lb=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Is(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Lb.has(t)}function el(){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 Ts(){return`__settingsPanel:${el()}`}function Cs(e,t){return{type:e,props:t}}function Mb(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Is(e)}function tl(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Is(t)){const r=Ts();return n(e.add(r,t)),Cs(r,{})}if(typeof t=="function"){const r=Ts();return n(e.add(r,t)),Cs(r,{})}if(Mb(t)){const r=t.type;if(typeof r=="string")return t;if(Is(r)||typeof r=="function"){const s=Ts();return n(e.add(s,r)),Cs(s,t.props)}return t}return t}var xb=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??el();ws(this._container,n=>{const r=i=>this._trackRegistration(i),s=tl(n,e.content,r),o=e.advancedTabs?.map(i=>({...i,content:tl(n,i.content,r)}));c.getEmitter$1(this._container,c.SETTINGS_PANEL_EVENT).fire({...e,content:s,advancedTabs:o,instanceKey:t,type:c.ADVANCED_SETTINGS_PANEL})})}closeSettingsPanel(){this._clearPanelRegistrations(),c.getEmitter$1(this._container,c.SETTINGS_PANEL_EVENT).fire(null)}},Fb=class{_context;constructor(e){this._context=e}get apiVersion(){return this._service().apiVersion}supports(e,t){return this._service().supports(e,t)}addViews(e,t){return this._service().addViews(this._owner(),e,t,this._context)}addItem(e){return this._service().addItem(this._owner(),e)}open(e,...t){return this._service().open(e,t[0])}_service(){return Mn(this._context.container)}_owner(){return Nt(this._context.container).current()}},nl=vs({SandboxScriptApi:Nb,ElementsApi:Ob,BlocksApi:Ib,MessageService:Db,SettingsPanelApi:xb,ModalApi:Rb,Commands:Tb,Ui:Fb});function As(e,t,n,r={}){const s=Object.assign({},e);for(const[o,i]of Object.entries(t))if(i!==void 0)if(n.includes(o)&&typeof i=="object"&&i!==null){const a=s[o],l=r[o]??{};s[o]=Object.assign({},typeof a=="object"&&a!==null?a:l,i)}else s[o]=i;return s}var Ee={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},Bb={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"},Os={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},rl={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},lt={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:Ee.border,borderRadius:Ee.borderRadius,textAlign:"center",padding:Ee.padding},sl={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Ee.padding},Ds={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Ee.border,borderRadius:Ee.borderRadiusCards};function jb(e){return{...Bb,...e}}function Ub(e){return{...Os,...e,bold:e?.bold??Os.bold,italic:e?.italic??Os.italic}}function $b(e){return{...rl,...e,underline:e?.underline??rl.underline}}function Vb(e){return{...lt,...e,bold:e?.bold??lt.bold,italic:e?.italic??lt.italic,border:{...lt.border,...e?.border},borderRadius:{...lt.borderRadius,...e?.borderRadius},padding:{...lt.padding,...e?.padding}}}function Hb(e){return{...sl,...e,padding:{...sl.padding,...e?.padding}}}function Gb(e){return{...Ds,...e,border:{...Ds.border,...e?.border},borderRadius:{...Ds.borderRadius,...e?.borderRadius}}}function Ps(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 ol(e){let t={...c.COMMON_STYLES};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Rs(e){return{text:jb(e.text),headings:Ub(e.headings),links:$b(e.links),buttons:Vb(e.buttons),block:Hb(e.block),cards:Gb(e.cards)}}var il=c.createIdentifier$1("EmailSettingsPort"),Wb=1e4,al=class{_editor;_layoutSettingsChanged=new c.Emitter;_contentStylesChanged=new c.Emitter;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!ac(this._editor.container)||!Ke(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(il);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Ps(this._settings().read())}_getCurrentContentStyles(){const e=Ke(this._editor.container)?.current()?.get().attributes.common_styles;return Rs(ol(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(il),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(c.MESSAGE_SERVICE_ID,()=>new c.MessageService),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const s=r?.data,o=s?.operation;if(o===c.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){const l=Ps(s?.settings),d=this._getLayoutSnapshot(l);d!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=d,this._layoutSettingsChanged.fire(l));return}if(o!==c.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE)return;const i=Rs(r.data?.settings?.commonStyles??{...c.COMMON_STYLES}),a=this._getContentSnapshot(i);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(i))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=Ps(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Wb){const t=Ke(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,s=c.getEvent(r,c.events.ON_EMAIL_INIT_ID);return new Promise(o=>{let i=!1,a;const l=()=>{a&&(clearTimeout(a),a=void 0)},d=s(()=>{i||(i=!0,l(),d.dispose(),o())});a=setTimeout(()=>{i||(i=!0,d.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Ke(this._editor.container)?.current();if(!t)return;const n=ol(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=As(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Ee.border,borderRadius:Ee.borderRadius,padding:Ee.padding})),e.block!==void 0&&(n.block=As(n.block||{},e.block,["padding"],{padding:Ee.padding})),e.cards!==void 0&&(n.cards=As(n.cards||{},e.cards,["border","borderRadius"],{border:Ee.border,borderRadius:Ee.borderRadiusCards}));const r=JSON.stringify(n);Qe(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const s=Rs(n);this._prevContentSnapshot=this._getContentSnapshot(s),this._contentStylesChanged.fire(s)}},Yb={...nl,...vs({EmailSettingsApi:al})},qb={...nl},kw={...qb,...vs({EmailSettingsApi:al})},Kb={...Yb};function zb(){Mc.addAll(Kb)}var Xb=[c.defineMixin(()=>{zb()}),i_,v_,o_,c.JWTMixin,r_,c.OAuthMixin];async function Jb(){return(await Rt()).asyncMixins}var Qb=bb,Zb=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let s;try{s=await Jb()}catch(i){throw e.failPendingWaits(i),i}t=s(e);const o=await e.getInstanceAsync(c.INSTANCE_ID);Object.assign(o,t.instance||{});for(const i of e.getInstance(c.LATE_SURFACE_LISTENERS_ID)??[])i()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},ey=c.combineMixins([...Xb]);function ks(){let e,t=!1;const n=new Map,r=new Map;function s(){for(const o of r.values())o();r.clear()}return{event(o,i,a){const l=Symbol("subscription");return t||(n.set(l,{listener:o,priority:i,thisArg:a}),e&&r.set(l,e(o,i,a))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(o){s(),e=o;for(const[i,{listener:a,priority:l,thisArg:d}]of n)r.set(i,o(a,l,d))},dispose(){t=!0,s(),n.clear(),e=void 0}}}function ty(e){const t=ks(),n=ks(),r=ks();return e.getInstance(c.DISPOSABLE_ID)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(it).then(s=>{t.attach(s.onNotify),n.attach(s.onError),r.attach(s.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(s){const o=e.getInstance(it);if(o){o.notify(s);return}e.getInstanceAsync(it).then(i=>i.notify(s),()=>{})}}}var cl=c.createIdentifier$1("CodeErrors"),ny=[];function ry(e){return e?.getInstance(cl)?.get()??ny}function sy(e){return e?.getInstance(cl)!==void 0}function Nw(e){return e}var oy="SAVE",iy="SAVE_BLOCK",Lw="SET_THEME",Mw="NOTIFY",xw="SET_CONFIG",Fw="UPDATE_CONFIG",ll=class extends c.Disposable{_options;_listeners=[];constructor(e){super(),this._options=e}fire=e=>{if(!this.isDisposed()){let t;const n=[...this._listeners];for(const r of n){if(t===!1)return!1;t instanceof Promise?t=t.then(s=>s===!1||this.isDisposed()?!1:r(s)).catch(s=>{}):t=r(e)}return t}};addEventListener=e=>{const t=this._listeners,n=this._options;return t.push(e),t.length===1&&this._options?.onFirstListenerAdd&&this._options.onFirstListenerAdd(),{dispose:()=>{const r=t.indexOf(e);r>=0&&(t.splice(r,1),t.length||n?.onFirstListenerAdd&&n.onLastListenerRemove())}}};event=this.addEventListener},dl;(function(e){function t(s){let o;const i=new ll({onFirstListenerAdd(){o=s(i.fire)},onLastListenerRemove(){o.dispose()}});return i.event}e.snapshot=t;function n(s,o){return t(i=>s(a=>o(a)&&i(a)))}e.filter=n;function r(s,o){return t(i=>s(a=>i(o(a))))}e.map=r})(dl||(dl={}));var ay=c.createIdentifier$1("helpers.commandEmitter");function cy(e,t,n){e instanceof c.Container||(e=c.getContainer(e)),e.getOrCreateInstance(ay,()=>new ll).fire({id:t,payload:n})}var Ns="document.getSnapshot",ly="document.save",ul=Symbol.for("emailmaker.legacyEmailSnapshot"),Ls=Symbol.for("emailmaker.legacyEmailSnapshotError");function dy(e,t){return Object.defineProperty(e,ul,{value:t})}function uy(e){return dy({kind:"email",id:e.id==null?null:String(e.id),content:e.code??"",subject:e.subject??"",preheader:e.preheader??""},e)}function fy(e){return{kind:"block",id:e.id==null?null:String(e.id),content:e.code??"",subject:"",preheader:""}}function py(e,t){const n=Te(e),r={[Ns]:{declaration:{title:"Get document snapshot",description:"Returns the open document: kind, id and content."},handler:async()=>{try{const i=Se(e),a=J(i?.sessionKey())?await t.getBlockSnapshot():null;return at(a?fy(a):uy(await t.readEmailSnapshot()))}catch(i){return Object.defineProperty(be("internal",i instanceof Error?i.message:String(i)),Ls,{value:i})}}},[ly]:{declaration:{title:"Save document",description:"Saves the open document and finishes when the save is done."},handler:()=>vy(e)}},s=new Map,o=n.commands.watch(()=>{n.disposed||Object.entries(r).forEach(([i,{declaration:a,handler:l}])=>{n.has(i)||s.set(i,n.register(kn,{[i]:a},{[i]:l}))})});return{dispose:()=>{o.dispose(),s.forEach(i=>i.dispose())}}}async function hy(e,t){const n=await Te(e).run(Ns,void 0,{caller:"plugin"});if(n.ok===!1){if(Ls in n)throw n[Ls];return t()}return n.value[ul]}function my(e){return Te(e).info(Ns)?.owner===kn}async function gy(e,t){const n=await new Promise(o=>{cy(e,t,{source:wf,settle:o})});if(n.ok!==!1)return at();if(n.reason==="unready")return;const r=n.reason==="locked"?"readOnly":n.reason==="aborted"?"aborted":"internal",s=be(r,n.message);return n.notified?Object.defineProperty(s,Tf,{value:!0}):s}async function vy(e){if(ct(Ln(e))?.readOnly)return be("readOnly","The editor is read-only.");const t=Se(e)?.sessionKey();if(t!==void 0){const r=J(t);if(Af(e,r?"block":"email")){const s=await gy(e,r?iy:oy);if(s)return s}}const n=e.getInstance(c.INSTANCE_ID);if(t===void 0||!n)return be("unavailable","There is no open document to save.");try{return await(J(t)?n.saveBlock():n.save()),at()}catch(r){return r instanceof Oe&&r.reason==="locked"?be("readOnly",r.message):be("internal",r instanceof Error?r.message:String(r))}}var Ey=class extends c.Disposable{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=Tt(e),this.addDisposable(c.getEvent(e,c.events.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t})),this.addDisposable(py(e,this))}openEmail(){const e=Se(this._container);if(e&&J(e.sessionKey())&&!e.hasSuspended())throw new Error("[emailmaker] no open email: only a block is shown");return Ua(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>pe(t,this._container))}async _readProjectBlocks(){const e=await $a(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>At(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>Jr(n,this._container))}async getEmailSnapshot(){return J(Se(this._container)?.sessionKey())||!my(this._container)?this.readEmailSnapshot():hy(this._container,()=>this.readEmailSnapshot())}async readEmailSnapshot(){return ge(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Se(this._container),t=e?.current();return!e||!t||!J(e.sessionKey())?null:(await t.whenReady(),pe(dn(t),this._container))}setEmailMeta(e){const t=Kr(this._container);if(!t)return;const n=t.get().attributes.meta;Qe(t,{meta:mn({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,s=>s&&mn(s,e))}setBlockMeta(e,t){const n=Se(this._container);if(n?.sessionKey()===Kt(e)){const s=n.current();s&&Qe(s,{meta:mn({meta:s.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:s}=this._dataSources.blocks;await s.getIfPresent(e)&&await s.addOrUpdate(e,o=>o&&mn(o,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return sy(this._container)?ry(this._container):void 0}},_y=c.createIdentifier$1("EmailDataController");function by(e){return e.getOrCreateInstance(_y,()=>{const t=new Ey(e);return e.getInstance(c.DISPOSABLE_ID)?.addDisposable(t),t})}function yy(e){const t=by(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function Sy(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function wy(e){let t;const n=ga(e),r=c.getEvent(e,c.events.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:o})=>{t=o}));const s=()=>t?Sy(t):void 0;return{undoRedoService:{undo:()=>s()?.undo(),redo:()=>s()?.redo(),clear:()=>s()?.clear(),getPast:o=>s()?.getPast(o)??[],getFuture:o=>s()?.getFuture(o)??[],canUndo:()=>s()?.canUndo()??!1,canRedo:()=>s()?.canRedo()??!1,createSnapshot:()=>s()?.createSnapshot(),restoreSnapshot:o=>s()?.restoreSnapshot(o)}}}var Iy=c.createIdentifier$1("plugin.mountElement");function Ty(e){const t=e.getInstance(c.OPTIONS_SOURCE_ID)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function Cy(e){return e.getOrCreateInstance(Iy,()=>{let t=!1,n;return{get:()=>t?n:Ty(e),set(r){t=!0,n=r}}})}function Ay(e){const t=Cy(e);return{getElement:()=>t.get()}}function Oy(e){return{handleLoadImage:V(c.getEvent(e,c.events.UPLOAD_EVENT_ID)),handleFileProxy:V(c.getEvent(e,c.events.FILE_PROXY_EVENT_ID)),handleUrlProxy:V(c.getEvent(e,c.events.PROXY_URL_EVENT_ID)),handleAITextRequest:V(c.getEvent(e,c.events.AI_TEXT_REQUEST_ID)),handleAIImageRequest:V(c.getEvent(e,c.events.AI_IMAGE_REQUEST_ID)),handleReadLocale:V(c.getEvent(e,c.events.READ_LOCALE)),handleLimitUsage:V(c.getEvent(e,c.events.ON_LIMIT_ID)),handleTranslate:V(c.getEvent(e,c.events.ON_TRANSLATE_ID))}}var Dy=[ng,CE,ty,g_,yy,wy,Ay,Oy];function Py(e,t=Dy){const n=ds(e);e_(e);const r=ey(e),s=Qb(e),o=Zb(e),i={...r.instance,...s.instance,...o.instance};for(const l of t)Object.assign(i,l(e));let a=!0;return{instance:i,async setOptions(l){await r.setOptions(l);const d=a&&n.get()===l;a=!1,d||n.set(l),await s.setOptions(l),await o.setOptions(l)}}}function Ry(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var ky=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]}},Ny="editor-runtime.react.copies",Ms=8;function Lt(e){return e&&typeof e=="object"?e:void 0}function fl(e){const t=Lt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Lt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function Ly(e){const t=Lt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Lt(t?.default),s=r&&typeof r.version=="string"?r.version:void 0;return n??s??"unknown"}function My(e,t,n){return e.package===t&&e.version===n}function xy({ourReact:e,entries:t,packageName:n,version:r}){const s=fl(e);if(!s||!Array.isArray(t))return[];const o=[],i=new Set;for(const a of t){const l=Lt(a);if(!l||!My(l,n,r))continue;const d=fl(l.react);!d||d===s||i.has(d)||(i.add(d),o.push({package:n,version:r,reactVersion:Ly(l.react),react:l.react}))}return o}function Fy({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,Ms))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Ms&&n.push(` …and ${t.length-Ms} 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(`
2153
+ `)}var pl=new Set;function By({packageName:e="@emailmaker/emailmaker",version:t="1.3.5",log:n=r=>{}}={}){const r=s=>{try{const o=globalThis[Symbol.for(Ny)],i=xy({ourReact:s,entries:o,packageName:e,version:t}).filter(a=>!pl.has(a.react));if(!i.length)return;i.forEach(a=>pl.add(a.react)),n(Fy({packageName:e,copies:i}))}catch{}};try{const s=qn()?.modules?.React;if(s&&typeof s.then=="function"){s.then(r,()=>{});return}r(s)}catch{}}async function jy(e,t,n){c.throwIfAborted(e.signal);const r=t??c.DependencyResolver.createChild();ds(r);const s=r.getInstance(c.DISPOSABLE_ID);let o;async function i(){r.inject(c.COOKIE_MANAGER_ID,Ry(new ky)),By();const a=Py(r),l={...a.instance,container:r,get ready(){return o??Promise.resolve(l)},async reset(d){if(c.throwIfAborted(d.signal),s.isDisposed())throw Ae();return await a.setOptions(d),l}};r.inject(c.INSTANCE_ID,l);try{if(n?.onInstance?.(l),await a.setOptions(e),c.throwIfAborted(e.signal),s.isDisposed()||await wE(r),e.devTools)try{const d=r.getInstance(c.PLUGIN_COLLECTION_ID);d&&await(await Rt()).initDevTools(r,d)}catch{}return c.throwIfAborted(e.signal),c.getEmitter(r,c.APP_LOAD_EVENT_ID).fire(l),l}catch(d){throw s.dispose(),d}}try{return o=c.raceWithAbortSignal(i(),e.signal),o.catch(()=>{}),await o}catch(a){throw s.isDisposed()||s.dispose(),a}}var Mt=new WeakMap;function Uy(e){return e?Mt.get(e):void 0}function hl(e){try{e.getInstance(c.DISPOSABLE_ID)?.dispose()}catch{}try{e.dispose()}catch{}}function $y(e,t){if(!e)return;const n=Mt.get(e);n&&n!==t&&hl(n),Mt.set(e,t)}function Vy(e,t){e&&Mt.get(e)===t&&Mt.delete(e)}function Hy(e){const t=c.DependencyResolver.createChild();return yt(e)&&t.inject(c.SECURITY_MODULE_ID,hn(e)),t}var xt=new WeakMap,Gy="data-emailmaker-config-styles";function Wy(e){return typeof e=="string"?e.trim():""}function ml(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Yy(e,t,n){if(!e||typeof document>"u")return null;const r=Wy(t),s=xt.get(e),o=n||e;if(!r)return s&&(s.remove(),xt.delete(e)),null;if(s)return s.textContent!==r&&(s.textContent=r),(s.parentNode!==o||s!==o.firstChild)&&ml(o,s),s;const i=document.createElement("style");return i.setAttribute(Gy,"true"),i.textContent=r,ml(o,i),xt.set(e,i),i}function qy(e){if(!e)return;const t=xt.get(e);t&&(t.remove(),xt.delete(e))}var Bw=!1;function gl(){return!1}var jw=28,Ky=`
2154
2154
  .blocks-app-initial-spinner-wrapper {
2155
2155
  width: 100%;
2156
2156
  height: 100%;
@@ -2179,11 +2179,11 @@ __emailmaker__.define("emailmaker.js",["require","exports","module","static/umd/
2179
2179
  100% {
2180
2180
  transform: rotate(360deg);
2181
2181
  }
2182
- }`;function z_(){return()=>{}}function X_(e,t){if(!bl()||!e||typeof document>"u")return z_();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const o=document.createElement("style");o.setAttribute(t,"true"),o.textContent=K_,document.head?.appendChild(o),e.appendChild(n);let s=!1;return()=>{s||(s=!0,n.remove(),o.remove())}}function J_(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function Q_({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,s){const i=t.get(o);if(i!==void 0)return i;const a=s().catch(c=>{throw n.has(o)||(n.add(o),r(c)),J_(c)||t.delete(o),c});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var uo=Q_();function Sl(){uo.clear()}l.setApiOriginFailoverHook(()=>uo.clear());var yl=new WeakMap;function fo(e){return l.resolveExplicitApiBaseUrl(e)}function Z_(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function eb(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function tb(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}var po=new WeakMap;function ho(e,t){po.set(e,t)}function nb(e){return po.get(e)}function rb(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&po.get(r)||e,s=fo(n);if(!s)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await tb(o);if(o.getAuthToken&&!a)throw eb();a&&i.set("authorization",a);const c=await l.fetchWithApiOriginFailover("/app/v1/app_init",{method:"POST",headers:i,body:new URLSearchParams,credentials:"same-origin"},s,{attemptTimeout:br(o)||void 0});if(!c.ok)throw Z_(c.status,c.statusText);return await c.json()}}function ob(e){return JSON.stringify({baseUrl:fo(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function sb(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function ib(e){return t=>uo.run(ob(t),()=>(te("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>te("appInit:end",{kind:"network"}))))}function ab(e,t){if(ht(e)||!e.appInit&&!fo(e.baseUrl)||!sb(e))return e;const n=e.appInit??rb(e,t);let r=yl.get(n);return r||(r=ib(n),yl.set(n,r)),{...e,appInit:r}}var wl=0;function lb(){return wl}function cb(){wl+=1,Sl()}var Il=new WeakMap,Tl=new WeakMap,db=3e4;function ub(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function fb(e,t){try{const n=l.decodeJwt(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+db}function pb(e){const t=new Map,n=new Map;return async(r,o,s)=>{const i=ub(r,o);if(s)return n.delete(i),t.delete(i),Sl(),e(r,o,s);const a=n.get(i);if(a&&!t.has(i)){if(a.expiresAtMs>Date.now())return a.token;n.delete(i)}let c=t.get(i);return c===void 0&&(te("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,o,s)).then(d=>{const u=String(d||"").trim();return u&&n.set(i,{token:d,expiresAtMs:fb(u,Date.now())}),d}).finally(()=>{te("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,c)),c}}function hb(e){if(ht(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Il.get(t);const r=lb();return(!n||Tl.get(t)!==r)&&(n=pb(t),Il.set(t,n),Tl.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var mb="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function gb(e){const t=new Error(mb,{cause:e});return t.name="EditorStartFailedError",t}var vb={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function Cl(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Al=["handleLoad","handleDestroy"];function Dl(e,t){let n=e;for(const r of Al){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(s,...i)=>o(t,...i)})}return n}function Eb(e){let t,n="pending",r,o,s,i;const a=new Set,c=[],d=new Set;let u,p;const m=new Promise((y,B)=>{u=y,p=B});m.catch(()=>{});const h={},_=y=>t?.[y],S=()=>r??we(),v=(y,B)=>{const U=_(y);if(typeof U!="function")throw Cl(y);return U.apply(t,B)},b=(y,B)=>{try{return Promise.resolve(v(y,B))}catch(U){return Promise.reject(U)}},D=()=>{const y=t?.container?.getInstance?.(l.DISPOSABLE_ID);if(!(n!=="ready"||y?.isDisposed()||typeof _("getConfig")!="function"))try{i=v("getConfig",[])}catch{}},j=()=>n==="dead"?Promise.reject(S()):n==="ready"?Promise.resolve():m,x=()=>{for(const[y,B]of vn)B==="field"&&(h[y]=_(y))},C=y=>{const B=_(y.name);y.dispose||typeof B!="function"||n==="dead"||(y.dispose=B.apply(t,y.args))},I=()=>a.forEach(C),R=()=>{for(const y of a){try{y.dispose?.()}catch{}y.dispose=void 0}},A=()=>{x(),I()},O=()=>{s?.delete(A),s=void 0},L=(y,B)=>{const[U,...W]=B;return!Al.includes(y)||typeof U!="function"?B:[(ie,...re)=>U(h,...re),...W]},w=(y,B)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof _(y)!="function")throw Cl(y);const U={name:y,args:L(y,B)};return a.add(U),C(U),()=>{a.delete(U),U.dispose?.(),U.dispose=void 0}},P=()=>t?.container?.getInstance(l.OPTIONS_SOURCE_ID)?.get()?.content,k=()=>{const y=e.element();return y!==void 0&&typeof y!="string"?y:void 0},F=(y,B)=>{switch(B){case"event":return(...U)=>w(y,U);case"async":return(...U)=>(y==="show"&&U[0]!==void 0&&e.shown?.(U[0]),n!=="dead"&&typeof _(y)=="function"?b(y,U):j().then(()=>v(y,U)));case"queued":return(...U)=>{if(n==="dead"){if(y==="notify")return;throw S()}if(n==="pending"){c.push({name:y,args:U});return}return v(y,U)};case"sync":return(...U)=>{if(n==="dead"){if(y==="getConfig")return i;throw S()}if(typeof _(y)!="function")throw new Error(`[emailmaker] \`${y}\` is not available before the editor is ready: ${vb[y]??"await `ready` first"}`);const W=v(y,U);return y==="getConfig"&&(i=W),W};case"element":return()=>{if(typeof _(y)!="function")return k();try{return v(y,[])}catch{return k()}};case"codeErrors":return()=>n==="ready"&&typeof _(y)=="function"?v(y,[]):[];case"field":return}};for(const[y,B]of vn)h[y]=F(y,B);h.reset=y=>(y?.content!==void 0&&e.shown?.(y.content),j().then(async()=>{const B=y?.content!==void 0&&l.deepEqual(y.content,P());await v("reset",[Dl(y,E)]),B&&await v("show",[y.content])}).then(()=>h)),h.destroy=()=>{if(n==="dead")return;const y=l.createAbortError("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),d.forEach(B=>B(y)),D(),e.destroy()},Object.defineProperty(h,"ready",{get:()=>o,enumerable:!0,configurable:!0});const E=h;return{object:E,get state(){return n},get editor(){return t},bind:y=>{n==="dead"||t===y||(R(),O(),t=y,x(),I(),n==="pending"&&(s=y.container.getOrCreateInstance(l.LATE_SURFACE_LISTENERS_ID,()=>new Set),s.add(A)))},settle:()=>{if(n==="pending"){n="ready",O(),x(),I();for(const y of c.splice(0))try{v(y.name,y.args)}catch(B){queueMicrotask(()=>{throw B})}u()}},kill:(y,B)=>{n!=="dead"&&(D(),n="dead",r=y,c.length=0,d.forEach(U=>U(y)),O(),B?.keepSubscriptions||(R(),a.clear()),p(y))},detach:()=>{R(),a.clear()},setReady:y=>{o=y},trackCall:y=>(d.add(y),()=>d.delete(y)),hasCalls:()=>d.size>0}}var mo="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function _b(){return l.createAbortError(mo)}function Pl(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===mo}function bb(e,t,n){if(typeof document>"u")return;let r=!1,o;const s=()=>{r=!0,o?.disconnect(),o=void 0},i=()=>{r||(s(),t())};if(n.addDispose(s),!e.isConnected){queueMicrotask(i);return}o=new MutationObserver(()=>{e.isConnected||i()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function Sb(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const s=new AbortController;return bb(n,()=>{n.id,s.abort(_b())},o),l.composeAbortSignals(r,s.signal)}var go="Superseded by newer init() on the same mount element";function Ol(){return l.createAbortError(go)}function Rl(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===go}var Dt=new Map,kl=new WeakMap,bn=new WeakMap;function yb(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function wb(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=yb(e);(n?Dt.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(Ol())});const r=kl.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(Ol())});const o=bn.get(e)??Promise.resolve();let s;const i=new Promise(u=>{s=u}),a=o.then(()=>i);bn.set(e,a),a.then(()=>{bn.get(e)===a&&bn.delete(e)});const c=new AbortController,d={element:e,controller:c,supersedable:t};if(r.add(d),kl.set(e,r),n){const u=Dt.get(n)??new Set;u.add(d),Dt.set(n,u)}return{signal:c.signal,previous:o,release:()=>{s(),r.delete(d);const u=n?Dt.get(n):void 0;n&&u?.delete(d)&&u.size===0&&Dt.delete(n)}}}var Pt=new WeakMap;function vo(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function Eo(e){return Object.entries(e).filter(([t,n])=>vo(t,n)).map(([t])=>t).sort()}function Nl(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!vo(n,r)&&(t[n]=r);return t}function _o(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Pt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Pt.set(e,r));const{current:o,trampolines:s}=r;o.clear();const i={...t};for(const a of Eo(t)){o.set(a,t[a]);let c=s.get(a);c||(c=(...d)=>o.get(a)?.(...d),s.set(a,c)),i[a]=c}return r.lastOptions=t,i}function Ll(e,t){const n=e?Pt.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];vo(r,o)?n.current.set(r,o):n.current.delete(r)}}function Ib(e){const t=e?Pt.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,s)=>t.current.set(s,o)),t.lastOptions=r}}function Tb(e,t,n){const r=e?Pt.get(e):void 0;if(!r||!n)return!1;const o=Eo(t),s=l.deepEqual(o,Eo(r.lastOptions)),i=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!s||!i||!l.deepEqual(Nl(t),Nl(r.lastOptions))?!1:(_o(e,t),!0)}var _e=new WeakMap,NS=0;function Sn(e){let t=_e.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},_e.set(e,t)),t}var Ce=e=>e!==void 0&&e.state!=="dead";function Cb(e){const t=_e.get(e)?.shared;return Ce(t)?t:void 0}function Ab(e,t){Sn(e).shared=t}function Db(e,t){!(Ce(e.shared)&&[...e.counted].some(Ce))||e.warned||!t.devTools||(e.warned=!0)}function Pb(e,t,n,r){const o=Sn(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(s=>s.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(s=>s!==t&&Ce(s)),t],Db(o,r),o.latestCall}function Ob(e,t){return _e.get(e)?.latestCall===t}function Rb(e){const t=_e.get(e);if(t)return t.order=t.order.filter(Ce),t.order.at(-1)?.object}function Ot(e,t){const n=_e.get(e);return n?Ce(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&Ce(r)):!1}function kb(e,t){const n=_e.get(e),r=n?.order.filter(o=>o!==t&&Ce(o)).at(-1);return r?n?.options.get(r):void 0}function Ml(e,t){Sn(e).content={value:t}}function Nb(e){return _e.get(e)?.content}function Lb(e,t,n,r){const o=Sn(e);if(o.counted.delete(t),o.options.delete(t),Ot(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),xl(e,r)}function xl(e,t){const n=_e.get(e);!n||Ot(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Ot(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function Mb(e,t){const n=_e.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);_e.delete(e)}}var xb=Tn.__exportAll({FileManagerApiError:()=>Fb,IntegratorSaveTimeoutError:()=>Nt,SaveRefusedError:()=>De}),Fb=class Ul extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,o){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=o,Error.captureStackTrace&&Error.captureStackTrace(this,Ul)}},Bb=Tn.__exportAll({mapHttpStatusToErrorCode:()=>l.mapHttpStatusToErrorCode});function jb(e,t){return{...e,element:t}}function bo(){return()=>{}}function Ub(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?bo():(Y_(t,e.config?.styles,t),()=>{q_(t)})}function $b(e){if(!bl()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:bo()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:bo()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=X_(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function Hb(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function yn(e){try{e.destroy()}catch{}}function wn(e,...t){const n=l.ELEMENT_MAP.get(e);t.some(r=>r!==void 0&&r===n)&&l.ELEMENT_MAP.delete(e)}var Vb="1.3.3";async function Gb(e){nr(),await _E(typeof __emailmaker__<"u"?__emailmaker__:void 0)}async function Wb(e){return Fl(e).ready}function Yb(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function qb(e){const t=l.ELEMENT_MAP.get(e);return t&&!(t instanceof Promise)?t:void 0}function In(e,t,n){const r=t??qb(e);r&&(wn(e,r),yn(r)),Mb(e,n)}function Kb(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const i=t.editor;zb(i),t.kill(we());return}if(n==="single"){In(o,t.editor,we());return}const s=kb(o,t);Lb(o,t,we(),()=>In(o,t.editor,we())),s&&Ot(o)&&Ll(o,s)}function zb(e){e&&yn(e)}function Fl(e){te(ce.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=l.composeAbortSignals(e.signal,n.signal),o=t==="single"?Yb(e.element):void 0,s=o?Cb(o):void 0;let i;if(s)i={control:s,mode:t,ref:{host:o}};else{const u={},p=Eb({element:()=>u.host??e.element,destroy:()=>Kb(i),shown:m=>{u.host&&Ml(u.host,m)}});i={control:p,mode:t,ref:u},o&&Ab(o,p)}const{control:a}=i,c=a.trackCall(u=>n.abort(u)),d=tS(Dl({...e,signal:r},a.object),i).then(()=>(c(),te(ce.initEnd),a.settle(),a.object),u=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const p=i.ref.host;throw p&&xl(p,()=>In(p,void 0,we())),u});return a.setReady(d),a.object}function Xb(e){const t=typeof e=="string"?document.querySelector(e):e;return t?Rb(t):void 0}function Jb(e){let t,n,r=!1;try{t=e.container.getInstance(l.OPTIONS_SOURCE_ID)?.get(),n=e.container.getInstance(l.INIT_PIPELINE_ID)?.externalSignal;const o=Ve(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:Qb(e),dirty:r}}async function Qb(e){try{return await e.getEmailSnapshot()}catch{return}}function Zb(e){const t=Ve(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function Bl(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Ot(e,n)}async function eS(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),Rl(o)||Pl(o))return;const s=()=>In(t,e,gb(o)),{options:i}=n;if(!i||!Bl(t,r)){s();return}const a=await n.email,c=a&&(i.content!==void 0||a.id!==void 0)?a:void 0,d=typeof i.content=="object"&&"email"in i.content?i.content:void 0;try{await e.reset({...i,signal:i.signal??n.signal,content:c?{...d,email:c}:i.content}),n.dirty&&c&&Zb(e),Bl(t,r)?l.ELEMENT_MAP.set(t,e):s()}catch{s()}}async function tS(e,t){l.throwIfAborted(e.signal);const n=new l.Disposable;let r,o,s,i,a=0;try{const c=await l.waitForElement(e.element,n,e.signal);c&&(i=c,t.ref.host=c,a=Pb(c,t.control,t.mode,e));const d=Sb({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),u=wb(c,{supersede:t.mode==="single"});r=u.release;const p=l.composeAbortSignals(d,u.signal);l.throwIfAborted(p),s=Ib(c),Ll(c,e),await l.raceWithAbortSignal(u.previous,p),o=nS(e,c,t,p,s);const m=await l.raceWithAbortSignal(o,p);return c&&e.content!==void 0&&Ml(c,e.content),m}catch(c){throw i&&s&&Ob(i,a)&&s(),c}finally{const c=r;o!==void 0&&c?o.then(c,c):c?.(),n.dispose()}}async function jl(e,t,n,r){const o=Nb(t);n===void 0||r||!o||l.deepEqual(n,o.value)||await e.show(n)}async function nS(e,t,n,r,o){const{control:s}=n,i=S=>s.bind(S);l.throwIfAborted(r);let a;const c=S=>{cb();const v=hb(jb(S,t)),b=ab(v,()=>a);return{preparedOptions:b,preparedOptionsWithSignal:r!=null?{...b,signal:r}:b}};let d;if(t){const S=l.ELEMENT_MAP.get(t);if(S){let v;try{v=await S,l.throwIfAborted(r)}catch{l.throwIfAborted(r),wn(t,S),v=void 0}if(v)if(v.getElement()===t){const b=U_(t);a=b;const D=v.container.getInstance(l.OPTIONS_SOURCE_ID)?.get();if(Tb(t,e,D))return i(v),r&&v.container.getInstance(l.INIT_PIPELINE_ID)?.relinkExternalSignal(r),l.ELEMENT_MAP.set(t,v),await jl(v,t,e.content,!1),v;const j=!l.deepEqual(e.content,D?.content);d=c(_o(t,e));const{preparedOptions:x,preparedOptionsWithSignal:C}=d,I=b&&nb(b),R=Jb(v);try{b&&ho(b,x),i(v);const A=await v.reset(Hb(e,C));return l.throwIfAborted(r),l.ELEMENT_MAP.set(t,v),await jl(v,t,e.content,j),A}catch(A){if(b&&I&&ho(b,I),!uc(A))throw o(),await eS(v,t,R,n,A),A;wn(t,S,v),yn(v),l.throwIfAborted(r)}}else wn(t,S,v),yn(v)}}l.throwIfAborted(r),d??=c(_o(t,e,{fresh:!0}));const{preparedOptions:u}=d,p=Ub(u),m=$b(u),h=r!=null?{...m.options,signal:r}:m.options;let _;try{a=V_(h),$_(t,a),ho(a,u),Gr(a).set(h),await Xr(),te(ce.coreReady),l.throwIfAborted(r),l.throwIfAborted(r),_=j_(h,a,{onInstance:i}),t&&l.ELEMENT_MAP.set(t,_);const S=await _;if(r?.aborted&&(S.destroy(),l.throwIfAborted(r)),t)if(l.ELEMENT_MAP.get(t)===_)l.ELEMENT_MAP.set(t,S);else throw S.destroy(),l.throwIfAborted(r),l.createAbortError(r?.reason);return S}catch(S){throw p(),m.cleanup(),a&&(El(a),H_(t,a)),t&&_&&l.ELEMENT_MAP.get(t)===_&&l.ELEMENT_MAP.delete(t),S}}async function rS(e){return(await It()).parseAMP(e)}typeof window<"u"&&(rt()&&cc(),SE(typeof __emailmaker__<"u"?__emailmaker__:void 0)),he.ELEMENT_DETACHED_ABORT_MESSAGE=mo,he.SUPERSEDED_INIT_ABORT_MESSAGE=go,he.create=Fl,Object.defineProperty(he,"errors",{enumerable:!0,get:function(){return xb}}),he.getInstance=Xb,Object.defineProperty(he,"helpers",{enumerable:!0,get:function(){return Bb}}),he.init=Wb,he.isElementDetachedError=Pl,he.isSupersededInitError=Rl,he.parseAMP=rS,he.pluginRegistry=rl,he.preload=Gb,he.version=Vb});
2182
+ }`;function zy(){return()=>{}}function Xy(e,t){if(!gl()||!e||typeof document>"u")return zy();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const s=document.createElement("style");s.setAttribute(t,"true"),s.textContent=Ky,document.head?.appendChild(s),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),s.remove())}}function Jy(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function Qy({report:e}={}){const t=new Map,n=new Set,r=e??(s=>{});return{run(s,o){const i=t.get(s);if(i!==void 0)return i;const a=o().catch(l=>{throw n.has(s)||(n.add(s),r(l)),Jy(l)||t.delete(s),l});return t.set(s,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var xs=Qy();function vl(){xs.clear()}c.setApiOriginFailoverHook(()=>xs.clear());var El=new WeakMap;function Fs(e){return c.resolveExplicitApiBaseUrl(e)}function Zy(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function eS(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function tS(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}var Bs=new WeakMap;function js(e,t){Bs.set(e,t)}function nS(e){return Bs.get(e)}function rS(e,t){return async({baseUrl:n})=>{const r=t(),s=r&&Bs.get(r)||e,o=Fs(n);if(!o)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await tS(s);if(s.getAuthToken&&!a)throw eS();a&&i.set("authorization",a);const l=await c.fetchWithApiOriginFailover("/app/v1/app_init",{method:"POST",headers:i,body:new URLSearchParams,credentials:"same-origin"},o,{attemptTimeout:jr(s)||void 0});if(!l.ok)throw Zy(l.status,l.statusText);return await l.json()}}function sS(e){return JSON.stringify({baseUrl:Fs(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function oS(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function iS(e){return t=>xs.run(sS(t),()=>(te("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>te("appInit:end",{kind:"network"}))))}function aS(e,t){if(yt(e)||!e.appInit&&!Fs(e.baseUrl)||!oS(e))return e;const n=e.appInit??rS(e,t);let r=El.get(n);return r||(r=iS(n),El.set(n,r)),{...e,appInit:r}}var _l=0;function cS(){return _l}function lS(){_l+=1,vl()}var bl=new WeakMap,yl=new WeakMap,dS=3e4;function uS(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function fS(e,t){try{const n=c.decodeJwt(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+dS}function pS(e){const t=new Map,n=new Map;return async(r,s,o)=>{const i=uS(r,s);if(o)return n.delete(i),t.delete(i),vl(),e(r,s,o);const a=n.get(i);if(a&&!t.has(i)){if(a.expiresAtMs>Date.now())return a.token;n.delete(i)}let l=t.get(i);return l===void 0&&(te("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,s,o)).then(d=>{const u=String(d||"").trim();return u&&n.set(i,{token:d,expiresAtMs:fS(u,Date.now())}),d}).finally(()=>{te("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,l)),l}}function hS(e){if(yt(e))return e;const t=e.getAuthToken;if(!t)return e;let n=bl.get(t);const r=cS();return(!n||yl.get(t)!==r)&&(n=pS(t),bl.set(t,n),yl.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(s=>{}),{...e,getAuthToken:n}}var mS="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function gS(e){const t=new Error(mS,{cause:e});return t.name="EditorStartFailedError",t}var vS={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function Sl(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var wl=["handleLoad","handleDestroy"];function Il(e,t){let n=e;for(const r of wl){const s=e?.[r];typeof s=="function"&&(n={...n,[r]:(o,...i)=>s(t,...i)})}return n}function ES(e){let t,n="pending",r,s,o,i;const a=new Set,l=[],d=new Set;let u,p;const h=new Promise((w,B)=>{u=w,p=B});h.catch(()=>{});const m={},_=w=>t?.[w],y=()=>r??Ae(),v=(w,B)=>{const U=_(w);if(typeof U!="function")throw Sl(w);return U.apply(t,B)},b=(w,B)=>{try{return Promise.resolve(v(w,B))}catch(U){return Promise.reject(U)}},O=()=>{const w=t?.container?.getInstance?.(c.DISPOSABLE_ID);if(!(n!=="ready"||w?.isDisposed()||typeof _("getConfig")!="function"))try{i=v("getConfig",[])}catch{}},j=()=>n==="dead"?Promise.reject(y()):n==="ready"?Promise.resolve():h,x=()=>{for(const[w,B]of xn)B==="field"&&(m[w]=_(w))},C=w=>{const B=_(w.name);w.dispose||typeof B!="function"||n==="dead"||(w.dispose=B.apply(t,w.args))},I=()=>a.forEach(C),R=()=>{for(const w of a){try{w.dispose?.()}catch{}w.dispose=void 0}},A=()=>{x(),I()},P=()=>{o?.delete(A),o=void 0},L=(w,B)=>{const[U,...W]=B;return!wl.includes(w)||typeof U!="function"?B:[(ae,...re)=>U(m,...re),...W]},S=(w,B)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof _(w)!="function")throw Sl(w);const U={name:w,args:L(w,B)};return a.add(U),C(U),()=>{a.delete(U),U.dispose?.(),U.dispose=void 0}},D=()=>t?.container?.getInstance(c.OPTIONS_SOURCE_ID)?.get()?.content,k=()=>{const w=e.element();return w!==void 0&&typeof w!="string"?w:void 0},F=(w,B)=>{switch(B){case"event":return(...U)=>S(w,U);case"async":return(...U)=>(w==="show"&&U[0]!==void 0&&e.shown?.(U[0]),n!=="dead"&&typeof _(w)=="function"?b(w,U):j().then(()=>v(w,U)));case"queued":return(...U)=>{if(n==="dead"){if(w==="notify")return;throw y()}if(n==="pending"){l.push({name:w,args:U});return}return v(w,U)};case"sync":return(...U)=>{if(n==="dead"){if(w==="getConfig")return i;throw y()}if(typeof _(w)!="function")throw new Error(`[emailmaker] \`${w}\` is not available before the editor is ready: ${vS[w]??"await `ready` first"}`);const W=v(w,U);return w==="getConfig"&&(i=W),W};case"element":return()=>{if(typeof _(w)!="function")return k();try{return v(w,[])}catch{return k()}};case"codeErrors":return()=>n==="ready"&&typeof _(w)=="function"?v(w,[]):[];case"field":return}};for(const[w,B]of xn)m[w]=F(w,B);m.reset=w=>(w?.content!==void 0&&e.shown?.(w.content),j().then(async()=>{const B=w?.content!==void 0&&c.deepEqual(w.content,D());await v("reset",[Il(w,E)]),B&&await v("show",[w.content])}).then(()=>m)),m.destroy=()=>{if(n==="dead")return;const w=c.createAbortError("[emailmaker] editor was destroyed before it was ready");s?.catch(()=>{}),d.forEach(B=>B(w)),O(),e.destroy()},Object.defineProperty(m,"ready",{get:()=>s,enumerable:!0,configurable:!0});const E=m;return{object:E,get state(){return n},get editor(){return t},bind:w=>{n==="dead"||t===w||(R(),P(),t=w,x(),I(),n==="pending"&&(o=w.container.getOrCreateInstance(c.LATE_SURFACE_LISTENERS_ID,()=>new Set),o.add(A)))},settle:()=>{if(n==="pending"){n="ready",P(),x(),I();for(const w of l.splice(0))try{v(w.name,w.args)}catch(B){queueMicrotask(()=>{throw B})}u()}},kill:(w,B)=>{n!=="dead"&&(O(),n="dead",r=w,l.length=0,d.forEach(U=>U(w)),P(),B?.keepSubscriptions||(R(),a.clear()),p(w))},detach:()=>{R(),a.clear()},setReady:w=>{s=w},trackCall:w=>(d.add(w),()=>d.delete(w)),hasCalls:()=>d.size>0}}var Us="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function _S(){return c.createAbortError(Us)}function Tl(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Us}function bS(e,t,n){if(typeof document>"u")return;let r=!1,s;const o=()=>{r=!0,s?.disconnect(),s=void 0},i=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(i);return}s=new MutationObserver(()=>{e.isConnected||i()});let a=e.parentNode;for(;a;)s.observe(a,{childList:!0}),a=a.parentNode}function yS(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:s}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return bS(n,()=>{n.id,o.abort(_S())},s),c.composeAbortSignals(r,o.signal)}var $s="Superseded by newer init() on the same mount element";function Cl(){return c.createAbortError($s)}function Al(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===$s}var Ft=new Map,Ol=new WeakMap,jn=new WeakMap;function SS(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function wS(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=SS(e);(n?Ft.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(Cl())});const r=Ol.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(Cl())});const s=jn.get(e)??Promise.resolve();let o;const i=new Promise(u=>{o=u}),a=s.then(()=>i);jn.set(e,a),a.then(()=>{jn.get(e)===a&&jn.delete(e)});const l=new AbortController,d={element:e,controller:l,supersedable:t};if(r.add(d),Ol.set(e,r),n){const u=Ft.get(n)??new Set;u.add(d),Ft.set(n,u)}return{signal:l.signal,previous:s,release:()=>{o(),r.delete(d);const u=n?Ft.get(n):void 0;n&&u?.delete(d)&&u.size===0&&Ft.delete(n)}}}var Bt=new WeakMap;function Vs(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function Hs(e){return Object.entries(e).filter(([t,n])=>Vs(t,n)).map(([t])=>t).sort()}function Dl(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!Vs(n,r)&&(t[n]=r);return t}function Gs(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Bt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Bt.set(e,r));const{current:s,trampolines:o}=r;s.clear();const i={...t};for(const a of Hs(t)){s.set(a,t[a]);let l=o.get(a);l||(l=(...d)=>s.get(a)?.(...d),o.set(a,l)),i[a]=l}return r.lastOptions=t,i}function Pl(e,t){const n=e?Bt.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const s=t[r];Vs(r,s)?n.current.set(r,s):n.current.delete(r)}}function IS(e){const t=e?Bt.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((s,o)=>t.current.set(o,s)),t.lastOptions=r}}function TS(e,t,n){const r=e?Bt.get(e):void 0;if(!r||!n)return!1;const s=Hs(t),o=c.deepEqual(s,Hs(r.lastOptions)),i=s.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!o||!i||!c.deepEqual(Dl(t),Dl(r.lastOptions))?!1:(Gs(e,t),!0)}var ye=new WeakMap,Uw=0;function Un(e){let t=ye.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},ye.set(e,t)),t}var Re=e=>e!==void 0&&e.state!=="dead";function CS(e){const t=ye.get(e)?.shared;return Re(t)?t:void 0}function AS(e,t){Un(e).shared=t}function OS(e,t){!(Re(e.shared)&&[...e.counted].some(Re))||e.warned||!t.devTools||(e.warned=!0)}function DS(e,t,n,r){const s=Un(e);return s.latestCall+=1,s.releaseTimer!==void 0&&(clearTimeout(s.releaseTimer),s.releaseTimer=void 0),s.leaving.forEach(o=>o.detach()),s.leaving.clear(),n==="single"?s.shared=t:s.counted.add(t),s.options.set(t,r),s.order=[...s.order.filter(o=>o!==t&&Re(o)),t],OS(s,r),s.latestCall}function PS(e,t){return ye.get(e)?.latestCall===t}function RS(e){const t=ye.get(e);if(t)return t.order=t.order.filter(Re),t.order.at(-1)?.object}function jt(e,t){const n=ye.get(e);return n?Re(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&Re(r)):!1}function kS(e,t){const n=ye.get(e),r=n?.order.filter(s=>s!==t&&Re(s)).at(-1);return r?n?.options.get(r):void 0}function Rl(e,t){Un(e).content={value:t}}function NS(e){return ye.get(e)?.content}function LS(e,t,n,r){const s=Un(e);if(s.counted.delete(t),s.options.delete(t),jt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),s.leaving.add(t),kl(e,r)}function kl(e,t){const n=ye.get(e);!n||jt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!jt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function MS(e,t){const n=ye.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);ye.delete(e)}}var xS=Gn.__exportAll({FileManagerApiError:()=>FS,IntegratorSaveTimeoutError:()=>Ht,SaveRefusedError:()=>Oe}),FS=class Bl extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,s){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=s,Error.captureStackTrace&&Error.captureStackTrace(this,Bl)}},BS=Gn.__exportAll({mapHttpStatusToErrorCode:()=>c.mapHttpStatusToErrorCode});function jS(e,t){return{...e,element:t}}function Ws(){return()=>{}}function US(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Ws():(Yy(t,e.config?.styles,t),()=>{qy(t)})}function $S(e){if(!gl()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Ws()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Ws()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=Xy(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function VS(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function $n(e){try{e.destroy()}catch{}}function Vn(e,...t){const n=c.ELEMENT_MAP.get(e);t.some(r=>r!==void 0&&r===n)&&c.ELEMENT_MAP.delete(e)}var HS="1.3.5";async function GS(e){Sr(),await w_(typeof __emailmaker__<"u"?__emailmaker__:void 0)}async function WS(e){return Nl(e).ready}function YS(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function qS(e){const t=c.ELEMENT_MAP.get(e);return t&&!(t instanceof Promise)?t:void 0}function Hn(e,t,n){const r=t??qS(e);r&&(Vn(e,r),$n(r)),MS(e,n)}function KS(e){const{control:t,mode:n,ref:r}=e,s=r.host;if(!s){const i=t.editor;zS(i),t.kill(Ae());return}if(n==="single"){Hn(s,t.editor,Ae());return}const o=kS(s,t);LS(s,t,Ae(),()=>Hn(s,t.editor,Ae())),o&&jt(s)&&Pl(s,o)}function zS(e){e&&$n(e)}function Nl(e){te(de.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=c.composeAbortSignals(e.signal,n.signal),s=t==="single"?YS(e.element):void 0,o=s?CS(s):void 0;let i;if(o)i={control:o,mode:t,ref:{host:s}};else{const u={},p=ES({element:()=>u.host??e.element,destroy:()=>KS(i),shown:h=>{u.host&&Rl(u.host,h)}});i={control:p,mode:t,ref:u},s&&AS(s,p)}const{control:a}=i,l=a.trackCall(u=>n.abort(u)),d=tw(Il({...e,signal:r},a.object),i).then(()=>(l(),te(de.initEnd),a.settle(),a.object),u=>{l(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const p=i.ref.host;throw p&&kl(p,()=>Hn(p,void 0,Ae())),u});return a.setReady(d),a.object}function XS(e){const t=typeof e=="string"?document.querySelector(e):e;return t?RS(t):void 0}function JS(e){let t,n,r=!1;try{t=e.container.getInstance(c.OPTIONS_SOURCE_ID)?.get(),n=e.container.getInstance(c.INIT_PIPELINE_ID)?.externalSignal;const s=Ke(e.container)?.current();r=s!==void 0&&s.get().savedVersion!==null&&s.isDirty()}catch{t=void 0}return{options:t,signal:n,email:QS(e),dirty:r}}async function QS(e){try{return await e.getEmailSnapshot()}catch{return}}function ZS(e){const t=Ke(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function Ll(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||jt(e,n)}async function ew(e,t,n,r,s){if(r.mode==="counted"&&r.control.detach(),Al(s)||Tl(s))return;const o=()=>Hn(t,e,gS(s)),{options:i}=n;if(!i||!Ll(t,r)){o();return}const a=await n.email,l=a&&(i.content!==void 0||a.id!==void 0)?a:void 0,d=typeof i.content=="object"&&"email"in i.content?i.content:void 0;try{await e.reset({...i,signal:i.signal??n.signal,content:l?{...d,email:l}:i.content}),n.dirty&&l&&ZS(e),Ll(t,r)?c.ELEMENT_MAP.set(t,e):o()}catch{o()}}async function tw(e,t){c.throwIfAborted(e.signal);const n=new c.Disposable;let r,s,o,i,a=0;try{const l=await c.waitForElement(e.element,n,e.signal);l&&(i=l,t.ref.host=l,a=DS(l,t.control,t.mode,e));const d=yS({hostElementOption:e.element,resolvedElement:l,externalSignal:e.signal,disposable:n}),u=wS(l,{supersede:t.mode==="single"});r=u.release;const p=c.composeAbortSignals(d,u.signal);c.throwIfAborted(p),o=IS(l),Pl(l,e),await c.raceWithAbortSignal(u.previous,p),s=nw(e,l,t,p,o);const h=await c.raceWithAbortSignal(s,p);return l&&e.content!==void 0&&Rl(l,e.content),h}catch(l){throw i&&o&&PS(i,a)&&o(),l}finally{const l=r;s!==void 0&&l?s.then(l,l):l?.(),n.dispose()}}async function Ml(e,t,n,r){const s=NS(t);n===void 0||r||!s||c.deepEqual(n,s.value)||await e.show(n)}async function nw(e,t,n,r,s){const{control:o}=n,i=y=>o.bind(y);c.throwIfAborted(r);let a;const l=y=>{lS();const v=hS(jS(y,t)),b=aS(v,()=>a);return{preparedOptions:b,preparedOptionsWithSignal:r!=null?{...b,signal:r}:b}};let d;if(t){const y=c.ELEMENT_MAP.get(t);if(y){let v;try{v=await y,c.throwIfAborted(r)}catch{c.throwIfAborted(r),Vn(t,y),v=void 0}if(v)if(v.getElement()===t){const b=Uy(t);a=b;const O=v.container.getInstance(c.OPTIONS_SOURCE_ID)?.get();if(TS(t,e,O))return i(v),r&&v.container.getInstance(c.INIT_PIPELINE_ID)?.relinkExternalSignal(r),c.ELEMENT_MAP.set(t,v),await Ml(v,t,e.content,!1),v;const j=!c.deepEqual(e.content,O?.content);d=l(Gs(t,e));const{preparedOptions:x,preparedOptionsWithSignal:C}=d,I=b&&nS(b),R=JS(v);try{b&&js(b,x),i(v);const A=await v.reset(VS(e,C));return c.throwIfAborted(r),c.ELEMENT_MAP.set(t,v),await Ml(v,t,e.content,j),A}catch(A){if(b&&I&&js(b,I),!ld(A))throw s(),await ew(v,t,R,n,A),A;Vn(t,y,v),$n(v),c.throwIfAborted(r)}}else Vn(t,y,v),$n(v)}}c.throwIfAborted(r),d??=l(Gs(t,e,{fresh:!0}));const{preparedOptions:u}=d,p=US(u),h=$S(u),m=r!=null?{...h.options,signal:r}:h.options;let _;try{a=Hy(m),$y(t,a),js(a,u),ds(a).set(m),await gs(),te(de.coreReady),c.throwIfAborted(r),c.throwIfAborted(r),_=jy(m,a,{onInstance:i}),t&&c.ELEMENT_MAP.set(t,_);const y=await _;if(r?.aborted&&(y.destroy(),c.throwIfAborted(r)),t)if(c.ELEMENT_MAP.get(t)===_)c.ELEMENT_MAP.set(t,y);else throw y.destroy(),c.throwIfAborted(r),c.createAbortError(r?.reason);return y}catch(y){throw p(),h.cleanup(),a&&(hl(a),Vy(t,a)),t&&_&&c.ELEMENT_MAP.get(t)===_&&c.ELEMENT_MAP.delete(t),y}}async function rw(e){return(await Rt()).parseAMP(e)}typeof window<"u"&&(dt()&&ad(),T_(typeof __emailmaker__<"u"?__emailmaker__:void 0)),he.ELEMENT_DETACHED_ABORT_MESSAGE=Us,he.SUPERSEDED_INIT_ABORT_MESSAGE=$s,he.create=Nl,Object.defineProperty(he,"errors",{enumerable:!0,get:function(){return xS}}),he.getInstance=XS,Object.defineProperty(he,"helpers",{enumerable:!0,get:function(){return BS}}),he.init=WS,he.isElementDetachedError=Tl,he.isSupersededInitError=Al,he.parseAMP=rw,he.pluginRegistry=Mc,he.preload=GS,he.version=HS});
2183
2183
 
2184
2184
 
2185
2185
  // Возвращаем API из entry модуля
2186
2186
  return __emailmaker__.syncRequire("emailmaker.js");
2187
2187
  });
2188
2188
 
2189
- __emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/0c2b284d.js":["__delivery__/libs"],"static/core/15ea858c.js":[],"static/core/1708db7c.js":[],"static/core/1922419a.js":[],"static/core/1c5fcd3e.js":[],"static/core/1d705ef4.js":[],"static/core/2f2b6a03.js":["static/core/c16f27f8.js","static/core/a4d994c7.js","__delivery__/libs","static/core/e123b734.js"],"static/core/32a14159.js":[],"static/core/370f04c3.js":[],"static/core/43a8b244.js":[],"static/core/44ad0bec.js":[],"static/core/462ebf44.js":[],"static/core/4797d4f7.js":[],"static/core/5b124cab.js":["static/core/e123b734.js","__delivery__/libs"],"static/core/5c396b20.js":["static/core/64c240c3.js"],"static/core/64c240c3.js":[],"static/core/6933d533.js":[],"static/core/6dfc3524.js":["static/core/9c4c7364.js","static/core/64c240c3.js","static/core/762d0d48.js"],"static/core/7452d34b.js":[],"static/core/762d0d48.js":["static/core/64c240c3.js"],"static/core/76d1e927.js":[],"static/core/76d1f317.js":[],"static/core/7c519fb4.js":["static/core/9c4c7364.js"],"static/core/8608a2b9.js":["static/core/e123b734.js","static/core/c16f27f8.js","static/core/5b124cab.js","static/core/892bb74e.js","__delivery__/libs"],"static/core/892bb74e.js":["static/core/a4d994c7.js","__delivery__/libs"],"static/core/8a5b1c18.js":[],"static/core/8bf56b5b.js":[],"static/core/9c4c7364.js":[],"static/core/9f7f5230.js":["static/core/e6f6edff.js"],"static/core/a30b0fae.js":["static/core/e123b734.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/a4d994c7.js":["static/core/0c2b284d.js","__delivery__/libs"],"static/core/a8cb6e27.js":[],"static/core/aa75c19b.js":["static/core/0c2b284d.js","__delivery__/libs"],"static/core/b0c57adf.js":[],"static/core/b9f59067.js":[],"static/core/c16f27f8.js":["static/core/e123b734.js","__delivery__/libs"],"static/core/cd998f60.js":["static/core/370f04c3.js","__delivery__/libs","monaco"],"static/core/d0b845c8.js":[],"static/core/e123b734.js":["static/core/a8cb6e27.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/e6f6edff.js":[],"static/core/e70683db.js":[],"static/core/ec552634.js":[],"static/monaco/editor.api-DqgksfDR.js":[],"monaco":["static/monaco/editor.api-DqgksfDR.js","static/monaco/lspLanguageFeatures-BnvITcKb.js"],"static/monaco/lspLanguageFeatures-BnvITcKb.js":["static/monaco/editor.api-DqgksfDR.js"],"emailmaker.js":[],"static/umd/17c59c44.js":[],"static/umd/3f12d6ff.js":["static/umd/790cf6cb.js"],"static/umd/790cf6cb.js":[],"static/umd/b3ebeaee.js":[]},"bundles":{"static/core/a4d994c7.js":["static/core/66cfac3d.js","static/core/86f3e5f8.js","static/core/a6f666b3.js"],"static/core/7c519fb4.js":["static/core/a54d9b28.js"],"static/core/a30b0fae.js":["static/core/be880f91.js"],"static/core/892bb74e.js":["static/core/61378c9e.js"],"static/core/2f2b6a03.js":["static/core/2ffe45f5.js"],"core":["static/core/5dc34752.js","static/core/ee980948.js","static/core/dd7229b2.js","static/core/b0a1816d.js","static/core/52afb633.js"]}});
2189
+ __emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/15ea858c.js":[],"static/core/1922419a.js":[],"static/core/19f19adb.js":["static/core/f52ad95a.js","__delivery__/libs"],"static/core/239be344.js":[],"static/core/294defd8.js":[],"static/core/2cee0217.js":[],"static/core/2fbd0ef8.js":[],"static/core/3320a3fd.js":[],"static/core/370f04c3.js":[],"static/core/3a0fc0cb.js":[],"static/core/423efc66.js":["static/core/2fbd0ef8.js"],"static/core/42f18479.js":[],"static/core/43a8b244.js":[],"static/core/4797d4f7.js":[],"static/core/4a259bd9.js":["static/core/a74cc07c.js"],"static/core/4ee64f35.js":["static/core/370f04c3.js","__delivery__/libs","monaco"],"static/core/4fd85bc9.js":["static/core/5150fae0.js","static/core/f52ad95a.js","__delivery__/libs","static/core/d7e61b4c.js"],"static/core/5150fae0.js":["static/core/d7e61b4c.js","__delivery__/libs"],"static/core/5913ff80.js":[],"static/core/64c425bf.js":["static/core/2fbd0ef8.js"],"static/core/65db94be.js":[],"static/core/6933d533.js":[],"static/core/7452d34b.js":[],"static/core/76d1f317.js":[],"static/core/78663aeb.js":["static/core/d7e61b4c.js","__delivery__/libs"],"static/core/89df46ff.js":[],"static/core/8a5b1c18.js":[],"static/core/8bf56b5b.js":[],"static/core/90aedd7b.js":[],"static/core/97ab9fc2.js":["static/core/c2fc9f27.js","__delivery__/libs"],"static/core/99be02b7.js":["static/core/a74cc07c.js","static/core/2fbd0ef8.js","static/core/64c425bf.js"],"static/core/9f7f5230.js":["static/core/e6f6edff.js"],"static/core/a74cc07c.js":[],"static/core/a8cb6e27.js":[],"static/core/c2fc9f27.js":["__delivery__/libs"],"static/core/c8c233fb.js":[],"static/core/d0b845c8.js":[],"static/core/d4b8f1e0.js":["static/core/d7e61b4c.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/d7e61b4c.js":["static/core/a8cb6e27.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/e21f8693.js":["static/core/d7e61b4c.js","static/core/5150fae0.js","static/core/78663aeb.js","static/core/19f19adb.js","__delivery__/libs"],"static/core/e6f6edff.js":[],"static/core/f52ad95a.js":["static/core/c2fc9f27.js","__delivery__/libs"],"static/monaco/editor.api-DqgksfDR.js":[],"monaco":["static/monaco/editor.api-DqgksfDR.js","static/monaco/lspLanguageFeatures-BnvITcKb.js"],"static/monaco/lspLanguageFeatures-BnvITcKb.js":["static/monaco/editor.api-DqgksfDR.js"],"emailmaker.js":[],"static/umd/3f12d6ff.js":["static/umd/790cf6cb.js"],"static/umd/790cf6cb.js":[],"static/umd/b3ebeaee.js":[],"static/umd/de747b3f.js":[]},"bundles":{"static/core/f52ad95a.js":["static/core/6ed13ebc.js","static/core/18a17911.js","static/core/4b1ffe74.js"],"static/core/4a259bd9.js":["static/core/a54d9b28.js"],"static/core/d4b8f1e0.js":["static/core/be880f91.js"],"static/core/19f19adb.js":["static/core/61378c9e.js"],"static/core/4fd85bc9.js":["static/core/c5a27ad0.js"],"core":["static/core/5dc34752.js","static/core/ee980948.js","static/core/c1188df9.js","static/core/4295983b.js","static/core/89840b0e.js"]}});