@storyblok/astro 7.3.6 → 7.3.8

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.
@@ -55,17 +55,17 @@ function ke(e) {
55
55
  function we(e) {
56
56
  return e.endsWith(".astro") ? e : `${e}.astro`;
57
57
  }
58
- function B(e) {
58
+ function q(e) {
59
59
  return `/${e.trim().replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/{2,}/g, "/")}`;
60
60
  }
61
- const Le = /[\p{Lu}]/u, Ae = /[\p{Ll}]/u, W = /^[\p{Lu}](?![\p{Lu}])/gu, ie = /([\p{Alpha}\p{N}_]|$)/u, q = /[_.\- ]+/, Ee = new RegExp("^" + q.source), Y = new RegExp(q.source + ie.source, "gu"), K = new RegExp("\\d+" + ie.source, "gu"), Re = (e, t, s, r) => {
62
- let o = !1, n = !1, l = !1, i = !1;
61
+ const Le = /[\p{Lu}]/u, Ae = /[\p{Ll}]/u, Y = /^[\p{Lu}](?![\p{Lu}])/gu, ie = /([\p{Alpha}\p{N}_]|$)/u, G = /[_.\- ]+/, Ee = new RegExp("^" + G.source), K = new RegExp(G.source + ie.source, "gu"), X = new RegExp("\\d+" + ie.source, "gu"), Re = (e, t, s, r) => {
62
+ let o = !1, n = !1, a = !1, l = !1;
63
63
  for (let c = 0; c < e.length; c++) {
64
64
  const u = e[c];
65
- i = c > 2 ? e[c - 3] === "-" : !0, o && Le.test(u) ? (e = e.slice(0, c) + "-" + e.slice(c), o = !1, l = n, n = !0, c++) : n && l && Ae.test(u) && (!i || r) ? (e = e.slice(0, c - 1) + "-" + e.slice(c - 1), l = n, n = !1, o = !0) : (o = t(u) === u && s(u) !== u, l = n, n = s(u) === u && t(u) !== u);
65
+ l = c > 2 ? e[c - 3] === "-" : !0, o && Le.test(u) ? (e = e.slice(0, c) + "-" + e.slice(c), o = !1, a = n, n = !0, c++) : n && a && Ae.test(u) && (!l || r) ? (e = e.slice(0, c - 1) + "-" + e.slice(c - 1), a = n, n = !1, o = !0) : (o = t(u) === u && s(u) !== u, a = n, n = s(u) === u && t(u) !== u);
66
66
  }
67
67
  return e;
68
- }, _e = (e, t) => (W.lastIndex = 0, e.replaceAll(W, (s) => t(s))), Te = (e, t) => (Y.lastIndex = 0, K.lastIndex = 0, e.replaceAll(K, (s, r, o) => ["_", "-"].includes(e.charAt(o + s.length)) ? s : t(s)).replaceAll(Y, (s, r) => t(r)));
68
+ }, Te = (e, t) => (Y.lastIndex = 0, e.replaceAll(Y, (s) => t(s))), _e = (e, t) => (K.lastIndex = 0, X.lastIndex = 0, e.replaceAll(X, (s, r, o) => ["_", "-"].includes(e.charAt(o + s.length)) ? s : t(s)).replaceAll(K, (s, r) => t(r)));
69
69
  function $e(e, t) {
70
70
  if (!(typeof e == "string" || Array.isArray(e)))
71
71
  throw new TypeError("Expected the input to be `string | string[]`");
@@ -76,29 +76,29 @@ function $e(e, t) {
76
76
  }, Array.isArray(e) ? e = e.map((n) => n.trim()).filter((n) => n.length).join("-") : e = e.trim(), e.length === 0)
77
77
  return "";
78
78
  const s = t.locale === !1 ? (n) => n.toLowerCase() : (n) => n.toLocaleLowerCase(t.locale), r = t.locale === !1 ? (n) => n.toUpperCase() : (n) => n.toLocaleUpperCase(t.locale);
79
- return e.length === 1 ? q.test(e) ? "" : t.pascalCase ? r(e) : s(e) : (e !== s(e) && (e = Re(e, s, r, t.preserveConsecutiveUppercase)), e = e.replace(Ee, ""), e = t.preserveConsecutiveUppercase ? _e(e, s) : s(e), t.pascalCase && (e = r(e.charAt(0)) + e.slice(1)), Te(e, r));
79
+ return e.length === 1 ? G.test(e) ? "" : t.pascalCase ? r(e) : s(e) : (e !== s(e) && (e = Re(e, s, r, t.preserveConsecutiveUppercase)), e = e.replace(Ee, ""), e = t.preserveConsecutiveUppercase ? Te(e, s) : s(e), t.pascalCase && (e = r(e.charAt(0)) + e.slice(1)), _e(e, r));
80
80
  }
81
- function Se(e) {
81
+ function Ie(e) {
82
82
  return $e(e);
83
83
  }
84
- function Ie(e, t, s, r) {
84
+ function Se(e, t, s, r) {
85
85
  const o = "virtual:import-storyblok-components", n = `\0${o}`;
86
86
  return {
87
87
  name: "vite-plugin-import-storyblok-components",
88
88
  /**
89
89
  * Resolves virtual module imports
90
90
  */
91
- async resolveId(l) {
92
- if (l === o)
91
+ async resolveId(a) {
92
+ if (a === o)
93
93
  return n;
94
94
  },
95
95
  /**
96
96
  * Generates the virtual module content with dynamic imports
97
97
  */
98
- async load(l) {
99
- if (l !== n)
98
+ async load(a) {
99
+ if (a !== n)
100
100
  return;
101
- const i = await xe(
101
+ const l = await xe(
102
102
  this,
103
103
  t,
104
104
  s,
@@ -111,14 +111,14 @@ function Ie(e, t, s, r) {
111
111
  );
112
112
  return Oe(
113
113
  t,
114
- i,
114
+ l,
115
115
  c
116
116
  );
117
117
  }
118
118
  };
119
119
  }
120
120
  function Oe(e, t, s) {
121
- const o = `${B(e)}/storyblok/**/*.astro`;
121
+ const o = `${q(e)}/storyblok/**/*.astro`;
122
122
  return `
123
123
  // Import utilities and fallback component
124
124
  import { toCamelCase } from '@storyblok/astro';
@@ -148,9 +148,9 @@ function Oe(e, t, s) {
148
148
 
149
149
  // Manual imports (overwrite auto if same key exists)
150
150
  ${s.map((n) => {
151
- var i;
152
- const l = (i = n.match(/import\s+(\w+)\s+from/)) == null ? void 0 : i[1];
153
- return `storyblokComponents['${l}'] = ${l};`;
151
+ var l;
152
+ const a = (l = n.match(/import\s+(\w+)\s+from/)) == null ? void 0 : l[1];
153
+ return `storyblokComponents['${a}'] = ${a};`;
154
154
  }).join(`
155
155
  `)}
156
156
 
@@ -179,19 +179,19 @@ async function xe(e, t, s, r) {
179
179
  }
180
180
  async function Me(e, t, s, r) {
181
181
  const o = [];
182
- for await (const [n, l] of Object.entries(t)) {
183
- const i = ae(s, l), c = await e.resolve(i);
182
+ for await (const [n, a] of Object.entries(t)) {
183
+ const l = ae(s, a), c = await e.resolve(l);
184
184
  if (c)
185
- o.push(`import ${Se(n)} from "${c.id}"`);
185
+ o.push(`import ${Ie(n)} from "${c.id}"`);
186
186
  else if (!r)
187
187
  throw new Error(
188
- `Component could not be found for blok "${n}"! Does "${i}" exist?`
188
+ `Component could not be found for blok "${n}"! Does "${l}" exist?`
189
189
  );
190
190
  }
191
191
  return o;
192
192
  }
193
193
  function ae(e, t) {
194
- const r = `${B(e)}${B(t)}`;
194
+ const r = `${q(e)}${q(t)}`;
195
195
  return we(r);
196
196
  }
197
197
  function ft(e) {
@@ -207,51 +207,51 @@ function ft(e) {
207
207
  useCustomApi: r,
208
208
  apiOptions: o,
209
209
  componentsDir: n,
210
- customFallbackComponent: l,
211
- enableFallbackComponent: i,
210
+ customFallbackComponent: a,
211
+ enableFallbackComponent: l,
212
212
  components: c,
213
213
  bridge: u,
214
- livePreview: d
215
- } = t, p = ke(t.bridge);
214
+ livePreview: g
215
+ } = t, d = ke(t.bridge);
216
216
  return {
217
217
  name: "@storyblok/astro",
218
218
  hooks: {
219
219
  "astro:config:setup": ({
220
- injectScript: L,
221
- updateConfig: _,
222
- addDevToolbarApp: v,
220
+ injectScript: C,
221
+ updateConfig: R,
222
+ addDevToolbarApp: k,
223
223
  addMiddleware: T,
224
224
  config: $
225
225
  }) => {
226
- if (_({
226
+ if (R({
227
227
  vite: {
228
228
  plugins: [
229
229
  Ce(s, r, o),
230
- Ie(
230
+ Se(
231
231
  c || {},
232
232
  n,
233
- i,
234
- l
233
+ l,
234
+ a
235
235
  ),
236
236
  ve(t)
237
237
  ]
238
238
  }
239
- }), d && ($ == null ? void 0 : $.output) !== "server")
239
+ }), g && ($ == null ? void 0 : $.output) !== "server")
240
240
  throw new Error(
241
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."
242
242
  );
243
- L(
243
+ C(
244
244
  "page-ssr",
245
245
  `
246
246
  import { storyblokApiInstance } from "virtual:storyblok-init";
247
247
  globalThis.storyblokApiInstance = storyblokApiInstance;
248
248
  `
249
- ), u && !d && L(
249
+ ), u && !g && C(
250
250
  "page",
251
251
  `import { loadStoryblokBridge } from "@storyblok/astro";
252
252
  loadStoryblokBridge().then(() => {
253
253
  const { StoryblokBridge, location } = window;
254
- ${p}
254
+ ${d}
255
255
  storyblokInstance.on(["published", "change"], (event) => {
256
256
  if (!event.slugChanged) {
257
257
  location.reload(true);
@@ -259,19 +259,19 @@ function ft(e) {
259
259
  });
260
260
  });
261
261
  `
262
- ), d && (L(
262
+ ), g && (C(
263
263
  "page",
264
264
  `import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
265
265
  loadStoryblokBridge().then(() => {
266
266
  const { StoryblokBridge, location } = window;
267
- ${p}
267
+ ${d}
268
268
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
269
269
  });
270
270
  `
271
271
  ), T({
272
272
  entrypoint: "@storyblok/astro/middleware.ts",
273
273
  order: "pre"
274
- })), v({
274
+ })), k({
275
275
  id: "storyblok",
276
276
  name: "Storyblok",
277
277
  icon: be,
@@ -281,19 +281,19 @@ function ft(e) {
281
281
  }
282
282
  };
283
283
  }
284
- let X;
284
+ let Q;
285
285
  async function mt(e) {
286
286
  const { action: t, story: s } = e || {};
287
287
  if (t === "input" && s) {
288
288
  const r = async () => {
289
- Q("storyblok-live-preview-updating", { story: s });
290
- const n = await He(s), l = document.body;
291
- if (n.outerHTML === l.outerHTML)
289
+ ee("storyblok-live-preview-updating", { story: s });
290
+ const n = await He(s), a = document.body;
291
+ if (n.outerHTML === a.outerHTML)
292
292
  return;
293
- const i = document.querySelector('[data-blok-focused="true"]');
294
- Pe(l, n, i), Q("storyblok-live-preview-updated", { story: s });
293
+ const l = document.querySelector('[data-blok-focused="true"]');
294
+ Pe(a, n, l), ee("storyblok-live-preview-updated", { story: s });
295
295
  };
296
- clearTimeout(X), X = setTimeout(r, 500);
296
+ clearTimeout(Q), Q = setTimeout(r, 500);
297
297
  }
298
298
  ["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
299
299
  }
@@ -319,11 +319,11 @@ async function He(e) {
319
319
  })).text();
320
320
  return new DOMParser().parseFromString(s, "text/html").body;
321
321
  }
322
- function Q(e, t) {
322
+ function ee(e, t) {
323
323
  document.dispatchEvent(new CustomEvent(e, { detail: t }));
324
324
  }
325
- var Ne = Object.defineProperty, je = (e, t, s) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, g = (e, t, s) => je(e, typeof t != "symbol" ? t + "" : t, s);
326
- let k = /* @__PURE__ */ function(e) {
325
+ var Ne = Object.defineProperty, je = (e, t, s) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, y = (e, t, s) => je(e, typeof t != "symbol" ? t + "" : t, s);
326
+ let w = /* @__PURE__ */ function(e) {
327
327
  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;
328
328
  }({}), A = /* @__PURE__ */ function(e) {
329
329
  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;
@@ -354,52 +354,52 @@ const Ue = [
354
354
  };
355
355
  return Object.keys(r).map((o) => `${o}="${r[o]}"`).join(" ");
356
356
  }, Be = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
357
- function Fe(e) {
357
+ function qe(e) {
358
358
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
359
359
  }
360
- const I = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
361
- function qe(e, t) {
360
+ const S = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
361
+ function Fe(e, t) {
362
362
  if (!t) return {
363
363
  src: e,
364
364
  attrs: {}
365
365
  };
366
366
  let s = 0, r = 0;
367
367
  const o = {}, n = [];
368
- function l(c, u, d, p, L) {
369
- typeof c != "number" || c <= u || c >= d ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${u} and ${d} (inclusive)`) : L.push(`${p}(${c})`);
368
+ function a(c, u, g, d, C) {
369
+ typeof c != "number" || c <= u || c >= g ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${u} and ${g} (inclusive)`) : C.push(`${d}(${c})`);
370
370
  }
371
371
  if (typeof t == "object") {
372
372
  if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (o.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")), t.height !== void 0 && (typeof t.height == "number" && t.height >= 0 ? (o.height = t.height, r = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete o.width, delete o.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (o.loading = t.loading), t.class && (o.class = t.class), t.filters) {
373
- const { filters: c } = t || {}, { blur: u, brightness: d, fill: p, format: L, grayscale: _, quality: v, rotate: T } = c || {};
374
- u && l(u, 0, 100, "blur", n), v && l(v, 0, 100, "quality", n), d && l(d, 0, 100, "brightness", n), p && n.push(`fill(${p})`), _ && n.push("grayscale()"), T && [
373
+ const { filters: c } = t || {}, { blur: u, brightness: g, fill: d, format: C, grayscale: R, quality: k, rotate: T } = c || {};
374
+ u && a(u, 0, 100, "blur", n), k && a(k, 0, 100, "quality", n), g && a(g, 0, 100, "brightness", n), d && n.push(`fill(${d})`), R && n.push("grayscale()"), T && [
375
375
  0,
376
376
  90,
377
377
  180,
378
378
  270
379
- ].includes(t.filters.rotate || 0) && n.push(`rotate(${T})`), L && [
379
+ ].includes(t.filters.rotate || 0) && n.push(`rotate(${T})`), C && [
380
380
  "webp",
381
381
  "png",
382
382
  "jpeg"
383
- ].includes(L) && n.push(`format(${L})`);
383
+ ].includes(C) && n.push(`format(${C})`);
384
384
  }
385
385
  t.srcset && (o.srcset = t.srcset.map((c) => {
386
386
  if (typeof c == "number") return `${e}/m/${c}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
387
387
  if (Array.isArray(c) && c.length === 2) {
388
- const [u, d] = c;
389
- return `${e}/m/${u}x${d}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
388
+ const [u, g] = c;
389
+ return `${e}/m/${u}x${g}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
390
390
  } else {
391
391
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
392
392
  return;
393
393
  }
394
394
  }).join(", ")), t.sizes && (o.sizes = t.sizes.join(", "));
395
395
  }
396
- let i = `${e}/m/`;
397
- return (s > 0 || r > 0) && (i = `${i}${s}x${r}/`), n.length > 0 && (i = `${i}filters:${n.join(":")}`), {
398
- src: i,
396
+ let l = `${e}/m/`;
397
+ return (s > 0 || r > 0) && (l = `${l}${s}x${r}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
398
+ src: l,
399
399
  attrs: o
400
400
  };
401
401
  }
402
- function ee(e, t = {}, s) {
402
+ function te(e, t = {}, s) {
403
403
  const r = Ve(t), o = r ? `${e} ${r}` : e, n = Array.isArray(s) ? s.join("") : s || "";
404
404
  if (e) {
405
405
  if (Ue.includes(e)) return `<${o}>`;
@@ -407,189 +407,189 @@ function ee(e, t = {}, s) {
407
407
  return `<${o}>${n}</${e}>`;
408
408
  }
409
409
  function Ge(e = {}) {
410
- const t = /* @__PURE__ */ new Map(), { renderFn: s = ee, textFn: r = Fe, resolvers: o = {}, optimizeImages: n = !1, keyedResolvers: l = !1 } = e, i = s !== ee, c = (a = {}) => {
411
- const { textAlign: h, class: f, id: m, style: y, ...C } = a, b = [];
412
- return y && b.push(y.endsWith(";") ? y : `${y};`), h && b.push(`text-align: ${h};`), I({
413
- ...C,
414
- class: f,
415
- id: m,
410
+ const t = /* @__PURE__ */ new Map(), { renderFn: s = te, textFn: r = qe, resolvers: o = {}, optimizeImages: n = !1, keyedResolvers: a = !1 } = e, l = s !== te, c = (i = {}) => {
411
+ const { textAlign: h, class: p, id: f, style: m, ...v } = i, b = [];
412
+ return m && b.push(m.endsWith(";") ? m : `${m};`), h && b.push(`text-align: ${h};`), S({
413
+ ...v,
414
+ class: p,
415
+ id: f,
416
416
  ...b.length > 0 ? { style: b.join(" ") } : {}
417
417
  });
418
- }, u = (a) => (h, f) => {
419
- const m = c(h.attrs);
420
- return f.render(a, m, h.children || null);
421
- }, d = (a, h) => {
422
- const { src: f, alt: m, title: y, srcset: C, sizes: b } = a.attrs || {};
423
- let E = f, w = {};
418
+ }, u = (i) => (h, p) => {
419
+ const f = c(h.attrs);
420
+ return p.render(i, f, h.children || null);
421
+ }, g = (i, h) => {
422
+ const { src: p, alt: f, title: m, srcset: v, sizes: b } = i.attrs || {};
423
+ let E = p, L = {};
424
424
  if (n) {
425
- const { src: ye, attrs: ge } = qe(f, n);
426
- E = ye, w = ge;
425
+ const { src: ye, attrs: ge } = Fe(p, n);
426
+ E = ye, L = ge;
427
427
  }
428
- const S = {
428
+ const I = {
429
429
  src: E,
430
- alt: m,
431
- title: y,
432
- srcset: C,
430
+ alt: f,
431
+ title: m,
432
+ srcset: v,
433
433
  sizes: b,
434
- ...w
434
+ ...L
435
435
  };
436
- return h.render("img", I(S));
437
- }, p = (a, h) => {
438
- const { level: f, ...m } = a.attrs || {}, y = c(m);
439
- return h.render(`h${f}`, y, a.children);
440
- }, L = (a, h) => {
441
- var f, m, y, C;
436
+ return h.render("img", S(I));
437
+ }, d = (i, h) => {
438
+ const { level: p, ...f } = i.attrs || {}, m = c(f);
439
+ return h.render(`h${p}`, m, i.children);
440
+ }, C = (i, h) => {
441
+ var p, f, m, v;
442
442
  const b = h.render("img", {
443
- src: (f = a.attrs) == null ? void 0 : f.fallbackImage,
444
- alt: (m = a.attrs) == null ? void 0 : m.alt,
443
+ src: (p = i.attrs) == null ? void 0 : p.fallbackImage,
444
+ alt: (f = i.attrs) == null ? void 0 : f.alt,
445
445
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
446
446
  draggable: "false",
447
447
  loading: "lazy"
448
448
  });
449
449
  return h.render("span", {
450
450
  "data-type": "emoji",
451
- "data-name": (y = a.attrs) == null ? void 0 : y.name,
452
- "data-emoji": (C = a.attrs) == null ? void 0 : C.emoji
451
+ "data-name": (m = i.attrs) == null ? void 0 : m.name,
452
+ "data-emoji": (v = i.attrs) == null ? void 0 : v.emoji
453
453
  }, b);
454
- }, _ = (a, h) => h.render("pre", a.attrs || {}, h.render("code", {}, a.children || "")), v = (a, h = !1) => ({ text: f, attrs: m }, y) => {
455
- const { class: C, id: b, ...E } = m || {}, w = h ? {
456
- class: C,
454
+ }, R = (i, h) => h.render("pre", i.attrs || {}, h.render("code", {}, i.children || "")), k = (i, h = !1) => ({ text: p, attrs: f }, m) => {
455
+ const { class: v, id: b, ...E } = f || {}, L = h ? {
456
+ class: v,
457
457
  id: b,
458
458
  style: Be(E) || void 0
459
- } : m || {};
460
- return y.render(a, I(w), f);
461
- }, T = (a) => N(a), $ = (a) => {
462
- const { marks: h, ...f } = a;
463
- if ("text" in a) {
464
- if (h) return h.reduce((y, C) => T({
465
- ...C,
466
- text: y
459
+ } : f || {};
460
+ return m.render(i, S(L), p);
461
+ }, T = (i) => j(i), $ = (i) => {
462
+ const { marks: h, ...p } = i;
463
+ if ("text" in i) {
464
+ if (h) return h.reduce((m, v) => T({
465
+ ...v,
466
+ text: m
467
467
  }), T({
468
- ...f,
469
- children: f.children
468
+ ...p,
469
+ children: p.children
470
470
  }));
471
- const m = a.attrs || {};
472
- if (l) {
473
- const y = t.get("txt") || 0;
474
- t.set("txt", y + 1), m.key = `txt-${y}`;
471
+ const f = i.attrs || {};
472
+ if (a) {
473
+ const m = t.get("txt") || 0;
474
+ t.set("txt", m + 1), f.key = `txt-${m}`;
475
475
  }
476
- return r(f.text, m);
476
+ return r(p.text, f);
477
477
  }
478
478
  return "";
479
- }, z = (a, h) => {
480
- const { linktype: f, href: m, anchor: y, ...C } = a.attrs || {};
479
+ }, Z = (i, h) => {
480
+ const { linktype: p, href: f, anchor: m, ...v } = i.attrs || {};
481
481
  let b = "";
482
- switch (f) {
482
+ switch (p) {
483
483
  case M.ASSET:
484
484
  case M.URL:
485
- b = m;
485
+ b = f;
486
486
  break;
487
487
  case M.EMAIL:
488
- b = `mailto:${m}`;
488
+ b = `mailto:${f}`;
489
489
  break;
490
490
  case M.STORY:
491
- b = m, y && (b = `${b}#${y}`);
491
+ b = f, m && (b = `${b}#${m}`);
492
492
  break;
493
493
  default:
494
- b = m;
494
+ b = f;
495
495
  break;
496
496
  }
497
- const E = { ...C };
498
- return b && (E.href = b), h.render("a", E, a.text);
499
- }, ue = (a, h) => {
500
- var f, m;
497
+ const E = { ...v };
498
+ return b && (E.href = b), h.render("a", E, i.text);
499
+ }, ue = (i, h) => {
500
+ var p, f;
501
501
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
502
- blok: (f = a == null ? void 0 : a.attrs) == null ? void 0 : f.body[0],
503
- id: (m = a.attrs) == null ? void 0 : m.id,
502
+ blok: (p = i == null ? void 0 : i.attrs) == null ? void 0 : p.body[0],
503
+ id: (f = i.attrs) == null ? void 0 : f.id,
504
504
  style: "display: none"
505
505
  });
506
- }, he = (a, h) => {
507
- const f = c(a.attrs), m = a.children || null;
508
- return h.render("table", f, h.render("tbody", {}, m));
509
- }, de = (a, h) => {
510
- const f = c(a.attrs);
511
- return h.render("tr", f, a.children);
512
- }, pe = (a, h) => {
513
- const { colspan: f, rowspan: m, colwidth: y, backgroundColor: C, textAlign: b, ...E } = a.attrs || {}, w = [];
514
- y && w.push(`width: ${y}px;`), C && w.push(`background-color: ${C};`), b && w.push(`text-align: ${b};`);
515
- const S = {
506
+ }, he = (i, h) => {
507
+ const p = c(i.attrs), f = i.children || null;
508
+ return h.render("table", p, h.render("tbody", {}, f));
509
+ }, de = (i, h) => {
510
+ const p = c(i.attrs);
511
+ return h.render("tr", p, i.children);
512
+ }, pe = (i, h) => {
513
+ const { colspan: p, rowspan: f, colwidth: m, backgroundColor: v, textAlign: b, ...E } = i.attrs || {}, L = [];
514
+ m && L.push(`width: ${m}px;`), v && L.push(`background-color: ${v};`), b && L.push(`text-align: ${b};`);
515
+ const I = {
516
516
  ...E,
517
- ...f > 1 ? { colspan: f } : {},
518
- ...m > 1 ? { rowspan: m } : {},
519
- ...w.length > 0 ? { style: w.join(" ") } : {}
517
+ ...p > 1 ? { colspan: p } : {},
518
+ ...f > 1 ? { rowspan: f } : {},
519
+ ...L.length > 0 ? { style: L.join(" ") } : {}
520
520
  };
521
- return h.render("td", I(S), a.children);
522
- }, fe = (a, h) => {
523
- const { colspan: f, rowspan: m, colwidth: y, backgroundColor: C, textAlign: b, ...E } = a.attrs || {}, w = [];
524
- y && w.push(`width: ${y}px;`), C && w.push(`background-color: ${C};`), b && w.push(`text-align: ${b};`);
525
- const S = {
521
+ return h.render("td", S(I), i.children);
522
+ }, fe = (i, h) => {
523
+ const { colspan: p, rowspan: f, colwidth: m, backgroundColor: v, textAlign: b, ...E } = i.attrs || {}, L = [];
524
+ m && L.push(`width: ${m}px;`), v && L.push(`background-color: ${v};`), b && L.push(`text-align: ${b};`);
525
+ const I = {
526
526
  ...E,
527
- ...f > 1 ? { colspan: f } : {},
528
- ...m > 1 ? { rowspan: m } : {},
529
- ...w.length > 0 ? { style: w.join(" ") } : {}
527
+ ...p > 1 ? { colspan: p } : {},
528
+ ...f > 1 ? { rowspan: f } : {},
529
+ ...L.length > 0 ? { style: L.join(" ") } : {}
530
530
  };
531
- return h.render("th", I(S), a.children);
532
- }, Z = /* @__PURE__ */ new Map([
533
- [k.DOCUMENT, u("")],
534
- [k.HEADING, p],
535
- [k.PARAGRAPH, u("p")],
536
- [k.UL_LIST, u("ul")],
537
- [k.OL_LIST, u("ol")],
538
- [k.LIST_ITEM, u("li")],
539
- [k.IMAGE, d],
540
- [k.EMOJI, L],
541
- [k.CODE_BLOCK, _],
542
- [k.HR, u("hr")],
543
- [k.BR, u("br")],
544
- [k.QUOTE, u("blockquote")],
545
- [k.COMPONENT, ue],
531
+ return h.render("th", S(I), i.children);
532
+ }, J = /* @__PURE__ */ new Map([
533
+ [w.DOCUMENT, u("")],
534
+ [w.HEADING, d],
535
+ [w.PARAGRAPH, u("p")],
536
+ [w.UL_LIST, u("ul")],
537
+ [w.OL_LIST, u("ol")],
538
+ [w.LIST_ITEM, u("li")],
539
+ [w.IMAGE, g],
540
+ [w.EMOJI, C],
541
+ [w.CODE_BLOCK, R],
542
+ [w.HR, u("hr")],
543
+ [w.BR, u("br")],
544
+ [w.QUOTE, u("blockquote")],
545
+ [w.COMPONENT, ue],
546
546
  [De.TEXT, $],
547
- [A.LINK, z],
548
- [A.ANCHOR, z],
549
- [A.STYLED, v("span", !0)],
550
- [A.BOLD, v("strong")],
551
- [A.TEXT_STYLE, v("span", !0)],
552
- [A.ITALIC, v("em")],
553
- [A.UNDERLINE, v("u")],
554
- [A.STRIKE, v("s")],
555
- [A.CODE, v("code")],
556
- [A.SUPERSCRIPT, v("sup")],
557
- [A.SUBSCRIPT, v("sub")],
558
- [A.HIGHLIGHT, v("mark")],
559
- [k.TABLE, he],
560
- [k.TABLE_ROW, de],
561
- [k.TABLE_CELL, pe],
562
- [k.TABLE_HEADER, fe]
563
- ]), J = new Map([...Z, ...Object.entries(o).map(([a, h]) => [a, h])]), me = () => ({
564
- render: (a, h = {}, f) => {
565
- if (l && a) {
566
- const m = t.get(a) || 0;
567
- t.set(a, m + 1), h.key = `${a}-${m}`;
547
+ [A.LINK, Z],
548
+ [A.ANCHOR, Z],
549
+ [A.STYLED, k("span", !0)],
550
+ [A.BOLD, k("strong")],
551
+ [A.TEXT_STYLE, k("span", !0)],
552
+ [A.ITALIC, k("em")],
553
+ [A.UNDERLINE, k("u")],
554
+ [A.STRIKE, k("s")],
555
+ [A.CODE, k("code")],
556
+ [A.SUPERSCRIPT, k("sup")],
557
+ [A.SUBSCRIPT, k("sub")],
558
+ [A.HIGHLIGHT, k("mark")],
559
+ [w.TABLE, he],
560
+ [w.TABLE_ROW, de],
561
+ [w.TABLE_CELL, pe],
562
+ [w.TABLE_HEADER, fe]
563
+ ]), W = new Map([...J, ...Object.entries(o).map(([i, h]) => [i, h])]), me = () => ({
564
+ render: (i, h = {}, p) => {
565
+ if (a && i) {
566
+ const f = t.get(i) || 0;
567
+ t.set(i, f + 1), h.key = `${i}-${f}`;
568
568
  }
569
- return s(a, h, f);
569
+ return s(i, h, p);
570
570
  },
571
- originalResolvers: Z,
572
- mergedResolvers: J
571
+ originalResolvers: J,
572
+ mergedResolvers: W
573
573
  });
574
- function x(a) {
575
- const h = J.get(a.type);
574
+ function x(i) {
575
+ const h = W.get(i.type);
576
576
  if (!h)
577
- return console.error("<Storyblok>", `No resolver found for node type ${a.type}`), "";
578
- const f = me();
579
- if (a.type === "text") return h(a, f);
580
- const m = a.content ? a.content.map(N) : void 0;
577
+ return console.error("<Storyblok>", `No resolver found for node type ${i.type}`), "";
578
+ const p = me();
579
+ if (i.type === "text") return h(i, p);
580
+ const f = i.content ? i.content.map(j) : void 0;
581
581
  return h({
582
- ...a,
583
- children: m
584
- }, f);
582
+ ...i,
583
+ children: f
584
+ }, p);
585
585
  }
586
- function N(a) {
587
- return a.type === "doc" ? i ? a.content.map(x) : a.content.map(x).join("") : Array.isArray(a) ? a.map(x) : x(a);
586
+ function j(i) {
587
+ return i.type === "doc" ? l ? i.content.map(x) : i.content.map(x).join("") : Array.isArray(i) ? i.map(x) : x(i);
588
588
  }
589
- return { render: N };
589
+ return { render: j };
590
590
  }
591
- let te = !1;
592
- const se = [], le = (e) => new Promise((t, s) => {
591
+ let se = !1;
592
+ const re = [], le = (e) => new Promise((t, s) => {
593
593
  if (typeof window > "u") {
594
594
  s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
595
595
  return;
@@ -599,31 +599,31 @@ const se = [], le = (e) => new Promise((t, s) => {
599
599
  console.warn("You are not in Draft Mode or in the Visual Editor.");
600
600
  return;
601
601
  }
602
- te ? o() : se.push(o);
602
+ se ? o() : re.push(o);
603
603
  }, document.getElementById("storyblok-javascript-bridge")) {
604
604
  t(void 0);
605
605
  return;
606
606
  }
607
607
  const r = document.createElement("script");
608
608
  r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (o) => s(o), r.onload = (o) => {
609
- se.forEach((n) => n()), te = !0, t(o);
609
+ re.forEach((n) => n()), se = !0, t(o);
610
610
  }, document.getElementsByTagName("head")[0].appendChild(r);
611
- }), re = (e = "") => e.includes("/cdn/"), ze = (e, t = 25, s = 1) => ({
611
+ }), D = (e = "") => e.includes("/cdn/"), ze = (e, t = 25, s = 1) => ({
612
612
  ...e,
613
613
  per_page: t,
614
614
  page: s
615
615
  }), Ze = (e) => new Promise((t) => setTimeout(t, e)), Je = (e = 0, t) => Array.from({ length: e }, t), We = (e = 0, t = e) => {
616
616
  const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
617
617
  return Je(s, (o, n) => n * r + e);
618
- }, Ye = async (e, t) => Promise.all(e.map(t)), Ke = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), G = (e, t, s) => {
618
+ }, Ye = async (e, t) => Promise.all(e.map(t)), Ke = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), z = (e, t, s) => {
619
619
  const r = [];
620
620
  for (const o in e) {
621
621
  if (!Object.prototype.hasOwnProperty.call(e, o)) continue;
622
622
  const n = e[o];
623
623
  if (n == null) continue;
624
- const l = s ? "" : encodeURIComponent(o);
625
- let i;
626
- typeof n == "object" ? i = G(n, t ? t + encodeURIComponent(`[${l}]`) : l, Array.isArray(n)) : i = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(n)}`, r.push(i);
624
+ const a = s ? "" : encodeURIComponent(o);
625
+ let l;
626
+ typeof n == "object" ? l = z(n, t ? t + encodeURIComponent(`[${a}]`) : a, Array.isArray(n)) : l = `${t ? t + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, r.push(l);
627
627
  }
628
628
  return r.join("&");
629
629
  }, oe = (e) => {
@@ -638,7 +638,7 @@ const se = [], le = (e) => new Promise((t, s) => {
638
638
  };
639
639
  var Xe = class {
640
640
  constructor(e) {
641
- g(this, "baseURL"), g(this, "timeout"), g(this, "headers"), g(this, "responseInterceptor"), g(this, "fetch"), g(this, "ejectInterceptor"), g(this, "url"), g(this, "parameters"), g(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
641
+ y(this, "baseURL"), y(this, "timeout"), y(this, "headers"), y(this, "responseInterceptor"), y(this, "fetch"), y(this, "ejectInterceptor"), y(this, "url"), y(this, "parameters"), y(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
642
642
  }
643
643
  /**
644
644
  *
@@ -673,23 +673,23 @@ var Xe = class {
673
673
  }
674
674
  async _methodHandler(e) {
675
675
  let t = `${this.baseURL}${this.url}`, s = null;
676
- e === "get" ? t = `${this.baseURL}${this.url}?${G(this.parameters)}` : s = JSON.stringify(this.parameters);
676
+ e === "get" ? t = `${this.baseURL}${this.url}?${z(this.parameters)}` : s = JSON.stringify(this.parameters);
677
677
  const r = new URL(t), o = new AbortController(), { signal: n } = o;
678
- let l = null;
679
- this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
678
+ let a = null;
679
+ this.timeout && (a = setTimeout(() => o.abort(), this.timeout));
680
680
  try {
681
- const i = await this.fetch(`${r}`, {
681
+ const l = await this.fetch(`${r}`, {
682
682
  method: e,
683
683
  headers: this.headers,
684
684
  body: s,
685
685
  signal: n,
686
686
  ...this.fetchOptions
687
687
  });
688
- this.timeout && l && clearTimeout(l);
689
- const c = await this._responseHandler(i);
688
+ this.timeout && a && clearTimeout(a);
689
+ const c = await this._responseHandler(l);
690
690
  return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
691
- } catch (i) {
692
- return { message: i };
691
+ } catch (l) {
692
+ return l.name === "AbortError" ? { message: "Request timeout: The request was aborted due to timeout" } : { message: l.message || l.toString() || "An unknown error occurred" };
693
693
  }
694
694
  }
695
695
  setFetchOptions(e = {}) {
@@ -728,14 +728,14 @@ var Xe = class {
728
728
  });
729
729
  }
730
730
  }, Qe = Xe;
731
- const ne = "SB-Agent", j = {
731
+ const ne = "SB-Agent", U = {
732
732
  defaultAgentName: "SB-JS-CLIENT",
733
733
  defaultAgentVersion: "SB-Agent-Version",
734
734
  packageVersion: "7.0.0"
735
735
  }, ce = {
736
736
  DRAFT: "draft",
737
737
  PUBLISHED: "published"
738
- }, et = 25, D = {
738
+ }, et = 25, V = {
739
739
  SMALL: 25,
740
740
  MEDIUM: 50,
741
741
  LARGE: 75
@@ -744,7 +744,7 @@ const ne = "SB-Agent", j = {
744
744
  MEDIUM: 15,
745
745
  LARGE: 10,
746
746
  VERY_LARGE: 6
747
- }, U = 1e3, V = 3;
747
+ }, B = 1e3, P = 3;
748
748
  function tt(e) {
749
749
  return e.version === ce.DRAFT;
750
750
  }
@@ -753,13 +753,13 @@ function st(e, t) {
753
753
  return s && r || o;
754
754
  }
755
755
  function rt(e) {
756
- return e <= D.SMALL ? O.SINGLE_OR_SMALL : e <= D.MEDIUM ? O.MEDIUM : e <= D.LARGE ? O.LARGE : O.VERY_LARGE;
756
+ return e <= V.SMALL ? O.SINGLE_OR_SMALL : e <= V.MEDIUM ? O.MEDIUM : e <= V.LARGE ? O.LARGE : O.VERY_LARGE;
757
757
  }
758
- function P(e, t, s = {}, r) {
759
- if (s.userRateLimit !== void 0) return Math.min(s.userRateLimit, U);
760
- if (s.serverHeadersRateLimit !== void 0) return Math.min(s.serverHeadersRateLimit, U);
761
- if (t && !tt(t)) return U;
758
+ function H(e, t, s = {}, r) {
759
+ if (s.userRateLimit !== void 0) return Math.min(s.userRateLimit, B);
760
+ if (s.serverHeadersRateLimit !== void 0) return Math.min(s.serverHeadersRateLimit, B);
762
761
  if (r !== void 0) return r;
762
+ if (t && !tt(t)) return B;
763
763
  if (st(e, t)) return O.SINGLE_OR_SMALL;
764
764
  const o = t.per_page || et;
765
765
  return rt(o);
@@ -795,34 +795,34 @@ function at(e, t, s) {
795
795
  if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
796
796
  if (!Number.isFinite(s)) throw new TypeError("Expected `interval` to be a finite number");
797
797
  const r = [];
798
- let o = [], n = 0, l = !1;
799
- const i = async () => {
798
+ let o = [], n = 0, a = !1;
799
+ const l = async () => {
800
800
  n++;
801
801
  const u = r.shift();
802
802
  if (u) try {
803
- const p = await e(...u.args);
804
- u.resolve(p);
805
- } catch (p) {
806
- u.reject(p);
803
+ const d = await e(...u.args);
804
+ u.resolve(d);
805
+ } catch (d) {
806
+ u.reject(d);
807
807
  }
808
- const d = setTimeout(() => {
809
- n--, r.length > 0 && i(), o = o.filter((p) => p !== d);
808
+ const g = setTimeout(() => {
809
+ n--, r.length > 0 && l(), o = o.filter((d) => d !== g);
810
810
  }, s);
811
- o.includes(d) || o.push(d);
812
- }, c = (...u) => l ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((d, p) => {
811
+ o.includes(g) || o.push(g);
812
+ }, c = (...u) => a ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((g, d) => {
813
813
  r.push({
814
- resolve: d,
815
- reject: p,
814
+ resolve: g,
815
+ reject: d,
816
816
  args: u
817
- }), n < t && i();
817
+ }), n < t && l();
818
818
  });
819
819
  return c.abort = () => {
820
- l = !0, o.forEach(clearTimeout), o = [], r.forEach((u) => u.reject(() => new it("Throttle function aborted"))), r.length = 0;
820
+ a = !0, o.forEach(clearTimeout), o = [], r.forEach((u) => u.reject(() => new it("Throttle function aborted"))), r.length = 0;
821
821
  }, c;
822
822
  }
823
823
  var lt = at, ct = class {
824
824
  constructor(e, t = 1e3) {
825
- g(this, "queues"), g(this, "interval"), g(this, "throttledRequestFn"), this.queues = /* @__PURE__ */ new Map(), this.interval = t, this.throttledRequestFn = e;
825
+ y(this, "queues"), y(this, "interval"), y(this, "throttledRequestFn"), this.queues = /* @__PURE__ */ new Map(), this.interval = t, this.throttledRequestFn = e;
826
826
  }
827
827
  /**
828
828
  * Gets or creates a throttle queue for the specified rate limit
@@ -853,8 +853,8 @@ var lt = at, ct = class {
853
853
  return this.queues.size;
854
854
  }
855
855
  };
856
- let H = {};
857
- const R = {};
856
+ let N = {};
857
+ const _ = {};
858
858
  var ut = class {
859
859
  /**
860
860
  *
@@ -862,7 +862,7 @@ var ut = class {
862
862
  * @param pEndpoint string, optional
863
863
  */
864
864
  constructor(e, t) {
865
- g(this, "client"), g(this, "maxRetries"), g(this, "retriesDelay"), g(this, "throttleManager"), g(this, "accessToken"), g(this, "cache"), g(this, "resolveCounter"), g(this, "relations"), g(this, "links"), g(this, "version"), g(this, "rateLimitConfig"), g(this, "richTextResolver"), g(this, "resolveNestedRelations"), g(this, "stringifiedStoriesCache"), g(this, "inlineAssets");
865
+ y(this, "client"), y(this, "maxRetries"), y(this, "retriesDelay"), y(this, "throttleManager"), y(this, "accessToken"), y(this, "cache"), y(this, "resolveCounter"), y(this, "relations"), y(this, "links"), y(this, "version"), y(this, "rateLimitConfig"), y(this, "richTextResolver"), y(this, "resolveNestedRelations"), y(this, "stringifiedStoriesCache"), y(this, "inlineAssets");
866
866
  let s = e.endpoint || t;
867
867
  if (!s) {
868
868
  const o = e.https === !1 ? "http" : "https";
@@ -871,7 +871,7 @@ var ut = class {
871
871
  const r = new Headers();
872
872
  r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([o, n]) => {
873
873
  r.set(o, n);
874
- }), r.has(ne) || (r.set(ne, j.defaultAgentName), r.set(j.defaultAgentVersion, j.packageVersion)), e.oauthToken && r.set("Authorization", e.oauthToken), this.rateLimitConfig = nt(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new ct(this.throttledRequest.bind(this), 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ce.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Qe({
874
+ }), r.has(ne) || (r.set(ne, U.defaultAgentName), r.set(U.defaultAgentVersion, U.packageVersion)), e.oauthToken && r.set("Authorization", e.oauthToken), this.rateLimitConfig = nt(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new ct(this.throttledRequest.bind(this), 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ce.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Qe({
875
875
  baseURL: s,
876
876
  timeout: e.timeout || 0,
877
877
  headers: r,
@@ -880,10 +880,10 @@ var ut = class {
880
880
  });
881
881
  }
882
882
  parseParams(e) {
883
- return e.token || (e.token = this.getToken()), e.cv || (e.cv = R[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
883
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = _[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
884
884
  }
885
885
  factoryParamOptions(e, t) {
886
- return re(e) ? this.parseParams(t) : t;
886
+ return D(e) ? this.parseParams(t) : t;
887
887
  }
888
888
  makeRequest(e, t, s, r, o) {
889
889
  const n = this.factoryParamOptions(e, ze(t, s, r));
@@ -892,27 +892,27 @@ var ut = class {
892
892
  get(e, t = {}, s) {
893
893
  t || (t = {});
894
894
  const r = `/${e}`;
895
- re(r) && (t.version = t.version || this.version);
895
+ D(r) && (t.version = t.version || this.version);
896
896
  const o = this.factoryParamOptions(r, t);
897
897
  return this.cacheResponse(r, o, void 0, s);
898
898
  }
899
899
  async getAll(e, t = {}, s, r) {
900
- const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), l = s ?? n.substring(n.lastIndexOf("/") + 1);
900
+ const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), a = s ?? n.substring(n.lastIndexOf("/") + 1);
901
901
  t.version = t.version || this.version;
902
- const i = 1, c = await this.makeRequest(n, t, o, i, r), u = c.total ? Math.ceil(c.total / (c.perPage || o)) : 1, d = await Ye(We(i, u), (p) => this.makeRequest(n, t, o, p + 1, r));
903
- return Ke([c, ...d], (p) => Object.values(p.data[l]));
902
+ const l = 1, c = await this.makeRequest(n, t, o, l, r), u = c.total ? Math.ceil(c.total / (c.perPage || o)) : 1, g = await Ye(We(l, u), (d) => this.makeRequest(n, t, o, d + 1, r));
903
+ return Ke([c, ...g], (d) => Object.values(d.data[a]));
904
904
  }
905
905
  post(e, t = {}, s) {
906
- const r = `/${e}`, o = P(void 0, void 0, this.rateLimitConfig, V);
906
+ const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
907
907
  return this.throttleManager.execute(o, "post", r, t, s);
908
908
  }
909
909
  put(e, t = {}, s) {
910
- const r = `/${e}`, o = P(void 0, void 0, this.rateLimitConfig, V);
910
+ const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
911
911
  return this.throttleManager.execute(o, "put", r, t, s);
912
912
  }
913
913
  delete(e, t = {}, s) {
914
914
  t || (t = {});
915
- const r = `/${e}`, o = P(void 0, void 0, this.rateLimitConfig, V);
915
+ const r = `/${e}`, o = H(void 0, void 0, this.rateLimitConfig, P);
916
916
  return this.throttleManager.execute(o, "delete", r, t, s);
917
917
  }
918
918
  getStories(e = {}, t) {
@@ -994,10 +994,10 @@ var ut = class {
994
994
  iterateTree(e, t, s) {
995
995
  const r = (o, n = "") => {
996
996
  if (!(!o || o._stopResolving)) {
997
- if (Array.isArray(o)) o.forEach((l, i) => r(l, `${n}[${i}]`));
998
- else if (typeof o == "object") for (const l in o) {
999
- const i = n ? `${n}.${l}` : l;
1000
- (o.component && o._uid || o.type === "link") && (this._insertRelations(o, l, t, s), this._insertLinks(o, l, s)), r(o[l], i);
997
+ if (Array.isArray(o)) o.forEach((a, l) => r(a, `${n}[${l}]`));
998
+ else if (typeof o == "object") for (const a in o) {
999
+ const l = n ? `${n}.${a}` : a;
1000
+ (o.component && o._uid || o.type === "link") && (this._insertRelations(o, a, t, s), this._insertLinks(o, a, s)), r(o[a], l);
1001
1001
  }
1002
1002
  }
1003
1003
  };
@@ -1006,18 +1006,18 @@ var ut = class {
1006
1006
  async resolveLinks(e, t, s) {
1007
1007
  let r = [];
1008
1008
  if (e.link_uuids) {
1009
- const o = e.link_uuids.length, n = [], l = 50;
1010
- for (let i = 0; i < o; i += l) {
1011
- const c = Math.min(o, i + l);
1012
- n.push(e.link_uuids.slice(i, c));
1009
+ const o = e.link_uuids.length, n = [], a = 50;
1010
+ for (let l = 0; l < o; l += a) {
1011
+ const c = Math.min(o, l + a);
1012
+ n.push(e.link_uuids.slice(l, c));
1013
1013
  }
1014
- for (let i = 0; i < n.length; i++)
1014
+ for (let l = 0; l < n.length; l++)
1015
1015
  (await this.getStories({
1016
- per_page: l,
1016
+ per_page: a,
1017
1017
  language: t.language,
1018
1018
  version: t.version,
1019
1019
  starts_with: t.starts_with,
1020
- by_uuids: n[i].join(",")
1020
+ by_uuids: n[l].join(",")
1021
1021
  })).data.stories.forEach((c) => {
1022
1022
  r.push(c);
1023
1023
  });
@@ -1032,18 +1032,18 @@ var ut = class {
1032
1032
  async resolveRelations(e, t, s) {
1033
1033
  let r = [];
1034
1034
  if (e.rel_uuids) {
1035
- const o = e.rel_uuids.length, n = [], l = 50;
1036
- for (let i = 0; i < o; i += l) {
1037
- const c = Math.min(o, i + l);
1038
- n.push(e.rel_uuids.slice(i, c));
1035
+ const o = e.rel_uuids.length, n = [], a = 50;
1036
+ for (let l = 0; l < o; l += a) {
1037
+ const c = Math.min(o, l + a);
1038
+ n.push(e.rel_uuids.slice(l, c));
1039
1039
  }
1040
- for (let i = 0; i < n.length; i++)
1040
+ for (let l = 0; l < n.length; l++)
1041
1041
  (await this.getStories({
1042
- per_page: l,
1042
+ per_page: a,
1043
1043
  language: t.language,
1044
1044
  version: t.version,
1045
1045
  starts_with: t.starts_with,
1046
- by_uuids: n[i].join(","),
1046
+ by_uuids: n[l].join(","),
1047
1047
  excluding_fields: t.excluding_fields
1048
1048
  })).data.stories.forEach((c) => {
1049
1049
  r.push(c);
@@ -1074,45 +1074,45 @@ var ut = class {
1074
1074
  "story",
1075
1075
  "url",
1076
1076
  "link"
1077
- ].includes(t.resolve_links) && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations) for (const l in this.relations[s]) this.iterateTree(this.relations[s][l], n, s);
1078
- e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((l) => {
1079
- this.iterateTree(l, n, s);
1077
+ ].includes(t.resolve_links) && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations) for (const a in this.relations[s]) this.iterateTree(this.relations[s][a], n, s);
1078
+ e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((a) => {
1079
+ this.iterateTree(a, n, s);
1080
1080
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
1081
1081
  }
1082
1082
  async cacheResponse(e, t, s, r) {
1083
- const o = G({
1083
+ const o = z({
1084
1084
  url: e,
1085
1085
  params: t
1086
1086
  }), n = this.cacheProvider();
1087
1087
  if (t.version === "published" && e !== "/cdn/spaces/me") {
1088
- const i = await n.get(o);
1089
- if (i) return Promise.resolve(i);
1088
+ const c = await n.get(o);
1089
+ if (c) return Promise.resolve(c);
1090
1090
  }
1091
- const l = P(e, t, this.rateLimitConfig);
1092
- return new Promise(async (i, c) => {
1093
- var u;
1091
+ const a = !D(e) && this.rateLimitConfig.isManagementApi ? P : void 0, l = H(e, t, this.rateLimitConfig, a);
1092
+ return new Promise(async (c, u) => {
1093
+ var g;
1094
1094
  try {
1095
1095
  const d = await this.throttleManager.execute(l, "get", e, t, r);
1096
- if (d.status !== 200) return c(d);
1097
- let p = {
1096
+ if (d.status !== 200) return u(d);
1097
+ let C = {
1098
1098
  data: d.data,
1099
1099
  headers: d.headers
1100
1100
  };
1101
- const L = ot(d.headers);
1102
- if ((L == null ? void 0 : L.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = L.max), (u = d.headers) != null && u["per-page"] && (p = Object.assign({}, p, {
1101
+ const R = ot(d.headers);
1102
+ if ((R == null ? void 0 : R.max) !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = R.max), (g = d.headers) != null && g["per-page"] && (C = Object.assign({}, C, {
1103
1103
  perPage: d.headers["per-page"] ? Number.parseInt(d.headers["per-page"]) : 0,
1104
1104
  total: d.headers["per-page"] ? Number.parseInt(d.headers.total) : 0
1105
- })), p.data.story || p.data.stories) {
1106
- const v = this.resolveCounter = ++this.resolveCounter % 1e3;
1107
- await this.resolveStories(p.data, t, `${v}`), p = await this.processInlineAssets(p);
1105
+ })), C.data.story || C.data.stories) {
1106
+ const T = this.resolveCounter = ++this.resolveCounter % 1e3;
1107
+ await this.resolveStories(C.data, t, `${T}`), C = await this.processInlineAssets(C);
1108
1108
  }
1109
- t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, p);
1110
- const _ = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
1111
- return t.token && p.data.cv && (_ && R[t.token] && R[t.token] !== p.data.cv && await this.flushCache(), R[t.token] = p.data.cv), i(p);
1109
+ t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, C);
1110
+ const k = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
1111
+ return t.token && C.data.cv && (k && _[t.token] && _[t.token] !== C.data.cv && await this.flushCache(), _[t.token] = C.data.cv), c(C);
1112
1112
  } catch (d) {
1113
1113
  if (d.response && d.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
1114
- return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Ze(this.retriesDelay), this.cacheResponse(e, t, s).then(i).catch(c);
1115
- c(d);
1114
+ return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Ze(this.retriesDelay), this.cacheResponse(e, t, s).then(c).catch(u);
1115
+ u(d);
1116
1116
  }
1117
1117
  });
1118
1118
  }
@@ -1120,32 +1120,32 @@ var ut = class {
1120
1120
  return this.client.setFetchOptions(r), this.client[e](t, s);
1121
1121
  }
1122
1122
  cacheVersions() {
1123
- return R;
1123
+ return _;
1124
1124
  }
1125
1125
  cacheVersion() {
1126
- return R[this.accessToken];
1126
+ return _[this.accessToken];
1127
1127
  }
1128
1128
  setCacheVersion(e) {
1129
- this.accessToken && (R[this.accessToken] = e);
1129
+ this.accessToken && (_[this.accessToken] = e);
1130
1130
  }
1131
1131
  clearCacheVersion() {
1132
- this.accessToken && (R[this.accessToken] = 0);
1132
+ this.accessToken && (_[this.accessToken] = 0);
1133
1133
  }
1134
1134
  cacheProvider() {
1135
1135
  switch (this.cache.type) {
1136
1136
  case "memory":
1137
1137
  return {
1138
1138
  get(e) {
1139
- return Promise.resolve(H[e]);
1139
+ return Promise.resolve(N[e]);
1140
1140
  },
1141
1141
  getAll() {
1142
- return Promise.resolve(H);
1142
+ return Promise.resolve(N);
1143
1143
  },
1144
1144
  set(e, t) {
1145
- return H[e] = t, Promise.resolve(void 0);
1145
+ return N[e] = t, Promise.resolve(void 0);
1146
1146
  },
1147
1147
  flush() {
1148
- return H = {}, Promise.resolve(void 0);
1148
+ return N = {}, Promise.resolve(void 0);
1149
1149
  }
1150
1150
  };
1151
1151
  case "custom":
@@ -1217,17 +1217,17 @@ const bt = (e = {}) => {
1217
1217
  bridge: r,
1218
1218
  accessToken: o,
1219
1219
  use: n = [],
1220
- apiOptions: l = {},
1221
- bridgeUrl: i
1220
+ apiOptions: a = {},
1221
+ bridgeUrl: l
1222
1222
  } = e;
1223
- l.accessToken = l.accessToken || o;
1224
- const c = { bridge: r, apiOptions: l };
1223
+ a.accessToken = a.accessToken || o;
1224
+ const c = { bridge: r, apiOptions: a };
1225
1225
  let u = {};
1226
- n.forEach((p) => {
1227
- u = { ...u, ...p(c) };
1228
- }), i && (F = i);
1229
- const d = !(typeof window > "u") && ((s = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : s.includes("_storyblok_tk"));
1230
- return r !== !1 && d && le(F), u;
1226
+ n.forEach((d) => {
1227
+ u = { ...u, ...d(c) };
1228
+ }), l && (F = l);
1229
+ const g = !(typeof window > "u") && ((s = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : s.includes("_storyblok_tk"));
1230
+ return r !== !1 && g && le(F), u;
1231
1231
  };
1232
1232
  function Ct(e, t) {
1233
1233
  return Ge(t).render(e);
@@ -1243,6 +1243,6 @@ export {
1243
1243
  ft as storyblok,
1244
1244
  gt as storyblokEditable,
1245
1245
  bt as storyblokInit,
1246
- Se as toCamelCase,
1246
+ Ie as toCamelCase,
1247
1247
  dt as useStoryblokApi
1248
1248
  };