@questwork/p-templates-model 0.1.1 → 0.1.3

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,7 +1,7 @@
1
- import { TenantAwareEntity as Et, copySerializableProperties as w, copySerializableKeyValueObjects as Fe, Lifecycle as yt, TrackedEntity as Qe, EntityAction as Je, copySerializableValue as Ke } from "@questwork/q-utilities";
2
- import { Liquid as gt, TypeGuards as A, Tokenizer as _t } from "liquidjs";
3
- import Ot from "juice/client";
4
- const Pe = 2, Ze = Object.freeze([2]), y = Object.freeze({
1
+ import { TenantAwareEntity as Ot, copySerializableProperties as L, copySerializableKeyValueObjects as qe, Lifecycle as Ct, TrackedEntity as tt, EntityAction as nt, copySerializableValue as Ge } from "@questwork/q-utilities";
2
+ import { Liquid as At, TypeGuards as A, Tokenizer as Rt } from "liquidjs";
3
+ import Nt from "juice/client";
4
+ const Ie = 2, rt = Object.freeze([2]), y = Object.freeze({
5
5
  BLOCK_CONTEXT_MISMATCH: "BLOCK_CONTEXT_MISMATCH",
6
6
  BLOCK_DEPRECATED: "BLOCK_DEPRECATED",
7
7
  BLOCK_ELEMENT_INVALID: "BLOCK_ELEMENT_INVALID",
@@ -27,53 +27,53 @@ const Pe = 2, Ze = Object.freeze([2]), y = Object.freeze({
27
27
  UNKNOWN_BLOCK: "UNKNOWN_BLOCK",
28
28
  UNKNOWN_FUNCTION: "UNKNOWN_FUNCTION",
29
29
  VARIABLE_INVALID: "VARIABLE_INVALID"
30
- }), H = Object.freeze({
30
+ }), X = Object.freeze({
31
31
  ERROR: "ERROR",
32
32
  WARNING: "WARNING"
33
- }), Ie = Object.freeze(["blank", "empty", "false", "forloop", "nil", "null", "params", "true"]), F = "params", Y = /^[A-Z_]\w*$/i, P = Object.freeze({
33
+ }), De = Object.freeze(["blank", "empty", "false", "forloop", "nil", "null", "params", "true"]), F = "params", Q = /^[A-Z_]\w*$/i, P = Object.freeze({
34
34
  BOOLEAN: "boolean",
35
35
  DATE: "date",
36
36
  LIST: "list",
37
37
  NUMBER: "number",
38
38
  OBJECT: "object",
39
39
  STRING: "string"
40
- }), Ct = /* @__PURE__ */ new Set([P.BOOLEAN, P.DATE, P.NUMBER, P.STRING]), ne = Symbol("templateProjectionNode"), At = 10;
41
- class et {
40
+ }), St = /* @__PURE__ */ new Set([P.BOOLEAN, P.DATE, P.NUMBER, P.STRING]), se = Symbol("templateProjectionNode"), Lt = 10;
41
+ class it {
42
42
  constructor({ projectionCode: e, label: n, description: r, fields: i } = {}) {
43
43
  if (!e || typeof e != "string")
44
44
  throw new TypeError("TemplateProjection requires a projectionCode.");
45
- Object.defineProperty(this, ne, {
45
+ Object.defineProperty(this, se, {
46
46
  enumerable: !1,
47
- value: ie({ description: r, fields: i, label: n, type: P.OBJECT }, e)
47
+ value: oe({ description: r, fields: i, label: n, type: P.OBJECT }, e)
48
48
  }), this.projectionCode = e, Object.freeze(this);
49
49
  }
50
50
  /** Serializable schema for editors and checks (no functions). */
51
51
  describe() {
52
- return se(this[ne]);
52
+ return ae(this[se]);
53
53
  }
54
54
  /** Project a model (or plain object) onto plain data: declared fields plus the other values. */
55
55
  project(e) {
56
- return oe(this[ne], e);
56
+ return ce(this[se], e);
57
57
  }
58
58
  }
59
- function j(t) {
60
- return new et(t);
59
+ function B(t) {
60
+ return new it(t);
61
61
  }
62
- function De(t, { label: e, description: n, value: r } = {}) {
62
+ function ve(t, { label: e, description: n, value: r } = {}) {
63
63
  return { description: n, item: t, label: e, type: P.LIST, value: r };
64
64
  }
65
- function Rt(t, e = "root") {
66
- return ie(t, e);
65
+ function We(t, e = "root") {
66
+ return oe(t, e);
67
67
  }
68
- function Nt(t) {
69
- return se(t);
68
+ function wt(t) {
69
+ return ae(t);
70
70
  }
71
- function St(t, e) {
72
- return oe(t, e);
71
+ function Pt(t, e) {
72
+ return ce(t, e);
73
73
  }
74
- function ie(t, e) {
75
- if (t instanceof et)
76
- return t[ne];
74
+ function oe(t, e) {
75
+ if (t instanceof it)
76
+ return t[se];
77
77
  if (!t || typeof t != "object")
78
78
  throw new TypeError(`Template field "${e}" must be an object definition.`);
79
79
  const { description: n, label: r, type: i, value: s } = t;
@@ -81,70 +81,81 @@ function ie(t, e) {
81
81
  throw new TypeError(`Template field "${e}" value must be a function.`);
82
82
  const o = { description: n, label: r, type: i, value: s };
83
83
  if (i === P.OBJECT)
84
- o.fields = Object.entries(t.fields || {}).reduce((a, [l, c]) => (Lt(l, e), a[l] = ie(c, `${e}.${l}`), a), {});
84
+ o.fields = Object.entries(t.fields || {}).reduce((a, [c, l]) => (It(c, e), a[c] = oe(l, `${e}.${c}`), a), {});
85
85
  else if (i === P.LIST)
86
- o.item = ie(t.item, `${e}[]`);
87
- else if (!Ct.has(i))
86
+ o.item = oe(t.item, `${e}[]`);
87
+ else if (!St.has(i))
88
88
  throw new TypeError(`Template field "${e}" has unsupported type "${i}".`);
89
89
  return Object.freeze(o);
90
90
  }
91
- function Lt(t, e) {
92
- if (!Y.test(t) || t.startsWith("__") || Ie.includes(t))
91
+ function It(t, e) {
92
+ if (!Q.test(t) || t.startsWith("__") || De.includes(t))
93
93
  throw new TypeError(`Template field name "${e}.${t}" is not allowed.`);
94
94
  }
95
- function se(t) {
95
+ function ae(t) {
96
96
  const e = { type: t.type };
97
- return t.label && (e.label = t.label), t.description && (e.description = t.description), t.fields && (e.fields = Object.entries(t.fields).reduce((n, [r, i]) => (n[r] = se(i), n), {})), t.item && (e.item = se(t.item)), e;
97
+ return t.label && (e.label = t.label), t.description && (e.description = t.description), t.fields && (e.fields = Object.entries(t.fields).reduce((n, [r, i]) => (n[r] = ae(i), n), {})), t.item && (e.item = ae(t.item)), e;
98
98
  }
99
- function oe(t, e) {
99
+ function ce(t, e) {
100
100
  if (t.type === P.OBJECT) {
101
101
  if (e === null || typeof e != "object")
102
102
  return null;
103
- const n = Ce(e, 0, /* @__PURE__ */ new WeakSet()) || {};
104
- return Object.entries(t.fields).reduce((r, [i, s]) => (r[i] = oe(s, s.value ? s.value(e) : e[i]), r), n);
103
+ const n = Ae(e, 0, /* @__PURE__ */ new WeakSet()) || {};
104
+ return Object.entries(t.fields).reduce((r, [i, s]) => (r[i] = ce(s, s.value ? s.value(e) : e[i]), r), n);
105
105
  }
106
- return t.type === P.LIST ? Array.isArray(e) ? e.map((n) => oe(t.item, n)) : [] : e instanceof Date ? Number.isNaN(e.getTime()) ? null : e.getTime() : ["string", "number", "boolean"].includes(typeof e) ? typeof e == "number" && !Number.isFinite(e) ? null : e : null;
106
+ return t.type === P.LIST ? Array.isArray(e) ? e.map((n) => ce(t.item, n)) : [] : e instanceof Date ? Number.isNaN(e.getTime()) ? null : e.getTime() : ["string", "number", "boolean"].includes(typeof e) ? typeof e == "number" && !Number.isFinite(e) ? null : e : null;
107
107
  }
108
- function Ce(t, e, n) {
108
+ function Ae(t, e, n) {
109
109
  if (t instanceof Date)
110
110
  return Number.isNaN(t.getTime()) ? null : t.getTime();
111
111
  if (typeof t == "number")
112
112
  return Number.isFinite(t) ? t : null;
113
113
  if (typeof t == "string" || typeof t == "boolean" || t === null)
114
114
  return t;
115
- if (typeof t != "object" || e >= At || n.has(t))
115
+ if (typeof t != "object" || e >= Lt || n.has(t))
116
116
  return null;
117
117
  n.add(t);
118
118
  try {
119
119
  if (Array.isArray(t))
120
- return t.map((i) => i === void 0 || typeof i == "function" || typeof i == "symbol" ? null : Ce(i, e + 1, n));
120
+ return t.map((i) => i === void 0 || typeof i == "function" || typeof i == "symbol" ? null : Ae(i, e + 1, n));
121
121
  const r = typeof t.toObject == "function" ? t.toObject() : t;
122
- return Object.entries(r).reduce((i, [s, o]) => (o !== void 0 && typeof o != "function" && typeof o != "symbol" && typeof o != "bigint" && (i[s] = Ce(o, e + 1, n)), i), {});
122
+ return Object.entries(r).reduce((i, [s, o]) => (o !== void 0 && typeof o != "function" && typeof o != "symbol" && typeof o != "bigint" && (i[s] = Ae(o, e + 1, n)), i), {});
123
123
  } finally {
124
124
  n.delete(t);
125
125
  }
126
126
  }
127
- class wt {
128
- constructor({ contextCode: e, name: n, subjectType: r, roots: i, recipientRules: s = [], functionNames: o = [], loadData: a, sampleData: l } = {}) {
127
+ class Dt {
128
+ constructor({ contextCode: e, name: n, subjectType: r, roots: i, recipientRules: s = [], functionNames: o = [], includeTemplateDocumentReference: a = !1, loadData: c, sampleData: l } = {}) {
129
129
  if (!e || typeof e != "string")
130
130
  throw new TypeError("DataContext requires a contextCode.");
131
- if (a !== void 0 && typeof a != "function")
131
+ if (c !== void 0 && typeof c != "function")
132
132
  throw new TypeError(`DataContext ${e} loadData must be a function.`);
133
- const c = Object.entries(i || {}).reduce((f, [u, p]) => {
134
- if (!Y.test(u) || u.startsWith("__") || Ie.includes(u))
135
- throw new TypeError(`DataContext ${e} root name "${u}" is not allowed.`);
136
- return f[u] = Rt(p, u), f;
133
+ const m = Object.entries(i || {}).reduce((u, [d, f]) => {
134
+ if (!Q.test(d) || d.startsWith("__") || De.includes(d))
135
+ throw new TypeError(`DataContext ${e} root name "${d}" is not allowed.`);
136
+ return u[d] = We(f, d), u;
137
137
  }, {});
138
- if (!Object.keys(c).length)
138
+ if (a) {
139
+ if (Object.hasOwn(m, "template"))
140
+ throw new TypeError(`DataContext ${e} already declares a template root.`);
141
+ m.template = We({
142
+ fields: {
143
+ documentReference: { label: "Document reference", type: "string" }
144
+ },
145
+ label: "Template",
146
+ type: "object"
147
+ }, "template");
148
+ }
149
+ if (!Object.keys(m).length)
139
150
  throw new TypeError(`DataContext ${e} requires at least one data root.`);
140
151
  Object.defineProperties(this, {
141
- _loadData: { enumerable: !1, value: a },
142
- _rootNodes: { enumerable: !1, value: Object.freeze(c) },
152
+ _loadData: { enumerable: !1, value: c },
153
+ _rootNodes: { enumerable: !1, value: Object.freeze(m) },
143
154
  _sampleData: { enumerable: !1, value: l }
144
- }), this.contextCode = e, this.functionNames = Object.freeze([...new Set(o)]), this.name = n || e, this.recipientRules = Object.freeze(s.map(({ recipientType: f, name: u, description: p }) => {
145
- if (!f)
155
+ }), this.contextCode = e, this.functionNames = Object.freeze([...new Set(o)]), this.includeTemplateDocumentReference = !!a, this.name = n || e, this.recipientRules = Object.freeze(s.map(({ recipientType: u, name: d, description: f }) => {
156
+ if (!u)
146
157
  throw new TypeError(`DataContext ${e} recipient rules require recipientType.`);
147
- return Object.freeze({ description: p, name: u || f, recipientType: f });
158
+ return Object.freeze({ description: f, name: d || u, recipientType: u });
148
159
  })), this.subjectType = r, Object.freeze(this);
149
160
  }
150
161
  get rootNames() {
@@ -155,15 +166,16 @@ class wt {
155
166
  return {
156
167
  contextCode: this.contextCode,
157
168
  functionNames: [...this.functionNames],
169
+ ...this.includeTemplateDocumentReference ? { includeTemplateDocumentReference: !0 } : {},
158
170
  name: this.name,
159
171
  recipientRules: this.recipientRules.map((e) => ({ ...e })),
160
- roots: Object.entries(this._rootNodes).reduce((e, [n, r]) => (e[n] = Nt(r), e), {}),
172
+ roots: Object.entries(this._rootNodes).reduce((e, [n, r]) => (e[n] = wt(r), e), {}),
161
173
  subjectType: this.subjectType
162
174
  };
163
175
  }
164
176
  /** Project raw root models into the plain data a template renders with. */
165
177
  project(e = {}) {
166
- return Object.entries(this._rootNodes).reduce((n, [r, i]) => (n[r] = St(i, e[r]), n), {});
178
+ return Object.entries(this._rootNodes).reduce((n, [r, i]) => (this.includeTemplateDocumentReference && r === "template" || (n[r] = Pt(i, e[r])), n), {});
167
179
  }
168
180
  /**
169
181
  * Build template data for every recipient of a subject.
@@ -187,10 +199,10 @@ class wt {
187
199
  return this._sampleData ? structuredClone(this._sampleData) : null;
188
200
  }
189
201
  }
190
- function ue(t) {
191
- return new wt(t);
202
+ function pe(t) {
203
+ return new Dt(t);
192
204
  }
193
- function de(t) {
205
+ function J(t) {
194
206
  return t ? typeof t.describe == "function" ? t.describe() : t : null;
195
207
  }
196
208
  const U = Object.freeze({
@@ -200,10 +212,10 @@ const U = Object.freeze({
200
212
  NUMBER: "number",
201
213
  OBJECT: "object",
202
214
  STRING: "string"
203
- }), Pt = new Set(Object.values(U)), It = /^__[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/, V = /* @__PURE__ */ new Map();
204
- let ve = 0;
205
- function Dt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i, description: s } = {}) {
206
- if (!It.test(t || ""))
215
+ }), vt = new Set(Object.values(U)), jt = /^__[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/, V = /* @__PURE__ */ new Map();
216
+ let je = 0;
217
+ function Bt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i, description: s } = {}) {
218
+ if (!jt.test(t || ""))
207
219
  throw new TypeError(`Template function name "${t}" must be "__" followed by snake_case letters and digits.`);
208
220
  if (typeof e != "function")
209
221
  throw new TypeError(`Template function ${t} requires fn.`);
@@ -211,13 +223,13 @@ function Dt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i,
211
223
  throw new Error(`Template function ${t} is already registered.`);
212
224
  if (!n.length)
213
225
  throw new TypeError(`Template function ${t} requires a signature with at least the piped value.`);
214
- const o = n.map((a, l) => {
215
- const c = (a == null ? void 0 : a.types) || [];
216
- if (!c.length || c.some((f) => !Pt.has(f)))
217
- throw new TypeError(`Template function ${t} argument #${l + 1} has invalid types.`);
226
+ const o = n.map((a, c) => {
227
+ const l = (a == null ? void 0 : a.types) || [];
228
+ if (!l.length || l.some((m) => !vt.has(m)))
229
+ throw new TypeError(`Template function ${t} argument #${c + 1} has invalid types.`);
218
230
  return Object.freeze({
219
231
  ...a.optional ? { optional: !0 } : {},
220
- types: Object.freeze([...c]),
232
+ types: Object.freeze([...l]),
221
233
  ...a.variadic ? { variadic: !0 } : {}
222
234
  });
223
235
  });
@@ -229,41 +241,41 @@ function Dt({ name: t, fn: e, signature: n = [], trustedHtml: r = !1, label: i,
229
241
  signature: Object.freeze(o),
230
242
  trustedHtml: !!r
231
243
  }),
232
- filter: jt(t, e, o)
233
- })), ve += 1;
244
+ filter: $t(t, e, o)
245
+ })), je += 1;
234
246
  }
235
- function pe() {
247
+ function me() {
236
248
  return [...V.values()].map(({ descriptor: t }) => ({
237
249
  ...t,
238
250
  signature: t.signature.map((e) => ({ ...e, types: [...e.types] }))
239
251
  }));
240
252
  }
241
- function yr(t) {
253
+ function Or(t) {
242
254
  var e;
243
255
  return ((e = V.get(t)) == null ? void 0 : e.descriptor) || null;
244
256
  }
245
- function vt() {
257
+ function xt() {
246
258
  return {
247
259
  filters: [...V.values()].map(({ descriptor: t, filter: e }) => ({ handler: e, name: t.name, raw: t.trustedHtml })),
248
- version: ve
260
+ version: je
249
261
  };
250
262
  }
251
- function gr() {
252
- V.clear(), ve += 1;
263
+ function Cr() {
264
+ V.clear(), je += 1;
253
265
  }
254
- function jt(t, e, n) {
266
+ function $t(t, e, n) {
255
267
  return (...r) => {
256
268
  const i = r.map((o) => o === void 0 ? null : o);
257
269
  i.forEach((o, a) => {
258
- const l = n[Math.min(a, n.length - 1)];
259
- if (o !== null && l && !l.types.some((c) => Bt(o, c)))
260
- throw new TypeError(`${t} argument #${a + 1} must be ${l.types.join(" or ")}.`);
270
+ const c = n[Math.min(a, n.length - 1)];
271
+ if (o !== null && c && !c.types.some((l) => Mt(o, l)))
272
+ throw new TypeError(`${t} argument #${a + 1} must be ${c.types.join(" or ")}.`);
261
273
  });
262
274
  const s = e(...i);
263
275
  return s === void 0 ? null : s;
264
276
  };
265
277
  }
266
- function Bt(t, e) {
278
+ function Mt(t, e) {
267
279
  switch (e) {
268
280
  case U.ANY:
269
281
  return !0;
@@ -279,58 +291,58 @@ function Bt(t, e) {
279
291
  return typeof t == "string";
280
292
  }
281
293
  }
282
- function O({ code: t, message: e, severity: n = H.ERROR, ...r } = {}) {
294
+ function O({ code: t, message: e, severity: n = X.ERROR, ...r } = {}) {
283
295
  const i = { code: t, message: e, severity: n };
284
296
  return ["partCode", "offset", "line", "column", "source", "blockRef", "detail"].forEach((s) => {
285
297
  typeof r[s] < "u" && (i[s] = r[s]);
286
298
  }), i;
287
299
  }
288
300
  function K(t = []) {
289
- return t.some((e) => e.severity === H.ERROR);
301
+ return t.some((e) => e.severity === X.ERROR);
290
302
  }
291
- class Q extends Error {
303
+ class ee extends Error {
292
304
  constructor(e = [], n) {
293
- const r = e.filter((i) => i.severity === H.ERROR);
294
- super(n || xt(r)), this.name = "TemplateSyntaxError", this.code = "TEMPLATE_SYNTAX_INVALID", this.issues = e;
305
+ const r = e.filter((i) => i.severity === X.ERROR);
306
+ super(n || Ut(r)), this.name = "TemplateSyntaxError", this.code = "TEMPLATE_SYNTAX_INVALID", this.issues = e;
295
307
  }
296
308
  }
297
- class v extends Error {
309
+ class j extends Error {
298
310
  constructor({ message: e, partCode: n, source: r, cause: i } = {}) {
299
311
  super(e || "Template rendering failed.", i ? { cause: i } : void 0), this.name = "TemplateRenderError", this.code = "TEMPLATE_RENDER_FAILED", this.partCode = n, this.source = r;
300
312
  }
301
313
  }
302
- function xt(t) {
314
+ function Ut(t) {
303
315
  if (!t.length)
304
316
  return "Template is invalid.";
305
317
  const [e] = t, n = e.partCode ? ` (${e.partCode}${e.line ? `:${e.line}:${e.column}` : ""})` : "", r = t.length > 1 ? ` and ${t.length - 1} more issue(s)` : "";
306
318
  return `${e.code}: ${e.message}${n}${r}`;
307
319
  }
308
- const tt = "data-qw-layout", $t = `<([a-z][a-z0-9-]*)\\b[^>]*\\s${tt}\\s*=\\s*"([^"]*)"[^>]*>\\s*</\\1\\s*>`, Mt = "PUBLISHED", nt = () => new RegExp($t, "gi"), Ut = (t) => typeof (t == null ? void 0 : t.describe) == "function" ? t.describe() : t;
309
- function _r(t) {
310
- return `<div ${tt}="${t}"></div>`;
320
+ const st = "data-qw-layout", kt = `<([a-z][a-z0-9-]*)\\b[^>]*\\s${st}\\s*=\\s*"([^"]*)"[^>]*>\\s*</\\1\\s*>`, zt = "PUBLISHED", ot = () => new RegExp(kt, "gi"), Vt = (t) => typeof (t == null ? void 0 : t.describe) == "function" ? t.describe() : t;
321
+ function Ar(t) {
322
+ return `<div ${st}="${t}"></div>`;
311
323
  }
312
- function je(t) {
313
- return [...new Set([...String(t || "").matchAll(nt())].map(([, , e]) => e))];
324
+ function Be(t) {
325
+ return [...new Set([...String(t || "").matchAll(ot())].map(([, , e]) => e))];
314
326
  }
315
- function rt({ layouts: t = [], layoutCode: e } = {}) {
316
- return e && t.map(Ut).filter((n) => (n == null ? void 0 : n.layoutCode) === e && n.stateCode === Mt).sort((n, r) => r.version - n.version)[0] || null;
327
+ function at({ layouts: t = [], layoutCode: e } = {}) {
328
+ return e && t.map(Vt).filter((n) => (n == null ? void 0 : n.layoutCode) === e && n.stateCode === zt).sort((n, r) => r.version - n.version)[0] || null;
317
329
  }
318
- function kt({ html: t, layouts: e = [] } = {}) {
330
+ function Ft({ html: t, layouts: e = [] } = {}) {
319
331
  const n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
320
- return { html: String(t || "").replace(nt(), (s, o, a) => {
321
- const l = rt({ layoutCode: a, layouts: e });
322
- return l ? (n.add(`${l.layoutCode}@${l.version}`), l.html || "") : (r.add(a), s);
332
+ return { html: String(t || "").replace(ot(), (s, o, a) => {
333
+ const c = at({ layoutCode: a, layouts: e });
334
+ return c ? (n.add(`${c.layoutCode}@${c.version}`), c.html || "") : (r.add(a), s);
323
335
  }), layoutRefs: [...n], missingLayoutCodes: [...r] };
324
336
  }
325
- function it(t) {
326
- return String(t || "").trim() ? je(t).map((e) => O({ code: y.LAYOUT_NOT_ALLOWED, layoutCode: e, message: `Layout ${e} cannot be placed inside another layout.`, partCode: "layout" })) : [O({ code: y.LAYOUT_EMPTY, message: "The layout is empty.", partCode: "layout" })];
337
+ function ct(t) {
338
+ return String(t || "").trim() ? Be(t).map((e) => O({ code: y.LAYOUT_NOT_ALLOWED, layoutCode: e, message: `Layout ${e} cannot be placed inside another layout.`, partCode: "layout" })) : [O({ code: y.LAYOUT_EMPTY, message: "The layout is empty.", partCode: "layout" })];
327
339
  }
328
- const st = Object.freeze(["#", "case", "comment", "for", "if", "unless"]), Ae = Object.freeze(["assign", "capture"]), Ee = (t = !1) => ({ ...t ? { optional: t } : {}, types: ["any"] }), g = (t, e = !1) => ({ ...e ? { optional: e } : {}, types: t }), ot = Object.freeze([
340
+ const lt = Object.freeze(["#", "case", "comment", "for", "if", "unless"]), Re = Object.freeze(["assign", "capture"]), ye = (t = !1) => ({ ...t ? { optional: t } : {}, types: ["any"] }), g = (t, e = !1) => ({ ...e ? { optional: e } : {}, types: t }), ut = Object.freeze([
329
341
  { description: 'Format a timestamp (milliseconds) or date text, e.g. date: "%Y-%m-%d". Dates are UTC unless a time zone is given.', label: "date", name: "date", signature: [g(["number", "string"]), g(["string"], !0), g(["number", "string"], !0)] },
330
- { description: "The argument when the value is nil, false or empty.", name: "default", signature: [Ee(), Ee()] },
342
+ { description: "The argument when the value is nil, false or empty.", name: "default", signature: [ye(), ye()] },
331
343
  { description: "Join list items with a separator.", label: "joined", name: "join", signature: [g(["array"]), g(["string"], !0)] },
332
344
  { description: "The given field of every list item.", name: "map", signature: [g(["array"]), g(["string"])] },
333
- { description: "List items whose field is truthy or equals a value.", name: "where", signature: [g(["array"]), g(["string"]), Ee(!0)] },
345
+ { description: "List items whose field is truthy or equals a value.", name: "where", signature: [g(["array"]), g(["string"]), ye(!0)] },
334
346
  { description: 'List items for which an expression is true, e.g. where_exp: "line", "line.qty > 0".', name: "where_exp", signature: [g(["array"]), g(["string"]), g(["string"])] },
335
347
  { description: "The first list item.", label: "first", name: "first", signature: [g(["array"])] },
336
348
  { description: "Number of list items or characters.", label: "count", name: "size", signature: [g(["array", "string"])] },
@@ -343,7 +355,7 @@ const st = Object.freeze(["#", "case", "comment", "for", "if", "unless"]), Ae =
343
355
  { description: "Multiply by a number.", name: "times", signature: [g(["number"]), g(["number"])] },
344
356
  { description: "Divide by a number.", name: "divided_by", signature: [g(["number"]), g(["number"])] },
345
357
  { description: "Round to a number of decimals.", label: "rounded", name: "round", signature: [g(["number"]), g(["number"], !0)] }
346
- ].map((t) => Object.freeze({ ...t, builtin: !0, signature: Object.freeze(t.signature.map(Object.freeze)) }))), zt = new Set(ot.map(({ name: t }) => t)), at = Object.freeze({
358
+ ].map((t) => Object.freeze({ ...t, builtin: !0, signature: Object.freeze(t.signature.map(Object.freeze)) }))), Kt = new Set(ut.map(({ name: t }) => t)), dt = Object.freeze({
347
359
  "&#34;": '"',
348
360
  "&#39;": "'",
349
361
  "&#60;": "<",
@@ -355,15 +367,15 @@ const st = Object.freeze(["#", "case", "comment", "for", "if", "unless"]), Ae =
355
367
  "&lt;": "<",
356
368
  "&nbsp;": " ",
357
369
  "&quot;": '"'
358
- }), Vt = /\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}/g;
359
- function Ft(t) {
360
- return String(t ?? "").replace(Vt, (e) => e.replace(/&(?:#34|#39|#60|#62|#x27|amp|apos|gt|lt|nbsp|quot);/g, (n) => at[n]).replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"').replace(/\xA0/g, " ").replace(/[\u200B-\u200D\uFEFF]/g, ""));
370
+ }), qt = /\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}/g;
371
+ function Gt(t) {
372
+ return String(t ?? "").replace(qt, (e) => e.replace(/&(?:#34|#39|#60|#62|#x27|amp|apos|gt|lt|nbsp|quot);/g, (n) => dt[n]).replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"').replace(/\xA0/g, " ").replace(/[\u200B-\u200D\uFEFF]/g, ""));
361
373
  }
362
- function qe(t) {
363
- return String(t ?? "").replace(/&(?:#34|#39|#60|#62|#x27|amp|apos|gt|lt|nbsp|quot);/g, (e) => at[e]);
374
+ function He(t) {
375
+ return String(t ?? "").replace(/&(?:#34|#39|#60|#62|#x27|amp|apos|gt|lt|nbsp|quot);/g, (e) => dt[e]);
364
376
  }
365
- function ct({ escape: t = !1, limits: e = {}, tags: n } = {}) {
366
- const r = new gt({
377
+ function pt({ escape: t = !1, limits: e = {}, tags: n } = {}) {
378
+ const r = new At({
367
379
  cache: !1,
368
380
  dynamicPartials: !1,
369
381
  jsTruthy: !1,
@@ -375,7 +387,7 @@ function ct({ escape: t = !1, limits: e = {}, tags: n } = {}) {
375
387
  ...e
376
388
  });
377
389
  Object.keys(r.filters).forEach((s) => {
378
- zt.has(s) || r.unregisterFilter(s);
390
+ Kt.has(s) || r.unregisterFilter(s);
379
391
  });
380
392
  const i = r.filters.date;
381
393
  if (r.registerFilter("date", function(s, ...o) {
@@ -388,28 +400,28 @@ function ct({ escape: t = !1, limits: e = {}, tags: n } = {}) {
388
400
  }
389
401
  return r;
390
402
  }
391
- const k = "data-qw-block", Re = "data-qw-params", Kt = /^([A-Z][A-Z0-9_]*)@([1-9]\d*)$/, qt = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]), Gt = ct();
392
- function J(t, { partCode: e, allowBlocks: n = !0 } = {}) {
393
- const r = Ft(typeof t == "string" ? t : ""), i = Zt(r, e), s = [], o = [], a = [];
394
- let l = 0, c = ae(r, l);
395
- for (; c; )
396
- a.push(c), l = c.end, c.issue ? s.push(O({ ...c.issue, ...i(c.start) })) : n ? o.push({ ...c.node, end: c.end, location: i(c.start), start: c.start }) : s.push(O({ blockRef: c.node.blockRef, code: y.BLOCK_NOT_ALLOWED, message: "Block instances are not allowed here.", ...i(c.start) })), c = ae(r, l);
397
- let f = [];
403
+ const k = "data-qw-block", Ne = "data-qw-params", Wt = /^([A-Z][A-Z0-9_]*)@([1-9]\d*)$/, Ht = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]), Yt = pt();
404
+ function te(t, { partCode: e, allowBlocks: n = !0 } = {}) {
405
+ const r = Gt(typeof t == "string" ? t : ""), i = nn(r, e), s = [], o = [], a = [];
406
+ let c = 0, l = le(r, c);
407
+ for (; l; )
408
+ a.push(l), c = l.end, l.issue ? s.push(O({ ...l.issue, ...i(l.start) })) : n ? o.push({ ...l.node, end: l.end, location: i(l.start), start: l.start }) : s.push(O({ blockRef: l.node.blockRef, code: y.BLOCK_NOT_ALLOWED, message: "Block instances are not allowed here.", ...i(l.start) })), l = le(r, c);
409
+ let m = [];
398
410
  try {
399
- f = Gt.parse(Xt(r, a));
411
+ m = Yt.parse(Zt(r, a));
400
412
  } catch (u) {
401
- s.push(Ht(u, i));
413
+ s.push(Qt(u, i));
402
414
  }
403
- return { blockRefs: [...new Set(o.map(({ blockRef: u }) => u))], blocks: o, issues: s, locate: i, templates: f, text: r };
415
+ return { blockRefs: [...new Set(o.map(({ blockRef: u }) => u))], blocks: o, issues: s, locate: i, templates: m, text: r };
404
416
  }
405
- function Wt(t) {
417
+ function Xt(t) {
406
418
  const e = typeof t == "string" ? t : "", n = /* @__PURE__ */ new Set();
407
- let r = ae(e, 0);
419
+ let r = le(e, 0);
408
420
  for (; r; )
409
- r.node && n.add(r.node.blockRef), r = ae(e, r.end);
421
+ r.node && n.add(r.node.blockRef), r = le(e, r.end);
410
422
  return [...n];
411
423
  }
412
- function Ht(t, e, n = 0) {
424
+ function Qt(t, e, n = 0) {
413
425
  var i;
414
426
  if (!(t != null && t.token) && !/^(?:Parse|Tokenization|Liquid)Error$/.test((t == null ? void 0 : t.name) || ""))
415
427
  throw t;
@@ -420,18 +432,18 @@ function Ht(t, e, n = 0) {
420
432
  ...e ? e(n + (((i = t.token) == null ? void 0 : i.begin) ?? 0)) : {}
421
433
  });
422
434
  }
423
- function Yt(t) {
424
- const e = Kt.exec(typeof t == "string" ? t.trim() : "");
435
+ function Jt(t) {
436
+ const e = Wt.exec(typeof t == "string" ? t.trim() : "");
425
437
  return e ? { blockCode: e[1], version: Number(e[2]) } : null;
426
438
  }
427
- function Ne({ blockCode: t, version: e } = {}) {
439
+ function Se({ blockCode: t, version: e } = {}) {
428
440
  return `${t}@${e}`;
429
441
  }
430
- function Or({ blockCode: t, version: e, params: n = {}, tagName: r = "div" } = {}) {
442
+ function Rr({ blockCode: t, version: e, params: n = {}, tagName: r = "div" } = {}) {
431
443
  const i = JSON.stringify(n || {}).replace(/&/g, "&amp;").replace(/'/g, "&#39;");
432
- return `<${r} ${k}="${Ne({ blockCode: t, version: e })}" ${Re}='${i}'></${r}>`;
444
+ return `<${r} ${k}="${Se({ blockCode: t, version: e })}" ${Ne}='${i}'></${r}>`;
433
445
  }
434
- function Xt(t, e) {
446
+ function Zt(t, e) {
435
447
  if (!e.length)
436
448
  return t;
437
449
  let n = "", r = 0;
@@ -439,55 +451,55 @@ function Xt(t, e) {
439
451
  n += t.slice(r, i) + t.slice(i, s).replace(/[^\n]/g, " "), r = s;
440
452
  }), n + t.slice(r);
441
453
  }
442
- function ae(t, e) {
454
+ function le(t, e) {
443
455
  let n = e;
444
456
  for (; n < t.length; ) {
445
457
  const r = t.indexOf(k, n);
446
458
  if (r === -1)
447
459
  return null;
448
- const i = t.lastIndexOf("<", r), s = i >= e ? Qt(t, i) : null;
460
+ const i = t.lastIndexOf("<", r), s = i >= e ? en(t, i) : null;
449
461
  if (!s || s.end <= r || !Object.hasOwn(s.attributes, k)) {
450
462
  n = r + k.length;
451
463
  continue;
452
464
  }
453
- const o = s.selfClosing || qt.has(s.name) ? s.end : Jt(t, s.name, s.end);
465
+ const o = s.selfClosing || Ht.has(s.name) ? s.end : tn(t, s.name, s.end);
454
466
  if (o === -1)
455
467
  return {
456
468
  end: t.length,
457
469
  issue: { code: y.BLOCK_ELEMENT_INVALID, message: `Block element <${s.name}> is not closed.` },
458
470
  start: i
459
471
  };
460
- const a = Yt(qe(s.attributes[k]));
472
+ const a = Jt(He(s.attributes[k]));
461
473
  if (!a)
462
474
  return {
463
475
  end: o,
464
476
  issue: { code: y.BLOCK_ELEMENT_INVALID, message: `Block reference "${s.attributes[k]}" must look like BLOCK_CODE@1.` },
465
477
  start: i
466
478
  };
467
- let l = {};
468
- const c = s.attributes[Re];
469
- if (c) {
479
+ let c = {};
480
+ const l = s.attributes[Ne];
481
+ if (l) {
470
482
  try {
471
- l = JSON.parse(qe(c));
483
+ c = JSON.parse(He(l));
472
484
  } catch {
473
- l = null;
485
+ c = null;
474
486
  }
475
- if (!l || typeof l != "object" || Array.isArray(l))
487
+ if (!c || typeof c != "object" || Array.isArray(c))
476
488
  return {
477
489
  end: o,
478
- issue: { blockRef: Ne(a), code: y.BLOCK_PARAMS_INVALID, message: `${Re} must be a JSON object.` },
490
+ issue: { blockRef: Se(a), code: y.BLOCK_PARAMS_INVALID, message: `${Ne} must be a JSON object.` },
479
491
  start: i
480
492
  };
481
493
  }
482
494
  return {
483
495
  end: o,
484
- node: { blockCode: a.blockCode, blockRef: Ne(a), params: l, type: "Block", version: a.version },
496
+ node: { blockCode: a.blockCode, blockRef: Se(a), params: c, type: "Block", version: a.version },
485
497
  start: i
486
498
  };
487
499
  }
488
500
  return null;
489
501
  }
490
- function Qt(t, e) {
502
+ function en(t, e) {
491
503
  const n = /^<([A-Z][\w-]*)/i.exec(t.slice(e));
492
504
  if (!n)
493
505
  return null;
@@ -504,7 +516,7 @@ function Qt(t, e) {
504
516
  }
505
517
  return null;
506
518
  }
507
- function Jt(t, e, n) {
519
+ function tn(t, e, n) {
508
520
  const r = new RegExp(`<(/?)${e}(?=[\\s/>])[^>]*>`, "gi");
509
521
  r.lastIndex = n;
510
522
  let i = 1, s = r.exec(t);
@@ -517,7 +529,7 @@ function Jt(t, e, n) {
517
529
  }
518
530
  return -1;
519
531
  }
520
- function Zt(t, e) {
532
+ function nn(t, e) {
521
533
  const n = [0];
522
534
  for (let r = 0; r < t.length; r += 1)
523
535
  t[r] === `
@@ -534,10 +546,11 @@ function Zt(t, e) {
534
546
  };
535
547
  };
536
548
  }
537
- const en = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], tn = ["contextCode", "name", "templateCode", "templateSyntaxVersion"], nn = ["contextCode", "name", "templateSyntaxVersion"];
538
- class rn extends Et {
549
+ const rn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], sn = ["contextCode", "documentReference", "name", "templateCode", "templateRevision", "templateSyntaxVersion"], on = ["contextCode", "name", "templateSyntaxVersion"];
550
+ class an extends Ot {
539
551
  constructor(e = {}) {
540
- e = e || {}, super(e), this._type = e._type || "Template", this.contextCode = e.contextCode, this.name = e.name, this.partContent = Ge(e.partContent), this.templateCode = e.templateCode, this.templateSyntaxVersion = Number(e.templateSyntaxVersion || Pe);
552
+ var n;
553
+ e = e || {}, super(e), this._type = e._type || "Template", this.contextCode = e.contextCode, this.documentReference = Ye(e.documentReference), this.name = e.name, this.partContent = Xe(e.partContent), this.templateCode = e.templateCode, this.templateRevision = Number(e.templateRevision || ((n = e.meta) == null ? void 0 : n.revision) || 1), this.templateSyntaxVersion = Number(e.templateSyntaxVersion || Ie);
541
554
  }
542
555
  static get _classname() {
543
556
  return "Template";
@@ -554,7 +567,7 @@ class rn extends Et {
554
567
  return ((e = this.kind) == null ? void 0 : e.partDefinitions) || [];
555
568
  }
556
569
  get isValid() {
557
- return super.isValid && !!this.templateCode && !!this.contextCode;
570
+ return super.isValid && !!this.templateCode && !!this.contextCode && Number.isInteger(this.templateRevision) && this.templateRevision > 0 && (this.documentReference == null || typeof this.documentReference == "string" && this.documentReference.length <= 120 && !/[\r\n]/.test(this.documentReference));
558
571
  }
559
572
  getCode() {
560
573
  return this.templateCode;
@@ -576,12 +589,12 @@ class rn extends Et {
576
589
  getBlockRefs() {
577
590
  const e = /* @__PURE__ */ new Set();
578
591
  return this.getContentParts().forEach(({ content: n }) => {
579
- Wt(n).forEach((r) => e.add(r));
592
+ Xt(n).forEach((r) => e.add(r));
580
593
  }), [...e];
581
594
  }
582
595
  /** Codes of the email layouts placed in the parts. */
583
596
  getLayoutCodes() {
584
- return [...new Set(this.getContentParts().flatMap(({ content: e }) => je(e)))];
597
+ return [...new Set(this.getContentParts().flatMap(({ content: e }) => Be(e)))];
585
598
  }
586
599
  setPartContent(e, n) {
587
600
  if (!this.constructor.partDefinitions.some((r) => r.partCode === e))
@@ -593,7 +606,7 @@ class rn extends Et {
593
606
  * part is unchanged and an explicit null clears it.
594
607
  */
595
608
  update(e = {}) {
596
- return nn.forEach((n) => {
609
+ return Object.hasOwn(e, "documentReference") && (this.documentReference = Ye(e.documentReference)), on.forEach((n) => {
597
610
  Object.hasOwn(e, n) && (this[n] = n === "templateSyntaxVersion" ? Number(e[n]) : e[n]);
598
611
  }), e.partContent && typeof e.partContent == "object" && Object.entries(e.partContent).forEach(([n, r]) => {
599
612
  this.setPartContent(n, r);
@@ -605,29 +618,32 @@ class rn extends Et {
605
618
  toObject() {
606
619
  const e = {
607
620
  _type: this._type,
608
- meta: w(this.meta, en),
609
- metadata: Fe(this.metadata),
610
- partContent: Ge(this.partContent),
611
- remarks: Fe(this.remarks),
621
+ meta: L(this.meta, rn),
622
+ metadata: qe(this.metadata),
623
+ partContent: Xe(this.partContent),
624
+ remarks: qe(this.remarks),
612
625
  tenantCode: this.tenantCode,
613
- ...w(this, tn)
626
+ ...L(this, sn)
614
627
  };
615
628
  return typeof this.id < "u" && (e.id = this.id), e;
616
629
  }
617
630
  }
618
- function Ge(t) {
631
+ function Ye(t) {
632
+ return typeof t == "string" ? t.trim() || null : t;
633
+ }
634
+ function Xe(t) {
619
635
  return !t || typeof t != "object" ? {} : Object.entries(t).reduce((e, [n, r]) => (typeof r == "string" && (e[n] = r), e), {});
620
636
  }
621
637
  const z = Object.freeze({
622
638
  DEPRECATED: "DEPRECATED",
623
639
  DRAFT: "DRAFT",
624
640
  PUBLISHED: "PUBLISHED"
625
- }), sn = new Set(Object.values(z)), on = Object.freeze({
641
+ }), cn = new Set(Object.values(z)), ln = Object.freeze({
626
642
  DEPRECATED: /* @__PURE__ */ new Set(),
627
643
  DRAFT: /* @__PURE__ */ new Set(["PUBLISHED"]),
628
644
  PUBLISHED: /* @__PURE__ */ new Set(["DEPRECATED"])
629
645
  });
630
- class Se extends yt {
646
+ class Le extends Ct {
631
647
  constructor(e = {}) {
632
648
  super(e), this._setPublicationState(e.publication);
633
649
  }
@@ -646,7 +662,7 @@ class Se extends yt {
646
662
  canTransition(e, n) {
647
663
  var i, s;
648
664
  const r = (i = this.getState(e)) == null ? void 0 : i.stateCode;
649
- return e === "publication" && !!((s = on[r]) != null && s.has(n));
665
+ return e === "publication" && !!((s = ln[r]) != null && s.has(n));
650
666
  }
651
667
  transition(e, { actionRevision: n, modified: r = Date.now(), stateCode: i } = {}) {
652
668
  var s;
@@ -655,7 +671,7 @@ class Se extends yt {
655
671
  return this._setPublicationState({ actionRevision: n, modified: r, stateCode: i });
656
672
  }
657
673
  _setPublicationState(e) {
658
- if (!sn.has(e == null ? void 0 : e.stateCode))
674
+ if (!cn.has(e == null ? void 0 : e.stateCode))
659
675
  throw new TypeError(`Invalid ${this.constructor.entityType} lifecycle state for publication.`);
660
676
  return this._setState("publication", e);
661
677
  }
@@ -665,40 +681,40 @@ const R = Object.freeze({
665
681
  MULTI_SELECT: "multiSelect",
666
682
  SELECT: "select",
667
683
  TEXT: "text"
668
- }), an = new Set(Object.values(R)), We = /* @__PURE__ */ new Set([R.MULTI_SELECT, R.SELECT]);
669
- function X(t = []) {
684
+ }), un = new Set(Object.values(R)), Qe = /* @__PURE__ */ new Set([R.MULTI_SELECT, R.SELECT]);
685
+ function Z(t = []) {
670
686
  const e = [], n = /* @__PURE__ */ new Set();
671
687
  return { definitions: (Array.isArray(t) ? t : []).map((i, s) => {
672
- const { paramCode: o, type: a, label: l, description: c, required: f = !1, options: u = [] } = i || {};
673
- return !Y.test(o || "") || o.startsWith("__") ? e.push(`Param #${s + 1} has an invalid paramCode "${o}".`) : n.has(o) && e.push(`Param "${o}" is declared twice.`), n.add(o), an.has(a) || e.push(`Param "${o}" has unsupported type "${a}".`), We.has(a) && (!Array.isArray(u) || !u.length ? e.push(`Param "${o}" requires options.`) : u.some((p) => !Y.test(String((p == null ? void 0 : p.value) ?? ""))) && e.push(`Param "${o}" option values must match [A-Za-z_]\\w*.`)), {
674
- ...c ? { description: c } : {},
688
+ const { paramCode: o, type: a, label: c, description: l, required: m = !1, options: u = [] } = i || {};
689
+ return !Q.test(o || "") || o.startsWith("__") ? e.push(`Param #${s + 1} has an invalid paramCode "${o}".`) : n.has(o) && e.push(`Param "${o}" is declared twice.`), n.add(o), un.has(a) || e.push(`Param "${o}" has unsupported type "${a}".`), Qe.has(a) && (!Array.isArray(u) || !u.length ? e.push(`Param "${o}" requires options.`) : u.some((d) => !Q.test(String((d == null ? void 0 : d.value) ?? ""))) && e.push(`Param "${o}" option values must match [A-Za-z_]\\w*.`)), {
690
+ ...l ? { description: l } : {},
675
691
  ..."default" in (i || {}) ? { default: i.default } : {},
676
- label: l || o,
677
- ...We.has(a) ? { options: u.map(({ value: p, label: b }) => ({ label: b || p, value: p })) } : {},
692
+ label: c || o,
693
+ ...Qe.has(a) ? { options: u.map(({ value: d, label: f }) => ({ label: f || d, value: d })) } : {},
678
694
  paramCode: o,
679
- required: !!f,
695
+ required: !!m,
680
696
  type: a
681
697
  };
682
698
  }), errors: e };
683
699
  }
684
- function lt(t = [], e = {}) {
700
+ function mt(t = [], e = {}) {
685
701
  const n = [], r = e && typeof e == "object" ? e : {}, i = new Set(t.map(({ paramCode: o }) => o));
686
702
  Object.keys(r).forEach((o) => {
687
703
  i.has(o) || n.push(`Unknown param "${o}".`);
688
704
  });
689
705
  const s = t.reduce((o, a) => {
690
- const { paramCode: l, type: c, required: f } = a, u = Object.hasOwn(r, l) ? r[l] : a.default;
706
+ const { paramCode: c, type: l, required: m } = a, u = Object.hasOwn(r, c) ? r[c] : a.default;
691
707
  if (u == null || u === "")
692
- return f && n.push(`Param "${l}" is required.`), o[l] = c === R.MULTI_SELECT ? [] : c === R.BOOLEAN ? !1 : null, o;
693
- const p = ln(a, u);
694
- return p && n.push(p), o[l] = u, o;
708
+ return m && n.push(`Param "${c}" is required.`), o[c] = l === R.MULTI_SELECT ? [] : l === R.BOOLEAN ? !1 : null, o;
709
+ const d = pn(a, u);
710
+ return d && n.push(d), o[c] = u, o;
695
711
  }, {});
696
712
  return { errors: n, values: s };
697
713
  }
698
- function cn(t = [], e = {}) {
714
+ function dn(t = [], e = {}) {
699
715
  return t.reduce((n, { paramCode: r, type: i }) => (i === R.MULTI_SELECT ? n[r] = (Array.isArray(e[r]) ? e[r] : []).reduce((s, o) => (s[o] = !0, s), {}) : n[r] = e[r] ?? null, n), {});
700
716
  }
701
- function Be(t = []) {
717
+ function xe(t = []) {
702
718
  return {
703
719
  fields: t.reduce((e, { paramCode: n, type: r, label: i, options: s }) => (r === R.MULTI_SELECT ? e[n] = {
704
720
  fields: s.reduce((o, a) => (o[a.value] = { label: a.label, type: "boolean" }, o), {}),
@@ -708,7 +724,7 @@ function Be(t = []) {
708
724
  type: "object"
709
725
  };
710
726
  }
711
- function ln({ paramCode: t, type: e, options: n = [] }, r) {
727
+ function pn({ paramCode: t, type: e, options: n = [] }, r) {
712
728
  const i = new Set(n.map((s) => s.value));
713
729
  switch (e) {
714
730
  case R.BOOLEAN:
@@ -723,21 +739,23 @@ function ln({ paramCode: t, type: e, options: n = [] }, r) {
723
739
  return null;
724
740
  }
725
741
  }
726
- const xe = Object.freeze({
742
+ const $e = Object.freeze({
727
743
  EMAIL: "EMAIL"
728
744
  }), x = Object.freeze({
729
745
  TEXT_HTML: "text/html",
730
746
  TEXT_PLAIN: "text/plain"
731
- }), B = Object.freeze({
747
+ }), I = Object.freeze({
732
748
  MAILBOX: "mailbox",
733
749
  MAILBOX_LIST: "mailboxList",
734
750
  TEXT: "text"
735
- }), $e = Object.freeze({
751
+ }), Me = Object.freeze({
736
752
  fieldDefinitions: Object.freeze([
737
- Object.freeze({ emailExpression: !1, fieldCode: "from", label: "From", nameExpression: !0, type: B.MAILBOX }),
738
- Object.freeze({ emailExpression: !0, fieldCode: "replyTo", label: "Reply to", nameExpression: !0, type: B.MAILBOX }),
739
- Object.freeze({ emailExpression: !0, fieldCode: "cc", label: "CC", nameExpression: !0, type: B.MAILBOX_LIST }),
740
- Object.freeze({ emailExpression: !0, fieldCode: "bcc", label: "BCC", nameExpression: !0, type: B.MAILBOX_LIST })
753
+ Object.freeze({ fieldCode: "documentReference", label: "Document reference", literal: !0, type: I.TEXT }),
754
+ Object.freeze({ emailExpression: !1, fieldCode: "to", label: "To", nameExpression: !0, type: I.MAILBOX }),
755
+ Object.freeze({ emailExpression: !1, fieldCode: "from", label: "From", nameExpression: !0, type: I.MAILBOX }),
756
+ Object.freeze({ emailExpression: !0, fieldCode: "replyTo", label: "Reply to", nameExpression: !0, type: I.MAILBOX }),
757
+ Object.freeze({ emailExpression: !0, fieldCode: "cc", label: "CC", nameExpression: !0, type: I.MAILBOX_LIST }),
758
+ Object.freeze({ emailExpression: !0, fieldCode: "bcc", label: "BCC", nameExpression: !0, type: I.MAILBOX_LIST })
741
759
  ]),
742
760
  label: "Email",
743
761
  partDefinitions: Object.freeze([
@@ -755,14 +773,14 @@ const xe = Object.freeze({
755
773
  Object.freeze({ label: "HTML", previewViewCode: "HTML" }),
756
774
  Object.freeze({ label: "Plain text", previewViewCode: "TEXT" })
757
775
  ]),
758
- templateKindCode: xe.EMAIL
759
- }), un = Object.freeze({
760
- [xe.EMAIL]: $e
776
+ templateKindCode: $e.EMAIL
777
+ }), mn = Object.freeze({
778
+ [$e.EMAIL]: Me
761
779
  });
762
- function ut(t) {
763
- return un[t] || null;
780
+ function ft(t) {
781
+ return mn[t] || null;
764
782
  }
765
- function Cr(t) {
783
+ function Nr(t) {
766
784
  return structuredClone({
767
785
  fieldDefinitions: t.fieldDefinitions || [],
768
786
  label: t.label,
@@ -772,25 +790,27 @@ function Cr(t) {
772
790
  templateKindCode: t.templateKindCode
773
791
  });
774
792
  }
775
- function dn(t, e = {}) {
776
- return (t.fieldDefinitions || []).flatMap(({ fieldCode: n, type: r, emailExpression: i, nameExpression: s, expressionAllowed: o = !1 }) => {
777
- const a = e[n];
778
- return r === B.TEXT ? typeof a == "string" && a ? [{ content: a, expressionAllowed: !!o, fieldPath: n }] : [] : (r === B.MAILBOX_LIST ? Array.isArray(a) ? a : [] : a ? [a] : []).flatMap((c, f) => {
779
- const u = r === B.MAILBOX_LIST ? `${n}[${f}]` : n;
793
+ function fn(t, e = {}) {
794
+ return (t.fieldDefinitions || []).flatMap(({ fieldCode: n, type: r, emailExpression: i, nameExpression: s, literal: o, expressionAllowed: a = !1 }) => {
795
+ if (o)
796
+ return [];
797
+ const c = e[n];
798
+ return r === I.TEXT ? typeof c == "string" && c ? [{ content: c, expressionAllowed: !!a, fieldPath: n }] : [] : (r === I.MAILBOX_LIST ? Array.isArray(c) ? c : [] : c ? [c] : []).flatMap((m, u) => {
799
+ const d = r === I.MAILBOX_LIST ? `${n}[${u}]` : n;
780
800
  return [
781
- { content: (c == null ? void 0 : c.email) || "", expressionAllowed: i, fieldPath: `${u}.email` },
782
- { content: (c == null ? void 0 : c.name) || "", expressionAllowed: s, fieldPath: `${u}.name` }
783
- ].filter(({ content: p }) => p);
801
+ { content: (m == null ? void 0 : m.email) || "", expressionAllowed: i, fieldPath: `${d}.email` },
802
+ { content: (m == null ? void 0 : m.name) || "", expressionAllowed: s, fieldPath: `${d}.name` }
803
+ ].filter(({ content: f }) => f);
784
804
  });
785
805
  });
786
806
  }
787
- const dt = new Map(ot.map((t) => [t.name, t])), S = Object.freeze({ type: "number" }), Me = Object.freeze({ type: "string" }), Le = Object.freeze({ type: "boolean" }), pn = Object.freeze({
788
- fields: Object.freeze({ first: Le, index: S, index0: S, last: Le, length: S, rindex: S, rindex0: S }),
807
+ const ht = new Map(ut.map((t) => [t.name, t])), w = Object.freeze({ type: "number" }), Ue = Object.freeze({ type: "string" }), we = Object.freeze({ type: "boolean" }), hn = Object.freeze({
808
+ fields: Object.freeze({ first: we, index: w, index0: w, last: we, length: w, rindex: w, rindex0: w }),
789
809
  label: "Loop",
790
810
  type: "object"
791
- }), mn = /* @__PURE__ */ new Set([F, "forloop"]), fn = /* @__PURE__ */ new Set(["where", "where_exp"]), hn = /* @__PURE__ */ new Set(["date", "downcase", "join", "strip_html", "truncate", "upcase"]), Tn = /* @__PURE__ */ new Set(["divided_by", "minus", "plus", "round", "size", "times"]);
792
- function me(t, { locate: e, text: n, roots: r = null, variables: i = /* @__PURE__ */ new Map(), functionsByName: s = null, allowedFunctionNames: o = null, allowAssign: a = !1 } = {}) {
793
- const l = {
811
+ }), Tn = /* @__PURE__ */ new Set([F, "forloop"]), bn = /* @__PURE__ */ new Set(["where", "where_exp"]), En = /* @__PURE__ */ new Set(["date", "downcase", "join", "strip_html", "truncate", "upcase"]), yn = /* @__PURE__ */ new Set(["divided_by", "minus", "plus", "round", "size", "times"]);
812
+ function fe(t, { locate: e, text: n, roots: r = null, variables: i = /* @__PURE__ */ new Map(), functionsByName: s = null, allowedFunctionNames: o = null, allowAssign: a = !1 } = {}) {
813
+ const c = {
794
814
  allowAssign: a,
795
815
  allowedFunctionNames: o,
796
816
  assigned: /* @__PURE__ */ new Map(),
@@ -801,27 +821,27 @@ function me(t, { locate: e, text: n, roots: r = null, variables: i = /* @__PURE_
801
821
  roots: r,
802
822
  text: n
803
823
  };
804
- return D(t, i, l), { issues: l.issues, requiredRoots: [...l.requiredRoots].sort() };
824
+ return v(t, i, c), { issues: c.issues, requiredRoots: [...c.requiredRoots].sort() };
805
825
  }
806
- function Ar(t, e) {
807
- return dt.get(t) || (e == null ? void 0 : e.get(t)) || null;
826
+ function Sr(t, e) {
827
+ return ht.get(t) || (e == null ? void 0 : e.get(t)) || null;
808
828
  }
809
- function D(t, e, n) {
829
+ function v(t, e, n) {
810
830
  (t || []).forEach((r) => {
811
831
  const { token: i } = r;
812
832
  if (A.isOutputToken(i)) {
813
- const s = ce(n, i), o = G(r.value, e, n, s);
833
+ const s = ue(n, i), o = H(r.value, e, n, s);
814
834
  o && (o.type === "list" || o.type === "object") && N(n, y.OUTPUT_NOT_SCALAR, `"${s}" outputs a ${o.type}; output a field of it or use a filter such as join or size.`, i, s);
815
835
  return;
816
836
  }
817
- A.isTagToken(i) && bn(r, e, n);
837
+ A.isTagToken(i) && gn(r, e, n);
818
838
  });
819
839
  }
820
- function bn(t, e, n) {
840
+ function gn(t, e, n) {
821
841
  var o;
822
- const { name: r, token: i } = t, s = ce(n, i);
823
- if (!st.includes(r) && !(n.allowAssign && Ae.includes(r))) {
824
- const a = Ae.includes(r) ? " outside block fragments" : "";
842
+ const { name: r, token: i } = t, s = ue(n, i);
843
+ if (!lt.includes(r) && !(n.allowAssign && Re.includes(r))) {
844
+ const a = Re.includes(r) ? " outside block fragments" : "";
825
845
  N(n, y.TAG_NOT_ALLOWED, `Tag "${r}" is not allowed${a}.`, i, s);
826
846
  return;
827
847
  }
@@ -829,52 +849,52 @@ function bn(t, e, n) {
829
849
  case "if":
830
850
  case "unless":
831
851
  t.branches.forEach((a) => {
832
- G(a.value, e, n, s), D(a.templates, e, n);
833
- }), D(t.elseTemplates, e, n);
852
+ H(a.value, e, n, s), v(a.templates, e, n);
853
+ }), v(t.elseTemplates, e, n);
834
854
  break;
835
855
  case "case":
836
- G(t.value, e, n, s), t.branches.forEach((a) => {
837
- a.values.forEach((l) => I(l, e, n, s)), D(a.templates, e, n);
838
- }), D(t.elseTemplates, e, n);
856
+ H(t.value, e, n, s), t.branches.forEach((a) => {
857
+ a.values.forEach((c) => D(c, e, n, s)), v(a.templates, e, n);
858
+ }), v(t.elseTemplates, e, n);
839
859
  break;
840
860
  case "for": {
841
861
  const { variable: a } = t;
842
- ye(a, e, n, i, s);
843
- const l = I(t.collection, e, n, s);
844
- let c = null;
845
- A.isRangeToken(t.collection) ? c = S : l && l.type !== "list" ? N(n, y.LOOP_SOURCE_NOT_LIST, `"${ce(n, t.collection)}" is not a list.`, t.collection, s) : l && (c = l.item || null), Object.values(((o = t.hash) == null ? void 0 : o.hash) || {}).forEach((f) => {
846
- f && I(f, e, n, s);
847
- }), D(t.templates, new Map([...e, [a, c], ["forloop", pn]]), n), D(t.elseTemplates, e, n);
862
+ ge(a, e, n, i, s);
863
+ const c = D(t.collection, e, n, s);
864
+ let l = null;
865
+ A.isRangeToken(t.collection) ? l = w : c && c.type !== "list" ? N(n, y.LOOP_SOURCE_NOT_LIST, `"${ue(n, t.collection)}" is not a list.`, t.collection, s) : c && (l = c.item || null), Object.values(((o = t.hash) == null ? void 0 : o.hash) || {}).forEach((m) => {
866
+ m && D(m, e, n, s);
867
+ }), v(t.templates, new Map([...e, [a, l], ["forloop", hn]]), n), v(t.elseTemplates, e, n);
848
868
  break;
849
869
  }
850
870
  case "assign": {
851
- ye(t.key, e, n, i, s), n.assigned.set(t.key, G(t.value, e, n, s));
871
+ ge(t.key, e, n, i, s), n.assigned.set(t.key, H(t.value, e, n, s));
852
872
  break;
853
873
  }
854
874
  case "capture":
855
- ye(t.variable, e, n, i, s), D(t.templates, e, n), n.assigned.set(t.variable, Me);
875
+ ge(t.variable, e, n, i, s), v(t.templates, e, n), n.assigned.set(t.variable, Ue);
856
876
  break;
857
877
  }
858
878
  }
859
- function ye(t, e, n, r, i) {
860
- !Y.test(t || "") || t.startsWith("__") ? N(n, y.VARIABLE_INVALID, `Variable "${t}" must match [A-Za-z_]\\w* and must not start with "__".`, r, i) : (Ie.includes(t) || e.has(t) || n.roots && Object.hasOwn(n.roots, t)) && N(n, y.VARIABLE_INVALID, `Variable "${t}" conflicts with a data root, a loop variable or a reserved name.`, r, i);
879
+ function ge(t, e, n, r, i) {
880
+ !Q.test(t || "") || t.startsWith("__") ? N(n, y.VARIABLE_INVALID, `Variable "${t}" must match [A-Za-z_]\\w* and must not start with "__".`, r, i) : (De.includes(t) || e.has(t) || n.roots && Object.hasOwn(n.roots, t)) && N(n, y.VARIABLE_INVALID, `Variable "${t}" conflicts with a data root, a loop variable or a reserved name.`, r, i);
861
881
  }
862
- function G(t, e, n, r) {
882
+ function H(t, e, n, r) {
863
883
  if (!t)
864
884
  return null;
865
- let i = pt(t.initial, e, n, r);
885
+ let i = Tt(t.initial, e, n, r);
866
886
  return (t.filters || []).forEach((s) => {
867
- i = yn(s, i, e, n, r);
887
+ i = On(s, i, e, n, r);
868
888
  }), i;
869
889
  }
870
- function pt(t, e, n, r) {
871
- const i = [...(t == null ? void 0 : t.postfix) || []], s = i.map((o) => I(o, e, n, r));
872
- return i.length === 1 ? s[0] : i.some((o) => A.isOperatorToken(o)) ? Le : null;
890
+ function Tt(t, e, n, r) {
891
+ const i = [...(t == null ? void 0 : t.postfix) || []], s = i.map((o) => D(o, e, n, r));
892
+ return i.length === 1 ? s[0] : i.some((o) => A.isOperatorToken(o)) ? we : null;
873
893
  }
874
- function I(t, e, n, r) {
875
- return t ? A.isPropertyAccessToken(t) ? En(t, e, n, r) : A.isRangeToken(t) ? (I(t.lhs, e, n, r), I(t.rhs, e, n, r), { item: S, type: "list" }) : A.isNumberToken(t) ? S : A.isQuotedToken(t) ? Me : t.initial ? G(t, e, n, r) : null : null;
894
+ function D(t, e, n, r) {
895
+ return t ? A.isPropertyAccessToken(t) ? _n(t, e, n, r) : A.isRangeToken(t) ? (D(t.lhs, e, n, r), D(t.rhs, e, n, r), { item: w, type: "list" }) : A.isNumberToken(t) ? w : A.isQuotedToken(t) ? Ue : t.initial ? H(t, e, n, r) : null : null;
876
896
  }
877
- function En(t, e, n, r) {
897
+ function _n(t, e, n, r) {
878
898
  const [i, ...s] = t.props || [], o = i == null ? void 0 : i.content;
879
899
  if (typeof o != "string" || !A.isWordToken(i))
880
900
  return null;
@@ -889,162 +909,162 @@ function En(t, e, n, r) {
889
909
  else
890
910
  return N(n, y.ROOT_UNKNOWN, `"${o}" is not a data root of this context (${Object.keys(n.roots).join(", ")}) or a template variable.`, t, r), null;
891
911
  else return o !== F && n.requiredRoots.add(o), null;
892
- for (const l of s) {
912
+ for (const c of s) {
893
913
  if (!a)
894
914
  return null;
895
- if (A.isPropertyAccessToken(l) || l.initial) {
896
- if (I(l, e, n, r), a.type === "list") {
915
+ if (A.isPropertyAccessToken(c) || c.initial) {
916
+ if (D(c, e, n, r), a.type === "list") {
897
917
  a = a.item || null;
898
918
  continue;
899
919
  }
900
- return a.type === "object" ? null : ee(n, t, r, "only a list or an object can be indexed.");
920
+ return a.type === "object" ? null : ie(n, t, r, "only a list or an object can be indexed.");
901
921
  }
902
- if (A.isNumberToken(l)) {
922
+ if (A.isNumberToken(c)) {
903
923
  if (a.type !== "list")
904
- return ee(n, t, r, "only a list can be indexed.");
924
+ return ie(n, t, r, "only a list can be indexed.");
905
925
  a = a.item || null;
906
926
  continue;
907
927
  }
908
- const c = l.content;
928
+ const l = c.content;
909
929
  if (a.type === "list")
910
- if (c === "size")
911
- a = S;
912
- else if (c === "first" || c === "last")
930
+ if (l === "size")
931
+ a = w;
932
+ else if (l === "first" || l === "last")
913
933
  a = a.item || null;
914
934
  else
915
- return ee(n, t, r, `a list has no field "${c}" (use size, first, last or a loop).`);
916
- else if (a.type === "string" && c === "size")
917
- a = S;
918
- else if (a.type === "object" && a.fields && Object.hasOwn(a.fields, c))
919
- a = a.fields[c];
920
- else return a.type === "object" && !mn.has(o) ? null : ee(n, t, r, `field "${c}" does not exist.`);
935
+ return ie(n, t, r, `a list has no field "${l}" (use size, first, last or a loop).`);
936
+ else if (a.type === "string" && l === "size")
937
+ a = w;
938
+ else if (a.type === "object" && a.fields && Object.hasOwn(a.fields, l))
939
+ a = a.fields[l];
940
+ else return a.type === "object" && !Tn.has(o) ? null : ie(n, t, r, `field "${l}" does not exist.`);
921
941
  }
922
942
  return a;
923
943
  }
924
- function ee(t, e, n, r) {
925
- return N(t, y.PATH_UNKNOWN, `"${ce(t, e)}": ${r}`, e, n), null;
944
+ function ie(t, e, n, r) {
945
+ return N(t, y.PATH_UNKNOWN, `"${ue(t, e)}": ${r}`, e, n), null;
926
946
  }
927
- function yn(t, e, n, r, i) {
947
+ function On(t, e, n, r, i) {
928
948
  var _;
929
949
  const { name: s, args: o = [] } = t;
930
950
  if (!s)
931
951
  return N(r, y.SYNTAX_ERROR, 'A filter name is missing after "|".', t.token, i), null;
932
- const a = o.filter((m) => !Array.isArray(m)), l = o.filter((m) => Array.isArray(m));
933
- a.forEach((m) => I(m, n, r, i)), l.forEach(([, m]) => I(m, n, r, i));
934
- const c = dt.get(s), f = c || ((_ = r.functionsByName) == null ? void 0 : _.get(s));
935
- if (!f)
952
+ const a = o.filter((h) => !Array.isArray(h)), c = o.filter((h) => Array.isArray(h));
953
+ a.forEach((h) => D(h, n, r, i)), c.forEach(([, h]) => D(h, n, r, i));
954
+ const l = ht.get(s), m = l || ((_ = r.functionsByName) == null ? void 0 : _.get(s));
955
+ if (!m)
936
956
  return (r.functionsByName || !s.startsWith("__")) && N(r, y.UNKNOWN_FUNCTION, `Filter "${s}" is not available.`, t.token, i), null;
937
- if (!c && r.allowedFunctionNames && !r.allowedFunctionNames.has(s))
957
+ if (!l && r.allowedFunctionNames && !r.allowedFunctionNames.has(s))
938
958
  return N(r, y.FUNCTION_NOT_ALLOWED, `Filter "${s}" is not allowed in this data context.`, t.token, i), null;
939
- const u = (f.signature || []).slice(1), p = u.filter((m) => !m.optional && !m.variadic).length, b = u.some((m) => m.variadic);
940
- if (l.length || a.length < p || !b && a.length > u.length) {
941
- const m = b ? `at least ${p}` : p === u.length ? p : `${p}-${u.length}`;
942
- return N(r, y.FUNCTION_ARGUMENTS_INVALID, `Filter "${s}" expects ${m} argument(s)${l.length ? " and no named arguments" : ""}, got ${a.length}.`, t.token, i), null;
959
+ const u = (m.signature || []).slice(1), d = u.filter((h) => !h.optional && !h.variadic).length, f = u.some((h) => h.variadic);
960
+ if (c.length || a.length < d || !f && a.length > u.length) {
961
+ const h = f ? `at least ${d}` : d === u.length ? d : `${d}-${u.length}`;
962
+ return N(r, y.FUNCTION_ARGUMENTS_INVALID, `Filter "${s}" expects ${h} argument(s)${c.length ? " and no named arguments" : ""}, got ${a.length}.`, t.token, i), null;
943
963
  }
944
- return c ? gn(s, e, a, n, r, i) : null;
964
+ return l ? Cn(s, e, a, n, r, i) : null;
945
965
  }
946
- function gn(t, e, n, r, i, s) {
947
- const o = (e == null ? void 0 : e.type) === "list" ? e.item : null, a = (c) => !o || o.type !== "object" || typeof c != "string" ? null : o.fields && Object.hasOwn(o.fields, c) ? o.fields[c] : null, l = (c) => c && A.isQuotedToken(c) ? c.content : null;
966
+ function Cn(t, e, n, r, i, s) {
967
+ const o = (e == null ? void 0 : e.type) === "list" ? e.item : null, a = (l) => !o || o.type !== "object" || typeof l != "string" ? null : o.fields && Object.hasOwn(o.fields, l) ? o.fields[l] : null, c = (l) => l && A.isQuotedToken(l) ? l.content : null;
948
968
  if (t === "where")
949
- return a(l(n[0])), e;
969
+ return a(c(n[0])), e;
950
970
  if (t === "where_exp")
951
- return _n(l(n[0]), n[1], o, r, i, s), e;
952
- if (fn.has(t))
971
+ return An(c(n[0]), n[1], o, r, i, s), e;
972
+ if (bn.has(t))
953
973
  return e;
954
974
  if (t === "map") {
955
- const c = a(l(n[0]));
956
- return (e == null ? void 0 : e.type) === "list" ? { item: c, type: "list" } : null;
975
+ const l = a(c(n[0]));
976
+ return (e == null ? void 0 : e.type) === "list" ? { item: l, type: "list" } : null;
957
977
  }
958
- return t === "first" ? o : t === "default" ? e : Tn.has(t) ? S : hn.has(t) ? Me : null;
978
+ return t === "first" ? o : t === "default" ? e : yn.has(t) ? w : En.has(t) ? Ue : null;
959
979
  }
960
- function _n(t, e, n, r, i, s) {
980
+ function An(t, e, n, r, i, s) {
961
981
  if (!t || !e || !A.isQuotedToken(e))
962
982
  return;
963
983
  let o;
964
984
  try {
965
- o = new _t(e.content).readExpression();
966
- } catch (l) {
967
- N(i, y.SYNTAX_ERROR, `where_exp expression: ${l.message}`, e, s);
985
+ o = new Rt(e.content).readExpression();
986
+ } catch (c) {
987
+ N(i, y.SYNTAX_ERROR, `where_exp expression: ${c.message}`, e, s);
968
988
  return;
969
989
  }
970
990
  const a = { ...i, text: e.content };
971
- a.issues = [], pt(o, new Map([...r, [t, n]]), a, s), a.issues.forEach((l) => i.issues.push({ ...l, ...i.locate(e.begin) }));
991
+ a.issues = [], Tt(o, new Map([...r, [t, n]]), a, s), a.issues.forEach((c) => i.issues.push({ ...c, ...i.locate(e.begin) }));
972
992
  }
973
- function ce(t, e) {
993
+ function ue(t, e) {
974
994
  return t.text && e ? t.text.slice(e.begin, e.end) : "";
975
995
  }
976
996
  function N(t, e, n, r, i) {
977
997
  t.issues.push(O({ code: e, message: n, ...t.locate((r == null ? void 0 : r.begin) ?? 0), ...i ? { source: i } : {} }));
978
998
  }
979
- const On = /\{\{|\{%/, ge = Object.freeze({ DEPRECATED: "DEPRECATED", DRAFT: "DRAFT", PUBLISHED: "PUBLISHED" });
980
- function Rr({ template: t, kind: e, context: n, functions: r, blocks: i, allowedDeprecatedBlockRefs: s, layouts: o = [] } = {}) {
981
- var T;
982
- const a = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {}, l = e || ((T = t == null ? void 0 : t.constructor) == null ? void 0 : T.kind) || ut(a.templateKindCode), c = [], f = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
983
- if (!l)
999
+ const Rn = /\{\{|\{%/, _e = Object.freeze({ DEPRECATED: "DEPRECATED", DRAFT: "DRAFT", PUBLISHED: "PUBLISHED" });
1000
+ function Lr({ template: t, kind: e, context: n, functions: r, blocks: i, allowedDeprecatedBlockRefs: s, layouts: o = [] } = {}) {
1001
+ var b;
1002
+ const a = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {}, c = e || ((b = t == null ? void 0 : t.constructor) == null ? void 0 : b.kind) || ft(a.templateKindCode), l = [], m = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
1003
+ if (!c)
984
1004
  throw new TypeError("checkTemplate requires a template kind.");
985
- const p = a.templateSyntaxVersion ?? Pe;
986
- if (!Ze.includes(p))
987
- return c.push(O({ code: y.SYNTAX_VERSION_UNSUPPORTED, message: `Template syntax version ${p} is not supported.` })), { blockRefs: [], issues: c, layoutCodes: [], valid: !1 };
988
- const b = ft({ allowedDeprecatedBlockRefs: s, blocks: i, context: n, functions: r }), _ = a.partContent || {}, m = new Set(l.partDefinitions.map(({ partCode: d }) => d));
989
- return l.partDefinitions.forEach(({ partCode: d, required: h }) => {
990
- const E = _[d];
1005
+ const d = a.templateSyntaxVersion ?? Ie;
1006
+ if (!rt.includes(d))
1007
+ return l.push(O({ code: y.SYNTAX_VERSION_UNSUPPORTED, message: `Template syntax version ${d} is not supported.` })), { blockRefs: [], issues: l, layoutCodes: [], valid: !1 };
1008
+ const f = Et({ allowedDeprecatedBlockRefs: s, blocks: i, context: n, functions: r }), _ = a.partContent || {}, h = new Set(c.partDefinitions.map(({ partCode: p }) => p));
1009
+ return c.partDefinitions.forEach(({ partCode: p, required: T }) => {
1010
+ const E = _[p];
991
1011
  if (typeof E != "string" || !E.trim()) {
992
- h && c.push(O({ code: y.PART_REQUIRED, message: `Part "${d}" is required.`, partCode: d }));
1012
+ T && l.push(O({ code: y.PART_REQUIRED, message: `Part "${p}" is required.`, partCode: p }));
993
1013
  return;
994
1014
  }
995
- const C = le(E, { allowBlocks: !0, env: b, partCode: d });
996
- c.push(...C.issues), C.blockRefs.forEach((L) => f.add(L)), je(E).forEach((L) => {
997
- u.has(L) || c.push(...Cn(L, { env: b, layouts: o, partCode: d })), u.add(L);
1015
+ const C = de(E, { allowBlocks: !0, env: f, partCode: p });
1016
+ l.push(...C.issues), C.blockRefs.forEach((S) => m.add(S)), Be(E).forEach((S) => {
1017
+ u.has(S) || l.push(...Nn(S, { env: f, layouts: o, partCode: p })), u.add(S);
998
1018
  });
999
- }), Object.keys(_).forEach((d) => {
1000
- m.has(d) || c.push(O({ code: y.PART_UNKNOWN, message: `Part "${d}" is not declared by template kind ${l.templateKindCode}.`, partCode: d }));
1001
- }), dn(l, a).forEach(({ fieldPath: d, content: h, expressionAllowed: E }) => {
1019
+ }), Object.keys(_).forEach((p) => {
1020
+ h.has(p) || l.push(O({ code: y.PART_UNKNOWN, message: `Part "${p}" is not declared by template kind ${c.templateKindCode}.`, partCode: p }));
1021
+ }), fn(c, a).forEach(({ fieldPath: p, content: T, expressionAllowed: E }) => {
1002
1022
  if (!E) {
1003
- On.test(h) && c.push(O({ code: y.FIELD_EXPRESSION_NOT_ALLOWED, message: `Field "${d}" must be a fixed value.`, partCode: d }));
1023
+ Rn.test(T) && l.push(O({ code: y.FIELD_EXPRESSION_NOT_ALLOWED, message: `Field "${p}" must be a fixed value.`, partCode: p }));
1004
1024
  return;
1005
1025
  }
1006
- c.push(...le(h, { allowBlocks: !1, env: b, partCode: d }).issues);
1007
- }), { blockRefs: [...f], issues: c, layoutCodes: [...u], valid: !K(c) };
1026
+ l.push(...de(T, { allowBlocks: !1, env: f, partCode: p }).issues);
1027
+ }), { blockRefs: [...m], issues: l, layoutCodes: [...u], valid: !K(l) };
1008
1028
  }
1009
- function Cn(t, { env: e, layouts: n, partCode: r }) {
1010
- const i = rt({ layoutCode: t, layouts: n });
1029
+ function Nn(t, { env: e, layouts: n, partCode: r }) {
1030
+ const i = at({ layoutCode: t, layouts: n });
1011
1031
  if (!i)
1012
1032
  return [O({ code: y.LAYOUT_NOT_FOUND, layoutCode: t, message: `Layout ${t} has no published version.`, partCode: r })];
1013
1033
  const s = `${i.layoutCode}@${i.version}`;
1014
1034
  return [
1015
- ...le(i.html || "", { allowBlocks: !1, env: e, partCode: r }).issues,
1016
- ...it(i.html)
1035
+ ...de(i.html || "", { allowBlocks: !1, env: e, partCode: r }).issues,
1036
+ ...ct(i.html)
1017
1037
  ].map((o) => ({ ...o, layoutRef: s, message: `${s}: ${o.message}`, partCode: r }));
1018
1038
  }
1019
- function Nr({ content: t, partCode: e, allowBlocks: n = !0, context: r, functions: i, blocks: s, allowedDeprecatedBlockRefs: o } = {}) {
1020
- const a = ft({ allowedDeprecatedBlockRefs: o, blocks: s, context: r, functions: i }), l = le(t, { allowBlocks: n, env: a, partCode: e });
1021
- return { ...l, valid: !K(l.issues) };
1039
+ function wr({ content: t, partCode: e, allowBlocks: n = !0, context: r, functions: i, blocks: s, allowedDeprecatedBlockRefs: o } = {}) {
1040
+ const a = Et({ allowedDeprecatedBlockRefs: o, blocks: s, context: r, functions: i }), c = de(t, { allowBlocks: n, env: a, partCode: e });
1041
+ return { ...c, valid: !K(c.issues) };
1022
1042
  }
1023
- function An({ fragment: t, params: e, functions: n, context: r } = {}) {
1024
- const { definitions: i, errors: s } = X(e), o = s.map((l) => O({ code: y.BLOCK_PARAMS_INVALID, message: l })), a = mt(t, { allowAssign: !0, context: r, functions: n, paramsRoot: Be(i) });
1043
+ function Sn({ fragment: t, params: e, functions: n, context: r } = {}) {
1044
+ const { definitions: i, errors: s } = Z(e), o = s.map((c) => O({ code: y.BLOCK_PARAMS_INVALID, message: c })), a = bt(t, { allowAssign: !0, context: r, functions: n, paramsRoot: xe(i) });
1025
1045
  return o.push(...a.issues), { issues: o, requiredRoots: a.requiredRoots, valid: !K(o) };
1026
1046
  }
1027
- function Rn({ html: t, functions: e } = {}) {
1028
- const n = mt(t || "", { allowAssign: !1, functions: e, paramsRoot: Be([]) }), r = [...n.issues.map((i) => ({ ...i, partCode: "layout" })), ...it(t)];
1047
+ function Ln({ html: t, functions: e } = {}) {
1048
+ const n = bt(t || "", { allowAssign: !1, functions: e, paramsRoot: xe([]) }), r = [...n.issues.map((i) => ({ ...i, partCode: "layout" })), ...ct(t)];
1029
1049
  return { issues: r, requiredRoots: n.requiredRoots, valid: !K(r) };
1030
1050
  }
1031
- function mt(t, { allowAssign: e, context: n, functions: r, paramsRoot: i }) {
1032
- const s = de(n), o = J(t, { allowBlocks: !1 }), a = r || (s ? pe() : null), l = me(o.templates, {
1051
+ function bt(t, { allowAssign: e, context: n, functions: r, paramsRoot: i }) {
1052
+ const s = J(n), o = te(t, { allowBlocks: !1 }), a = r || (s ? me() : null), c = fe(o.templates, {
1033
1053
  allowAssign: e,
1034
1054
  allowedFunctionNames: s ? new Set(s.functionNames || []) : null,
1035
- functionsByName: a ? new Map(a.map((c) => [c.name, c])) : null,
1055
+ functionsByName: a ? new Map(a.map((l) => [l.name, l])) : null,
1036
1056
  locate: o.locate,
1037
1057
  roots: (s == null ? void 0 : s.roots) || null,
1038
1058
  text: o.text,
1039
1059
  variables: /* @__PURE__ */ new Map([[F, i]])
1040
1060
  });
1041
- return { issues: [...o.issues, ...l.issues], requiredRoots: l.requiredRoots };
1061
+ return { issues: [...o.issues, ...c.issues], requiredRoots: c.requiredRoots };
1042
1062
  }
1043
- function ft({ allowedDeprecatedBlockRefs: t = [], blocks: e = [], context: n, functions: r }) {
1044
- const i = de(n);
1063
+ function Et({ allowedDeprecatedBlockRefs: t = [], blocks: e = [], context: n, functions: r }) {
1064
+ const i = J(n);
1045
1065
  if (!i || !i.roots)
1046
1066
  throw new TypeError("Template checks require a data context.");
1047
- const s = r || pe();
1067
+ const s = r || me();
1048
1068
  return {
1049
1069
  allowedDeprecatedBlockRefs: new Set(t),
1050
1070
  allowedFunctionNames: new Set(i.functionNames || []),
@@ -1057,68 +1077,68 @@ function ft({ allowedDeprecatedBlockRefs: t = [], blocks: e = [], context: n, fu
1057
1077
  roots: i.roots
1058
1078
  };
1059
1079
  }
1060
- function le(t, { allowBlocks: e, env: n, partCode: r }) {
1061
- const i = J(t, { allowBlocks: e, partCode: r }), s = [...i.issues];
1062
- return s.push(...me(i.templates, {
1080
+ function de(t, { allowBlocks: e, env: n, partCode: r }) {
1081
+ const i = te(t, { allowBlocks: e, partCode: r }), s = [...i.issues];
1082
+ return s.push(...fe(i.templates, {
1063
1083
  allowedFunctionNames: n.allowedFunctionNames,
1064
1084
  functionsByName: n.functionsByName,
1065
1085
  locate: i.locate,
1066
1086
  roots: n.roots,
1067
1087
  text: i.text
1068
- }).issues), i.blocks.forEach((o) => Nn(o, n, s)), { blockRefs: i.blockRefs, issues: s };
1088
+ }).issues), i.blocks.forEach((o) => wn(o, n, s)), { blockRefs: i.blockRefs, issues: s };
1069
1089
  }
1070
- function Nn(t, e, n) {
1071
- const { blockRef: r, location: i } = t, s = (u, p, b) => n.push(O({ blockRef: r, code: u, message: p, severity: b, ...i })), o = e.blocksByRef.get(r);
1090
+ function wn(t, e, n) {
1091
+ const { blockRef: r, location: i } = t, s = (u, d, f) => n.push(O({ blockRef: r, code: u, message: d, severity: f, ...i })), o = e.blocksByRef.get(r);
1072
1092
  if (!o) {
1073
1093
  s(y.UNKNOWN_BLOCK, `Block ${r} does not exist.`);
1074
1094
  return;
1075
1095
  }
1076
- const a = o.stateCode || ge.PUBLISHED;
1077
- if (a === ge.DRAFT) {
1096
+ const a = o.stateCode || _e.PUBLISHED;
1097
+ if (a === _e.DRAFT) {
1078
1098
  s(y.BLOCK_NOT_PUBLISHED, `Block ${r} is not published.`);
1079
1099
  return;
1080
1100
  }
1081
- if (a === ge.DEPRECATED) {
1101
+ if (a === _e.DEPRECATED) {
1082
1102
  const u = e.allowedDeprecatedBlockRefs.has(r);
1083
1103
  s(
1084
1104
  y.BLOCK_DEPRECATED,
1085
1105
  u ? `Block ${r} is deprecated; consider a newer version.` : `Block ${r} is deprecated and cannot be added.`,
1086
- u ? H.WARNING : H.ERROR
1106
+ u ? X.WARNING : X.ERROR
1087
1107
  );
1088
1108
  }
1089
1109
  if (o.contextCode !== e.contextCode) {
1090
1110
  s(y.BLOCK_CONTEXT_MISMATCH, `Block ${r} is for data context ${o.contextCode || "(none)"}, not ${e.contextCode}.`);
1091
1111
  return;
1092
1112
  }
1093
- const l = (o.requiredRoots || []).filter((u) => !Object.hasOwn(e.roots, u));
1094
- l.length && s(y.BLOCK_ROOT_NOT_IN_CONTEXT, `Block ${r} requires data roots not in this context: ${l.join(", ")}.`);
1095
- const { definitions: c } = X(o.params), { errors: f } = lt(c, t.params);
1096
- if (f.forEach((u) => s(y.BLOCK_PARAMS_INVALID, `${r}: ${u}`)), typeof o.fragment == "string" && !l.length) {
1097
- const u = J(o.fragment, { allowBlocks: !1 }), p = me(u.templates, {
1113
+ const c = (o.requiredRoots || []).filter((u) => !Object.hasOwn(e.roots, u));
1114
+ c.length && s(y.BLOCK_ROOT_NOT_IN_CONTEXT, `Block ${r} requires data roots not in this context: ${c.join(", ")}.`);
1115
+ const { definitions: l } = Z(o.params), { errors: m } = mt(l, t.params);
1116
+ if (m.forEach((u) => s(y.BLOCK_PARAMS_INVALID, `${r}: ${u}`)), typeof o.fragment == "string" && !c.length) {
1117
+ const u = te(o.fragment, { allowBlocks: !1 }), d = fe(u.templates, {
1098
1118
  allowAssign: !0,
1099
1119
  allowedFunctionNames: e.allowedFunctionNames,
1100
1120
  functionsByName: e.functionsByName,
1101
1121
  locate: u.locate,
1102
1122
  roots: e.roots,
1103
1123
  text: u.text,
1104
- variables: /* @__PURE__ */ new Map([[F, Be(c)]])
1124
+ variables: /* @__PURE__ */ new Map([[F, xe(l)]])
1105
1125
  });
1106
- [...u.issues, ...p.issues].forEach((b) => n.push(O({
1126
+ [...u.issues, ...d.issues].forEach((f) => n.push(O({
1107
1127
  ...i,
1108
1128
  blockRef: r,
1109
- code: b.code,
1110
- message: `${r}: ${b.message}`,
1111
- severity: b.severity
1129
+ code: f.code,
1130
+ message: `${r}: ${f.message}`,
1131
+ severity: f.severity
1112
1132
  })));
1113
1133
  }
1114
1134
  }
1115
- const Sn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], Ln = ["blockCode", "category", "contextCode", "description", "fragment", "name", "tenantCode", "version"], He = ["category", "contextCode", "description", "fragment", "name", "params"], wn = /^[A-Z][A-Z0-9_]*$/, Sr = Object.freeze({
1135
+ const Pn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], In = ["blockCode", "category", "contextCode", "description", "fragment", "name", "tenantCode", "version"], Je = ["category", "contextCode", "description", "fragment", "name", "params"], Dn = /^[A-Z][A-Z0-9_]*$/, Pr = Object.freeze({
1116
1136
  DEPRECATED: "TEMPLATE_BLOCK_DEPRECATED",
1117
1137
  PUBLISHED: "TEMPLATE_BLOCK_PUBLISHED"
1118
1138
  });
1119
- class Pn extends Qe {
1139
+ class vn extends tt {
1120
1140
  constructor(e = {}) {
1121
- e = e || {}, super(e), this._type = e._type || "TemplateBlock", this.blockCode = e.blockCode, this.category = e.category || "", this.contextCode = e.contextCode || "", this.description = e.description || "", this.fragment = typeof e.fragment == "string" ? e.fragment : "", this.lifecycle = e.lifecycle ? Se.init(e.lifecycle) : null, this.name = e.name || "", this.params = X(e.params).definitions, this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
1141
+ e = e || {}, super(e), this._type = e._type || "TemplateBlock", this.blockCode = e.blockCode, this.category = e.category || "", this.contextCode = e.contextCode || "", this.description = e.description || "", this.fragment = typeof e.fragment == "string" ? e.fragment : "", this.lifecycle = e.lifecycle ? Le.init(e.lifecycle) : null, this.name = e.name || "", this.params = Z(e.params).definitions, this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
1122
1142
  }
1123
1143
  static get _classname() {
1124
1144
  return "TemplateBlock";
@@ -1130,13 +1150,13 @@ class Pn extends Qe {
1130
1150
  static create({ actionRevision: e = 1, modified: n = Date.now(), ...r } = {}) {
1131
1151
  return this.init({
1132
1152
  ...r,
1133
- lifecycle: Se.create({ actionRevision: e, modified: n }).toObject(),
1153
+ lifecycle: Le.create({ actionRevision: e, modified: n }).toObject(),
1134
1154
  meta: { ...r.meta, revision: e }
1135
1155
  });
1136
1156
  }
1137
1157
  get isValid() {
1138
1158
  var e;
1139
- return super.isValid && wn.test(this.blockCode || "") && !!this.contextCode && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
1159
+ return super.isValid && Dn.test(this.blockCode || "") && !!this.contextCode && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
1140
1160
  }
1141
1161
  get blockRef() {
1142
1162
  return `${this.blockCode}@${this.version}`;
@@ -1160,15 +1180,15 @@ class Pn extends Qe {
1160
1180
  */
1161
1181
  check({ context: e, functions: n } = {}) {
1162
1182
  var r;
1163
- if (e && ((r = de(e)) == null ? void 0 : r.contextCode) !== this.contextCode)
1183
+ if (e && ((r = J(e)) == null ? void 0 : r.contextCode) !== this.contextCode)
1164
1184
  throw new TypeError(`TemplateBlock ${this.blockRef} belongs to data context ${this.contextCode}.`);
1165
- return An({ context: e, fragment: this.fragment, functions: n, params: this.params });
1185
+ return Sn({ context: e, fragment: this.fragment, functions: n, params: this.params });
1166
1186
  }
1167
1187
  update(e = {}) {
1168
- if (He.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
1188
+ if (Je.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
1169
1189
  throw new Error(`TemplateBlock ${this.blockRef} is ${this.stateCode}; publish changes as a new version.`);
1170
- return He.forEach((r) => {
1171
- Object.hasOwn(e, r) && (this[r] = r === "params" ? X(e.params).definitions : e[r] ?? "");
1190
+ return Je.forEach((r) => {
1191
+ Object.hasOwn(e, r) && (this[r] = r === "params" ? Z(e.params).definitions : e[r] ?? "");
1172
1192
  }), super.update(e);
1173
1193
  }
1174
1194
  /**
@@ -1178,7 +1198,7 @@ class Pn extends Qe {
1178
1198
  publish({ actionRevision: e = this.revision + 1, context: n, modified: r = Date.now(), functions: i } = {}) {
1179
1199
  const s = this.check({ context: n, functions: i });
1180
1200
  if (!s.valid)
1181
- throw new Q(s.issues.map((o) => ({ ...o, blockRef: this.blockRef })));
1201
+ throw new ee(s.issues.map((o) => ({ ...o, blockRef: this.blockRef })));
1182
1202
  return this.lifecycle.transition("publication", { actionRevision: e, modified: r, stateCode: z.PUBLISHED }), this.requiredRoots = s.requiredRoots, this.meta.revision = e, this.setModified();
1183
1203
  }
1184
1204
  /** Hide this version from editors; templates that use it still render. */
@@ -1187,7 +1207,7 @@ class Pn extends Qe {
1187
1207
  }
1188
1208
  /** EntityAction for the latest publication transition. */
1189
1209
  createEntityAction({ actionCode: e, actor: n, previousStateCode: r, timestamp: i = Date.now(), ...s } = {}) {
1190
- return Je.init({
1210
+ return nt.init({
1191
1211
  ...s,
1192
1212
  actionCode: e,
1193
1213
  actor: n,
@@ -1210,7 +1230,7 @@ class Pn extends Qe {
1210
1230
  description: this.description,
1211
1231
  fragment: this.fragment,
1212
1232
  name: this.name,
1213
- params: Ke(this.params),
1233
+ params: Ge(this.params),
1214
1234
  requiredRoots: [...this.requiredRoots],
1215
1235
  stateCode: this.stateCode,
1216
1236
  ...this.tenantCode ? { tenantCode: this.tenantCode } : {},
@@ -1224,55 +1244,52 @@ class Pn extends Qe {
1224
1244
  const e = {
1225
1245
  _type: this._type,
1226
1246
  ...this.lifecycle ? { lifecycle: this.lifecycle.toObject() } : {},
1227
- meta: w(this.meta, Sn),
1228
- params: Ke(this.params),
1247
+ meta: L(this.meta, Pn),
1248
+ params: Ge(this.params),
1229
1249
  requiredRoots: [...this.requiredRoots],
1230
- ...w(this, Ln)
1250
+ ...L(this, In)
1231
1251
  };
1232
1252
  return typeof this.id < "u" && (e.id = this.id), e;
1233
1253
  }
1234
1254
  }
1235
- const te = ["email", "name"], In = ["bcc", "cc", "from", "replyTo"];
1236
- class Dn extends rn {
1255
+ const G = ["email", "name"], jn = ["bcc", "cc", "from", "replyTo", "to"];
1256
+ class Bn extends an {
1237
1257
  constructor(e = {}) {
1238
- if (e = e || {}, Array.isArray(e.to) ? e.to.length : e.to)
1239
- throw new TypeError('TemplateEmail does not accept "to"; recipients come from the sending job.');
1240
- super(e), this._type = e._type || "TemplateEmail", this.bcc = _e(e.bcc), this.cc = _e(e.cc), this.from = re(e.from), this.replyTo = re(e.replyTo);
1258
+ e = e || {}, super(e), this._type = e._type || "TemplateEmail", this.bcc = Oe(e.bcc), this.cc = Oe(e.cc), this.from = W(e.from), this.replyTo = W(e.replyTo), this.to = W(e.to);
1241
1259
  }
1242
1260
  static get _classname() {
1243
1261
  return "TemplateEmail";
1244
1262
  }
1245
1263
  static get kind() {
1246
- return $e;
1264
+ return Me;
1247
1265
  }
1248
1266
  update(e = {}) {
1249
- if (Array.isArray(e.to) ? e.to.length : e.to)
1250
- throw new TypeError('TemplateEmail does not accept "to"; recipients come from the sending job.');
1251
- return In.forEach((n) => {
1252
- Object.hasOwn(e, n) && (this[n] = n === "cc" || n === "bcc" ? _e(e[n]) : re(e[n]));
1267
+ return jn.forEach((n) => {
1268
+ Object.hasOwn(e, n) && (this[n] = n === "cc" || n === "bcc" ? Oe(e[n]) : W(e[n]));
1253
1269
  }), super.update(e);
1254
1270
  }
1255
1271
  toObject() {
1256
1272
  return {
1257
1273
  ...super.toObject(),
1258
- bcc: this.bcc.map((e) => w(e, te)),
1259
- cc: this.cc.map((e) => w(e, te)),
1260
- from: this.from ? w(this.from, te) : null,
1261
- replyTo: this.replyTo ? w(this.replyTo, te) : null
1274
+ bcc: this.bcc.map((e) => L(e, G)),
1275
+ cc: this.cc.map((e) => L(e, G)),
1276
+ from: this.from ? L(this.from, G) : null,
1277
+ replyTo: this.replyTo ? L(this.replyTo, G) : null,
1278
+ to: this.to ? L(this.to, G) : null
1262
1279
  };
1263
1280
  }
1264
1281
  }
1265
- function re(t) {
1282
+ function W(t) {
1266
1283
  return t ? typeof t == "string" ? t.trim() ? { email: t.trim() } : null : typeof t != "object" || !t.email ? null : {
1267
1284
  email: String(t.email).trim(),
1268
1285
  ...t.name ? { name: String(t.name) } : {}
1269
1286
  } : null;
1270
1287
  }
1271
- function _e(t) {
1272
- return (Array.isArray(t) ? t : []).map(re).filter(Boolean);
1288
+ function Oe(t) {
1289
+ return (Array.isArray(t) ? t : []).map(W).filter(Boolean);
1273
1290
  }
1274
- const Oe = z;
1275
- class Ye extends Se {
1291
+ const Ce = z;
1292
+ class Ze extends Le {
1276
1293
  static get _classname() {
1277
1294
  return "LifecycleTemplateLayout";
1278
1295
  }
@@ -1280,13 +1297,13 @@ class Ye extends Se {
1280
1297
  return "TemplateLayout";
1281
1298
  }
1282
1299
  }
1283
- const vn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], jn = ["description", "eventShortCode", "html", "layoutCode", "name", "templateKindCode", "tenantCode", "version"], Xe = ["description", "html", "name"], Bn = /^[A-Z][A-Z0-9_]*$/, Lr = Object.freeze({
1300
+ const xn = ["active", "created", "creator", "deleted", "modified", "owner", "revision"], $n = ["description", "eventShortCode", "html", "layoutCode", "name", "templateKindCode", "tenantCode", "version"], et = ["description", "html", "name"], Mn = /^[A-Z][A-Z0-9_]*$/, Ir = Object.freeze({
1284
1301
  DEPRECATED: "TEMPLATE_LAYOUT_DEPRECATED",
1285
1302
  PUBLISHED: "TEMPLATE_LAYOUT_PUBLISHED"
1286
1303
  });
1287
- class wr extends Qe {
1304
+ class Dr extends tt {
1288
1305
  constructor(e = {}) {
1289
- e = e || {}, super(e), this._type = e._type || "TemplateLayout", this.description = e.description || "", this.eventShortCode = e.eventShortCode || void 0, this.html = typeof e.html == "string" ? e.html : "", this.layoutCode = e.layoutCode, this.lifecycle = e.lifecycle ? Ye.init(e.lifecycle) : null, this.name = e.name || "", this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.templateKindCode = e.templateKindCode || xe.EMAIL, this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
1306
+ e = e || {}, super(e), this._type = e._type || "TemplateLayout", this.description = e.description || "", this.eventShortCode = e.eventShortCode || void 0, this.html = typeof e.html == "string" ? e.html : "", this.layoutCode = e.layoutCode, this.lifecycle = e.lifecycle ? Ze.init(e.lifecycle) : null, this.name = e.name || "", this.requiredRoots = Array.isArray(e.requiredRoots) ? [...e.requiredRoots] : [], this.templateKindCode = e.templateKindCode || $e.EMAIL, this.tenantCode = e.tenantCode || void 0, this.version = Number(e.version);
1290
1307
  }
1291
1308
  static get _classname() {
1292
1309
  return "TemplateLayout";
@@ -1298,13 +1315,13 @@ class wr extends Qe {
1298
1315
  static create({ actionRevision: e = 1, modified: n = Date.now(), ...r } = {}) {
1299
1316
  return this.init({
1300
1317
  ...r,
1301
- lifecycle: Ye.create({ actionRevision: e, modified: n }).toObject(),
1318
+ lifecycle: Ze.create({ actionRevision: e, modified: n }).toObject(),
1302
1319
  meta: { ...r.meta, revision: e }
1303
1320
  });
1304
1321
  }
1305
1322
  get isValid() {
1306
1323
  var e;
1307
- return super.isValid && Bn.test(this.layoutCode || "") && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
1324
+ return super.isValid && Mn.test(this.layoutCode || "") && Number.isInteger(this.version) && this.version >= 1 && !!((e = this.lifecycle) != null && e.isValid);
1308
1325
  }
1309
1326
  get layoutRef() {
1310
1327
  return `${this.layoutCode}@${this.version}`;
@@ -1314,7 +1331,7 @@ class wr extends Qe {
1314
1331
  return ((n = (e = this.lifecycle) == null ? void 0 : e.getState("publication")) == null ? void 0 : n.stateCode) || null;
1315
1332
  }
1316
1333
  get isDraft() {
1317
- return this.stateCode === Oe.DRAFT;
1334
+ return this.stateCode === Ce.DRAFT;
1318
1335
  }
1319
1336
  getCode() {
1320
1337
  return this.layoutRef;
@@ -1324,12 +1341,12 @@ class wr extends Qe {
1324
1341
  }
1325
1342
  /** Check the HTML without changing the layout. */
1326
1343
  check({ functions: e } = {}) {
1327
- return Rn({ functions: e, html: this.html });
1344
+ return Ln({ functions: e, html: this.html });
1328
1345
  }
1329
1346
  update(e = {}) {
1330
- if (Xe.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
1347
+ if (et.some((r) => Object.hasOwn(e, r)) && !this.isDraft)
1331
1348
  throw new Error(`TemplateLayout ${this.layoutRef} is ${this.stateCode}; publish changes as a new version.`);
1332
- return Xe.forEach((r) => {
1349
+ return et.forEach((r) => {
1333
1350
  Object.hasOwn(e, r) && (this[r] = e[r] ?? "");
1334
1351
  }), super.update(e);
1335
1352
  }
@@ -1340,16 +1357,16 @@ class wr extends Qe {
1340
1357
  publish({ actionRevision: e = this.revision + 1, modified: n = Date.now(), functions: r } = {}) {
1341
1358
  const i = this.check({ functions: r });
1342
1359
  if (!i.valid)
1343
- throw new Q(i.issues.map((s) => ({ ...s, layoutRef: this.layoutRef })));
1344
- return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode: Oe.PUBLISHED }), this.requiredRoots = i.requiredRoots, this.meta.revision = e, this.setModified();
1360
+ throw new ee(i.issues.map((s) => ({ ...s, layoutRef: this.layoutRef })));
1361
+ return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode: Ce.PUBLISHED }), this.requiredRoots = i.requiredRoots, this.meta.revision = e, this.setModified();
1345
1362
  }
1346
1363
  /** Retire this version; templates fall back to an older published version, if any. */
1347
1364
  deprecate({ actionRevision: e = this.revision + 1, modified: n = Date.now() } = {}) {
1348
- return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode: Oe.DEPRECATED }), this.meta.revision = e, this.setModified();
1365
+ return this.lifecycle.transition("publication", { actionRevision: e, modified: n, stateCode: Ce.DEPRECATED }), this.meta.revision = e, this.setModified();
1349
1366
  }
1350
1367
  /** EntityAction for the latest publication transition. */
1351
1368
  createEntityAction({ actionCode: e, actor: n, previousStateCode: r, timestamp: i = Date.now(), ...s } = {}) {
1352
- return Je.init({
1369
+ return nt.init({
1353
1370
  ...s,
1354
1371
  actionCode: e,
1355
1372
  actor: n,
@@ -1385,22 +1402,22 @@ class wr extends Qe {
1385
1402
  const e = {
1386
1403
  _type: this._type,
1387
1404
  ...this.lifecycle ? { lifecycle: this.lifecycle.toObject() } : {},
1388
- meta: w(this.meta, vn),
1405
+ meta: L(this.meta, xn),
1389
1406
  requiredRoots: [...this.requiredRoots],
1390
- ...w(this, jn)
1407
+ ...L(this, $n)
1391
1408
  };
1392
1409
  return typeof this.id < "u" && (e.id = this.id), e;
1393
1410
  }
1394
1411
  }
1395
- const xn = Object.freeze({
1412
+ const Un = Object.freeze({
1396
1413
  memoryLimit: 1e7,
1397
1414
  parseLimit: 1024 * 1024,
1398
1415
  renderLimit: 1e3
1399
- }), ht = "qw_block";
1400
- let W = null;
1401
- const $n = {
1416
+ }), yt = "qw_block";
1417
+ let Y = null;
1418
+ const kn = {
1402
1419
  parse(t) {
1403
- if (this.block = W == null ? void 0 : W[Number(t.args)], !this.block)
1420
+ if (this.block = Y == null ? void 0 : Y[Number(t.args)], !this.block)
1404
1421
  throw new Error(`Unknown block instance ${t.args}.`);
1405
1422
  },
1406
1423
  *render(t, e) {
@@ -1408,183 +1425,184 @@ const $n = {
1408
1425
  yield this.liquid.renderer.renderTemplates(this.block.templates, n, e);
1409
1426
  }
1410
1427
  };
1411
- function Mn({ maxCacheEntries: t = 500, limits: e = {} } = {}) {
1412
- const n = /* @__PURE__ */ new Map(), r = Object.freeze({ ...xn, ...e });
1428
+ function zn({ maxCacheEntries: t = 500, limits: e = {} } = {}) {
1429
+ const n = /* @__PURE__ */ new Map(), r = Object.freeze({ ...Un, ...e });
1413
1430
  let i = null;
1414
1431
  const s = () => {
1415
- const { filters: u, version: p } = vt();
1416
- if ((i == null ? void 0 : i.version) === p)
1432
+ const { filters: u, version: d } = xt();
1433
+ if ((i == null ? void 0 : i.version) === d)
1417
1434
  return i;
1418
1435
  n.clear();
1419
- const b = (_) => {
1420
- const m = ct({ escape: _, limits: r, tags: [...st, ...Ae] });
1421
- return u.forEach(({ name: T, handler: d, raw: h }) => m.registerFilter(T, { handler: d, raw: _ && h })), m.registerTag(ht, $n), m;
1436
+ const f = (_) => {
1437
+ const h = pt({ escape: _, limits: r, tags: [...lt, ...Re] });
1438
+ return u.forEach(({ name: b, handler: p, raw: T }) => h.registerFilter(b, { handler: p, raw: _ && T })), h.registerTag(yt, kn), h;
1422
1439
  };
1423
- return i = { html: b(!0), text: b(!1), version: p }, i;
1424
- }, o = ({ content: u, contentType: p, partCode: b, allowedFunctions: _, blocks: m, allowBlocks: T, cacheKey: d }) => {
1440
+ return i = { html: f(!0), text: f(!1), version: d }, i;
1441
+ }, o = ({ content: u, contentType: d, partCode: f, allowedFunctions: _, blocks: h, allowBlocks: b, cacheKey: p }) => {
1425
1442
  s();
1426
- const h = d ? `${d}\0${b}\0${p}\0${_.join(",")}` : null;
1427
- if (h && n.has(h)) {
1428
- const C = n.get(h);
1429
- return n.delete(h), n.set(h, C), C;
1443
+ const T = p ? `${p}\0${f}\0${d}\0${_.join(",")}` : null;
1444
+ if (T && n.has(T)) {
1445
+ const C = n.get(T);
1446
+ return n.delete(T), n.set(T, C), C;
1430
1447
  }
1431
- const E = Vn({ allowBlocks: T, allowedFunctions: _, blocks: m, content: u, contentType: p, engines: s(), partCode: b });
1432
- return h && (n.set(h, E), n.size > t && n.delete(n.keys().next().value)), E;
1433
- }, a = ({ content: u, contentType: p = x.TEXT_HTML, partCode: b, data: _, context: m, blocks: T, cacheKey: d, allowBlocks: h = !0 } = {}) => {
1434
- const E = de(m);
1448
+ const E = qn({ allowBlocks: b, allowedFunctions: _, blocks: h, content: u, contentType: d, engines: s(), partCode: f });
1449
+ return T && (n.set(T, E), n.size > t && n.delete(n.keys().next().value)), E;
1450
+ }, a = ({ content: u, contentType: d = x.TEXT_HTML, partCode: f, data: _, context: h, blocks: b, cacheKey: p, allowBlocks: T = !0 } = {}) => {
1451
+ const E = J(h);
1435
1452
  if (!E)
1436
1453
  throw new TypeError("Template rendering requires a data context.");
1437
1454
  return o({
1438
- allowBlocks: h,
1455
+ allowBlocks: T,
1439
1456
  allowedFunctions: [...E.functionNames || []].sort(),
1440
- blocks: zn(T),
1441
- cacheKey: d,
1457
+ blocks: Kn(b),
1458
+ cacheKey: p,
1442
1459
  content: u ?? "",
1443
- contentType: p,
1444
- partCode: b
1460
+ contentType: d,
1461
+ partCode: f
1445
1462
  }).render(_ || {});
1446
1463
  };
1447
- return Object.freeze({ clearCache: () => n.clear(), renderBlock: ({ block: u, params: p = {}, data: b, context: _ } = {}) => {
1448
- const m = typeof (u == null ? void 0 : u.describe) == "function" ? u.describe() : u, T = `${m.blockCode}@${m.version}`, d = JSON.stringify(p).replace(/&/g, "&amp;").replace(/'/g, "&#39;");
1464
+ return Object.freeze({ clearCache: () => n.clear(), renderBlock: ({ block: u, params: d = {}, data: f, context: _ } = {}) => {
1465
+ const h = typeof (u == null ? void 0 : u.describe) == "function" ? u.describe() : u, b = `${h.blockCode}@${h.version}`, p = JSON.stringify(d).replace(/&/g, "&amp;").replace(/'/g, "&#39;");
1449
1466
  return a({
1450
- blocks: [{ ...m, stateCode: "PUBLISHED" }],
1451
- content: `<div data-qw-block="${T}" data-qw-params='${d}'></div>`,
1467
+ blocks: [{ ...h, stateCode: "PUBLISHED" }],
1468
+ content: `<div data-qw-block="${b}" data-qw-params='${p}'></div>`,
1452
1469
  context: _,
1453
- data: b,
1470
+ data: f,
1454
1471
  partCode: "block"
1455
1472
  });
1456
- }, renderContent: a, renderTemplate: ({ template: u, kind: p, data: b, context: _, blocks: m, cacheKey: T, draft: d = !1, layouts: h = [] } = {}) => {
1457
- var ze;
1458
- const E = typeof (u == null ? void 0 : u.toObject) == "function" ? u.toObject() : u || {}, C = p || ((ze = u == null ? void 0 : u.constructor) == null ? void 0 : ze.kind) || ut(E.templateKindCode);
1473
+ }, renderContent: a, renderTemplate: ({ template: u, kind: d, data: f, context: _, blocks: h, cacheKey: b, draft: p = !1, layouts: T = [] } = {}) => {
1474
+ var Fe;
1475
+ const E = typeof (u == null ? void 0 : u.toObject) == "function" ? u.toObject() : u || {}, C = d || ((Fe = u == null ? void 0 : u.constructor) == null ? void 0 : Fe.kind) || ft(E.templateKindCode);
1459
1476
  if (!C)
1460
1477
  throw new TypeError("renderTemplate requires a template kind.");
1461
- Un(E.templateSyntaxVersion);
1462
- const L = d ? null : T ?? kn(E), Te = {};
1463
- return C.partDefinitions.forEach(({ partCode: $, contentType: be }) => {
1464
- var Ve;
1465
- const Z = (Ve = E.partContent) == null ? void 0 : Ve[$];
1466
- if (typeof Z != "string" || !Z)
1478
+ Vn(E.templateSyntaxVersion);
1479
+ const S = J(_), Ve = S != null && S.includeTemplateDocumentReference ? { ...f, template: { documentReference: E.documentReference ?? "" } } : f, ne = p ? null : b ?? Fn(E), be = {};
1480
+ return C.partDefinitions.forEach(({ partCode: $, contentType: Ee }) => {
1481
+ var Ke;
1482
+ const re = (Ke = E.partContent) == null ? void 0 : Ke[$];
1483
+ if (typeof re != "string" || !re)
1467
1484
  return;
1468
- if (be !== x.TEXT_HTML) {
1469
- Te[$] = a({ blocks: m, cacheKey: L, content: Z, context: _, contentType: be, data: b, partCode: $ });
1485
+ if (Ee !== x.TEXT_HTML) {
1486
+ be[$] = a({ blocks: h, cacheKey: ne, content: re, context: S, contentType: Ee, data: Ve, partCode: $ });
1470
1487
  return;
1471
1488
  }
1472
- const q = kt({ html: Z, layouts: h });
1489
+ const q = Ft({ html: re, layouts: T });
1473
1490
  if (q.missingLayoutCodes.length)
1474
- throw new v({ message: `Layout ${q.missingLayoutCodes.join(", ")} has no published version.`, partCode: $ });
1475
- const bt = L && q.layoutRefs.length ? `${L}\0${q.layoutRefs.join(",")}` : L;
1476
- Te[$] = a({ blocks: m, cacheKey: bt, content: q.html, context: _, contentType: be, data: b, partCode: $ });
1477
- }), { partContent: Te };
1491
+ throw new j({ message: `Layout ${q.missingLayoutCodes.join(", ")} has no published version.`, partCode: $ });
1492
+ const _t = ne && q.layoutRefs.length ? `${ne}\0${q.layoutRefs.join(",")}` : ne;
1493
+ be[$] = a({ blocks: h, cacheKey: _t, content: q.html, context: S, contentType: Ee, data: Ve, partCode: $ });
1494
+ }), { partContent: be };
1478
1495
  } });
1479
1496
  }
1480
- function Un(t = Pe) {
1481
- if (!Ze.includes(t))
1482
- throw new Q([O({
1497
+ function Vn(t = Ie) {
1498
+ if (!rt.includes(t))
1499
+ throw new ee([O({
1483
1500
  code: y.SYNTAX_VERSION_UNSUPPORTED,
1484
1501
  message: `Template syntax version ${t} is not supported.`
1485
1502
  })]);
1486
1503
  }
1487
- function kn(t) {
1504
+ function Fn(t) {
1488
1505
  const { templateCode: e, tenantCode: n, meta: r } = t;
1489
1506
  return !e || !(r != null && r.revision) ? null : `${n || ""}\0${e}\0${r.revision}`;
1490
1507
  }
1491
- function zn(t = []) {
1508
+ function Kn(t = []) {
1492
1509
  return new Map((t || []).map((e) => {
1493
1510
  const n = typeof e.describe == "function" ? e.describe() : e;
1494
1511
  return [`${n.blockCode}@${n.version}`, n];
1495
1512
  }));
1496
1513
  }
1497
- function Vn({ content: t, contentType: e, partCode: n, allowedFunctions: r, blocks: i, allowBlocks: s, engines: o }) {
1498
- const a = new Map(pe().map((d) => [d.name, d])), l = new Set(r), c = J(t, { allowBlocks: s, partCode: n }), f = (d, h) => me(d.templates, { allowedFunctionNames: l, functionsByName: a, locate: d.locate, text: d.text, ...h }).issues, u = [...c.issues, ...f(c, {})];
1514
+ function qn({ content: t, contentType: e, partCode: n, allowedFunctions: r, blocks: i, allowBlocks: s, engines: o }) {
1515
+ const a = new Map(me().map((p) => [p.name, p])), c = new Set(r), l = te(t, { allowBlocks: s, partCode: n }), m = (p, T) => fe(p.templates, { allowedFunctionNames: c, functionsByName: a, locate: p.locate, text: p.text, ...T }).issues, u = [...l.issues, ...m(l, {})];
1499
1516
  if (K(u))
1500
- throw new Q(u);
1501
- const p = e === x.TEXT_PLAIN ? o.text : o.html, b = c.blocks.map((d) => Fn(d, { blocks: i, engine: p, partCode: n, policy: f }));
1502
- let _ = "", m = 0;
1503
- c.blocks.forEach(({ start: d, end: h }, E) => {
1504
- _ += `${c.text.slice(m, d)}{% ${ht} ${E} %}`, m = h;
1505
- }), _ += c.text.slice(m);
1506
- const T = Tt(p, _, b);
1517
+ throw new ee(u);
1518
+ const d = e === x.TEXT_PLAIN ? o.text : o.html, f = l.blocks.map((p) => Gn(p, { blocks: i, engine: d, partCode: n, policy: m }));
1519
+ let _ = "", h = 0;
1520
+ l.blocks.forEach(({ start: p, end: T }, E) => {
1521
+ _ += `${l.text.slice(h, p)}{% ${yt} ${E} %}`, h = T;
1522
+ }), _ += l.text.slice(h);
1523
+ const b = gt(d, _, f);
1507
1524
  return Object.freeze({
1508
- render(d) {
1525
+ render(p) {
1509
1526
  try {
1510
- return p.renderSync(T, { ...d });
1511
- } catch (h) {
1512
- const E = (h == null ? void 0 : h.originalError) || h;
1513
- if (E instanceof v)
1527
+ return d.renderSync(b, { ...p });
1528
+ } catch (T) {
1529
+ const E = (T == null ? void 0 : T.originalError) || T;
1530
+ if (E instanceof j)
1514
1531
  throw E;
1515
- const C = String((E == null ? void 0 : E.message) || h.message).replace(/, line:\d+, col:\d+$/, "");
1516
- throw new v({ cause: h, message: `Failed to render ${n || "content"}: ${C}`, partCode: n });
1532
+ const C = String((E == null ? void 0 : E.message) || T.message).replace(/, line:\d+, col:\d+$/, "");
1533
+ throw new j({ cause: T, message: `Failed to render ${n || "content"}: ${C}`, partCode: n });
1517
1534
  }
1518
1535
  }
1519
1536
  });
1520
1537
  }
1521
- function Fn(t, { blocks: e, engine: n, partCode: r, policy: i }) {
1538
+ function Gn(t, { blocks: e, engine: n, partCode: r, policy: i }) {
1522
1539
  const { blockRef: s } = t, o = e.get(s);
1523
1540
  if (!o || typeof o.fragment != "string")
1524
- throw new v({ message: `Block ${s} is not available for rendering.`, partCode: r, source: s });
1541
+ throw new j({ message: `Block ${s} is not available for rendering.`, partCode: r, source: s });
1525
1542
  if (o.stateCode === "DRAFT")
1526
- throw new v({ message: `Block ${s} is not published.`, partCode: r, source: s });
1527
- const { definitions: a, errors: l } = X(o.params), { errors: c, values: f } = lt(a, t.params);
1528
- if (l.length || c.length)
1529
- throw new v({ message: `Block ${s} params are invalid: ${[...l, ...c].join(" ")}`, partCode: r, source: s });
1530
- const u = J(o.fragment, { allowBlocks: !1 }), p = [...u.issues, ...i(u, { allowAssign: !0, variables: /* @__PURE__ */ new Map([[F, null]]) })];
1531
- if (K(p))
1532
- throw new Q(p.map((b) => ({ ...b, blockRef: s })));
1543
+ throw new j({ message: `Block ${s} is not published.`, partCode: r, source: s });
1544
+ const { definitions: a, errors: c } = Z(o.params), { errors: l, values: m } = mt(a, t.params);
1545
+ if (c.length || l.length)
1546
+ throw new j({ message: `Block ${s} params are invalid: ${[...c, ...l].join(" ")}`, partCode: r, source: s });
1547
+ const u = te(o.fragment, { allowBlocks: !1 }), d = [...u.issues, ...i(u, { allowAssign: !0, variables: /* @__PURE__ */ new Map([[F, null]]) })];
1548
+ if (K(d))
1549
+ throw new ee(d.map((f) => ({ ...f, blockRef: s })));
1533
1550
  return {
1534
- params: Object.freeze(cn(a, f)),
1535
- templates: Tt(n, u.text, [])
1551
+ params: Object.freeze(dn(a, m)),
1552
+ templates: gt(n, u.text, [])
1536
1553
  };
1537
1554
  }
1538
- function Tt(t, e, n) {
1539
- W = n;
1555
+ function gt(t, e, n) {
1556
+ Y = n;
1540
1557
  try {
1541
1558
  return t.parse(e);
1542
1559
  } finally {
1543
- W = null;
1560
+ Y = null;
1544
1561
  }
1545
1562
  }
1546
- const Kn = /^[^\s@<>()[\]\\,;:"]+@[^\s"(),:;<>@[\\\]][^\s"(),.:;<>@[\\\]]*\.[^\s"(),:;<>@[\\\]]+$/, qn = /cid:([^\s"'<>)]+)/g, Gn = Mn();
1547
- async function Pr({ template: t, data: e, context: n, blocks: r, layouts: i, renderer: s = Gn, resolveInlineImage: o, juiceOptions: a, draft: l = !1 } = {}) {
1548
- const c = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {}, { partContent: f } = s.renderTemplate({ blocks: r, context: n, data: e, draft: l, kind: $e, layouts: i, template: c }), u = (T, d) => s.renderContent({
1563
+ const Wn = /^[^\s@<>()[\]\\,;:"]+@[^\s"(),:;<>@[\\\]][^\s"(),.:;<>@[\\\]]*\.[^\s"(),:;<>@[\\\]]+$/, Hn = /cid:([^\s"'<>)]+)/g, Yn = zn();
1564
+ async function vr({ template: t, data: e, context: n, blocks: r, layouts: i, renderer: s = Yn, resolveInlineImage: o, juiceOptions: a, draft: c = !1 } = {}) {
1565
+ const l = typeof (t == null ? void 0 : t.toObject) == "function" ? t.toObject() : t || {}, { partContent: m } = s.renderTemplate({ blocks: r, context: n, data: e, draft: c, kind: Me, layouts: i, template: l }), u = (b, p) => s.renderContent({
1549
1566
  allowBlocks: !1,
1550
- content: T,
1567
+ content: b,
1551
1568
  context: n,
1552
1569
  contentType: x.TEXT_PLAIN,
1553
1570
  data: e,
1554
- partCode: d
1555
- }).trim(), p = (T, d, { fixedEmail: h = !1 } = {}) => {
1556
- if (!(T != null && T.email))
1571
+ partCode: p
1572
+ }).trim(), d = (b, p, { fixedEmail: T = !1 } = {}) => {
1573
+ if (!(b != null && b.email))
1557
1574
  return null;
1558
- if (h && /\{\{|\{%/.test(T.email))
1559
- throw new v({ message: `${d}.email must be a fixed address.`, partCode: `${d}.email` });
1560
- const E = h ? T.email.trim() : u(T.email, `${d}.email`);
1575
+ if (T && /\{\{|\{%/.test(b.email))
1576
+ throw new j({ message: `${p}.email must be a fixed address.`, partCode: `${p}.email` });
1577
+ const E = T ? b.email.trim() : u(b.email, `${p}.email`);
1561
1578
  if (!E)
1562
1579
  return null;
1563
- if (!Kn.test(E))
1564
- throw new v({ message: `${d}.email "${E}" is not a valid email address.`, partCode: `${d}.email` });
1565
- const C = T.name ? u(T.name, `${d}.name`) : "";
1580
+ if (!Wn.test(E))
1581
+ throw new j({ message: `${p}.email "${E}" is not a valid email address.`, partCode: `${p}.email` });
1582
+ const C = b.name ? u(b.name, `${p}.name`) : "";
1566
1583
  return { email: E, ...C ? { name: C } : {} };
1567
- }, b = (T, d) => (Array.isArray(T) ? T : []).map((h, E) => p(typeof h == "string" ? { email: h } : h, `${d}[${E}]`)).filter(Boolean);
1568
- let _ = f.html ? Ot(f.html, { preserveImportant: !0, preserveMediaQueries: !0, ...a }) : "";
1569
- const m = [...new Set([..._.matchAll(qn)].map((T) => T[1]))];
1570
- if (o && m.length) {
1571
- const T = await Promise.all(m.map((d) => o({ contentId: d })));
1572
- m.forEach((d, h) => {
1573
- T[h] && (_ = _.split(`cid:${d}`).join(T[h]));
1584
+ }, f = (b, p) => (Array.isArray(b) ? b : []).map((T, E) => d(typeof T == "string" ? { email: T } : T, `${p}[${E}]`)).filter(Boolean);
1585
+ let _ = m.html ? Nt(m.html, { preserveImportant: !0, preserveMediaQueries: !0, ...a }) : "";
1586
+ const h = [...new Set([..._.matchAll(Hn)].map((b) => b[1]))];
1587
+ if (o && h.length) {
1588
+ const b = await Promise.all(h.map((p) => o({ contentId: p })));
1589
+ h.forEach((p, T) => {
1590
+ b[T] && (_ = _.split(`cid:${p}`).join(b[T]));
1574
1591
  });
1575
1592
  }
1576
1593
  return {
1577
- bcc: b(c.bcc, "bcc"),
1578
- cc: b(c.cc, "cc"),
1579
- from: p(c.from, "from", { fixedEmail: !0 }),
1594
+ bcc: f(l.bcc, "bcc"),
1595
+ cc: f(l.cc, "cc"),
1596
+ from: d(l.from, "from", { fixedEmail: !0 }),
1580
1597
  html: _,
1581
- inlineAttachments: m.map((T) => ({ contentId: T })),
1582
- replyTo: p(c.replyTo, "replyTo"),
1583
- subject: (f.subject || "").replace(/\s+/g, " ").trim(),
1584
- text: f.text ?? null
1598
+ inlineAttachments: h.map((b) => ({ contentId: b })),
1599
+ replyTo: d(l.replyTo, "replyTo"),
1600
+ subject: (m.subject || "").replace(/\s+/g, " ").trim(),
1601
+ text: m.text ?? null,
1602
+ to: d(l.to, "to", { fixedEmail: !0 })
1585
1603
  };
1586
1604
  }
1587
- const Wn = Object.freeze({
1605
+ const Xn = Object.freeze({
1588
1606
  blockCode: "INVOICE_LINES_TABLE",
1589
1607
  category: "Invoice",
1590
1608
  contextCode: "RECEIPT",
@@ -1600,7 +1618,7 @@ const Wn = Object.freeze({
1600
1618
  name: "Invoice lines (fixed)",
1601
1619
  params: [],
1602
1620
  version: 1
1603
- }), Hn = Object.freeze({
1621
+ }), Qn = Object.freeze({
1604
1622
  blockCode: "INVOICE_LINES_TABLE",
1605
1623
  category: "Invoice",
1606
1624
  contextCode: "RECEIPT",
@@ -1652,7 +1670,7 @@ const Wn = Object.freeze({
1652
1670
  { default: !0, label: "Show total", paramCode: "showTotal", type: "boolean" }
1653
1671
  ],
1654
1672
  version: 2
1655
- }), Yn = Object.freeze({
1673
+ }), Jn = Object.freeze({
1656
1674
  blockCode: "AUTHOR_LIST",
1657
1675
  category: "Abstract",
1658
1676
  contextCode: "ABSTRACT",
@@ -1670,7 +1688,7 @@ const Wn = Object.freeze({
1670
1688
  { default: !0, label: "Show affiliation", paramCode: "showAffiliation", type: "boolean" }
1671
1689
  ],
1672
1690
  version: 1
1673
- }), Xn = Object.freeze({
1691
+ }), Zn = Object.freeze({
1674
1692
  blockCode: "AUTHOR_LIST",
1675
1693
  category: "Abstract",
1676
1694
  contextCode: "ABSTRACT",
@@ -1708,16 +1726,16 @@ const Wn = Object.freeze({
1708
1726
  ],
1709
1727
  version: 2
1710
1728
  });
1711
- function Ir({ modified: t = Date.UTC(2027, 0, 1) } = {}) {
1712
- const e = (n) => Pn.create({ ...n, modified: t }).publish({ modified: t });
1729
+ function jr({ modified: t = Date.UTC(2027, 0, 1) } = {}) {
1730
+ const e = (n) => vn.create({ ...n, modified: t }).publish({ modified: t });
1713
1731
  return [
1714
- e(Wn).deprecate({ modified: t }),
1715
- e(Hn),
1716
- e(Yn),
1717
- e(Xn)
1732
+ e(Xn).deprecate({ modified: t }),
1733
+ e(Qn),
1734
+ e(Jn),
1735
+ e(Zn)
1718
1736
  ];
1719
1737
  }
1720
- const fe = j({
1738
+ const he = B({
1721
1739
  fields: {
1722
1740
  code: { description: "The recipient's event registration code.", label: "Registration code", type: "string" },
1723
1741
  displayName: { description: "Prefix, first name and last name, for greetings.", label: "Display name", type: "string", value: (t) => [t.prefix, t.firstName, t.lastName].filter(Boolean).join(" ") },
@@ -1729,7 +1747,7 @@ const fe = j({
1729
1747
  description: "Current email recipient values.",
1730
1748
  label: "Recipient",
1731
1749
  projectionCode: "PERSON"
1732
- }), he = j({
1750
+ }), Te = B({
1733
1751
  fields: {
1734
1752
  badge: {
1735
1753
  fields: {
@@ -1748,7 +1766,7 @@ const fe = j({
1748
1766
  description: "Current congress or event display information.",
1749
1767
  label: "Event",
1750
1768
  projectionCode: "EVENT"
1751
- }), Qn = j({
1769
+ }), er = B({
1752
1770
  fields: {
1753
1771
  amount: { description: "Amount of the line: quantity times unit price.", label: "Amount", type: "number" },
1754
1772
  name: { description: "Name of the item bought.", label: "Item", type: "string", value: (t) => {
@@ -1761,19 +1779,19 @@ const fe = j({
1761
1779
  description: "One line of an invoice.",
1762
1780
  label: "Invoice line",
1763
1781
  projectionCode: "INVOICE_LINE"
1764
- }), Jn = j({
1782
+ }), tr = B({
1765
1783
  fields: {
1766
1784
  created: { description: "Date the invoice was issued.", label: "Invoice date", type: "date" },
1767
1785
  currencyCode: { description: "Currency code of the invoice, such as AUD.", label: "Currency", type: "string" },
1768
1786
  invoiceNumber: { description: "Number printed on the invoice.", label: "Invoice number", type: "string" },
1769
- lines: De(Qn, { description: "Items bought on the invoice.", label: "Lines" }),
1787
+ lines: ve(er, { description: "Items bought on the invoice.", label: "Lines" }),
1770
1788
  revisionNumber: { description: "Revision of the invoice; 0 for the first issue.", label: "Revision", type: "number" },
1771
1789
  total: { description: "Sum of all invoice lines.", label: "Total", type: "number", value: (t) => (t.lines || []).reduce((e, n) => e + (n.amount || 0), 0) }
1772
1790
  },
1773
1791
  description: "Invoice header and number values.",
1774
1792
  label: "Invoice",
1775
1793
  projectionCode: "INVOICE"
1776
- }), Zn = j({
1794
+ }), nr = B({
1777
1795
  fields: {
1778
1796
  paidAmount: { description: "Amount paid in this payment.", label: "Paid amount", type: "number" },
1779
1797
  paymentDate: { description: "Date the payment was made.", label: "Payment date", type: "date" },
@@ -1784,7 +1802,7 @@ const fe = j({
1784
1802
  description: "Payment result, paid amount and payment details.",
1785
1803
  label: "Payment result",
1786
1804
  projectionCode: "PAYMENT_RESULT"
1787
- }), er = j({
1805
+ }), rr = B({
1788
1806
  fields: {
1789
1807
  affiliation: { description: "The author's institution.", label: "Affiliation", type: "string" },
1790
1808
  capacity: { description: "The author's role on the abstract, such as co-author.", label: "Capacity", type: "string" },
@@ -1795,10 +1813,10 @@ const fe = j({
1795
1813
  description: "One author of an abstract.",
1796
1814
  label: "Author",
1797
1815
  projectionCode: "AUTHOR"
1798
- }), tr = j({
1816
+ }), ir = B({
1799
1817
  fields: {
1800
1818
  abstractCode: { description: "Reference ID of the submitted abstract.", label: "Abstract code", type: "string" },
1801
- authors: De(er, { description: "Authors attached to the abstract.", label: "Authors" }),
1819
+ authors: ve(rr, { description: "Authors attached to the abstract.", label: "Authors" }),
1802
1820
  conclusions: { description: "Conclusions section of the abstract.", label: "Conclusions", type: "string" },
1803
1821
  keywords: { description: "Keywords given by the submitter.", label: "Keywords", type: "string" },
1804
1822
  methods: { description: "Methods section of the abstract.", label: "Methods", type: "string" },
@@ -1812,27 +1830,27 @@ const fe = j({
1812
1830
  description: "Abstract submission values.",
1813
1831
  label: "Abstract",
1814
1832
  projectionCode: "ABSTRACT"
1815
- }), nr = j({
1833
+ }), sr = B({
1816
1834
  fields: {
1817
1835
  eventRegistrationCode: { description: "Code of the event registration.", label: "Registration code", type: "string" },
1818
1836
  hasBadge: { description: "Whether the registration includes a badge.", label: "Has badge", type: "boolean" },
1819
- roleCodes: De({ label: "Role", type: "string" }, { description: "Role codes of the registration.", label: "Roles" })
1837
+ roleCodes: ve({ label: "Role", type: "string" }, { description: "Role codes of the registration.", label: "Roles" })
1820
1838
  },
1821
1839
  description: "Event registration profile values.",
1822
1840
  label: "Event registration",
1823
1841
  projectionCode: "EVENT_REGISTRATION"
1824
- }), Ue = Object.freeze({
1842
+ }), ke = Object.freeze({
1825
1843
  badge: { barcodeFormat: "QR_CODE" },
1826
1844
  displayDate: "27-30 August 2027",
1827
1845
  isOnline: !1,
1828
1846
  location: "Example Convention Centre",
1829
1847
  name: "Example Congress 2027",
1830
1848
  websiteUrl: "https://congress.example.org"
1831
- }), ke = Object.freeze({
1849
+ }), ze = Object.freeze({
1832
1850
  "ER-1001": { code: "ER-1001", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" },
1833
1851
  "ER-1002": { code: "ER-1002", email: "sam.wong@example.org", firstName: "Sam", lastName: "Wong", prefix: "Prof" },
1834
1852
  "ER-1003": { code: "ER-1003", email: "kim.lee@example.org", firstName: "Kim", lastName: "Lee", prefix: "" }
1835
- }), rr = Object.freeze({
1853
+ }), or = Object.freeze({
1836
1854
  "INV-2027-0001": {
1837
1855
  created: Date.UTC(2027, 2, 14),
1838
1856
  currencyCode: "HKD",
@@ -1846,7 +1864,7 @@ const fe = j({
1846
1864
  paymentResult: { paidAmount: 3200, paymentDate: Date.UTC(2027, 2, 15), paymentMethod: "Credit card", paymentRemark: "Paid online", receivedAmount: 3200 },
1847
1865
  revisionNumber: 1
1848
1866
  }
1849
- }), ir = Object.freeze({
1867
+ }), ar = Object.freeze({
1850
1868
  "ABS-0042": {
1851
1869
  abstractCode: "ABS-0042",
1852
1870
  authors: [
@@ -1866,24 +1884,24 @@ Methods
1866
1884
  Results`,
1867
1885
  title: "Outcomes of an example study"
1868
1886
  }
1869
- }), sr = Object.freeze({
1887
+ }), cr = Object.freeze({
1870
1888
  "ER-1001": { eventRegistrationCode: "ER-1001", hasBadge: !0, roleCodes: ["REGISTRANT", "DELEGATE"] }
1871
1889
  }), M = Object.freeze({
1872
1890
  ALL_AUTHORS: "ALL_AUTHORS",
1873
1891
  PRESENTER: "PRESENTER",
1874
1892
  SUBMITTER: "SUBMITTER"
1875
- }), or = ue({
1893
+ }), lr = pe({
1876
1894
  contextCode: "ABSTRACT",
1877
1895
  functionNames: ["__format_date", "__multiline"],
1878
1896
  loadData: async ({ subjectRef: t, recipientType: e }) => {
1879
- const n = ir[t];
1897
+ const n = ar[t];
1880
1898
  return n ? {
1881
1899
  [M.ALL_AUTHORS]: n.authors.map((i) => i.registrationCode),
1882
1900
  [M.PRESENTER]: n.authors.filter((i) => i.isPresenter).map((i) => i.registrationCode),
1883
1901
  [M.SUBMITTER]: [n.submitterCode]
1884
1902
  }[e].map((i) => ({
1885
1903
  recipientRef: i,
1886
- roots: { abstract: n, event: Ue, recipient: ke[i] }
1904
+ roots: { abstract: n, event: ke, recipient: ze[i] }
1887
1905
  })) : [];
1888
1906
  },
1889
1907
  name: "Abstract",
@@ -1893,9 +1911,9 @@ Results`,
1893
1911
  { name: "All authors", recipientType: M.ALL_AUTHORS }
1894
1912
  ],
1895
1913
  roots: {
1896
- abstract: tr,
1897
- event: he,
1898
- recipient: fe
1914
+ abstract: ir,
1915
+ event: Te,
1916
+ recipient: he
1899
1917
  },
1900
1918
  sampleData: {
1901
1919
  abstract: {
@@ -1919,19 +1937,19 @@ Line two`,
1919
1937
  recipient: { code: "ER-0001", displayName: "Dr Alex Chan", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" }
1920
1938
  },
1921
1939
  subjectType: "Abstract"
1922
- }), ar = ue({
1940
+ }), ur = pe({
1923
1941
  contextCode: "EVENT_REGISTRATION",
1924
1942
  functionNames: ["__barcode", "__format_date"],
1925
1943
  loadData: async ({ subjectRef: t }) => {
1926
- const e = sr[t];
1927
- return e ? [{ recipientRef: t, roots: { event: Ue, eventRegistration: e, recipient: ke[t] } }] : [];
1944
+ const e = cr[t];
1945
+ return e ? [{ recipientRef: t, roots: { event: ke, eventRegistration: e, recipient: ze[t] } }] : [];
1928
1946
  },
1929
1947
  name: "Event registration",
1930
1948
  recipientRules: [{ name: "Registrant", recipientType: "REGISTRANT" }],
1931
1949
  roots: {
1932
- event: he,
1933
- eventRegistration: nr,
1934
- recipient: fe
1950
+ event: Te,
1951
+ eventRegistration: sr,
1952
+ recipient: he
1935
1953
  },
1936
1954
  sampleData: {
1937
1955
  event: { badge: { barcodeFormat: "QR_CODE" }, displayDate: "27-30 August 2027", isOnline: !1, location: "Sample Venue", name: "Sample Congress", websiteUrl: "https://congress.example.org" },
@@ -1939,20 +1957,20 @@ Line two`,
1939
1957
  recipient: { code: "ER-0001", displayName: "Dr Alex Chan", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" }
1940
1958
  },
1941
1959
  subjectType: "EventRegistration"
1942
- }), cr = ue({
1960
+ }), dr = pe({
1943
1961
  contextCode: "RECEIPT",
1944
1962
  functionNames: ["__format_date", "__format_money"],
1945
1963
  loadData: async ({ subjectRef: t }) => {
1946
- const e = rr[t];
1947
- return e ? [{ recipientRef: e.payerCode, roots: { event: Ue, invoice: e, paymentResult: e.paymentResult, recipient: ke[e.payerCode] } }] : [];
1964
+ const e = or[t];
1965
+ return e ? [{ recipientRef: e.payerCode, roots: { event: ke, invoice: e, paymentResult: e.paymentResult, recipient: ze[e.payerCode] } }] : [];
1948
1966
  },
1949
1967
  name: "Receipt",
1950
1968
  recipientRules: [{ name: "Payer", recipientType: "PAYER" }],
1951
1969
  roots: {
1952
- event: he,
1953
- invoice: Jn,
1954
- paymentResult: Zn,
1955
- recipient: fe
1970
+ event: Te,
1971
+ invoice: tr,
1972
+ paymentResult: nr,
1973
+ recipient: he
1956
1974
  },
1957
1975
  sampleData: {
1958
1976
  event: { badge: { barcodeFormat: "QR_CODE" }, displayDate: "27-30 August 2027", isOnline: !1, location: "Sample Venue", name: "Sample Congress", websiteUrl: "https://congress.example.org" },
@@ -1971,35 +1989,35 @@ Line two`,
1971
1989
  recipient: { code: "ER-0001", displayName: "Dr Alex Chan", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" }
1972
1990
  },
1973
1991
  subjectType: "Invoice"
1974
- }), Dr = ue({
1992
+ }), Br = pe({
1975
1993
  contextCode: "LAYOUT",
1976
1994
  functionNames: ["__format_date"],
1977
1995
  name: "Layout (every email)",
1978
1996
  roots: {
1979
- event: he,
1980
- recipient: fe
1997
+ event: Te,
1998
+ recipient: he
1981
1999
  },
1982
2000
  sampleData: {
1983
2001
  event: { badge: { barcodeFormat: "QR_CODE" }, displayDate: "27-30 August 2027", isOnline: !1, location: "Sample Venue", name: "Sample Congress", websiteUrl: "https://congress.example.org" },
1984
2002
  recipient: { code: "ER-0001", displayName: "Dr Alex Chan", email: "alex.chan@example.org", firstName: "Alex", lastName: "Chan", prefix: "Dr" }
1985
2003
  }
1986
- }), lr = Object.freeze({
1987
- ABSTRACT: or,
1988
- EVENT_REGISTRATION: ar,
1989
- RECEIPT: cr
1990
- }), ur = Object.freeze({
2004
+ }), pr = Object.freeze({
2005
+ ABSTRACT: lr,
2006
+ EVENT_REGISTRATION: ur,
2007
+ RECEIPT: dr
2008
+ }), mr = Object.freeze({
1991
2009
  ABSTRACT: "ABSTRACT",
1992
2010
  EVENT_REGISTRATION: "EVENT_REGISTRATION",
1993
2011
  RECEIPT: "RECEIPT",
1994
2012
  STORE: "RECEIPT"
1995
2013
  });
1996
- function we(t) {
1997
- return ur[t] || null;
2014
+ function Pe(t) {
2015
+ return mr[t] || null;
1998
2016
  }
1999
- function vr(t) {
2000
- return lr[we(t)] || null;
2017
+ function xr(t) {
2018
+ return pr[Pe(t)] || null;
2001
2019
  }
2002
- const dr = Object.freeze([
2020
+ const fr = Object.freeze([
2003
2021
  {
2004
2022
  description: "Format an amount with a currency code, e.g. HKD 1,200.00.",
2005
2023
  fn: (t, e) => {
@@ -2035,13 +2053,13 @@ const dr = Object.freeze([
2035
2053
  trustedHtml: !0
2036
2054
  }
2037
2055
  ]);
2038
- function jr() {
2039
- const t = new Set(pe().map(({ name: e }) => e));
2040
- dr.forEach((e) => {
2041
- t.has(e.name) || Dt(e);
2056
+ function $r() {
2057
+ const t = new Set(me().map(({ name: e }) => e));
2058
+ fr.forEach((e) => {
2059
+ t.has(e.name) || Bt(e);
2042
2060
  });
2043
2061
  }
2044
- const pr = Object.freeze({
2062
+ const hr = Object.freeze({
2045
2063
  description: "Event banner across the top of the email.",
2046
2064
  eventShortCode: "EXAMPLE2027",
2047
2065
  html: '<img src="https://congress.2026.apvrs.org/userfile/apvrs/img/apvrs2026/banner.png" alt="{{ event.name }}" width="600" style="display: block; width: 100%; height: auto; border: 0;">',
@@ -2049,7 +2067,7 @@ const pr = Object.freeze({
2049
2067
  name: "APVRS header",
2050
2068
  tenantCode: "example",
2051
2069
  version: 1
2052
- }), mr = Object.freeze({
2070
+ }), Tr = Object.freeze({
2053
2071
  description: "Event name, dates and website below the content.",
2054
2072
  eventShortCode: "EXAMPLE2027",
2055
2073
  html: '<p style="margin: 24px 0 0; padding-top: 12px; border-top: 1px solid #dddddd; font-size: 16px; color: #666666;">{{ event.name }} · {{ event.displayDate }} · <a href="{{ event.websiteUrl }}">{{ event.websiteUrl }}</a></p>',
@@ -2057,7 +2075,7 @@ const pr = Object.freeze({
2057
2075
  name: "Congress footer",
2058
2076
  tenantCode: "example",
2059
2077
  version: 1
2060
- }), fr = Object.freeze({
2078
+ }), br = Object.freeze({
2061
2079
  description: "APVRS 2026 venue and copyright lines for the footer row of the email frame.",
2062
2080
  eventShortCode: "EXAMPLE2027",
2063
2081
  html: '<p style="margin: 0; font-size: 12px; line-height: 1.5; color: #888888;">APVRS 2026 Gold Coast · Gold Coast Convention &amp; Exhibition Centre, Queensland, Australia<br>© 2026 Asia-Pacific Vitreo-Retina Society. All rights reserved.</p>',
@@ -2065,10 +2083,10 @@ const pr = Object.freeze({
2065
2083
  name: "APVRS footer",
2066
2084
  tenantCode: "example",
2067
2085
  version: 1
2068
- }), Br = Object.freeze([pr, mr, fr]), hr = ["mobileWalletBadgePass", "subTemplateGroupName", "templateGroupName"];
2069
- class xr extends Dn {
2086
+ }), Mr = Object.freeze([hr, Tr, br]), Er = ["mobileWalletBadgePass", "subTemplateGroupName", "templateGroupName"];
2087
+ class Ur extends Bn {
2070
2088
  constructor(e = {}) {
2071
- e = e || {}, super({ ...e, contextCode: we(e.templateGroupName) || e.contextCode }), this._type = e._type || "TemplateEmailCongress", this.eventShortCode = e.eventShortCode, this.mobileWalletBadgePass = !!e.mobileWalletBadgePass, this.subTemplateGroupName = e.subTemplateGroupName || null, this.templateGroupName = e.templateGroupName;
2089
+ e = e || {}, super({ ...e, contextCode: Pe(e.templateGroupName) || e.contextCode }), this._type = e._type || "TemplateEmailCongress", this.eventShortCode = e.eventShortCode, this.mobileWalletBadgePass = !!e.mobileWalletBadgePass, this.subTemplateGroupName = e.subTemplateGroupName || null, this.templateGroupName = e.templateGroupName;
2072
2090
  }
2073
2091
  static get _classname() {
2074
2092
  return "TemplateEmailCongress";
@@ -2077,9 +2095,9 @@ class xr extends Dn {
2077
2095
  return super.isValid && !!this.eventShortCode && !!this.templateGroupName;
2078
2096
  }
2079
2097
  update(e = {}) {
2080
- return hr.forEach((n) => {
2098
+ return Er.forEach((n) => {
2081
2099
  Object.hasOwn(e, n) && (this[n] = n === "mobileWalletBadgePass" ? !!e[n] : e[n]);
2082
- }), Object.hasOwn(e, "templateGroupName") && (this.contextCode = we(e.templateGroupName)), super.update(e);
2100
+ }), Object.hasOwn(e, "templateGroupName") && (this.contextCode = Pe(e.templateGroupName)), super.update(e);
2083
2101
  }
2084
2102
  toObject() {
2085
2103
  return {
@@ -2091,7 +2109,7 @@ class xr extends Dn {
2091
2109
  };
2092
2110
  }
2093
2111
  }
2094
- const $r = Object.freeze({
2112
+ const kr = Object.freeze({
2095
2113
  bcc: [{ email: "finance@congress.example.org" }],
2096
2114
  eventShortCode: "EXAMPLE2027",
2097
2115
  from: { email: "secretariat@congress.example.org", name: "{{ event.name }} Secretariat" },
@@ -2118,7 +2136,7 @@ const $r = Object.freeze({
2118
2136
  templateCode: "RECEIPT.EVENT.paymentCompleted",
2119
2137
  templateGroupName: "RECEIPT",
2120
2138
  tenantCode: "example"
2121
- }), Mr = Object.freeze({
2139
+ }), zr = Object.freeze({
2122
2140
  eventShortCode: "EXAMPLE2027",
2123
2141
  meta: { revision: 1 },
2124
2142
  name: "Submission acknowledgement",
@@ -2137,7 +2155,7 @@ const $r = Object.freeze({
2137
2155
  templateCode: "ABSTRACT.submissionAcknowledgement",
2138
2156
  templateGroupName: "ABSTRACT",
2139
2157
  tenantCode: "example"
2140
- }), Ur = Object.freeze({
2158
+ }), Vr = Object.freeze({
2141
2159
  eventShortCode: "EXAMPLE2027",
2142
2160
  meta: { revision: 1 },
2143
2161
  mobileWalletBadgePass: !0,
@@ -2161,105 +2179,105 @@ const $r = Object.freeze({
2161
2179
  tenantCode: "example"
2162
2180
  });
2163
2181
  export {
2164
- Mr as ABSTRACT_ACKNOWLEDGEMENT_TEMPLATE,
2182
+ zr as ABSTRACT_ACKNOWLEDGEMENT_TEMPLATE,
2165
2183
  M as ABSTRACT_RECIPIENT_TYPE,
2166
- fr as APVRS_FOOTER_V1,
2167
- pr as APVRS_HEADER_V1,
2168
- Yn as AUTHOR_LIST_V1,
2169
- Xn as AUTHOR_LIST_V2,
2184
+ br as APVRS_FOOTER_V1,
2185
+ hr as APVRS_HEADER_V1,
2186
+ Jn as AUTHOR_LIST_V1,
2187
+ Zn as AUTHOR_LIST_V2,
2170
2188
  k as BLOCK_ATTRIBUTE,
2171
- Re as BLOCK_PARAMS_ATTRIBUTE,
2189
+ Ne as BLOCK_PARAMS_ATTRIBUTE,
2172
2190
  F as BLOCK_PARAMS_ROOT,
2173
- lr as CONGRESS_CONTEXTS,
2174
- mr as CONGRESS_FOOTER_V1,
2175
- Br as CONGRESS_LAYOUTS,
2176
- dr as CONGRESS_TEMPLATE_FUNCTIONS,
2177
- wt as DataContext,
2178
- Wn as INVOICE_LINES_TABLE_V1,
2179
- Hn as INVOICE_LINES_TABLE_V2,
2180
- tt as LAYOUT_ATTRIBUTE,
2181
- Se as LifecycleTemplateBlock,
2182
- Ye as LifecycleTemplateLayout,
2183
- $r as RECEIPT_TEMPLATE,
2184
- Ur as REGISTRATION_CONFIRMATION_TEMPLATE,
2185
- ir as SAMPLE_ABSTRACTS,
2186
- Ue as SAMPLE_EVENT,
2187
- rr as SAMPLE_INVOICES,
2188
- ke as SAMPLE_PEOPLE,
2189
- sr as SAMPLE_REGISTRATIONS,
2190
- Ze as SUPPORTED_TEMPLATE_SYNTAX_VERSIONS,
2191
- Sr as TEMPLATE_BLOCK_ACTION_CODE,
2191
+ pr as CONGRESS_CONTEXTS,
2192
+ Tr as CONGRESS_FOOTER_V1,
2193
+ Mr as CONGRESS_LAYOUTS,
2194
+ fr as CONGRESS_TEMPLATE_FUNCTIONS,
2195
+ Dt as DataContext,
2196
+ Xn as INVOICE_LINES_TABLE_V1,
2197
+ Qn as INVOICE_LINES_TABLE_V2,
2198
+ st as LAYOUT_ATTRIBUTE,
2199
+ Le as LifecycleTemplateBlock,
2200
+ Ze as LifecycleTemplateLayout,
2201
+ kr as RECEIPT_TEMPLATE,
2202
+ Vr as REGISTRATION_CONFIRMATION_TEMPLATE,
2203
+ ar as SAMPLE_ABSTRACTS,
2204
+ ke as SAMPLE_EVENT,
2205
+ or as SAMPLE_INVOICES,
2206
+ ze as SAMPLE_PEOPLE,
2207
+ cr as SAMPLE_REGISTRATIONS,
2208
+ rt as SUPPORTED_TEMPLATE_SYNTAX_VERSIONS,
2209
+ Pr as TEMPLATE_BLOCK_ACTION_CODE,
2192
2210
  R as TEMPLATE_BLOCK_PARAM_TYPE,
2193
2211
  z as TEMPLATE_BLOCK_STATE_CODE,
2194
- ot as TEMPLATE_BUILTIN_FILTERS,
2212
+ ut as TEMPLATE_BUILTIN_FILTERS,
2195
2213
  x as TEMPLATE_CONTENT_TYPE,
2196
- $e as TEMPLATE_EMAIL_KIND,
2197
- xn as TEMPLATE_EVALUATION_LIMITS,
2198
- B as TEMPLATE_FIELD_KIND,
2214
+ Me as TEMPLATE_EMAIL_KIND,
2215
+ Un as TEMPLATE_EVALUATION_LIMITS,
2216
+ I as TEMPLATE_FIELD_KIND,
2199
2217
  P as TEMPLATE_FIELD_TYPE,
2200
- Ae as TEMPLATE_FRAGMENT_TAGS,
2218
+ Re as TEMPLATE_FRAGMENT_TAGS,
2201
2219
  U as TEMPLATE_FUNCTION_ARG_TYPE,
2202
2220
  y as TEMPLATE_ISSUE_CODE,
2203
- H as TEMPLATE_ISSUE_SEVERITY,
2204
- xe as TEMPLATE_KIND_CODE,
2205
- Lr as TEMPLATE_LAYOUT_ACTION_CODE,
2206
- Oe as TEMPLATE_LAYOUT_STATE_CODE,
2207
- Pe as TEMPLATE_SYNTAX_VERSION,
2208
- st as TEMPLATE_TAGS,
2209
- rn as Template,
2210
- Pn as TemplateBlock,
2211
- Dn as TemplateEmail,
2212
- xr as TemplateEmailCongress,
2213
- wr as TemplateLayout,
2214
- et as TemplateProjection,
2215
- v as TemplateRenderError,
2216
- Q as TemplateSyntaxError,
2217
- or as abstractContext,
2218
- tr as abstractProjection,
2219
- er as authorProjection,
2220
- An as checkBlockFragment,
2221
- Rr as checkTemplate,
2222
- Nr as checkTemplateContent,
2223
- Rn as checkTemplateLayoutContent,
2224
- gr as clearCustomFunctions,
2225
- we as contextCodeForTemplateGroup,
2226
- vr as contextForTemplateGroup,
2227
- Or as createBlockElement,
2228
- Ir as createCongressBlocks,
2229
- Mn as createTemplateRenderer,
2230
- ue as defineDataContext,
2231
- j as defineTemplateProjection,
2232
- Ar as describeTemplateFilter,
2233
- pe as describeTemplateFunctions,
2234
- Cr as describeTemplateKind,
2235
- he as eventProjection,
2236
- ar as eventRegistrationContext,
2237
- nr as eventRegistrationProjection,
2238
- kt as expandTemplateLayouts,
2239
- Wt as findBlockRefs,
2240
- je as findLayoutCodes,
2241
- Ne as formatBlockRef,
2242
- yr as getTemplateFunctionDescriptor,
2243
- ut as getTemplateKind,
2221
+ X as TEMPLATE_ISSUE_SEVERITY,
2222
+ $e as TEMPLATE_KIND_CODE,
2223
+ Ir as TEMPLATE_LAYOUT_ACTION_CODE,
2224
+ Ce as TEMPLATE_LAYOUT_STATE_CODE,
2225
+ Ie as TEMPLATE_SYNTAX_VERSION,
2226
+ lt as TEMPLATE_TAGS,
2227
+ an as Template,
2228
+ vn as TemplateBlock,
2229
+ Bn as TemplateEmail,
2230
+ Ur as TemplateEmailCongress,
2231
+ Dr as TemplateLayout,
2232
+ it as TemplateProjection,
2233
+ j as TemplateRenderError,
2234
+ ee as TemplateSyntaxError,
2235
+ lr as abstractContext,
2236
+ ir as abstractProjection,
2237
+ rr as authorProjection,
2238
+ Sn as checkBlockFragment,
2239
+ Lr as checkTemplate,
2240
+ wr as checkTemplateContent,
2241
+ Ln as checkTemplateLayoutContent,
2242
+ Cr as clearCustomFunctions,
2243
+ Pe as contextCodeForTemplateGroup,
2244
+ xr as contextForTemplateGroup,
2245
+ Rr as createBlockElement,
2246
+ jr as createCongressBlocks,
2247
+ zn as createTemplateRenderer,
2248
+ pe as defineDataContext,
2249
+ B as defineTemplateProjection,
2250
+ Sr as describeTemplateFilter,
2251
+ me as describeTemplateFunctions,
2252
+ Nr as describeTemplateKind,
2253
+ Te as eventProjection,
2254
+ ur as eventRegistrationContext,
2255
+ sr as eventRegistrationProjection,
2256
+ Ft as expandTemplateLayouts,
2257
+ Xt as findBlockRefs,
2258
+ Be as findLayoutCodes,
2259
+ Se as formatBlockRef,
2260
+ Or as getTemplateFunctionDescriptor,
2261
+ ft as getTemplateKind,
2244
2262
  K as hasTemplateErrors,
2245
- Qn as invoiceLineProjection,
2246
- Jn as invoiceProjection,
2247
- Dr as layoutContext,
2248
- _r as layoutElementHtml,
2249
- it as layoutHtmlIssues,
2250
- De as listOf,
2251
- X as normalizeBlockParamDefinitions,
2252
- Ft as normalizeTemplateMarkup,
2253
- Yt as parseBlockRef,
2254
- J as parseTemplateContent,
2255
- Zn as paymentResultProjection,
2256
- fe as personProjection,
2257
- cr as receiptContext,
2258
- jr as registerCongressTemplateFunctions,
2259
- Dt as registerTemplateFunction,
2260
- Pr as renderTemplateEmail,
2261
- lt as resolveBlockParams,
2262
- rt as resolveTemplateLayout,
2263
- de as toDataContextDescriptor
2263
+ er as invoiceLineProjection,
2264
+ tr as invoiceProjection,
2265
+ Br as layoutContext,
2266
+ Ar as layoutElementHtml,
2267
+ ct as layoutHtmlIssues,
2268
+ ve as listOf,
2269
+ Z as normalizeBlockParamDefinitions,
2270
+ Gt as normalizeTemplateMarkup,
2271
+ Jt as parseBlockRef,
2272
+ te as parseTemplateContent,
2273
+ nr as paymentResultProjection,
2274
+ he as personProjection,
2275
+ dr as receiptContext,
2276
+ $r as registerCongressTemplateFunctions,
2277
+ Bt as registerTemplateFunction,
2278
+ vr as renderTemplateEmail,
2279
+ mt as resolveBlockParams,
2280
+ at as resolveTemplateLayout,
2281
+ J as toDataContextDescriptor
2264
2282
  };
2265
2283
  //# sourceMappingURL=p-templates-model.esm.js.map