@storyblok/astro 7.2.7 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,138 +1,200 @@
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
- <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
- <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
4
- <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
5
- <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>
6
- <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>
7
- </g>
8
- </g>
9
- </g>
10
- </svg>`, ee = /[\p{Lu}]/u, te = /[\p{Ll}]/u, N = /^[\p{Lu}](?![\p{Lu}])/gu, G = /([\p{Alpha}\p{N}_]|$)/u, O = /[_.\- ]+/, re = new RegExp("^" + O.source), M = new RegExp(O.source + G.source, "gu"), P = new RegExp("\\d+" + G.source, "gu"), oe = (e, t, s, n) => {
11
- let l = !1, o = !1, b = !1, p = !1;
12
- for (let i = 0; i < e.length; i++) {
13
- const u = e[i];
14
- p = i > 2 ? e[i - 3] === "-" : !0, l && ee.test(u) ? (e = e.slice(0, i) + "-" + e.slice(i), l = !1, b = o, o = !0, i++) : o && b && te.test(u) && (!p || n) ? (e = e.slice(0, i - 1) + "-" + e.slice(i - 1), b = o, o = !1, l = !0) : (l = t(u) === u && s(u) !== u, b = o, o = s(u) === u && t(u) !== u);
15
- }
16
- return e;
17
- }, se = (e, t) => (N.lastIndex = 0, e.replaceAll(N, (s) => t(s))), ne = (e, t) => (M.lastIndex = 0, P.lastIndex = 0, e.replaceAll(P, (s, n, l) => ["_", "-"].includes(e.charAt(l + s.length)) ? s : t(s)).replaceAll(M, (s, n) => t(n)));
18
- function le(e, t) {
19
- if (!(typeof e == "string" || Array.isArray(e)))
20
- throw new TypeError("Expected the input to be `string | string[]`");
21
- if (t = {
22
- pascalCase: !1,
23
- preserveConsecutiveUppercase: !1,
24
- ...t
25
- }, Array.isArray(e) ? e = e.map((o) => o.trim()).filter((o) => o.length).join("-") : e = e.trim(), e.length === 0)
26
- return "";
27
- const s = t.locale === !1 ? (o) => o.toLowerCase() : (o) => o.toLocaleLowerCase(t.locale), n = t.locale === !1 ? (o) => o.toUpperCase() : (o) => o.toLocaleUpperCase(t.locale);
28
- return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? n(e) : s(e) : (e !== s(e) && (e = oe(e, s, n, t.preserveConsecutiveUppercase)), e = e.replace(re, ""), e = t.preserveConsecutiveUppercase ? se(e, s) : s(e), t.pascalCase && (e = n(e.charAt(0)) + e.slice(1)), ne(e, n));
29
- }
30
- function j(e) {
31
- return le(e);
32
- }
33
- function ae(e, t = {}, s, n) {
34
- const l = "virtual:storyblok-components", o = `\0${l}`;
35
- return {
36
- name: "vite-plugin-storyblok-components",
37
- async resolveId(b) {
38
- if (b === l)
39
- return o;
40
- },
41
- async load(b) {
42
- if (b === o) {
43
- const p = [], i = [];
44
- for await (const [y, E] of Object.entries(t)) {
45
- const L = await this.resolve(
46
- `/${e}/${E}.astro`
47
- );
48
- if (L)
49
- p.push(`import ${j(y)} from "${L.id}"`);
50
- else if (s)
51
- i.push(y);
52
- else
53
- throw new Error(
54
- `Component could not be found for blok "${y}"! Does "${`/${e}/${E}`}.astro" exist?`
55
- );
56
- }
57
- let u = "";
58
- if (s)
59
- if (u = ",FallbackComponent", n) {
60
- const y = await this.resolve(
61
- `/${e}/${n}.astro`
62
- );
63
- if (!y)
64
- throw new Error(
65
- `Custom fallback component could not be found. Does "${`/${e}/${n}`}.astro" exist?`
66
- );
67
- p.push(
68
- `import FallbackComponent from "${y.id}"`
69
- );
70
- } else
71
- p.push(
72
- "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
73
- );
74
- if (Object.values(t).length)
75
- return `${p.join(";")};export default {${Object.keys(t).filter((y) => !i.includes(y)).map((y) => j(y)).join(",")}${u}}`;
76
- if (s)
77
- return `${p[0]}; export default {${u.replace(",", "")}}`;
78
- throw new Error(
79
- `Currently, no Storyblok components are registered in astro.config.mjs.
80
- Please register your components or enable the fallback component.
81
- Detailed information can be found here: https://github.com/storyblok/storyblok-astro`
82
- );
83
- }
84
- }
85
- };
86
- }
87
- function ie(e, t, s) {
88
- const n = "virtual:storyblok-init", l = `\0${n}`;
1
+ const oe = `
2
+ <svg class="logo-storyblok logo-storyblok--dark" role="img" aria-label="Storyblok Official Logo" viewBox="0 0 19 22" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M29.0287 14.9132C28.2686 14.9132 27.5302 14.8018 26.7918 14.5568C26.0988 14.3265 25.462 13.9468 24.924 13.4432L25.9013 11.7504C26.4443 12.1291 26.9655 12.4186 27.4867 12.6414C27.9862 12.8641 28.4858 12.9532 28.9636 12.9532C29.3111 12.9532 29.5934 12.8864 29.7888 12.7527C29.9843 12.6414 30.0712 12.4409 30.0712 12.1959C30.0712 11.9732 29.9626 11.7504 29.702 11.6168C29.2938 11.4162 28.8636 11.2666 28.4206 11.1714L26.9003 10.6591C26.4877 10.4809 26.1619 10.3027 25.9013 10.1023C25.6407 9.92408 25.4452 9.67908 25.3366 9.43408C25.2184 9.1529 25.1592 8.84935 25.1629 8.54317C25.1502 7.66646 25.5255 6.83107 26.1836 6.27136C26.4877 6.00408 26.8786 5.80363 27.313 5.64772C27.7473 5.49181 28.2251 5.42499 28.7247 5.42499C29.3979 5.42499 30.0277 5.51408 30.6141 5.69226C31.2005 5.89272 31.7652 6.22681 32.3081 6.71681L31.244 8.38726C30.8236 8.07881 30.3722 7.81747 29.8974 7.60772C29.4848 7.42954 29.1156 7.36272 28.7247 7.36272C28.4423 7.36272 28.1817 7.40726 27.9862 7.5409C27.7691 7.65226 27.6822 7.85272 27.6822 8.11999C27.6822 8.38726 27.7908 8.56545 28.008 8.69908C28.2251 8.83272 28.6595 8.96635 29.2459 9.12226C29.7903 9.26289 30.3268 9.4339 30.853 9.63454C31.2874 9.81272 31.6349 10.0132 31.9172 10.2136C32.4511 10.6169 32.7463 11.2726 32.6991 11.9509C32.6991 12.8641 32.3733 13.5768 31.7 14.1114C31.0485 14.6459 30.1798 14.9132 29.0287 14.9132ZM39.7792 14.2673C39.41 14.4232 38.9756 14.5791 38.4978 14.7127C38.02 14.8464 37.5422 14.9354 37.0427 14.9354C36.6952 14.9354 36.3911 14.8909 36.0871 14.8018C35.7915 14.7134 35.5176 14.5616 35.2835 14.3564C35.0663 14.1782 34.8926 13.9109 34.7623 13.6214C34.632 13.3095 34.5451 12.9309 34.5451 12.4854V7.69681H33.4158V5.60317H34.5668V2.68545H37.2599V5.5809H39.0842V7.69681H37.2599V11.5277C37.2599 11.8173 37.325 12.04 37.4771 12.1959C37.6291 12.3073 37.8245 12.3741 38.0417 12.3741C38.2589 12.3741 38.4761 12.3518 38.6715 12.2627C38.8887 12.1959 39.0842 12.1291 39.2362 12.04L39.7575 14.2673H39.7792ZM44.8612 14.9132C44.1701 14.9255 43.4835 14.7968 42.8414 14.5345C41.7112 14.076 40.8261 13.1439 40.409 11.9732C39.9823 10.8102 39.9823 9.52792 40.409 8.36499C40.8261 7.19423 41.7112 6.26214 42.8414 5.80363C43.4278 5.55863 44.1011 5.42499 44.8612 5.42499C46.1833 5.36117 47.4671 5.88947 48.3795 6.87272C48.7922 7.2959 49.0962 7.80817 49.3134 8.36499C49.758 9.5322 49.758 10.8282 49.3134 11.9954C48.8937 13.1518 48.0186 14.0734 46.9027 14.5345C46.2538 14.7998 45.5596 14.9285 44.8612 14.9132ZM42.9066 10.1914C42.9066 10.9041 43.0803 11.4832 43.4495 11.9064C43.8405 12.3518 44.3183 12.5745 44.8829 12.5745C45.4284 12.5853 45.9487 12.3391 46.2946 11.9064C46.4683 11.6836 46.5987 11.4609 46.7072 11.1491C46.8158 10.8595 46.8593 10.5254 46.8593 10.1914C46.8593 9.45636 46.6638 8.87726 46.2946 8.45408C45.9254 8.00863 45.4476 7.78589 44.8829 7.78589C44.3394 7.78464 43.8229 8.02909 43.4712 8.45408C43.2975 8.67681 43.1455 8.89954 43.0369 9.21136C42.939 9.52794 42.8949 9.85944 42.9066 10.1914ZM56.6541 7.98636C56.0026 7.98636 55.3945 8.09772 54.8515 8.32045C54.3736 8.48572 53.9666 8.81646 53.7005 9.2559V14.7573H50.9857V5.60317H53.4833V7.42954C53.7873 6.8059 54.1783 6.3159 54.6778 5.98181C55.1556 5.62545 55.6551 5.44726 56.1981 5.42499H56.4804L56.6541 5.44726V7.96408V7.98636ZM57.8486 16.1159C58.2263 16.2505 58.6217 16.3256 59.0214 16.3386C59.3472 16.3386 59.6078 16.2273 59.8033 16.0045C59.977 15.7818 60.129 15.3364 60.2811 14.7573L56.893 5.60317H59.6947L61.7579 12.3518L63.5605 5.60317H66.1015L62.6918 16.2273C62.1569 18.0318 60.3638 19.1157 58.5653 18.7218C58.3481 18.6773 58.0875 18.6104 57.8486 18.4991V16.1159ZM72.5301 14.9133C71.8568 14.9133 71.2487 14.7795 70.7492 14.4677C70.2417 14.1818 69.8208 13.758 69.533 13.2427V14.7573H67.1657V2.01727H69.9022V7.09545C70.4962 6.02938 71.6157 5.38681 72.8124 5.42499C73.3771 5.42499 73.8983 5.53636 74.3761 5.80363C74.8539 6.02636 75.2448 6.38272 75.614 6.8059C76.6831 8.32739 76.974 10.2831 76.3959 12.0623C76.1787 12.6414 75.8746 13.1536 75.5054 13.5768C74.7429 14.4342 73.6616 14.9198 72.5301 14.9133ZM71.7699 12.5745C72.6515 12.5764 73.4369 12.0037 73.7245 11.1491C74.043 10.2518 73.887 9.24956 73.3119 8.49863C72.9724 8.0401 72.4398 7.7753 71.8785 7.7859C71.4659 7.7859 71.0749 7.94181 70.7057 8.23136C70.3582 8.54317 70.0759 8.92181 69.8805 9.38954V11.305C70.2309 12.0628 70.9738 12.5476 71.7916 12.5523L71.7699 12.5745ZM78.0247 2.01727H80.7395V11.4832C80.7395 12.1959 81.0218 12.53 81.6082 12.53C81.9183 12.5309 82.2239 12.4545 82.4987 12.3073L82.8679 14.3786C82.1072 14.7203 81.2875 14.902 80.4572 14.9132C79.6753 14.9132 79.0672 14.6904 78.6546 14.2895C78.2202 13.8441 78.003 13.265 78.003 12.4632V2.01727H78.0247ZM87.9933 14.9132C87.3023 14.9255 86.6157 14.7968 85.9736 14.5345C84.8367 14.0789 83.9437 13.1469 83.5194 11.9732C82.8914 10.2226 83.2408 8.26037 84.4316 6.85045C84.8659 6.40499 85.3437 6.0709 85.9518 5.80363C86.5382 5.55863 87.2115 5.42499 87.9716 5.42499C89.2937 5.36117 90.5776 5.88947 91.49 6.87272C91.9243 7.2959 92.2066 7.80817 92.4238 8.36499C93.0767 10.1133 92.7249 12.0889 91.5117 13.4877C91.099 13.9332 90.5995 14.2895 89.9914 14.5345C89.3493 14.7968 88.6627 14.9255 87.9716 14.9132H87.9933ZM86.017 10.1914C86.017 10.9041 86.1907 11.4832 86.5599 11.9064C86.9509 12.3518 87.4287 12.5745 87.9933 12.5745C88.5382 12.5821 89.0571 12.3364 89.405 11.9064C89.5788 11.6836 89.7091 11.4609 89.8177 11.1491C89.9262 10.8595 89.9697 10.5254 89.9697 10.1914C89.9697 9.45636 89.7742 8.87726 89.405 8.45408C89.0358 8.00863 88.558 7.78589 87.9933 7.78589C87.4498 7.78464 86.9334 8.02909 86.5817 8.45408C86.4079 8.67681 86.2559 8.89954 86.1473 9.21136C86.0387 9.52317 86.017 9.83499 86.017 10.1914ZM100.112 14.7573L97.7882 11.06L96.8326 12.0845V14.7573H94.1178V2.01727H96.8326V9.38954L99.8514 5.60317H102.74L99.5256 9.54545L103.001 14.7573H100.112Z" fill="currentColor"></path>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M0 1.71089C0 0.76599 0.76599 0 1.71089 0H17.1089C18.0538 0 18.8198 0.76599 18.8198 1.71089V17.1089C18.8198 18.0538 18.0538 18.8198 17.1089 18.8198H7.13145L4.57616 20.9297C4.24445 21.2036 3.74366 20.9676 3.74366 20.5375V18.8198H1.71089C0.76599 18.8198 0 18.0538 0 17.1089V1.71089ZM3.74233 3.10946H11.9675C13.7438 3.10946 15.1839 4.5495 15.1839 6.32587C15.1839 7.74936 14.2592 8.95687 12.9777 9.38045C14.4761 9.65447 15.6117 10.9667 15.6117 12.5443C15.6117 14.3207 14.1717 15.7607 12.3953 15.7607H3.74247V9.54229H3.74233V3.10946ZM10.583 6.00384H6.73607V7.93369H10.583C11.1159 7.93369 11.5479 7.50168 11.5479 6.96877C11.5479 6.43585 11.1159 6.00384 10.583 6.00384ZM6.73607 10.2925H10.9035C11.4956 10.2925 11.9757 10.7725 11.9757 11.3647C11.9757 11.9568 11.4956 12.4368 10.9035 12.4368H6.73607V10.2925Z" fill="currentColor"></path>
5
+ </svg>
6
+ `;
7
+ function re(e, t, r) {
8
+ const l = "virtual:storyblok-init", s = `\0${l}`;
89
9
  return {
90
10
  name: "vite-plugin-storyblok-init",
91
- async resolveId(o) {
92
- if (o === n)
93
- return l;
11
+ async resolveId(n) {
12
+ if (n === l)
13
+ return s;
94
14
  },
95
- async load(o) {
96
- if (o === l)
15
+ async load(n) {
16
+ if (n === s)
97
17
  return `
98
18
  import { storyblokInit, apiPlugin } from "@storyblok/js";
99
19
  const { storyblokApi } = storyblokInit({
100
20
  accessToken: "${e}",
101
21
  use: ${t ? "[]" : "[apiPlugin]"},
102
- apiOptions: ${JSON.stringify(s)},
22
+ apiOptions: ${JSON.stringify(r)},
103
23
  });
104
24
  export const storyblokApiInstance = storyblokApi;
105
25
  `;
106
26
  }
107
27
  };
108
28
  }
109
- function ce(e) {
110
- const t = "virtual:storyblok-options", s = `\0${t}`;
29
+ function ne(e) {
30
+ const t = "virtual:storyblok-options", r = `\0${t}`;
111
31
  return {
112
32
  name: "vite-plugin-storyblok-options",
113
- async resolveId(n) {
114
- if (n === t)
115
- return s;
33
+ async resolveId(l) {
34
+ if (l === t)
35
+ return r;
116
36
  },
117
- async load(n) {
118
- if (n === s)
37
+ async load(l) {
38
+ if (l === r)
119
39
  return `export default ${JSON.stringify(e)}`;
120
40
  }
121
41
  };
122
42
  }
123
- function Ce() {
43
+ function Re() {
124
44
  if (!(globalThis != null && globalThis.storyblokApiInstance))
125
45
  throw new Error("storyblokApiInstance has not been initialized correctly");
126
46
  return globalThis.storyblokApiInstance;
127
47
  }
128
- async function Ee(e) {
48
+ async function xe(e) {
129
49
  let t = null;
130
50
  return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data), t;
131
51
  }
132
- function de(e) {
52
+ function se(e) {
133
53
  return typeof e == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});` : "const storyblokInstance = new StoryblokBridge();";
134
54
  }
135
- function Le(e) {
55
+ function le(e) {
56
+ return e.endsWith(".astro") ? e : `${e}.astro`;
57
+ }
58
+ function H(e) {
59
+ return `/${e.trim().replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/{2,}/g, "/")}`;
60
+ }
61
+ const ae = /[\p{Lu}]/u, ie = /[\p{Ll}]/u, D = /^[\p{Lu}](?![\p{Lu}])/gu, G = /([\p{Alpha}\p{N}_]|$)/u, M = /[_.\- ]+/, ce = new RegExp("^" + M.source), B = new RegExp(M.source + G.source, "gu"), V = new RegExp("\\d+" + G.source, "gu"), ue = (e, t, r, l) => {
62
+ let s = !1, n = !1, b = !1, m = !1;
63
+ for (let u = 0; u < e.length; u++) {
64
+ const d = e[u];
65
+ m = u > 2 ? e[u - 3] === "-" : !0, s && ae.test(d) ? (e = e.slice(0, u) + "-" + e.slice(u), s = !1, b = n, n = !0, u++) : n && b && ie.test(d) && (!m || l) ? (e = e.slice(0, u - 1) + "-" + e.slice(u - 1), b = n, n = !1, s = !0) : (s = t(d) === d && r(d) !== d, b = n, n = r(d) === d && t(d) !== d);
66
+ }
67
+ return e;
68
+ }, de = (e, t) => (D.lastIndex = 0, e.replaceAll(D, (r) => t(r))), pe = (e, t) => (B.lastIndex = 0, V.lastIndex = 0, e.replaceAll(V, (r, l, s) => ["_", "-"].includes(e.charAt(s + r.length)) ? r : t(r)).replaceAll(B, (r, l) => t(l)));
69
+ function be(e, t) {
70
+ if (!(typeof e == "string" || Array.isArray(e)))
71
+ throw new TypeError("Expected the input to be `string | string[]`");
72
+ if (t = {
73
+ pascalCase: !1,
74
+ preserveConsecutiveUppercase: !1,
75
+ ...t
76
+ }, Array.isArray(e) ? e = e.map((n) => n.trim()).filter((n) => n.length).join("-") : e = e.trim(), e.length === 0)
77
+ return "";
78
+ const r = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), l = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
79
+ return e.length === 1 ? M.test(e) ? "" : t.pascalCase ? l(e) : r(e) : (e !== r(e) && (e = ue(e, r, l, t.preserveConsecutiveUppercase)), e = e.replace(ce, ""), e = t.preserveConsecutiveUppercase ? de(e, r) : r(e), t.pascalCase && (e = l(e.charAt(0)) + e.slice(1)), pe(e, l));
80
+ }
81
+ function Ce(e) {
82
+ return be(e);
83
+ }
84
+ function me(e, t, r, l) {
85
+ const s = "virtual:import-storyblok-components", n = `\0${s}`;
86
+ return {
87
+ name: "vite-plugin-import-storyblok-components",
88
+ /**
89
+ * Resolves virtual module imports
90
+ */
91
+ async resolveId(b) {
92
+ if (b === s)
93
+ return n;
94
+ },
95
+ /**
96
+ * Generates the virtual module content with dynamic imports
97
+ */
98
+ async load(b) {
99
+ if (b !== n)
100
+ return;
101
+ const m = await ye(
102
+ this,
103
+ t,
104
+ r,
105
+ l
106
+ ), u = await he(
107
+ this,
108
+ e,
109
+ t,
110
+ r
111
+ );
112
+ return fe(
113
+ t,
114
+ m,
115
+ u
116
+ );
117
+ }
118
+ };
119
+ }
120
+ function fe(e, t, r) {
121
+ const s = `${H(e)}/storyblok/**/*.astro`;
122
+ return `
123
+ // Import utilities and fallback component
124
+ import { toCamelCase } from '@storyblok/astro';
125
+ ${t}
126
+ ${r.join(`
127
+ `)}
128
+
129
+ // Dynamically import all Storyblok components using Vite's glob import
130
+ const modules = import.meta.glob('${s}', { eager: true });
131
+ // Process imported modules into a components object
132
+ const storyblokComponents = {};
133
+
134
+ for (const filePath in modules) {
135
+ // Extract component name from file path (remove extension)
136
+ const fileName = filePath.split('/').pop();
137
+ const componentName = fileName?.replace(/\\.[^/.]+$/, '');
138
+
139
+ if (componentName) {
140
+ // Get the component (handle both default and named exports)
141
+ const component = modules[filePath].default || modules[filePath];
142
+
143
+ // Convert filename to camelCase for Storyblok component naming
144
+ const camelCaseName = toCamelCase(componentName);
145
+ storyblokComponents[camelCaseName] = component;
146
+ }
147
+ }
148
+
149
+ // Manual imports (overwrite auto if same key exists)
150
+ ${r.map((n) => {
151
+ var m;
152
+ const b = (m = n.match(/import\s+(\w+)\s+from/)) == null ? void 0 : m[1];
153
+ return `storyblokComponents['${b}'] = ${b};`;
154
+ }).join(`
155
+ `)}
156
+
157
+ // Add fallback component if enabled
158
+ ${t ? "storyblokComponents['FallbackComponent'] = FallbackComponent;" : ""}
159
+
160
+ // Export the components object for use in Storyblok initialization
161
+ export { storyblokComponents };
162
+ `.trim();
163
+ }
164
+ async function ye(e, t, r, l) {
165
+ if (!r)
166
+ return "";
167
+ if (l) {
168
+ const s = W(
169
+ t,
170
+ l
171
+ );
172
+ if (!await e.resolve(s))
173
+ throw new Error(
174
+ `Custom fallback component could not be found. Does "${s}" exist?`
175
+ );
176
+ return `import FallbackComponent from '${s}';`;
177
+ }
178
+ return "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro';";
179
+ }
180
+ async function he(e, t, r, l) {
181
+ const s = [];
182
+ for await (const [n, b] of Object.entries(t)) {
183
+ const m = W(r, b), u = await e.resolve(m);
184
+ if (u)
185
+ s.push(`import ${Ce(n)} from "${u.id}"`);
186
+ else if (!l)
187
+ throw new Error(
188
+ `Component could not be found for blok "${n}"! Does "${m}" exist?`
189
+ );
190
+ }
191
+ return s;
192
+ }
193
+ function W(e, t) {
194
+ const l = `${H(e)}${H(t)}`;
195
+ return le(l);
196
+ }
197
+ function Oe(e) {
136
198
  const t = {
137
199
  useCustomApi: !1,
138
200
  bridge: !0,
@@ -140,50 +202,56 @@ function Le(e) {
140
202
  enableFallbackComponent: !1,
141
203
  livePreview: !1,
142
204
  ...e
143
- }, s = de(t.bridge);
205
+ }, {
206
+ accessToken: r,
207
+ useCustomApi: l,
208
+ apiOptions: s,
209
+ componentsDir: n,
210
+ customFallbackComponent: b,
211
+ enableFallbackComponent: m,
212
+ components: u,
213
+ bridge: d,
214
+ livePreview: k
215
+ } = t, E = se(t.bridge);
144
216
  return {
145
217
  name: "@storyblok/astro",
146
218
  hooks: {
147
219
  "astro:config:setup": ({
148
- injectScript: n,
149
- updateConfig: l,
150
- addDevToolbarApp: o,
151
- addMiddleware: b,
152
- config: p
220
+ injectScript: L,
221
+ updateConfig: $,
222
+ addDevToolbarApp: g,
223
+ addMiddleware: A,
224
+ config: S
153
225
  }) => {
154
- if (l({
226
+ if ($({
155
227
  vite: {
156
228
  plugins: [
157
- ie(
158
- t.accessToken,
159
- t.useCustomApi,
160
- t.apiOptions
161
- ),
162
- ae(
163
- t.componentsDir,
164
- t.components,
165
- t.enableFallbackComponent,
166
- t.customFallbackComponent
229
+ re(r, l, s),
230
+ me(
231
+ u || {},
232
+ n,
233
+ m,
234
+ b
167
235
  ),
168
- ce(t)
236
+ ne(t)
169
237
  ]
170
238
  }
171
- }), t.livePreview && (p == null ? void 0 : p.output) !== "server")
239
+ }), k && (S == null ? void 0 : S.output) !== "server")
172
240
  throw new Error(
173
241
  "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."
174
242
  );
175
- n(
243
+ L(
176
244
  "page-ssr",
177
245
  `
178
246
  import { storyblokApiInstance } from "virtual:storyblok-init";
179
247
  globalThis.storyblokApiInstance = storyblokApiInstance;
180
248
  `
181
- ), t.bridge && !t.livePreview && n(
249
+ ), d && !k && L(
182
250
  "page",
183
251
  `import { loadStoryblokBridge } from "@storyblok/astro";
184
252
  loadStoryblokBridge().then(() => {
185
253
  const { StoryblokBridge, location } = window;
186
- ${s}
254
+ ${E}
187
255
  storyblokInstance.on(["published", "change"], (event) => {
188
256
  if (!event.slugChanged) {
189
257
  location.reload(true);
@@ -191,54 +259,55 @@ function Le(e) {
191
259
  });
192
260
  });
193
261
  `
194
- ), t.livePreview && (n(
262
+ ), k && (L(
195
263
  "page",
196
264
  `import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
197
265
  loadStoryblokBridge().then(() => {
198
266
  const { StoryblokBridge, location } = window;
199
- ${s}
267
+ ${E}
200
268
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
201
269
  });
202
270
  `
203
- ), b({
271
+ ), A({
204
272
  entrypoint: "@storyblok/astro/middleware.ts",
205
273
  order: "pre"
206
- })), o({
274
+ })), g({
207
275
  id: "storyblok",
208
276
  name: "Storyblok",
209
- icon: Q,
277
+ icon: oe,
210
278
  entrypoint: "@storyblok/astro/toolbarApp.ts"
211
279
  });
212
280
  }
213
281
  }
214
282
  };
215
283
  }
216
- let D;
217
- async function Te(e) {
218
- const { action: t, story: s } = e || {};
219
- if (t === "input" && s) {
220
- const n = async () => {
221
- const o = await pe(s), b = document.body;
222
- if (o.outerHTML === b.outerHTML)
284
+ let j;
285
+ async function He(e) {
286
+ const { action: t, story: r } = e || {};
287
+ if (t === "input" && r) {
288
+ const l = async () => {
289
+ U("storyblok-live-preview-updating", { story: r });
290
+ const n = await ke(r), b = document.body;
291
+ if (n.outerHTML === b.outerHTML)
223
292
  return;
224
- const p = document.querySelector('[data-blok-focused="true"]');
225
- ue(b, o, p), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
293
+ const m = document.querySelector('[data-blok-focused="true"]');
294
+ ge(b, n, m), U("storyblok-live-preview-updated", { story: r });
226
295
  };
227
- clearTimeout(D), D = setTimeout(n, 500);
296
+ clearTimeout(j), j = setTimeout(l, 500);
228
297
  }
229
298
  ["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
230
299
  }
231
- function ue(e, t, s) {
232
- if (s) {
233
- const n = s.getAttribute("data-blok-uid"), l = t.querySelector(
234
- `[data-blok-uid="${n}"]`
300
+ function ge(e, t, r) {
301
+ if (r) {
302
+ const l = r.getAttribute("data-blok-uid"), s = t.querySelector(
303
+ `[data-blok-uid="${l}"]`
235
304
  );
236
- l && (l.setAttribute("data-blok-focused", "true"), s.replaceWith(l));
305
+ s && (s.setAttribute("data-blok-focused", "true"), r.replaceWith(s));
237
306
  } else
238
307
  e.replaceWith(t);
239
308
  }
240
- async function pe(e) {
241
- const s = await (await fetch(location.href, {
309
+ async function ke(e) {
310
+ const r = await (await fetch(location.href, {
242
311
  method: "POST",
243
312
  body: JSON.stringify({
244
313
  ...e,
@@ -248,18 +317,21 @@ async function pe(e) {
248
317
  "Content-Type": "application/json"
249
318
  }
250
319
  })).text();
251
- return new DOMParser().parseFromString(s, "text/html").body;
320
+ return new DOMParser().parseFromString(r, "text/html").body;
252
321
  }
253
- let m = /* @__PURE__ */ function(e) {
322
+ function U(e, t) {
323
+ document.dispatchEvent(new CustomEvent(e, { detail: t }));
324
+ }
325
+ let y = /* @__PURE__ */ function(e) {
254
326
  return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
255
- }({}), C = /* @__PURE__ */ function(e) {
327
+ }({}), v = /* @__PURE__ */ function(e) {
256
328
  return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
257
- }({}), be = /* @__PURE__ */ function(e) {
329
+ }({}), ve = /* @__PURE__ */ function(e) {
258
330
  return e.TEXT = "text", e;
259
- }({}), I = /* @__PURE__ */ function(e) {
331
+ }({}), x = /* @__PURE__ */ function(e) {
260
332
  return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
261
333
  }({});
262
- const ye = [
334
+ const Ee = [
263
335
  "area",
264
336
  "base",
265
337
  "br",
@@ -274,244 +346,262 @@ const ye = [
274
346
  "source",
275
347
  "track",
276
348
  "wbr"
277
- ], fe = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), he = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
278
- function ge(e) {
349
+ ], Le = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), we = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
350
+ function Ae(e) {
279
351
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
280
352
  }
281
- const A = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
282
- function me(e, t) {
353
+ const T = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
354
+ function $e(e, t) {
283
355
  if (!t) return {
284
356
  src: e,
285
357
  attrs: {}
286
358
  };
287
- let s = 0, n = 0;
288
- const l = {}, o = [];
289
- function b(i, u, y, E, L) {
290
- typeof i != "number" || i <= u || i >= y ? console.warn(`[StoryblokRichText] - ${E.charAt(0).toUpperCase() + E.slice(1)} value must be a number between ${u} and ${y} (inclusive)`) : L.push(`${E}(${i})`);
359
+ let r = 0, l = 0;
360
+ const s = {}, n = [];
361
+ function b(u, d, k, E, L) {
362
+ typeof u != "number" || u <= d || u >= k ? console.warn(`[StoryblokRichText] - ${E.charAt(0).toUpperCase() + E.slice(1)} value must be a number between ${d} and ${k} (inclusive)`) : L.push(`${E}(${u})`);
291
363
  }
292
364
  if (typeof t == "object") {
293
- if (typeof t.width == "number" && t.width > 0 ? (l.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (l.height = t.height, n = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (l.loading = t.loading), t.class && (l.class = t.class), t.filters) {
294
- const { filters: i } = t || {}, { blur: u, brightness: y, fill: E, format: L, grayscale: v, quality: T, rotate: $ } = i || {};
295
- u && b(u, 0, 100, "blur", o), T && b(T, 0, 100, "quality", o), y && b(y, 0, 100, "brightness", o), E && o.push(`fill(${E})`), v && o.push("grayscale()"), $ && [
365
+ if (typeof t.width == "number" && t.width > 0 ? (s.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (s.height = t.height, l = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (s.loading = t.loading), t.class && (s.class = t.class), t.filters) {
366
+ const { filters: u } = t || {}, { blur: d, brightness: k, fill: E, format: L, grayscale: $, quality: g, rotate: A } = u || {};
367
+ d && b(d, 0, 100, "blur", n), g && b(g, 0, 100, "quality", n), k && b(k, 0, 100, "brightness", n), E && n.push(`fill(${E})`), $ && n.push("grayscale()"), A && [
296
368
  0,
297
369
  90,
298
370
  180,
299
371
  270
300
- ].includes(t.filters.rotate || 0) && o.push(`rotate(${$})`), L && [
372
+ ].includes(t.filters.rotate || 0) && n.push(`rotate(${A})`), L && [
301
373
  "webp",
302
374
  "png",
303
375
  "jpeg"
304
- ].includes(L) && o.push(`format(${L})`);
376
+ ].includes(L) && n.push(`format(${L})`);
305
377
  }
306
- t.srcset && (l.srcset = t.srcset.map((i) => {
307
- if (typeof i == "number") return `${e}/m/${i}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${i}w`;
308
- if (Array.isArray(i) && i.length === 2) {
309
- const [u, y] = i;
310
- return `${e}/m/${u}x${y}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${u}w`;
378
+ t.srcset && (s.srcset = t.srcset.map((u) => {
379
+ if (typeof u == "number") return `${e}/m/${u}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
380
+ if (Array.isArray(u) && u.length === 2) {
381
+ const [d, k] = u;
382
+ return `${e}/m/${d}x${k}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${d}w`;
311
383
  } else {
312
384
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
313
385
  return;
314
386
  }
315
- }).join(", ")), t.sizes && (l.sizes = t.sizes.join(", "));
387
+ }).join(", ")), t.sizes && (s.sizes = t.sizes.join(", "));
316
388
  }
317
- let p = `${e}/m/`;
318
- return s > 0 && n > 0 && (p = `${p}${s}x${n}/`), o.length > 0 && (p = `${p}filters:${o.join(":")}`), {
319
- src: p,
320
- attrs: l
389
+ let m = `${e}/m/`;
390
+ return r > 0 && l > 0 && (m = `${m}${r}x${l}/`), n.length > 0 && (m = `${m}filters:${n.join(":")}`), {
391
+ src: m,
392
+ attrs: s
321
393
  };
322
394
  }
323
- function U(e, t = {}, s) {
324
- const n = fe(t), l = n ? `${e} ${n}` : e, o = Array.isArray(s) ? s.join("") : s || "";
395
+ function z(e, t = {}, r) {
396
+ const l = Le(t), s = l ? `${e} ${l}` : e, n = Array.isArray(r) ? r.join("") : r || "";
325
397
  if (e) {
326
- if (ye.includes(e)) return `<${l}>`;
327
- } else return o;
328
- return `<${l}>${o}</${e}>`;
398
+ if (Ee.includes(e)) return `<${s}>`;
399
+ } else return n;
400
+ return `<${s}>${n}</${e}>`;
329
401
  }
330
- function ke(e = {}) {
331
- const t = /* @__PURE__ */ new Map(), { renderFn: s = U, textFn: n = ge, resolvers: l = {}, optimizeImages: o = !1, keyedResolvers: b = !1 } = e, p = s !== U, i = (r) => (a, c) => {
332
- const d = a.attrs || {};
333
- return c.render(r, d, a.children || null);
334
- }, u = (r, a) => {
335
- const { src: c, alt: d, title: f, srcset: k, sizes: h } = r.attrs || {};
336
- let g = c, w = {};
337
- if (o) {
338
- const { src: Z, attrs: V } = me(c, o);
339
- g = Z, w = V;
402
+ function Se(e = {}) {
403
+ const t = /* @__PURE__ */ new Map(), { renderFn: r = z, textFn: l = Ae, resolvers: s = {}, optimizeImages: n = !1, keyedResolvers: b = !1 } = e, m = r !== z, u = (o = {}) => {
404
+ const { textAlign: a, class: i, id: c, style: p, ...f } = o, C = [];
405
+ return p && C.push(p.endsWith(";") ? p : `${p};`), a && C.push(`text-align: ${a};`), T({
406
+ ...f,
407
+ class: i,
408
+ id: c,
409
+ ...C.length > 0 ? { style: C.join(" ") } : {}
410
+ });
411
+ }, d = (o) => (a, i) => {
412
+ const c = u(a.attrs);
413
+ return i.render(o, c, a.children || null);
414
+ }, k = (o, a) => {
415
+ const { src: i, alt: c, title: p, srcset: f, sizes: C } = o.attrs || {};
416
+ let w = i, h = {};
417
+ if (n) {
418
+ const { src: ee, attrs: te } = $e(i, n);
419
+ w = ee, h = te;
340
420
  }
341
- const X = {
342
- src: g,
343
- alt: d,
344
- title: f,
345
- srcset: k,
346
- sizes: h,
347
- ...w
421
+ const I = {
422
+ src: w,
423
+ alt: c,
424
+ title: p,
425
+ srcset: f,
426
+ sizes: C,
427
+ ...h
348
428
  };
349
- return a.render("img", A(X));
350
- }, y = (r, a) => {
351
- const { level: c, ...d } = r.attrs || {};
352
- return a.render(`h${c}`, d, r.children);
353
- }, E = (r, a) => {
354
- var c, d, f, k;
355
- const h = a.render("img", {
356
- src: (c = r.attrs) == null ? void 0 : c.fallbackImage,
357
- alt: (d = r.attrs) == null ? void 0 : d.alt,
429
+ return a.render("img", T(I));
430
+ }, E = (o, a) => {
431
+ const { level: i, ...c } = o.attrs || {}, p = u(c);
432
+ return a.render(`h${i}`, p, o.children);
433
+ }, L = (o, a) => {
434
+ var i, c, p, f;
435
+ const C = a.render("img", {
436
+ src: (i = o.attrs) == null ? void 0 : i.fallbackImage,
437
+ alt: (c = o.attrs) == null ? void 0 : c.alt,
358
438
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
359
439
  draggable: "false",
360
440
  loading: "lazy"
361
441
  });
362
442
  return a.render("span", {
363
443
  "data-type": "emoji",
364
- "data-name": (f = r.attrs) == null ? void 0 : f.name,
365
- "data-emoji": (k = r.attrs) == null ? void 0 : k.emoji
366
- }, h);
367
- }, L = (r, a) => a.render("pre", r.attrs || {}, a.render("code", {}, r.children || "")), v = (r, a = !1) => ({ text: c, attrs: d }, f) => {
368
- const { class: k, id: h, ...g } = d || {}, w = a ? {
369
- class: k,
370
- id: h,
371
- style: he(g) || void 0
372
- } : d || {};
373
- return f.render(r, A(w), c);
374
- }, T = (r) => R(r), $ = (r) => {
375
- const { marks: a, ...c } = r;
376
- if ("text" in r) {
377
- if (a) return a.reduce((f, k) => T({
378
- ...k,
379
- text: f
380
- }), T({
381
- ...c,
382
- children: c.children
444
+ "data-name": (p = o.attrs) == null ? void 0 : p.name,
445
+ "data-emoji": (f = o.attrs) == null ? void 0 : f.emoji
446
+ }, C);
447
+ }, $ = (o, a) => a.render("pre", o.attrs || {}, a.render("code", {}, o.children || "")), g = (o, a = !1) => ({ text: i, attrs: c }, p) => {
448
+ const { class: f, id: C, ...w } = c || {}, h = a ? {
449
+ class: f,
450
+ id: C,
451
+ style: we(w) || void 0
452
+ } : c || {};
453
+ return p.render(o, T(h), i);
454
+ }, A = (o) => O(o), S = (o) => {
455
+ const { marks: a, ...i } = o;
456
+ if ("text" in o) {
457
+ if (a) return a.reduce((p, f) => A({
458
+ ...f,
459
+ text: p
460
+ }), A({
461
+ ...i,
462
+ children: i.children
383
463
  }));
384
- const d = r.attrs || {};
464
+ const c = o.attrs || {};
385
465
  if (b) {
386
- const f = t.get("txt") || 0;
387
- t.set("txt", f + 1), d.key = `txt-${f}`;
466
+ const p = t.get("txt") || 0;
467
+ t.set("txt", p + 1), c.key = `txt-${p}`;
388
468
  }
389
- return n(c.text, d);
469
+ return l(i.text, c);
390
470
  }
391
471
  return "";
392
- }, x = (r, a) => {
393
- const { linktype: c, href: d, anchor: f, ...k } = r.attrs || {};
394
- let h = "";
395
- switch (c) {
396
- case I.ASSET:
397
- case I.URL:
398
- h = d;
472
+ }, _ = (o, a) => {
473
+ const { linktype: i, href: c, anchor: p, ...f } = o.attrs || {};
474
+ let C = "";
475
+ switch (i) {
476
+ case x.ASSET:
477
+ case x.URL:
478
+ C = c;
399
479
  break;
400
- case I.EMAIL:
401
- h = `mailto:${d}`;
480
+ case x.EMAIL:
481
+ C = `mailto:${c}`;
402
482
  break;
403
- case I.STORY:
404
- h = d, f && (h = `${h}#${f}`);
483
+ case x.STORY:
484
+ C = c, p && (C = `${C}#${p}`);
405
485
  break;
406
486
  default:
407
- h = d;
487
+ C = c;
408
488
  break;
409
489
  }
410
- const g = { ...k };
411
- return h && (g.href = h), a.render("a", g, r.text);
412
- }, z = (r, a) => {
413
- var c, d;
490
+ const w = { ...f };
491
+ return C && (w.href = C), a.render("a", w, o.text);
492
+ }, J = (o, a) => {
493
+ var i, c;
414
494
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), a.render("span", {
415
- blok: (c = r == null ? void 0 : r.attrs) == null ? void 0 : c.body[0],
416
- id: (d = r.attrs) == null ? void 0 : d.id,
495
+ blok: (i = o == null ? void 0 : o.attrs) == null ? void 0 : i.body[0],
496
+ id: (c = o.attrs) == null ? void 0 : c.id,
417
497
  style: "display: none"
418
498
  });
419
- }, K = (r, a) => {
420
- const c = {}, d = a.render("tbody", {}, r.children);
421
- return a.render("table", c, d);
422
- }, J = (r, a) => {
423
- const c = {};
424
- return a.render("tr", c, r.children);
425
- }, W = (r, a) => {
426
- const { colspan: c, rowspan: d, colwidth: f, backgroundColor: k, ...h } = r.attrs || {}, g = { ...h };
427
- c > 1 && (g.colspan = c), d > 1 && (g.rowspan = d);
428
- const w = [];
429
- return f && w.push(`width: ${f}px;`), k && w.push(`background-color: ${k};`), w.length > 0 && (g.style = w.join(" ")), a.render("td", A(g), r.children);
430
- }, Y = (r, a) => {
431
- const { colspan: c, rowspan: d, colwidth: f, backgroundColor: k, ...h } = r.attrs || {}, g = { ...h };
432
- c > 1 && (g.colspan = c), d > 1 && (g.rowspan = d);
433
- const w = [];
434
- return f && w.push(`width: ${f}px;`), k && w.push(`background-color: ${k};`), w.length > 0 && (g.style = w.join(" ")), a.render("th", A(g), r.children);
435
- }, _ = /* @__PURE__ */ new Map([
436
- [m.DOCUMENT, i("")],
437
- [m.HEADING, y],
438
- [m.PARAGRAPH, i("p")],
439
- [m.UL_LIST, i("ul")],
440
- [m.OL_LIST, i("ol")],
441
- [m.LIST_ITEM, i("li")],
442
- [m.IMAGE, u],
443
- [m.EMOJI, E],
444
- [m.CODE_BLOCK, L],
445
- [m.HR, i("hr")],
446
- [m.BR, i("br")],
447
- [m.QUOTE, i("blockquote")],
448
- [m.COMPONENT, z],
449
- [be.TEXT, $],
450
- [C.LINK, x],
451
- [C.ANCHOR, x],
452
- [C.STYLED, v("span", !0)],
453
- [C.BOLD, v("strong")],
454
- [C.TEXT_STYLE, v("span", !0)],
455
- [C.ITALIC, v("em")],
456
- [C.UNDERLINE, v("u")],
457
- [C.STRIKE, v("s")],
458
- [C.CODE, v("code")],
459
- [C.SUPERSCRIPT, v("sup")],
460
- [C.SUBSCRIPT, v("sub")],
461
- [C.HIGHLIGHT, v("mark")],
462
- [m.TABLE, K],
463
- [m.TABLE_ROW, J],
464
- [m.TABLE_CELL, W],
465
- [m.TABLE_HEADER, Y]
466
- ]), B = new Map([..._, ...Object.entries(l).map(([r, a]) => [r, a])]), q = () => ({
467
- render: (r, a = {}, c) => {
468
- if (b && r) {
469
- const d = t.get(r) || 0;
470
- t.set(r, d + 1), a.key = `${r}-${d}`;
499
+ }, q = (o, a) => {
500
+ const i = u(o.attrs), c = o.children || null;
501
+ return a.render("table", i, a.render("tbody", {}, c));
502
+ }, K = (o, a) => {
503
+ const i = u(o.attrs);
504
+ return a.render("tr", i, o.children);
505
+ }, Y = (o, a) => {
506
+ const { colspan: i, rowspan: c, colwidth: p, backgroundColor: f, textAlign: C, ...w } = o.attrs || {}, h = [];
507
+ p && h.push(`width: ${p}px;`), f && h.push(`background-color: ${f};`), C && h.push(`text-align: ${C};`);
508
+ const I = {
509
+ ...w,
510
+ ...i > 1 ? { colspan: i } : {},
511
+ ...c > 1 ? { rowspan: c } : {},
512
+ ...h.length > 0 ? { style: h.join(" ") } : {}
513
+ };
514
+ return a.render("td", T(I), o.children);
515
+ }, X = (o, a) => {
516
+ const { colspan: i, rowspan: c, colwidth: p, backgroundColor: f, textAlign: C, ...w } = o.attrs || {}, h = [];
517
+ p && h.push(`width: ${p}px;`), f && h.push(`background-color: ${f};`), C && h.push(`text-align: ${C};`);
518
+ const I = {
519
+ ...w,
520
+ ...i > 1 ? { colspan: i } : {},
521
+ ...c > 1 ? { rowspan: c } : {},
522
+ ...h.length > 0 ? { style: h.join(" ") } : {}
523
+ };
524
+ return a.render("th", T(I), o.children);
525
+ }, N = /* @__PURE__ */ new Map([
526
+ [y.DOCUMENT, d("")],
527
+ [y.HEADING, E],
528
+ [y.PARAGRAPH, d("p")],
529
+ [y.UL_LIST, d("ul")],
530
+ [y.OL_LIST, d("ol")],
531
+ [y.LIST_ITEM, d("li")],
532
+ [y.IMAGE, k],
533
+ [y.EMOJI, L],
534
+ [y.CODE_BLOCK, $],
535
+ [y.HR, d("hr")],
536
+ [y.BR, d("br")],
537
+ [y.QUOTE, d("blockquote")],
538
+ [y.COMPONENT, J],
539
+ [ve.TEXT, S],
540
+ [v.LINK, _],
541
+ [v.ANCHOR, _],
542
+ [v.STYLED, g("span", !0)],
543
+ [v.BOLD, g("strong")],
544
+ [v.TEXT_STYLE, g("span", !0)],
545
+ [v.ITALIC, g("em")],
546
+ [v.UNDERLINE, g("u")],
547
+ [v.STRIKE, g("s")],
548
+ [v.CODE, g("code")],
549
+ [v.SUPERSCRIPT, g("sup")],
550
+ [v.SUBSCRIPT, g("sub")],
551
+ [v.HIGHLIGHT, g("mark")],
552
+ [y.TABLE, q],
553
+ [y.TABLE_ROW, K],
554
+ [y.TABLE_CELL, Y],
555
+ [y.TABLE_HEADER, X]
556
+ ]), P = new Map([...N, ...Object.entries(s).map(([o, a]) => [o, a])]), Q = () => ({
557
+ render: (o, a = {}, i) => {
558
+ if (b && o) {
559
+ const c = t.get(o) || 0;
560
+ t.set(o, c + 1), a.key = `${o}-${c}`;
471
561
  }
472
- return s(r, a, c);
562
+ return r(o, a, i);
473
563
  },
474
- originalResolvers: _,
475
- mergedResolvers: B
564
+ originalResolvers: N,
565
+ mergedResolvers: P
476
566
  });
477
- function S(r) {
478
- const a = B.get(r.type);
567
+ function R(o) {
568
+ const a = P.get(o.type);
479
569
  if (!a)
480
- return console.error("<Storyblok>", `No resolver found for node type ${r.type}`), "";
481
- const c = q();
482
- if (r.type === "text") return a(r, c);
483
- const d = r.content ? r.content.map(R) : void 0;
570
+ return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
571
+ const i = Q();
572
+ if (o.type === "text") return a(o, i);
573
+ const c = o.content ? o.content.map(O) : void 0;
484
574
  return a({
485
- ...r,
486
- children: d
487
- }, c);
575
+ ...o,
576
+ children: c
577
+ }, i);
488
578
  }
489
- function R(r) {
490
- return r.type === "doc" ? p ? r.content.map(S) : r.content.map(S).join("") : Array.isArray(r) ? r.map(S) : S(r);
579
+ function O(o) {
580
+ return o.type === "doc" ? m ? o.content.map(R) : o.content.map(R).join("") : Array.isArray(o) ? o.map(R) : R(o);
491
581
  }
492
- return { render: R };
582
+ return { render: O };
493
583
  }
494
- let H = !1;
495
- const F = [], we = (e) => new Promise((t, s) => {
584
+ let Z = !1;
585
+ const F = [], Ie = (e) => new Promise((t, r) => {
496
586
  if (typeof window > "u") {
497
- s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
587
+ r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
498
588
  return;
499
589
  }
500
- if (window.storyblokRegisterEvent = (l) => {
590
+ if (window.storyblokRegisterEvent = (s) => {
501
591
  if (!window.location.search.includes("_storyblok")) {
502
592
  console.warn("You are not in Draft Mode or in the Visual Editor.");
503
593
  return;
504
594
  }
505
- H ? l() : F.push(l);
595
+ Z ? s() : F.push(s);
506
596
  }, document.getElementById("storyblok-javascript-bridge")) {
507
597
  t(void 0);
508
598
  return;
509
599
  }
510
- const n = document.createElement("script");
511
- n.async = !0, n.src = e, n.id = "storyblok-javascript-bridge", n.onerror = (l) => s(l), n.onload = (l) => {
512
- F.forEach((o) => o()), H = !0, t(l);
513
- }, document.getElementsByTagName("head")[0].appendChild(n);
514
- }), $e = (e) => {
600
+ const l = document.createElement("script");
601
+ l.async = !0, l.src = e, l.id = "storyblok-javascript-bridge", l.onerror = (s) => r(s), l.onload = (s) => {
602
+ F.forEach((n) => n()), Z = !0, t(s);
603
+ }, document.getElementsByTagName("head")[0].appendChild(l);
604
+ }), Me = (e) => {
515
605
  if (typeof e != "object" || typeof e._editable > "u")
516
606
  return {};
517
607
  try {
@@ -526,19 +616,19 @@ const F = [], we = (e) => new Promise((t, s) => {
526
616
  return {};
527
617
  }
528
618
  };
529
- let ve = "https://app.storyblok.com/f/storyblok-v2-latest.js";
530
- function Se(e, t) {
531
- return ke(t).render(e);
619
+ let Te = "https://app.storyblok.com/f/storyblok-v2-latest.js";
620
+ function _e(e, t) {
621
+ return Se(t).render(e);
532
622
  }
533
- const Ie = () => we(ve);
623
+ const Ne = () => Ie(Te);
534
624
  export {
535
- Ee as getLiveStory,
536
- Te as handleStoryblokMessage,
537
- Ie as loadStoryblokBridge,
538
- Se as renderRichText,
539
- ke as richTextResolver,
540
- Le as storyblok,
541
- $e as storyblokEditable,
542
- j as toCamelCase,
543
- Ce as useStoryblokApi
625
+ xe as getLiveStory,
626
+ He as handleStoryblokMessage,
627
+ Ne as loadStoryblokBridge,
628
+ _e as renderRichText,
629
+ Se as richTextResolver,
630
+ Oe as storyblok,
631
+ Me as storyblokEditable,
632
+ Ce as toCamelCase,
633
+ Re as useStoryblokApi
544
634
  };