monto-email-builder 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,385 +1,394 @@
1
- import { jsx as o, jsxs as f, Fragment as Nt } from "react/jsx-runtime";
2
- import { forwardRef as dt, useState as E, useRef as $, useEffect as X, useCallback as D, useMemo as J, useImperativeHandle as zt } from "react";
3
- import Ot from "@uiw/react-codemirror";
4
- import { html as Pt } from "@codemirror/lang-html";
5
- import { xcodeDark as _t, tomorrowNightBlue as Wt, dracula as ut, basicDark as jt, abcdef as Gt, bbedit as Ut, noctisLilac as qt, gruvboxLight as Yt, tokyoNightDay as Kt, vscodeLight as Xt, xcodeLight as Jt } from "@uiw/codemirror-themes-all";
1
+ import { jsx as r, jsxs as x, Fragment as Nt } from "react/jsx-runtime";
2
+ import { forwardRef as ut, useState as V, useRef as $, useEffect as G, useCallback as L, useMemo as J, useImperativeHandle as Ot } from "react";
3
+ import Pt from "@uiw/react-codemirror";
4
+ import { html as _t } from "@codemirror/lang-html";
5
+ import { xcodeDark as Wt, tomorrowNightBlue as jt, dracula as mt, basicDark as Gt, abcdef as qt, bbedit as Ut, noctisLilac as Yt, gruvboxLight as Kt, tokyoNightDay as Xt, vscodeLight as Jt, xcodeLight as Qt } from "@uiw/codemirror-themes-all";
6
6
  import Q from "@mui/material/ToggleButton";
7
7
  import et from "@mui/material/ToggleButtonGroup";
8
- import { ThemeProvider as Qt, ScopedCssBaseline as Zt, useTheme as er, Box as m, Tooltip as G, FormControl as tr, InputLabel as rr, Select as or, ListSubheader as tt, MenuItem as rt, Button as ve, Tabs as ar, Tab as ot, Typography as B, Accordion as nr, AccordionSummary as ir, AccordionDetails as lr, TextField as ye, Divider as sr } from "@mui/material";
9
- import { alpha as ce } from "@mui/material/styles";
10
- import * as cr from "@mui/icons-material/AddOutlined";
11
- import * as dr from "@mui/icons-material/Code";
12
- import * as ur from "@mui/icons-material/DataObjectOutlined";
13
- import * as mr from "@mui/icons-material/ExpandMoreOutlined";
14
- import * as hr from "@mui/icons-material/HelpOutlined";
15
- import * as br from "@mui/icons-material/Visibility";
16
- import * as pr from "@mui/icons-material/ViewColumn";
17
- import * as fr from "@mui/icons-material/MonitorOutlined";
18
- import * as xr from "@mui/icons-material/PhoneIphoneOutlined";
19
- import { B as gr, V as A, r as L, T as vr, t as yr } from "./chunks/chunk-ZMWDxWGX.js";
20
- const Ee = gr, at = "unsubscribe_link", Ve = /\{\{\s*([^{}]+?)\s*\}\}/g, nt = /\{%\s*([^{}%]+?)\s*%\}/g;
21
- function Te(a, n, s, d, c) {
22
- return a[n - 1] !== d && a[s] !== c;
8
+ import { ThemeProvider as Zt, ScopedCssBaseline as er, useTheme as tr, Box as h, Tooltip as q, FormControl as rr, InputLabel as or, Select as nr, ListSubheader as tt, MenuItem as rt, Button as Ie, Tabs as ar, Tab as ot, Typography as k, Accordion as ir, AccordionSummary as lr, AccordionDetails as sr, TextField as Ee, Divider as cr } from "@mui/material";
9
+ import { alpha as de } from "@mui/material/styles";
10
+ import * as dr from "@mui/icons-material/AddOutlined";
11
+ import * as ur from "@mui/icons-material/Code";
12
+ import * as mr from "@mui/icons-material/DataObjectOutlined";
13
+ import * as hr from "@mui/icons-material/ExpandMoreOutlined";
14
+ import * as br from "@mui/icons-material/HelpOutlined";
15
+ import * as pr from "@mui/icons-material/Visibility";
16
+ import * as fr from "@mui/icons-material/ViewColumn";
17
+ import * as xr from "@mui/icons-material/MonitorOutlined";
18
+ import * as gr from "@mui/icons-material/PhoneIphoneOutlined";
19
+ import { B as vr, V as F, r as B, T as yr, a as nt, t as Ir } from "./chunks/chunk-CT9uNEVC.js";
20
+ const Ve = vr, at = "unsubscribe_link", Te = /\{\{\s*([^{}]+?)\s*\}\}/g, it = /\{%\s*([^{}%]+?)\s*%\}/g;
21
+ function Ce(n, a, s, u, d) {
22
+ return n[a - 1] !== u && n[s] !== d;
23
23
  }
24
- function mt(a, n = "user") {
25
- return n === "builtin" || n === "system" ? `{%${a}%}` : `{{${a}}}`;
24
+ function ht(n, a = "user") {
25
+ return a === "builtin" || a === "system" ? `{%${n}%}` : `{{${n}}}`;
26
26
  }
27
- function Ir(a) {
28
- const n = typeof a == "string" ? a.trim() : "";
29
- if (n.startsWith("{{") && n.endsWith("}}")) {
30
- const s = n.slice(2, -2).trim();
31
- if (A.test(s)) return { attribute: s, type: "user" };
27
+ function Er(n) {
28
+ const a = typeof n == "string" ? n.trim() : "";
29
+ if (a.startsWith("{{") && a.endsWith("}}")) {
30
+ const s = a.slice(2, -2).trim();
31
+ if (F.test(s)) return { attribute: s, type: "user" };
32
32
  }
33
- if (n.startsWith("{%") && n.endsWith("%}")) {
34
- const s = n.slice(2, -2).trim();
35
- if (A.test(s)) return { attribute: s, type: "system" };
33
+ if (a.startsWith("{%") && a.endsWith("%}")) {
34
+ const s = a.slice(2, -2).trim();
35
+ if (F.test(s)) return { attribute: s, type: "system" };
36
36
  }
37
37
  return null;
38
38
  }
39
- function Er(a, n) {
40
- const s = a.variable ?? a.Variable ?? a.key ?? "", d = Ir(s), x = (a.type ?? a.Type ?? (d == null ? void 0 : d.type) ?? "user") === "system" ? "system" : "user", i = a.attribute ?? a.Attribute ?? (d == null ? void 0 : d.attribute) ?? "", u = String(i).trim();
41
- return !u || !A.test(u) ? null : {
42
- id: Number(a.id) || n + 1,
43
- variableInstanceId: a.variableInstanceId ?? a.VariableInstanceId,
44
- variable: x === "system" ? `{%${u}%}` : `{{${u}}}`,
45
- type: x,
46
- attribute: u,
47
- default: String(a.default ?? a.Default ?? a.value ?? "")
39
+ function Vr(n, a) {
40
+ const s = n.variable ?? n.Variable ?? n.key ?? "", u = Er(s), g = (n.type ?? n.Type ?? (u == null ? void 0 : u.type) ?? "user") === "system" ? "system" : "user", i = n.attribute ?? n.Attribute ?? (u == null ? void 0 : u.attribute) ?? "", m = String(i).trim();
41
+ return !m || !F.test(m) ? null : {
42
+ id: Number(n.id) || a + 1,
43
+ variableInstanceId: n.variableInstanceId ?? n.VariableInstanceId,
44
+ variable: g === "system" ? `{%${m}%}` : `{{${m}}}`,
45
+ type: g,
46
+ attribute: m,
47
+ default: String(n.default ?? n.Default ?? n.value ?? "")
48
48
  };
49
49
  }
50
- function it(a) {
51
- return Array.isArray(a) ? a.map((n, s) => Er(n, s)).filter((n) => !!n).map((n, s) => ({
52
- ...n,
50
+ function lt(n) {
51
+ return Array.isArray(n) ? n.map((a, s) => Vr(a, s)).filter((a) => !!a).map((a, s) => ({
52
+ ...a,
53
53
  id: s + 1,
54
- variableInstanceId: n.variableInstanceId || we(n.type, n.attribute, s)
54
+ variableInstanceId: a.variableInstanceId || He(a.type, a.attribute, s)
55
55
  })) : [];
56
56
  }
57
- function de(a) {
58
- const n = a || "", s = [], d = (i, u, p) => {
59
- s.push({ attribute: i, type: u, start: p });
57
+ function Z(n) {
58
+ const a = n || "", s = [], u = (i, m, f) => {
59
+ s.push({ attribute: i, type: m, start: f });
60
60
  };
61
- let c;
62
- for (Ve.lastIndex = 0; c = Ve.exec(n); ) {
63
- const i = c.index, u = i + c[0].length;
64
- if (!Te(n, i, u, "{", "}")) continue;
65
- const p = c[1].trim();
66
- !p || !A.test(p) || d(p, "user", i);
61
+ let d;
62
+ for (Te.lastIndex = 0; d = Te.exec(a); ) {
63
+ const i = d.index, m = i + d[0].length;
64
+ if (!Ce(a, i, m, "{", "}")) continue;
65
+ const f = d[1].trim();
66
+ !f || !F.test(f) || u(f, "user", i);
67
67
  }
68
- let x;
69
- for (nt.lastIndex = 0; x = nt.exec(n); ) {
70
- const i = x.index, u = i + x[0].length;
71
- if (!Te(n, i, u, "{", "}")) continue;
72
- const p = x[1].trim();
73
- !p || !A.test(p) || d(p, "system", i);
68
+ let g;
69
+ for (it.lastIndex = 0; g = it.exec(a); ) {
70
+ const i = g.index, m = i + g[0].length;
71
+ if (!Ce(a, i, m, "{", "}")) continue;
72
+ const f = g[1].trim();
73
+ !f || !F.test(f) || u(f, "system", i);
74
74
  }
75
- return s.sort((i, u) => i.start - u.start), s.map((i, u) => ({
76
- id: u + 1,
77
- variableInstanceId: wr(i.type, i.attribute, i.start),
75
+ return s.sort((i, m) => i.start - m.start), s.map((i, m) => ({
76
+ id: m + 1,
77
+ variableInstanceId: Hr(i.type, i.attribute, i.start),
78
78
  variable: i.type === "system" ? `{%${i.attribute}%}` : `{{${i.attribute}}}`,
79
79
  type: i.type,
80
80
  attribute: i.attribute,
81
81
  default: ""
82
82
  }));
83
83
  }
84
- function Ie(a, n) {
85
- const s = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
86
- return n.forEach((c) => {
87
- const x = { item: c, consumed: !1 };
88
- if (c.variableInstanceId) {
89
- const p = s.get(c.variableInstanceId) ?? [];
90
- p.push(x), s.set(c.variableInstanceId, p);
84
+ function ue(n, a) {
85
+ const s = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
86
+ return a.forEach((d) => {
87
+ const g = { item: d, consumed: !1 };
88
+ if (d.variableInstanceId) {
89
+ const f = s.get(d.variableInstanceId) ?? [];
90
+ f.push(g), s.set(d.variableInstanceId, f);
91
91
  }
92
- const i = `${c.type}:${c.attribute}`, u = d.get(i) ?? [];
93
- u.push(x), d.set(i, u);
94
- }), a.map((c, x) => {
95
- var N;
96
- const i = `${c.type}:${c.attribute}`, u = c.variableInstanceId ? (N = s.get(c.variableInstanceId)) == null ? void 0 : N.find((g) => !g.consumed) : void 0, p = (d.get(i) ?? []).find((g) => !g.consumed), w = u ?? p;
97
- return w && (w.consumed = !0), {
98
- ...c,
99
- id: x + 1,
100
- variableInstanceId: c.variableInstanceId || we(c.type, c.attribute, x),
101
- default: c.type === "system" ? "" : (w == null ? void 0 : w.item.default) ?? c.default ?? ""
92
+ const i = `${d.type}:${d.attribute}`, m = u.get(i) ?? [];
93
+ m.push(g), u.set(i, m);
94
+ }), n.map((d, g) => {
95
+ var z;
96
+ const i = `${d.type}:${d.attribute}`, m = d.variableInstanceId ? (z = s.get(d.variableInstanceId)) == null ? void 0 : z.find((v) => !v.consumed) : void 0, f = (u.get(i) ?? []).find((v) => !v.consumed), H = m ?? f;
97
+ return H && (H.consumed = !0), {
98
+ ...d,
99
+ id: g + 1,
100
+ variableInstanceId: d.variableInstanceId || He(d.type, d.attribute, g),
101
+ default: d.type === "system" ? "" : (H == null ? void 0 : H.item.default) ?? d.default ?? ""
102
102
  };
103
103
  });
104
104
  }
105
- function Vr(a) {
106
- return a.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
105
+ function Tr(n) {
106
+ return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
107
107
  }
108
- function lt(a, n) {
109
- const s = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
110
- n.forEach((i) => {
111
- i.type === "user" && (i.variableInstanceId && s.set(i.variableInstanceId, i.default ?? ""), d.has(i.attribute) || d.set(i.attribute, i.default ?? ""));
108
+ function st(n, a) {
109
+ const s = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
110
+ a.forEach((i) => {
111
+ i.type === "user" && (i.variableInstanceId && s.set(i.variableInstanceId, i.default ?? ""), u.has(i.attribute) || u.set(i.attribute, i.default ?? ""));
112
112
  });
113
- const c = de(a), x = /* @__PURE__ */ new Map();
114
- return c.forEach((i) => {
115
- const u = Number(String(i.variableInstanceId ?? "").split("-at-")[1]);
116
- Number.isFinite(u) && x.set(u, i);
117
- }), (a || "").replace(Ve, (i, u, p, w) => {
118
- var Z;
119
- const N = p + i.length;
120
- if (!Te(w, p, N, "{", "}")) return i;
121
- const g = String(u).trim();
122
- if (!g || !A.test(g)) return i;
123
- const F = (Z = x.get(p)) == null ? void 0 : Z.variableInstanceId, z = (F ? s.get(F) : void 0) ?? (n.filter((l) => l.type === "user" && l.attribute === g).length === 1 ? d.get(g) : void 0);
124
- return z === void 0 || z === "" ? i : Vr(z);
113
+ const d = Z(n), g = /* @__PURE__ */ new Map();
114
+ return d.forEach((i) => {
115
+ const m = Number(String(i.variableInstanceId ?? "").split("-at-")[1]);
116
+ Number.isFinite(m) && g.set(m, i);
117
+ }), (n || "").replace(Te, (i, m, f, H) => {
118
+ var ee;
119
+ const z = f + i.length;
120
+ if (!Ce(H, f, z, "{", "}")) return i;
121
+ const v = String(m).trim();
122
+ if (!v || !F.test(v)) return i;
123
+ const R = (ee = g.get(f)) == null ? void 0 : ee.variableInstanceId, N = (R ? s.get(R) : void 0) ?? (a.filter((l) => l.type === "user" && l.attribute === v).length === 1 ? u.get(v) : void 0);
124
+ return N === void 0 || N === "" ? i : Tr(N);
125
125
  });
126
126
  }
127
- function st(a, n, s = "") {
128
- const d = a.trim();
129
- if (!d || !A.test(d)) return null;
130
- const c = n === "builtin" ? "system" : "user";
127
+ function ct(n, a, s = "") {
128
+ const u = n.trim();
129
+ if (!u || !F.test(u)) return null;
130
+ const d = a === "builtin" ? "system" : "user";
131
131
  return {
132
132
  id: 1,
133
- variableInstanceId: we(c, d, 0),
134
- variable: mt(d, n),
135
- type: c,
136
- attribute: d,
137
- default: c === "system" ? "" : s
133
+ variableInstanceId: He(d, u, 0),
134
+ variable: ht(u, a),
135
+ type: d,
136
+ attribute: u,
137
+ default: d === "system" ? "" : s
138
138
  };
139
139
  }
140
- function Tr(a) {
141
- const n = a.trim();
142
- return n ? Ee.some((s) => s.items.some((d) => d.name === n)) : !1;
140
+ function Cr(n) {
141
+ const a = n.trim();
142
+ return a ? Ve.some((s) => s.items.some((u) => u.name === a)) : !1;
143
143
  }
144
- function Cr(a, n) {
145
- const s = a.trim();
146
- return n === "user" && s === at ? `<a href="{{${at}}}">Unsubscribe Link</a>` : mt(s, n);
144
+ function wr(n, a) {
145
+ const s = n.trim();
146
+ return a === "user" && s === at ? `<a href="{{${at}}}">Unsubscribe Link</a>` : ht(s, a);
147
147
  }
148
- function we(a, n, s) {
149
- return `html-${a}-${n}-${s + 1}`;
148
+ function He(n, a, s) {
149
+ return `html-${n}-${a}-${s + 1}`;
150
150
  }
151
- function wr(a, n, s) {
152
- return `html-${a}-${n}-at-${s}`;
151
+ function Hr(n, a, s) {
152
+ return `html-${n}-${a}-at-${s}`;
153
153
  }
154
- const Hr = L(cr), Sr = L(dr), Mr = L(ur), Dr = L(mr), Lr = L(hr), kr = L(br), Br = L(pr), Ar = L(fr), Fr = L(xr), Ce = {
154
+ const Sr = B(dr), Dr = B(ur), Mr = B(mr), Lr = B(hr), kr = B(br), Br = B(pr), Ar = B(fr), Fr = B(xr), Rr = B(gr), we = {
155
155
  // 浅色主题
156
- xcodeLight: Jt,
157
- vscodeLight: Xt,
158
- tokyoNightDay: Kt,
159
- gruvboxLight: Yt,
160
- noctisLilac: qt,
156
+ xcodeLight: Qt,
157
+ vscodeLight: Jt,
158
+ tokyoNightDay: Xt,
159
+ gruvboxLight: Kt,
160
+ noctisLilac: Yt,
161
161
  bbedit: Ut,
162
162
  // 深色主题
163
- abcdef: Gt,
164
- basicDark: jt,
165
- dracula: ut,
166
- tomorrowNightBlue: Wt,
167
- xcodeDark: _t
168
- }, Rr = {
163
+ abcdef: qt,
164
+ basicDark: Gt,
165
+ dracula: mt,
166
+ tomorrowNightBlue: jt,
167
+ xcodeDark: Wt
168
+ }, $r = {
169
169
  xcodeLight: "Xcode Light (Light)",
170
170
  vscodeLight: "VSCode Light (Light)",
171
171
  tokyoNightDay: "Tokyo Night Day (Light)",
172
172
  gruvboxLight: "Gruvbox Light (Light)",
173
173
  noctisLilac: "Noctis Lilac (Light)",
174
174
  bbedit: "BBEdit (Light)"
175
- }, $r = {
175
+ }, zr = {
176
176
  abcdef: "ABCDEF (Dark)",
177
177
  basicDark: "Basic Dark (Dark)",
178
178
  dracula: "Dracula (Dark)",
179
179
  tomorrowNightBlue: "Tomorrow Night Blue (Dark)",
180
180
  xcodeDark: "Xcode Dark (Dark)"
181
- }, ht = "html-editor-theme", ct = "dracula";
182
- function Nr(a = ct) {
183
- const n = a && Ce[a] ? a : ct;
184
- if (typeof window > "u") return n;
181
+ }, bt = "html-editor-theme", dt = "dracula";
182
+ function Nr(n = dt) {
183
+ const a = n && we[n] ? n : dt;
184
+ if (typeof window > "u") return a;
185
185
  try {
186
- const s = localStorage.getItem(ht);
187
- if (s && Ce[s]) return s;
186
+ const s = localStorage.getItem(bt);
187
+ if (s && we[s]) return s;
188
188
  } catch {
189
189
  console.error("Failed to get HTML Editor stored theme");
190
190
  }
191
- return n;
191
+ return a;
192
192
  }
193
- function zr(a) {
193
+ function Or(n) {
194
194
  try {
195
- localStorage.setItem(ht, a);
195
+ localStorage.setItem(bt, n);
196
196
  } catch {
197
- console.error("Failed to set HTML Editor stored theme", a);
197
+ console.error("Failed to set HTML Editor stored theme", n);
198
198
  }
199
199
  }
200
- function Or({
201
- value: a,
202
- onChange: n,
200
+ function Pr({
201
+ value: n,
202
+ onChange: a,
203
203
  language: s = "zh",
204
- initialMode: d = "split",
205
- initialDevice: c = "desktop",
206
- codeEditorHeight: x = "100%",
204
+ initialMode: u = "split",
205
+ initialDevice: d = "desktop",
206
+ codeEditorHeight: g = "100%",
207
207
  previewHeight: i = "100%",
208
- sx: u,
209
- showToolbar: p = !0,
210
- initialTheme: w,
211
- initialRightTab: N = "preview",
212
- variables: g,
213
- onVariablesChange: F,
214
- requireVariableDefaults: z = !0
215
- }, Z) {
216
- var Re, $e, Ne, ze, Oe, Pe, _e, We, je, Ge, Ue, qe, Ye, Ke, Xe, Je, Qe, Ze;
217
- const l = (e, t) => yr(e, t, s), [H, pt] = E(d), [O, ft] = E(c), [He, xt] = E(() => Nr(w)), [T, ue] = E(a), [ee, P] = E(N), [C, Se] = E(() => it(g)), [gt, vt] = E(!1), [yt, It] = E(null), [_, Me] = E(""), [W, De] = E(""), [me, te] = E(!1), [he, re] = E(!1), U = $(null), be = $(null), R = $(C), Le = $(null), ke = $(null), pe = $(!1), oe = $(null);
218
- X(() => {
219
- a !== T && ue(a);
220
- }, [a]), X(() => {
221
- if (g === void 0) return;
222
- const e = it(g);
223
- R.current = e, Se(e);
224
- }, [g]);
225
- const k = D(
208
+ sx: m,
209
+ showToolbar: f = !0,
210
+ initialTheme: H,
211
+ initialRightTab: z = "preview",
212
+ variables: v,
213
+ onVariablesChange: R,
214
+ requireVariableDefaults: N = !0
215
+ }, ee) {
216
+ var Re, $e, ze, Ne, Oe, Pe, _e, We, je, Ge, qe, Ue, Ye, Ke, Xe, Je, Qe, Ze;
217
+ const l = (e, t) => Ir(e, t, s), [S, ft] = V(u), [O, xt] = V(d), [Se, gt] = V(() => Nr(H)), [E, me] = V(n), [te, P] = V(z), [w, he] = V(() => lt(v)), [vt, yt] = V(!1), [It, Et] = V(null), [_, De] = V(""), [W, Me] = V(""), [be, re] = V(!1), [pe, oe] = V(!1), U = $(null), fe = $(null), T = $(w), Le = $(null), ke = $(null), xe = $(!1), ne = $(null);
218
+ G(() => {
219
+ n !== E && me(n);
220
+ }, [n]), G(() => {
221
+ if (v === void 0) return;
222
+ const e = lt(v);
223
+ T.current = e, he(e);
224
+ }, [v]), G(() => {
225
+ if (v !== void 0) return;
226
+ const e = Z(E), t = ue(e, T.current);
227
+ (t.length !== T.current.length || t.some((c, y) => {
228
+ const b = T.current[y];
229
+ return !b || b.variableInstanceId !== c.variableInstanceId || b.attribute !== c.attribute || b.type !== c.type || b.default !== c.default;
230
+ })) && (T.current = t, he(t));
231
+ }, [E, v]);
232
+ const A = L(
226
233
  (e) => {
227
- const t = e.map((r, h) => ({
228
- ...r,
229
- id: h + 1,
230
- default: r.type === "system" ? "" : r.default ?? ""
234
+ const t = e.map((o, c) => ({
235
+ ...o,
236
+ id: c + 1,
237
+ default: o.type === "system" ? "" : o.default ?? ""
231
238
  }));
232
- return R.current = t, Se(t), F == null || F(t), t;
239
+ return T.current = t, he(t), R == null || R(t), t;
233
240
  },
234
- [F]
235
- ), S = D(() => {
236
- var t, r;
237
- const e = (r = (t = be.current) == null ? void 0 : t.state) == null ? void 0 : r.doc;
238
- return e && typeof e.toString == "function" ? e.toString() : T;
239
- }, [T]), fe = (e) => {
240
- ue(e), U.current && clearTimeout(U.current), U.current = setTimeout(() => {
241
- n == null || n(e);
241
+ [R]
242
+ ), D = L(() => {
243
+ var t, o;
244
+ const e = (o = (t = fe.current) == null ? void 0 : t.state) == null ? void 0 : o.doc;
245
+ return e && typeof e.toString == "function" ? e.toString() : E;
246
+ }, [E]), ge = (e) => {
247
+ me(e), U.current && clearTimeout(U.current), U.current = setTimeout(() => {
248
+ a == null || a(e);
242
249
  }, 300);
243
- }, q = D(
250
+ }, Y = L(
244
251
  (e) => {
245
- const t = de(e ?? S()), r = Ie(t, R.current);
246
- return k(r);
252
+ const t = Z(e ?? D()), o = ue(t, T.current);
253
+ return A(o);
247
254
  },
248
- [S, k]
249
- ), ae = D(() => {
250
- const e = S();
251
- e !== T && ue(e);
252
- const t = q(e), r = z ? t.filter((h) => h.type === "user" && h.default.trim() === "") : [];
253
- return vt(r.length > 0), r.length > 0 && P("variables"), {
254
- valid: r.length === 0,
255
+ [D, A]
256
+ ), ae = L(() => {
257
+ const e = D();
258
+ e !== E && me(e);
259
+ const t = Y(e), o = N ? t.filter(
260
+ (c) => c.type === "user" && nt(c.attribute, "user") && c.default.trim() === ""
261
+ ) : [];
262
+ return yt(o.length > 0), o.length > 0 && P("variables"), {
263
+ valid: o.length === 0,
255
264
  variables: t,
256
- missing: r
265
+ missing: o
257
266
  };
258
- }, [S, T, z, q]), Et = D(() => {
259
- pe.current = !0, ae(), P("variables");
267
+ }, [D, E, N, Y]), Vt = L(() => {
268
+ xe.current = !0, ae(), P("variables");
260
269
  }, [ae]);
261
- X(() => {
262
- if (ee !== "variables" || !pe.current) return;
270
+ G(() => {
271
+ if (te !== "variables" || !xe.current) return;
263
272
  const e = window.requestAnimationFrame(() => {
264
- const t = Le.current, r = ke.current;
265
- t && r && t.scrollTo({
266
- top: Math.max(r.offsetTop - 8, 0),
273
+ const t = Le.current, o = ke.current;
274
+ t && o && t.scrollTo({
275
+ top: Math.max(o.offsetTop - 8, 0),
267
276
  behavior: "auto"
268
- }), pe.current = !1;
277
+ }), xe.current = !1;
269
278
  });
270
279
  return () => window.cancelAnimationFrame(e);
271
- }, [ee, C.length]), X(() => () => {
280
+ }, [te, w.length]), G(() => () => {
272
281
  U.current && clearTimeout(U.current);
273
282
  }, []);
274
- const Vt = (e) => {
275
- var y, I, Y;
283
+ const Tt = (e) => {
284
+ var p, I, K;
276
285
  const t = e || "";
277
- let r = t;
286
+ let o = t;
278
287
  if (!t.trim())
279
- r = "<!DOCTYPE html><html><head></head><body></body></html>";
288
+ o = "<!DOCTYPE html><html><head></head><body></body></html>";
280
289
  else {
281
- const M = new DOMParser().parseFromString(t, "text/html"), ge = ((y = M.documentElement) == null ? void 0 : y.tagName.toLowerCase()) === "html", Ft = ((I = M.head) == null ? void 0 : I.tagName.toLowerCase()) === "head", Rt = ((Y = M.body) == null ? void 0 : Y.tagName.toLowerCase()) === "body";
282
- if (!ge || !Ft || !Rt) {
283
- const $t = M.body ? M.body.innerHTML : t;
284
- r = `<!DOCTYPE html><html><head>${M.head ? M.head.innerHTML : ""}</head><body>${$t}</body></html>`;
290
+ const M = new DOMParser().parseFromString(t, "text/html"), ye = ((p = M.documentElement) == null ? void 0 : p.tagName.toLowerCase()) === "html", Rt = ((I = M.head) == null ? void 0 : I.tagName.toLowerCase()) === "head", $t = ((K = M.body) == null ? void 0 : K.tagName.toLowerCase()) === "body";
291
+ if (!ye || !Rt || !$t) {
292
+ const zt = M.body ? M.body.innerHTML : t;
293
+ o = `<!DOCTYPE html><html><head>${M.head ? M.head.innerHTML : ""}</head><body>${zt}</body></html>`;
285
294
  } else
286
- r = `<!DOCTYPE html>${M.documentElement.outerHTML}`;
295
+ o = `<!DOCTYPE html>${M.documentElement.outerHTML}`;
287
296
  }
288
- const h = ["script", "iframe", "object", "embed", "canvas"], b = new DOMParser().parseFromString(r, "text/html");
289
- return h.forEach((K) => {
290
- b.querySelectorAll(K).forEach((ge) => ge.remove());
291
- }), r = `<!DOCTYPE html>${b.documentElement.outerHTML}`, r;
297
+ const c = ["script", "iframe", "object", "embed", "canvas"], b = new DOMParser().parseFromString(o, "text/html");
298
+ return c.forEach((X) => {
299
+ b.querySelectorAll(X).forEach((ye) => ye.remove());
300
+ }), o = `<!DOCTYPE html>${b.documentElement.outerHTML}`, o;
292
301
  }, Be = J(
293
- () => lt(T, C),
294
- [C, T]
295
- ), ne = J(() => Vt(Be), [Be]);
296
- zt(
297
- Z,
302
+ () => st(E, w),
303
+ [w, E]
304
+ ), ie = J(() => Tt(Be), [Be]);
305
+ Ot(
306
+ ee,
298
307
  () => ({
299
- getValue: () => S(),
300
- getPreviewHtml: () => lt(S(), R.current),
301
- scanVariables: () => q(S()),
308
+ getValue: () => D(),
309
+ getPreviewHtml: () => st(D(), T.current),
310
+ scanVariables: () => Y(D()),
302
311
  getVariables: (e) => {
303
- const t = q(S());
312
+ const t = Y(D());
304
313
  return e == null || e(t), t;
305
314
  },
306
315
  validateVariables: ae,
307
316
  showVariables: () => P("variables")
308
317
  }),
309
- [S, q, ae]
310
- ), X(() => {
311
- oe.current && oe.current.srcdoc !== ne && (oe.current.srcdoc = ne);
312
- }, [ne]);
313
- const Tt = (e, t) => {
314
- t !== null && pt(t);
315
- }, Ct = (e, t) => {
316
- (t === "desktop" || t === "mobile") && ft(t);
317
- }, ie = D(
318
+ [D, Y, ae]
319
+ ), G(() => {
320
+ ne.current && ne.current.srcdoc !== ie && (ne.current.srcdoc = ie);
321
+ }, [ie]);
322
+ const Ct = (e, t) => {
323
+ t !== null && ft(t);
324
+ }, wt = (e, t) => {
325
+ (t === "desktop" || t === "mobile") && xt(t);
326
+ }, le = L(
318
327
  (e) => {
319
- var h, v;
320
- const t = be.current;
328
+ var c, y;
329
+ const t = fe.current;
321
330
  if (t != null && t.state && (t != null && t.dispatch)) {
322
- const b = (h = t.state.selection) == null ? void 0 : h.main, y = t.state.doc.toString(), I = (b == null ? void 0 : b.from) ?? t.state.doc.length, Y = (b == null ? void 0 : b.to) ?? I, K = `${y.slice(0, I)}${e}${y.slice(Y)}`;
331
+ const b = (c = t.state.selection) == null ? void 0 : c.main, p = t.state.doc.toString(), I = (b == null ? void 0 : b.from) ?? t.state.doc.length, K = (b == null ? void 0 : b.to) ?? I, X = `${p.slice(0, I)}${e}${p.slice(K)}`;
323
332
  return t.dispatch({
324
- changes: { from: I, to: Y, insert: e },
333
+ changes: { from: I, to: K, insert: e },
325
334
  selection: { anchor: I + e.length }
326
- }), (v = t.focus) == null || v.call(t), fe(K), K;
335
+ }), (y = t.focus) == null || y.call(t), ge(X), X;
327
336
  }
328
- const r = `${T}${e}`;
329
- return fe(r), r;
337
+ const o = `${E}${e}`;
338
+ return ge(o), o;
330
339
  },
331
- [T]
332
- ), wt = D(
340
+ [E]
341
+ ), Ht = L(
333
342
  (e, t) => {
334
- const r = R.current;
335
- k(
336
- r.map(
337
- (h) => h.variableInstanceId === e ? { ...h, default: t } : h
343
+ const o = T.current;
344
+ A(
345
+ o.map(
346
+ (c) => c.variableInstanceId === e ? { ...c, default: t } : c
338
347
  )
339
348
  );
340
349
  },
341
- [k]
342
- ), Ht = D(
350
+ [A]
351
+ ), St = L(
343
352
  (e, t) => {
344
- if (!st(e, t)) return;
345
- const h = ie(Cr(e, t)), v = de(h), b = Ie(v, R.current);
346
- k(b), P("variables");
353
+ if (!ct(e, t)) return;
354
+ const c = le(wr(e, t)), y = Z(c), b = ue(y, T.current);
355
+ A(b), P("variables");
347
356
  },
348
- [ie, k]
349
- ), le = J(() => {
357
+ [le, A]
358
+ ), se = J(() => {
350
359
  const e = _.trim();
351
- return e ? A.test(e) ? Tr(e) || C.some((t) => t.type === "user" && t.attribute === e) ? l("text.variables.customVariableNameDuplicate") : "" : l("text.variables.customVariableNameInvalid") : l("text.variables.customVariableNameRequired");
352
- }, [_, C]), St = D(() => {
360
+ return e ? F.test(e) ? Cr(e) || w.some((t) => t.type === "user" && t.attribute === e) ? l("text.variables.customVariableNameDuplicate") : "" : l("text.variables.customVariableNameInvalid") : l("text.variables.customVariableNameRequired");
361
+ }, [_, w]), Dt = L(() => {
353
362
  const e = W.trim();
354
- if (te(!0), re(!0), le || e === "") return;
355
- const t = st(_.trim(), "user", e);
363
+ if (re(!0), oe(!0), se || e === "") return;
364
+ const t = ct(_.trim(), "user", e);
356
365
  if (!t) return;
357
- const r = ie(t.variable), h = de(r), v = Ie(h, R.current);
366
+ const o = le(t.variable), c = Z(o), y = ue(c, T.current);
358
367
  let b = -1;
359
- for (let y = v.length - 1; y >= 0; y -= 1) {
360
- const I = v[y];
368
+ for (let p = y.length - 1; p >= 0; p -= 1) {
369
+ const I = y[p];
361
370
  if (I.type === t.type && I.attribute === t.attribute && I.default === "") {
362
- b = y;
371
+ b = p;
363
372
  break;
364
373
  }
365
374
  }
366
- k(
367
- v.map(
368
- (y, I) => I === b ? { ...y, default: t.default } : y
375
+ A(
376
+ y.map(
377
+ (p, I) => I === b ? { ...p, default: t.default } : p
369
378
  )
370
- ), Me(""), De(""), te(!1), re(!1), P("variables");
371
- }, [W, _, le, ie, k]), Mt = J(() => {
379
+ ), De(""), Me(""), re(!1), oe(!1), P("variables");
380
+ }, [W, _, se, le, A]), Mt = J(() => {
372
381
  const e = /* @__PURE__ */ new Set();
373
- return [{ id: "custom", items: C.filter((r) => r.type === "user").filter((r) => !Ee.some((h) => h.items.some((v) => v.name === r.attribute))).filter((r) => e.has(r.attribute) ? !1 : (e.add(r.attribute), !0)).map((r) => ({
374
- name: r.attribute,
375
- labelKey: r.attribute,
382
+ return [{ id: "custom", items: w.filter((o) => o.type === "user").filter((o) => !Ve.some((c) => c.items.some((y) => y.name === o.attribute))).filter((o) => e.has(o.attribute) ? !1 : (e.add(o.attribute), !0)).map((o) => ({
383
+ name: o.attribute,
384
+ labelKey: o.attribute,
376
385
  kind: "user"
377
- })) }, ...Ee];
378
- }, [C]), se = J(
379
- () => C.filter((e) => e.type !== "system"),
380
- [C]
381
- ), Dt = (e) => e === "custom" ? "text.variables.groupCustom" : e === "contacts" ? "text.variables.groupContacts" : e === "email" ? "text.variables.groupEmail" : e === "organization" ? "text.variables.groupOrganization" : e === "date" ? "text.variables.groupDate" : "text.variables.groupLinks", V = er(), Lt = O === "desktop" || O === "mobile" ? O : "desktop", kt = H === "split" || H === "code" || H === "preview" ? H : "split";
382
- ($e = (Re = V.palette) == null ? void 0 : Re.action) == null || $e.selected, (ze = (Ne = V.palette) == null ? void 0 : Ne.primary) == null || ze.main, (Pe = (Oe = V.palette) == null ? void 0 : Oe.action) == null || Pe.selected, (We = (_e = V.palette) == null ? void 0 : _e.background) == null || We.paper, (Ge = (je = V.palette) == null ? void 0 : je.text) == null || Ge.primary, (qe = (Ue = V.palette) == null ? void 0 : Ue.action) == null || qe.hover;
386
+ })) }, ...Ve];
387
+ }, [w]), ce = J(
388
+ () => w.filter((e) => e.type !== "system"),
389
+ [w]
390
+ ), Lt = (e) => e === "custom" ? "text.variables.groupCustom" : e === "contacts" ? "text.variables.groupContacts" : e === "email" ? "text.variables.groupEmail" : e === "organization" ? "text.variables.groupOrganization" : e === "date" ? "text.variables.groupDate" : "text.variables.groupLinks", C = tr(), kt = O === "desktop" || O === "mobile" ? O : "desktop", Bt = S === "split" || S === "code" || S === "preview" ? S : "split";
391
+ ($e = (Re = C.palette) == null ? void 0 : Re.action) == null || $e.selected, (Ne = (ze = C.palette) == null ? void 0 : ze.primary) == null || Ne.main, (Pe = (Oe = C.palette) == null ? void 0 : Oe.action) == null || Pe.selected, (We = (_e = C.palette) == null ? void 0 : _e.background) == null || We.paper, (Ge = (je = C.palette) == null ? void 0 : je.text) == null || Ge.primary, (Ue = (qe = C.palette) == null ? void 0 : qe.action) == null || Ue.hover;
383
392
  const j = {
384
393
  tooltip: {
385
394
  sx: {
@@ -387,14 +396,14 @@ function Or({
387
396
  fontWeight: 400,
388
397
  lineHeight: 1.45,
389
398
  maxWidth: 360,
390
- backgroundColor: ce(((Ke = (Ye = V.palette) == null ? void 0 : Ye.text) == null ? void 0 : Ke.primary) ?? "#1F1F21", 0.9),
391
- color: ((Je = (Xe = V.palette) == null ? void 0 : Xe.common) == null ? void 0 : Je.white) ?? "#fff"
399
+ backgroundColor: de(((Ke = (Ye = C.palette) == null ? void 0 : Ye.text) == null ? void 0 : Ke.primary) ?? "#1F1F21", 0.9),
400
+ color: ((Je = (Xe = C.palette) == null ? void 0 : Xe.common) == null ? void 0 : Je.white) ?? "#fff"
392
401
  }
393
402
  },
394
403
  arrow: {
395
- sx: { color: ce(((Ze = (Qe = V.palette) == null ? void 0 : Qe.text) == null ? void 0 : Ze.primary) ?? "#1F1F21", 0.9) }
404
+ sx: { color: de(((Ze = (Qe = C.palette) == null ? void 0 : Qe.text) == null ? void 0 : Ze.primary) ?? "#1F1F21", 0.9) }
396
405
  }
397
- }, xe = {
406
+ }, ve = {
398
407
  component: "div",
399
408
  sx: {
400
409
  mt: 0.5,
@@ -402,21 +411,21 @@ function Or({
402
411
  minHeight: 18,
403
412
  lineHeight: 1.5
404
413
  }
405
- }, Ae = () => /* @__PURE__ */ f(
406
- m,
414
+ }, Ae = () => /* @__PURE__ */ x(
415
+ h,
407
416
  {
408
417
  sx: {
409
- height: x,
418
+ height: g,
410
419
  minHeight: 0,
411
420
  display: "flex",
412
421
  flexDirection: "column",
413
422
  position: "relative",
414
- borderRight: H === "split" ? "1px solid" : "none",
423
+ borderRight: S === "split" ? "1px solid" : "none",
415
424
  borderColor: "divider"
416
425
  },
417
426
  children: [
418
- /* @__PURE__ */ o(
419
- m,
427
+ /* @__PURE__ */ r(
428
+ h,
420
429
  {
421
430
  sx: {
422
431
  flex: 1,
@@ -446,16 +455,16 @@ function Or({
446
455
  opacity: 1
447
456
  }
448
457
  },
449
- children: /* @__PURE__ */ o(
450
- Ot,
458
+ children: /* @__PURE__ */ r(
459
+ Pt,
451
460
  {
452
- value: T,
461
+ value: E,
453
462
  height: "100%",
454
- extensions: [Pt()],
455
- theme: Ce[He] || ut,
456
- onChange: fe,
463
+ extensions: [_t()],
464
+ theme: we[Se] || mt,
465
+ onChange: ge,
457
466
  onCreateEditor: (e) => {
458
- be.current = e;
467
+ fe.current = e;
459
468
  },
460
469
  basicSetup: {
461
470
  lineNumbers: !0,
@@ -467,13 +476,13 @@ function Or({
467
476
  )
468
477
  }
469
478
  ),
470
- /* @__PURE__ */ o(
471
- ve,
479
+ /* @__PURE__ */ r(
480
+ Ie,
472
481
  {
473
482
  size: "small",
474
483
  variant: "contained",
475
- startIcon: /* @__PURE__ */ o(Mr, { fontSize: "small" }),
476
- onClick: Et,
484
+ startIcon: /* @__PURE__ */ r(Mr, { fontSize: "small" }),
485
+ onClick: Vt,
477
486
  sx: {
478
487
  position: "absolute",
479
488
  right: 16,
@@ -487,15 +496,15 @@ function Or({
487
496
  )
488
497
  ]
489
498
  }
490
- ), Bt = () => /* @__PURE__ */ o(m, { sx: {
499
+ ), At = () => /* @__PURE__ */ r(h, { sx: {
491
500
  height: i,
492
501
  overflow: "auto",
493
502
  backgroundColor: "#F5F5F5",
494
503
  padding: O === "mobile" ? "32px 16px" : "16px",
495
504
  display: "flex",
496
505
  justifyContent: "center"
497
- }, children: /* @__PURE__ */ o(
498
- m,
506
+ }, children: /* @__PURE__ */ r(
507
+ h,
499
508
  {
500
509
  sx: {
501
510
  width: "100%",
@@ -504,11 +513,11 @@ function Or({
504
513
  border: "none",
505
514
  overflow: "hidden"
506
515
  },
507
- children: /* @__PURE__ */ o(
516
+ children: /* @__PURE__ */ r(
508
517
  "iframe",
509
518
  {
510
- ref: oe,
511
- srcDoc: ne,
519
+ ref: ne,
520
+ srcDoc: ie,
512
521
  style: {
513
522
  width: "100%",
514
523
  height: "100%",
@@ -520,8 +529,8 @@ function Or({
520
529
  }
521
530
  )
522
531
  }
523
- ) }), At = () => /* @__PURE__ */ f(
524
- m,
532
+ ) }), Ft = () => /* @__PURE__ */ x(
533
+ h,
525
534
  {
526
535
  ref: Le,
527
536
  sx: {
@@ -535,23 +544,23 @@ function Or({
535
544
  pb: 6
536
545
  },
537
546
  children: [
538
- /* @__PURE__ */ o(m, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 1, mb: 1.5 }, children: /* @__PURE__ */ f(m, { sx: { minWidth: 0 }, children: [
539
- /* @__PURE__ */ f(m, { sx: { display: "flex", alignItems: "center", gap: 0.75 }, children: [
540
- /* @__PURE__ */ o(B, { variant: "subtitle1", sx: { fontWeight: 700 }, children: l("htmlEditor.variables.title") }),
541
- /* @__PURE__ */ o(G, { title: l("htmlEditor.variables.help"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(m, { component: "span", sx: { display: "inline-flex", color: "text.secondary", cursor: "help" }, children: /* @__PURE__ */ o(Lr, { fontSize: "small" }) }) })
547
+ /* @__PURE__ */ r(h, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 1, mb: 1.5 }, children: /* @__PURE__ */ x(h, { sx: { minWidth: 0 }, children: [
548
+ /* @__PURE__ */ x(h, { sx: { display: "flex", alignItems: "center", gap: 0.75 }, children: [
549
+ /* @__PURE__ */ r(k, { variant: "subtitle1", sx: { fontWeight: 700 }, children: l("htmlEditor.variables.title") }),
550
+ /* @__PURE__ */ r(q, { title: l("htmlEditor.variables.help"), arrow: !0, slotProps: j, children: /* @__PURE__ */ r(h, { component: "span", sx: { display: "inline-flex", color: "text.secondary", cursor: "help" }, children: /* @__PURE__ */ r(kr, { fontSize: "small" }) }) })
542
551
  ] }),
543
- /* @__PURE__ */ o(B, { component: "div", variant: "body2", color: "text.secondary", children: l("htmlEditor.variables.scanHint") })
552
+ /* @__PURE__ */ r(k, { component: "div", variant: "body2", color: "text.secondary", children: l("htmlEditor.variables.scanHint") })
544
553
  ] }) }),
545
- /* @__PURE__ */ o(m, { sx: { mb: 2 }, children: Mt.map((e) => {
546
- const t = yt === e.id;
547
- return /* @__PURE__ */ f(
548
- nr,
554
+ /* @__PURE__ */ r(h, { sx: { mb: 2 }, children: Mt.map((e) => {
555
+ const t = It === e.id;
556
+ return /* @__PURE__ */ x(
557
+ ir,
549
558
  {
550
559
  disableGutters: !0,
551
560
  square: !0,
552
561
  elevation: 0,
553
562
  expanded: t,
554
- onChange: (r, h) => It(h ? e.id : null),
563
+ onChange: (o, c) => Et(c ? e.id : null),
555
564
  sx: {
556
565
  "&:before": { display: "none" },
557
566
  border: 1,
@@ -561,66 +570,66 @@ function Or({
561
570
  mb: 1
562
571
  },
563
572
  children: [
564
- /* @__PURE__ */ o(
565
- ir,
573
+ /* @__PURE__ */ r(
574
+ lr,
566
575
  {
567
- expandIcon: /* @__PURE__ */ o(Dr, { fontSize: "small" }),
576
+ expandIcon: /* @__PURE__ */ r(Lr, { fontSize: "small" }),
568
577
  sx: {
569
578
  minHeight: 44,
570
579
  "& .MuiAccordionSummary-content": { my: 1 }
571
580
  },
572
- children: /* @__PURE__ */ o(B, { component: "div", variant: "body2", color: "text.primary", children: l(Dt(e.id)) })
581
+ children: /* @__PURE__ */ r(k, { component: "div", variant: "body2", color: "text.primary", children: l(Lt(e.id)) })
573
582
  }
574
583
  ),
575
- /* @__PURE__ */ f(lr, { sx: { pt: 0, pb: 1.25 }, children: [
576
- e.id === "custom" && /* @__PURE__ */ f(m, { sx: { mb: 1 }, children: [
577
- /* @__PURE__ */ o(
578
- ye,
584
+ /* @__PURE__ */ x(sr, { sx: { pt: 0, pb: 1.25 }, children: [
585
+ e.id === "custom" && /* @__PURE__ */ x(h, { sx: { mb: 1 }, children: [
586
+ /* @__PURE__ */ r(
587
+ Ee,
579
588
  {
580
589
  size: "small",
581
590
  fullWidth: !0,
582
591
  label: l("text.variables.customVariableName"),
583
592
  value: _,
584
593
  placeholder: "e.g. order_id",
585
- onChange: (r) => {
586
- Me(r.target.value), !me && r.target.value.trim() !== "" && te(!0);
594
+ onChange: (o) => {
595
+ De(o.target.value), !be && o.target.value.trim() !== "" && re(!0);
587
596
  },
588
597
  onBlur: () => {
589
- _.trim() !== "" && te(!0);
598
+ _.trim() !== "" && re(!0);
590
599
  },
591
- error: me && !!le,
592
- helperText: me && le || " ",
593
- FormHelperTextProps: xe,
600
+ error: be && !!se,
601
+ helperText: be && se || " ",
602
+ FormHelperTextProps: ve,
594
603
  sx: { mb: 1 }
595
604
  }
596
605
  ),
597
- /* @__PURE__ */ o(
598
- ye,
606
+ /* @__PURE__ */ r(
607
+ Ee,
599
608
  {
600
609
  size: "small",
601
610
  fullWidth: !0,
602
611
  label: l("text.variables.defaultValueLabel"),
603
612
  value: W,
604
613
  placeholder: l("text.variables.defaultPlaceholder"),
605
- onChange: (r) => {
606
- De(r.target.value), !he && r.target.value.trim() !== "" && re(!0);
614
+ onChange: (o) => {
615
+ Me(o.target.value), !pe && o.target.value.trim() !== "" && oe(!0);
607
616
  },
608
617
  onBlur: () => {
609
- W.trim() !== "" && re(!0);
618
+ W.trim() !== "" && oe(!0);
610
619
  },
611
- error: he && W.trim() === "",
612
- helperText: he && W.trim() === "" ? l("text.variables.defaultRequired") : " ",
613
- FormHelperTextProps: xe
620
+ error: pe && W.trim() === "",
621
+ helperText: pe && W.trim() === "" ? l("text.variables.defaultRequired") : " ",
622
+ FormHelperTextProps: ve
614
623
  }
615
624
  ),
616
- /* @__PURE__ */ o(
617
- ve,
625
+ /* @__PURE__ */ r(
626
+ Ie,
618
627
  {
619
628
  fullWidth: !0,
620
629
  size: "small",
621
630
  variant: "outlined",
622
- startIcon: /* @__PURE__ */ o(Hr, { fontSize: "small" }),
623
- onClick: St,
631
+ startIcon: /* @__PURE__ */ r(Sr, { fontSize: "small" }),
632
+ onClick: Dt,
624
633
  sx: {
625
634
  justifyContent: "center",
626
635
  borderColor: "divider",
@@ -632,33 +641,33 @@ function Or({
632
641
  }
633
642
  )
634
643
  ] }),
635
- e.items.length > 0 && /* @__PURE__ */ o(m, { sx: { display: "grid", gap: 0.75 }, children: e.items.map((r) => /* @__PURE__ */ o(
636
- ve,
644
+ e.items.length > 0 && /* @__PURE__ */ r(h, { sx: { display: "grid", gap: 0.75 }, children: e.items.map((o) => /* @__PURE__ */ r(
645
+ Ie,
637
646
  {
638
647
  size: "small",
639
648
  variant: "outlined",
640
- onClick: () => Ht(r.name, r.kind),
649
+ onClick: () => St(o.name, o.kind),
641
650
  sx: {
642
651
  justifyContent: "flex-start",
643
652
  borderColor: "divider",
644
653
  color: "text.secondary",
645
654
  textTransform: "none"
646
655
  },
647
- children: /* @__PURE__ */ f(m, { sx: { textAlign: "left", minWidth: 0 }, children: [
648
- /* @__PURE__ */ o(B, { component: "div", variant: "body2", color: "text.primary", children: e.id === "custom" ? r.name : l(r.labelKey) }),
649
- /* @__PURE__ */ o(
650
- B,
656
+ children: /* @__PURE__ */ x(h, { sx: { textAlign: "left", minWidth: 0 }, children: [
657
+ /* @__PURE__ */ r(k, { component: "div", variant: "body2", color: "text.primary", children: e.id === "custom" ? o.name : l(o.labelKey) }),
658
+ /* @__PURE__ */ r(
659
+ k,
651
660
  {
652
661
  component: "div",
653
662
  variant: "caption",
654
663
  color: "text.secondary",
655
664
  sx: { fontFamily: "monospace" },
656
- children: r.kind === "builtin" ? `{%${r.name}%}` : `{{${r.name}}}`
665
+ children: o.kind === "builtin" ? `{%${o.name}%}` : `{{${o.name}}}`
657
666
  }
658
667
  )
659
668
  ] })
660
669
  },
661
- `${e.id}:${r.name}`
670
+ `${e.id}:${o.name}`
662
671
  )) })
663
672
  ] })
664
673
  ]
@@ -666,11 +675,11 @@ function Or({
666
675
  e.id
667
676
  );
668
677
  }) }),
669
- /* @__PURE__ */ o(sr, { sx: { my: 2 } }),
670
- /* @__PURE__ */ o(B, { component: "div", ref: ke, variant: "subtitle2", sx: { mb: 0.5 }, children: l("htmlEditor.variables.detected") }),
671
- /* @__PURE__ */ o(B, { component: "div", variant: "caption", color: "text.secondary", sx: { display: "block", mb: 1 }, children: l("htmlEditor.variables.defaultHelp") }),
672
- se.length === 0 ? /* @__PURE__ */ o(
673
- m,
678
+ /* @__PURE__ */ r(cr, { sx: { my: 2 } }),
679
+ /* @__PURE__ */ r(k, { component: "div", ref: ke, variant: "subtitle2", sx: { mb: 0.5 }, children: l("htmlEditor.variables.detected") }),
680
+ /* @__PURE__ */ r(k, { component: "div", variant: "caption", color: "text.secondary", sx: { display: "block", mb: 1 }, children: l("htmlEditor.variables.defaultHelp") }),
681
+ ce.length === 0 ? /* @__PURE__ */ r(
682
+ h,
674
683
  {
675
684
  sx: {
676
685
  border: "1px dashed",
@@ -683,32 +692,32 @@ function Or({
683
692
  },
684
693
  children: l("htmlEditor.variables.empty")
685
694
  }
686
- ) : /* @__PURE__ */ o(m, { sx: { display: "grid", gap: 0.25 }, children: se.map((e, t) => {
687
- const r = gt && e.type === "user" && e.default.trim() === "", h = se.filter((b) => b.type === e.type && b.attribute === e.attribute).length, v = se.slice(0, t + 1).filter((b) => b.type === e.type && b.attribute === e.attribute).length;
688
- return /* @__PURE__ */ f(
689
- m,
695
+ ) : /* @__PURE__ */ r(h, { sx: { display: "grid", gap: 0.75 }, children: ce.map((e, t) => {
696
+ const o = e.type === "user" && nt(e.attribute, "user"), c = vt && o && e.default.trim() === "", y = ce.filter((p) => p.type === e.type && p.attribute === e.attribute).length, b = ce.slice(0, t + 1).filter((p) => p.type === e.type && p.attribute === e.attribute).length;
697
+ return /* @__PURE__ */ x(
698
+ h,
690
699
  {
691
700
  sx: {
692
701
  display: "grid",
693
702
  gridTemplateColumns: { xs: "1fr", sm: "minmax(150px, 42%) 1fr" },
694
- alignItems: r ? "flex-start" : "center",
703
+ alignItems: c ? "flex-start" : "center",
695
704
  gap: 1,
696
705
  px: 1,
697
706
  py: 0.75,
698
707
  border: "1px solid",
699
- borderColor: r ? "error.main" : "transparent",
708
+ borderColor: c ? "error.main" : "transparent",
700
709
  borderRadius: 1,
701
- borderBottomColor: r ? "error.main" : "divider",
702
- backgroundColor: r ? ce(V.palette.error.main, 0.04) : "transparent",
710
+ borderBottomColor: c ? "error.main" : "divider",
711
+ backgroundColor: c ? de(C.palette.error.main, 0.04) : "transparent",
703
712
  transition: "background-color 120ms ease, border-color 120ms ease",
704
713
  "&:hover": {
705
- backgroundColor: r ? ce(V.palette.error.main, 0.04) : "action.hover",
706
- borderColor: r ? "error.main" : "divider"
714
+ backgroundColor: c ? de(C.palette.error.main, 0.04) : "action.hover",
715
+ borderColor: c ? "error.main" : "divider"
707
716
  }
708
717
  },
709
718
  children: [
710
- /* @__PURE__ */ o(
711
- B,
719
+ /* @__PURE__ */ r(
720
+ k,
712
721
  {
713
722
  component: "div",
714
723
  variant: "body2",
@@ -717,32 +726,35 @@ function Or({
717
726
  fontSize: 13,
718
727
  lineHeight: 1.35,
719
728
  wordBreak: "break-all",
720
- color: r ? "error.main" : "text.primary"
729
+ color: c ? "error.main" : "text.primary"
721
730
  },
722
- children: h > 1 ? `${e.variable} (${v})` : e.variable
731
+ children: y > 1 ? `${e.variable} (${b})` : e.variable
723
732
  }
724
733
  ),
725
- /* @__PURE__ */ o(
726
- ye,
734
+ o ? /* @__PURE__ */ r(
735
+ Ee,
727
736
  {
728
737
  size: "small",
729
738
  fullWidth: !0,
730
- disabled: e.type === "system",
731
739
  value: e.default,
732
- label: r ? l("text.variables.defaultValueLabel") : void 0,
733
- placeholder: e.type === "system" ? l("htmlEditor.variables.systemDefault") : l("text.variables.defaultPlaceholder"),
734
- error: r,
735
- helperText: r ? l("text.variables.defaultRequired") : void 0,
736
- FormHelperTextProps: xe,
737
- onChange: (b) => wt(e.variableInstanceId, b.target.value),
740
+ label: c ? l("text.variables.defaultValueLabel") : void 0,
741
+ placeholder: l("text.variables.defaultPlaceholder"),
742
+ error: c,
743
+ helperText: c ? l("text.variables.defaultRequired") : " ",
744
+ FormHelperTextProps: ve,
745
+ onChange: (p) => Ht(e.variableInstanceId, p.target.value),
738
746
  sx: {
747
+ "& .MuiOutlinedInput-root": {
748
+ minHeight: 40,
749
+ alignItems: "center"
750
+ },
739
751
  "& .MuiInputBase-input": {
740
- py: 0.75,
752
+ py: 1.25,
741
753
  fontSize: 13
742
754
  }
743
755
  }
744
756
  }
745
- )
757
+ ) : /* @__PURE__ */ r(k, { component: "div", variant: "body2", color: "text.secondary", sx: { fontSize: 13 }, children: l("htmlEditor.variables.systemDefault") })
746
758
  ]
747
759
  },
748
760
  e.variableInstanceId || `${e.type}:${e.attribute}:${e.id}`
@@ -750,11 +762,11 @@ function Or({
750
762
  }) })
751
763
  ]
752
764
  }
753
- ), Fe = () => /* @__PURE__ */ f(m, { sx: { height: i, minHeight: 0, display: "flex", flexDirection: "column" }, children: [
754
- /* @__PURE__ */ f(
765
+ ), Fe = () => /* @__PURE__ */ x(h, { sx: { height: i, minHeight: 0, display: "flex", flexDirection: "column" }, children: [
766
+ /* @__PURE__ */ x(
755
767
  ar,
756
768
  {
757
- value: ee,
769
+ value: te,
758
770
  onChange: (e, t) => P(t),
759
771
  sx: {
760
772
  minHeight: 40,
@@ -767,15 +779,15 @@ function Or({
767
779
  }
768
780
  },
769
781
  children: [
770
- /* @__PURE__ */ o(ot, { value: "preview", label: l("htmlEditor.tabs.preview") }),
771
- /* @__PURE__ */ o(ot, { value: "variables", label: l("htmlEditor.tabs.variables") })
782
+ /* @__PURE__ */ r(ot, { value: "preview", label: l("htmlEditor.tabs.preview") }),
783
+ /* @__PURE__ */ r(ot, { value: "variables", label: l("htmlEditor.tabs.variables") })
772
784
  ]
773
785
  }
774
786
  ),
775
- /* @__PURE__ */ o(m, { sx: { flex: 1, minHeight: 0, overflow: "hidden", display: "flex", flexDirection: "column" }, children: ee === "preview" ? Bt() : At() })
787
+ /* @__PURE__ */ r(h, { sx: { flex: 1, minHeight: 0, overflow: "hidden", display: "flex", flexDirection: "column" }, children: te === "preview" ? At() : Ft() })
776
788
  ] });
777
- return /* @__PURE__ */ f(
778
- m,
789
+ return /* @__PURE__ */ x(
790
+ h,
779
791
  {
780
792
  sx: {
781
793
  display: "flex",
@@ -784,11 +796,11 @@ function Or({
784
796
  width: "100%",
785
797
  minHeight: 0,
786
798
  minWidth: 0,
787
- ...u
799
+ ...m
788
800
  },
789
801
  children: [
790
- p && /* @__PURE__ */ f(
791
- m,
802
+ f && /* @__PURE__ */ x(
803
+ h,
792
804
  {
793
805
  sx: {
794
806
  display: "flex",
@@ -800,55 +812,55 @@ function Or({
800
812
  backgroundColor: "background.paper"
801
813
  },
802
814
  children: [
803
- /* @__PURE__ */ f(m, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
804
- /* @__PURE__ */ f(
815
+ /* @__PURE__ */ x(h, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
816
+ /* @__PURE__ */ x(
805
817
  et,
806
818
  {
807
- value: kt,
819
+ value: Bt,
808
820
  exclusive: !0,
809
- onChange: Tt,
821
+ onChange: Ct,
810
822
  size: "small",
811
823
  "aria-label": l("htmlEditor.mode.split"),
812
824
  children: [
813
- /* @__PURE__ */ o(G, { title: l("htmlEditor.tooltips.splitView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
825
+ /* @__PURE__ */ r(q, { title: l("htmlEditor.tooltips.splitView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ r(
814
826
  Q,
815
827
  {
816
828
  value: "split",
817
829
  "aria-label": l("htmlEditor.mode.split"),
818
- children: /* @__PURE__ */ o(Br, { fontSize: "small" })
830
+ children: /* @__PURE__ */ r(Ar, { fontSize: "small" })
819
831
  }
820
832
  ) }),
821
- /* @__PURE__ */ o(G, { title: l("htmlEditor.tooltips.codeOnly"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
833
+ /* @__PURE__ */ r(q, { title: l("htmlEditor.tooltips.codeOnly"), arrow: !0, slotProps: j, children: /* @__PURE__ */ r(
822
834
  Q,
823
835
  {
824
836
  value: "code",
825
837
  "aria-label": l("htmlEditor.mode.code"),
826
- children: /* @__PURE__ */ o(Sr, { fontSize: "small" })
838
+ children: /* @__PURE__ */ r(Dr, { fontSize: "small" })
827
839
  }
828
840
  ) }),
829
- /* @__PURE__ */ o(G, { title: l("htmlEditor.tooltips.previewOnly"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
841
+ /* @__PURE__ */ r(q, { title: l("htmlEditor.tooltips.previewOnly"), arrow: !0, slotProps: j, children: /* @__PURE__ */ r(
830
842
  Q,
831
843
  {
832
844
  value: "preview",
833
845
  "aria-label": l("htmlEditor.mode.preview"),
834
- children: /* @__PURE__ */ o(kr, { fontSize: "small" })
846
+ children: /* @__PURE__ */ r(Br, { fontSize: "small" })
835
847
  }
836
848
  ) })
837
849
  ]
838
850
  }
839
851
  ),
840
- /* @__PURE__ */ f(tr, { size: "small", sx: { minWidth: 140 }, children: [
841
- /* @__PURE__ */ o(rr, { id: "theme-select-label", children: l("htmlEditor.theme") }),
842
- /* @__PURE__ */ f(
843
- or,
852
+ /* @__PURE__ */ x(rr, { size: "small", sx: { minWidth: 140 }, children: [
853
+ /* @__PURE__ */ r(or, { id: "theme-select-label", children: l("htmlEditor.theme") }),
854
+ /* @__PURE__ */ x(
855
+ nr,
844
856
  {
845
857
  labelId: "theme-select-label",
846
858
  id: "theme-select",
847
- value: He,
859
+ value: Se,
848
860
  label: l("htmlEditor.theme"),
849
861
  onChange: (e) => {
850
862
  const t = e.target.value;
851
- xt(t), zr(t);
863
+ gt(t), Or(t);
852
864
  },
853
865
  sx: {
854
866
  // fontSize: '0.875rem',
@@ -857,38 +869,38 @@ function Or({
857
869
  }
858
870
  },
859
871
  children: [
860
- /* @__PURE__ */ o(tt, { children: l("htmlEditor.lightThemes") }),
861
- Object.entries(Rr).map(([e, t]) => /* @__PURE__ */ o(rt, { value: e, children: t }, e)),
862
- /* @__PURE__ */ o(tt, { children: l("htmlEditor.darkThemes") }),
863
- Object.entries($r).map(([e, t]) => /* @__PURE__ */ o(rt, { value: e, children: t }, e))
872
+ /* @__PURE__ */ r(tt, { children: l("htmlEditor.lightThemes") }),
873
+ Object.entries($r).map(([e, t]) => /* @__PURE__ */ r(rt, { value: e, children: t }, e)),
874
+ /* @__PURE__ */ r(tt, { children: l("htmlEditor.darkThemes") }),
875
+ Object.entries(zr).map(([e, t]) => /* @__PURE__ */ r(rt, { value: e, children: t }, e))
864
876
  ]
865
877
  }
866
878
  )
867
879
  ] })
868
880
  ] }),
869
- /* @__PURE__ */ o(m, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: H !== "code" && /* @__PURE__ */ f(
881
+ /* @__PURE__ */ r(h, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: S !== "code" && /* @__PURE__ */ x(
870
882
  et,
871
883
  {
872
- value: Lt,
884
+ value: kt,
873
885
  exclusive: !0,
874
- onChange: Ct,
886
+ onChange: wt,
875
887
  size: "small",
876
888
  "aria-label": l("htmlEditor.device.desktop"),
877
889
  children: [
878
- /* @__PURE__ */ o(G, { title: l("htmlEditor.tooltips.desktopView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
890
+ /* @__PURE__ */ r(q, { title: l("htmlEditor.tooltips.desktopView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ r(
879
891
  Q,
880
892
  {
881
893
  value: "desktop",
882
894
  "aria-label": l("htmlEditor.device.desktop"),
883
- children: /* @__PURE__ */ o(Ar, { fontSize: "small" })
895
+ children: /* @__PURE__ */ r(Fr, { fontSize: "small" })
884
896
  }
885
897
  ) }),
886
- /* @__PURE__ */ o(G, { title: l("htmlEditor.tooltips.mobileView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
898
+ /* @__PURE__ */ r(q, { title: l("htmlEditor.tooltips.mobileView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ r(
887
899
  Q,
888
900
  {
889
901
  value: "mobile",
890
902
  "aria-label": l("htmlEditor.device.mobile"),
891
- children: /* @__PURE__ */ o(Fr, { fontSize: "small" })
903
+ children: /* @__PURE__ */ r(Rr, { fontSize: "small" })
892
904
  }
893
905
  ) })
894
906
  ]
@@ -897,8 +909,8 @@ function Or({
897
909
  ]
898
910
  }
899
911
  ),
900
- /* @__PURE__ */ f(
901
- m,
912
+ /* @__PURE__ */ x(
913
+ h,
902
914
  {
903
915
  sx: {
904
916
  flex: 1,
@@ -908,12 +920,12 @@ function Or({
908
920
  overflow: "hidden"
909
921
  },
910
922
  children: [
911
- H === "split" && /* @__PURE__ */ f(Nt, { children: [
912
- /* @__PURE__ */ o(m, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Ae() }),
913
- /* @__PURE__ */ o(m, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Fe() })
923
+ S === "split" && /* @__PURE__ */ x(Nt, { children: [
924
+ /* @__PURE__ */ r(h, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Ae() }),
925
+ /* @__PURE__ */ r(h, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Fe() })
914
926
  ] }),
915
- H === "code" && /* @__PURE__ */ o(m, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Ae() }),
916
- H === "preview" && /* @__PURE__ */ o(m, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Fe() })
927
+ S === "code" && /* @__PURE__ */ r(h, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Ae() }),
928
+ S === "preview" && /* @__PURE__ */ r(h, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Fe() })
917
929
  ]
918
930
  }
919
931
  )
@@ -921,10 +933,10 @@ function Or({
921
933
  }
922
934
  );
923
935
  }
924
- const bt = dt(Or);
925
- bt.displayName = "HtmlEditorContent";
926
- const Pr = dt((a, n) => /* @__PURE__ */ o(Qt, { theme: vr, children: /* @__PURE__ */ o(
927
- Zt,
936
+ const pt = ut(Pr);
937
+ pt.displayName = "HtmlEditorContent";
938
+ const _r = ut((n, a) => /* @__PURE__ */ r(Zt, { theme: yr, children: /* @__PURE__ */ r(
939
+ er,
928
940
  {
929
941
  sx: {
930
942
  height: "100%",
@@ -934,11 +946,11 @@ const Pr = dt((a, n) => /* @__PURE__ */ o(Qt, { theme: vr, children: /* @__PURE_
934
946
  display: "flex",
935
947
  flexDirection: "column"
936
948
  },
937
- children: /* @__PURE__ */ o(bt, { ref: n, ...a })
949
+ children: /* @__PURE__ */ r(pt, { ref: a, ...n })
938
950
  }
939
951
  ) }));
940
- Pr.displayName = "HtmlEditor";
952
+ _r.displayName = "HtmlEditor";
941
953
  export {
942
- Pr as HtmlEditor,
943
- Pr as default
954
+ _r as HtmlEditor,
955
+ _r as default
944
956
  };