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