@storyblok/js 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,39 +4,39 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- function te(r, e) {
7
+ function se(r, e) {
8
8
  if (!e)
9
9
  return { src: r, attrs: {} };
10
10
  let t = 0, o = 0;
11
11
  const s = {}, n = [];
12
- function a(h, c, d, y, T) {
13
- typeof h != "number" || h <= c || h >= d ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${c} and ${d} (inclusive)`) : T.push(`${y}(${h})`);
12
+ function l(a, h, d, y, T) {
13
+ typeof a != "number" || a <= h || a >= d ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${h} and ${d} (inclusive)`) : T.push(`${y}(${a})`);
14
14
  }
15
15
  if (typeof e == "object") {
16
16
  if (typeof e.width == "number" && e.width > 0 ? (s.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (s.height = e.height, o = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (s.loading = e.loading), e.class && (s.class = e.class), e.filters) {
17
- const { filters: h } = e || {}, { blur: c, brightness: d, fill: y, format: T, grayscale: A, quality: _, rotate: S } = h || {};
18
- c && a(c, 0, 100, "blur", n), _ && a(_, 0, 100, "quality", n), d && a(d, 0, 100, "brightness", n), y && n.push(`fill(${y})`), A && n.push("grayscale()"), S && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${S})`), T && ["webp", "png", "jpeg"].includes(T) && n.push(`format(${T})`);
17
+ const { filters: a } = e || {}, { blur: h, brightness: d, fill: y, format: T, grayscale: R, quality: A, rotate: I } = a || {};
18
+ h && l(h, 0, 100, "blur", n), A && l(A, 0, 100, "quality", n), d && l(d, 0, 100, "brightness", n), y && n.push(`fill(${y})`), R && n.push("grayscale()"), I && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${I})`), T && ["webp", "png", "jpeg"].includes(T) && n.push(`format(${T})`);
19
19
  }
20
- e.srcset && (s.srcset = e.srcset.map((h) => {
21
- if (typeof h == "number")
22
- return `${r}/m/${h}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
23
- if (Array.isArray(h) && h.length === 2) {
24
- const [c, d] = h;
25
- return `${r}/m/${c}x${d}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
20
+ e.srcset && (s.srcset = e.srcset.map((a) => {
21
+ if (typeof a == "number")
22
+ return `${r}/m/${a}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${a}w`;
23
+ if (Array.isArray(a) && a.length === 2) {
24
+ const [h, d] = a;
25
+ return `${r}/m/${h}x${d}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
26
26
  } else {
27
27
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
28
28
  return;
29
29
  }
30
30
  }).join(", ")), e.sizes && (s.sizes = e.sizes.join(", "));
31
31
  }
32
- let l = `${r}/m/`;
33
- return t > 0 && o > 0 && (l = `${l}${t}x${o}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
34
- src: l,
32
+ let c = `${r}/m/`;
33
+ return t > 0 && o > 0 && (c = `${c}${t}x${o}/`), n.length > 0 && (c = `${c}filters:${n.join(":")}`), {
34
+ src: c,
35
35
  attrs: s
36
36
  };
37
37
  }
38
- var v = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r.TABLE = "table", r.TABLE_ROW = "tableRow", r.TABLE_CELL = "tableCell", r.TABLE_HEADER = "tableHeader", r))(v || {}), R = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(R || {}), F = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(F || {}), I = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(I || {});
39
- const se = [
38
+ var v = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r.TABLE = "table", r.TABLE_ROW = "tableRow", r.TABLE_CELL = "tableCell", r.TABLE_HEADER = "tableHeader", r))(v || {}), _ = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(_ || {}), V = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(V || {}), S = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(S || {});
39
+ const re = [
40
40
  "area",
41
41
  "base",
42
42
  "br",
@@ -51,43 +51,37 @@ const se = [
51
51
  "source",
52
52
  "track",
53
53
  "wbr"
54
- ], re = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), oe = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
55
- function ne(r) {
54
+ ], oe = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), ne = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
55
+ function ie(r) {
56
56
  return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
57
57
  }
58
58
  const O = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
59
- function H(r, e = {}, t) {
60
- const o = re(e), s = o ? `${r} ${o}` : r, n = Array.isArray(t) ? t.join("") : t || "";
59
+ function D(r, e = {}, t) {
60
+ const o = oe(e), s = o ? `${r} ${o}` : r, n = Array.isArray(t) ? t.join("") : t || "";
61
61
  if (r) {
62
- if (se.includes(r))
62
+ if (re.includes(r))
63
63
  return `<${s}>`;
64
64
  } else return n;
65
65
  return `<${s}>${n}</${r}>`;
66
66
  }
67
- function ie(r = {}) {
67
+ function ae(r = {}) {
68
68
  const e = /* @__PURE__ */ new Map(), {
69
- renderFn: t = H,
70
- textFn: o = ne,
69
+ renderFn: t = D,
70
+ textFn: o = ie,
71
71
  resolvers: s = {},
72
72
  optimizeImages: n = !1,
73
- keyedResolvers: a = !1
74
- } = r, l = t !== H, h = () => ({ render: (i, u = {}, p) => {
75
- if (a && i) {
76
- const f = e.get(i) || 0;
77
- e.set(i, f + 1), u.key = `${i}-${f}`;
78
- }
79
- return t(i, u, p);
80
- } }), c = (i) => (u, p) => {
73
+ keyedResolvers: l = !1
74
+ } = r, c = t !== D, a = (i) => (u, p) => {
81
75
  const f = u.attrs || {};
82
76
  return p.render(i, f, u.children || null);
83
- }, d = (i, u) => {
77
+ }, h = (i, u) => {
84
78
  const { src: p, alt: f, title: m, srcset: w, sizes: b } = i.attrs || {};
85
79
  let k = p, $ = {};
86
80
  if (n) {
87
- const { src: Z, attrs: ee } = te(p, n);
88
- k = Z, $ = ee;
81
+ const { src: ee, attrs: te } = se(p, n);
82
+ k = ee, $ = te;
89
83
  }
90
- const Q = {
84
+ const Z = {
91
85
  src: k,
92
86
  alt: f,
93
87
  title: m,
@@ -95,11 +89,11 @@ function ie(r = {}) {
95
89
  sizes: b,
96
90
  ...$
97
91
  };
98
- return u.render("img", O(Q));
99
- }, y = (i, u) => {
92
+ return u.render("img", O(Z));
93
+ }, d = (i, u) => {
100
94
  const { level: p, ...f } = i.attrs || {};
101
95
  return u.render(`h${p}`, f, i.children);
102
- }, T = (i, u) => {
96
+ }, y = (i, u) => {
103
97
  var p, f, m, w;
104
98
  const b = u.render("img", {
105
99
  src: (p = i.attrs) == null ? void 0 : p.fallbackImage,
@@ -113,45 +107,45 @@ function ie(r = {}) {
113
107
  "data-name": (m = i.attrs) == null ? void 0 : m.name,
114
108
  "data-emoji": (w = i.attrs) == null ? void 0 : w.emoji
115
109
  }, b);
116
- }, A = (i, u) => u.render(
110
+ }, T = (i, u) => u.render(
117
111
  "pre",
118
112
  i.attrs || {},
119
113
  u.render("code", {}, i.children || "")
120
- ), _ = (i, u = !1) => ({ text: p, attrs: f }, m) => {
114
+ ), R = (i, u = !1) => ({ text: p, attrs: f }, m) => {
121
115
  const { class: w, id: b, ...k } = f || {}, $ = u ? {
122
116
  class: w,
123
117
  id: b,
124
- style: oe(k) || void 0
118
+ style: ne(k) || void 0
125
119
  } : f || {};
126
120
  return m.render(i, O($), p);
127
- }, S = (i) => C(i), V = (i) => {
121
+ }, A = (i) => C(i), I = (i) => {
128
122
  const { marks: u, ...p } = i;
129
123
  if ("text" in i) {
130
124
  if (u)
131
125
  return u.reduce(
132
- (m, w) => S({ ...w, text: m }),
133
- S({ ...p, children: p.children })
126
+ (m, w) => A({ ...w, text: m }),
127
+ A({ ...p, children: p.children })
134
128
  );
135
129
  const f = i.attrs || {};
136
- if (a) {
130
+ if (l) {
137
131
  const m = e.get("txt") || 0;
138
132
  e.set("txt", m + 1), f.key = `txt-${m}`;
139
133
  }
140
134
  return o(p.text, f);
141
135
  }
142
136
  return "";
143
- }, B = (i, u) => {
137
+ }, H = (i, u) => {
144
138
  const { linktype: p, href: f, anchor: m, ...w } = i.attrs || {};
145
139
  let b = "";
146
140
  switch (p) {
147
- case I.ASSET:
148
- case I.URL:
141
+ case S.ASSET:
142
+ case S.URL:
149
143
  b = f;
150
144
  break;
151
- case I.EMAIL:
145
+ case S.EMAIL:
152
146
  b = `mailto:${f}`;
153
147
  break;
154
- case I.STORY:
148
+ case S.STORY:
155
149
  b = f, m && (b = `${b}#${m}`);
156
150
  break;
157
151
  default:
@@ -160,71 +154,83 @@ function ie(r = {}) {
160
154
  }
161
155
  const k = { ...w };
162
156
  return b && (k.href = b), u.render("a", k, i.text);
163
- }, q = (i, u) => {
157
+ }, J = (i, u) => {
164
158
  var p, f;
165
159
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), u.render("span", {
166
160
  blok: (p = i == null ? void 0 : i.attrs) == null ? void 0 : p.body[0],
167
161
  id: (f = i.attrs) == null ? void 0 : f.id,
168
162
  style: "display: none"
169
163
  });
170
- }, J = (i, u) => {
164
+ }, Y = (i, u) => {
171
165
  const p = {}, f = u.render("tbody", {}, i.children);
172
166
  return u.render("table", p, f);
173
- }, Y = (i, u) => {
167
+ }, K = (i, u) => {
174
168
  const p = {};
175
169
  return u.render("tr", p, i.children);
176
- }, K = (i, u) => {
170
+ }, W = (i, u) => {
177
171
  const { colspan: p, rowspan: f, colwidth: m, backgroundColor: w, ...b } = i.attrs || {}, k = {
178
172
  ...b
179
173
  };
180
174
  p > 1 && (k.colspan = p), f > 1 && (k.rowspan = f);
181
175
  const $ = [];
182
176
  return m && $.push(`width: ${m}px;`), w && $.push(`background-color: ${w};`), $.length > 0 && (k.style = $.join(" ")), u.render("td", O(k), i.children);
183
- }, W = (i, u) => {
177
+ }, X = (i, u) => {
184
178
  const { colspan: p, rowspan: f, colwidth: m, backgroundColor: w, ...b } = i.attrs || {}, k = {
185
179
  ...b
186
180
  };
187
181
  p > 1 && (k.colspan = p), f > 1 && (k.rowspan = f);
188
182
  const $ = [];
189
183
  return m && $.push(`width: ${m}px;`), w && $.push(`background-color: ${w};`), $.length > 0 && (k.style = $.join(" ")), u.render("th", O(k), i.children);
190
- }, X = new Map([
191
- [v.DOCUMENT, c("")],
192
- [v.HEADING, y],
193
- [v.PARAGRAPH, c("p")],
194
- [v.UL_LIST, c("ul")],
195
- [v.OL_LIST, c("ol")],
196
- [v.LIST_ITEM, c("li")],
197
- [v.IMAGE, d],
198
- [v.EMOJI, T],
199
- [v.CODE_BLOCK, A],
200
- [v.HR, c("hr")],
201
- [v.BR, c("br")],
202
- [v.QUOTE, c("blockquote")],
203
- [v.COMPONENT, q],
204
- [F.TEXT, V],
205
- [R.LINK, B],
206
- [R.ANCHOR, B],
207
- [R.STYLED, _("span", !0)],
208
- [R.BOLD, _("strong")],
209
- [R.TEXT_STYLE, _("span", !0)],
210
- [R.ITALIC, _("em")],
211
- [R.UNDERLINE, _("u")],
212
- [R.STRIKE, _("s")],
213
- [R.CODE, _("code")],
214
- [R.SUPERSCRIPT, _("sup")],
215
- [R.SUBSCRIPT, _("sub")],
216
- [R.HIGHLIGHT, _("mark")],
217
- [v.TABLE, J],
218
- [v.TABLE_ROW, Y],
219
- [v.TABLE_CELL, K],
220
- [v.TABLE_HEADER, W],
184
+ }, B = /* @__PURE__ */ new Map([
185
+ [v.DOCUMENT, a("")],
186
+ [v.HEADING, d],
187
+ [v.PARAGRAPH, a("p")],
188
+ [v.UL_LIST, a("ul")],
189
+ [v.OL_LIST, a("ol")],
190
+ [v.LIST_ITEM, a("li")],
191
+ [v.IMAGE, h],
192
+ [v.EMOJI, y],
193
+ [v.CODE_BLOCK, T],
194
+ [v.HR, a("hr")],
195
+ [v.BR, a("br")],
196
+ [v.QUOTE, a("blockquote")],
197
+ [v.COMPONENT, J],
198
+ [V.TEXT, I],
199
+ [_.LINK, H],
200
+ [_.ANCHOR, H],
201
+ [_.STYLED, R("span", !0)],
202
+ [_.BOLD, R("strong")],
203
+ [_.TEXT_STYLE, R("span", !0)],
204
+ [_.ITALIC, R("em")],
205
+ [_.UNDERLINE, R("u")],
206
+ [_.STRIKE, R("s")],
207
+ [_.CODE, R("code")],
208
+ [_.SUPERSCRIPT, R("sup")],
209
+ [_.SUBSCRIPT, R("sub")],
210
+ [_.HIGHLIGHT, R("mark")],
211
+ [v.TABLE, Y],
212
+ [v.TABLE_ROW, K],
213
+ [v.TABLE_CELL, W],
214
+ [v.TABLE_HEADER, X]
215
+ ]), U = new Map([
216
+ ...B,
221
217
  ...Object.entries(s).map(([i, u]) => [i, u])
222
- ]);
218
+ ]), Q = () => ({
219
+ render: (i, u = {}, p) => {
220
+ if (l && i) {
221
+ const f = e.get(i) || 0;
222
+ e.set(i, f + 1), u.key = `${i}-${f}`;
223
+ }
224
+ return t(i, u, p);
225
+ },
226
+ originalResolvers: B,
227
+ mergedResolvers: U
228
+ });
223
229
  function L(i) {
224
- const u = X.get(i.type);
230
+ const u = U.get(i.type);
225
231
  if (!u)
226
232
  return console.error("<Storyblok>", `No resolver found for node type ${i.type}`), "";
227
- const p = h();
233
+ const p = Q();
228
234
  if (i.type === "text")
229
235
  return u(i, p);
230
236
  const f = i.content ? i.content.map(C) : void 0;
@@ -234,55 +240,55 @@ function ie(r = {}) {
234
240
  }, p);
235
241
  }
236
242
  function C(i) {
237
- return i.type === "doc" ? l ? i.content.map(L) : i.content.map(L).join("") : Array.isArray(i) ? i.map(L) : L(i);
243
+ return i.type === "doc" ? c ? i.content.map(L) : i.content.map(L).join("") : Array.isArray(i) ? i.map(L) : L(i);
238
244
  }
239
245
  return {
240
246
  render: C
241
247
  };
242
248
  }
243
- let U = !1;
244
- const D = [], G = (r) => new Promise((e, t) => {
249
+ let M = !1;
250
+ const z = [], q = (r) => new Promise((e, t) => {
245
251
  if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
246
252
  if (window.location === window.parent.location) {
247
253
  console.warn("You are not in Draft Mode or in the Visual Editor.");
248
254
  return;
249
255
  }
250
- U ? s() : D.push(s);
256
+ M ? s() : z.push(s);
251
257
  }, document.getElementById("storyblok-javascript-bridge")))
252
258
  return;
253
259
  const o = document.createElement("script");
254
260
  o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (s) => t(s), o.onload = (s) => {
255
- D.forEach((n) => n()), U = !0, e(s);
261
+ z.forEach((n) => n()), M = !0, e(s);
256
262
  }, document.getElementsByTagName("head")[0].appendChild(o);
257
263
  });
258
- var ae = Object.defineProperty, le = (r, e, t) => e in r ? ae(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, g = (r, e, t) => le(r, typeof e != "symbol" ? e + "" : e, t);
259
- class ce extends Error {
264
+ var le = Object.defineProperty, ce = (r, e, t) => e in r ? le(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, g = (r, e, t) => ce(r, typeof e != "symbol" ? e + "" : e, t);
265
+ class he extends Error {
260
266
  constructor(e) {
261
267
  super(e), this.name = "AbortError";
262
268
  }
263
269
  }
264
- function he(r, e, t) {
270
+ function ue(r, e, t) {
265
271
  if (!Number.isFinite(e))
266
272
  throw new TypeError("Expected `limit` to be a finite number");
267
273
  if (!Number.isFinite(t))
268
274
  throw new TypeError("Expected `interval` to be a finite number");
269
275
  const o = [];
270
- let s = [], n = 0, a = !1;
271
- const l = async () => {
276
+ let s = [], n = 0, l = !1;
277
+ const c = async () => {
272
278
  n++;
273
- const c = o.shift();
274
- if (c)
279
+ const h = o.shift();
280
+ if (h)
275
281
  try {
276
- const y = await r(...c.args);
277
- c.resolve(y);
282
+ const y = await r(...h.args);
283
+ h.resolve(y);
278
284
  } catch (y) {
279
- c.reject(y);
285
+ h.reject(y);
280
286
  }
281
287
  const d = setTimeout(() => {
282
- n--, o.length > 0 && l(), s = s.filter((y) => y !== d);
288
+ n--, o.length > 0 && c(), s = s.filter((y) => y !== d);
283
289
  }, t);
284
290
  s.includes(d) || s.push(d);
285
- }, h = (...c) => a ? Promise.reject(
291
+ }, a = (...h) => l ? Promise.reject(
286
292
  new Error(
287
293
  "Throttled function is already aborted and not accepting new promises"
288
294
  )
@@ -290,23 +296,23 @@ function he(r, e, t) {
290
296
  o.push({
291
297
  resolve: d,
292
298
  reject: y,
293
- args: c
294
- }), n < e && l();
299
+ args: h
300
+ }), n < e && c();
295
301
  });
296
- return h.abort = () => {
297
- a = !0, s.forEach(clearTimeout), s = [], o.forEach(
298
- (c) => c.reject(() => new ce("Throttle function aborted"))
302
+ return a.abort = () => {
303
+ l = !0, s.forEach(clearTimeout), s = [], o.forEach(
304
+ (h) => h.reject(() => new he("Throttle function aborted"))
299
305
  ), o.length = 0;
300
- }, h;
306
+ }, a;
301
307
  }
302
- const ue = (r = "") => r.includes("/cdn/"), de = (r, e = 25, t = 1) => ({
308
+ const de = (r = "") => r.includes("/cdn/"), pe = (r, e = 25, t = 1) => ({
303
309
  ...r,
304
310
  per_page: e,
305
311
  page: t
306
- }), pe = (r) => new Promise((e) => setTimeout(e, r)), fe = (r = 0, e) => Array.from({ length: r }, e), ye = (r = 0, e = r) => {
312
+ }), fe = (r) => new Promise((e) => setTimeout(e, r)), ye = (r = 0, e) => Array.from({ length: r }, e), ge = (r = 0, e = r) => {
307
313
  const t = Math.abs(e - r) || 0, o = r < e ? 1 : -1;
308
- return fe(t, (s, n) => n * o + r);
309
- }, ge = async (r, e) => Promise.all(r.map(e)), me = (r = [], e) => r.map(e).reduce((t, o) => [...t, ...o], []), N = (r, e, t) => {
314
+ return ye(t, (s, n) => n * o + r);
315
+ }, me = async (r, e) => Promise.all(r.map(e)), be = (r = [], e) => r.map(e).reduce((t, o) => [...t, ...o], []), N = (r, e, t) => {
310
316
  const o = [];
311
317
  for (const s in r) {
312
318
  if (!Object.prototype.hasOwnProperty.call(r, s))
@@ -314,16 +320,16 @@ const ue = (r = "") => r.includes("/cdn/"), de = (r, e = 25, t = 1) => ({
314
320
  const n = r[s];
315
321
  if (n == null)
316
322
  continue;
317
- const a = t ? "" : encodeURIComponent(s);
318
- let l;
319
- typeof n == "object" ? l = N(
323
+ const l = t ? "" : encodeURIComponent(s);
324
+ let c;
325
+ typeof n == "object" ? c = N(
320
326
  n,
321
- e ? e + encodeURIComponent(`[${a}]`) : a,
327
+ e ? e + encodeURIComponent(`[${l}]`) : l,
322
328
  Array.isArray(n)
323
- ) : l = `${e ? e + encodeURIComponent(`[${a}]`) : a}=${encodeURIComponent(n)}`, o.push(l);
329
+ ) : c = `${e ? e + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(n)}`, o.push(c);
324
330
  }
325
331
  return o.join("&");
326
- }, M = (r) => {
332
+ }, F = (r) => {
327
333
  const e = {
328
334
  eu: "api.storyblok.com",
329
335
  us: "api-us.storyblok.com",
@@ -333,7 +339,7 @@ const ue = (r = "") => r.includes("/cdn/"), de = (r, e = 25, t = 1) => ({
333
339
  };
334
340
  return e[r] ?? e.eu;
335
341
  };
336
- class be {
342
+ class ve {
337
343
  constructor(e) {
338
344
  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 = {};
339
345
  }
@@ -372,25 +378,25 @@ class be {
372
378
  async _methodHandler(e) {
373
379
  let t = `${this.baseURL}${this.url}`, o = null;
374
380
  e === "get" ? t = `${this.baseURL}${this.url}?${N(this.parameters)}` : o = JSON.stringify(this.parameters);
375
- const s = new URL(t), n = new AbortController(), { signal: a } = n;
376
- let l;
377
- this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
381
+ const s = new URL(t), n = new AbortController(), { signal: l } = n;
382
+ let c;
383
+ this.timeout && (c = setTimeout(() => n.abort(), this.timeout));
378
384
  try {
379
- const h = await this.fetch(`${s}`, {
385
+ const a = await this.fetch(`${s}`, {
380
386
  method: e,
381
387
  headers: this.headers,
382
388
  body: o,
383
- signal: a,
389
+ signal: l,
384
390
  ...this.fetchOptions
385
391
  });
386
- this.timeout && clearTimeout(l);
387
- const c = await this._responseHandler(
388
- h
392
+ this.timeout && clearTimeout(c);
393
+ const h = await this._responseHandler(
394
+ a
389
395
  );
390
- return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
391
- } catch (h) {
396
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
397
+ } catch (a) {
392
398
  return {
393
- message: h
399
+ message: a
394
400
  };
395
401
  }
396
402
  }
@@ -436,16 +442,16 @@ class be {
436
442
  });
437
443
  }
438
444
  }
439
- const z = "SB-Agent", P = {
445
+ const G = "SB-Agent", P = {
440
446
  defaultAgentName: "SB-JS-CLIENT",
441
447
  defaultAgentVersion: "SB-Agent-Version",
442
448
  packageVersion: "6.0.0"
443
- }, ve = {
449
+ }, ke = {
444
450
  DRAFT: "draft"
445
451
  };
446
452
  let j = {};
447
453
  const E = {};
448
- class ke {
454
+ class we {
449
455
  /**
450
456
  *
451
457
  * @param config ISbConfig interface
@@ -455,22 +461,22 @@ class ke {
455
461
  g(this, "client"), g(this, "maxRetries"), g(this, "retriesDelay"), g(this, "throttle"), g(this, "accessToken"), g(this, "cache"), g(this, "resolveCounter"), g(this, "relations"), g(this, "links"), g(this, "version"), g(this, "richTextResolver"), g(this, "resolveNestedRelations"), g(this, "stringifiedStoriesCache"), g(this, "inlineAssets");
456
462
  let o = e.endpoint || t;
457
463
  if (!o) {
458
- const a = e.https === !1 ? "http" : "https";
459
- e.oauthToken ? o = `${a}://${M(e.region)}/v1` : o = `${a}://${M(e.region)}/v2`;
464
+ const l = e.https === !1 ? "http" : "https";
465
+ e.oauthToken ? o = `${l}://${F(e.region)}/v1` : o = `${l}://${F(e.region)}/v2`;
460
466
  }
461
467
  const s = new Headers();
462
- s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([a, l]) => {
463
- s.set(a, l);
464
- }), s.has(z) || (s.set(z, P.defaultAgentName), s.set(
468
+ s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([l, c]) => {
469
+ s.set(l, c);
470
+ }), s.has(G) || (s.set(G, P.defaultAgentName), s.set(
465
471
  P.defaultAgentVersion,
466
472
  P.packageVersion
467
473
  ));
468
474
  let n = 5;
469
- e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = he(
475
+ e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ue(
470
476
  this.throttledRequest.bind(this),
471
477
  n,
472
478
  1e3
473
- ), 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 || ve.DRAFT, this.inlineAssets = e.inlineAssets || !1, this.client = new be({
479
+ ), 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 || ke.DRAFT, this.inlineAssets = e.inlineAssets || !1, this.client = new ve({
474
480
  baseURL: o,
475
481
  timeout: e.timeout || 0,
476
482
  headers: s,
@@ -482,14 +488,14 @@ class ke {
482
488
  return e.token || (e.token = this.getToken()), e.cv || (e.cv = E[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
483
489
  }
484
490
  factoryParamOptions(e, t) {
485
- return ue(e) ? this.parseParams(t) : t;
491
+ return de(e) ? this.parseParams(t) : t;
486
492
  }
487
493
  makeRequest(e, t, o, s, n) {
488
- const a = this.factoryParamOptions(
494
+ const l = this.factoryParamOptions(
489
495
  e,
490
- de(t, o, s)
496
+ pe(t, o, s)
491
497
  );
492
- return this.cacheResponse(e, a, void 0, n);
498
+ return this.cacheResponse(e, l, void 0, n);
493
499
  }
494
500
  get(e, t = {}, o) {
495
501
  t || (t = {});
@@ -499,19 +505,19 @@ class ke {
499
505
  return this.cacheResponse(s, n, void 0, o);
500
506
  }
501
507
  async getAll(e, t = {}, o, s) {
502
- const n = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), l = o ?? a.substring(a.lastIndexOf("/") + 1);
508
+ const n = (t == null ? void 0 : t.per_page) || 25, l = `/${e}`.replace(/\/$/, ""), c = o ?? l.substring(l.lastIndexOf("/") + 1);
503
509
  t.version = t.version || this.version;
504
- const h = 1, c = await this.makeRequest(
505
- a,
510
+ const a = 1, h = await this.makeRequest(
511
+ l,
506
512
  t,
507
513
  n,
508
- h,
514
+ a,
509
515
  s
510
- ), d = c.total ? Math.ceil(c.total / n) : 1, y = await ge(
511
- ye(h, d),
512
- (T) => this.makeRequest(a, t, n, T + 1, s)
516
+ ), d = h.total ? Math.ceil(h.total / n) : 1, y = await me(
517
+ ge(a, d),
518
+ (T) => this.makeRequest(l, t, n, T + 1, s)
513
519
  );
514
- return me([c, ...y], (T) => Object.values(T.data[l]));
520
+ return be([h, ...y], (T) => Object.values(T.data[c]));
515
521
  }
516
522
  post(e, t = {}, o) {
517
523
  const s = `/${e}`;
@@ -591,7 +597,7 @@ class ke {
591
597
  * allowing flexible specification of relation patterns.
592
598
  */
593
599
  _insertRelations(e, t, o, s) {
594
- if (Array.isArray(o) ? o.find((a) => a.endsWith(`.${t}`)) : o.endsWith(`.${t}`)) {
600
+ if (Array.isArray(o) ? o.find((l) => l.endsWith(`.${t}`)) : o.endsWith(`.${t}`)) {
595
601
  this._resolveField(e, t, s);
596
602
  return;
597
603
  }
@@ -605,14 +611,14 @@ class ke {
605
611
  * @param resolveId - The unique identifier for the current resolution context
606
612
  */
607
613
  iterateTree(e, t, o) {
608
- const s = (n, a = "") => {
614
+ const s = (n, l = "") => {
609
615
  if (!(!n || n._stopResolving)) {
610
616
  if (Array.isArray(n))
611
- n.forEach((l, h) => s(l, `${a}[${h}]`));
617
+ n.forEach((c, a) => s(c, `${l}[${a}]`));
612
618
  else if (typeof n == "object")
613
- for (const l in n) {
614
- const h = a ? `${a}.${l}` : l;
615
- (n.component && n._uid || n.type === "link") && (this._insertRelations(n, l, t, o), this._insertLinks(n, l, o)), s(n[l], h);
619
+ for (const c in n) {
620
+ const a = l ? `${l}.${c}` : c;
621
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(n, c, t, o), this._insertLinks(n, c, o)), s(n[c], a);
616
622
  }
617
623
  }
618
624
  };
@@ -621,21 +627,21 @@ class ke {
621
627
  async resolveLinks(e, t, o) {
622
628
  let s = [];
623
629
  if (e.link_uuids) {
624
- const n = e.link_uuids.length, a = [], l = 50;
625
- for (let h = 0; h < n; h += l) {
626
- const c = Math.min(n, h + l);
627
- a.push(e.link_uuids.slice(h, c));
630
+ const n = e.link_uuids.length, l = [], c = 50;
631
+ for (let a = 0; a < n; a += c) {
632
+ const h = Math.min(n, a + c);
633
+ l.push(e.link_uuids.slice(a, h));
628
634
  }
629
- for (let h = 0; h < a.length; h++)
635
+ for (let a = 0; a < l.length; a++)
630
636
  (await this.getStories({
631
- per_page: l,
637
+ per_page: c,
632
638
  language: t.language,
633
639
  version: t.version,
634
640
  starts_with: t.starts_with,
635
- by_uuids: a[h].join(",")
641
+ by_uuids: l[a].join(",")
636
642
  })).data.stories.forEach(
637
- (c) => {
638
- s.push(c);
643
+ (h) => {
644
+ s.push(h);
639
645
  }
640
646
  );
641
647
  } else
@@ -650,21 +656,21 @@ class ke {
650
656
  async resolveRelations(e, t, o) {
651
657
  let s = [];
652
658
  if (e.rel_uuids) {
653
- const n = e.rel_uuids.length, a = [], l = 50;
654
- for (let h = 0; h < n; h += l) {
655
- const c = Math.min(n, h + l);
656
- a.push(e.rel_uuids.slice(h, c));
659
+ const n = e.rel_uuids.length, l = [], c = 50;
660
+ for (let a = 0; a < n; a += c) {
661
+ const h = Math.min(n, a + c);
662
+ l.push(e.rel_uuids.slice(a, h));
657
663
  }
658
- for (let h = 0; h < a.length; h++)
664
+ for (let a = 0; a < l.length; a++)
659
665
  (await this.getStories({
660
- per_page: l,
666
+ per_page: c,
661
667
  language: t.language,
662
668
  version: t.version,
663
669
  starts_with: t.starts_with,
664
- by_uuids: a[h].join(","),
670
+ by_uuids: l[a].join(","),
665
671
  excluding_fields: t.excluding_fields
666
- })).data.stories.forEach((c) => {
667
- s.push(c);
672
+ })).data.stories.forEach((h) => {
673
+ s.push(h);
668
674
  });
669
675
  s.length > 0 && (e.rels = s, delete e.rel_uuids);
670
676
  } else
@@ -687,27 +693,27 @@ class ke {
687
693
  */
688
694
  async resolveStories(e, t, o) {
689
695
  var s, n;
690
- let a = [];
691
- if (this.links[o] = {}, this.relations[o] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (a = t.resolve_relations.split(",")), await this.resolveRelations(e, t, o)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, o), this.resolveNestedRelations)
692
- for (const l in this.relations[o])
696
+ let l = [];
697
+ if (this.links[o] = {}, this.relations[o] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (l = t.resolve_relations.split(",")), await this.resolveRelations(e, t, o)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, o), this.resolveNestedRelations)
698
+ for (const c in this.relations[o])
693
699
  this.iterateTree(
694
- this.relations[o][l],
695
- a,
700
+ this.relations[o][c],
701
+ l,
696
702
  o
697
703
  );
698
- e.story ? this.iterateTree(e.story, a, o) : e.stories.forEach((l) => {
699
- this.iterateTree(l, a, o);
704
+ e.story ? this.iterateTree(e.story, l, o) : e.stories.forEach((c) => {
705
+ this.iterateTree(c, l, o);
700
706
  }), this.stringifiedStoriesCache = {}, delete this.links[o], delete this.relations[o];
701
707
  }
702
708
  async cacheResponse(e, t, o, s) {
703
- const n = N({ url: e, params: t }), a = this.cacheProvider();
709
+ const n = N({ url: e, params: t }), l = this.cacheProvider();
704
710
  if (t.version === "published" && e !== "/cdn/spaces/me") {
705
- const l = await a.get(n);
706
- if (l)
707
- return Promise.resolve(l);
711
+ const c = await l.get(n);
712
+ if (c)
713
+ return Promise.resolve(c);
708
714
  }
709
- return new Promise(async (l, h) => {
710
- var c;
715
+ return new Promise(async (c, a) => {
716
+ var h;
711
717
  try {
712
718
  const d = await this.throttle(
713
719
  "get",
@@ -716,24 +722,24 @@ class ke {
716
722
  s
717
723
  );
718
724
  if (d.status !== 200)
719
- return h(d);
725
+ return a(d);
720
726
  let y = { data: d.data, headers: d.headers };
721
- if ((c = d.headers) != null && c["per-page"] && (y = Object.assign({}, y, {
727
+ if ((h = d.headers) != null && h["per-page"] && (y = Object.assign({}, y, {
722
728
  perPage: d.headers["per-page"] ? Number.parseInt(d.headers["per-page"]) : 0,
723
729
  total: d.headers["per-page"] ? Number.parseInt(d.headers.total) : 0
724
730
  })), y.data.story || y.data.stories) {
725
- const A = this.resolveCounter = ++this.resolveCounter % 1e3;
726
- await this.resolveStories(y.data, t, `${A}`), y = await this.processInlineAssets(y);
731
+ const R = this.resolveCounter = ++this.resolveCounter % 1e3;
732
+ await this.resolveStories(y.data, t, `${R}`), y = await this.processInlineAssets(y);
727
733
  }
728
- t.version === "published" && e !== "/cdn/spaces/me" && await a.set(n, y);
734
+ t.version === "published" && e !== "/cdn/spaces/me" && await l.set(n, y);
729
735
  const T = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
730
- return t.token && y.data.cv && (T && E[t.token] && E[t.token] !== y.data.cv && await this.flushCache(), E[t.token] = y.data.cv), l(y);
736
+ return t.token && y.data.cv && (T && E[t.token] && E[t.token] !== y.data.cv && await this.flushCache(), E[t.token] = y.data.cv), c(y);
731
737
  } catch (d) {
732
738
  if (d.response && d.status === 429 && (o = typeof o > "u" ? 0 : o + 1, o < this.maxRetries))
733
739
  return console.log(
734
740
  `Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
735
- ), await pe(this.retriesDelay), this.cacheResponse(e, t, o).then(l).catch(h);
736
- h(d);
741
+ ), await fe(this.retriesDelay), this.cacheResponse(e, t, o).then(c).catch(a);
742
+ a(d);
737
743
  }
738
744
  });
739
745
  }
@@ -812,7 +818,7 @@ class ke {
812
818
  return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((o) => (o.content = t(o.content), o))), e;
813
819
  }
814
820
  }
815
- const we = (r = {}) => {
821
+ const Te = (r = {}) => {
816
822
  const { apiOptions: e } = r;
817
823
  if (!e || !e.accessToken) {
818
824
  console.error(
@@ -820,8 +826,8 @@ const we = (r = {}) => {
820
826
  );
821
827
  return;
822
828
  }
823
- return { storyblokApi: new ke(e) };
824
- }, Te = (r) => {
829
+ return { storyblokApi: new we(e) };
830
+ }, Re = (r) => {
825
831
  if (typeof r != "object" || typeof r._editable > "u")
826
832
  return {};
827
833
  try {
@@ -838,19 +844,19 @@ const we = (r = {}) => {
838
844
  };
839
845
  let x = "https://app.storyblok.com/f/storyblok-v2-latest.js";
840
846
  const $e = (r, e, t = {}) => {
841
- var l;
842
- const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((l = window.location) == null ? void 0 : l.href).searchParams.get(
847
+ var c;
848
+ const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((c = window.location) == null ? void 0 : c.href).searchParams.get(
843
849
  "_storyblok"
844
- ), a = n !== null && +n === r;
845
- if (!(!s || !a)) {
850
+ ), l = n !== null && +n === r;
851
+ if (!(!s || !l)) {
846
852
  if (!r) {
847
853
  console.warn("Story ID is not defined. Please provide a valid ID.");
848
854
  return;
849
855
  }
850
856
  window.storyblokRegisterEvent(() => {
851
- new window.StoryblokBridge(t).on(["input", "published", "change"], (c) => {
857
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (h) => {
852
858
  var d;
853
- c && (c.action === "input" && ((d = c.story) == null ? void 0 : d.id) === r ? e(c.story) : (c.action === "change" || c.action === "published") && c.storyId === r && window.location.reload());
859
+ h && (h.action === "input" && ((d = h.story) == null ? void 0 : d.id) === r ? e(h.story) : (h.action === "change" || h.action === "published") && h.storyId === r && window.location.reload());
854
860
  });
855
861
  });
856
862
  }
@@ -864,28 +870,28 @@ const $e = (r, e, t = {}) => {
864
870
  bridgeUrl: n
865
871
  } = r;
866
872
  s.accessToken = s.accessToken || t;
867
- const a = { bridge: e, apiOptions: s };
868
- let l = {};
873
+ const l = { bridge: e, apiOptions: s };
874
+ let c = {};
869
875
  o.forEach((T) => {
870
- l = { ...l, ...T(a) };
876
+ c = { ...c, ...T(l) };
871
877
  }), n && (x = n);
872
- const c = !(typeof window > "u") && ((y = (d = window.location) == null ? void 0 : d.search) == null ? void 0 : y.includes("_storyblok_tk"));
873
- return e !== !1 && c && G(x), l;
878
+ const h = !(typeof window > "u") && ((y = (d = window.location) == null ? void 0 : d.search) == null ? void 0 : y.includes("_storyblok_tk"));
879
+ return e !== !1 && h && q(x), c;
874
880
  };
875
- function Re(r, e) {
876
- return ie(e).render(r);
881
+ function Ee(r, e) {
882
+ return ae(e).render(r);
877
883
  }
878
- const Ee = () => G(x);
884
+ const Ae = () => q(x);
879
885
  export {
880
886
  v as BlockTypes,
881
- R as MarkTypes,
882
- F as TextTypes,
883
- we as apiPlugin,
884
- Ee as loadStoryblokBridge,
887
+ _ as MarkTypes,
888
+ V as TextTypes,
889
+ Te as apiPlugin,
890
+ Ae as loadStoryblokBridge,
885
891
  $e as registerStoryblokBridge,
886
- Re as renderRichText,
887
- ie as richTextResolver,
888
- Te as storyblokEditable,
892
+ Ee as renderRichText,
893
+ ae as richTextResolver,
894
+ Re as storyblokEditable,
889
895
  _e as storyblokInit,
890
896
  $e as useStoryblokBridge
891
897
  };