@storyblok/astro 5.1.0-alpha.4 → 5.1.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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -114
  3. package/{components → dist/components}/FallbackComponent.astro +1 -1
  4. package/dist/components/FallbackComponent.d.ts +6 -0
  5. package/{components → dist/components}/StoryblokComponent.astro +3 -3
  6. package/dist/components/StoryblokComponent.d.ts +6 -0
  7. package/dist/{types/dev-toolbar → dev-toolbar}/toolbarApp.d.ts +1 -1
  8. package/{dev-toolbar → dist/dev-toolbar}/toolbarApp.ts +143 -146
  9. package/dist/{types/index.d.ts → index.d.ts} +12 -17
  10. package/dist/{types/live-preview → live-preview}/handleStoryblokMessage.d.ts +1 -1
  11. package/dist/live-preview/middleware.d.ts +1 -0
  12. package/dist/live-preview/middleware.ts +25 -0
  13. package/dist/storyblok-astro.es.js +1324 -0
  14. package/dist/storyblok-astro.umd.js +69 -0
  15. package/dist/types.d.ts +12 -0
  16. package/dist/utils/generateFinalBridgeObject.d.ts +3 -0
  17. package/dist/utils/parseAstCode.d.ts +7 -0
  18. package/dist/utils/toCamelCase.d.ts +1 -0
  19. package/dist/vite-plugins/vite-plugin-storyblok-bridge.d.ts +12 -0
  20. package/dist/vite-plugins/vite-plugin-storyblok-components.d.ts +2 -0
  21. package/dist/vite-plugins/vite-plugin-storyblok-init.d.ts +3 -0
  22. package/dist/{types/vite-plugins → vite-plugins}/vite-plugin-storyblok-options.d.ts +1 -1
  23. package/package.json +123 -62
  24. package/components/FallbackComponent.ts +0 -2
  25. package/components/StoryblokComponent.ts +0 -2
  26. package/dist/storyblok-astro.js +0 -72
  27. package/dist/storyblok-astro.mjs +0 -1259
  28. package/dist/types/components/FallbackComponent.d.ts +0 -2
  29. package/dist/types/components/StoryblokComponent.d.ts +0 -2
  30. package/dist/types/content-layer/storyblokLoader.d.ts +0 -9
  31. package/dist/types/content-layer/syncContentUpdate.d.ts +0 -4
  32. package/dist/types/cypress/e2e/index.cy.d.ts +0 -0
  33. package/dist/types/cypress/plugins/index.d.ts +0 -2
  34. package/dist/types/cypress/support/commands.d.ts +0 -0
  35. package/dist/types/cypress/support/e2e.d.ts +0 -1
  36. package/dist/types/cypress.config.d.ts +0 -2
  37. package/dist/types/live-preview/middleware.d.ts +0 -1
  38. package/dist/types/node_modules/astro/dist/runtime/client/dev-toolbar/ui-library/icons.d.ts +0 -35
  39. package/dist/types/node_modules/astro/dist/toolbar/index.d.ts +0 -2
  40. package/dist/types/node_modules/camelcase/index.d.ts +0 -102
  41. package/dist/types/types.d.ts +0 -12
  42. package/dist/types/utils/initStoryblokBridge.d.ts +0 -2
  43. package/dist/types/vite-plugins/vite-plugin-storyblok-components.d.ts +0 -2
  44. package/dist/types/vite-plugins/vite-plugin-storyblok-init.d.ts +0 -3
  45. package/live-preview/handleStoryblokMessage.ts +0 -78
  46. package/live-preview/middleware.ts +0 -24
  47. package/utils/initStoryblokBridge.ts +0 -11
@@ -0,0 +1,1324 @@
1
+ function $r(o, t, r) {
2
+ const s = "virtual:storyblok-init", i = `\0${s}`;
3
+ return {
4
+ name: "vite-plugin-storyblok-init",
5
+ async resolveId(l) {
6
+ if (l === s)
7
+ return i;
8
+ },
9
+ async load(l) {
10
+ if (l === i)
11
+ return `
12
+ import { storyblokInit, apiPlugin } from "@storyblok/js";
13
+ const { storyblokApi } = storyblokInit({
14
+ accessToken: "${o}",
15
+ use: ${t ? "[]" : "[apiPlugin]"},
16
+ apiOptions: ${JSON.stringify(r)},
17
+ });
18
+ export const storyblokApiInstance = storyblokApi;
19
+ `;
20
+ }
21
+ };
22
+ }
23
+ const Or = /[\p{Lu}]/u, xr = /[\p{Ll}]/u, Me = /^[\p{Lu}](?![\p{Lu}])/gu, Je = /([\p{Alpha}\p{N}_]|$)/u, fe = /[_.\- ]+/, jr = new RegExp("^" + fe.source), Ne = new RegExp(fe.source + Je.source, "gu"), ze = new RegExp("\\d+" + Je.source, "gu"), Er = (o, t, r, s) => {
24
+ let i = !1, l = !1, u = !1, f = !1;
25
+ for (let g = 0; g < o.length; g++) {
26
+ const y = o[g];
27
+ f = g > 2 ? o[g - 3] === "-" : !0, i && Or.test(y) ? (o = o.slice(0, g) + "-" + o.slice(g), i = !1, u = l, l = !0, g++) : l && u && xr.test(y) && (!f || s) ? (o = o.slice(0, g - 1) + "-" + o.slice(g - 1), u = l, l = !1, i = !0) : (i = t(y) === y && r(y) !== y, u = l, l = r(y) === y && t(y) !== y);
28
+ }
29
+ return o;
30
+ }, Rr = (o, t) => (Me.lastIndex = 0, o.replaceAll(Me, (r) => t(r))), Lr = (o, t) => (Ne.lastIndex = 0, ze.lastIndex = 0, o.replaceAll(ze, (r, s, i) => ["_", "-"].includes(o.charAt(i + r.length)) ? r : t(r)).replaceAll(Ne, (r, s) => t(s)));
31
+ function Pr(o, t) {
32
+ if (!(typeof o == "string" || Array.isArray(o)))
33
+ throw new TypeError("Expected the input to be `string | string[]`");
34
+ if (t = {
35
+ pascalCase: !1,
36
+ preserveConsecutiveUppercase: !1,
37
+ ...t
38
+ }, Array.isArray(o) ? o = o.map((l) => l.trim()).filter((l) => l.length).join("-") : o = o.trim(), o.length === 0)
39
+ return "";
40
+ const r = t.locale === !1 ? (l) => l.toLowerCase() : (l) => l.toLocaleLowerCase(t.locale), s = t.locale === !1 ? (l) => l.toUpperCase() : (l) => l.toLocaleUpperCase(t.locale);
41
+ return o.length === 1 ? fe.test(o) ? "" : t.pascalCase ? s(o) : r(o) : (o !== r(o) && (o = Er(o, r, s, t.preserveConsecutiveUppercase)), o = o.replace(jr, ""), o = t.preserveConsecutiveUppercase ? Rr(o, r) : r(o), t.pascalCase && (o = s(o.charAt(0)) + o.slice(1)), Lr(o, s));
42
+ }
43
+ function Fe(o) {
44
+ return Pr(o);
45
+ }
46
+ function Mr(o, t = {}, r, s) {
47
+ const i = "virtual:storyblok-components", l = `\0${i}`;
48
+ return {
49
+ name: "vite-plugin-storyblok-components",
50
+ async resolveId(u) {
51
+ if (u === i)
52
+ return l;
53
+ },
54
+ async load(u) {
55
+ if (u === l) {
56
+ const f = [], g = [];
57
+ for await (const [_, C] of Object.entries(t)) {
58
+ const T = await this.resolve(
59
+ `/${o}/${C}.astro`
60
+ );
61
+ if (T)
62
+ f.push(`import ${Fe(_)} from "${T.id}"`);
63
+ else if (r)
64
+ g.push(_);
65
+ else
66
+ throw new Error(
67
+ `Component could not be found for blok "${_}"! Does "${`/${o}/${C}`}.astro" exist?`
68
+ );
69
+ }
70
+ let y = "";
71
+ if (r)
72
+ if (y = ",FallbackComponent", s) {
73
+ const _ = await this.resolve(
74
+ `/${o}/${s}.astro`
75
+ );
76
+ if (!_)
77
+ throw new Error(
78
+ `Custom fallback component could not be found. Does "${`/${o}/${s}`}.astro" exist?`
79
+ );
80
+ f.push(
81
+ `import FallbackComponent from "${_.id}"`
82
+ );
83
+ } else
84
+ f.push(
85
+ "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
86
+ );
87
+ if (Object.values(t).length)
88
+ return `${f.join(";")};export default {${Object.keys(t).filter((_) => !g.includes(_)).map((_) => Fe(_)).join(",")}${y}}`;
89
+ if (r)
90
+ return `${f[0]}; export default {${y.replace(",", "")}}`;
91
+ throw new Error(
92
+ `Currently, no Storyblok components are registered in astro.config.mjs.
93
+ Please register your components or enable the fallback component.
94
+ Detailed information can be found here: https://github.com/storyblok/storyblok-astro`
95
+ );
96
+ }
97
+ }
98
+ };
99
+ }
100
+ function Nr(o) {
101
+ const t = "virtual:storyblok-options", r = `\0${t}`;
102
+ return {
103
+ name: "vite-plugin-storyblok-options",
104
+ async resolveId(s) {
105
+ if (s === t)
106
+ return r;
107
+ },
108
+ async load(s) {
109
+ if (s === r)
110
+ return `export default ${JSON.stringify(o)}`;
111
+ }
112
+ };
113
+ }
114
+ let De = !1;
115
+ const Be = [], zr = (o) => new Promise((t, r) => {
116
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (i) => {
117
+ if (window.location === window.parent.location) {
118
+ console.warn("You are not in Draft Mode or in the Visual Editor.");
119
+ return;
120
+ }
121
+ De ? i() : Be.push(i);
122
+ }, document.getElementById("storyblok-javascript-bridge"))) return;
123
+ const s = document.createElement("script");
124
+ s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (i) => r(i), s.onload = (i) => {
125
+ Be.forEach((l) => l()), De = !0, t(i);
126
+ }, document.getElementsByTagName("head")[0].appendChild(s);
127
+ });
128
+ var Fr = Object.defineProperty, Dr = (o, t, r) => t in o ? Fr(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r, S = (o, t, r) => Dr(o, typeof t != "symbol" ? t + "" : t, r);
129
+ let Br = class {
130
+ constructor() {
131
+ S(this, "isCDNUrl", (o = "") => o.includes("/cdn/")), S(this, "getOptionsPage", (o, t = 25, r = 1) => ({
132
+ ...o,
133
+ per_page: t,
134
+ page: r
135
+ })), S(this, "delay", (o) => new Promise((t) => setTimeout(t, o))), S(this, "arrayFrom", (o = 0, t) => Array.from({ length: o }, t)), S(this, "range", (o = 0, t = o) => {
136
+ const r = Math.abs(t - o) || 0, s = o < t ? 1 : -1;
137
+ return this.arrayFrom(r, (i, l) => l * s + o);
138
+ }), S(this, "asyncMap", async (o, t) => Promise.all(o.map(t))), S(this, "flatMap", (o = [], t) => o.map(t).reduce((r, s) => [...r, ...s], [])), S(this, "escapeHTML", function(o) {
139
+ const t = {
140
+ "&": "&amp;",
141
+ "<": "&lt;",
142
+ ">": "&gt;",
143
+ '"': "&quot;",
144
+ "'": "&#39;"
145
+ }, r = /[&<>"']/g, s = new RegExp(r.source);
146
+ return o && s.test(o) ? o.replace(r, (i) => t[i]) : o;
147
+ });
148
+ }
149
+ /**
150
+ * @method stringify
151
+ * @param {object} params
152
+ * @param {string} prefix
153
+ * @param {boolean} isArray
154
+ * @return {string} Stringified object
155
+ */
156
+ stringify(o, t, r) {
157
+ const s = [];
158
+ for (const i in o) {
159
+ if (!Object.prototype.hasOwnProperty.call(o, i))
160
+ continue;
161
+ const l = o[i], u = r ? "" : encodeURIComponent(i);
162
+ let f;
163
+ typeof l == "object" ? f = this.stringify(
164
+ l,
165
+ t ? t + encodeURIComponent(`[${u}]`) : u,
166
+ Array.isArray(l)
167
+ ) : f = `${t ? t + encodeURIComponent(`[${u}]`) : u}=${encodeURIComponent(l)}`, s.push(f);
168
+ }
169
+ return s.join("&");
170
+ }
171
+ /**
172
+ * @method getRegionURL
173
+ * @param {string} regionCode region code, could be eu, us, cn, ap or ca
174
+ * @return {string} The base URL of the region
175
+ */
176
+ getRegionURL(o) {
177
+ const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn", i = "api-ap.storyblok.com", l = "api-ca.storyblok.com";
178
+ switch (o) {
179
+ case "us":
180
+ return r;
181
+ case "cn":
182
+ return s;
183
+ case "ap":
184
+ return i;
185
+ case "ca":
186
+ return l;
187
+ default:
188
+ return t;
189
+ }
190
+ }
191
+ };
192
+ const Ur = function(o, t) {
193
+ const r = {};
194
+ for (const s in o) {
195
+ const i = o[s];
196
+ t.includes(s) && i !== null && (r[s] = i);
197
+ }
198
+ return r;
199
+ }, Hr = (o) => o === "email", qr = () => ({
200
+ singleTag: "hr"
201
+ }), Gr = () => ({
202
+ tag: "blockquote"
203
+ }), Jr = () => ({
204
+ tag: "ul"
205
+ }), Wr = (o) => ({
206
+ tag: [
207
+ "pre",
208
+ {
209
+ tag: "code",
210
+ attrs: o.attrs
211
+ }
212
+ ]
213
+ }), Kr = () => ({
214
+ singleTag: "br"
215
+ }), Zr = (o) => ({
216
+ tag: `h${o.attrs.level}`
217
+ }), Vr = (o) => ({
218
+ singleTag: [
219
+ {
220
+ tag: "img",
221
+ attrs: Ur(o.attrs, ["src", "alt", "title"])
222
+ }
223
+ ]
224
+ }), Xr = () => ({
225
+ tag: "li"
226
+ }), Yr = () => ({
227
+ tag: "ol"
228
+ }), Qr = () => ({
229
+ tag: "p"
230
+ }), en = (o) => ({
231
+ tag: [
232
+ {
233
+ tag: "span",
234
+ attrs: {
235
+ "data-type": "emoji",
236
+ "data-name": o.attrs.name,
237
+ emoji: o.attrs.emoji
238
+ }
239
+ }
240
+ ]
241
+ }), tn = () => ({
242
+ tag: "b"
243
+ }), rn = () => ({
244
+ tag: "s"
245
+ }), nn = () => ({
246
+ tag: "u"
247
+ }), on = () => ({
248
+ tag: "strong"
249
+ }), an = () => ({
250
+ tag: "code"
251
+ }), sn = () => ({
252
+ tag: "i"
253
+ }), ln = (o) => {
254
+ if (!o.attrs)
255
+ return {
256
+ tag: ""
257
+ };
258
+ const t = new Br().escapeHTML, r = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
259
+ if (delete r.linktype, r.href && (r.href = t(o.attrs.href || "")), Hr(s) && (r.href = `mailto:${r.href}`), r.anchor && (r.href = `${r.href}#${r.anchor}`, delete r.anchor), r.custom) {
260
+ for (const i in r.custom)
261
+ r[i] = r.custom[i];
262
+ delete r.custom;
263
+ }
264
+ return {
265
+ tag: [
266
+ {
267
+ tag: "a",
268
+ attrs: r
269
+ }
270
+ ]
271
+ };
272
+ }, cn = (o) => ({
273
+ tag: [
274
+ {
275
+ tag: "span",
276
+ attrs: o.attrs
277
+ }
278
+ ]
279
+ }), un = () => ({
280
+ tag: "sub"
281
+ }), fn = () => ({
282
+ tag: "sup"
283
+ }), dn = (o) => ({
284
+ tag: [
285
+ {
286
+ tag: "span",
287
+ attrs: o.attrs
288
+ }
289
+ ]
290
+ }), pn = (o) => {
291
+ var t;
292
+ return (t = o.attrs) != null && t.color ? {
293
+ tag: [
294
+ {
295
+ tag: "span",
296
+ attrs: {
297
+ style: `background-color:${o.attrs.color};`
298
+ }
299
+ }
300
+ ]
301
+ } : {
302
+ tag: ""
303
+ };
304
+ }, gn = (o) => {
305
+ var t;
306
+ return (t = o.attrs) != null && t.color ? {
307
+ tag: [
308
+ {
309
+ tag: "span",
310
+ attrs: {
311
+ style: `color:${o.attrs.color}`
312
+ }
313
+ }
314
+ ]
315
+ } : {
316
+ tag: ""
317
+ };
318
+ }, hn = {
319
+ nodes: {
320
+ horizontal_rule: qr,
321
+ blockquote: Gr,
322
+ bullet_list: Jr,
323
+ code_block: Wr,
324
+ hard_break: Kr,
325
+ heading: Zr,
326
+ image: Vr,
327
+ list_item: Xr,
328
+ ordered_list: Yr,
329
+ paragraph: Qr,
330
+ emoji: en
331
+ },
332
+ marks: {
333
+ bold: tn,
334
+ strike: rn,
335
+ underline: nn,
336
+ strong: on,
337
+ code: an,
338
+ italic: sn,
339
+ link: ln,
340
+ styled: cn,
341
+ subscript: un,
342
+ superscript: fn,
343
+ anchor: dn,
344
+ highlight: pn,
345
+ textStyle: gn
346
+ }
347
+ }, bn = function(o) {
348
+ const t = {
349
+ "&": "&amp;",
350
+ "<": "&lt;",
351
+ ">": "&gt;",
352
+ '"': "&quot;",
353
+ "'": "&#39;"
354
+ }, r = /[&<>"']/g, s = new RegExp(r.source);
355
+ return o && s.test(o) ? o.replace(r, (i) => t[i]) : o;
356
+ };
357
+ let Ue = !1;
358
+ class yn {
359
+ constructor(t) {
360
+ S(this, "marks"), S(this, "nodes"), t || (t = hn), this.marks = t.marks || [], this.nodes = t.nodes || [];
361
+ }
362
+ addNode(t, r) {
363
+ this.nodes[t] = r;
364
+ }
365
+ addMark(t, r) {
366
+ this.marks[t] = r;
367
+ }
368
+ render(t, r = { optimizeImages: !1 }, s = !0) {
369
+ if (!Ue && s && (console.warn(
370
+ "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/"
371
+ ), Ue = !0), t && t.content && Array.isArray(t.content)) {
372
+ let i = "";
373
+ return t.content.forEach((l) => {
374
+ i += this.renderNode(l);
375
+ }), r.optimizeImages ? this.optimizeImages(i, r.optimizeImages) : i;
376
+ }
377
+ return console.warn(
378
+ `The render method must receive an Object with a "content" field.
379
+ The "content" field must be an array of nodes as the type ISbRichtext.
380
+ ISbRichtext:
381
+ content?: ISbRichtext[]
382
+ marks?: ISbRichtext[]
383
+ attrs?: any
384
+ text?: string
385
+ type: string
386
+
387
+ Example:
388
+ {
389
+ content: [
390
+ {
391
+ content: [
392
+ {
393
+ text: 'Hello World',
394
+ type: 'text'
395
+ }
396
+ ],
397
+ type: 'paragraph'
398
+ }
399
+ ],
400
+ type: 'doc'
401
+ }`
402
+ ), "";
403
+ }
404
+ optimizeImages(t, r) {
405
+ let s = 0, i = 0, l = "", u = "";
406
+ typeof r != "boolean" && (typeof r.width == "number" && r.width > 0 && (l += `width="${r.width}" `, s = r.width), typeof r.height == "number" && r.height > 0 && (l += `height="${r.height}" `, i = r.height), (r.loading === "lazy" || r.loading === "eager") && (l += `loading="${r.loading}" `), typeof r.class == "string" && r.class.length > 0 && (l += `class="${r.class}" `), r.filters && (typeof r.filters.blur == "number" && r.filters.blur >= 0 && r.filters.blur <= 100 && (u += `:blur(${r.filters.blur})`), typeof r.filters.brightness == "number" && r.filters.brightness >= -100 && r.filters.brightness <= 100 && (u += `:brightness(${r.filters.brightness})`), r.filters.fill && (r.filters.fill.match(/[0-9A-F]{6}/gi) || r.filters.fill === "transparent") && (u += `:fill(${r.filters.fill})`), r.filters.format && ["webp", "png", "jpeg"].includes(r.filters.format) && (u += `:format(${r.filters.format})`), typeof r.filters.grayscale == "boolean" && r.filters.grayscale && (u += ":grayscale()"), typeof r.filters.quality == "number" && r.filters.quality >= 0 && r.filters.quality <= 100 && (u += `:quality(${r.filters.quality})`), r.filters.rotate && [90, 180, 270].includes(r.filters.rotate) && (u += `:rotate(${r.filters.rotate})`), u.length > 0 && (u = `/filters${u}`))), l.length > 0 && (t = t.replace(/<img/g, `<img ${l.trim()}`));
407
+ const f = s > 0 || i > 0 || u.length > 0 ? `${s}x${i}${u}` : "";
408
+ return t = t.replace(
409
+ /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
410
+ `a.storyblok.com/f/$1/$2.$3/m/${f}`
411
+ ), typeof r != "boolean" && (r.sizes || r.srcset) && (t = t.replace(/<img.*?src=["|'](.*?)["|']/g, (g) => {
412
+ var y, _;
413
+ const C = g.match(
414
+ /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
415
+ );
416
+ if (C && C.length > 0) {
417
+ const T = {
418
+ srcset: (y = r.srcset) == null ? void 0 : y.map((w) => {
419
+ if (typeof w == "number")
420
+ return `//${C}/m/${w}x0${u} ${w}w`;
421
+ if (typeof w == "object" && w.length === 2) {
422
+ let x = 0, H = 0;
423
+ return typeof w[0] == "number" && (x = w[0]), typeof w[1] == "number" && (H = w[1]), `//${C}/m/${x}x${H}${u} ${x}w`;
424
+ }
425
+ return "";
426
+ }).join(", "),
427
+ sizes: (_ = r.sizes) == null ? void 0 : _.map((w) => w).join(", ")
428
+ };
429
+ let $ = "";
430
+ return T.srcset && ($ += `srcset="${T.srcset}" `), T.sizes && ($ += `sizes="${T.sizes}" `), g.replace(/<img/g, `<img ${$.trim()}`);
431
+ }
432
+ return g;
433
+ })), t;
434
+ }
435
+ renderNode(t) {
436
+ const r = [];
437
+ t.marks && t.marks.forEach((i) => {
438
+ const l = this.getMatchingMark(i);
439
+ l && l.tag !== "" && r.push(this.renderOpeningTag(l.tag));
440
+ });
441
+ const s = this.getMatchingNode(t);
442
+ return s && s.tag && r.push(this.renderOpeningTag(s.tag)), t.content ? t.content.forEach((i) => {
443
+ r.push(this.renderNode(i));
444
+ }) : t.text ? r.push(bn(t.text)) : s && s.singleTag ? r.push(this.renderTag(s.singleTag, " /")) : s && s.html ? r.push(s.html) : t.type === "emoji" && r.push(this.renderEmoji(t)), s && s.tag && r.push(this.renderClosingTag(s.tag)), t.marks && t.marks.slice(0).reverse().forEach((i) => {
445
+ const l = this.getMatchingMark(i);
446
+ l && l.tag !== "" && r.push(this.renderClosingTag(l.tag));
447
+ }), r.join("");
448
+ }
449
+ renderTag(t, r) {
450
+ return t.constructor === String ? `<${t}${r}>` : t.map((s) => {
451
+ if (s.constructor === String)
452
+ return `<${s}${r}>`;
453
+ {
454
+ let i = `<${s.tag}`;
455
+ if (s.attrs) {
456
+ for (const l in s.attrs)
457
+ if (Object.prototype.hasOwnProperty.call(s.attrs, l)) {
458
+ const u = s.attrs[l];
459
+ u !== null && (i += ` ${l}="${u}"`);
460
+ }
461
+ }
462
+ return `${i}${r}>`;
463
+ }
464
+ }).join("");
465
+ }
466
+ renderOpeningTag(t) {
467
+ return this.renderTag(t, "");
468
+ }
469
+ renderClosingTag(t) {
470
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
471
+ }
472
+ getMatchingNode(t) {
473
+ const r = this.nodes[t.type];
474
+ if (typeof r == "function")
475
+ return r(t);
476
+ }
477
+ getMatchingMark(t) {
478
+ const r = this.marks[t.type];
479
+ if (typeof r == "function")
480
+ return r(t);
481
+ }
482
+ renderEmoji(t) {
483
+ if (t.attrs.emoji)
484
+ return t.attrs.emoji;
485
+ const r = [
486
+ {
487
+ tag: "img",
488
+ attrs: {
489
+ src: t.attrs.fallbackImage,
490
+ draggable: "false",
491
+ loading: "lazy",
492
+ align: "absmiddle"
493
+ }
494
+ }
495
+ ];
496
+ return this.renderTag(r, " /");
497
+ }
498
+ }
499
+ const mn = yn, Pn = (o) => {
500
+ if (typeof o != "object" || typeof o._editable > "u")
501
+ return {};
502
+ try {
503
+ const t = JSON.parse(
504
+ o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
505
+ );
506
+ return t ? {
507
+ "data-blok-c": JSON.stringify(t),
508
+ "data-blok-uid": t.id + "-" + t.uid
509
+ } : {};
510
+ } catch {
511
+ return {};
512
+ }
513
+ };
514
+ let vn, _n = "https://app.storyblok.com/f/storyblok-v2-latest.js";
515
+ const wn = (o, t) => {
516
+ o.addNode("blok", (r) => {
517
+ let s = "";
518
+ return r.attrs.body.forEach((i) => {
519
+ s += t(i.component, i);
520
+ }), {
521
+ html: s
522
+ };
523
+ });
524
+ }, kn = (o) => !o || !(o != null && o.content.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule")), Tn = (o, t, r) => {
525
+ let s = r || vn;
526
+ if (!s) {
527
+ console.error(
528
+ "Please initialize the Storyblok SDK before calling the renderRichText function"
529
+ );
530
+ return;
531
+ }
532
+ return kn(o) ? "" : (t && (s = new mn(t.schema), t.resolver && wn(s, t.resolver)), s.render(o, {}, !1));
533
+ }, Mn = () => zr(_n);
534
+ function Cn(o) {
535
+ const t = {
536
+ resolveRelations: []
537
+ };
538
+ function r(s) {
539
+ s && Array.isArray(t.resolveRelations) && t.resolveRelations.push(
540
+ ...Array.isArray(s) ? s : [s]
541
+ );
542
+ }
543
+ for (const s of o)
544
+ if (s.options) {
545
+ const { apiOptions: i, bridgeOptions: l } = s.options;
546
+ if (r(i == null ? void 0 : i.resolve_relations), l) {
547
+ const { resolveRelations: u, ...f } = l;
548
+ r(u), Object.assign(t, f);
549
+ }
550
+ }
551
+ return t.resolveRelations = [...new Set(t.resolveRelations)], t;
552
+ }
553
+ var Y = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
554
+ function An(o) {
555
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
556
+ }
557
+ var U = { exports: {} };
558
+ U.exports;
559
+ var He;
560
+ function Sn() {
561
+ return He || (He = 1, function(o, t) {
562
+ var r = 200, s = "__lodash_hash_undefined__", i = 800, l = 16, u = 9007199254740991, f = "[object Arguments]", g = "[object Array]", y = "[object AsyncFunction]", _ = "[object Boolean]", C = "[object Date]", T = "[object Error]", $ = "[object Function]", w = "[object GeneratorFunction]", x = "[object Map]", H = "[object Number]", We = "[object Null]", de = "[object Object]", Ke = "[object Proxy]", Ze = "[object RegExp]", Ve = "[object Set]", Xe = "[object String]", Ye = "[object Undefined]", Qe = "[object WeakMap]", et = "[object ArrayBuffer]", tt = "[object DataView]", rt = "[object Float32Array]", nt = "[object Float64Array]", ot = "[object Int8Array]", at = "[object Int16Array]", st = "[object Int32Array]", it = "[object Uint8Array]", lt = "[object Uint8ClampedArray]", ct = "[object Uint16Array]", ut = "[object Uint32Array]", ft = /[\\^$.*+?()[\]{}|]/g, dt = /^\[object .+?Constructor\]$/, pt = /^(?:0|[1-9]\d*)$/, b = {};
563
+ b[rt] = b[nt] = b[ot] = b[at] = b[st] = b[it] = b[lt] = b[ct] = b[ut] = !0, b[f] = b[g] = b[et] = b[_] = b[tt] = b[C] = b[T] = b[$] = b[x] = b[H] = b[de] = b[Ze] = b[Ve] = b[Xe] = b[Qe] = !1;
564
+ var pe = typeof Y == "object" && Y && Y.Object === Object && Y, gt = typeof self == "object" && self && self.Object === Object && self, M = pe || gt || Function("return this")(), ge = t && !t.nodeType && t, N = ge && !0 && o && !o.nodeType && o, he = N && N.exports === ge, Q = he && pe.process, be = function() {
565
+ try {
566
+ var e = N && N.require && N.require("util").types;
567
+ return e || Q && Q.binding && Q.binding("util");
568
+ } catch {
569
+ }
570
+ }(), ye = be && be.isTypedArray;
571
+ function ht(e, n, a) {
572
+ switch (a.length) {
573
+ case 0:
574
+ return e.call(n);
575
+ case 1:
576
+ return e.call(n, a[0]);
577
+ case 2:
578
+ return e.call(n, a[0], a[1]);
579
+ case 3:
580
+ return e.call(n, a[0], a[1], a[2]);
581
+ }
582
+ return e.apply(n, a);
583
+ }
584
+ function bt(e, n) {
585
+ for (var a = -1, c = Array(e); ++a < e; )
586
+ c[a] = n(a);
587
+ return c;
588
+ }
589
+ function yt(e) {
590
+ return function(n) {
591
+ return e(n);
592
+ };
593
+ }
594
+ function mt(e, n) {
595
+ return e == null ? void 0 : e[n];
596
+ }
597
+ function vt(e, n) {
598
+ return function(a) {
599
+ return e(n(a));
600
+ };
601
+ }
602
+ var _t = Array.prototype, wt = Function.prototype, q = Object.prototype, ee = M["__core-js_shared__"], G = wt.toString, O = q.hasOwnProperty, me = function() {
603
+ var e = /[^.]+$/.exec(ee && ee.keys && ee.keys.IE_PROTO || "");
604
+ return e ? "Symbol(src)_1." + e : "";
605
+ }(), ve = q.toString, kt = G.call(Object), Tt = RegExp(
606
+ "^" + G.call(O).replace(ft, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
607
+ ), J = he ? M.Buffer : void 0, _e = M.Symbol, we = M.Uint8Array;
608
+ J && J.allocUnsafe;
609
+ var ke = vt(Object.getPrototypeOf, Object), Te = Object.create, Ct = q.propertyIsEnumerable, At = _t.splice, j = _e ? _e.toStringTag : void 0, W = function() {
610
+ try {
611
+ var e = ne(Object, "defineProperty");
612
+ return e({}, "", {}), e;
613
+ } catch {
614
+ }
615
+ }(), St = J ? J.isBuffer : void 0, Ce = Math.max, It = Date.now, Ae = ne(M, "Map"), z = ne(Object, "create"), $t = /* @__PURE__ */ function() {
616
+ function e() {
617
+ }
618
+ return function(n) {
619
+ if (!R(n))
620
+ return {};
621
+ if (Te)
622
+ return Te(n);
623
+ e.prototype = n;
624
+ var a = new e();
625
+ return e.prototype = void 0, a;
626
+ };
627
+ }();
628
+ function E(e) {
629
+ var n = -1, a = e == null ? 0 : e.length;
630
+ for (this.clear(); ++n < a; ) {
631
+ var c = e[n];
632
+ this.set(c[0], c[1]);
633
+ }
634
+ }
635
+ function Ot() {
636
+ this.__data__ = z ? z(null) : {}, this.size = 0;
637
+ }
638
+ function xt(e) {
639
+ var n = this.has(e) && delete this.__data__[e];
640
+ return this.size -= n ? 1 : 0, n;
641
+ }
642
+ function jt(e) {
643
+ var n = this.__data__;
644
+ if (z) {
645
+ var a = n[e];
646
+ return a === s ? void 0 : a;
647
+ }
648
+ return O.call(n, e) ? n[e] : void 0;
649
+ }
650
+ function Et(e) {
651
+ var n = this.__data__;
652
+ return z ? n[e] !== void 0 : O.call(n, e);
653
+ }
654
+ function Rt(e, n) {
655
+ var a = this.__data__;
656
+ return this.size += this.has(e) ? 0 : 1, a[e] = z && n === void 0 ? s : n, this;
657
+ }
658
+ E.prototype.clear = Ot, E.prototype.delete = xt, E.prototype.get = jt, E.prototype.has = Et, E.prototype.set = Rt;
659
+ function I(e) {
660
+ var n = -1, a = e == null ? 0 : e.length;
661
+ for (this.clear(); ++n < a; ) {
662
+ var c = e[n];
663
+ this.set(c[0], c[1]);
664
+ }
665
+ }
666
+ function Lt() {
667
+ this.__data__ = [], this.size = 0;
668
+ }
669
+ function Pt(e) {
670
+ var n = this.__data__, a = K(n, e);
671
+ if (a < 0)
672
+ return !1;
673
+ var c = n.length - 1;
674
+ return a == c ? n.pop() : At.call(n, a, 1), --this.size, !0;
675
+ }
676
+ function Mt(e) {
677
+ var n = this.__data__, a = K(n, e);
678
+ return a < 0 ? void 0 : n[a][1];
679
+ }
680
+ function Nt(e) {
681
+ return K(this.__data__, e) > -1;
682
+ }
683
+ function zt(e, n) {
684
+ var a = this.__data__, c = K(a, e);
685
+ return c < 0 ? (++this.size, a.push([e, n])) : a[c][1] = n, this;
686
+ }
687
+ I.prototype.clear = Lt, I.prototype.delete = Pt, I.prototype.get = Mt, I.prototype.has = Nt, I.prototype.set = zt;
688
+ function L(e) {
689
+ var n = -1, a = e == null ? 0 : e.length;
690
+ for (this.clear(); ++n < a; ) {
691
+ var c = e[n];
692
+ this.set(c[0], c[1]);
693
+ }
694
+ }
695
+ function Ft() {
696
+ this.size = 0, this.__data__ = {
697
+ hash: new E(),
698
+ map: new (Ae || I)(),
699
+ string: new E()
700
+ };
701
+ }
702
+ function Dt(e) {
703
+ var n = V(this, e).delete(e);
704
+ return this.size -= n ? 1 : 0, n;
705
+ }
706
+ function Bt(e) {
707
+ return V(this, e).get(e);
708
+ }
709
+ function Ut(e) {
710
+ return V(this, e).has(e);
711
+ }
712
+ function Ht(e, n) {
713
+ var a = V(this, e), c = a.size;
714
+ return a.set(e, n), this.size += a.size == c ? 0 : 1, this;
715
+ }
716
+ L.prototype.clear = Ft, L.prototype.delete = Dt, L.prototype.get = Bt, L.prototype.has = Ut, L.prototype.set = Ht;
717
+ function P(e) {
718
+ var n = this.__data__ = new I(e);
719
+ this.size = n.size;
720
+ }
721
+ function qt() {
722
+ this.__data__ = new I(), this.size = 0;
723
+ }
724
+ function Gt(e) {
725
+ var n = this.__data__, a = n.delete(e);
726
+ return this.size = n.size, a;
727
+ }
728
+ function Jt(e) {
729
+ return this.__data__.get(e);
730
+ }
731
+ function Wt(e) {
732
+ return this.__data__.has(e);
733
+ }
734
+ function Kt(e, n) {
735
+ var a = this.__data__;
736
+ if (a instanceof I) {
737
+ var c = a.__data__;
738
+ if (!Ae || c.length < r - 1)
739
+ return c.push([e, n]), this.size = ++a.size, this;
740
+ a = this.__data__ = new L(c);
741
+ }
742
+ return a.set(e, n), this.size = a.size, this;
743
+ }
744
+ P.prototype.clear = qt, P.prototype.delete = Gt, P.prototype.get = Jt, P.prototype.has = Wt, P.prototype.set = Kt;
745
+ function Zt(e, n) {
746
+ var a = se(e), c = !a && ae(e), d = !a && !c && xe(e), h = !a && !c && !d && Ee(e), m = a || c || d || h, p = m ? bt(e.length, String) : [], v = p.length;
747
+ for (var A in e)
748
+ m && // Safari 9 has enumerable `arguments.length` in strict mode.
749
+ (A == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
750
+ d && (A == "offset" || A == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
751
+ h && (A == "buffer" || A == "byteLength" || A == "byteOffset") || // Skip index properties.
752
+ $e(A, v)) || p.push(A);
753
+ return p;
754
+ }
755
+ function te(e, n, a) {
756
+ (a !== void 0 && !X(e[n], a) || a === void 0 && !(n in e)) && re(e, n, a);
757
+ }
758
+ function Vt(e, n, a) {
759
+ var c = e[n];
760
+ (!(O.call(e, n) && X(c, a)) || a === void 0 && !(n in e)) && re(e, n, a);
761
+ }
762
+ function K(e, n) {
763
+ for (var a = e.length; a--; )
764
+ if (X(e[a][0], n))
765
+ return a;
766
+ return -1;
767
+ }
768
+ function re(e, n, a) {
769
+ n == "__proto__" && W ? W(e, n, {
770
+ configurable: !0,
771
+ enumerable: !0,
772
+ value: a,
773
+ writable: !0
774
+ }) : e[n] = a;
775
+ }
776
+ var Xt = ur();
777
+ function Z(e) {
778
+ return e == null ? e === void 0 ? Ye : We : j && j in Object(e) ? fr(e) : yr(e);
779
+ }
780
+ function Se(e) {
781
+ return F(e) && Z(e) == f;
782
+ }
783
+ function Yt(e) {
784
+ if (!R(e) || hr(e))
785
+ return !1;
786
+ var n = le(e) ? Tt : dt;
787
+ return n.test(wr(e));
788
+ }
789
+ function Qt(e) {
790
+ return F(e) && je(e.length) && !!b[Z(e)];
791
+ }
792
+ function er(e) {
793
+ if (!R(e))
794
+ return br(e);
795
+ var n = Oe(e), a = [];
796
+ for (var c in e)
797
+ c == "constructor" && (n || !O.call(e, c)) || a.push(c);
798
+ return a;
799
+ }
800
+ function Ie(e, n, a, c, d) {
801
+ e !== n && Xt(n, function(h, m) {
802
+ if (d || (d = new P()), R(h))
803
+ tr(e, n, m, a, Ie, c, d);
804
+ else {
805
+ var p = c ? c(oe(e, m), h, m + "", e, n, d) : void 0;
806
+ p === void 0 && (p = h), te(e, m, p);
807
+ }
808
+ }, Re);
809
+ }
810
+ function tr(e, n, a, c, d, h, m) {
811
+ var p = oe(e, a), v = oe(n, a), A = m.get(v);
812
+ if (A) {
813
+ te(e, a, A);
814
+ return;
815
+ }
816
+ var k = h ? h(p, v, a + "", e, n, m) : void 0, D = k === void 0;
817
+ if (D) {
818
+ var ce = se(v), ue = !ce && xe(v), Pe = !ce && !ue && Ee(v);
819
+ k = v, ce || ue || Pe ? se(p) ? k = p : kr(p) ? k = ir(p) : ue ? (D = !1, k = or(v)) : Pe ? (D = !1, k = sr(v)) : k = [] : Tr(v) || ae(v) ? (k = p, ae(p) ? k = Cr(p) : (!R(p) || le(p)) && (k = dr(v))) : D = !1;
820
+ }
821
+ D && (m.set(v, k), d(k, v, c, h, m), m.delete(v)), te(e, a, k);
822
+ }
823
+ function rr(e, n) {
824
+ return vr(mr(e, n, Le), e + "");
825
+ }
826
+ var nr = W ? function(e, n) {
827
+ return W(e, "toString", {
828
+ configurable: !0,
829
+ enumerable: !1,
830
+ value: Sr(n),
831
+ writable: !0
832
+ });
833
+ } : Le;
834
+ function or(e, n) {
835
+ return e.slice();
836
+ }
837
+ function ar(e) {
838
+ var n = new e.constructor(e.byteLength);
839
+ return new we(n).set(new we(e)), n;
840
+ }
841
+ function sr(e, n) {
842
+ var a = ar(e.buffer);
843
+ return new e.constructor(a, e.byteOffset, e.length);
844
+ }
845
+ function ir(e, n) {
846
+ var a = -1, c = e.length;
847
+ for (n || (n = Array(c)); ++a < c; )
848
+ n[a] = e[a];
849
+ return n;
850
+ }
851
+ function lr(e, n, a, c) {
852
+ var d = !a;
853
+ a || (a = {});
854
+ for (var h = -1, m = n.length; ++h < m; ) {
855
+ var p = n[h], v = void 0;
856
+ v === void 0 && (v = e[p]), d ? re(a, p, v) : Vt(a, p, v);
857
+ }
858
+ return a;
859
+ }
860
+ function cr(e) {
861
+ return rr(function(n, a) {
862
+ var c = -1, d = a.length, h = d > 1 ? a[d - 1] : void 0, m = d > 2 ? a[2] : void 0;
863
+ for (h = e.length > 3 && typeof h == "function" ? (d--, h) : void 0, m && pr(a[0], a[1], m) && (h = d < 3 ? void 0 : h, d = 1), n = Object(n); ++c < d; ) {
864
+ var p = a[c];
865
+ p && e(n, p, c, h);
866
+ }
867
+ return n;
868
+ });
869
+ }
870
+ function ur(e) {
871
+ return function(n, a, c) {
872
+ for (var d = -1, h = Object(n), m = c(n), p = m.length; p--; ) {
873
+ var v = m[++d];
874
+ if (a(h[v], v, h) === !1)
875
+ break;
876
+ }
877
+ return n;
878
+ };
879
+ }
880
+ function V(e, n) {
881
+ var a = e.__data__;
882
+ return gr(n) ? a[typeof n == "string" ? "string" : "hash"] : a.map;
883
+ }
884
+ function ne(e, n) {
885
+ var a = mt(e, n);
886
+ return Yt(a) ? a : void 0;
887
+ }
888
+ function fr(e) {
889
+ var n = O.call(e, j), a = e[j];
890
+ try {
891
+ e[j] = void 0;
892
+ var c = !0;
893
+ } catch {
894
+ }
895
+ var d = ve.call(e);
896
+ return c && (n ? e[j] = a : delete e[j]), d;
897
+ }
898
+ function dr(e) {
899
+ return typeof e.constructor == "function" && !Oe(e) ? $t(ke(e)) : {};
900
+ }
901
+ function $e(e, n) {
902
+ var a = typeof e;
903
+ return n = n ?? u, !!n && (a == "number" || a != "symbol" && pt.test(e)) && e > -1 && e % 1 == 0 && e < n;
904
+ }
905
+ function pr(e, n, a) {
906
+ if (!R(a))
907
+ return !1;
908
+ var c = typeof n;
909
+ return (c == "number" ? ie(a) && $e(n, a.length) : c == "string" && n in a) ? X(a[n], e) : !1;
910
+ }
911
+ function gr(e) {
912
+ var n = typeof e;
913
+ return n == "string" || n == "number" || n == "symbol" || n == "boolean" ? e !== "__proto__" : e === null;
914
+ }
915
+ function hr(e) {
916
+ return !!me && me in e;
917
+ }
918
+ function Oe(e) {
919
+ var n = e && e.constructor, a = typeof n == "function" && n.prototype || q;
920
+ return e === a;
921
+ }
922
+ function br(e) {
923
+ var n = [];
924
+ if (e != null)
925
+ for (var a in Object(e))
926
+ n.push(a);
927
+ return n;
928
+ }
929
+ function yr(e) {
930
+ return ve.call(e);
931
+ }
932
+ function mr(e, n, a) {
933
+ return n = Ce(n === void 0 ? e.length - 1 : n, 0), function() {
934
+ for (var c = arguments, d = -1, h = Ce(c.length - n, 0), m = Array(h); ++d < h; )
935
+ m[d] = c[n + d];
936
+ d = -1;
937
+ for (var p = Array(n + 1); ++d < n; )
938
+ p[d] = c[d];
939
+ return p[n] = a(m), ht(e, this, p);
940
+ };
941
+ }
942
+ function oe(e, n) {
943
+ if (!(n === "constructor" && typeof e[n] == "function") && n != "__proto__")
944
+ return e[n];
945
+ }
946
+ var vr = _r(nr);
947
+ function _r(e) {
948
+ var n = 0, a = 0;
949
+ return function() {
950
+ var c = It(), d = l - (c - a);
951
+ if (a = c, d > 0) {
952
+ if (++n >= i)
953
+ return arguments[0];
954
+ } else
955
+ n = 0;
956
+ return e.apply(void 0, arguments);
957
+ };
958
+ }
959
+ function wr(e) {
960
+ if (e != null) {
961
+ try {
962
+ return G.call(e);
963
+ } catch {
964
+ }
965
+ try {
966
+ return e + "";
967
+ } catch {
968
+ }
969
+ }
970
+ return "";
971
+ }
972
+ function X(e, n) {
973
+ return e === n || e !== e && n !== n;
974
+ }
975
+ var ae = Se(/* @__PURE__ */ function() {
976
+ return arguments;
977
+ }()) ? Se : function(e) {
978
+ return F(e) && O.call(e, "callee") && !Ct.call(e, "callee");
979
+ }, se = Array.isArray;
980
+ function ie(e) {
981
+ return e != null && je(e.length) && !le(e);
982
+ }
983
+ function kr(e) {
984
+ return F(e) && ie(e);
985
+ }
986
+ var xe = St || Ir;
987
+ function le(e) {
988
+ if (!R(e))
989
+ return !1;
990
+ var n = Z(e);
991
+ return n == $ || n == w || n == y || n == Ke;
992
+ }
993
+ function je(e) {
994
+ return typeof e == "number" && e > -1 && e % 1 == 0 && e <= u;
995
+ }
996
+ function R(e) {
997
+ var n = typeof e;
998
+ return e != null && (n == "object" || n == "function");
999
+ }
1000
+ function F(e) {
1001
+ return e != null && typeof e == "object";
1002
+ }
1003
+ function Tr(e) {
1004
+ if (!F(e) || Z(e) != de)
1005
+ return !1;
1006
+ var n = ke(e);
1007
+ if (n === null)
1008
+ return !0;
1009
+ var a = O.call(n, "constructor") && n.constructor;
1010
+ return typeof a == "function" && a instanceof a && G.call(a) == kt;
1011
+ }
1012
+ var Ee = ye ? yt(ye) : Qt;
1013
+ function Cr(e) {
1014
+ return lr(e, Re(e));
1015
+ }
1016
+ function Re(e) {
1017
+ return ie(e) ? Zt(e) : er(e);
1018
+ }
1019
+ var Ar = cr(function(e, n, a, c) {
1020
+ Ie(e, n, a, c);
1021
+ });
1022
+ function Sr(e) {
1023
+ return function() {
1024
+ return e;
1025
+ };
1026
+ }
1027
+ function Le(e) {
1028
+ return e;
1029
+ }
1030
+ function Ir() {
1031
+ return !1;
1032
+ }
1033
+ o.exports = Ar;
1034
+ }(U, U.exports)), U.exports;
1035
+ }
1036
+ var In = Sn();
1037
+ const $n = /* @__PURE__ */ An(In);
1038
+ function On(o) {
1039
+ let t = {};
1040
+ function r(s, i) {
1041
+ if ((i == null ? void 0 : i.type) === "AwaitExpression" && i.argument.type === "CallExpression" && i.argument.callee.type === "Identifier" && i.argument.callee.name === "useStoryblok") {
1042
+ const l = i.argument.arguments;
1043
+ if (l && l[1].type === "ObjectExpression") {
1044
+ const u = qe(l[1].properties);
1045
+ t = {
1046
+ ...t,
1047
+ apiOptions: u
1048
+ };
1049
+ }
1050
+ if (l && l[2].type === "ObjectExpression") {
1051
+ const u = qe(l[2].properties);
1052
+ t = {
1053
+ ...t,
1054
+ bridgeOptions: u
1055
+ };
1056
+ }
1057
+ }
1058
+ }
1059
+ return $n({}, o, r), t;
1060
+ }
1061
+ function qe(o) {
1062
+ const t = {};
1063
+ return o.reduce((r, s) => {
1064
+ if (s.type !== "Property")
1065
+ return r;
1066
+ const { key: i, value: l } = s, { type: u } = l;
1067
+ if (i.type !== "Identifier")
1068
+ return r;
1069
+ if (u === "Literal")
1070
+ r[i.name] = l.value;
1071
+ else if (u === "ArrayExpression") {
1072
+ const f = l.elements.reduce(
1073
+ (g, y) => y.type === "Literal" && y.value ? [...g, y.value] : g,
1074
+ []
1075
+ );
1076
+ r[i.name] = f;
1077
+ }
1078
+ return r;
1079
+ }, t);
1080
+ }
1081
+ let B = [];
1082
+ function xn(o, t) {
1083
+ const r = "virtual:storyblok-bridge", s = `\0${r}`;
1084
+ if (!o || t !== "server")
1085
+ return {
1086
+ name: "vite-plugin-storyblok-bridge",
1087
+ resolveId(f) {
1088
+ if (f === r)
1089
+ return s;
1090
+ },
1091
+ load(f) {
1092
+ if (f === s)
1093
+ return "export const bridgeOptions = null";
1094
+ }
1095
+ };
1096
+ let i = [], l = null, u;
1097
+ return {
1098
+ name: "vite-plugin-storyblok-bridge",
1099
+ async resolveId(f) {
1100
+ if (f === r)
1101
+ return s;
1102
+ },
1103
+ async transform(f, g) {
1104
+ var w;
1105
+ if (g.includes("node_modules") && !g.includes("/pages/") || !f.includes("useStoryblok"))
1106
+ return;
1107
+ const _ = this.getModuleInfo(g);
1108
+ if (!((w = _ == null ? void 0 : _.meta) != null && w.astro))
1109
+ return;
1110
+ const [, ...C] = g.split("src/pages/"), T = C.join("/").replace(".astro", ""), $ = On(this.parse(f));
1111
+ B.length && (i = B.filter((x) => x.url !== T)), i.push({
1112
+ url: T,
1113
+ options: $
1114
+ }), l && (u && clearTimeout(u), u = setTimeout(() => {
1115
+ jn(B, i) || (B.length !== 0 && (l == null || l.restart(), console.info("Bridge options updated. Restarting...")), B = [...i]);
1116
+ }, 1e3));
1117
+ },
1118
+ async load(f) {
1119
+ if (f === s)
1120
+ return `export const bridgeOptions = ${JSON.stringify(Cn(i))}`;
1121
+ },
1122
+ configureServer(f) {
1123
+ l = f;
1124
+ }
1125
+ };
1126
+ }
1127
+ function jn(o = [], t = []) {
1128
+ return t.every(({ url: r, options: s }) => {
1129
+ const i = o.find((l) => (l == null ? void 0 : l.url) === r);
1130
+ return i && JSON.stringify(s) === JSON.stringify(i.options);
1131
+ });
1132
+ }
1133
+ const En = `<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">
1134
+ <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1135
+ <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
1136
+ <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
1137
+ <path d="M2.32662261,0 C1.03405449,0 0,1.0331384 0,2.27290448 L0,42.8752437 C0,44.1150097 1.03405449,44.8898635 2.27491989,44.8898635 L8.27243596,44.8898635 L8.27243596,53 L15.7176283,44.9415205 L42.9132615,44.9415205 C44.1541269,44.9415205 44.9296678,44.1666667 44.9296678,42.8752437 L44.9296678,2.3245614 C44.9296678,1.08479532 44.2058296,0 42.9132615,0 L2.32662261,0 Z" id="Shape-path-Copy" fill="#0AB3AF"></path>
1138
+ <path d="M29.1016723,8.11483254 C30.1351059,8.11483254 31.0135245,8.32132604 31.8402713,8.78593643 C32.6153465,9.19892344 33.33875,9.76678059 33.9071385,10.4378845 C35.0647615,11.8482391 35.6869248,13.6215753 35.6639755,15.445352 C35.6639755,16.7875598 35.3022738,18.0781442 34.630542,19.3171053 C33.9341248,20.5632996 32.8438147,21.5436614 31.5302412,22.1047676 C33.183735,22.569378 34.4755269,23.395352 35.4572888,24.5826897 C36.387379,25.8216507 36.8524241,27.4219754 36.8524241,29.4352871 C36.8524241,30.7258715 36.6168825,31.8756998 36.1290206,32.7391832 C35.6123039,33.668404 34.8372287,34.4427546 33.9071385,35.0106118 C32.9253766,35.6300923 31.8402713,36.1979494 30.600151,36.4560663 C29.3600307,36.7658066 28.0165671,37.0239234 26.6214318,37.0239234 L8.32965751,37.0239234 L8.32965751,8.11483254 L29.1016723,8.11483254 Z M26.1340815,24.271851 L15.77813,24.271851 L15.77813,29.1552028 L25.8851404,29.1552028 C26.4825991,29.1552028 27.0302696,28.9110352 27.4783637,28.5203671 C27.8766695,28.1296989 28.1256107,27.5436967 28.1256107,26.811194 C28.140051,26.1827412 27.948041,25.5663945 27.5779401,25.0531873 C27.1796343,24.5648522 26.7315403,24.271851 26.1340815,24.271851 Z M25.2876816,14.5051475 L15.77813,14.5051475 L15.77813,18.9001641 L25.0885287,18.9001641 C25.586411,18.9001641 26.0842933,18.6559965 26.4825991,18.3629954 C26.9306932,18.0699943 27.1298461,17.4351586 27.1298461,16.6049888 C27.1298461,15.872486 26.9306932,15.3353173 26.5821756,14.9934827 C26.233658,14.7004816 25.7855639,14.5051475 25.2876816,14.5051475 Z" id="Combined-Shape-Copy-3" fill="#FFFFFF"></path>
1139
+ </g>
1140
+ </g>
1141
+ </g>
1142
+ </svg>`;
1143
+ let Ge;
1144
+ async function Nn(o) {
1145
+ const { action: t, story: r } = o || {};
1146
+ if (t === "input" && r) {
1147
+ const s = async () => {
1148
+ const l = await Ln(r), u = document.body;
1149
+ if (l.outerHTML === u.outerHTML)
1150
+ return;
1151
+ const f = document.querySelector('[data-blok-focused="true"]');
1152
+ Rn(u, l, f);
1153
+ };
1154
+ clearTimeout(Ge), Ge = setTimeout(s, 500);
1155
+ }
1156
+ ["published", "change"].includes(o == null ? void 0 : o.action) && location.reload();
1157
+ }
1158
+ function Rn(o, t, r) {
1159
+ if (r) {
1160
+ const s = r.getAttribute("data-blok-uid"), i = t.querySelector(
1161
+ `[data-blok-uid="${s}"]`
1162
+ );
1163
+ i && (i.setAttribute("data-blok-focused", "true"), r.replaceWith(i));
1164
+ } else
1165
+ o.replaceWith(t);
1166
+ }
1167
+ async function Ln(o) {
1168
+ const r = await (await fetch(location.href, {
1169
+ method: "POST",
1170
+ body: JSON.stringify({
1171
+ ...o,
1172
+ is_storyblok_preview: !0
1173
+ }),
1174
+ headers: {
1175
+ "Content-Type": "application/json"
1176
+ }
1177
+ })).text();
1178
+ return new DOMParser().parseFromString(r, "text/html").body;
1179
+ }
1180
+ function zn() {
1181
+ if (!(globalThis != null && globalThis.storyblokApiInstance))
1182
+ throw new Error("storyblokApiInstance has not been initialized correctly");
1183
+ return globalThis.storyblokApiInstance;
1184
+ }
1185
+ async function Fn(o, t = {}, r = {}, s) {
1186
+ var l;
1187
+ if (!globalThis.storyblokApiInstance)
1188
+ throw new Error("storyblokApiInstance has not been initialized correctly");
1189
+ let i = null;
1190
+ if (s && s.locals._storyblok_preview_data)
1191
+ i = s.locals._storyblok_preview_data;
1192
+ else {
1193
+ const { data: u } = await ((l = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : l.get(
1194
+ o,
1195
+ t
1196
+ ));
1197
+ i = u.story;
1198
+ }
1199
+ return i;
1200
+ }
1201
+ function Dn(o, t) {
1202
+ var s;
1203
+ const r = (s = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : s.richTextResolver;
1204
+ if (!r)
1205
+ throw new Error(
1206
+ "Please initialize the Storyblok SDK before calling the renderRichText function"
1207
+ );
1208
+ return Tn(o, t, r);
1209
+ }
1210
+ function Bn(o) {
1211
+ const t = {
1212
+ useCustomApi: !1,
1213
+ bridge: !0,
1214
+ componentsDir: "src",
1215
+ enableFallbackComponent: !1,
1216
+ livePreview: !1,
1217
+ ...o
1218
+ };
1219
+ return {
1220
+ name: "@storyblok/astro",
1221
+ hooks: {
1222
+ "astro:config:setup": ({
1223
+ injectScript: r,
1224
+ updateConfig: s,
1225
+ addDevToolbarApp: i,
1226
+ addMiddleware: l,
1227
+ config: u
1228
+ }) => {
1229
+ if (s({
1230
+ vite: {
1231
+ plugins: [
1232
+ $r(
1233
+ t.accessToken,
1234
+ t.useCustomApi,
1235
+ t.apiOptions
1236
+ ),
1237
+ Mr(
1238
+ t.componentsDir,
1239
+ t.components,
1240
+ t.enableFallbackComponent,
1241
+ t.customFallbackComponent
1242
+ ),
1243
+ Nr(t),
1244
+ xn(
1245
+ t.livePreview,
1246
+ u.output
1247
+ )
1248
+ ]
1249
+ }
1250
+ }), t.livePreview && (u == null ? void 0 : u.output) !== "server")
1251
+ throw new Error(
1252
+ "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."
1253
+ );
1254
+ if (r(
1255
+ "page-ssr",
1256
+ `
1257
+ import { storyblokApiInstance } from "virtual:storyblok-init";
1258
+ globalThis.storyblokApiInstance = storyblokApiInstance;
1259
+ `
1260
+ ), t.bridge && !t.livePreview) {
1261
+ let f = "";
1262
+ if (typeof t.bridge == "object") {
1263
+ const g = { ...t.bridge };
1264
+ f = `const storyblokInstance = new StoryblokBridge(${JSON.stringify(
1265
+ g
1266
+ )});`;
1267
+ } else
1268
+ f = "const storyblokInstance = new StoryblokBridge()";
1269
+ r(
1270
+ "page",
1271
+ `
1272
+ import { loadStoryblokBridge } from "@storyblok/astro";
1273
+ loadStoryblokBridge().then(() => {
1274
+ const { StoryblokBridge, location } = window;
1275
+ ${f}
1276
+
1277
+ storyblokInstance.on(["published", "change"], (event) => {
1278
+ if (!event.slugChanged) {
1279
+ location.reload(true);
1280
+ }
1281
+ });
1282
+ });
1283
+ `
1284
+ );
1285
+ }
1286
+ t.livePreview && (r(
1287
+ "page",
1288
+ `
1289
+ import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
1290
+ import { bridgeOptions } from "virtual:storyblok-bridge";
1291
+ console.info("The Storyblok Astro live preview feature is currently in an experimental phase, and its API is subject to change in the future.")
1292
+ loadStoryblokBridge().then(() => {
1293
+ const { StoryblokBridge, location } = window;
1294
+ if(bridgeOptions){
1295
+ const storyblokInstance = new StoryblokBridge(bridgeOptions);
1296
+ storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
1297
+ };
1298
+ });
1299
+ `
1300
+ ), l({
1301
+ entrypoint: "@storyblok/astro/middleware.ts",
1302
+ order: "pre"
1303
+ })), i({
1304
+ id: "storyblok",
1305
+ name: "Storyblok",
1306
+ icon: En,
1307
+ entrypoint: "@storyblok/astro/toolbarApp.ts"
1308
+ });
1309
+ }
1310
+ }
1311
+ };
1312
+ }
1313
+ export {
1314
+ mn as RichTextResolver,
1315
+ hn as RichTextSchema,
1316
+ Bn as default,
1317
+ Nn as handleStoryblokMessage,
1318
+ Mn as loadStoryblokBridge,
1319
+ Dn as renderRichText,
1320
+ Pn as storyblokEditable,
1321
+ Fe as toCamelCase,
1322
+ Fn as useStoryblok,
1323
+ zn as useStoryblokApi
1324
+ };