@storyblok/astro 6.1.0 → 6.1.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.
@@ -1,4 +1,4 @@
1
- const E = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
1
+ const Q = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
2
  <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
3
  <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
4
4
  <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
@@ -7,74 +7,74 @@ const E = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xml
7
7
  </g>
8
8
  </g>
9
9
  </g>
10
- </svg>`, L = /[\p{Lu}]/u, T = /[\p{Ll}]/u, k = /^[\p{Lu}](?![\p{Lu}])/gu, A = /([\p{Alpha}\p{N}_]|$)/u, b = /[_.\- ]+/, j = new RegExp("^" + b.source), w = new RegExp(b.source + A.source, "gu"), $ = new RegExp("\\d+" + A.source, "gu"), R = (r, t, e, o) => {
11
- let s = !1, n = !1, a = !1, l = !1;
10
+ </svg>`, ee = /[\p{Lu}]/u, te = /[\p{Ll}]/u, O = /^[\p{Lu}](?![\p{Lu}])/gu, H = /([\p{Alpha}\p{N}_]|$)/u, j = /[_.\- ]+/, re = new RegExp("^" + j.source), _ = new RegExp(j.source + H.source, "gu"), M = new RegExp("\\d+" + H.source, "gu"), oe = (r, e, t, o) => {
11
+ let n = !1, s = !1, l = !1, d = !1;
12
12
  for (let i = 0; i < r.length; i++) {
13
- const c = r[i];
14
- l = i > 2 ? r[i - 3] === "-" : !0, s && L.test(c) ? (r = r.slice(0, i) + "-" + r.slice(i), s = !1, a = n, n = !0, i++) : n && a && T.test(c) && (!l || o) ? (r = r.slice(0, i - 1) + "-" + r.slice(i - 1), a = n, n = !1, s = !0) : (s = t(c) === c && e(c) !== c, a = n, n = e(c) === c && t(c) !== c);
13
+ const p = r[i];
14
+ d = i > 2 ? r[i - 3] === "-" : !0, n && ee.test(p) ? (r = r.slice(0, i) + "-" + r.slice(i), n = !1, l = s, s = !0, i++) : s && l && te.test(p) && (!d || o) ? (r = r.slice(0, i - 1) + "-" + r.slice(i - 1), l = s, s = !1, n = !0) : (n = e(p) === p && t(p) !== p, l = s, s = t(p) === p && e(p) !== p);
15
15
  }
16
16
  return r;
17
- }, M = (r, t) => (k.lastIndex = 0, r.replaceAll(k, (e) => t(e))), O = (r, t) => (w.lastIndex = 0, $.lastIndex = 0, r.replaceAll($, (e, o, s) => ["_", "-"].includes(r.charAt(s + e.length)) ? e : t(e)).replaceAll(w, (e, o) => t(o)));
18
- function P(r, t) {
17
+ }, se = (r, e) => (O.lastIndex = 0, r.replaceAll(O, (t) => e(t))), ne = (r, e) => (_.lastIndex = 0, M.lastIndex = 0, r.replaceAll(M, (t, o, n) => ["_", "-"].includes(r.charAt(n + t.length)) ? t : e(t)).replaceAll(_, (t, o) => e(o)));
18
+ function ae(r, e) {
19
19
  if (!(typeof r == "string" || Array.isArray(r)))
20
20
  throw new TypeError("Expected the input to be `string | string[]`");
21
- if (t = {
21
+ if (e = {
22
22
  pascalCase: !1,
23
23
  preserveConsecutiveUppercase: !1,
24
- ...t
25
- }, Array.isArray(r) ? r = r.map((n) => n.trim()).filter((n) => n.length).join("-") : r = r.trim(), r.length === 0)
24
+ ...e
25
+ }, Array.isArray(r) ? r = r.map((s) => s.trim()).filter((s) => s.length).join("-") : r = r.trim(), r.length === 0)
26
26
  return "";
27
- const e = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), o = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
28
- return r.length === 1 ? b.test(r) ? "" : t.pascalCase ? o(r) : e(r) : (r !== e(r) && (r = R(r, e, o, t.preserveConsecutiveUppercase)), r = r.replace(j, ""), r = t.preserveConsecutiveUppercase ? M(r, e) : e(r), t.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), O(r, o));
27
+ const t = e.locale === !1 ? (s) => s.toLowerCase() : (s) => s.toLocaleLowerCase(e.locale), o = e.locale === !1 ? (s) => s.toUpperCase() : (s) => s.toLocaleUpperCase(e.locale);
28
+ return r.length === 1 ? j.test(r) ? "" : e.pascalCase ? o(r) : t(r) : (r !== t(r) && (r = oe(r, t, o, e.preserveConsecutiveUppercase)), r = r.replace(re, ""), r = e.preserveConsecutiveUppercase ? se(r, t) : t(r), e.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), ne(r, o));
29
29
  }
30
- function v(r) {
31
- return P(r);
30
+ function N(r) {
31
+ return ae(r);
32
32
  }
33
- function _(r, t = {}, e, o) {
34
- const s = "virtual:storyblok-components", n = `\0${s}`;
33
+ function le(r, e = {}, t, o) {
34
+ const n = "virtual:storyblok-components", s = `\0${n}`;
35
35
  return {
36
36
  name: "vite-plugin-storyblok-components",
37
- async resolveId(a) {
38
- if (a === s)
39
- return n;
37
+ async resolveId(l) {
38
+ if (l === n)
39
+ return s;
40
40
  },
41
- async load(a) {
42
- if (a === n) {
43
- const l = [], i = [];
44
- for await (const [u, p] of Object.entries(t)) {
45
- const f = await this.resolve(
46
- `/${r}/${p}.astro`
41
+ async load(l) {
42
+ if (l === s) {
43
+ const d = [], i = [];
44
+ for await (const [g, $] of Object.entries(e)) {
45
+ const E = await this.resolve(
46
+ `/${r}/${$}.astro`
47
47
  );
48
- if (f)
49
- l.push(`import ${v(u)} from "${f.id}"`);
50
- else if (e)
51
- i.push(u);
48
+ if (E)
49
+ d.push(`import ${N(g)} from "${E.id}"`);
50
+ else if (t)
51
+ i.push(g);
52
52
  else
53
53
  throw new Error(
54
- `Component could not be found for blok "${u}"! Does "${`/${r}/${p}`}.astro" exist?`
54
+ `Component could not be found for blok "${g}"! Does "${`/${r}/${$}`}.astro" exist?`
55
55
  );
56
56
  }
57
- let c = "";
58
- if (e)
59
- if (c = ",FallbackComponent", o) {
60
- const u = await this.resolve(
57
+ let p = "";
58
+ if (t)
59
+ if (p = ",FallbackComponent", o) {
60
+ const g = await this.resolve(
61
61
  `/${r}/${o}.astro`
62
62
  );
63
- if (!u)
63
+ if (!g)
64
64
  throw new Error(
65
65
  `Custom fallback component could not be found. Does "${`/${r}/${o}`}.astro" exist?`
66
66
  );
67
- l.push(
68
- `import FallbackComponent from "${u.id}"`
67
+ d.push(
68
+ `import FallbackComponent from "${g.id}"`
69
69
  );
70
70
  } else
71
- l.push(
71
+ d.push(
72
72
  "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
73
73
  );
74
- if (Object.values(t).length)
75
- return `${l.join(";")};export default {${Object.keys(t).filter((u) => !i.includes(u)).map((u) => v(u)).join(",")}${c}}`;
76
- if (e)
77
- return `${l[0]}; export default {${c.replace(",", "")}}`;
74
+ if (Object.values(e).length)
75
+ return `${d.join(";")};export default {${Object.keys(e).filter((g) => !i.includes(g)).map((g) => N(g)).join(",")}${p}}`;
76
+ if (t)
77
+ return `${d[0]}; export default {${p.replace(",", "")}}`;
78
78
  throw new Error(
79
79
  `Currently, no Storyblok components are registered in astro.config.mjs.
80
80
  Please register your components or enable the fallback component.
@@ -84,76 +84,76 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
84
84
  }
85
85
  };
86
86
  }
87
- function N(r, t, e) {
88
- const o = "virtual:storyblok-init", s = `\0${o}`;
87
+ function ie(r, e, t) {
88
+ const o = "virtual:storyblok-init", n = `\0${o}`;
89
89
  return {
90
90
  name: "vite-plugin-storyblok-init",
91
- async resolveId(n) {
92
- if (n === o)
93
- return s;
91
+ async resolveId(s) {
92
+ if (s === o)
93
+ return n;
94
94
  },
95
- async load(n) {
96
- if (n === s)
95
+ async load(s) {
96
+ if (s === n)
97
97
  return `
98
98
  import { storyblokInit, apiPlugin } from "@storyblok/js";
99
99
  const { storyblokApi } = storyblokInit({
100
100
  accessToken: "${r}",
101
- use: ${t ? "[]" : "[apiPlugin]"},
102
- apiOptions: ${JSON.stringify(e)},
101
+ use: ${e ? "[]" : "[apiPlugin]"},
102
+ apiOptions: ${JSON.stringify(t)},
103
103
  });
104
104
  export const storyblokApiInstance = storyblokApi;
105
105
  `;
106
106
  }
107
107
  };
108
108
  }
109
- function z(r) {
110
- const t = "virtual:storyblok-options", e = `\0${t}`;
109
+ function ce(r) {
110
+ const e = "virtual:storyblok-options", t = `\0${e}`;
111
111
  return {
112
112
  name: "vite-plugin-storyblok-options",
113
113
  async resolveId(o) {
114
- if (o === t)
115
- return e;
114
+ if (o === e)
115
+ return t;
116
116
  },
117
117
  async load(o) {
118
- if (o === e)
118
+ if (o === t)
119
119
  return `export default ${JSON.stringify(r)}`;
120
120
  }
121
121
  };
122
122
  }
123
- let C = !1;
124
- const I = [], B = (r) => new Promise((t, e) => {
125
- if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
123
+ let P = !1;
124
+ const B = [], ue = (r) => new Promise((e, t) => {
125
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
126
126
  if (window.location === window.parent.location) {
127
127
  console.warn("You are not in Draft Mode or in the Visual Editor.");
128
128
  return;
129
129
  }
130
- C ? s() : I.push(s);
130
+ P ? n() : B.push(n);
131
131
  }, document.getElementById("storyblok-javascript-bridge")))
132
132
  return;
133
133
  const o = document.createElement("script");
134
- o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (s) => e(s), o.onload = (s) => {
135
- I.forEach((n) => n()), C = !0, t(s);
134
+ o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (n) => t(n), o.onload = (n) => {
135
+ B.forEach((s) => s()), P = !0, e(n);
136
136
  }, document.getElementsByTagName("head")[0].appendChild(o);
137
137
  });
138
- var D = Object.defineProperty, F = (r, t, e) => t in r ? D(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, g = (r, t, e) => F(r, typeof t != "symbol" ? t + "" : t, e);
139
- class U {
138
+ var de = Object.defineProperty, pe = (r, e, t) => e in r ? de(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, v = (r, e, t) => pe(r, typeof e != "symbol" ? e + "" : e, t);
139
+ class ge {
140
140
  constructor() {
141
- g(this, "isCDNUrl", (t = "") => t.includes("/cdn/")), g(this, "getOptionsPage", (t, e = 25, o = 1) => ({
142
- ...t,
143
- per_page: e,
141
+ v(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), v(this, "getOptionsPage", (e, t = 25, o = 1) => ({
142
+ ...e,
143
+ per_page: t,
144
144
  page: o
145
- })), g(this, "delay", (t) => new Promise((e) => setTimeout(e, t))), g(this, "arrayFrom", (t = 0, e) => Array.from({ length: t }, e)), g(this, "range", (t = 0, e = t) => {
146
- const o = Math.abs(e - t) || 0, s = t < e ? 1 : -1;
147
- return this.arrayFrom(o, (n, a) => a * s + t);
148
- }), g(this, "asyncMap", async (t, e) => Promise.all(t.map(e))), g(this, "flatMap", (t = [], e) => t.map(e).reduce((o, s) => [...o, ...s], [])), g(this, "escapeHTML", function(t) {
149
- const e = {
145
+ })), v(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), v(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), v(this, "range", (e = 0, t = e) => {
146
+ const o = Math.abs(t - e) || 0, n = e < t ? 1 : -1;
147
+ return this.arrayFrom(o, (s, l) => l * n + e);
148
+ }), v(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), v(this, "flatMap", (e = [], t) => e.map(t).reduce((o, n) => [...o, ...n], [])), v(this, "escapeHTML", function(e) {
149
+ const t = {
150
150
  "&": "&amp;",
151
151
  "<": "&lt;",
152
152
  ">": "&gt;",
153
153
  '"': "&quot;",
154
154
  "'": "&#39;"
155
- }, o = /[&<>"']/g, s = new RegExp(o.source);
156
- return t && s.test(t) ? t.replace(o, (n) => e[n]) : t;
155
+ }, o = /[&<>"']/g, n = new RegExp(o.source);
156
+ return e && n.test(e) ? e.replace(o, (s) => t[s]) : e;
157
157
  });
158
158
  }
159
159
  /**
@@ -163,56 +163,56 @@ class U {
163
163
  * @param {boolean} isArray
164
164
  * @return {string} Stringified object
165
165
  */
166
- stringify(t, e, o) {
167
- const s = [];
168
- for (const n in t) {
169
- if (!Object.prototype.hasOwnProperty.call(t, n))
166
+ stringify(e, t, o) {
167
+ const n = [];
168
+ for (const s in e) {
169
+ if (!Object.prototype.hasOwnProperty.call(e, s))
170
170
  continue;
171
- const a = t[n], l = o ? "" : encodeURIComponent(n);
171
+ const l = e[s], d = o ? "" : encodeURIComponent(s);
172
172
  let i;
173
- typeof a == "object" ? i = this.stringify(
174
- a,
175
- e ? e + encodeURIComponent(`[${l}]`) : l,
176
- Array.isArray(a)
177
- ) : i = `${e ? e + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(a)}`, s.push(i);
173
+ typeof l == "object" ? i = this.stringify(
174
+ l,
175
+ t ? t + encodeURIComponent(`[${d}]`) : d,
176
+ Array.isArray(l)
177
+ ) : i = `${t ? t + encodeURIComponent(`[${d}]`) : d}=${encodeURIComponent(l)}`, n.push(i);
178
178
  }
179
- return s.join("&");
179
+ return n.join("&");
180
180
  }
181
181
  /**
182
182
  * @method getRegionURL
183
183
  * @param {string} regionCode region code, could be eu, us, cn, ap or ca
184
184
  * @return {string} The base URL of the region
185
185
  */
186
- getRegionURL(t) {
187
- const e = "api.storyblok.com", o = "api-us.storyblok.com", s = "app.storyblokchina.cn", n = "api-ap.storyblok.com", a = "api-ca.storyblok.com";
188
- switch (t) {
186
+ getRegionURL(e) {
187
+ const t = "api.storyblok.com", o = "api-us.storyblok.com", n = "app.storyblokchina.cn", s = "api-ap.storyblok.com", l = "api-ca.storyblok.com";
188
+ switch (e) {
189
189
  case "us":
190
190
  return o;
191
191
  case "cn":
192
- return s;
193
- case "ap":
194
192
  return n;
193
+ case "ap":
194
+ return s;
195
195
  case "ca":
196
- return a;
196
+ return l;
197
197
  default:
198
- return e;
198
+ return t;
199
199
  }
200
200
  }
201
201
  }
202
- const q = function(r, t) {
203
- const e = {};
202
+ const he = function(r, e) {
203
+ const t = {};
204
204
  for (const o in r) {
205
- const s = r[o];
206
- t.includes(o) && s !== null && (e[o] = s);
205
+ const n = r[o];
206
+ e.includes(o) && n !== null && (t[o] = n);
207
207
  }
208
- return e;
209
- }, H = (r) => r === "email", J = () => ({
208
+ return t;
209
+ }, fe = (r) => r === "email", be = () => ({
210
210
  singleTag: "hr"
211
- }), W = () => ({
211
+ }), ye = () => ({
212
212
  tag: "blockquote"
213
- }), K = () => ({
213
+ }), me = () => ({
214
214
  tag: "ul"
215
- }), V = (r) => ({
215
+ }), ke = (r) => ({
216
216
  tag: [
217
217
  "pre",
218
218
  {
@@ -220,24 +220,24 @@ const q = function(r, t) {
220
220
  attrs: r.attrs
221
221
  }
222
222
  ]
223
- }), Z = () => ({
223
+ }), $e = () => ({
224
224
  singleTag: "br"
225
- }), G = (r) => ({
225
+ }), we = (r) => ({
226
226
  tag: `h${r.attrs.level}`
227
- }), Y = (r) => ({
227
+ }), Te = (r) => ({
228
228
  singleTag: [
229
229
  {
230
230
  tag: "img",
231
- attrs: q(r.attrs, ["src", "alt", "title"])
231
+ attrs: he(r.attrs, ["src", "alt", "title"])
232
232
  }
233
233
  ]
234
- }), Q = () => ({
234
+ }), Ee = () => ({
235
235
  tag: "li"
236
- }), X = () => ({
236
+ }), Ce = () => ({
237
237
  tag: "ol"
238
- }), ee = () => ({
238
+ }), ve = () => ({
239
239
  tag: "p"
240
- }), te = (r) => ({
240
+ }), Ie = (r) => ({
241
241
  tag: [
242
242
  {
243
243
  tag: "span",
@@ -248,58 +248,58 @@ const q = function(r, t) {
248
248
  }
249
249
  }
250
250
  ]
251
- }), re = () => ({
251
+ }), Se = () => ({
252
252
  tag: "b"
253
- }), oe = () => ({
253
+ }), Le = () => ({
254
254
  tag: "s"
255
- }), se = () => ({
255
+ }), Ae = () => ({
256
256
  tag: "u"
257
- }), ne = () => ({
257
+ }), Re = () => ({
258
258
  tag: "strong"
259
- }), ae = () => ({
259
+ }), xe = () => ({
260
260
  tag: "code"
261
- }), le = () => ({
261
+ }), je = () => ({
262
262
  tag: "i"
263
- }), ie = (r) => {
263
+ }), Oe = (r) => {
264
264
  if (!r.attrs)
265
265
  return {
266
266
  tag: ""
267
267
  };
268
- const t = new U().escapeHTML, e = { ...r.attrs }, { linktype: o = "url" } = r.attrs;
269
- if (delete e.linktype, e.href && (e.href = t(r.attrs.href || "")), H(o) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
270
- for (const s in e.custom)
271
- e[s] = e.custom[s];
272
- delete e.custom;
268
+ const e = new ge().escapeHTML, t = { ...r.attrs }, { linktype: o = "url" } = r.attrs;
269
+ if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), fe(o) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
270
+ for (const n in t.custom)
271
+ t[n] = t.custom[n];
272
+ delete t.custom;
273
273
  }
274
274
  return {
275
275
  tag: [
276
276
  {
277
277
  tag: "a",
278
- attrs: e
278
+ attrs: t
279
279
  }
280
280
  ]
281
281
  };
282
- }, ce = (r) => ({
282
+ }, _e = (r) => ({
283
283
  tag: [
284
284
  {
285
285
  tag: "span",
286
286
  attrs: r.attrs
287
287
  }
288
288
  ]
289
- }), ue = () => ({
289
+ }), Me = () => ({
290
290
  tag: "sub"
291
- }), de = () => ({
291
+ }), Ne = () => ({
292
292
  tag: "sup"
293
- }), ge = (r) => ({
293
+ }), Pe = (r) => ({
294
294
  tag: [
295
295
  {
296
296
  tag: "span",
297
297
  attrs: r.attrs
298
298
  }
299
299
  ]
300
- }), pe = (r) => {
301
- var t;
302
- return (t = r.attrs) != null && t.color ? {
300
+ }), Be = (r) => {
301
+ var e;
302
+ return (e = r.attrs) != null && e.color ? {
303
303
  tag: [
304
304
  {
305
305
  tag: "span",
@@ -311,9 +311,9 @@ const q = function(r, t) {
311
311
  } : {
312
312
  tag: ""
313
313
  };
314
- }, fe = (r) => {
315
- var t;
316
- return (t = r.attrs) != null && t.color ? {
314
+ }, De = (r) => {
315
+ var e;
316
+ return (e = r.attrs) != null && e.color ? {
317
317
  tag: [
318
318
  {
319
319
  tag: "span",
@@ -325,64 +325,64 @@ const q = function(r, t) {
325
325
  } : {
326
326
  tag: ""
327
327
  };
328
- }, he = {
328
+ }, Ue = {
329
329
  nodes: {
330
- horizontal_rule: J,
331
- blockquote: W,
332
- bullet_list: K,
333
- code_block: V,
334
- hard_break: Z,
335
- heading: G,
336
- image: Y,
337
- list_item: Q,
338
- ordered_list: X,
339
- paragraph: ee,
340
- emoji: te
330
+ horizontal_rule: be,
331
+ blockquote: ye,
332
+ bullet_list: me,
333
+ code_block: ke,
334
+ hard_break: $e,
335
+ heading: we,
336
+ image: Te,
337
+ list_item: Ee,
338
+ ordered_list: Ce,
339
+ paragraph: ve,
340
+ emoji: Ie
341
341
  },
342
342
  marks: {
343
- bold: re,
344
- strike: oe,
345
- underline: se,
346
- strong: ne,
347
- code: ae,
348
- italic: le,
349
- link: ie,
350
- styled: ce,
351
- subscript: ue,
352
- superscript: de,
353
- anchor: ge,
354
- highlight: pe,
355
- textStyle: fe
343
+ bold: Se,
344
+ strike: Le,
345
+ underline: Ae,
346
+ strong: Re,
347
+ code: xe,
348
+ italic: je,
349
+ link: Oe,
350
+ styled: _e,
351
+ subscript: Me,
352
+ superscript: Ne,
353
+ anchor: Pe,
354
+ highlight: Be,
355
+ textStyle: De
356
356
  }
357
- }, ye = function(r) {
358
- const t = {
357
+ }, ze = function(r) {
358
+ const e = {
359
359
  "&": "&amp;",
360
360
  "<": "&lt;",
361
361
  ">": "&gt;",
362
362
  '"': "&quot;",
363
363
  "'": "&#39;"
364
- }, e = /[&<>"']/g, o = new RegExp(e.source);
365
- return r && o.test(r) ? r.replace(e, (s) => t[s]) : r;
364
+ }, t = /[&<>"']/g, o = new RegExp(t.source);
365
+ return r && o.test(r) ? r.replace(t, (n) => e[n]) : r;
366
366
  };
367
- let S = !1;
368
- class be {
369
- constructor(t) {
370
- g(this, "marks"), g(this, "nodes"), t || (t = he), this.marks = t.marks || [], this.nodes = t.nodes || [];
367
+ let D = !1;
368
+ class He {
369
+ constructor(e) {
370
+ v(this, "marks"), v(this, "nodes"), e || (e = Ue), this.marks = e.marks || [], this.nodes = e.nodes || [];
371
371
  }
372
- addNode(t, e) {
373
- this.nodes[t] = e;
372
+ addNode(e, t) {
373
+ this.nodes[e] = t;
374
374
  }
375
- addMark(t, e) {
376
- this.marks[t] = e;
375
+ addMark(e, t) {
376
+ this.marks[e] = t;
377
377
  }
378
- render(t, e = { optimizeImages: !1 }, o = !0) {
379
- if (!S && o && (console.warn(
378
+ render(e, t = { optimizeImages: !1 }, o = !0) {
379
+ if (!D && o && (console.warn(
380
380
  "Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
381
- ), S = !0), t && t.content && Array.isArray(t.content)) {
382
- let s = "";
383
- return t.content.forEach((n) => {
384
- s += this.renderNode(n);
385
- }), e.optimizeImages ? this.optimizeImages(s, e.optimizeImages) : s;
381
+ ), D = !0), e && e.content && Array.isArray(e.content)) {
382
+ let n = "";
383
+ return e.content.forEach((s) => {
384
+ n += this.renderNode(s);
385
+ }), t.optimizeImages ? this.optimizeImages(n, t.optimizeImages) : n;
386
386
  }
387
387
  return console.warn(
388
388
  `The render method must receive an Object with a "content" field.
@@ -411,197 +411,427 @@ class be {
411
411
  }`
412
412
  ), "";
413
413
  }
414
- optimizeImages(t, e) {
415
- let o = 0, s = 0, n = "", a = "";
416
- typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (n += `width="${e.width}" `, o = e.width), typeof e.height == "number" && e.height > 0 && (n += `height="${e.height}" `, s = e.height), (e.loading === "lazy" || e.loading === "eager") && (n += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (n += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (a += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (a += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-F]{6}/gi) || e.filters.fill === "transparent") && (a += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (a += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (a += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (a += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (a += `:rotate(${e.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), n.length > 0 && (t = t.replace(/<img/g, `<img ${n.trim()}`));
417
- const l = o > 0 || s > 0 || a.length > 0 ? `${o}x${s}${a}` : "";
418
- return t = t.replace(
414
+ optimizeImages(e, t) {
415
+ let o = 0, n = 0, s = "", l = "";
416
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (s += `width="${t.width}" `, o = t.width), typeof t.height == "number" && t.height > 0 && (s += `height="${t.height}" `, n = t.height), (t.loading === "lazy" || t.loading === "eager") && (s += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (s += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (l += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (l += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (l += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (l += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (l += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (l += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (l += `:rotate(${t.filters.rotate})`), l.length > 0 && (l = `/filters${l}`))), s.length > 0 && (e = e.replace(/<img/g, `<img ${s.trim()}`));
417
+ const d = o > 0 || n > 0 || l.length > 0 ? `${o}x${n}${l}` : "";
418
+ return e = e.replace(
419
419
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
420
- `a.storyblok.com/f/$1/$2.$3/m/${l}`
421
- ), typeof e != "boolean" && (e.sizes || e.srcset) && (t = t.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
422
- var c, u;
423
- const p = i.match(
420
+ `a.storyblok.com/f/$1/$2.$3/m/${d}`
421
+ ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
422
+ var p, g;
423
+ const $ = i.match(
424
424
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
425
425
  );
426
- if (p && p.length > 0) {
427
- const f = {
428
- srcset: (c = e.srcset) == null ? void 0 : c.map((d) => {
429
- if (typeof d == "number")
430
- return `//${p}/m/${d}x0${a} ${d}w`;
431
- if (typeof d == "object" && d.length === 2) {
432
- let y = 0, m = 0;
433
- return typeof d[0] == "number" && (y = d[0]), typeof d[1] == "number" && (m = d[1]), `//${p}/m/${y}x${m}${a} ${y}w`;
426
+ if ($ && $.length > 0) {
427
+ const E = {
428
+ srcset: (p = t.srcset) == null ? void 0 : p.map((m) => {
429
+ if (typeof m == "number")
430
+ return `//${$}/m/${m}x0${l} ${m}w`;
431
+ if (typeof m == "object" && m.length === 2) {
432
+ let I = 0, S = 0;
433
+ return typeof m[0] == "number" && (I = m[0]), typeof m[1] == "number" && (S = m[1]), `//${$}/m/${I}x${S}${l} ${I}w`;
434
434
  }
435
435
  return "";
436
436
  }).join(", "),
437
- sizes: (u = e.sizes) == null ? void 0 : u.map((d) => d).join(", ")
437
+ sizes: (g = t.sizes) == null ? void 0 : g.map((m) => m).join(", ")
438
438
  };
439
- let h = "";
440
- return f.srcset && (h += `srcset="${f.srcset}" `), f.sizes && (h += `sizes="${f.sizes}" `), i.replace(/<img/g, `<img ${h.trim()}`);
439
+ let w = "";
440
+ return E.srcset && (w += `srcset="${E.srcset}" `), E.sizes && (w += `sizes="${E.sizes}" `), i.replace(/<img/g, `<img ${w.trim()}`);
441
441
  }
442
442
  return i;
443
- })), t;
443
+ })), e;
444
444
  }
445
- renderNode(t) {
446
- const e = [];
447
- t.marks && t.marks.forEach((s) => {
448
- const n = this.getMatchingMark(s);
449
- n && n.tag !== "" && e.push(this.renderOpeningTag(n.tag));
445
+ renderNode(e) {
446
+ const t = [];
447
+ e.marks && e.marks.forEach((n) => {
448
+ const s = this.getMatchingMark(n);
449
+ s && s.tag !== "" && t.push(this.renderOpeningTag(s.tag));
450
450
  });
451
- const o = this.getMatchingNode(t);
452
- return o && o.tag && e.push(this.renderOpeningTag(o.tag)), t.content ? t.content.forEach((s) => {
453
- e.push(this.renderNode(s));
454
- }) : t.text ? e.push(ye(t.text)) : o && o.singleTag ? e.push(this.renderTag(o.singleTag, " /")) : o && o.html ? e.push(o.html) : t.type === "emoji" && e.push(this.renderEmoji(t)), o && o.tag && e.push(this.renderClosingTag(o.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
455
- const n = this.getMatchingMark(s);
456
- n && n.tag !== "" && e.push(this.renderClosingTag(n.tag));
457
- }), e.join("");
451
+ const o = this.getMatchingNode(e);
452
+ return o && o.tag && t.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((n) => {
453
+ t.push(this.renderNode(n));
454
+ }) : e.text ? t.push(ze(e.text)) : o && o.singleTag ? t.push(this.renderTag(o.singleTag, " /")) : o && o.html ? t.push(o.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), o && o.tag && t.push(this.renderClosingTag(o.tag)), e.marks && e.marks.slice(0).reverse().forEach((n) => {
455
+ const s = this.getMatchingMark(n);
456
+ s && s.tag !== "" && t.push(this.renderClosingTag(s.tag));
457
+ }), t.join("");
458
458
  }
459
- renderTag(t, e) {
460
- return t.constructor === String ? `<${t}${e}>` : t.map((o) => {
459
+ renderTag(e, t) {
460
+ return e.constructor === String ? `<${e}${t}>` : e.map((o) => {
461
461
  if (o.constructor === String)
462
- return `<${o}${e}>`;
462
+ return `<${o}${t}>`;
463
463
  {
464
- let s = `<${o.tag}`;
464
+ let n = `<${o.tag}`;
465
465
  if (o.attrs) {
466
- for (const n in o.attrs)
467
- if (Object.prototype.hasOwnProperty.call(o.attrs, n)) {
468
- const a = o.attrs[n];
469
- a !== null && (s += ` ${n}="${a}"`);
466
+ for (const s in o.attrs)
467
+ if (Object.prototype.hasOwnProperty.call(o.attrs, s)) {
468
+ const l = o.attrs[s];
469
+ l !== null && (n += ` ${s}="${l}"`);
470
470
  }
471
471
  }
472
- return `${s}${e}>`;
472
+ return `${n}${t}>`;
473
473
  }
474
474
  }).join("");
475
475
  }
476
- renderOpeningTag(t) {
477
- return this.renderTag(t, "");
476
+ renderOpeningTag(e) {
477
+ return this.renderTag(e, "");
478
478
  }
479
- renderClosingTag(t) {
480
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
479
+ renderClosingTag(e) {
480
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
481
481
  }
482
- getMatchingNode(t) {
483
- const e = this.nodes[t.type];
484
- if (typeof e == "function")
485
- return e(t);
482
+ getMatchingNode(e) {
483
+ const t = this.nodes[e.type];
484
+ if (typeof t == "function")
485
+ return t(e);
486
486
  }
487
- getMatchingMark(t) {
488
- const e = this.marks[t.type];
489
- if (typeof e == "function")
490
- return e(t);
487
+ getMatchingMark(e) {
488
+ const t = this.marks[e.type];
489
+ if (typeof t == "function")
490
+ return t(e);
491
491
  }
492
- renderEmoji(t) {
493
- if (t.attrs.emoji)
494
- return t.attrs.emoji;
495
- const e = [
492
+ renderEmoji(e) {
493
+ if (e.attrs.emoji)
494
+ return e.attrs.emoji;
495
+ const t = [
496
496
  {
497
497
  tag: "img",
498
498
  attrs: {
499
- src: t.attrs.fallbackImage,
499
+ src: e.attrs.fallbackImage,
500
500
  draggable: "false",
501
501
  loading: "lazy",
502
502
  align: "absmiddle"
503
503
  }
504
504
  }
505
505
  ];
506
- return this.renderTag(e, " /");
506
+ return this.renderTag(t, " /");
507
507
  }
508
508
  }
509
- const xe = (r) => {
509
+ const rt = (r) => {
510
510
  if (typeof r != "object" || typeof r._editable > "u")
511
511
  return {};
512
512
  try {
513
- const t = JSON.parse(
513
+ const e = JSON.parse(
514
514
  r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
515
515
  );
516
- return t ? {
517
- "data-blok-c": JSON.stringify(t),
518
- "data-blok-uid": `${t.id}-${t.uid}`
516
+ return e ? {
517
+ "data-blok-c": JSON.stringify(e),
518
+ "data-blok-uid": `${e.id}-${e.uid}`
519
519
  } : {};
520
520
  } catch {
521
521
  return {};
522
522
  }
523
523
  };
524
- let me, ke = "https://app.storyblok.com/f/storyblok-v2-latest.js";
525
- const we = (r, t) => {
526
- r.addNode("blok", (e) => {
524
+ function Fe(r, e) {
525
+ if (!e)
526
+ return { src: r, attrs: {} };
527
+ let t = 0, o = 0;
528
+ const n = {}, s = [];
529
+ function l(i, p, g, $, E) {
530
+ typeof i != "number" || i <= p || i >= g ? console.warn(`[StoryblokRichText] - ${$.charAt(0).toUpperCase() + $.slice(1)} value must be a number between ${p} and ${g} (inclusive)`) : E.push(`${$}(${i})`);
531
+ }
532
+ if (typeof e == "object") {
533
+ if (typeof e.width == "number" && e.width > 0 ? (n.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (n.height = e.height, o = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (n.loading = e.loading), e.class && (n.class = e.class), e.filters) {
534
+ const { filters: i } = e || {}, { blur: p, brightness: g, fill: $, format: E, grayscale: w, quality: m, rotate: I } = i || {};
535
+ p && l(p, 0, 100, "blur", s), m && l(m, 0, 100, "quality", s), g && l(g, 0, 100, "brightness", s), $ && s.push(`fill(${$})`), w && s.push("grayscale()"), I && [0, 90, 180, 270].includes(e.filters.rotate || 0) && s.push(`rotate(${I})`), E && ["webp", "png", "jpeg"].includes(E) && s.push(`format(${E})`);
536
+ }
537
+ e.srcset && (n.srcset = e.srcset.map((i) => {
538
+ if (typeof i == "number")
539
+ return `${r}/m/${i}x0/${s.length > 0 ? `filters:${s.join(":")}` : ""} ${i}w`;
540
+ if (Array.isArray(i) && i.length === 2) {
541
+ const [p, g] = i;
542
+ return `${r}/m/${p}x${g}/${s.length > 0 ? `filters:${s.join(":")}` : ""} ${p}w`;
543
+ } else {
544
+ console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
545
+ return;
546
+ }
547
+ }).join(", ")), e.sizes && (n.sizes = e.sizes.join(", "));
548
+ }
549
+ let d = `${r}/m/`;
550
+ return t > 0 && o > 0 && (d = `${d}${t}x${o}/`), s.length > 0 && (d = `${d}filters:${s.join(":")}`), {
551
+ src: d,
552
+ attrs: n
553
+ };
554
+ }
555
+ var y = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r.TABLE = "table", r.TABLE_ROW = "tableRow", r.TABLE_CELL = "tableCell", r.TABLE_HEADER = "tableHeader", r))(y || {}), C = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(C || {}), F = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(F || {}), L = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(L || {});
556
+ const qe = [
557
+ "area",
558
+ "base",
559
+ "br",
560
+ "col",
561
+ "embed",
562
+ "hr",
563
+ "img",
564
+ "input",
565
+ "link",
566
+ "meta",
567
+ "param",
568
+ "source",
569
+ "track",
570
+ "wbr"
571
+ ], Ge = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), Ke = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
572
+ function Je(r) {
573
+ return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
574
+ }
575
+ const R = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
576
+ function U(r, e = {}, t) {
577
+ const o = Ge(e), n = o ? `${r} ${o}` : r, s = Array.isArray(t) ? t.join("") : t || "";
578
+ if (r) {
579
+ if (qe.includes(r))
580
+ return `<${n}>`;
581
+ } else return s;
582
+ return `<${n}>${s}</${r}>`;
583
+ }
584
+ function ot(r = {}) {
585
+ let e = 0;
586
+ const {
587
+ renderFn: t = U,
588
+ textFn: o = Je,
589
+ resolvers: n = {},
590
+ optimizeImages: s = !1,
591
+ keyedResolvers: l = !1
592
+ } = r, d = t !== U, i = (a) => (c) => {
593
+ const u = c.attrs || {};
594
+ return l && (u.key = `${a}-${e}`), t(a, u, c.children || null);
595
+ }, p = (a) => {
596
+ const { src: c, alt: u, title: f, srcset: T, sizes: b } = a.attrs || {};
597
+ let h = c, k = {};
598
+ if (s) {
599
+ const { src: X, attrs: Z } = Fe(c, s);
600
+ h = X, k = Z;
601
+ }
602
+ l && (k = {
603
+ ...k,
604
+ key: `img-${e}`
605
+ });
606
+ const V = {
607
+ src: h,
608
+ alt: u,
609
+ title: f,
610
+ srcset: T,
611
+ sizes: b,
612
+ ...k
613
+ };
614
+ return t("img", R(V));
615
+ }, g = (a) => {
616
+ const { level: c, ...u } = a.attrs || {}, f = {
617
+ ...u
618
+ };
619
+ return l && (f.key = `h${c}-${e}`), t(`h${c}`, f, a.children);
620
+ }, $ = (a) => {
621
+ var c, u, f, T;
622
+ const b = t("img", {
623
+ src: (c = a.attrs) == null ? void 0 : c.fallbackImage,
624
+ alt: (u = a.attrs) == null ? void 0 : u.alt,
625
+ style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
626
+ draggable: "false",
627
+ loading: "lazy"
628
+ }), h = {
629
+ "data-type": "emoji",
630
+ "data-name": (f = a.attrs) == null ? void 0 : f.name,
631
+ "data-emoji": (T = a.attrs) == null ? void 0 : T.emoji
632
+ };
633
+ return l && (h.key = `emoji-${e}`), t("span", h, b);
634
+ }, E = (a) => t("pre", {
635
+ ...a.attrs,
636
+ key: `code-${e}`
637
+ }, t("code", { key: `code-${e}` }, a.children || "")), w = (a, c = !1) => ({ text: u, attrs: f }) => {
638
+ const { class: T, id: b, ...h } = f || {}, k = c ? {
639
+ class: T,
640
+ id: b,
641
+ style: Ke(h) || void 0
642
+ } : f || {};
643
+ return l && (k.key = `${a}-${e}`), t(a, R(k), u);
644
+ }, m = (a) => x(a), I = (a) => {
645
+ const { marks: c, ...u } = a;
646
+ return "text" in a ? c ? c.reduce(
647
+ (f, T) => m({ ...T, text: f }),
648
+ // Fix: Ensure render function returns a string
649
+ m({ ...u, children: u.children })
650
+ // Fix: Cast children to string
651
+ ) : o(u.text) : "";
652
+ }, S = (a) => {
653
+ const { linktype: c, href: u, anchor: f, ...T } = a.attrs || {};
654
+ let b = "";
655
+ switch (c) {
656
+ case L.ASSET:
657
+ case L.URL:
658
+ b = u;
659
+ break;
660
+ case L.EMAIL:
661
+ b = `mailto:${u}`;
662
+ break;
663
+ case L.STORY:
664
+ b = u, f && (b = `${b}#${f}`);
665
+ break;
666
+ default:
667
+ b = u;
668
+ break;
669
+ }
670
+ const h = { ...T };
671
+ return b && (h.href = b), l && (h.key = `a-${e}`), t("a", h, a.text);
672
+ }, q = (a) => {
673
+ var c, u;
674
+ return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
675
+ blok: (c = a == null ? void 0 : a.attrs) == null ? void 0 : c.body[0],
676
+ id: (u = a.attrs) == null ? void 0 : u.id,
677
+ key: `component-${e}`,
678
+ style: "display: none"
679
+ });
680
+ }, G = (a) => {
681
+ const c = {};
682
+ return l && (c.key = `table-${e}`), t("table", c, a.children);
683
+ }, K = (a) => {
684
+ const c = {};
685
+ return l && (c.key = `tr-${e}`), t("tr", c, a.children);
686
+ }, J = (a) => {
687
+ const { colspan: c, rowspan: u, colwidth: f, backgroundColor: T, ...b } = a.attrs || {}, h = {
688
+ ...b
689
+ };
690
+ c > 1 && (h.colspan = c), u > 1 && (h.rowspan = u);
691
+ const k = [];
692
+ return f && k.push(`width: ${f}px;`), T && k.push(`background-color: ${T};`), k.length > 0 && (h.style = k.join(" ")), l && (h.key = `td-${e}`), t("td", R(h), a.children);
693
+ }, W = (a) => {
694
+ const { colspan: c, rowspan: u, colwidth: f, backgroundColor: T, ...b } = a.attrs || {}, h = {
695
+ ...b
696
+ };
697
+ c > 1 && (h.colspan = c), u > 1 && (h.rowspan = u);
698
+ const k = [];
699
+ return f && k.push(`width: ${f}px;`), T && k.push(`background-color: ${T};`), k.length > 0 && (h.style = k.join(" ")), l && (h.key = `th-${e}`), t("th", R(h), a.children);
700
+ }, Y = new Map([
701
+ [y.DOCUMENT, i("")],
702
+ [y.HEADING, g],
703
+ [y.PARAGRAPH, i("p")],
704
+ [y.UL_LIST, i("ul")],
705
+ [y.OL_LIST, i("ol")],
706
+ [y.LIST_ITEM, i("li")],
707
+ [y.IMAGE, p],
708
+ [y.EMOJI, $],
709
+ [y.CODE_BLOCK, E],
710
+ [y.HR, i("hr")],
711
+ [y.BR, i("br")],
712
+ [y.QUOTE, i("blockquote")],
713
+ [y.COMPONENT, q],
714
+ [F.TEXT, I],
715
+ [C.LINK, S],
716
+ [C.ANCHOR, S],
717
+ [C.STYLED, w("span", !0)],
718
+ [C.BOLD, w("strong")],
719
+ [C.TEXT_STYLE, w("span", !0)],
720
+ [C.ITALIC, w("em")],
721
+ [C.UNDERLINE, w("u")],
722
+ [C.STRIKE, w("s")],
723
+ [C.CODE, w("code")],
724
+ [C.SUPERSCRIPT, w("sup")],
725
+ [C.SUBSCRIPT, w("sub")],
726
+ [C.HIGHLIGHT, w("mark")],
727
+ [y.TABLE, G],
728
+ [y.TABLE_ROW, K],
729
+ [y.TABLE_CELL, J],
730
+ [y.TABLE_HEADER, W],
731
+ ...Object.entries(n).map(([a, c]) => [a, c])
732
+ ]);
733
+ function A(a) {
734
+ e += 1;
735
+ const c = Y.get(a.type);
736
+ if (!c)
737
+ return console.error("<Storyblok>", `No resolver found for node type ${a.type}`), "";
738
+ if (a.type === "text")
739
+ return c(a);
740
+ const u = a.content ? a.content.map(x) : void 0;
741
+ return c({
742
+ ...a,
743
+ children: u
744
+ // Fix: Update the type of 'children' to Node[]
745
+ });
746
+ }
747
+ function x(a) {
748
+ return a.type === "doc" ? d ? a.content.map(A) : a.content.map(A).join("") : Array.isArray(a) ? a.map(A) : A(a);
749
+ }
750
+ return {
751
+ render: x
752
+ };
753
+ }
754
+ let We, Ye = "https://app.storyblok.com/f/storyblok-v2-latest.js";
755
+ const Ve = (r, e) => {
756
+ r.addNode("blok", (t) => {
527
757
  let o = "";
528
- return e.attrs.body.forEach((s) => {
529
- o += t(s.component, s);
758
+ return t.attrs.body.forEach((n) => {
759
+ o += e(n.component, n);
530
760
  }), {
531
761
  html: o
532
762
  };
533
763
  });
534
- }, $e = (r) => {
535
- var t;
536
- return !r || !((t = r == null ? void 0 : r.content) != null && t.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule"));
537
- }, ve = (r, t, e) => {
538
- let o = e || me;
764
+ }, Xe = (r) => {
765
+ var e;
766
+ return !r || !((e = r == null ? void 0 : r.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
767
+ }, Ze = (r, e, t) => {
768
+ let o = t || We;
539
769
  if (!o) {
540
770
  console.error(
541
771
  "Please initialize the Storyblok SDK before calling the renderRichText function"
542
772
  );
543
773
  return;
544
774
  }
545
- return $e(r) ? "" : (t && (o = new be(t.schema), t.resolver && we(o, t.resolver)), o.render(r, {}, !1));
546
- }, Ae = () => B(ke);
547
- function Ee() {
775
+ return Xe(r) ? "" : (e && (o = new He(e.schema), e.resolver && Ve(o, e.resolver)), o.render(r, {}, !1));
776
+ }, st = () => ue(Ye);
777
+ function nt() {
548
778
  if (!(globalThis != null && globalThis.storyblokApiInstance))
549
779
  throw new Error("storyblokApiInstance has not been initialized correctly");
550
780
  return globalThis.storyblokApiInstance;
551
781
  }
552
- async function Le(r) {
553
- let t = null;
554
- return r && r.locals._storyblok_preview_data && (t = r.locals._storyblok_preview_data), t;
782
+ async function at(r) {
783
+ let e = null;
784
+ return r && r.locals._storyblok_preview_data && (e = r.locals._storyblok_preview_data), e;
555
785
  }
556
- function Te(r, t) {
786
+ function lt(r, e) {
557
787
  var o;
558
- const e = (o = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : o.richTextResolver;
559
- if (!e)
788
+ const t = (o = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : o.richTextResolver;
789
+ if (!t)
560
790
  throw new Error(
561
791
  "Please initialize the Storyblok SDK before calling the renderRichText function"
562
792
  );
563
- return ve(r, t, e);
793
+ return Ze(r, e, t);
564
794
  }
565
- function Ce(r) {
795
+ function Qe(r) {
566
796
  return typeof r == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(r)});` : "const storyblokInstance = new StoryblokBridge();";
567
797
  }
568
- function je(r) {
569
- const t = {
798
+ function it(r) {
799
+ const e = {
570
800
  useCustomApi: !1,
571
801
  bridge: !0,
572
802
  componentsDir: "src",
573
803
  enableFallbackComponent: !1,
574
804
  livePreview: !1,
575
805
  ...r
576
- }, e = Ce(t.bridge);
806
+ }, t = Qe(e.bridge);
577
807
  return {
578
808
  name: "@storyblok/astro",
579
809
  hooks: {
580
810
  "astro:config:setup": ({
581
811
  injectScript: o,
582
- updateConfig: s,
583
- addDevToolbarApp: n,
584
- addMiddleware: a,
585
- config: l
812
+ updateConfig: n,
813
+ addDevToolbarApp: s,
814
+ addMiddleware: l,
815
+ config: d
586
816
  }) => {
587
- if (s({
817
+ if (n({
588
818
  vite: {
589
819
  plugins: [
590
- N(
591
- t.accessToken,
592
- t.useCustomApi,
593
- t.apiOptions
820
+ ie(
821
+ e.accessToken,
822
+ e.useCustomApi,
823
+ e.apiOptions
594
824
  ),
595
- _(
596
- t.componentsDir,
597
- t.components,
598
- t.enableFallbackComponent,
599
- t.customFallbackComponent
825
+ le(
826
+ e.componentsDir,
827
+ e.components,
828
+ e.enableFallbackComponent,
829
+ e.customFallbackComponent
600
830
  ),
601
- z(t)
831
+ ce(e)
602
832
  ]
603
833
  }
604
- }), t.livePreview && (l == null ? void 0 : l.output) !== "server")
834
+ }), e.livePreview && (d == null ? void 0 : d.output) !== "server")
605
835
  throw new Error(
606
836
  "To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode."
607
837
  );
@@ -611,12 +841,12 @@ function je(r) {
611
841
  import { storyblokApiInstance } from "virtual:storyblok-init";
612
842
  globalThis.storyblokApiInstance = storyblokApiInstance;
613
843
  `
614
- ), t.bridge && !t.livePreview && o(
844
+ ), e.bridge && !e.livePreview && o(
615
845
  "page",
616
846
  `import { loadStoryblokBridge } from "@storyblok/astro";
617
847
  loadStoryblokBridge().then(() => {
618
848
  const { StoryblokBridge, location } = window;
619
- ${e}
849
+ ${t}
620
850
  storyblokInstance.on(["published", "change"], (event) => {
621
851
  if (!event.slugChanged) {
622
852
  location.reload(true);
@@ -624,54 +854,54 @@ function je(r) {
624
854
  });
625
855
  });
626
856
  `
627
- ), t.livePreview && (o(
857
+ ), e.livePreview && (o(
628
858
  "page",
629
859
  `import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
630
860
  loadStoryblokBridge().then(() => {
631
861
  const { StoryblokBridge, location } = window;
632
- ${e}
862
+ ${t}
633
863
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
634
864
  });
635
865
  `
636
- ), a({
866
+ ), l({
637
867
  entrypoint: "@storyblok/astro/middleware.ts",
638
868
  order: "pre"
639
- })), n({
869
+ })), s({
640
870
  id: "storyblok",
641
871
  name: "Storyblok",
642
- icon: E,
872
+ icon: Q,
643
873
  entrypoint: "@storyblok/astro/toolbarApp.ts"
644
874
  });
645
875
  }
646
876
  }
647
877
  };
648
878
  }
649
- let x;
650
- async function Re(r) {
651
- const { action: t, story: e } = r || {};
652
- if (t === "input" && e) {
879
+ let z;
880
+ async function ct(r) {
881
+ const { action: e, story: t } = r || {};
882
+ if (e === "input" && t) {
653
883
  const o = async () => {
654
- const n = await Se(e), a = document.body;
655
- if (n.outerHTML === a.outerHTML)
884
+ const s = await tt(t), l = document.body;
885
+ if (s.outerHTML === l.outerHTML)
656
886
  return;
657
- const l = document.querySelector('[data-blok-focused="true"]');
658
- Ie(a, n, l), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
887
+ const d = document.querySelector('[data-blok-focused="true"]');
888
+ et(l, s, d), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
659
889
  };
660
- clearTimeout(x), x = setTimeout(o, 500);
890
+ clearTimeout(z), z = setTimeout(o, 500);
661
891
  }
662
892
  ["published", "change"].includes(r == null ? void 0 : r.action) && location.reload();
663
893
  }
664
- function Ie(r, t, e) {
665
- if (e) {
666
- const o = e.getAttribute("data-blok-uid"), s = t.querySelector(
894
+ function et(r, e, t) {
895
+ if (t) {
896
+ const o = t.getAttribute("data-blok-uid"), n = e.querySelector(
667
897
  `[data-blok-uid="${o}"]`
668
898
  );
669
- s && (s.setAttribute("data-blok-focused", "true"), e.replaceWith(s));
899
+ n && (n.setAttribute("data-blok-focused", "true"), t.replaceWith(n));
670
900
  } else
671
- r.replaceWith(t);
901
+ r.replaceWith(e);
672
902
  }
673
- async function Se(r) {
674
- const e = await (await fetch(location.href, {
903
+ async function tt(r) {
904
+ const t = await (await fetch(location.href, {
675
905
  method: "POST",
676
906
  body: JSON.stringify({
677
907
  ...r,
@@ -681,17 +911,19 @@ async function Se(r) {
681
911
  "Content-Type": "application/json"
682
912
  }
683
913
  })).text();
684
- return new DOMParser().parseFromString(e, "text/html").body;
914
+ return new DOMParser().parseFromString(t, "text/html").body;
685
915
  }
686
916
  export {
687
- be as RichTextResolver,
688
- he as RichTextSchema,
689
- Le as getLiveStory,
690
- Re as handleStoryblokMessage,
691
- Ae as loadStoryblokBridge,
692
- Te as renderRichText,
693
- je as storyblok,
694
- xe as storyblokEditable,
695
- v as toCamelCase,
696
- Ee as useStoryblokApi
917
+ He as RichTextResolver,
918
+ Ue as RichTextSchema,
919
+ F as TextTypes,
920
+ at as getLiveStory,
921
+ ct as handleStoryblokMessage,
922
+ st as loadStoryblokBridge,
923
+ lt as renderRichText,
924
+ ot as richTextResolver,
925
+ it as storyblok,
926
+ rt as storyblokEditable,
927
+ N as toCamelCase,
928
+ nt as useStoryblokApi
697
929
  };