useblocks 1.1.85-dev.7 → 1.1.85-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/iframe/.vite/manifest.json +4 -4
- package/iframe/js/{discussHandlers.C5qc-xPl.js → discussHandlers.BuuVtU3Y.js} +5 -5
- package/iframe/js/iframe-eblock.body.js +1 -1
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.body.js +2 -2
- package/iframe/js/iframe.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Custom/FormPanel/FormSection/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/ColorPickerInput/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/ControlFontFamily/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/InputSelect/index.js +34 -31
- package/node_modules/useblocks-ui-kit/es/components/Custom/PanelForm/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataDisplay/Card/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataDisplay/Skeleton/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/Cascader/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/Checkbox/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/ColorPicker/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/DatePicker/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/Form/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/Input/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/InputNumber/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/InputOTP/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/Password/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/Radio/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/SearchInput/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/Switch/index.js +2 -2
- package/node_modules/useblocks-ui-kit/es/components/DataEntry/TextArea/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Feedback/Alert/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Feedback/Popconfirm/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Feedback/Spin/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Feedback/Tooltip/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/General/Button/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Layout/Divider/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Layout/Row/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Layout/Space/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Navigation/FloatButton/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Navigation/Segmented/index.js +1 -1
- package/node_modules/useblocks-ui-kit/es/components/Navigation/Tabs/index.js +1 -1
- package/node_modules/useblocks-ui-kit/package.json +1 -1
- package/package.json +2 -2
- package/runtime/react/index.js +1 -1
- package/static/core/{b49f995f.js → 06d19668.js} +3 -3
- package/static/core/{51a46897.js → 13c7b13a.js} +1 -1
- package/static/core/{fdfb1e94.js → 1afe0f9c.js} +1 -1
- package/static/core/{8035d07f.js → 28160edc.js} +1 -1
- package/static/core/{6a939bac.js → 3d7934fb.js} +1 -1
- package/static/core/{53bcd609.js → 3df10afa.js} +8 -8
- package/static/core/{e2699a48.js → 41028939.js} +1 -1
- package/static/core/{7f91ed03.js → 45eb9af1.js} +1 -1
- package/static/core/{60f7aa8d.js → 48a8ba9d.js} +1 -1
- package/static/core/{740a4f32.js → 49a8dc9c.js} +1 -1
- package/static/core/{284b592e.js → 59cfe4a0.js} +1 -1
- package/static/core/{ec4827f1.js → 778aee63.js} +1 -1
- package/static/core/{c28968c1.js → 799f4d8e.js} +1 -1
- package/static/core/{77d63e01.js → 7c047ede.js} +1 -1
- package/static/core/{9ea82ab5.js → 982730aa.js} +1 -1
- package/static/core/{23f020c5.js → a46eae76.js} +1 -1
- package/static/core/{fc390885.js → b165db74.js} +1 -1
- package/static/core/{991b35ff.js → cb42ad65.js} +1 -1
- package/static/core/{7d627bff.js → db82c42b.js} +1 -1
- package/static/core/{1bdeb37f.js → df189a9d.js} +1 -1
- package/static/core/{74c1d64b.js → f1478faf.js} +1 -1
- package/static/core/{6ff64eea.js → f1498d3c.js} +1 -1
- package/static/core/{ea93d0cd.js → f8d889a1.js} +2 -2
- package/static/core/{78b1e678.js → fa60c7fb.js} +1 -1
- package/static/core/{d2bb1c0d.js → ff43365e.js} +1 -1
- package/static/esm/349f9e2c.js +1 -0
- package/static/umd-runtime/runtime.js +1 -1
- package/static/umd-runtime/ui-kit.js +2 -2
- package/{useblocks-core.46f9d75a.js → useblocks-core.ee20cf1c.js} +15 -15
- package/useblocks-esm.js +10 -10
- package/{useblocks-po.46f9d75a.js → useblocks-po.ee20cf1c.js} +1 -1
- package/useblocks.d.ts +9 -2
- package/useblocks.js +12 -12
- package/vite/index.cjs +38 -0
- package/vite/index.js +38 -0
- package/static/esm/ff1698e6.js +0 -1
- /package/iframe/{iframe-eblock.46f9d75a.html → iframe-eblock.ee20cf1c.html} +0 -0
- /package/iframe/{iframe.46f9d75a.html → iframe.ee20cf1c.html} +0 -0
package/vite/index.cjs
CHANGED
|
@@ -830,6 +830,41 @@ function checkHostReactVersion(projectRoot) {
|
|
|
830
830
|
};
|
|
831
831
|
}
|
|
832
832
|
//#endregion
|
|
833
|
+
//#region src/vite/devCors.ts
|
|
834
|
+
/** DEFAULT_ALLOWED_ORIGINS — адреса, которые vite пускает, когда `server.cors` не задан. */
|
|
835
|
+
var DEFAULT_ALLOWED_ORIGINS = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
|
|
836
|
+
function matchesOrigin(origin, allowed) {
|
|
837
|
+
return typeof allowed === "string" ? allowed === origin : allowed.test(origin);
|
|
838
|
+
}
|
|
839
|
+
function headerForOrigin(origin, allowed) {
|
|
840
|
+
if (allowed === false) return;
|
|
841
|
+
if (allowed === true) return origin;
|
|
842
|
+
if (typeof allowed === "string") return allowed;
|
|
843
|
+
if (!origin) return;
|
|
844
|
+
return (Array.isArray(allowed) ? allowed : [allowed]).some((item) => matchesOrigin(origin, item)) ? origin : void 0;
|
|
845
|
+
}
|
|
846
|
+
function resolveAllowedOrigin(origin, cors) {
|
|
847
|
+
if (cors === void 0) return Promise.resolve(DEFAULT_ALLOWED_ORIGINS);
|
|
848
|
+
if (typeof cors === "boolean") return Promise.resolve(cors ? "*" : false);
|
|
849
|
+
const allowed = cors.origin;
|
|
850
|
+
if (allowed === void 0) return Promise.resolve("*");
|
|
851
|
+
if (typeof allowed !== "function") return Promise.resolve(allowed);
|
|
852
|
+
return new Promise((resolve) => {
|
|
853
|
+
allowed(origin, (err, result) => resolve(err ? false : result));
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* applyDevCors ставит `Access-Control-Allow-Origin` по правилам `server.cors` самого vite.
|
|
858
|
+
* Нужна там, где плагин отвечает сам: такой ответ до CORS-слоя vite не доходит.
|
|
859
|
+
*/
|
|
860
|
+
async function applyDevCors(req, res, cors) {
|
|
861
|
+
const origin = req.headers.origin;
|
|
862
|
+
const value = headerForOrigin(origin, await resolveAllowedOrigin(origin, cors));
|
|
863
|
+
if (!value) return;
|
|
864
|
+
res.setHeader("Access-Control-Allow-Origin", value);
|
|
865
|
+
if (value !== "*") res.setHeader("Vary", "Origin");
|
|
866
|
+
}
|
|
867
|
+
//#endregion
|
|
833
868
|
//#region src/shared/reactDuplicateDetector.ts
|
|
834
869
|
/**
|
|
835
870
|
* Детектор дублированных runtime-копий React/antd в Vite-prebundle integrator'а.
|
|
@@ -1163,6 +1198,7 @@ var ViteServePlugin = (options) => {
|
|
|
1163
1198
|
const content = await fs.default.promises.readFile(handledPath);
|
|
1164
1199
|
const filePathParts = filePath.split(".");
|
|
1165
1200
|
const ext = filePathParts.length > 1 ? filePathParts[filePathParts.length - 1] : "";
|
|
1201
|
+
await applyDevCors(req, res, server.config.server.cors);
|
|
1166
1202
|
res.writeHead(200, { "Content-Type": getMimeTypeByExtension(ext) });
|
|
1167
1203
|
res.end(content);
|
|
1168
1204
|
}
|
|
@@ -1179,6 +1215,7 @@ var ViteServePlugin = (options) => {
|
|
|
1179
1215
|
if (depsRuntimeFilePath) {
|
|
1180
1216
|
if (fs.default.existsSync(depsRuntimeFilePath) && fs.default.statSync(depsRuntimeFilePath).isFile()) {
|
|
1181
1217
|
const content = await fs.default.promises.readFile(depsRuntimeFilePath, "utf-8");
|
|
1218
|
+
await applyDevCors(req, res, server.config.server.cors);
|
|
1182
1219
|
res.writeHead(200, { "Content-Type": getMimeTypeByExtension("js") });
|
|
1183
1220
|
res.end(content);
|
|
1184
1221
|
return;
|
|
@@ -1190,6 +1227,7 @@ var ViteServePlugin = (options) => {
|
|
|
1190
1227
|
const content = await fs.default.promises.readFile(optimizedFilePath, "utf-8");
|
|
1191
1228
|
logHostBootstrapInjectedOnce(logger, tracker.state, ENVIRONMENT_VARIABLE);
|
|
1192
1229
|
tracker.state.injectionCount += 1;
|
|
1230
|
+
await applyDevCors(req, res, server.config.server.cors);
|
|
1193
1231
|
res.writeHead(200, { "Content-Type": getMimeTypeByExtension("js") });
|
|
1194
1232
|
res.end(prependBootstrap(content, publicPath, startupPrefetchMode, options.compatGlobals));
|
|
1195
1233
|
return;
|
package/vite/index.js
CHANGED
|
@@ -801,6 +801,41 @@ function checkHostReactVersion(projectRoot) {
|
|
|
801
801
|
};
|
|
802
802
|
}
|
|
803
803
|
//#endregion
|
|
804
|
+
//#region src/vite/devCors.ts
|
|
805
|
+
/** DEFAULT_ALLOWED_ORIGINS — адреса, которые vite пускает, когда `server.cors` не задан. */
|
|
806
|
+
var DEFAULT_ALLOWED_ORIGINS = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
|
|
807
|
+
function matchesOrigin(origin, allowed) {
|
|
808
|
+
return typeof allowed === "string" ? allowed === origin : allowed.test(origin);
|
|
809
|
+
}
|
|
810
|
+
function headerForOrigin(origin, allowed) {
|
|
811
|
+
if (allowed === false) return;
|
|
812
|
+
if (allowed === true) return origin;
|
|
813
|
+
if (typeof allowed === "string") return allowed;
|
|
814
|
+
if (!origin) return;
|
|
815
|
+
return (Array.isArray(allowed) ? allowed : [allowed]).some((item) => matchesOrigin(origin, item)) ? origin : void 0;
|
|
816
|
+
}
|
|
817
|
+
function resolveAllowedOrigin(origin, cors) {
|
|
818
|
+
if (cors === void 0) return Promise.resolve(DEFAULT_ALLOWED_ORIGINS);
|
|
819
|
+
if (typeof cors === "boolean") return Promise.resolve(cors ? "*" : false);
|
|
820
|
+
const allowed = cors.origin;
|
|
821
|
+
if (allowed === void 0) return Promise.resolve("*");
|
|
822
|
+
if (typeof allowed !== "function") return Promise.resolve(allowed);
|
|
823
|
+
return new Promise((resolve) => {
|
|
824
|
+
allowed(origin, (err, result) => resolve(err ? false : result));
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* applyDevCors ставит `Access-Control-Allow-Origin` по правилам `server.cors` самого vite.
|
|
829
|
+
* Нужна там, где плагин отвечает сам: такой ответ до CORS-слоя vite не доходит.
|
|
830
|
+
*/
|
|
831
|
+
async function applyDevCors(req, res, cors) {
|
|
832
|
+
const origin = req.headers.origin;
|
|
833
|
+
const value = headerForOrigin(origin, await resolveAllowedOrigin(origin, cors));
|
|
834
|
+
if (!value) return;
|
|
835
|
+
res.setHeader("Access-Control-Allow-Origin", value);
|
|
836
|
+
if (value !== "*") res.setHeader("Vary", "Origin");
|
|
837
|
+
}
|
|
838
|
+
//#endregion
|
|
804
839
|
//#region src/shared/reactDuplicateDetector.ts
|
|
805
840
|
/**
|
|
806
841
|
* Детектор дублированных runtime-копий React/antd в Vite-prebundle integrator'а.
|
|
@@ -1134,6 +1169,7 @@ var ViteServePlugin = (options) => {
|
|
|
1134
1169
|
const content = await fs.promises.readFile(handledPath);
|
|
1135
1170
|
const filePathParts = filePath.split(".");
|
|
1136
1171
|
const ext = filePathParts.length > 1 ? filePathParts[filePathParts.length - 1] : "";
|
|
1172
|
+
await applyDevCors(req, res, server.config.server.cors);
|
|
1137
1173
|
res.writeHead(200, { "Content-Type": getMimeTypeByExtension(ext) });
|
|
1138
1174
|
res.end(content);
|
|
1139
1175
|
}
|
|
@@ -1150,6 +1186,7 @@ var ViteServePlugin = (options) => {
|
|
|
1150
1186
|
if (depsRuntimeFilePath) {
|
|
1151
1187
|
if (fs.existsSync(depsRuntimeFilePath) && fs.statSync(depsRuntimeFilePath).isFile()) {
|
|
1152
1188
|
const content = await fs.promises.readFile(depsRuntimeFilePath, "utf-8");
|
|
1189
|
+
await applyDevCors(req, res, server.config.server.cors);
|
|
1153
1190
|
res.writeHead(200, { "Content-Type": getMimeTypeByExtension("js") });
|
|
1154
1191
|
res.end(content);
|
|
1155
1192
|
return;
|
|
@@ -1161,6 +1198,7 @@ var ViteServePlugin = (options) => {
|
|
|
1161
1198
|
const content = await fs.promises.readFile(optimizedFilePath, "utf-8");
|
|
1162
1199
|
logHostBootstrapInjectedOnce(logger, tracker.state, ENVIRONMENT_VARIABLE);
|
|
1163
1200
|
tracker.state.injectionCount += 1;
|
|
1201
|
+
await applyDevCors(req, res, server.config.server.cors);
|
|
1164
1202
|
res.writeHead(200, { "Content-Type": getMimeTypeByExtension("js") });
|
|
1165
1203
|
res.end(prependBootstrap(content, publicPath, startupPrefetchMode, options.compatGlobals));
|
|
1166
1204
|
return;
|
package/static/esm/ff1698e6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var T=class Ae{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof Ae&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const n=this._inner.indexOf(t);n>=0&&this._inner.splice(n,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function k(e){return`service_container_${e}`}var N=new Set,W;function Ke(){if(!W)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,Ie.prototype.getInstanceAsync),e.stack}function U(e){N.delete(e)&&W?.end(e)}var Ie=class G extends T{_parent;_injectCallbacks=[];_injections=Object.create(null);_runCallbacks(t){this._injectCallbacks.forEach(n=>n(t))}constructor(t=null){super(),this._parent=t,t&&this.addDisposable(t.onInject(n=>this._runCallbacks(n)))}onInject=t=>(this._injectCallbacks.push(t),{dispose:()=>{const n=this._injectCallbacks.indexOf(t);n>=0&&this._injectCallbacks.splice(n,1)}});inject(t,n){this._injections[t]=()=>n,this._runCallbacks(t)}injectFactory(t,n,r){const s=this._injections[t];let o=typeof s=="function"?s():s;const i=this._injections[t]=()=>(o=n(this,o),o);r&&i(),this._runCallbacks(t)}_find(t,n=!0){return this._injections[t]||n&&this._parent?._find(t)}_onInject(t,n,r=new T){return r.addDisposable(this.onInject(s=>{t===s&&(r.dispose(),n(this.getInstance(s)))})),this._parent&&r.addDisposable(this._parent._onInject(t,n,r)),this.addDisposable(r),r}getInstance(t,n=!0){const r=this._find(t,n);if(typeof r=="function")return r()}getOrCreateInstance(t,n){const r=this._find(t);if(typeof r=="function")return r();const s=n(this);return this.inject(t,s),s}getInstanceAsync(t){const n=this._find(t);if(typeof n=="function")return Promise.resolve(n());const r=Ke();return new Promise((s,o)=>{const i={id:String(t),startedAt:Date.now(),origin:r,container:this,reject:o};N.add(i),W?.start(i),this._onInject(t,()=>{U(i),s(this.getInstance(t))})})}failPendingWaits(t){for(const n of Array.from(N))n.container===this&&(U(n),n.reject(t))}pendingWaits(){return[...N].filter(t=>t.container===this)}addService(t,n){const r=k(t);this.injectFactory(r,(o,i=[])=>i.indexOf(n)<0?[...i,n]:i);const s=new T;return s.addDispose(()=>{this.injectFactory(r,(o,i=[])=>i.filter(a=>a!==n))}),s}addServiceFactory(t,n,r){const s=k(t);let o;this.injectFactory(s,(a,c=[])=>(o=n(a,o),o===void 0?c:c.indexOf(o)<0?[...c,o]:c),r);const i=new T;return i.addDispose(()=>{this.injectFactory(s,(a,c=[])=>o===void 0?c:c.filter(_=>_!==o))}),i}getServices(t){const n=k(t);return[...this.getInstance(n,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new G(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const n=this._parent?.getOrCreateIsolatedContainer(t);return new G(n)})}remove(t){const n=this._injections;delete n[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(N))t.container===this&&U(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function X(e){return e.startsWith("__")?e:`__${e}__`}function ze(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=X(e),n=globalThis;return n[t]??={}}function Je(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function Ye(e){if(e)return X(e);const t="useblocks".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return X(t)}function Oe(e){const t=Ye(e),n=ze(t);if(Je(n.container))return n.container;const r=new Ie(null);return n.container=r,r}function Tn(e){return Oe(e)}function Qe(){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(n){let r=Math.random()*16;return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),(n==="x"?r:r&3|8).toString(16)})}function Ze(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Qe()}function d(e=Ze()){return e}function ge(){return"esm".trim()||"unknown"}function et(e){if(typeof globalThis>"u")return;const t=ge(),n=globalThis[e]??{};globalThis[e]=n;const r=n.__diagnostics??={},s=r.diModuleEval??={evalCount:0,records:[]};s.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),s.evalCount+=1}function tt(){const e="useblocks".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function nt(e,t){if(et(t),typeof globalThis>"u")return e;const n=ge(),r=globalThis,s=r[t]=r[t]||{},o=s.__diagnostics=s.__diagnostics||{},i=o.dependencyResolver=o.dependencyResolver||{entries:[]},a={container:e,source:"packages/runtime-core/di/index.ts",buildSource:n,timestamp:Date.now(),stack:new Error().stack};return i.entries.push(a),e}var w;function rt(){if(w)return w;const e=tt();return w=nt(Oe(e),e),w}var te=new Proxy({},{get(e,t,n){const r=rt(),s=Reflect.get(r,t,n);return typeof s=="function"?s.bind(r):s}});function mn(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 v(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 Te(e){if(e?.aborted)throw v(e.reason)}function Sn(e,t){return t?(t.aborted&&e.catch(()=>{}),Te(t),new Promise((n,r)=>{const s=()=>{o(),r(v(t.reason))},o=()=>{t.removeEventListener("abort",s)};t.addEventListener("abort",s),e.then(i=>{o(),n(i)},i=>{o(),r(i)})})):e}var me=class extends T{_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,n){if(this.isDisposed())return{dispose:()=>{}};const r=this._listeners,s=this._options;n&&typeof e=="function"&&(e=e.bind(n));const o=r.findIndex(([,a])=>a<t),i=[e,t];return r.splice(o>=0?o:r.length,0,i),r.length===1&&s.onFirstListenerAdd&&s.onFirstListenerAdd(),{dispose:()=>{const a=r.indexOf(i);a>=0&&(r.splice(a,1),!r.length&&s.onLastListenerRemove&&s.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,n)=>{const r=this._addListener((...s)=>(r?.dispose(),n?e.call(n,...s):e(...s)),t);return r};un=e=>{const t=this._listeners.findIndex(([n])=>n===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()}},P=class extends me{execute(e,t){for(const n of t)try{n(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},Dn=class extends P{execute([e],t){for(const n of t)try{n(e)}catch{}}},Nn=class extends P{_suspendCounter=0;_wasFired=!1;execute([e],t){if(this._suspendCounter)this._wasFired=!0;else for(const n of t)try{n(e)}catch{}}suspend(){this._suspendCounter++}resume(){--this._suspendCounter===0&&this._wasFired&&(this.fire(),this._wasFired=!1)}},q=class extends P{async execute([e],t){const n=[];for(const r of t)try{n.push(await r(e))}catch{}return n}async fireSettled(e){const t={results:[],errors:[]};if(this.isDisposed())return t;for(const n of this.getListeners([e]))try{t.results.push(await n(e))}catch(r){t.errors.push(r)}return t}};function yn(e,t=0){const n=new me,r=e(n,t);return r&&n.addDisposable(r),n.event}function Cn(e,t,n=0){const r=new P,s=e((...o)=>{if(t(...o))return r.fire(...o)},n);return s&&r.addDisposable(s),r.event}function vn(e,t=0,n=0){const r=new P;let s,o;const i=e((...a)=>{o=a,s||(s=setTimeout(()=>{o&&r.fire(...o),s=void 0},t))},n);return i&&r.addDisposable(i),r.event}function Pn(e,t){return e.getOrCreateInstance(t,()=>new q)}function l(e){return d(e)}var ne;(function(e){e.BEFORE_SAVE_EMAIL=l("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=l("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=l("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=l("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=l("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=l("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=l("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=l("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=l("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=l("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=l("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=l("events.ON_EMAIL_CHANGED_ID"),e.ON_HEADER_APPLIED_ID=l("events.ON_HEADER_APPLIED_ID"),e.ON_BLOCK_CHANGED_ID=l("events.ON_BLOCK_CHANGED_ID"),e.ON_CHUNKS_LOADED=l("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=l("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=l("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=l("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=l("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=l("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=l("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_NOTIFICATION=l("events.ON_NOTIFICATION"),e.READ_LOCALE=l("events.READ_LOCALE"),e.ON_TRANSLATE_ID=l("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=l("events.ON_CODE_VALIDATE_ID"),e.UPLOAD_EVENT_ID=l("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=l("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=l("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=l("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=l("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=l("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=l("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=l("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=l("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=l("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=l("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=l("events.AI_TEXT_STREAM_ID")})(ne||(ne={}));function bn(e,t){return e.getOrCreateInstance(t,()=>new q).event}function Ln(e,t){return e.getOrCreateInstance(t,()=>new q)}var Rn=d("plugin.app"),xn=d("plugin.disposable"),wn=d("InitPipelineContext"),Mn=d("plugin.instance"),Bn=d("plugin.lateSurfaceListeners"),st=d("plugin.optionsSource"),Fn=d("plugin.store"),ot=d("ConfigSource"),kn=d("plugin.standalone.project"),it=d("plugin.standalone.bootstrapToken"),Un=d("plugin.element"),at=d("plugin.securityModule"),jn=d("plugin.standalone.activated"),Gn=d("plugin.standalone.fileProxyRegistered"),H=d("plugin.jwt.token"),y=d("plugin.jwt.error"),Xn=d("PluginCollection"),Hn=l("APP_LOAD_EVENT"),$n=l("CONFIG_CHANGED_EVENT"),Vn=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),ct=class{baseUrl="https://api.emailmaker.ru/wp-json";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};async request({body:e,secure:t,path:n,type:r,query:s,format:o,baseUrl:i,cancelToken:a,extraQuery:c,proxyHandler:_,...u}){const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},E=this.mergeRequestParams(u,f);c&&(s=s?{...s,...c}:c);const p=s&&this.toQueryString(s),I=this.contentFormatters[r||"application/json"],h=o||E.format,R=`${i||this.baseUrl||""}${n}${p?`?${p}`:""}`,We=_?_(R,{body:e,secure:t,path:n,type:r,query:s,format:o,baseUrl:i,cancelToken:a,extraQuery:c,proxyHandler:_,...u}):R,Z=new Request(We,{...E,headers:{...E.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):E.signal)||null,body:typeof e>"u"||e===null?null:I(e)});return this.customFetch(Z).then(async ee=>{const O=ee;O.data=null,O.error=null,O.meta={request:Z,response:O};const qe=h?await ee[h]().then(x=>(O.ok?O.data=x:O.error={data:x},O)).catch(x=>(O.error=x,O)):O;return a&&this.abortControllers.delete(a),qe})}},_t=d("prewarm.networkActivity");function ut(){let e=0;const t=new Set,n=()=>{t.forEach(r=>r())};return{begin(){e+=1,n();let r=!1;return()=>{r||(r=!0,e-=1,n())}},inFlight:()=>e,watch(r){return t.add(r),()=>t.delete(r)}}}function lt(e){return e.getOrCreateInstance(_t,()=>ut())}var dt=Symbol("rest.publicRequest"),K=d("rest.requestHandler"),ft=d("rest.responseHandler"),Se=d("rest.customFetch"),De=d("rest_transport"),pt=e=>{e.inject(Se,{execute:async(t,n={})=>{const r=e.getServices(K),s={public:n[dt]===!0},o=lt(e).begin();try{let i=t instanceof Request?t:new Request(t,n);for(const _ of r){const u=await _.execute(i,s);u instanceof Request&&(i=u)}let a=await fetch(i);const c=e.getServices(ft);for(const _ of c)a=await _.execute(a);return a}finally{o()}}})};function Wn(e,t){const n=e.getInstance(De);if(!n)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(r=>new r(n)))}function Et(e,t=window){return{peer:e,send(n){e.postMessage(n,"*")},subscribe(n){const r=s=>{n({data:s.data,source:s.source,ports:s.ports})};return t.addEventListener("message",r),{dispose:()=>t.removeEventListener("message",r)}},close(){}}}function ht(e){let t=!1;return{peer:e,send(n){e.postMessage(n)},subscribe(n){const r=s=>{n({data:s.data,source:e})};return e.addEventListener("message",r),t||(t=!0,e.start()),{dispose:()=>e.removeEventListener("message",r)}},close(){e.close()}}}function qn(e){return e}function At(e){return e&&typeof e=="object"}function re(e,t){return e&&typeof e=="object"&&e.operationId===t}var g="INIT_MESSAGE",It="em:port-ready",Ot="em:window-drained",j="";function se(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var gt=class extends T{_listeners=Object.create(null);addListenerAsync=(e,t,n=0,r)=>{const s=this._listeners[e]||(this._listeners[e]=[]);r&&typeof t=="function"&&(t=t.bind(r));const o=s.findIndex(([a,c])=>n<=c),i=[t,n];return this.isDisposed()||s.splice(o>=0?o:s.length,0,i),{dispose(){const a=s.indexOf(i);a>=0&&s.splice(a,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const n=this._listeners[e]||(this._listeners[e]=[]);let r;for(let s=0;s<n.length;s++){const o=n[s][0],i=r;r=a=>o(a,i)}if(r)return r(t)}};addListener=(e,t,n=0)=>this.addListenerAsync(e,(r,s)=>{try{t(r)}catch{}return s&&s(r)},n)},Kn=class extends T{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_inited=!1;_emitter=this.addDisposable(new gt);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;constructor(e,t){super(),this._singleton=t,this._transport=Et({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(g,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(g))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,n=t.data,r=t.source,s=n?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&r&&n?.operationId==="em:window-drained"){this._drained.add(r);return}if(!(o&&r&&this._drained.has(r))){if(r&&r!==this._target&&this._greeted.has(r)&&re(n,g)){this._greeted.delete(r),this._handshaken.add(r),this._postMessage(r,{operationId:g,data:{}}),s&&this.usePort(s,!0,r);return}if(At(n)&&(t.source===this.target||this._isCurrentPort(t.source))||this._singleton&&re(n,g)){if(s){const _=this._target;Promise.resolve().then(()=>this.usePort(s,!0,_))}const i=this._emitter.fireAsync(n.operationId||j,n.operationId===void 0?t:n.data),a=n.result,c=n.error;a&&c&&Promise.resolve(i).then(_=>this._sendMessage(a,_),_=>this._sendMessage(c,_))}}};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(g,void 0);return}this._inited=!1,this._postMessage(e,{operationId:g,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:g,data:{},port:!0},[t])}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:g,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,n=this._target){if(!n||this._ports.has(n))return;const r=ht(e),s=r.subscribe(this._onTransportMessage);this._ports.set(n,{transport:r,subscription:s}),t&&(r.send({operationId:It,data:{}}),this.drainWindow(n))}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)}hasPort(e){return this._ports.has(e)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:Ot,data:{}},"*")}isWindowDrained(e){return this._drained.has(e)}_isPortSource(e){for(const t of this._ports.values())if(t.transport.peer===e)return!0;return!1}_isCurrentPort(e){return this._target!==void 0&&this._ports.get(this._target)?.transport.peer===e}getTarget(){return this._target}get target(){return this._target}_postMessage(e,t,n){let r=t;this._outgoingFilter&&!n?.length&&(r="data"in t?{...t,data:this._outgoingFilter(t.data)}:this._outgoingFilter(t));try{const s=this._ports.get(e);if(s){s.transport.send(r);return}if(n?.length){e.postMessage(r,"*",n);return}e.postMessage(r,"*")}catch(s){if(s?.name==="DataCloneError"){const o=typeof r?.data=="object"&&r?.data!==null?r.data:void 0}throw s}}_sendMessage(e,t,n=!0){if(!n&&!this.isInited())return;const r=this.addDisposable(this.onInit(s=>{const o=e?{operationId:e,data:t}:t;try{this._postMessage(s,{...o})}finally{r.dispose()}}))}send(e,t,n){return typeof e=="string"?this._sendMessage(e,t,n):this._sendMessage(j,e,t)}sendAsync(e,t,n=!0){if(!n&&!this.isInited())return Promise.resolve();const r=se(),s=se();return new Promise((o,i)=>{const a=this.addDisposable(new T);a.addDisposable(this.onInit(c=>{try{this._postMessage(c,{operationId:e,data:t,result:r,error:s})}catch(_){a.dispose(),i(_);return}a.addDisposable(this._onMessage(r,_=>{o(_),a.dispose()})),a.addDisposable(this._onMessage(s,_=>{i(_),a.dispose()}))}))})}_onMessage(e,t,n=0){return this._emitter.addListener(e,t,n)}addListener(e,t,n){return t?this._onMessage(e,t,n):this._onMessage(j,e)}addListenerAsyncPipe(e,t,n=0){return this._emitter.addListenerAsync(e,t,n)}addListenerAsync(e,t,n=0){return this._emitter.addListenerAsync(e,async(r,s)=>{const o=await t(r);return s?s(r):o},n)}isInited(){return this._inited}get inited(){return this._inited}onInit(e,t=!0,n=0){const r=this.addDisposable(new T);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?r.addDisposable(this.onInit(e,t,n)):e(this._target)}):r.addDisposable(this._onMessage(g,()=>{e(this._target)},n)),r}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function b(e){return d(e)}var zn=d("extensions.atomsHandlers"),Jn=b("HANDLE_ATOM_INSERT"),Yn=d("extensions.sandboxExtensions"),Qn="SANDBOX_EXTENSION_SCRIPT_STATUS",Zn=d("MESSAGE_SERVICE"),er=b("SETTINGS_PANEL_EVENT"),tr="advanced",nr=b("MODAL_SHOW_EVENT"),rr=b("MODAL_CLOSE_EVENT"),sr=b("MODAL_UPDATE_EVENT"),or=d("client"),ir=d("v2_client"),ar=d("ai_client"),cr=d("app.cookieManager"),_r=d("app.storageProvider"),ur=d("image-blob-resolver"),lr=d("template-directives"),Tt="INJECTION";function mt(e){return e.getState}function dr(e){if(!mt(e)){e.dispose();return}const t=e.getState()[Tt];t&&(te.getInstance(t)?.dispose(),te.remove(t))}function St(e){return Object.assign({},...e)}var Ne=["generic","stockImages","emFiles","cdn"];function z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function oe(e){return!z(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Ne.includes(t))}function ye(e){return e.length===0?[]:e.length===1?e[0]:e}function Ce(e){let t=!1,n=[];for(const r of e)if(r!==void 0){if(t=!0,Array.isArray(r)){n=[...r,...n];continue}n=[r,...n]}if(t)return ye(n)}function Dt(e){return z(e)&&("value"in e||"replace"in e)}function ie(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function Nt(e){let t=!1,n=[],r=!1;for(const o of e)if(o!==void 0){if(Dt(o)){t=!0,o.replace&&(n=[],r=!0),o.value!==void 0&&(n=ie(n,o.value),r=!0);continue}n=ie(n,o),r=!0}const s=r?ye(n):void 0;if(!t)return s;if(s!==void 0)return{value:s}}function fr(e){const t=e.filter(r=>r!==void 0);if(t.length===0)return;if(!t.some(r=>oe(r)))return Ce(t);const n={};for(const r of Ne){const s=Nt(e.map(o=>{if(o!==void 0)return oe(o)?o[r]:r==="generic"?o:void 0}));s!==void 0&&(n[r]=s)}return Object.keys(n).length>0?n:void 0}function pr(e){return Ce(e)}function yt(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 Ct(e,t){const n=[...e],r=new Set(n.map(s=>s.toLowerCase()));for(const s of t){const o=s.trim().replace(/:\d+$/,"");if(!o)continue;const i=o.toLowerCase();r.has(i)||(r.add(i),n.push(o))}return n}function vt(e){let t=[],n=!1;for(const r of e){const s=yt(r);s&&(n=!0,s.replace&&(t=[]),t=Ct(t,s.hosts))}return n?t:void 0}function Er(e){const t=e.filter(s=>s!==void 0);if(t.length===0)return;const n=St(t.map(({directHosts:s,...o})=>o)),r=vt(t.map(s=>s?.directHosts));return r!==void 0&&(n.directHosts=r),n}function J(e){return e?.backendProxy}function C(e){return e.replace(/\/$/,"")}function ve(e){return/^https?:\/\//i.test(e)}function Pe(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Pt(e){const t=new Set;return e.filter(n=>!n.url||t.has(n.url)?!1:(t.add(n.url),!0))}function bt(e){const t=J(e);return t?[t]:[]}function Lt(e){return{proxyEmFiles:!0,proxyAi:!1}}function Rt(e,t){const n=Lt(t),r=t?.backendProxyPolicy;switch(e){case"emFiles":return r?.proxyEmFiles??n.proxyEmFiles;case"ai":return r?.proxyAi??n.proxyAi;default:return!0}}var xt={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 wt(e){const t=[],n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(r,s)=>(t.push(s),`(${xt[s]||".+"})`));return{regex:new RegExp(`^${n}$`,"i"),tokens:t}}function Mt(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function Bt(e,t){if(Mt(t))return e;try{const n=new URL(e);return`${n.origin}${n.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function Ft(e,t,n){if(n.endsWith("_encoded"))return!0;const r=e.slice(0,t),s=r.lastIndexOf("#"),o=r.lastIndexOf("?"),i=r.lastIndexOf("&"),a=r.lastIndexOf("=");return a>Math.max(o,i)&&a>s}function kt(e){try{const t=new URL(e),n=t.pathname.replace(/^\/+/,""),r=t.search.replace(/^\?/,""),s=t.hash.replace(/^#/,""),o=n.replace(/^wp-json\/?/i,""),i=o?`/${o}`:"/",a=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),c=a?.[1]||"",_=a?.[2]||"",u=a?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:n,pathname:n,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:r,search:t.search,hash:t.hash,fragment:s,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:i,rest_namespace:c,rest_version:_,rest_route:u,rest_route_with_slash:u?`/${u}`:"/"}}catch{return}}function Y(e,t){if(!e)return{};if(Array.isArray(e)){for(const a of e){const c=Y(a,t);if(c!==void 0)return c}return}if(e==="*")return{};const n=Bt(t,e),{regex:r,tokens:s}=wt(e),o=r.exec(n);if(!o)return;const i={};return s.forEach((a,c)=>{i[`matched_${a}`]=o[c+1]||""}),i}function M(e,t,n={}){const r=kt(t);if(!r)return t;const s={...r,...n};let o="",i=0;const a=/\{([a-z_]+)\}/gi;let c;for(;c=a.exec(e);){o+=e.slice(i,c.index);const _=s[c[1]]??"",u=Ft(e,c.index,c[1])?encodeURIComponent(_):_;o+=u,i=c.index+c[0].length}o+=e.slice(i);try{const _=new URL(o),u=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&u.search&&u.searchParams.forEach((f,E)=>{_.searchParams.has(E)||_.searchParams.append(E,f)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&u.hash&&!_.hash&&(_.hash=u.hash),_.toString()}catch{return o}}function ae(e,t){try{const n=new URL(t);return`${C(e)}/${n.pathname.replace(/^\//,"")}${n.search}${n.hash}`}catch{return t}}function ce(e,t){const n=C(e);return t?ve(t)?t:t.startsWith("?")||t.startsWith("#")?`${n}${t}`:`${n}${t.startsWith("/")?"":"/"}${t}`:n}function be(e,t,n,r){const s=e.match;return s?Array.isArray(s)?s.some(o=>be({...e,match:o},t,n,r)):typeof s=="function"?!!s({url:t,method:r,requestType:n}):s==="*"?!0:Y(s,t)!==void 0:!0}function Ut(e,t,n,r="generic"){if(e==null)return[];const s=Array.isArray(e)?e:[e],o=[];return s.forEach((i,a)=>{if(!i)return;if(typeof i=="string"){const f=i.includes("{")&&i.includes("}")?M(i,t):ae(i,t);o.push({key:`backend:${a}`,url:f,source:"resource"});return}if(!Pe(i)||!("rewrite"in i))return;const c=i;if(!be(c,t,r,n))return;const _=typeof c.match=="string"||Array.isArray(c.match)?Y(c.match,t)||{}:{},u=typeof c.proxyBase=="string"&&c.proxyBase.trim()?c.proxyBase.trim():void 0;(Array.isArray(c.rewrite)?c.rewrite:[c.rewrite]).filter(Boolean).forEach((f,E)=>{const p=typeof f=="function"?(()=>{const I=f({url:t,proxyBase:u,method:n,requestType:r,..._}),h=u&&!ve(I)?ce(u,I):I;return h.includes("{")&&h.includes("}")?M(h,t,_):h})():u?M(ce(u,f),t,_):f.includes("{")&&f.includes("}")?M(f,t,_):ae(f,t);o.push({key:`backend:${c.id||"rule"}:${a}:${E}`,url:p,source:"resource"})})}),Pt(o)}function jt(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 Gt(e,t=[]){return e==null||(Array.isArray(e)?e:[e]).forEach(n=>{if(n){if(typeof n=="string"){const r=n.split("{")[0]?.trim();r&&t.push(C(r));return}!Pe(n)||!("rewrite"in n)||(typeof n.proxyBase=="string"&&n.proxyBase.trim()&&t.push(C(n.proxyBase.trim())),(Array.isArray(n.rewrite)?n.rewrite:[n.rewrite]).forEach(r=>{if(typeof r!="string")return;const s=r.split("{")[0]?.trim();s&&t.push(C(s))}))}}),t}function Xt(e,t){return bt(t).flatMap(n=>Gt(n)).filter(Boolean).some(n=>n&&e.startsWith(n))}function Ht(e,t){return!!J(t)&&Rt(e,t)}function $t(e,t={}){const n=t.requestType||jt(e);return Ht(n,t.config)?Ut(J(t.config),e,t.method,n):[]}function Vt(e,t={}){return Xt(e,t.config)?[e]:$t(e,t).map(n=>n.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 Wt(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const n=t.find(o=>o.aborted);if(n)return n;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const r=new AbortController,s=o=>{r.signal.aborted||r.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>s(o),{once:!0});return r.signal}var _e=3e5,ue=15e3,A=null,le=!1;function qt(){return!0}function Kt(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return _e;const t=Number(e);return Number.isFinite(t)&&t>0?t:_e}function zt(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return ue;const t=Number(e);return Number.isFinite(t)&&t>0?t:ue}function Jt(){const e="https://app.useblocks.io/api".trim();return e?D(e):void 0}function Yt(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const n=JSON.parse(t);if(!Array.isArray(n))throw new Error("expected JSON array");return n.map(r=>String(r).trim()).filter(Boolean)}catch{return le||(le=!0),[]}return t.split(",").map(n=>n.trim()).filter(Boolean)}function Qt(e){const t=new Set,n=[];for(const r of e){const s=D(r);t.has(s)||(t.add(s),n.push(s))}return n}function Le(e){const t=String(e||"").trim();return t?D(t):Jt()}function Re(e,t=[]){return e?Qt([e,...t]).slice(0,3):[]}function xe(){return Yt(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function Zt(e=Date.now()){return A?e-A.switchedAt>=Kt():!0}function we(e=Date.now()){A&&Zt(e)&&(A=null)}function S(e){if(!qt())return!1;const t=Le(e);if(!t)return!1;const n=xe();return n.length===0?!1:Re(t,n).length>1}function L(e){const t=Le(e);if(!t)return[];const n=xe();return n.length===0?[t]:Re(t,n)}function Q(e){const t=L(e);if(t.length===0)return"";if(we(),A){const n=t.indexOf(A.activeUrl);if(n>=0)return t[n]}return t[0]}function Me(e){const t=L(e);if(t.length<=1||(we(),!A||!t.includes(A.activeUrl)))return t;const n=A.activeUrl;return[n,...t.filter(r=>r!==n)]}function en(e){return Q(e)||void 0}function Be(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const n=zt(),r=new AbortController;let s;const o=setTimeout(()=>{s=tn(n),r.abort(s)},n);return{signal:Wt(t,r.signal),timeoutError:()=>s,done:()=>clearTimeout(o)}}function tn(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const n=new Error(t);return n.name="TimeoutError",n}function Fe(e){return e===502||e===503||e===504}function ke(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var Ue;function hr(e){Ue=e}function B(e,t){if(!S(t))return;const n=L(t);if(n.length<=1)return;const r=n.indexOf(D(e));if(r<0)return;const s=r+1;if(s>=n.length)return;const o=n[s],i=A?.activeUrl;A={activeUrl:o,switchedAt:Date.now()},i!==o&&Ue?.()}function je(e,t){if(!S(t))return;const n=D(e),r=L(t);if(r.includes(n)){if(n===r[0]){A=null;return}A?.activeUrl!==n&&(A={activeUrl:n,switchedAt:Date.now()})}}function Ge(){A=null}var nn=e=>{const t=new FormData,n=(r,s,o)=>{if(s!=null){if(s instanceof Blob){r.append(o,s);return}if(Array.isArray(s)){s.forEach((i,a)=>{const c=o?`${o}[${a}]`:`${a}`;n(r,i,c)});return}if(typeof s=="object"){Object.keys(s).forEach(i=>{const a=s[i],c=o?`${o}[${i}]`:i;n(r,a,c)});return}r.append(o,String(s))}};return n(t,e),t},rn={baseUrl:D("https://app.useblocks.io/api"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},m=new Map;function sn(e){const t=e?.getInstance(ot);return t?t.get()??t.bootstrap():void 0}var on=class extends ct{container;constructor(e={},t){super(e),this.container=t}buildRequestUrl(e){const{path:t,baseUrl:n,extraQuery:r}=e;let{query:s}=e;r&&(s=s?{...s,...r}:r);const o=s&&this.toQueryString(s);return`${n||this.baseUrl||""}${t}${o?`?${o}`:""}`}buildRequestKey(e,t){return`${t.toUpperCase()} ${e}`}getBackendProxyCandidates(e,t){const n=sn(this.container),r=this.container?.getInstance(at)!==void 0,s=Vt(e,{config:n,method:t,standalone:r}),o=s.length>0?s:[e],i=this.buildRequestKey(e,t),a=m.get(i);return!a||!o.includes(a)?o:[a,...o.filter(c=>c!==a)]}shouldRetryResponse(e){return e.status===502||e.status===503||e.status===504}resolveFailoverBaseUrl(){return String(this.baseUrl||"").trim()||void 0}async requestOnOrigin(e,t,n=!1){const r={...e,baseUrl:t},s=this.buildRequestUrl(r),o=r.method||"GET",i=this.buildRequestKey(s,o),a=this.getBackendProxyCandidates(s,o);let c,_;for(const u of a){const f=p=>p===s?u:p,E=n?Be(e.signal):void 0;try{const p=await super.request({...r,proxyHandler:f,...E?{signal:E.signal}:{}});if(!p.ok&&this.shouldRetryResponse(p)&&u!==a[a.length-1]){_=p,m.get(i)===u&&m.delete(i);continue}return m.set(i,u),p}catch(p){m.get(i)===u&&m.delete(i);const I=E?.timeoutError();if(I)throw I;if(c=p,(p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p}finally{E?.done()}}if(_)return _;throw c instanceof Error?c:new Error("Backend proxy chain failed")}async request(e){const t=String(e.baseUrl||"").trim();if(t)return this.requestOnOrigin(e,t);const n=this.resolveFailoverBaseUrl(),r=S(n),s=e.failoverAttemptTimeout??r,o=r?Me(n):n?[Q(n)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let i,a;for(let c=0;c<o.length;c++){const _=o[c],u=c===o.length-1;try{const f=await this.requestOnOrigin(e,_,s);if(!f.ok&&Fe(f.status)){if(a=f,!u){B(_,n);continue}break}return f.ok&&je(_,n),f}catch(f){if(!ke(f))throw f;i=f,u||B(_,n)}}if(r&&Ge(),a)return a;throw i instanceof Error?i:new Error("API origin failover chain failed")}};function an(e={},t){const n=new on({...rn,...e},t);return n.contentFormatters["multipart/form-data"]=nn,n}var cn=d("rest.clientFactory"),Ar=e=>{pt(e);const t=an({customFetch:e.getInstance(Se)?.execute||fetch},e);e.inject(De,t)},de;(function(e){const t="https://racs.rest/v3";function n(s,o){const i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(o)};return fetch(`${t}?resource=${s}&dataset=${document.location.hostname}`,i)}e.post=n;async function r(s,o=0){const i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:`{"filter":{},"limit":${o}}`};return await(await fetch(`${t}/get?resource=${s}&dataset=${document.location.hostname}`,i)).json()}e.getAll=r})(de||(de={}));function F(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e),r=Array.isArray(t);if(n){if(!r)return!1;const a=e.length;if(t.length!==a)return!1;for(let c=0;c<a;c++)if(!F(e[c],t[c]))return!1}else if(r)return!1;const s=Object.keys(e),o=Object.keys(t),i=s.length;if(i!==o.length)return!1;for(let a=0;a<i;a++){const c=s[a];if(!t.hasOwnProperty(c)||!F(e[c],t[c]))return!1}}return!0}function _n(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),n=atob(t),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return new TextDecoder().decode(r)}function un(e){const[t,n,r]=e.split("."),s=JSON.parse(_n(n));return{exp:s.exp,createdAt:s.iat,data:s}}var $=d("plugin.auth.token"),fe=new WeakMap,ln=3e4;function dn(e){let t;try{t=un(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+ln}function fn(e,t,n,r){const s=fe.get(e);s&&(s.stale=!0);const o={stale:!1};fe.set(e,o),e.injectFactory($,async(i,a)=>{if(o.stale)return"";try{let c=await a||void 0;if(!c){const _=e.getInstance(it);_&&(c=await _)}return t?!c||dn(c)?await t(n,r,c):c:""}catch{return""}},!0)}var pe=d("auth.oauthProvided"),Ee=new WeakMap;function Xe(e,t){const n=Ee.get(e)??{applied:!1};(!n.applied||n.getAuthToken!==t.getAuthToken||!F(n.user,t.user)||n.project!==t.project)&&(Ee.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),fn(e,t.getAuthToken,t.user,t.project))}function pn(e){if(e.getInstance(pe))return;e.inject(pe,!0);let t;e.getInstance(st)?.watch(n=>{t=n}),e.addService(K,{execute:async(n,r)=>{if(r?.public||!t?.getAuthToken)return;e.getInstance($)===void 0&&Xe(e,t);const s=await e.getInstanceAsync($);s&&n.headers.set("authorization",`Bearer ${s}`)}})}var Ir={text:{fontFamily:["Google Fonts","Sans Serif","Mulish","Regular"],fontSize:16,fontSizeDim:"px",lineHeight:24,lineHeightDim:"px",color:"#595959",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Google Fonts","Sans Serif","Mulish","Bold"],fontSize:28,fontSizeDim:"px",lineHeight:34,lineHeightDim:"px",color:"#000000",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},links:{color:"#1890ff",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Google Fonts","Sans Serif","Mulish","Medium"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1890ff",bold:!1,italic:!1,backgroundColor:"#1890ff",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:6,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},textAlign:"center",padding:{all:null,top:null,right:null,bottom:null,left:null}},block:{backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1890ff",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1890ff",contrastTextColor:"#ffffff",baseBackgroundColor:"#f8f8f8",baseTextColor:"#333333",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null}}},He="ERROR",Or="useblocks",gr={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_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_guest_locale:"em_guest_locale"},Tr="light",mr="dark",Sr="(prefers-color-scheme: dark)",Dr={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_PREVIEW:"update_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_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_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_WINDOW_CHARACTERISTIC:"sandbox_window-characteristic",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_ADD_MERGETAG:"sandbox_add_mergetag",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"},En=e=>{const t={current:Promise.resolve(),state:e,decorate:(n,r)=>(r&&(n=n.bind(r)),function(...s){const o=t.current.then(()=>n(...s));return t.current=o.then(i=>{t.state=i},i=>{}),o})};return t};function $e(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function Nr(e){return t=>{const n={},r=[];for(const i of e)r.push(i(t));for(const i of r)Object.assign(n,i.instance);return{instance:n,setOptions:async i=>{for(const a of r)await a.setOptions(i)},dispose:()=>{for(const i of r)i.dispose()}}}}function hn(e=He){const t=new Error(e);return t.name="AuthPipelineError",t}async function An(e,t,n,r){const s=r?.attemptTimeout??S(n),o=S(n)?Me(n):L(n).length>0?[Q(n)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const i=e.startsWith("/")?e:`/${e}`;let a,c;for(let _=0;_<o.length;_++){const u=o[_],f=_===o.length-1,E=s?Be(t.signal):void 0;try{const p=await fetch(`${u}${i}`,{...t,...E?{signal:E.signal}:{}});if(!p.ok&&Fe(p.status)){if(a=p,!f){B(u,n);continue}break}return p.ok&&je(u,n),p}catch(p){const I=E?.timeoutError();if(!I&&!ke(p))throw p;c=I||p,f||B(u,n)}finally{E?.done()}}if(S(n)&&Ge(),a)return a;throw c instanceof Error?c:new Error("[apiOriginFailover] fetch chain failed")}function he(e){e.inject(y,void 0),e.inject(H,void 0)}var yr=$e(e=>{let t,n;const r=En();return e.addService(K,{execute:r.decorate(async(s,o)=>{if(o?.public||!t)return;const i=String(e.getInstance(H)||"").trim();if(i){s.headers.append("authorization",`Bearer ${i}`);return}if(!e.getInstance(y))try{const a=e.getInstance(cn),c=String(a?.getOptions()?.baseUrl||"").trim(),_=en(n||c||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const u=await An("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},_);if(!u.ok)throw new Error(`JWT auth failed: ${u.status}`);const f=await u.json(),E=String(f.token||"").trim();if(!E)throw new Error("JWT auth failed: empty token");e.inject(y,void 0),e.inject(H,E),s.headers.append("authorization",`Bearer ${E}`)}catch{throw e.inject(y,He),hn()}})}),{setOptions(s){const o=s.jwtAuth,i=String(s.baseUrl||"").trim()||void 0,a=!F(o,t),c=i!==n;if(t=o,n=i,!o){he(e);return}a||c?he(e):e.inject(y,void 0)}}}),Cr=$e(e=>(pn(e),{setOptions(t){Xe(e,t)}}));function In(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function V(e,t=document){try{const r=t.querySelector(e);if(r)return r}catch{return null}const n=t.querySelectorAll("*");for(let r=0;r<n.length;r++){const s=n[r]?.shadowRoot;if(!s)continue;const o=V(e,s);if(o)return o}return null}function Ve(e,t=[]){const n=e.querySelectorAll("*");for(let r=0;r<n.length;r++){const s=n[r]?.shadowRoot;s&&(t.push(s),Ve(s,t))}return t}function On(e,t,n){if(e.isConnected)return e;const r=e.id?.trim();return r?gn(`#${In(r)}`,t,n):Promise.reject(v("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function gn(e,t,n){if(Te(n),typeof e<"u"){if(typeof e=="string"){const r=e,s=V(r);if(s)return s;const o=t.addDisposable(new T);return new Promise((i,a)=>{const c=h=>{o.dispose(),h()},_=()=>{c(()=>a(v(n?.reason)))};if(n?.aborted){_();return}n?.addEventListener("abort",_),o.addDispose(()=>n?.removeEventListener("abort",_));const u=document.body??document.documentElement;if(!u){c(()=>a(v("Document is not ready to observe mount element")));return}const f=new Set,E=new MutationObserver(()=>{const h=V(r);if(h){c(()=>i(h));return}I()}),p=h=>{f.has(h)||(f.add(h),E.observe(h,{attributes:!0,childList:!0,subtree:!0}))},I=()=>{const h=document.documentElement;if(h)for(const R of Ve(h))p(R)};p(u),I(),o.addDispose(()=>E.disconnect())})}return e instanceof Element?On(e,t,n):e}return e}var vr=new Map;export{$n as $,cr as A,Ze as At,Qn as B,hr as C,yn as Ct,Er as D,mn as Dt,fr as E,Te as Et,Zn as F,Se as G,Kn as H,rr as I,De as J,dt as K,nr as L,tr as M,k as Mt,zn as N,T as Nt,St as O,te as Ot,Jn as P,Hn as Q,sr as R,en as S,Cn as St,pr as T,Sn as Tt,It as U,er as V,qn as W,Vn as X,Wn as Y,Rn as Z,F as _,q as _t,Nr as a,st as at,Ar as b,Nn as bt,mr as c,jn as ct,gr as d,kn as dt,ot as et,Sr as f,Fn as ft,un as g,Pn as gt,pn as h,bn as ht,yr as i,Bn as it,lr as j,Tn as jt,dr as k,d as kt,Dr as l,it as lt,Ir as m,Ln as mt,gn as n,wn as nt,$e as o,Xn as ot,Or as p,ne as pt,K as q,Cr as r,Mn as rt,En as s,at as st,vr as t,xn as tt,Tr as u,Gn as ut,cn as v,P as vt,Wt as w,v as wt,Q as x,vn as xt,an as y,Dn as yt,Yn as z};
|
|
File without changes
|
|
File without changes
|