article-content-renderer-vue2 0.2.0 → 0.3.0

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