@storyblok/astro 7.2.3 → 7.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const te = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
1
+ const Q = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
2
  <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
3
  <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
4
4
  <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
@@ -7,74 +7,74 @@ const te = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xm
7
7
  </g>
8
8
  </g>
9
9
  </g>
10
- </svg>`, re = /[\p{Lu}]/u, oe = /[\p{Ll}]/u, M = /^[\p{Lu}](?![\p{Lu}])/gu, G = /([\p{Alpha}\p{N}_]|$)/u, O = /[_.\- ]+/, ne = new RegExp("^" + O.source), P = new RegExp(O.source + G.source, "gu"), j = new RegExp("\\d+" + G.source, "gu"), se = (e, t, r, s) => {
11
- let a = !1, n = !1, h = !1, p = !1;
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
12
  for (let i = 0; i < e.length; i++) {
13
- const d = e[i];
14
- p = i > 2 ? e[i - 3] === "-" : !0, a && re.test(d) ? (e = e.slice(0, i) + "-" + e.slice(i), a = !1, h = n, n = !0, i++) : n && h && oe.test(d) && (!p || s) ? (e = e.slice(0, i - 1) + "-" + e.slice(i - 1), h = n, n = !1, a = !0) : (a = t(d) === d && r(d) !== d, h = n, n = r(d) === d && t(d) !== d);
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
15
  }
16
16
  return e;
17
- }, ae = (e, t) => (M.lastIndex = 0, e.replaceAll(M, (r) => t(r))), le = (e, t) => (P.lastIndex = 0, j.lastIndex = 0, e.replaceAll(j, (r, s, a) => ["_", "-"].includes(e.charAt(a + r.length)) ? r : t(r)).replaceAll(P, (r, s) => t(s)));
18
- function ie(e, t) {
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
19
  if (!(typeof e == "string" || Array.isArray(e)))
20
20
  throw new TypeError("Expected the input to be `string | string[]`");
21
21
  if (t = {
22
22
  pascalCase: !1,
23
23
  preserveConsecutiveUppercase: !1,
24
24
  ...t
25
- }, Array.isArray(e) ? e = e.map((n) => n.trim()).filter((n) => n.length).join("-") : e = e.trim(), e.length === 0)
25
+ }, Array.isArray(e) ? e = e.map((o) => o.trim()).filter((o) => o.length).join("-") : e = e.trim(), e.length === 0)
26
26
  return "";
27
- const r = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), s = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
28
- return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? s(e) : r(e) : (e !== r(e) && (e = se(e, r, s, t.preserveConsecutiveUppercase)), e = e.replace(ne, ""), e = t.preserveConsecutiveUppercase ? ae(e, r) : r(e), t.pascalCase && (e = s(e.charAt(0)) + e.slice(1)), le(e, s));
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
29
  }
30
- function D(e) {
31
- return ie(e);
30
+ function j(e) {
31
+ return le(e);
32
32
  }
33
- function ce(e, t = {}, r, s) {
34
- const a = "virtual:storyblok-components", n = `\0${a}`;
33
+ function ae(e, t = {}, s, n) {
34
+ const l = "virtual:storyblok-components", o = `\0${l}`;
35
35
  return {
36
36
  name: "vite-plugin-storyblok-components",
37
- async resolveId(h) {
38
- if (h === a)
39
- return n;
37
+ async resolveId(b) {
38
+ if (b === l)
39
+ return o;
40
40
  },
41
- async load(h) {
42
- if (h === n) {
41
+ async load(b) {
42
+ if (b === o) {
43
43
  const p = [], i = [];
44
- for await (const [f, v] of Object.entries(t)) {
45
- const A = await this.resolve(
46
- `/${e}/${v}.astro`
44
+ for await (const [y, E] of Object.entries(t)) {
45
+ const L = await this.resolve(
46
+ `/${e}/${E}.astro`
47
47
  );
48
- if (A)
49
- p.push(`import ${D(f)} from "${A.id}"`);
50
- else if (r)
51
- i.push(f);
48
+ if (L)
49
+ p.push(`import ${j(y)} from "${L.id}"`);
50
+ else if (s)
51
+ i.push(y);
52
52
  else
53
53
  throw new Error(
54
- `Component could not be found for blok "${f}"! Does "${`/${e}/${v}`}.astro" exist?`
54
+ `Component could not be found for blok "${y}"! Does "${`/${e}/${E}`}.astro" exist?`
55
55
  );
56
56
  }
57
- let d = "";
58
- if (r)
59
- if (d = ",FallbackComponent", s) {
60
- const f = await this.resolve(
61
- `/${e}/${s}.astro`
57
+ let u = "";
58
+ if (s)
59
+ if (u = ",FallbackComponent", n) {
60
+ const y = await this.resolve(
61
+ `/${e}/${n}.astro`
62
62
  );
63
- if (!f)
63
+ if (!y)
64
64
  throw new Error(
65
- `Custom fallback component could not be found. Does "${`/${e}/${s}`}.astro" exist?`
65
+ `Custom fallback component could not be found. Does "${`/${e}/${n}`}.astro" exist?`
66
66
  );
67
67
  p.push(
68
- `import FallbackComponent from "${f.id}"`
68
+ `import FallbackComponent from "${y.id}"`
69
69
  );
70
70
  } else
71
71
  p.push(
72
72
  "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
73
73
  );
74
74
  if (Object.values(t).length)
75
- return `${p.join(";")};export default {${Object.keys(t).filter((f) => !i.includes(f)).map((f) => D(f)).join(",")}${d}}`;
76
- if (r)
77
- return `${p[0]}; export default {${d.replace(",", "")}}`;
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
78
  throw new Error(
79
79
  `Currently, no Storyblok components are registered in astro.config.mjs.
80
80
  Please register your components or enable the fallback component.
@@ -84,55 +84,55 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
84
84
  }
85
85
  };
86
86
  }
87
- function ue(e, t, r) {
88
- const s = "virtual:storyblok-init", a = `\0${s}`;
87
+ function ie(e, t, s) {
88
+ const n = "virtual:storyblok-init", l = `\0${n}`;
89
89
  return {
90
90
  name: "vite-plugin-storyblok-init",
91
- async resolveId(n) {
92
- if (n === s)
93
- return a;
91
+ async resolveId(o) {
92
+ if (o === n)
93
+ return l;
94
94
  },
95
- async load(n) {
96
- if (n === a)
95
+ async load(o) {
96
+ if (o === l)
97
97
  return `
98
98
  import { storyblokInit, apiPlugin } from "@storyblok/js";
99
99
  const { storyblokApi } = storyblokInit({
100
100
  accessToken: "${e}",
101
101
  use: ${t ? "[]" : "[apiPlugin]"},
102
- apiOptions: ${JSON.stringify(r)},
102
+ apiOptions: ${JSON.stringify(s)},
103
103
  });
104
104
  export const storyblokApiInstance = storyblokApi;
105
105
  `;
106
106
  }
107
107
  };
108
108
  }
109
- function de(e) {
110
- const t = "virtual:storyblok-options", r = `\0${t}`;
109
+ function ce(e) {
110
+ const t = "virtual:storyblok-options", s = `\0${t}`;
111
111
  return {
112
112
  name: "vite-plugin-storyblok-options",
113
- async resolveId(s) {
114
- if (s === t)
115
- return r;
113
+ async resolveId(n) {
114
+ if (n === t)
115
+ return s;
116
116
  },
117
- async load(s) {
118
- if (s === r)
117
+ async load(n) {
118
+ if (n === s)
119
119
  return `export default ${JSON.stringify(e)}`;
120
120
  }
121
121
  };
122
122
  }
123
- function _e() {
123
+ function Ce() {
124
124
  if (!(globalThis != null && globalThis.storyblokApiInstance))
125
125
  throw new Error("storyblokApiInstance has not been initialized correctly");
126
126
  return globalThis.storyblokApiInstance;
127
127
  }
128
- async function Be(e) {
128
+ async function Ee(e) {
129
129
  let t = null;
130
130
  return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data), t;
131
131
  }
132
- function pe(e) {
132
+ function de(e) {
133
133
  return typeof e == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});` : "const storyblokInstance = new StoryblokBridge();";
134
134
  }
135
- function Ne(e) {
135
+ function Le(e) {
136
136
  const t = {
137
137
  useCustomApi: !1,
138
138
  bridge: !0,
@@ -140,50 +140,50 @@ function Ne(e) {
140
140
  enableFallbackComponent: !1,
141
141
  livePreview: !1,
142
142
  ...e
143
- }, r = pe(t.bridge);
143
+ }, s = de(t.bridge);
144
144
  return {
145
145
  name: "@storyblok/astro",
146
146
  hooks: {
147
147
  "astro:config:setup": ({
148
- injectScript: s,
149
- updateConfig: a,
150
- addDevToolbarApp: n,
151
- addMiddleware: h,
148
+ injectScript: n,
149
+ updateConfig: l,
150
+ addDevToolbarApp: o,
151
+ addMiddleware: b,
152
152
  config: p
153
153
  }) => {
154
- if (a({
154
+ if (l({
155
155
  vite: {
156
156
  plugins: [
157
- ue(
157
+ ie(
158
158
  t.accessToken,
159
159
  t.useCustomApi,
160
160
  t.apiOptions
161
161
  ),
162
- ce(
162
+ ae(
163
163
  t.componentsDir,
164
164
  t.components,
165
165
  t.enableFallbackComponent,
166
166
  t.customFallbackComponent
167
167
  ),
168
- de(t)
168
+ ce(t)
169
169
  ]
170
170
  }
171
171
  }), t.livePreview && (p == null ? void 0 : p.output) !== "server")
172
172
  throw new Error(
173
173
  "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
174
  );
175
- s(
175
+ n(
176
176
  "page-ssr",
177
177
  `
178
178
  import { storyblokApiInstance } from "virtual:storyblok-init";
179
179
  globalThis.storyblokApiInstance = storyblokApiInstance;
180
180
  `
181
- ), t.bridge && !t.livePreview && s(
181
+ ), t.bridge && !t.livePreview && n(
182
182
  "page",
183
183
  `import { loadStoryblokBridge } from "@storyblok/astro";
184
184
  loadStoryblokBridge().then(() => {
185
185
  const { StoryblokBridge, location } = window;
186
- ${r}
186
+ ${s}
187
187
  storyblokInstance.on(["published", "change"], (event) => {
188
188
  if (!event.slugChanged) {
189
189
  location.reload(true);
@@ -191,54 +191,54 @@ function Ne(e) {
191
191
  });
192
192
  });
193
193
  `
194
- ), t.livePreview && (s(
194
+ ), t.livePreview && (n(
195
195
  "page",
196
196
  `import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
197
197
  loadStoryblokBridge().then(() => {
198
198
  const { StoryblokBridge, location } = window;
199
- ${r}
199
+ ${s}
200
200
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
201
201
  });
202
202
  `
203
- ), h({
203
+ ), b({
204
204
  entrypoint: "@storyblok/astro/middleware.ts",
205
205
  order: "pre"
206
- })), n({
206
+ })), o({
207
207
  id: "storyblok",
208
208
  name: "Storyblok",
209
- icon: te,
209
+ icon: Q,
210
210
  entrypoint: "@storyblok/astro/toolbarApp.ts"
211
211
  });
212
212
  }
213
213
  }
214
214
  };
215
215
  }
216
- let U;
217
- async function Me(e) {
218
- const { action: t, story: r } = e || {};
219
- if (t === "input" && r) {
220
- const s = async () => {
221
- const n = await fe(r), h = document.body;
222
- if (n.outerHTML === h.outerHTML)
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)
223
223
  return;
224
224
  const p = document.querySelector('[data-blok-focused="true"]');
225
- he(h, n, p), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
225
+ ue(b, o, p), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
226
226
  };
227
- clearTimeout(U), U = setTimeout(s, 500);
227
+ clearTimeout(D), D = setTimeout(n, 500);
228
228
  }
229
229
  ["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
230
230
  }
231
- function he(e, t, r) {
232
- if (r) {
233
- const s = r.getAttribute("data-blok-uid"), a = t.querySelector(
234
- `[data-blok-uid="${s}"]`
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}"]`
235
235
  );
236
- a && (a.setAttribute("data-blok-focused", "true"), r.replaceWith(a));
236
+ l && (l.setAttribute("data-blok-focused", "true"), s.replaceWith(l));
237
237
  } else
238
238
  e.replaceWith(t);
239
239
  }
240
- async function fe(e) {
241
- const r = await (await fetch(location.href, {
240
+ async function pe(e) {
241
+ const s = await (await fetch(location.href, {
242
242
  method: "POST",
243
243
  body: JSON.stringify({
244
244
  ...e,
@@ -248,306 +248,270 @@ async function fe(e) {
248
248
  "Content-Type": "application/json"
249
249
  }
250
250
  })).text();
251
- return new DOMParser().parseFromString(r, "text/html").body;
252
- }
253
- function I(e, t, r) {
254
- this.type = e, this.tag = t, this.attrs = null, this.map = null, this.nesting = r, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
251
+ return new DOMParser().parseFromString(s, "text/html").body;
255
252
  }
256
- I.prototype.attrIndex = function(e) {
257
- if (!this.attrs)
258
- return -1;
259
- const t = this.attrs;
260
- for (let r = 0, s = t.length; r < s; r++)
261
- if (t[r][0] === e)
262
- return r;
263
- return -1;
264
- };
265
- I.prototype.attrPush = function(e) {
266
- this.attrs ? this.attrs.push(e) : this.attrs = [e];
267
- };
268
- I.prototype.attrSet = function(e, t) {
269
- const r = this.attrIndex(e), s = [e, t];
270
- r < 0 ? this.attrPush(s) : this.attrs[r] = s;
271
- };
272
- I.prototype.attrGet = function(e) {
273
- const t = this.attrIndex(e);
274
- let r = null;
275
- return t >= 0 && (r = this.attrs[t][1]), r;
276
- };
277
- I.prototype.attrJoin = function(e, t) {
278
- const r = this.attrIndex(e);
279
- r < 0 ? this.attrPush([e, t]) : this.attrs[r][1] = this.attrs[r][1] + " " + t;
280
- };
281
- const be = "[a-zA-Z_:][a-zA-Z0-9:._-]*", ye = "[^\"'=<>`\\x00-\\x20]+", ge = "'[^']*'", ke = '"[^"]*"', me = "(?:" + ye + "|" + ge + "|" + ke + ")", we = "(?:\\s+" + be + "(?:\\s*=\\s*" + me + ")?)", Ce = "<[A-Za-z][A-Za-z0-9\\-]*" + we + "*\\s*\\/?>", Ee = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>", ve = new RegExp("^(?:" + Ce + "|" + Ee + ")");
282
- new RegExp(ve.source + "\\s*$");
283
- const Z = [];
284
- for (let e = 0; e < 256; e++)
285
- Z.push(0);
286
- "\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(e) {
287
- Z[e.charCodeAt(0)] = 1;
288
- });
289
- let k = /* @__PURE__ */ function(e) {
253
+ let m = /* @__PURE__ */ function(e) {
290
254
  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;
291
- }({}), E = /* @__PURE__ */ function(e) {
255
+ }({}), C = /* @__PURE__ */ function(e) {
292
256
  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;
293
- }({}), Ae = /* @__PURE__ */ function(e) {
257
+ }({}), be = /* @__PURE__ */ function(e) {
294
258
  return e.TEXT = "text", e;
295
- }({}), T = /* @__PURE__ */ function(e) {
259
+ }({}), I = /* @__PURE__ */ function(e) {
296
260
  return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
297
261
  }({});
298
- function Le(e, t) {
262
+ const ye = [
263
+ "area",
264
+ "base",
265
+ "br",
266
+ "col",
267
+ "embed",
268
+ "hr",
269
+ "img",
270
+ "input",
271
+ "link",
272
+ "meta",
273
+ "param",
274
+ "source",
275
+ "track",
276
+ "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) {
279
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
280
+ }
281
+ const A = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
282
+ function me(e, t) {
299
283
  if (!t) return {
300
284
  src: e,
301
285
  attrs: {}
302
286
  };
303
- let r = 0, s = 0;
304
- const a = {}, n = [];
305
- function h(i, d, f, v, A) {
306
- typeof i != "number" || i <= d || i >= f ? console.warn(`[StoryblokRichText] - ${v.charAt(0).toUpperCase() + v.slice(1)} value must be a number between ${d} and ${f} (inclusive)`) : A.push(`${v}(${i})`);
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})`);
307
291
  }
308
292
  if (typeof t == "object") {
309
- if (typeof t.width == "number" && t.width > 0 ? (a.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 ? (a.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (a.loading = t.loading), t.class && (a.class = t.class), t.filters) {
310
- const { filters: i } = t || {}, { blur: d, brightness: f, fill: v, format: A, grayscale: C, quality: L, rotate: $ } = i || {};
311
- d && h(d, 0, 100, "blur", n), L && h(L, 0, 100, "quality", n), f && h(f, 0, 100, "brightness", n), v && n.push(`fill(${v})`), C && n.push("grayscale()"), $ && [
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()"), $ && [
312
296
  0,
313
297
  90,
314
298
  180,
315
299
  270
316
- ].includes(t.filters.rotate || 0) && n.push(`rotate(${$})`), A && [
300
+ ].includes(t.filters.rotate || 0) && o.push(`rotate(${$})`), L && [
317
301
  "webp",
318
302
  "png",
319
303
  "jpeg"
320
- ].includes(A) && n.push(`format(${A})`);
304
+ ].includes(L) && o.push(`format(${L})`);
321
305
  }
322
- t.srcset && (a.srcset = t.srcset.map((i) => {
323
- if (typeof i == "number") return `${e}/m/${i}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${i}w`;
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`;
324
308
  if (Array.isArray(i) && i.length === 2) {
325
- const [d, f] = i;
326
- return `${e}/m/${d}x${f}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${d}w`;
309
+ const [u, y] = i;
310
+ return `${e}/m/${u}x${y}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${u}w`;
327
311
  } else {
328
312
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
329
313
  return;
330
314
  }
331
- }).join(", ")), t.sizes && (a.sizes = t.sizes.join(", "));
315
+ }).join(", ")), t.sizes && (l.sizes = t.sizes.join(", "));
332
316
  }
333
317
  let p = `${e}/m/`;
334
- return r > 0 && s > 0 && (p = `${p}${r}x${s}/`), n.length > 0 && (p = `${p}filters:${n.join(":")}`), {
318
+ return s > 0 && n > 0 && (p = `${p}${s}x${n}/`), o.length > 0 && (p = `${p}filters:${o.join(":")}`), {
335
319
  src: p,
336
- attrs: a
320
+ attrs: l
337
321
  };
338
322
  }
339
- const Ie = [
340
- "area",
341
- "base",
342
- "br",
343
- "col",
344
- "embed",
345
- "hr",
346
- "img",
347
- "input",
348
- "link",
349
- "meta",
350
- "param",
351
- "source",
352
- "track",
353
- "wbr"
354
- ], $e = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), Se = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
355
- function Te(e) {
356
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
357
- }
358
- const R = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
359
- function H(e, t = {}, r) {
360
- const s = $e(t), a = s ? `${e} ${s}` : e, n = Array.isArray(r) ? r.join("") : r || "";
323
+ function U(e, t = {}, s) {
324
+ const n = fe(t), l = n ? `${e} ${n}` : e, o = Array.isArray(s) ? s.join("") : s || "";
361
325
  if (e) {
362
- if (Ie.includes(e)) return `<${a}>`;
363
- } else return n;
364
- return `<${a}>${n}</${e}>`;
326
+ if (ye.includes(e)) return `<${l}>`;
327
+ } else return o;
328
+ return `<${l}>${o}</${e}>`;
365
329
  }
366
- function Re(e = {}) {
367
- const t = /* @__PURE__ */ new Map(), { renderFn: r = H, textFn: s = Te, resolvers: a = {}, optimizeImages: n = !1, keyedResolvers: h = !1 } = e, p = r !== H, i = (o) => (l, c) => {
368
- const u = l.attrs || {};
369
- return c.render(o, u, l.children || null);
370
- }, d = (o, l) => {
371
- const { src: c, alt: u, title: b, srcset: m, sizes: y } = o.attrs || {};
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 || {};
372
336
  let g = c, w = {};
373
- if (n) {
374
- const { src: Q, attrs: ee } = Le(c, n);
375
- g = Q, w = ee;
337
+ if (o) {
338
+ const { src: Z, attrs: V } = me(c, o);
339
+ g = Z, w = V;
376
340
  }
377
341
  const X = {
378
342
  src: g,
379
- alt: u,
380
- title: b,
381
- srcset: m,
382
- sizes: y,
343
+ alt: d,
344
+ title: f,
345
+ srcset: k,
346
+ sizes: h,
383
347
  ...w
384
348
  };
385
- return l.render("img", R(X));
386
- }, f = (o, l) => {
387
- const { level: c, ...u } = o.attrs || {};
388
- return l.render(`h${c}`, u, o.children);
389
- }, v = (o, l) => {
390
- var c, u, b, m;
391
- const y = l.render("img", {
392
- src: (c = o.attrs) == null ? void 0 : c.fallbackImage,
393
- alt: (u = o.attrs) == null ? void 0 : u.alt,
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,
394
358
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
395
359
  draggable: "false",
396
360
  loading: "lazy"
397
361
  });
398
- return l.render("span", {
362
+ return a.render("span", {
399
363
  "data-type": "emoji",
400
- "data-name": (b = o.attrs) == null ? void 0 : b.name,
401
- "data-emoji": (m = o.attrs) == null ? void 0 : m.emoji
402
- }, y);
403
- }, A = (o, l) => l.render("pre", o.attrs || {}, l.render("code", {}, o.children || "")), C = (o, l = !1) => ({ text: c, attrs: u }, b) => {
404
- const { class: m, id: y, ...g } = u || {}, w = l ? {
405
- class: m,
406
- id: y,
407
- style: Se(g) || void 0
408
- } : u || {};
409
- return b.render(o, R(w), c);
410
- }, L = (o) => x(o), $ = (o) => {
411
- const { marks: l, ...c } = o;
412
- if ("text" in o) {
413
- if (l) return l.reduce((b, m) => L({
414
- ...m,
415
- text: b
416
- }), L({
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({
417
381
  ...c,
418
382
  children: c.children
419
383
  }));
420
- const u = o.attrs || {};
421
- if (h) {
422
- const b = t.get("txt") || 0;
423
- t.set("txt", b + 1), u.key = `txt-${b}`;
384
+ const d = r.attrs || {};
385
+ if (b) {
386
+ const f = t.get("txt") || 0;
387
+ t.set("txt", f + 1), d.key = `txt-${f}`;
424
388
  }
425
- return s(c.text, u);
389
+ return n(c.text, d);
426
390
  }
427
391
  return "";
428
- }, _ = (o, l) => {
429
- const { linktype: c, href: u, anchor: b, ...m } = o.attrs || {};
430
- let y = "";
392
+ }, x = (r, a) => {
393
+ const { linktype: c, href: d, anchor: f, ...k } = r.attrs || {};
394
+ let h = "";
431
395
  switch (c) {
432
- case T.ASSET:
433
- case T.URL:
434
- y = u;
396
+ case I.ASSET:
397
+ case I.URL:
398
+ h = d;
435
399
  break;
436
- case T.EMAIL:
437
- y = `mailto:${u}`;
400
+ case I.EMAIL:
401
+ h = `mailto:${d}`;
438
402
  break;
439
- case T.STORY:
440
- y = u, b && (y = `${y}#${b}`);
403
+ case I.STORY:
404
+ h = d, f && (h = `${h}#${f}`);
441
405
  break;
442
406
  default:
443
- y = u;
407
+ h = d;
444
408
  break;
445
409
  }
446
- const g = { ...m };
447
- return y && (g.href = y), l.render("a", g, o.text);
448
- }, J = (o, l) => {
449
- var c, u;
450
- return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), l.render("span", {
451
- blok: (c = o == null ? void 0 : o.attrs) == null ? void 0 : c.body[0],
452
- id: (u = o.attrs) == null ? void 0 : u.id,
410
+ const g = { ...k };
411
+ return h && (g.href = h), a.render("a", g, r.text);
412
+ }, z = (r, a) => {
413
+ var c, d;
414
+ 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,
453
417
  style: "display: none"
454
418
  });
455
- }, K = (o, l) => {
456
- const c = {}, u = l.render("tbody", {}, o.children);
457
- return l.render("table", c, u);
458
- }, W = (o, l) => {
419
+ }, K = (r, a) => {
420
+ const c = {}, d = a.render("tbody", {}, r.children);
421
+ return a.render("table", c, d);
422
+ }, J = (r, a) => {
459
423
  const c = {};
460
- return l.render("tr", c, o.children);
461
- }, Y = (o, l) => {
462
- const { colspan: c, rowspan: u, colwidth: b, backgroundColor: m, ...y } = o.attrs || {}, g = { ...y };
463
- c > 1 && (g.colspan = c), u > 1 && (g.rowspan = u);
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);
464
428
  const w = [];
465
- return b && w.push(`width: ${b}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (g.style = w.join(" ")), l.render("td", R(g), o.children);
466
- }, q = (o, l) => {
467
- const { colspan: c, rowspan: u, colwidth: b, backgroundColor: m, ...y } = o.attrs || {}, g = { ...y };
468
- c > 1 && (g.colspan = c), u > 1 && (g.rowspan = u);
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);
469
433
  const w = [];
470
- return b && w.push(`width: ${b}px;`), m && w.push(`background-color: ${m};`), w.length > 0 && (g.style = w.join(" ")), l.render("th", R(g), o.children);
471
- }, B = /* @__PURE__ */ new Map([
472
- [k.DOCUMENT, i("")],
473
- [k.HEADING, f],
474
- [k.PARAGRAPH, i("p")],
475
- [k.UL_LIST, i("ul")],
476
- [k.OL_LIST, i("ol")],
477
- [k.LIST_ITEM, i("li")],
478
- [k.IMAGE, d],
479
- [k.EMOJI, v],
480
- [k.CODE_BLOCK, A],
481
- [k.HR, i("hr")],
482
- [k.BR, i("br")],
483
- [k.QUOTE, i("blockquote")],
484
- [k.COMPONENT, J],
485
- [Ae.TEXT, $],
486
- [E.LINK, _],
487
- [E.ANCHOR, _],
488
- [E.STYLED, C("span", !0)],
489
- [E.BOLD, C("strong")],
490
- [E.TEXT_STYLE, C("span", !0)],
491
- [E.ITALIC, C("em")],
492
- [E.UNDERLINE, C("u")],
493
- [E.STRIKE, C("s")],
494
- [E.CODE, C("code")],
495
- [E.SUPERSCRIPT, C("sup")],
496
- [E.SUBSCRIPT, C("sub")],
497
- [E.HIGHLIGHT, C("mark")],
498
- [k.TABLE, K],
499
- [k.TABLE_ROW, W],
500
- [k.TABLE_CELL, Y],
501
- [k.TABLE_HEADER, q]
502
- ]), N = new Map([...B, ...Object.entries(a).map(([o, l]) => [o, l])]), V = () => ({
503
- render: (o, l = {}, c) => {
504
- if (h && o) {
505
- const u = t.get(o) || 0;
506
- t.set(o, u + 1), l.key = `${o}-${u}`;
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}`;
507
471
  }
508
- return r(o, l, c);
472
+ return s(r, a, c);
509
473
  },
510
- originalResolvers: B,
511
- mergedResolvers: N
474
+ originalResolvers: _,
475
+ mergedResolvers: B
512
476
  });
513
- function S(o) {
514
- const l = N.get(o.type);
515
- if (!l)
516
- return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
517
- const c = V();
518
- if (o.type === "text") return l(o, c);
519
- const u = o.content ? o.content.map(x) : void 0;
520
- return l({
521
- ...o,
522
- children: u
477
+ function S(r) {
478
+ const a = B.get(r.type);
479
+ 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;
484
+ return a({
485
+ ...r,
486
+ children: d
523
487
  }, c);
524
488
  }
525
- function x(o) {
526
- return o.type === "doc" ? p ? o.content.map(S) : o.content.map(S).join("") : Array.isArray(o) ? o.map(S) : S(o);
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);
527
491
  }
528
- return { render: x };
492
+ return { render: R };
529
493
  }
530
- let z = !1;
531
- const F = [], xe = (e) => new Promise((t, r) => {
494
+ let H = !1;
495
+ const F = [], we = (e) => new Promise((t, s) => {
532
496
  if (typeof window > "u") {
533
- r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
497
+ s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
534
498
  return;
535
499
  }
536
- if (window.storyblokRegisterEvent = (a) => {
500
+ if (window.storyblokRegisterEvent = (l) => {
537
501
  if (!window.location.search.includes("_storyblok")) {
538
502
  console.warn("You are not in Draft Mode or in the Visual Editor.");
539
503
  return;
540
504
  }
541
- z ? a() : F.push(a);
505
+ H ? l() : F.push(l);
542
506
  }, document.getElementById("storyblok-javascript-bridge")) {
543
507
  t(void 0);
544
508
  return;
545
509
  }
546
- const s = document.createElement("script");
547
- s.async = !0, s.src = e, s.id = "storyblok-javascript-bridge", s.onerror = (a) => r(a), s.onload = (a) => {
548
- F.forEach((n) => n()), z = !0, t(a);
549
- }, document.getElementsByTagName("head")[0].appendChild(s);
550
- }), Pe = (e) => {
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) => {
551
515
  if (typeof e != "object" || typeof e._editable > "u")
552
516
  return {};
553
517
  try {
@@ -562,19 +526,19 @@ const F = [], xe = (e) => new Promise((t, r) => {
562
526
  return {};
563
527
  }
564
528
  };
565
- let Oe = "https://app.storyblok.com/f/storyblok-v2-latest.js";
566
- function je(e, t) {
567
- return Re(t).render(e);
529
+ let ve = "https://app.storyblok.com/f/storyblok-v2-latest.js";
530
+ function Se(e, t) {
531
+ return ke(t).render(e);
568
532
  }
569
- const De = () => xe(Oe);
533
+ const Ie = () => we(ve);
570
534
  export {
571
- Be as getLiveStory,
572
- Me as handleStoryblokMessage,
573
- De as loadStoryblokBridge,
574
- je as renderRichText,
575
- Re as richTextResolver,
576
- Ne as storyblok,
577
- Pe as storyblokEditable,
578
- D as toCamelCase,
579
- _e as useStoryblokApi
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
580
544
  };
@@ -1,4 +1,4 @@
1
- (function(C,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(C=typeof globalThis<"u"?globalThis:C||self,S(C.storyblokAstro={}))})(this,function(C){"use strict";const S=`<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
1
+ (function(v,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(v=typeof globalThis<"u"?globalThis:v||self,T(v.storyblokAstro={}))})(this,function(v){"use strict";const T=`<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
2
  <g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
3
  <g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
4
4
  <g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
@@ -7,23 +7,23 @@
7
7
  </g>
8
8
  </g>
9
9
  </g>
10
- </svg>`,Y=/[\p{Lu}]/u,q=/[\p{Ll}]/u,N=/^[\p{Lu}](?![\p{Lu}])/gu,P=/([\p{Alpha}\p{N}_]|$)/u,_=/[_.\- ]+/,V=new RegExp("^"+_.source),j=new RegExp(_.source+P.source,"gu"),D=new RegExp("\\d+"+P.source,"gu"),X=(e,t,r,s)=>{let a=!1,n=!1,f=!1,p=!1;for(let i=0;i<e.length;i++){const d=e[i];p=i>2?e[i-3]==="-":!0,a&&Y.test(d)?(e=e.slice(0,i)+"-"+e.slice(i),a=!1,f=n,n=!0,i++):n&&f&&q.test(d)&&(!p||s)?(e=e.slice(0,i-1)+"-"+e.slice(i-1),f=n,n=!1,a=!0):(a=t(d)===d&&r(d)!==d,f=n,n=r(d)===d&&t(d)!==d)}return e},Q=(e,t)=>(N.lastIndex=0,e.replaceAll(N,r=>t(r))),ee=(e,t)=>(j.lastIndex=0,D.lastIndex=0,e.replaceAll(D,(r,s,a)=>["_","-"].includes(e.charAt(a+r.length))?r:t(r)).replaceAll(j,(r,s)=>t(s)));function te(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(n=>n.trim()).filter(n=>n.length).join("-"):e=e.trim(),e.length===0)return"";const r=t.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(t.locale),s=t.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(t.locale);return e.length===1?_.test(e)?"":t.pascalCase?s(e):r(e):(e!==r(e)&&(e=X(e,r,s,t.preserveConsecutiveUppercase)),e=e.replace(V,""),e=t.preserveConsecutiveUppercase?Q(e,r):r(e),t.pascalCase&&(e=s(e.charAt(0))+e.slice(1)),ee(e,s))}function M(e){return te(e)}function re(e,t={},r,s){const a="virtual:storyblok-components",n=`\0${a}`;return{name:"vite-plugin-storyblok-components",async resolveId(f){if(f===a)return n},async load(f){if(f===n){const p=[],i=[];for await(const[h,A]of Object.entries(t)){const L=await this.resolve(`/${e}/${A}.astro`);if(L)p.push(`import ${M(h)} from "${L.id}"`);else if(r)i.push(h);else throw new Error(`Component could not be found for blok "${h}"! Does "${`/${e}/${A}`}.astro" exist?`)}let d="";if(r)if(d=",FallbackComponent",s){const h=await this.resolve(`/${e}/${s}.astro`);if(!h)throw new Error(`Custom fallback component could not be found. Does "${`/${e}/${s}`}.astro" exist?`);p.push(`import FallbackComponent from "${h.id}"`)}else p.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${p.join(";")};export default {${Object.keys(t).filter(h=>!i.includes(h)).map(h=>M(h)).join(",")}${d}}`;if(r)return`${p[0]}; export default {${d.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
10
+ </svg>`,W=/[\p{Lu}]/u,Y=/[\p{Ll}]/u,B=/^[\p{Lu}](?![\p{Lu}])/gu,N=/([\p{Alpha}\p{N}_]|$)/u,_=/[_.\- ]+/,q=new RegExp("^"+_.source),j=new RegExp(_.source+N.source,"gu"),P=new RegExp("\\d+"+N.source,"gu"),X=(e,t,n,s)=>{let l=!1,o=!1,b=!1,p=!1;for(let i=0;i<e.length;i++){const u=e[i];p=i>2?e[i-3]==="-":!0,l&&W.test(u)?(e=e.slice(0,i)+"-"+e.slice(i),l=!1,b=o,o=!0,i++):o&&b&&Y.test(u)&&(!p||s)?(e=e.slice(0,i-1)+"-"+e.slice(i-1),b=o,o=!1,l=!0):(l=t(u)===u&&n(u)!==u,b=o,o=n(u)===u&&t(u)!==u)}return e},Z=(e,t)=>(B.lastIndex=0,e.replaceAll(B,n=>t(n))),V=(e,t)=>(j.lastIndex=0,P.lastIndex=0,e.replaceAll(P,(n,s,l)=>["_","-"].includes(e.charAt(l+n.length))?n:t(n)).replaceAll(j,(n,s)=>t(s)));function Q(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(o=>o.trim()).filter(o=>o.length).join("-"):e=e.trim(),e.length===0)return"";const n=t.locale===!1?o=>o.toLowerCase():o=>o.toLocaleLowerCase(t.locale),s=t.locale===!1?o=>o.toUpperCase():o=>o.toLocaleUpperCase(t.locale);return e.length===1?_.test(e)?"":t.pascalCase?s(e):n(e):(e!==n(e)&&(e=X(e,n,s,t.preserveConsecutiveUppercase)),e=e.replace(q,""),e=t.preserveConsecutiveUppercase?Z(e,n):n(e),t.pascalCase&&(e=s(e.charAt(0))+e.slice(1)),V(e,s))}function x(e){return Q(e)}function ee(e,t={},n,s){const l="virtual:storyblok-components",o=`\0${l}`;return{name:"vite-plugin-storyblok-components",async resolveId(b){if(b===l)return o},async load(b){if(b===o){const p=[],i=[];for await(const[y,L]of Object.entries(t)){const S=await this.resolve(`/${e}/${L}.astro`);if(S)p.push(`import ${x(y)} from "${S.id}"`);else if(n)i.push(y);else throw new Error(`Component could not be found for blok "${y}"! Does "${`/${e}/${L}`}.astro" exist?`)}let u="";if(n)if(u=",FallbackComponent",s){const y=await this.resolve(`/${e}/${s}.astro`);if(!y)throw new Error(`Custom fallback component could not be found. Does "${`/${e}/${s}`}.astro" exist?`);p.push(`import FallbackComponent from "${y.id}"`)}else p.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${p.join(";")};export default {${Object.keys(t).filter(y=>!i.includes(y)).map(y=>x(y)).join(",")}${u}}`;if(n)return`${p[0]}; export default {${u.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
11
11
  Please register your components or enable the fallback component.
12
- Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function oe(e,t,r){const s="virtual:storyblok-init",a=`\0${s}`;return{name:"vite-plugin-storyblok-init",async resolveId(n){if(n===s)return a},async load(n){if(n===a)return`
12
+ Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function te(e,t,n){const s="virtual:storyblok-init",l=`\0${s}`;return{name:"vite-plugin-storyblok-init",async resolveId(o){if(o===s)return l},async load(o){if(o===l)return`
13
13
  import { storyblokInit, apiPlugin } from "@storyblok/js";
14
14
  const { storyblokApi } = storyblokInit({
15
15
  accessToken: "${e}",
16
16
  use: ${t?"[]":"[apiPlugin]"},
17
- apiOptions: ${JSON.stringify(r)},
17
+ apiOptions: ${JSON.stringify(n)},
18
18
  });
19
19
  export const storyblokApiInstance = storyblokApi;
20
- `}}}function ne(e){const t="virtual:storyblok-options",r=`\0${t}`;return{name:"vite-plugin-storyblok-options",async resolveId(s){if(s===t)return r},async load(s){if(s===r)return`export default ${JSON.stringify(e)}`}}}function se(){if(!(globalThis!=null&&globalThis.storyblokApiInstance))throw new Error("storyblokApiInstance has not been initialized correctly");return globalThis.storyblokApiInstance}async function ae(e){let t=null;return e&&e.locals._storyblok_preview_data&&(t=e.locals._storyblok_preview_data),t}function le(e){return typeof e=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});`:"const storyblokInstance = new StoryblokBridge();"}function ie(e){const t={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...e},r=le(t.bridge);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:s,updateConfig:a,addDevToolbarApp:n,addMiddleware:f,config:p})=>{if(a({vite:{plugins:[oe(t.accessToken,t.useCustomApi,t.apiOptions),re(t.componentsDir,t.components,t.enableFallbackComponent,t.customFallbackComponent),ne(t)]}}),t.livePreview&&(p==null?void 0:p.output)!=="server")throw new Error("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.");s("page-ssr",`
20
+ `}}}function re(e){const t="virtual:storyblok-options",n=`\0${t}`;return{name:"vite-plugin-storyblok-options",async resolveId(s){if(s===t)return n},async load(s){if(s===n)return`export default ${JSON.stringify(e)}`}}}function oe(){if(!(globalThis!=null&&globalThis.storyblokApiInstance))throw new Error("storyblokApiInstance has not been initialized correctly");return globalThis.storyblokApiInstance}async function ne(e){let t=null;return e&&e.locals._storyblok_preview_data&&(t=e.locals._storyblok_preview_data),t}function se(e){return typeof e=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});`:"const storyblokInstance = new StoryblokBridge();"}function le(e){const t={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...e},n=se(t.bridge);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:s,updateConfig:l,addDevToolbarApp:o,addMiddleware:b,config:p})=>{if(l({vite:{plugins:[te(t.accessToken,t.useCustomApi,t.apiOptions),ee(t.componentsDir,t.components,t.enableFallbackComponent,t.customFallbackComponent),re(t)]}}),t.livePreview&&(p==null?void 0:p.output)!=="server")throw new Error("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.");s("page-ssr",`
21
21
  import { storyblokApiInstance } from "virtual:storyblok-init";
22
22
  globalThis.storyblokApiInstance = storyblokApiInstance;
23
23
  `),t.bridge&&!t.livePreview&&s("page",`import { loadStoryblokBridge } from "@storyblok/astro";
24
24
  loadStoryblokBridge().then(() => {
25
25
  const { StoryblokBridge, location } = window;
26
- ${r}
26
+ ${n}
27
27
  storyblokInstance.on(["published", "change"], (event) => {
28
28
  if (!event.slugChanged) {
29
29
  location.reload(true);
@@ -33,7 +33,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
33
33
  `),t.livePreview&&(s("page",`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
34
34
  loadStoryblokBridge().then(() => {
35
35
  const { StoryblokBridge, location } = window;
36
- ${r}
36
+ ${n}
37
37
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
38
38
  });
39
- `),f({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),n({id:"storyblok",name:"Storyblok",icon:S,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let U;async function ce(e){const{action:t,story:r}=e||{};if(t==="input"&&r){const s=async()=>{const n=await de(r),f=document.body;if(n.outerHTML===f.outerHTML)return;const p=document.querySelector('[data-blok-focused="true"]');ue(f,n,p),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(U),U=setTimeout(s,500)}["published","change"].includes(e==null?void 0:e.action)&&location.reload()}function ue(e,t,r){if(r){const s=r.getAttribute("data-blok-uid"),a=t.querySelector(`[data-blok-uid="${s}"]`);a&&(a.setAttribute("data-blok-focused","true"),r.replaceWith(a))}else e.replaceWith(t)}async function de(e){const r=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...e,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(r,"text/html").body}function I(e,t,r){this.type=e,this.tag=t,this.attrs=null,this.map=null,this.nesting=r,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}I.prototype.attrIndex=function(e){if(!this.attrs)return-1;const t=this.attrs;for(let r=0,s=t.length;r<s;r++)if(t[r][0]===e)return r;return-1},I.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]},I.prototype.attrSet=function(e,t){const r=this.attrIndex(e),s=[e,t];r<0?this.attrPush(s):this.attrs[r]=s},I.prototype.attrGet=function(e){const t=this.attrIndex(e);let r=null;return t>=0&&(r=this.attrs[t][1]),r},I.prototype.attrJoin=function(e,t){const r=this.attrIndex(e);r<0?this.attrPush([e,t]):this.attrs[r][1]=this.attrs[r][1]+" "+t};const pe="[a-zA-Z_:][a-zA-Z0-9:._-]*",fe="[^\"'=<>`\\x00-\\x20]+",he="'[^']*'",be='"[^"]*"',ye="(?:"+fe+"|"+he+"|"+be+")",ge="(?:\\s+"+pe+"(?:\\s*=\\s*"+ye+")?)",me="<[A-Za-z][A-Za-z0-9\\-]*"+ge+"*\\s*\\/?>",ke="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Ce=new RegExp("^(?:"+me+"|"+ke+")");new RegExp(Ce.source+"\\s*$");const H=[];for(let e=0;e<256;e++)H.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(e){H[e.charCodeAt(0)]=1});let g=function(e){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}({}),v=function(e){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}({}),we=function(e){return e.TEXT="text",e}({}),T=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});function ve(e,t){if(!t)return{src:e,attrs:{}};let r=0,s=0;const a={},n=[];function f(i,d,h,A,L){typeof i!="number"||i<=d||i>=h?console.warn(`[StoryblokRichText] - ${A.charAt(0).toUpperCase()+A.slice(1)} value must be a number between ${d} and ${h} (inclusive)`):L.push(`${A}(${i})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(a.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?(a.height=t.height,s=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),t.loading&&["lazy","eager"].includes(t.loading)&&(a.loading=t.loading),t.class&&(a.class=t.class),t.filters){const{filters:i}=t||{},{blur:d,brightness:h,fill:A,format:L,grayscale:E,quality:$,rotate:O}=i||{};d&&f(d,0,100,"blur",n),$&&f($,0,100,"quality",n),h&&f(h,0,100,"brightness",n),A&&n.push(`fill(${A})`),E&&n.push("grayscale()"),O&&[0,90,180,270].includes(t.filters.rotate||0)&&n.push(`rotate(${O})`),L&&["webp","png","jpeg"].includes(L)&&n.push(`format(${L})`)}t.srcset&&(a.srcset=t.srcset.map(i=>{if(typeof i=="number")return`${e}/m/${i}x0/${n.length>0?`filters:${n.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[d,h]=i;return`${e}/m/${d}x${h}/${n.length>0?`filters:${n.join(":")}`:""} ${d}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(a.sizes=t.sizes.join(", "))}let p=`${e}/m/`;return r>0&&s>0&&(p=`${p}${r}x${s}/`),n.length>0&&(p=`${p}filters:${n.join(":")}`),{src:p,attrs:a}}const Ee=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Ae=(e={})=>Object.keys(e).map(t=>`${t}="${e[t]}"`).join(" "),Le=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function Se(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const R=e=>Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0));function z(e,t={},r){const s=Ae(t),a=s?`${e} ${s}`:e,n=Array.isArray(r)?r.join(""):r||"";if(e){if(Ee.includes(e))return`<${a}>`}else return n;return`<${a}>${n}</${e}>`}function F(e={}){const t=new Map,{renderFn:r=z,textFn:s=Se,resolvers:a={},optimizeImages:n=!1,keyedResolvers:f=!1}=e,p=r!==z,i=o=>(l,c)=>{const u=l.attrs||{};return c.render(o,u,l.children||null)},d=(o,l)=>{const{src:c,alt:u,title:b,srcset:k,sizes:y}=o.attrs||{};let m=c,w={};if(n){const{src:De,attrs:Ue}=ve(c,n);m=De,w=Ue}const je={src:m,alt:u,title:b,srcset:k,sizes:y,...w};return l.render("img",R(je))},h=(o,l)=>{const{level:c,...u}=o.attrs||{};return l.render(`h${c}`,u,o.children)},A=(o,l)=>{var c,u,b,k;const y=l.render("img",{src:(c=o.attrs)==null?void 0:c.fallbackImage,alt:(u=o.attrs)==null?void 0:u.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return l.render("span",{"data-type":"emoji","data-name":(b=o.attrs)==null?void 0:b.name,"data-emoji":(k=o.attrs)==null?void 0:k.emoji},y)},L=(o,l)=>l.render("pre",o.attrs||{},l.render("code",{},o.children||"")),E=(o,l=!1)=>({text:c,attrs:u},b)=>{const{class:k,id:y,...m}=u||{},w=l?{class:k,id:y,style:Le(m)||void 0}:u||{};return b.render(o,R(w),c)},$=o=>B(o),O=o=>{const{marks:l,...c}=o;if("text"in o){if(l)return l.reduce((b,k)=>$({...k,text:b}),$({...c,children:c.children}));const u=o.attrs||{};if(f){const b=t.get("txt")||0;t.set("txt",b+1),u.key=`txt-${b}`}return s(c.text,u)}return""},J=(o,l)=>{const{linktype:c,href:u,anchor:b,...k}=o.attrs||{};let y="";switch(c){case T.ASSET:case T.URL:y=u;break;case T.EMAIL:y=`mailto:${u}`;break;case T.STORY:y=u,b&&(y=`${y}#${b}`);break;default:y=u;break}const m={...k};return y&&(m.href=y),l.render("a",m,o.text)},xe=(o,l)=>{var c,u;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),l.render("span",{blok:(c=o==null?void 0:o.attrs)==null?void 0:c.body[0],id:(u=o.attrs)==null?void 0:u.id,style:"display: none"})},_e=(o,l)=>{const c={},u=l.render("tbody",{},o.children);return l.render("table",c,u)},Me=(o,l)=>{const c={};return l.render("tr",c,o.children)},Be=(o,l)=>{const{colspan:c,rowspan:u,colwidth:b,backgroundColor:k,...y}=o.attrs||{},m={...y};c>1&&(m.colspan=c),u>1&&(m.rowspan=u);const w=[];return b&&w.push(`width: ${b}px;`),k&&w.push(`background-color: ${k};`),w.length>0&&(m.style=w.join(" ")),l.render("td",R(m),o.children)},Ne=(o,l)=>{const{colspan:c,rowspan:u,colwidth:b,backgroundColor:k,...y}=o.attrs||{},m={...y};c>1&&(m.colspan=c),u>1&&(m.rowspan=u);const w=[];return b&&w.push(`width: ${b}px;`),k&&w.push(`background-color: ${k};`),w.length>0&&(m.style=w.join(" ")),l.render("th",R(m),o.children)},K=new Map([[g.DOCUMENT,i("")],[g.HEADING,h],[g.PARAGRAPH,i("p")],[g.UL_LIST,i("ul")],[g.OL_LIST,i("ol")],[g.LIST_ITEM,i("li")],[g.IMAGE,d],[g.EMOJI,A],[g.CODE_BLOCK,L],[g.HR,i("hr")],[g.BR,i("br")],[g.QUOTE,i("blockquote")],[g.COMPONENT,xe],[we.TEXT,O],[v.LINK,J],[v.ANCHOR,J],[v.STYLED,E("span",!0)],[v.BOLD,E("strong")],[v.TEXT_STYLE,E("span",!0)],[v.ITALIC,E("em")],[v.UNDERLINE,E("u")],[v.STRIKE,E("s")],[v.CODE,E("code")],[v.SUPERSCRIPT,E("sup")],[v.SUBSCRIPT,E("sub")],[v.HIGHLIGHT,E("mark")],[g.TABLE,_e],[g.TABLE_ROW,Me],[g.TABLE_CELL,Be],[g.TABLE_HEADER,Ne]]),W=new Map([...K,...Object.entries(a).map(([o,l])=>[o,l])]),Pe=()=>({render:(o,l={},c)=>{if(f&&o){const u=t.get(o)||0;t.set(o,u+1),l.key=`${o}-${u}`}return r(o,l,c)},originalResolvers:K,mergedResolvers:W});function x(o){const l=W.get(o.type);if(!l)return console.error("<Storyblok>",`No resolver found for node type ${o.type}`),"";const c=Pe();if(o.type==="text")return l(o,c);const u=o.content?o.content.map(B):void 0;return l({...o,children:u},c)}function B(o){return o.type==="doc"?p?o.content.map(x):o.content.map(x).join(""):Array.isArray(o)?o.map(x):x(o)}return{render:B}}let G=!1;const Z=[],Ie=e=>new Promise((t,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=a=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}G?a():Z.push(a)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const s=document.createElement("script");s.async=!0,s.src=e,s.id="storyblok-javascript-bridge",s.onerror=a=>r(a),s.onload=a=>{Z.forEach(n=>n()),G=!0,t(a)},document.getElementsByTagName("head")[0].appendChild(s)}),$e=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let Te="https://app.storyblok.com/f/storyblok-v2-latest.js";function Re(e,t){return F(t).render(e)}const Oe=()=>Ie(Te);C.getLiveStory=ae,C.handleStoryblokMessage=ce,C.loadStoryblokBridge=Oe,C.renderRichText=Re,C.richTextResolver=F,C.storyblok=ie,C.storyblokEditable=$e,C.toCamelCase=M,C.useStoryblokApi=se,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
39
+ `),b({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),o({id:"storyblok",name:"Storyblok",icon:T,entrypoint:"@storyblok/astro/toolbarApp.ts"})}}}}let D;async function ae(e){const{action:t,story:n}=e||{};if(t==="input"&&n){const s=async()=>{const o=await ce(n),b=document.body;if(o.outerHTML===b.outerHTML)return;const p=document.querySelector('[data-blok-focused="true"]');ie(b,o,p),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(D),D=setTimeout(s,500)}["published","change"].includes(e==null?void 0:e.action)&&location.reload()}function ie(e,t,n){if(n){const s=n.getAttribute("data-blok-uid"),l=t.querySelector(`[data-blok-uid="${s}"]`);l&&(l.setAttribute("data-blok-focused","true"),n.replaceWith(l))}else e.replaceWith(t)}async function ce(e){const n=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...e,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(n,"text/html").body}let g=function(e){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}({}),C=function(e){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}({}),de=function(e){return e.TEXT="text",e}({}),A=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const ue=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],pe=(e={})=>Object.keys(e).map(t=>`${t}="${e[t]}"`).join(" "),be=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function ye(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const I=e=>Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0));function fe(e,t){if(!t)return{src:e,attrs:{}};let n=0,s=0;const l={},o=[];function b(i,u,y,L,S){typeof i!="number"||i<=u||i>=y?console.warn(`[StoryblokRichText] - ${L.charAt(0).toUpperCase()+L.slice(1)} value must be a number between ${u} and ${y} (inclusive)`):S.push(`${L}(${i})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(l.width=t.width,n=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,s=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){const{filters:i}=t||{},{blur:u,brightness:y,fill:L,format:S,grayscale:E,quality:$,rotate:R}=i||{};u&&b(u,0,100,"blur",o),$&&b($,0,100,"quality",o),y&&b(y,0,100,"brightness",o),L&&o.push(`fill(${L})`),E&&o.push("grayscale()"),R&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${R})`),S&&["webp","png","jpeg"].includes(S)&&o.push(`format(${S})`)}t.srcset&&(l.srcset=t.srcset.map(i=>{if(typeof i=="number")return`${e}/m/${i}x0/${o.length>0?`filters:${o.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,y]=i;return`${e}/m/${u}x${y}/${o.length>0?`filters:${o.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(l.sizes=t.sizes.join(", "))}let p=`${e}/m/`;return n>0&&s>0&&(p=`${p}${n}x${s}/`),o.length>0&&(p=`${p}filters:${o.join(":")}`),{src:p,attrs:l}}function U(e,t={},n){const s=pe(t),l=s?`${e} ${s}`:e,o=Array.isArray(n)?n.join(""):n||"";if(e){if(ue.includes(e))return`<${l}>`}else return o;return`<${l}>${o}</${e}>`}function H(e={}){const t=new Map,{renderFn:n=U,textFn:s=ye,resolvers:l={},optimizeImages:o=!1,keyedResolvers:b=!1}=e,p=n!==U,i=r=>(a,c)=>{const d=a.attrs||{};return c.render(r,d,a.children||null)},u=(r,a)=>{const{src:c,alt:d,title:f,srcset:k,sizes:h}=r.attrs||{};let m=c,w={};if(o){const{src:Ae,attrs:Ie}=fe(c,o);m=Ae,w=Ie}const $e={src:m,alt:d,title:f,srcset:k,sizes:h,...w};return a.render("img",I($e))},y=(r,a)=>{const{level:c,...d}=r.attrs||{};return a.render(`h${c}`,d,r.children)},L=(r,a)=>{var c,d,f,k;const h=a.render("img",{src:(c=r.attrs)==null?void 0:c.fallbackImage,alt:(d=r.attrs)==null?void 0:d.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return a.render("span",{"data-type":"emoji","data-name":(f=r.attrs)==null?void 0:f.name,"data-emoji":(k=r.attrs)==null?void 0:k.emoji},h)},S=(r,a)=>a.render("pre",r.attrs||{},a.render("code",{},r.children||"")),E=(r,a=!1)=>({text:c,attrs:d},f)=>{const{class:k,id:h,...m}=d||{},w=a?{class:k,id:h,style:be(m)||void 0}:d||{};return f.render(r,I(w),c)},$=r=>M(r),R=r=>{const{marks:a,...c}=r;if("text"in r){if(a)return a.reduce((f,k)=>$({...k,text:f}),$({...c,children:c.children}));const d=r.attrs||{};if(b){const f=t.get("txt")||0;t.set("txt",f+1),d.key=`txt-${f}`}return s(c.text,d)}return""},z=(r,a)=>{const{linktype:c,href:d,anchor:f,...k}=r.attrs||{};let h="";switch(c){case A.ASSET:case A.URL:h=d;break;case A.EMAIL:h=`mailto:${d}`;break;case A.STORY:h=d,f&&(h=`${h}#${f}`);break;default:h=d;break}const m={...k};return h&&(m.href=h),a.render("a",m,r.text)},we=(r,a)=>{var c,d;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),a.render("span",{blok:(c=r==null?void 0:r.attrs)==null?void 0:c.body[0],id:(d=r.attrs)==null?void 0:d.id,style:"display: none"})},Ce=(r,a)=>{const c={},d=a.render("tbody",{},r.children);return a.render("table",c,d)},Ee=(r,a)=>{const c={};return a.render("tr",c,r.children)},Le=(r,a)=>{const{colspan:c,rowspan:d,colwidth:f,backgroundColor:k,...h}=r.attrs||{},m={...h};c>1&&(m.colspan=c),d>1&&(m.rowspan=d);const w=[];return f&&w.push(`width: ${f}px;`),k&&w.push(`background-color: ${k};`),w.length>0&&(m.style=w.join(" ")),a.render("td",I(m),r.children)},Se=(r,a)=>{const{colspan:c,rowspan:d,colwidth:f,backgroundColor:k,...h}=r.attrs||{},m={...h};c>1&&(m.colspan=c),d>1&&(m.rowspan=d);const w=[];return f&&w.push(`width: ${f}px;`),k&&w.push(`background-color: ${k};`),w.length>0&&(m.style=w.join(" ")),a.render("th",I(m),r.children)},K=new Map([[g.DOCUMENT,i("")],[g.HEADING,y],[g.PARAGRAPH,i("p")],[g.UL_LIST,i("ul")],[g.OL_LIST,i("ol")],[g.LIST_ITEM,i("li")],[g.IMAGE,u],[g.EMOJI,L],[g.CODE_BLOCK,S],[g.HR,i("hr")],[g.BR,i("br")],[g.QUOTE,i("blockquote")],[g.COMPONENT,we],[de.TEXT,R],[C.LINK,z],[C.ANCHOR,z],[C.STYLED,E("span",!0)],[C.BOLD,E("strong")],[C.TEXT_STYLE,E("span",!0)],[C.ITALIC,E("em")],[C.UNDERLINE,E("u")],[C.STRIKE,E("s")],[C.CODE,E("code")],[C.SUPERSCRIPT,E("sup")],[C.SUBSCRIPT,E("sub")],[C.HIGHLIGHT,E("mark")],[g.TABLE,Ce],[g.TABLE_ROW,Ee],[g.TABLE_CELL,Le],[g.TABLE_HEADER,Se]]),J=new Map([...K,...Object.entries(l).map(([r,a])=>[r,a])]),Te=()=>({render:(r,a={},c)=>{if(b&&r){const d=t.get(r)||0;t.set(r,d+1),a.key=`${r}-${d}`}return n(r,a,c)},originalResolvers:K,mergedResolvers:J});function O(r){const a=J.get(r.type);if(!a)return console.error("<Storyblok>",`No resolver found for node type ${r.type}`),"";const c=Te();if(r.type==="text")return a(r,c);const d=r.content?r.content.map(M):void 0;return a({...r,children:d},c)}function M(r){return r.type==="doc"?p?r.content.map(O):r.content.map(O).join(""):Array.isArray(r)?r.map(O):O(r)}return{render:M}}let F=!1;const G=[],he=e=>new Promise((t,n)=>{if(typeof window>"u"){n(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=l=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}F?l():G.push(l)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const s=document.createElement("script");s.async=!0,s.src=e,s.id="storyblok-javascript-bridge",s.onerror=l=>n(l),s.onload=l=>{G.forEach(o=>o()),F=!0,t(l)},document.getElementsByTagName("head")[0].appendChild(s)}),ge=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let me="https://app.storyblok.com/f/storyblok-v2-latest.js";function ke(e,t){return H(t).render(e)}const ve=()=>he(me);v.getLiveStory=ne,v.handleStoryblokMessage=ae,v.loadStoryblokBridge=ve,v.renderRichText=ke,v.richTextResolver=H,v.storyblok=le,v.storyblokEditable=ge,v.toCamelCase=x,v.useStoryblokApi=oe,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/astro",
3
3
  "type": "module",
4
- "version": "7.2.3",
4
+ "version": "7.2.5",
5
5
  "private": false,
6
6
  "description": "Official Astro integration for the Storyblok Headless CMS",
7
7
  "author": "Storyblok",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "main": "./dist/storyblok-astro.es.js",
48
48
  "module": "./dist/storyblok-astro.js",
49
- "types": "./dist/storyblok-astro.d.ts",
49
+ "types": "./dist/index.d.ts",
50
50
  "files": [
51
51
  "*.d.ts",
52
52
  "dist"
@@ -56,14 +56,14 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "camelcase": "^8.0.0",
59
- "@storyblok/js": "4.2.3"
59
+ "@storyblok/js": "4.2.5"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@cypress/vite-dev-server": "^6.0.3",
63
63
  "@rollup/plugin-dynamic-import-vars": "^2.1.5",
64
64
  "@types/lodash.mergewith": "^4.6.9",
65
65
  "@types/node": "^22.15.18",
66
- "astro": "^5.0.9",
66
+ "astro": "^5.13.2",
67
67
  "cypress": "^14.3.3",
68
68
  "eslint": "^9.26.0",
69
69
  "eslint-config-prettier": "^10.0.1",
@@ -77,7 +77,7 @@
77
77
  "vite-plugin-dts": "^4.5.3",
78
78
  "vite-plugin-static-copy": "^2.2.0",
79
79
  "vitest": "^3.1.3",
80
- "@storyblok/eslint-config": "0.4.0"
80
+ "@storyblok/eslint-config": "0.4.1"
81
81
  },
82
82
  "eslintConfig": {
83
83
  "env": {
@@ -134,6 +134,7 @@
134
134
  "scripts": {
135
135
  "dev": "vite",
136
136
  "build": "vite build && tsc --project tsconfig.json",
137
+ "test:types": "tsc --noEmit --skipLibCheck",
137
138
  "playground": "pnpm run --filter ./playground/ssg dev",
138
139
  "playground:ssr": "pnpm run --filter ./playground/ssr dev",
139
140
  "playground:test": "pnpm run --filter ./playground/test dev",