article-content-renderer-vue2 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,43 +1,43 @@
1
- var j = Object.defineProperty, z = Object.defineProperties;
2
- var M = Object.getOwnPropertyDescriptors;
3
- var S = Object.getOwnPropertySymbols;
4
- var Y = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
5
- var E = (i, r, t) => r in i ? j(i, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[r] = t, m = (i, r) => {
1
+ var F = Object.defineProperty, Y = Object.defineProperties;
2
+ var K = Object.getOwnPropertyDescriptors;
3
+ var B = Object.getOwnPropertySymbols;
4
+ var G = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
5
+ var E = (n, r, t) => r in n ? F(n, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[r] = t, m = (n, r) => {
6
6
  for (var t in r || (r = {}))
7
- Y.call(r, t) && E(i, t, r[t]);
8
- if (S)
9
- for (var t of S(r))
10
- F.call(r, t) && E(i, t, r[t]);
11
- return i;
12
- }, A = (i, r) => z(i, M(r));
13
- var B = (i, r, t) => E(i, typeof r != "symbol" ? r + "" : r, t);
14
- import K from "vue";
15
- const G = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]), W = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]), H = "https://article-content-renderer.invalid/", N = "https://www.doitme.link/";
16
- function X(i, r) {
17
- if (typeof i != "string") return i;
18
- const t = i.trim();
7
+ G.call(r, t) && E(n, t, r[t]);
8
+ if (B)
9
+ for (var t of B(r))
10
+ W.call(r, t) && E(n, t, r[t]);
11
+ return n;
12
+ }, A = (n, r) => Y(n, K(r));
13
+ var O = (n, r, t) => E(n, typeof r != "symbol" ? r + "" : r, t);
14
+ import $ from "vue";
15
+ const H = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]), X = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]), J = "https://article-content-renderer.invalid/", N = "https://www.doitme.link/";
16
+ function Q(n, r) {
17
+ if (typeof n != "string") return n;
18
+ const t = n.trim();
19
19
  if (!t.startsWith(N)) return t;
20
- const n = (r.trim() || N).replace(/\/+$/u, ""), s = t.slice(N.length).replace(/^\/+/, "");
21
- return `${n}/${s}`;
20
+ const i = (r.trim() || N).replace(/\/+$/u, ""), s = t.slice(N.length).replace(/^\/+/, "");
21
+ return `${i}/${s}`;
22
22
  }
23
- function T(i, r) {
24
- if (typeof i != "string") return null;
25
- const t = i.trim();
23
+ function _(n, r) {
24
+ if (typeof n != "string") return null;
25
+ const t = n.trim();
26
26
  if (!t || /[\u0000-\u001F\u007F]/u.test(t)) return null;
27
27
  try {
28
- const e = new URL(t, H);
29
- return (r === "link" ? G : W).has(e.protocol) ? t : null;
28
+ const e = new URL(t, J);
29
+ return (r === "link" ? H : X).has(e.protocol) ? t : null;
30
30
  } catch (e) {
31
31
  return null;
32
32
  }
33
33
  }
34
- function U(i, r) {
34
+ function x(n, r) {
35
35
  const t = new Set(
36
- typeof i == "string" ? i.trim().split(/\s+/u).filter(Boolean) : []
36
+ typeof n == "string" ? n.trim().split(/\s+/u).filter(Boolean) : []
37
37
  );
38
38
  return r === "_blank" && (t.add("noopener"), t.add("noreferrer")), t.size > 0 ? [...t].join(" ") : void 0;
39
39
  }
40
- const J = /* @__PURE__ */ new Set([
40
+ const Z = /* @__PURE__ */ new Set([
41
41
  "paragraph",
42
42
  "heading",
43
43
  "blockquote",
@@ -49,53 +49,53 @@ const J = /* @__PURE__ */ new Set([
49
49
  "articleButton",
50
50
  "table"
51
51
  ]);
52
- function p(i) {
53
- return typeof i == "object" && i !== null && !Array.isArray(i);
52
+ function h(n) {
53
+ return typeof n == "object" && n !== null && !Array.isArray(n);
54
54
  }
55
- function _(i) {
56
- return p(i) ? i : {};
55
+ function P(n) {
56
+ return h(n) ? n : {};
57
57
  }
58
- function f(i, r, t, e) {
59
- var c;
60
- const n = p(t) ? t : {}, s = p(t) ? e : t, o = {}, l = {};
61
- for (const [u, h] of Object.entries(n))
58
+ function f(n, r, t, e) {
59
+ var l;
60
+ const i = h(t) ? t : {}, s = h(t) ? e : t, o = {}, a = {};
61
+ for (const [u, g] of Object.entries(i))
62
62
  if (u === "class")
63
- o.class = h;
63
+ o.class = g;
64
64
  else if (u === "style")
65
- o.style = h;
66
- else if (u.startsWith("on") && typeof h == "function") {
65
+ o.style = g;
66
+ else if (u.startsWith("on") && typeof g == "function") {
67
67
  const y = u.slice(2).toLowerCase();
68
- o.on = A(m({}, (c = o.on) != null ? c : {}), { [y]: h });
69
- } else h !== void 0 && h !== !1 && (l[u] = h);
70
- return Object.keys(l).length > 0 && (o.attrs = l), i.createElement(r, o, s);
68
+ o.on = A(m({}, (l = o.on) != null ? l : {}), { [y]: g });
69
+ } else g !== void 0 && g !== !1 && (a[u] = g);
70
+ return Object.keys(a).length > 0 && (o.attrs = a), n.createElement(r, o, s);
71
71
  }
72
- function k(i) {
73
- return Array.isArray(i) ? i : [];
72
+ function k(n) {
73
+ return Array.isArray(n) ? n : [];
74
74
  }
75
- function g(i, ...r) {
76
- return `${i}/${r.map(String).join("/")}`;
75
+ function p(n, ...r) {
76
+ return `${n}/${r.map(String).join("/")}`;
77
77
  }
78
- function w(i) {
79
- return i === "left" || i === "center" || i === "right" || i === "justify";
78
+ function w(n) {
79
+ return n === "left" || n === "center" || n === "right" || n === "justify";
80
80
  }
81
- function Q(i) {
82
- return i === "left" || i === "center" || i === "right";
81
+ function tt(n) {
82
+ return n === "left" || n === "center" || n === "right";
83
83
  }
84
- function R(i) {
85
- return i === "_blank" || i === "_self";
84
+ function R(n) {
85
+ return n === "_blank" || n === "_self";
86
86
  }
87
- function b(i, r) {
88
- i.reportIssue(r);
87
+ function b(n, r) {
88
+ n.reportIssue(r);
89
89
  }
90
- function Z(i, r, t) {
91
- if (!p(i) || i.type !== "text" || typeof i.text != "string" || !i.text)
90
+ function et(n, r, t) {
91
+ if (!h(n) || n.type !== "text" || typeof n.text != "string" || !n.text)
92
92
  return null;
93
- let e = i.text;
94
- const n = k(i.marks);
95
- for (let s = 0; s < n.length; s += 1) {
96
- const o = n[s];
97
- if (!p(o) || typeof o.type != "string") continue;
98
- const l = g(r, "marks", s);
93
+ let e = n.text;
94
+ const i = k(n.marks);
95
+ for (let s = 0; s < i.length; s += 1) {
96
+ const o = i[s];
97
+ if (!h(o) || typeof o.type != "string") continue;
98
+ const a = p(r, "marks", s);
99
99
  switch (o.type) {
100
100
  case "bold":
101
101
  e = f(t, "strong", { class: "acp-mark acp-mark--bold" }, [e]);
@@ -113,25 +113,25 @@ function Z(i, r, t) {
113
113
  e = f(t, "code", { class: "acp-mark acp-mark--code" }, [e]);
114
114
  break;
115
115
  case "link": {
116
- const c = _(o.attrs), u = T(c.href, "link");
116
+ const l = P(o.attrs), u = _(l.href, "link");
117
117
  if (!u) {
118
118
  b(t, {
119
119
  code: "UNSAFE_URL",
120
- path: g(l, "attrs", "href"),
120
+ path: p(a, "attrs", "href"),
121
121
  message: "The link URL is empty, malformed, or uses a disallowed protocol.",
122
122
  nodeType: "link"
123
123
  });
124
124
  break;
125
125
  }
126
- const h = R(c.target) ? c.target : "_blank";
126
+ const g = R(l.target) ? l.target : "_blank";
127
127
  e = f(
128
128
  t,
129
129
  "a",
130
130
  {
131
131
  class: "acp-link",
132
132
  href: u,
133
- target: h,
134
- rel: U(void 0, h)
133
+ target: g,
134
+ rel: x(void 0, g)
135
135
  },
136
136
  [e]
137
137
  );
@@ -141,50 +141,50 @@ function Z(i, r, t) {
141
141
  }
142
142
  return e;
143
143
  }
144
- function O(i, r, t) {
145
- return k(i).map((e, n) => Z(e, g(r, n), t)).filter((e) => e !== null);
144
+ function V(n, r, t) {
145
+ return k(n).map((e, i) => et(e, p(r, i), t)).filter((e) => e !== null);
146
146
  }
147
- function V(i, r, t) {
148
- return !p(i) || i.type !== "listItem" ? null : f(
147
+ function q(n, r, t) {
148
+ return !h(n) || n.type !== "listItem" ? null : f(
149
149
  t,
150
150
  "li",
151
151
  { class: "acp-list-item", "data-node-type": "listItem" },
152
- P(i.content, g(r, "content"), t)
152
+ S(n.content, p(r, "content"), t)
153
153
  );
154
154
  }
155
- function tt(i, r, t) {
156
- return !p(i) || i.type !== "tableCell" ? null : f(
155
+ function rt(n, r, t) {
156
+ return !h(n) || n.type !== "tableCell" ? null : f(
157
157
  t,
158
158
  "td",
159
159
  { class: "acp-table-cell", "data-node-type": "tableCell" },
160
- P(i.content, g(r, "content"), t)
160
+ S(n.content, p(r, "content"), t)
161
161
  );
162
162
  }
163
- function et(i, r, t) {
164
- if (!p(i) || i.type !== "tableRow") return null;
165
- const e = k(i.content).map((n, s) => tt(n, g(r, "content", s), t)).filter((n) => n !== null);
163
+ function nt(n, r, t) {
164
+ if (!h(n) || n.type !== "tableRow") return null;
165
+ const e = k(n.content).map((i, s) => rt(i, p(r, "content", s), t)).filter((i) => i !== null);
166
166
  return f(t, "tr", { class: "acp-table-row", "data-node-type": "tableRow" }, e);
167
167
  }
168
- function q(i) {
169
- var n;
170
- if (p(i) && i.target !== void 0 && !R(i.target) || p(i) && i.rel !== void 0 && typeof i.rel != "string") return null;
171
- const r = typeof i == "string" ? { href: i } : p(i) && typeof i.href == "string" ? m(m({
172
- href: i.href
173
- }, R(i.target) ? { target: i.target } : {}), typeof i.rel == "string" ? { rel: i.rel } : {}) : null;
168
+ function C(n) {
169
+ var i;
170
+ if (h(n) && n.target !== void 0 && !R(n.target) || h(n) && n.rel !== void 0 && typeof n.rel != "string") return null;
171
+ const r = typeof n == "string" ? { href: n } : h(n) && typeof n.href == "string" ? m(m({
172
+ href: n.href
173
+ }, R(n.target) ? { target: n.target } : {}), typeof n.rel == "string" ? { rel: n.rel } : {}) : null;
174
174
  if (!r) return null;
175
- const t = T(r.href, "link");
175
+ const t = _(r.href, "link");
176
176
  if (!t) return null;
177
- const e = (n = r.target) != null ? n : "_self";
177
+ const e = (i = r.target) != null ? i : "_self";
178
178
  return {
179
179
  href: t,
180
180
  target: e,
181
- rel: U(r.rel, e)
181
+ rel: x(r.rel, e)
182
182
  };
183
183
  }
184
- function rt(i, r, t) {
185
- var h;
186
- const e = _(i.attrs), n = e.style === "text" || e.style === "button", s = e.style === "link";
187
- if (typeof e.text != "string" || !e.text || !n && !s || n && (typeof e.id != "string" || !e.id) || s && e.id !== void 0 && (typeof e.id != "string" || !e.id))
184
+ function it(n, r, t) {
185
+ var g;
186
+ const e = P(n.attrs), i = e.style === "text" || e.style === "button", s = e.style === "link";
187
+ if (typeof e.text != "string" || !e.text || !i && !s || i && (typeof e.id != "string" || !e.id) || s && e.id !== void 0 && (typeof e.id != "string" || !e.id))
188
188
  return null;
189
189
  const o = Object.freeze(s ? m(A(m(m({}, typeof e.id == "string" ? { id: e.id } : {}), typeof e.title == "string" ? { title: e.title } : {}), {
190
190
  text: e.text,
@@ -194,10 +194,10 @@ function rt(i, r, t) {
194
194
  }, typeof e.title == "string" ? { title: e.title } : {}), {
195
195
  text: e.text,
196
196
  style: e.style
197
- })), l = Object.freeze({ type: "articleButton", attrs: o });
198
- let c = null;
197
+ })), a = Object.freeze({ type: "articleButton", attrs: o });
198
+ let l = null;
199
199
  if (o.style === "link")
200
- o.href !== void 0 && (c = q(o.href), c || b(t, {
200
+ o.href !== void 0 && (l = C(o.href), l || b(t, {
201
201
  code: "UNSAFE_URL",
202
202
  path: `${r}/attrs/href`,
203
203
  message: "The articleButton link href is not a usable safe URL.",
@@ -213,8 +213,8 @@ function rt(i, r, t) {
213
213
  else
214
214
  try {
215
215
  const y = Object.freeze({ type: "articleButton", attrs: o }), L = t.resolveArticleButtonLink(o, y);
216
- c = q(L), c || b(t, {
217
- code: typeof L == "string" || p(L) && typeof L.href == "string" ? "UNSAFE_URL" : "LINK_RESOLUTION_FAILED",
216
+ l = C(L), l || b(t, {
217
+ code: typeof L == "string" || h(L) && typeof L.href == "string" ? "UNSAFE_URL" : "LINK_RESOLUTION_FAILED",
218
218
  path: r,
219
219
  message: "The articleButton link resolver returned no usable safe URL.",
220
220
  nodeType: "articleButton"
@@ -227,7 +227,7 @@ function rt(i, r, t) {
227
227
  nodeType: "articleButton"
228
228
  });
229
229
  }
230
- const u = (h = c == null ? void 0 : c.href) != null ? h : null;
230
+ const u = (g = l == null ? void 0 : l.href) != null ? g : null;
231
231
  return f(
232
232
  t,
233
233
  "a",
@@ -238,49 +238,49 @@ function rt(i, r, t) {
238
238
  !u && "acp-article-button--disabled"
239
239
  ],
240
240
  href: u != null ? u : void 0,
241
- target: c == null ? void 0 : c.target,
242
- rel: c == null ? void 0 : c.rel,
241
+ target: l == null ? void 0 : l.target,
242
+ rel: l == null ? void 0 : l.rel,
243
243
  title: o.title,
244
244
  "data-node-type": "articleButton",
245
245
  "data-article-button-id": o.id,
246
246
  "data-article-button-style": o.style,
247
247
  "aria-disabled": u ? void 0 : "true",
248
248
  onClick: (y) => {
249
- u || y.preventDefault(), t.emitArticleButtonClick({ attrs: o, node: l, href: u, event: y });
249
+ u || y.preventDefault(), t.emitArticleButtonClick({ attrs: o, node: a, href: u, event: y });
250
250
  }
251
251
  },
252
252
  o.text
253
253
  );
254
254
  }
255
- function D(i, r, t) {
256
- if (!p(i) || typeof i.type != "string" || !J.has(i.type))
255
+ function v(n, r, t) {
256
+ if (!h(n) || typeof n.type != "string" || !Z.has(n.type))
257
257
  return null;
258
- const e = _(i.attrs);
259
- switch (i.type) {
258
+ const e = P(n.attrs);
259
+ switch (n.type) {
260
260
  case "paragraph": {
261
- const n = w(e.textAlign) ? e.textAlign : void 0;
261
+ const i = w(e.textAlign) ? e.textAlign : void 0;
262
262
  return f(
263
263
  t,
264
264
  "p",
265
265
  {
266
266
  class: "acp-paragraph",
267
267
  "data-node-type": "paragraph",
268
- style: n ? { textAlign: n } : void 0
268
+ style: i ? { textAlign: i } : void 0
269
269
  },
270
- O(i.content, g(r, "content"), t)
270
+ V(n.content, p(r, "content"), t)
271
271
  );
272
272
  }
273
273
  case "heading": {
274
- const n = Number.isInteger(e.level) && Number(e.level) >= 1 && Number(e.level) <= 6 ? Number(e.level) : 1, s = w(e.textAlign) ? e.textAlign : void 0;
274
+ const i = Number.isInteger(e.level) && Number(e.level) >= 1 && Number(e.level) <= 6 ? Number(e.level) : 1, s = w(e.textAlign) ? e.textAlign : void 0;
275
275
  return f(
276
276
  t,
277
- `h${n}`,
277
+ `h${i}`,
278
278
  {
279
- class: ["acp-heading", `acp-heading--${n}`],
279
+ class: ["acp-heading", `acp-heading--${i}`],
280
280
  "data-node-type": "heading",
281
281
  style: s ? { textAlign: s } : void 0
282
282
  },
283
- O(i.content, g(r, "content"), t)
283
+ V(n.content, p(r, "content"), t)
284
284
  );
285
285
  }
286
286
  case "blockquote":
@@ -288,50 +288,50 @@ function D(i, r, t) {
288
288
  t,
289
289
  "blockquote",
290
290
  { class: "acp-blockquote", "data-node-type": "blockquote" },
291
- P(i.content, g(r, "content"), t)
291
+ S(n.content, p(r, "content"), t)
292
292
  );
293
293
  case "bulletList": {
294
- const n = k(i.content).map((s, o) => V(s, g(r, "content", o), t)).filter((s) => s !== null);
295
- return f(t, "ul", { class: "acp-list acp-list--bullet", "data-node-type": "bulletList" }, n);
294
+ const i = k(n.content).map((s, o) => q(s, p(r, "content", o), t)).filter((s) => s !== null);
295
+ return f(t, "ul", { class: "acp-list acp-list--bullet", "data-node-type": "bulletList" }, i);
296
296
  }
297
297
  case "orderedList": {
298
- const n = Number.isInteger(e.start) && Number(e.start) >= 1 ? Number(e.start) : 1, s = k(i.content).map((o, l) => V(o, g(r, "content", l), t)).filter((o) => o !== null);
298
+ const i = Number.isInteger(e.start) && Number(e.start) >= 1 ? Number(e.start) : 1, s = k(n.content).map((o, a) => q(o, p(r, "content", a), t)).filter((o) => o !== null);
299
299
  return f(
300
300
  t,
301
301
  "ol",
302
302
  {
303
303
  class: "acp-list acp-list--ordered",
304
304
  "data-node-type": "orderedList",
305
- start: n
305
+ start: i
306
306
  },
307
307
  s
308
308
  );
309
309
  }
310
310
  case "codeBlock": {
311
- const n = typeof e.language == "string" && e.language ? e.language : void 0, s = k(i.content).filter((o) => p(o) && o.type === "text" && typeof o.text == "string").map((o) => o.text).join("");
311
+ const i = typeof e.language == "string" && e.language ? e.language : void 0, s = k(n.content).filter((o) => h(o) && o.type === "text" && typeof o.text == "string").map((o) => o.text).join("");
312
312
  return f(
313
313
  t,
314
314
  "pre",
315
315
  {
316
316
  class: "acp-code-block",
317
317
  "data-node-type": "codeBlock",
318
- "data-language": n
318
+ "data-language": i
319
319
  },
320
- [f(t, "code", { class: n ? `language-${n}` : void 0 }, s)]
320
+ [f(t, "code", { class: i ? `language-${i}` : void 0 }, s)]
321
321
  );
322
322
  }
323
323
  case "horizontalRule":
324
324
  return f(t, "hr", { class: "acp-horizontal-rule", "data-node-type": "horizontalRule" });
325
325
  case "image": {
326
- const n = T(X(e.src, t.imageBaseUrl), "image");
327
- if (!n)
326
+ const i = _(Q(e.src, t.imageBaseUrl), "image");
327
+ if (!i)
328
328
  return b(t, {
329
329
  code: "UNSAFE_URL",
330
- path: g(r, "attrs", "src"),
330
+ path: p(r, "attrs", "src"),
331
331
  message: "The image URL is empty, malformed, or uses a disallowed protocol.",
332
332
  nodeType: "image"
333
333
  }), null;
334
- const s = Q(e.imageAlign) ? e.imageAlign : "center", o = Number.isInteger(e.width) && Number(e.width) >= 1 && Number(e.width) <= 1e4 ? Number(e.width) : void 0, l = Number.isInteger(e.height) && Number(e.height) >= 1 && Number(e.height) <= 1e4 ? Number(e.height) : void 0;
334
+ const s = tt(e.imageAlign) ? e.imageAlign : "center", o = Number.isInteger(e.width) && Number(e.width) >= 1 && Number(e.width) <= 1e4 ? Number(e.width) : void 0, a = Number.isInteger(e.height) && Number(e.height) >= 1 && Number(e.height) <= 1e4 ? Number(e.height) : void 0;
335
335
  return f(
336
336
  t,
337
337
  "div",
@@ -343,55 +343,55 @@ function D(i, r, t) {
343
343
  [
344
344
  f(t, "img", {
345
345
  class: "acp-image__element",
346
- src: n,
346
+ src: i,
347
347
  alt: typeof e.alt == "string" ? e.alt : "",
348
348
  title: typeof e.title == "string" ? e.title : void 0,
349
349
  width: o,
350
- height: l,
350
+ height: a,
351
351
  "data-image-align": s
352
352
  })
353
353
  ]
354
354
  );
355
355
  }
356
356
  case "articleButton":
357
- return rt(i, r, t);
357
+ return it(n, r, t);
358
358
  case "table": {
359
- const n = k(i.content).map((s, o) => et(s, g(r, "content", o), t)).filter((s) => s !== null);
359
+ const i = k(n.content).map((s, o) => nt(s, p(r, "content", o), t)).filter((s) => s !== null);
360
360
  return f(
361
361
  t,
362
362
  "div",
363
363
  { class: "acp-table-wrapper", "data-node-type": "table" },
364
- [f(t, "table", { class: "acp-table" }, [f(t, "tbody", n)])]
364
+ [f(t, "table", { class: "acp-table" }, [f(t, "tbody", i)])]
365
365
  );
366
366
  }
367
367
  }
368
368
  return null;
369
369
  }
370
- function P(i, r, t) {
371
- return k(i).map((e, n) => D(e, g(r, n), t)).filter((e) => e !== null);
370
+ function S(n, r, t) {
371
+ return k(n).map((e, i) => v(e, p(r, i), t)).filter((e) => e !== null);
372
372
  }
373
- function it(i, r) {
374
- const t = k(i.content), e = /* @__PURE__ */ new Map();
373
+ function st(n, r) {
374
+ const t = k(n.content), e = /* @__PURE__ */ new Map();
375
375
  r.customSlots.forEach((s) => {
376
- var l;
376
+ var a;
377
377
  if (!Number.isInteger(s.location) || s.location < 1 || s.location > t.length)
378
378
  return;
379
- const o = (l = e.get(s.location)) != null ? l : [];
379
+ const o = (a = e.get(s.location)) != null ? a : [];
380
380
  o.push(s), e.set(s.location, o);
381
381
  });
382
- const n = [];
382
+ const i = [];
383
383
  return t.forEach((s, o) => {
384
384
  var u;
385
- const l = o + 1;
386
- (u = e.get(l)) == null || u.forEach((h) => n.push(...h.content));
387
- const c = D(s, g("/content", o), r);
388
- c && typeof c != "string" && n.push(c);
389
- }), n;
385
+ const a = o + 1;
386
+ (u = e.get(a)) == null || u.forEach((g) => i.push(...g.content));
387
+ const l = v(s, p("/content", o), r);
388
+ l && typeof l != "string" && i.push(l);
389
+ }), i;
390
390
  }
391
- function nt(i, r) {
392
- return !p(i) || i.type !== "doc" ? [] : it(i, r);
391
+ function ot(n, r) {
392
+ return !h(n) || n.type !== "doc" ? [] : st(n, r);
393
393
  }
394
- const st = /* @__PURE__ */ new Set([
394
+ const at = /* @__PURE__ */ new Set([
395
395
  "paragraph",
396
396
  "heading",
397
397
  "blockquote",
@@ -402,28 +402,28 @@ const st = /* @__PURE__ */ new Set([
402
402
  "image",
403
403
  "articleButton",
404
404
  "table"
405
- ]), ot = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), at = /* @__PURE__ */ new Set(["left", "center", "right"]), lt = /* @__PURE__ */ new Set(["bold", "italic", "strike", "underline", "code"]);
406
- function I(i) {
407
- return typeof i == "object" && i !== null && !Array.isArray(i);
405
+ ]), ct = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), lt = /* @__PURE__ */ new Set(["left", "center", "right"]), dt = /* @__PURE__ */ new Set(["bold", "italic", "strike", "underline", "code"]);
406
+ function I(n) {
407
+ return typeof n == "object" && n !== null && !Array.isArray(n);
408
408
  }
409
- function a(i, r) {
410
- return `${i}/${String(r).replaceAll("~", "~0").replaceAll("/", "~1")}`;
409
+ function c(n, r) {
410
+ return `${n}/${String(r).replaceAll("~", "~0").replaceAll("/", "~1")}`;
411
411
  }
412
- function d(i, ...r) {
413
- let t = i;
414
- for (const e of r) t = a(t, e);
412
+ function d(n, ...r) {
413
+ let t = n;
414
+ for (const e of r) t = c(t, e);
415
415
  return t;
416
416
  }
417
- class ct {
417
+ class ut {
418
418
  constructor() {
419
- B(this, "issues", []);
419
+ O(this, "issues", []);
420
420
  }
421
421
  validate(r) {
422
422
  if (!I(r))
423
423
  return this.add("INVALID_ROOT", "", "The document must be an object."), this.result();
424
424
  this.checkProperties(r, "", ["type", "content"], ["type", "content"]), r.type !== "doc" && this.add("INVALID_ROOT", "/type", 'The root node type must be "doc".');
425
425
  const t = this.requireArray(r.content, "/content");
426
- return t == null || t.forEach((e, n) => this.validateBlock(e, a("/content", n))), this.result();
426
+ return t == null || t.forEach((e, i) => this.validateBlock(e, c("/content", i))), this.result();
427
427
  }
428
428
  result() {
429
429
  return {
@@ -431,23 +431,23 @@ class ct {
431
431
  issues: this.issues
432
432
  };
433
433
  }
434
- add(r, t, e, n) {
435
- this.issues.push(m({ code: r, path: t, message: e }, n ? { nodeType: n } : {}));
434
+ add(r, t, e, i) {
435
+ this.issues.push(m({ code: r, path: t, message: e }, i ? { nodeType: i } : {}));
436
436
  }
437
- checkProperties(r, t, e, n = [], s) {
437
+ checkProperties(r, t, e, i = [], s) {
438
438
  const o = new Set(e);
439
- for (const l of Object.keys(r))
440
- o.has(l) || this.add(
439
+ for (const a of Object.keys(r))
440
+ o.has(a) || this.add(
441
441
  "UNKNOWN_PROPERTY",
442
- a(t, l),
443
- `Property "${l}" is not allowed.`,
442
+ c(t, a),
443
+ `Property "${a}" is not allowed.`,
444
444
  s
445
445
  );
446
- for (const l of n)
447
- l in r || this.add(
446
+ for (const a of i)
447
+ a in r || this.add(
448
448
  "MISSING_PROPERTY",
449
- a(t, l),
450
- `Required property "${l}" is missing.`,
449
+ c(t, a),
450
+ `Required property "${a}" is missing.`,
451
451
  s
452
452
  );
453
453
  }
@@ -458,13 +458,13 @@ class ct {
458
458
  return r === void 0 ? [] : this.requireArray(r, t, e);
459
459
  }
460
460
  requireNonEmptyArray(r, t, e) {
461
- const n = this.requireArray(r, t, e);
462
- return n && n.length === 0 && this.add(
461
+ const i = this.requireArray(r, t, e);
462
+ return i && i.length === 0 && this.add(
463
463
  "INVALID_CONTENT",
464
464
  t,
465
465
  `Node "${e}" must contain at least one child.`,
466
466
  e
467
- ), n;
467
+ ), i;
468
468
  }
469
469
  requireRecord(r, t, e) {
470
470
  return I(r) ? r : (this.add("INVALID_TYPE", t, "Expected an object.", e), null);
@@ -472,22 +472,22 @@ class ct {
472
472
  optionalRecord(r, t, e) {
473
473
  return r === void 0 ? {} : this.requireRecord(r, t, e);
474
474
  }
475
- requireString(r, t, e, n = {}) {
476
- return typeof r != "string" ? (this.add("INVALID_TYPE", t, "Expected a string.", e), !1) : !n.allowEmpty && r.length === 0 ? (this.add("INVALID_VALUE", t, "The string must not be empty.", e), !1) : n.maxLength !== void 0 && r.length > n.maxLength ? (this.add(
475
+ requireString(r, t, e, i = {}) {
476
+ return typeof r != "string" ? (this.add("INVALID_TYPE", t, "Expected a string.", e), !1) : !i.allowEmpty && r.length === 0 ? (this.add("INVALID_VALUE", t, "The string must not be empty.", e), !1) : i.maxLength !== void 0 && r.length > i.maxLength ? (this.add(
477
477
  "INVALID_VALUE",
478
478
  t,
479
- `The string must contain at most ${n.maxLength} characters.`,
479
+ `The string must contain at most ${i.maxLength} characters.`,
480
480
  e
481
481
  ), !1) : !0;
482
482
  }
483
- optionalString(r, t, e, n = {}) {
484
- r !== void 0 && this.requireString(r, t, e, n);
483
+ optionalString(r, t, e, i = {}) {
484
+ r !== void 0 && this.requireString(r, t, e, i);
485
485
  }
486
- requireInteger(r, t, e, n, s) {
486
+ requireInteger(r, t, e, i, s) {
487
487
  if (!Number.isInteger(r))
488
488
  return this.add("INVALID_TYPE", t, "Expected an integer.", e), !1;
489
489
  const o = r;
490
- return n !== void 0 && o < n ? (this.add("INVALID_VALUE", t, `Value must be at least ${n}.`, e), !1) : s !== void 0 && o > s ? (this.add("INVALID_VALUE", t, `Value must be at most ${s}.`, e), !1) : !0;
490
+ return i !== void 0 && o < i ? (this.add("INVALID_VALUE", t, `Value must be at least ${i}.`, e), !1) : s !== void 0 && o > s ? (this.add("INVALID_VALUE", t, `Value must be at most ${s}.`, e), !1) : !0;
491
491
  }
492
492
  validateBlock(r, t) {
493
493
  if (!I(r)) {
@@ -496,11 +496,11 @@ class ct {
496
496
  }
497
497
  const e = r.type;
498
498
  if (typeof e != "string") {
499
- this.add("MISSING_PROPERTY", a(t, "type"), "A block node requires a type.");
499
+ this.add("MISSING_PROPERTY", c(t, "type"), "A block node requires a type.");
500
500
  return;
501
501
  }
502
- if (!st.has(e)) {
503
- this.add("UNKNOWN_NODE", a(t, "type"), `Unknown block node "${e}".`, e);
502
+ if (!at.has(e)) {
503
+ this.add("UNKNOWN_NODE", c(t, "type"), `Unknown block node "${e}".`, e);
504
504
  return;
505
505
  }
506
506
  switch (e) {
@@ -538,34 +538,34 @@ class ct {
538
538
  }
539
539
  validateParagraph(r, t) {
540
540
  const e = "paragraph";
541
- this.checkProperties(r, t, ["type", "attrs", "content"], ["type"], e), this.validateTextAlignAttrs(r.attrs, a(t, "attrs"), e, !1), this.validateInlineContent(r.content, a(t, "content"), e);
541
+ this.checkProperties(r, t, ["type", "attrs", "content"], ["type"], e), this.validateTextAlignAttrs(r.attrs, c(t, "attrs"), e, !1), this.validateInlineContent(r.content, c(t, "content"), e);
542
542
  }
543
543
  validateHeading(r, t) {
544
544
  const e = "heading";
545
545
  this.checkProperties(r, t, ["type", "attrs", "content"], ["type", "attrs"], e);
546
- const n = this.requireRecord(r.attrs, a(t, "attrs"), e);
547
- n && (this.checkProperties(n, a(t, "attrs"), ["level", "textAlign"], ["level"], e), this.requireInteger(n.level, d(t, "attrs", "level"), e, 1, 6), this.validateTextAlign(n.textAlign, d(t, "attrs", "textAlign"), e)), this.validateInlineContent(r.content, a(t, "content"), e);
546
+ const i = this.requireRecord(r.attrs, c(t, "attrs"), e);
547
+ i && (this.checkProperties(i, c(t, "attrs"), ["level", "textAlign"], ["level"], e), this.requireInteger(i.level, d(t, "attrs", "level"), e, 1, 6), this.validateTextAlign(i.textAlign, d(t, "attrs", "textAlign"), e)), this.validateInlineContent(r.content, c(t, "content"), e);
548
548
  }
549
- validateTextAlignAttrs(r, t, e, n) {
550
- const s = n ? this.requireRecord(r, t, e) : this.optionalRecord(r, t, e);
551
- s && (this.checkProperties(s, t, ["textAlign"], [], e), this.validateTextAlign(s.textAlign, a(t, "textAlign"), e));
549
+ validateTextAlignAttrs(r, t, e, i) {
550
+ const s = i ? this.requireRecord(r, t, e) : this.optionalRecord(r, t, e);
551
+ s && (this.checkProperties(s, t, ["textAlign"], [], e), this.validateTextAlign(s.textAlign, c(t, "textAlign"), e));
552
552
  }
553
553
  validateTextAlign(r, t, e) {
554
- r !== void 0 && (typeof r != "string" ? this.add("INVALID_TYPE", t, "Text alignment must be a string.", e) : ot.has(r) || this.add("INVALID_VALUE", t, `Unsupported text alignment "${r}".`, e));
554
+ r !== void 0 && (typeof r != "string" ? this.add("INVALID_TYPE", t, "Text alignment must be a string.", e) : ct.has(r) || this.add("INVALID_VALUE", t, `Unsupported text alignment "${r}".`, e));
555
555
  }
556
556
  validateInlineContent(r, t, e) {
557
- const n = this.optionalArray(r, t, e);
558
- n == null || n.forEach((s, o) => this.validateText(s, a(t, o), !0));
557
+ const i = this.optionalArray(r, t, e);
558
+ i == null || i.forEach((s, o) => this.validateText(s, c(t, o), !0));
559
559
  }
560
560
  validateText(r, t, e) {
561
561
  if (!I(r)) {
562
562
  this.add("INVALID_TYPE", t, "A text node must be an object.", "text");
563
563
  return;
564
564
  }
565
- const n = e ? ["type", "text", "marks"] : ["type", "text"];
566
- if (this.checkProperties(r, t, n, ["type", "text"], "text"), r.type !== "text" && this.add("INVALID_CONTENT", a(t, "type"), "Expected a text node.", "text"), this.requireString(r.text, a(t, "text"), "text"), e && r.marks !== void 0) {
567
- const s = this.requireArray(r.marks, a(t, "marks"), "text");
568
- s == null || s.forEach((o, l) => this.validateMark(o, d(t, "marks", l)));
565
+ const i = e ? ["type", "text", "marks"] : ["type", "text"];
566
+ if (this.checkProperties(r, t, i, ["type", "text"], "text"), r.type !== "text" && this.add("INVALID_CONTENT", c(t, "type"), "Expected a text node.", "text"), this.requireString(r.text, c(t, "text"), "text"), e && r.marks !== void 0) {
567
+ const s = this.requireArray(r.marks, c(t, "marks"), "text");
568
+ s == null || s.forEach((o, a) => this.validateMark(o, d(t, "marks", a)));
569
569
  }
570
570
  }
571
571
  validateMark(r, t) {
@@ -574,20 +574,20 @@ class ct {
574
574
  return;
575
575
  }
576
576
  if (typeof r.type != "string") {
577
- this.add("MISSING_PROPERTY", a(t, "type"), "A mark requires a type.");
577
+ this.add("MISSING_PROPERTY", c(t, "type"), "A mark requires a type.");
578
578
  return;
579
579
  }
580
- if (lt.has(r.type)) {
580
+ if (dt.has(r.type)) {
581
581
  this.checkProperties(r, t, ["type"], ["type"], r.type);
582
582
  return;
583
583
  }
584
584
  if (r.type !== "link") {
585
- this.add("UNKNOWN_MARK", a(t, "type"), `Unknown mark "${r.type}".`, r.type);
585
+ this.add("UNKNOWN_MARK", c(t, "type"), `Unknown mark "${r.type}".`, r.type);
586
586
  return;
587
587
  }
588
588
  this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], "link");
589
- const e = this.requireRecord(r.attrs, a(t, "attrs"), "link");
590
- e && (this.checkProperties(e, a(t, "attrs"), ["href", "target"], ["href"], "link"), this.requireString(e.href, d(t, "attrs", "href"), "link"), e.target !== void 0 && e.target !== "_blank" && e.target !== "_self" && this.add(
589
+ const e = this.requireRecord(r.attrs, c(t, "attrs"), "link");
590
+ e && (this.checkProperties(e, c(t, "attrs"), ["href", "target"], ["href"], "link"), this.requireString(e.href, d(t, "attrs", "href"), "link"), e.target !== void 0 && e.target !== "_blank" && e.target !== "_self" && this.add(
591
591
  "INVALID_VALUE",
592
592
  d(t, "attrs", "target"),
593
593
  'Link target must be "_blank" or "_self".',
@@ -597,83 +597,83 @@ class ct {
597
597
  validateBlockquote(r, t) {
598
598
  const e = "blockquote";
599
599
  this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
600
- const n = this.requireNonEmptyArray(r.content, a(t, "content"), e);
601
- n == null || n.forEach((s, o) => this.validateBlock(s, d(t, "content", o)));
600
+ const i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
601
+ i == null || i.forEach((s, o) => this.validateBlock(s, d(t, "content", o)));
602
602
  }
603
603
  validateBulletList(r, t) {
604
604
  const e = "bulletList";
605
605
  this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
606
- const n = this.requireNonEmptyArray(r.content, a(t, "content"), e);
607
- n == null || n.forEach((s, o) => this.validateListItem(s, d(t, "content", o)));
606
+ const i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
607
+ i == null || i.forEach((s, o) => this.validateListItem(s, d(t, "content", o)));
608
608
  }
609
609
  validateOrderedList(r, t) {
610
610
  const e = "orderedList";
611
611
  this.checkProperties(r, t, ["type", "attrs", "content"], ["type", "content"], e);
612
- const n = this.optionalRecord(r.attrs, a(t, "attrs"), e);
613
- n && (this.checkProperties(n, a(t, "attrs"), ["start"], [], e), n.start !== void 0 && this.requireInteger(n.start, d(t, "attrs", "start"), e, 1));
614
- const s = this.requireNonEmptyArray(r.content, a(t, "content"), e);
615
- s == null || s.forEach((o, l) => this.validateListItem(o, d(t, "content", l)));
612
+ const i = this.optionalRecord(r.attrs, c(t, "attrs"), e);
613
+ i && (this.checkProperties(i, c(t, "attrs"), ["start"], [], e), i.start !== void 0 && this.requireInteger(i.start, d(t, "attrs", "start"), e, 1));
614
+ const s = this.requireNonEmptyArray(r.content, c(t, "content"), e);
615
+ s == null || s.forEach((o, a) => this.validateListItem(o, d(t, "content", a)));
616
616
  }
617
617
  validateListItem(r, t) {
618
- const e = "listItem", n = this.requireRecord(r, t, e);
619
- if (!n) return;
620
- this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", a(t, "type"), "Expected a listItem node.", e);
621
- const s = this.requireNonEmptyArray(n.content, a(t, "content"), e);
622
- s == null || s.forEach((o, l) => this.validateBlock(o, d(t, "content", l)));
618
+ const e = "listItem", i = this.requireRecord(r, t, e);
619
+ if (!i) return;
620
+ this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a listItem node.", e);
621
+ const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
622
+ s == null || s.forEach((o, a) => this.validateBlock(o, d(t, "content", a)));
623
623
  }
624
624
  validateCodeBlock(r, t) {
625
625
  const e = "codeBlock";
626
626
  this.checkProperties(r, t, ["type", "attrs", "content"], ["type"], e);
627
- const n = this.optionalRecord(r.attrs, a(t, "attrs"), e);
628
- n && (this.checkProperties(n, a(t, "attrs"), ["language"], [], e), this.optionalString(n.language, d(t, "attrs", "language"), e, { maxLength: 32 }));
629
- const s = this.optionalArray(r.content, a(t, "content"), e);
627
+ const i = this.optionalRecord(r.attrs, c(t, "attrs"), e);
628
+ i && (this.checkProperties(i, c(t, "attrs"), ["language"], [], e), this.optionalString(i.language, d(t, "attrs", "language"), e, { maxLength: 32 }));
629
+ const s = this.optionalArray(r.content, c(t, "content"), e);
630
630
  s && (s.length > 1 && this.add(
631
631
  "INVALID_CONTENT",
632
- a(t, "content"),
632
+ c(t, "content"),
633
633
  "A codeBlock may contain at most one text node.",
634
634
  e
635
635
  ), s.forEach(
636
- (o, l) => this.validateText(o, d(t, "content", l), !1)
636
+ (o, a) => this.validateText(o, d(t, "content", a), !1)
637
637
  ));
638
638
  }
639
639
  validateImage(r, t) {
640
640
  const e = "image";
641
641
  this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], e);
642
- const n = this.requireRecord(r.attrs, a(t, "attrs"), e);
643
- n && (this.checkProperties(
644
- n,
645
- a(t, "attrs"),
642
+ const i = this.requireRecord(r.attrs, c(t, "attrs"), e);
643
+ i && (this.checkProperties(
644
+ i,
645
+ c(t, "attrs"),
646
646
  ["src", "alt", "title", "width", "height", "imageAlign"],
647
647
  ["src"],
648
648
  e
649
- ), this.requireString(n.src, d(t, "attrs", "src"), e), this.optionalString(n.alt, d(t, "attrs", "alt"), e, { allowEmpty: !0 }), this.optionalString(n.title, d(t, "attrs", "title"), e, { allowEmpty: !0 }), n.width !== void 0 && this.requireInteger(n.width, d(t, "attrs", "width"), e, 1, 1e4), n.height !== void 0 && this.requireInteger(n.height, d(t, "attrs", "height"), e, 1, 1e4), n.imageAlign !== void 0 && (typeof n.imageAlign != "string" ? this.add("INVALID_TYPE", d(t, "attrs", "imageAlign"), "Image alignment must be a string.", e) : at.has(n.imageAlign) || this.add(
649
+ ), this.requireString(i.src, d(t, "attrs", "src"), e), this.optionalString(i.alt, d(t, "attrs", "alt"), e, { allowEmpty: !0 }), this.optionalString(i.title, d(t, "attrs", "title"), e, { allowEmpty: !0 }), i.width !== void 0 && this.requireInteger(i.width, d(t, "attrs", "width"), e, 1, 1e4), i.height !== void 0 && this.requireInteger(i.height, d(t, "attrs", "height"), e, 1, 1e4), i.imageAlign !== void 0 && (typeof i.imageAlign != "string" ? this.add("INVALID_TYPE", d(t, "attrs", "imageAlign"), "Image alignment must be a string.", e) : lt.has(i.imageAlign) || this.add(
650
650
  "INVALID_VALUE",
651
651
  d(t, "attrs", "imageAlign"),
652
- `Unsupported image alignment "${n.imageAlign}".`,
652
+ `Unsupported image alignment "${i.imageAlign}".`,
653
653
  e
654
654
  )));
655
655
  }
656
656
  validateArticleButton(r, t) {
657
657
  const e = "articleButton";
658
658
  this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], e);
659
- const n = this.requireRecord(r.attrs, a(t, "attrs"), e);
660
- n && (this.checkProperties(
661
- n,
662
- a(t, "attrs"),
659
+ const i = this.requireRecord(r.attrs, c(t, "attrs"), e);
660
+ i && (this.checkProperties(
661
+ i,
662
+ c(t, "attrs"),
663
663
  ["id", "title", "text", "style", "href"],
664
664
  ["text", "style"],
665
665
  e
666
- ), n.style === "text" || n.style === "button" ? "id" in n ? this.requireString(n.id, d(t, "attrs", "id"), e) : this.add(
666
+ ), i.style === "text" || i.style === "button" ? "id" in i ? this.requireString(i.id, d(t, "attrs", "id"), e) : this.add(
667
667
  "MISSING_PROPERTY",
668
668
  d(t, "attrs", "id"),
669
669
  'Required property "id" is missing for an articleButton with text or button style.',
670
670
  e
671
- ) : this.optionalString(n.id, d(t, "attrs", "id"), e), this.optionalString(n.title, d(t, "attrs", "title"), e), this.requireString(n.text, d(t, "attrs", "text"), e), this.optionalString(n.href, d(t, "attrs", "href"), e), n.style !== "text" && n.style !== "button" && n.style !== "link" && this.add(
671
+ ) : this.optionalString(i.id, d(t, "attrs", "id"), e), this.optionalString(i.title, d(t, "attrs", "title"), e), this.requireString(i.text, d(t, "attrs", "text"), e), this.optionalString(i.href, d(t, "attrs", "href"), e), i.style !== "text" && i.style !== "button" && i.style !== "link" && this.add(
672
672
  "INVALID_VALUE",
673
673
  d(t, "attrs", "style"),
674
674
  'Article button style must be "text", "button", or "link".',
675
675
  e
676
- ), n.href !== void 0 && n.style !== "link" && this.add(
676
+ ), i.href !== void 0 && i.style !== "link" && this.add(
677
677
  "INVALID_VALUE",
678
678
  d(t, "attrs", "href"),
679
679
  'Article button href may only be present when style is "link".',
@@ -683,14 +683,14 @@ class ct {
683
683
  validateTable(r, t) {
684
684
  const e = "table";
685
685
  this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
686
- const n = this.requireNonEmptyArray(r.content, a(t, "content"), e);
687
- if (!n) return;
686
+ const i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
687
+ if (!i) return;
688
688
  let s = null;
689
- n.forEach((o, l) => {
690
- const c = d(t, "content", l), u = this.validateTableRow(o, c);
689
+ i.forEach((o, a) => {
690
+ const l = d(t, "content", a), u = this.validateTableRow(o, l);
691
691
  u !== null && (s === null ? s = u : u !== s && this.add(
692
692
  "TABLE_COLUMN_MISMATCH",
693
- a(c, "content"),
693
+ c(l, "content"),
694
694
  `Expected ${s} table cells but received ${u}.`,
695
695
  "tableRow"
696
696
  ));
@@ -698,48 +698,100 @@ class ct {
698
698
  }
699
699
  validateTableRow(r, t) {
700
700
  var o;
701
- const e = "tableRow", n = this.requireRecord(r, t, e);
702
- if (!n) return null;
703
- this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", a(t, "type"), "Expected a tableRow node.", e);
704
- const s = this.requireNonEmptyArray(n.content, a(t, "content"), e);
705
- return s == null || s.forEach((l, c) => this.validateTableCell(l, d(t, "content", c))), (o = s == null ? void 0 : s.length) != null ? o : null;
701
+ const e = "tableRow", i = this.requireRecord(r, t, e);
702
+ if (!i) return null;
703
+ this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a tableRow node.", e);
704
+ const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
705
+ return s == null || s.forEach((a, l) => this.validateTableCell(a, d(t, "content", l))), (o = s == null ? void 0 : s.length) != null ? o : null;
706
706
  }
707
707
  validateTableCell(r, t) {
708
- const e = "tableCell", n = this.requireRecord(r, t, e);
709
- if (!n) return;
710
- this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", a(t, "type"), "Expected a tableCell node.", e);
711
- const s = this.requireNonEmptyArray(n.content, a(t, "content"), e);
712
- s == null || s.forEach((o, l) => this.validateBlock(o, d(t, "content", l)));
708
+ const e = "tableCell", i = this.requireRecord(r, t, e);
709
+ if (!i) return;
710
+ this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a tableCell node.", e);
711
+ const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
712
+ s == null || s.forEach((o, a) => this.validateBlock(o, d(t, "content", a)));
713
713
  }
714
714
  }
715
- function dt(i) {
716
- return new ct().validate(i);
715
+ function ft(n) {
716
+ return new ut().validate(n);
717
717
  }
718
- const C = Object.freeze({
718
+ const U = Object.freeze({
719
719
  version: 1,
720
- validate: dt,
721
- render: nt
722
- }), $ = /* @__PURE__ */ new Map([[C.version, C]]), At = Object.freeze([...$.keys()]), v = 1;
723
- function x(i) {
724
- return $.get(i);
720
+ validate: ft,
721
+ render: ot
722
+ }), j = /* @__PURE__ */ new Map([[U.version, U]]), Rt = Object.freeze([...j.keys()]), z = 1;
723
+ function M(n) {
724
+ return j.get(n);
725
725
  }
726
- function ut(i, r = {}) {
726
+ function gt(n, r = {}) {
727
727
  var s;
728
- const t = (s = r.protocolVersion) != null ? s : v, e = x(t);
729
- return e ? e.validate(i) : { valid: !1, issues: [{
728
+ const t = (s = r.protocolVersion) != null ? s : z, e = M(t);
729
+ return e ? e.validate(n) : { valid: !1, issues: [{
730
730
  code: "UNSUPPORTED_PROTOCOL",
731
731
  path: "",
732
732
  message: `Article Content Protocol version ${t} is not supported.`
733
733
  }] };
734
734
  }
735
- function ft() {
735
+ function pt() {
736
736
  return [];
737
737
  }
738
- function ht(i) {
739
- return `${i.code}:${i.path}:${i.message}`;
738
+ function T(n) {
739
+ return `${n.code}:${n.path}:${n.message}`;
740
740
  }
741
- const gt = K.extend({
741
+ function ht(n) {
742
+ const r = n.slots();
743
+ return n.props.customSlots.map((t) => {
744
+ var s, o, a, l;
745
+ const e = { id: t.id, location: t.location }, i = (l = (a = (o = (s = n.scopedSlots)[t.id]) == null ? void 0 : o.call(s, e)) != null ? a : r[t.id]) != null ? l : [];
746
+ return A(m({}, t), { content: i });
747
+ });
748
+ }
749
+ function yt(n, r) {
750
+ Array.isArray(n) ? n.forEach((t) => t(r)) : n == null || n(r);
751
+ }
752
+ const mt = $.extend({
753
+ name: "ArticleContentRenderIssueReporter",
754
+ props: {
755
+ issues: {
756
+ type: Array,
757
+ required: !0
758
+ }
759
+ },
760
+ data() {
761
+ return {
762
+ reportedFingerprint: ""
763
+ };
764
+ },
765
+ watch: {
766
+ issues: {
767
+ immediate: !0,
768
+ deep: !0,
769
+ handler(n) {
770
+ const r = n.map(T).join("|");
771
+ r !== this.reportedFingerprint && (this.reportedFingerprint = r, this.$nextTick(() => n.forEach((t) => this.$emit("render-error", t))));
772
+ }
773
+ }
774
+ },
775
+ render(n) {
776
+ var r, t;
777
+ return (t = (r = this.$slots.default) == null ? void 0 : r[0]) != null ? t : n();
778
+ }
779
+ });
780
+ function D(n, r, t, e) {
781
+ var a;
782
+ const i = (a = t[0]) != null ? a : n(), s = r.listeners["render-error"], o = n(
783
+ mt,
784
+ {
785
+ props: { issues: e },
786
+ on: s ? { "render-error": s } : void 0
787
+ },
788
+ [i]
789
+ );
790
+ return t.length > 1 ? [o, ...t.slice(1)] : o;
791
+ }
792
+ const kt = {
742
793
  name: "ArticleContentRenderer",
794
+ functional: !0,
743
795
  props: {
744
796
  document: {
745
797
  type: null,
@@ -747,7 +799,7 @@ const gt = K.extend({
747
799
  },
748
800
  protocolVersion: {
749
801
  type: Number,
750
- default: v
802
+ default: z
751
803
  },
752
804
  strict: {
753
805
  type: Boolean,
@@ -755,7 +807,7 @@ const gt = K.extend({
755
807
  },
756
808
  customSlots: {
757
809
  type: Array,
758
- default: ft
810
+ default: pt
759
811
  },
760
812
  imageBaseUrl: {
761
813
  type: String,
@@ -766,57 +818,12 @@ const gt = K.extend({
766
818
  default: void 0
767
819
  }
768
820
  },
769
- data() {
770
- return {
771
- reportedRuntimeIssues: /* @__PURE__ */ new Set()
772
- };
773
- },
774
- computed: {
775
- validation() {
776
- return ut(this.document, { protocolVersion: this.protocolVersion });
777
- }
778
- },
779
- watch: {
780
- validation: {
781
- immediate: !0,
782
- deep: !0,
783
- handler(i) {
784
- i.issues.forEach((r) => this.$emit("render-error", r));
785
- }
786
- },
787
- document: {
788
- deep: !0,
789
- handler() {
790
- this.reportedRuntimeIssues.clear();
791
- }
792
- },
793
- protocolVersion() {
794
- this.reportedRuntimeIssues.clear();
795
- },
796
- resolveArticleButtonLink() {
797
- this.reportedRuntimeIssues.clear();
798
- },
799
- imageBaseUrl() {
800
- this.reportedRuntimeIssues.clear();
801
- }
802
- },
803
- methods: {
804
- resolveCustomSlots() {
805
- return this.customSlots.map((i) => {
806
- var e, n, s, o;
807
- const r = { id: i.id, location: i.location }, t = (o = (s = (n = (e = this.$scopedSlots)[i.id]) == null ? void 0 : n.call(e, r)) != null ? s : this.$slots[i.id]) != null ? o : [];
808
- return A(m({}, i), { content: t });
809
- });
810
- },
811
- reportRuntimeIssue(i) {
812
- const r = ht(i);
813
- this.reportedRuntimeIssues.has(r) || (this.reportedRuntimeIssues.add(r), this.$nextTick(() => this.$emit("render-error", i)));
814
- }
815
- },
816
- render(i) {
817
- const r = x(this.protocolVersion);
818
- if (!r || this.strict && !this.validation.valid)
819
- return i(
821
+ render(n, r) {
822
+ const { props: t } = r, e = gt(t.document, {
823
+ protocolVersion: t.protocolVersion
824
+ }), i = M(t.protocolVersion), s = [];
825
+ if (!i || t.strict && !e.valid) {
826
+ const a = n(
820
827
  "div",
821
828
  {
822
829
  class: "acp-render-error",
@@ -827,38 +834,35 @@ const gt = K.extend({
827
834
  },
828
835
  "Invalid article content"
829
836
  );
830
- const t = r.render(this.document, {
831
- createElement: i,
832
- customSlots: this.resolveCustomSlots(),
833
- imageBaseUrl: this.imageBaseUrl,
834
- resolveArticleButtonLink: this.resolveArticleButtonLink,
835
- emitArticleButtonClick: (e) => this.$emit("article-button-click", e),
836
- reportIssue: this.reportRuntimeIssue
837
+ return D(n, r, [a], e.issues);
838
+ }
839
+ const o = i.render(t.document, {
840
+ createElement: n,
841
+ customSlots: ht(r),
842
+ imageBaseUrl: t.imageBaseUrl,
843
+ resolveArticleButtonLink: t.resolveArticleButtonLink,
844
+ emitArticleButtonClick: (a) => yt(r.listeners["article-button-click"], a),
845
+ reportIssue: (a) => s.push(a)
837
846
  });
838
- return i(
839
- "div",
840
- {
841
- class: "acp-document",
842
- attrs: {
843
- "data-node-type": "doc",
844
- "data-protocol-version": this.protocolVersion
845
- }
846
- },
847
- t
848
- );
849
- }
850
- });
851
- function pt(i, r, t, e, n, s, o, l) {
852
- var c = typeof i == "function" ? i.options : i;
847
+ return D(n, r, o, [
848
+ ...e.issues,
849
+ ...s.filter(
850
+ (a, l, u) => u.findIndex((g) => T(g) === T(a)) === l
851
+ )
852
+ ]);
853
+ }
854
+ }, bt = $.extend(kt);
855
+ function At(n, r, t, e, i, s, o, a) {
856
+ var l = typeof n == "function" ? n.options : n;
853
857
  return {
854
- exports: i,
855
- options: c
858
+ exports: n,
859
+ options: l
856
860
  };
857
861
  }
858
- var yt = /* @__PURE__ */ pt(
859
- gt
862
+ var It = /* @__PURE__ */ At(
863
+ bt
860
864
  );
861
- const mt = yt.exports, It = Object.freeze({
865
+ const Lt = It.exports, Tt = Object.freeze({
862
866
  fileFormat: "article-content-protocol",
863
867
  fileFormatVersion: 1,
864
868
  mediaType: "application/vnd.article-content-protocol+json",
@@ -885,17 +889,17 @@ const mt = yt.exports, It = Object.freeze({
885
889
  "text"
886
890
  ]),
887
891
  markTypes: Object.freeze(["bold", "italic", "strike", "underline", "code", "link"])
888
- }), Lt = {
889
- install(i) {
890
- i.component("ArticleContentRenderer", mt);
892
+ }), _t = {
893
+ install(n) {
894
+ n.component("ArticleContentRenderer", Lt);
891
895
  }
892
896
  };
893
897
  export {
894
- It as ARTICLE_CONTENT_PROTOCOL_V1,
895
- mt as ArticleContentRenderer,
896
- Lt as ArticleContentRendererPlugin,
897
- v as CURRENT_PROTOCOL_VERSION,
898
- At as SUPPORTED_PROTOCOL_VERSIONS,
899
- mt as default,
900
- ut as validateArticleDocument
898
+ Tt as ARTICLE_CONTENT_PROTOCOL_V1,
899
+ Lt as ArticleContentRenderer,
900
+ _t as ArticleContentRendererPlugin,
901
+ z as CURRENT_PROTOCOL_VERSION,
902
+ Rt as SUPPORTED_PROTOCOL_VERSIONS,
903
+ Lt as default,
904
+ gt as validateArticleDocument
901
905
  };