@storyblok/react 4.4.2 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,80 +1,80 @@
1
1
  let U = !1;
2
- const H = [], F = (r) => new Promise((e, t) => {
3
- if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
2
+ const B = [], F = (n) => new Promise((e, t) => {
3
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
4
4
  if (window.location === window.parent.location) {
5
5
  console.warn("You are not in Draft Mode or in the Visual Editor.");
6
6
  return;
7
7
  }
8
- U ? n() : H.push(n);
8
+ U ? s() : B.push(s);
9
9
  }, document.getElementById("storyblok-javascript-bridge")))
10
10
  return;
11
- const s = document.createElement("script");
12
- s.async = !0, s.src = r, s.id = "storyblok-javascript-bridge", s.onerror = (n) => t(n), s.onload = (n) => {
13
- H.forEach((o) => o()), U = !0, e(n);
14
- }, document.getElementsByTagName("head")[0].appendChild(s);
11
+ const r = document.createElement("script");
12
+ r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => t(s), r.onload = (s) => {
13
+ B.forEach((o) => o()), U = !0, e(s);
14
+ }, document.getElementsByTagName("head")[0].appendChild(r);
15
15
  });
16
- var Q = Object.defineProperty, Z = (r, e, t) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => Z(r, typeof e != "symbol" ? e + "" : e, t);
17
- class ee extends Error {
16
+ var re = Object.defineProperty, se = (n, e, t) => e in n ? re(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t) => se(n, typeof e != "symbol" ? e + "" : e, t);
17
+ class ne extends Error {
18
18
  constructor(e) {
19
19
  super(e), this.name = "AbortError";
20
20
  }
21
21
  }
22
- function te(r, e, t) {
22
+ function oe(n, e, t) {
23
23
  if (!Number.isFinite(e))
24
24
  throw new TypeError("Expected `limit` to be a finite number");
25
25
  if (!Number.isFinite(t))
26
26
  throw new TypeError("Expected `interval` to be a finite number");
27
- const s = [];
28
- let n = [], o = 0, i = !1;
27
+ const r = [];
28
+ let s = [], o = 0, a = !1;
29
29
  const l = async () => {
30
30
  o++;
31
- const h = s.shift();
31
+ const h = r.shift();
32
32
  if (h)
33
33
  try {
34
- const d = await r(...h.args);
35
- h.resolve(d);
36
- } catch (d) {
37
- h.reject(d);
34
+ const p = await n(...h.args);
35
+ h.resolve(p);
36
+ } catch (p) {
37
+ h.reject(p);
38
38
  }
39
- const u = setTimeout(() => {
40
- o--, s.length > 0 && l(), n = n.filter((d) => d !== u);
39
+ const d = setTimeout(() => {
40
+ o--, r.length > 0 && l(), s = s.filter((p) => p !== d);
41
41
  }, t);
42
- n.includes(u) || n.push(u);
43
- }, a = (...h) => i ? Promise.reject(
42
+ s.includes(d) || s.push(d);
43
+ }, i = (...h) => a ? Promise.reject(
44
44
  new Error(
45
45
  "Throttled function is already aborted and not accepting new promises"
46
46
  )
47
- ) : new Promise((u, d) => {
48
- s.push({
49
- resolve: u,
50
- reject: d,
47
+ ) : new Promise((d, p) => {
48
+ r.push({
49
+ resolve: d,
50
+ reject: p,
51
51
  args: h
52
52
  }), o < e && l();
53
53
  });
54
- return a.abort = () => {
55
- i = !0, n.forEach(clearTimeout), n = [], s.forEach(
56
- (h) => h.reject(() => new ee("Throttle function aborted"))
57
- ), s.length = 0;
58
- }, a;
54
+ return i.abort = () => {
55
+ a = !0, s.forEach(clearTimeout), s = [], r.forEach(
56
+ (h) => h.reject(() => new ne("Throttle function aborted"))
57
+ ), r.length = 0;
58
+ }, i;
59
59
  }
60
- let A = class {
60
+ class L {
61
61
  constructor() {
62
- p(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), p(this, "getOptionsPage", (r, e = 25, t = 1) => ({
63
- ...r,
64
- per_page: e,
65
- page: t
66
- })), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) => Array.from({ length: r }, e)), p(this, "range", (r = 0, e = r) => {
67
- const t = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
68
- return this.arrayFrom(t, (n, o) => o * s + r);
69
- }), p(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), p(this, "flatMap", (r = [], e) => r.map(e).reduce((t, s) => [...t, ...s], [])), p(this, "escapeHTML", function(r) {
70
- const e = {
62
+ g(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), g(this, "getOptionsPage", (e, t = 25, r = 1) => ({
63
+ ...e,
64
+ per_page: t,
65
+ page: r
66
+ })), g(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), g(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), g(this, "range", (e = 0, t = e) => {
67
+ const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
68
+ return this.arrayFrom(r, (o, a) => a * s + e);
69
+ }), g(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), g(this, "flatMap", (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], [])), g(this, "escapeHTML", function(e) {
70
+ const t = {
71
71
  "&": "&amp;",
72
72
  "<": "&lt;",
73
73
  ">": "&gt;",
74
74
  '"': "&quot;",
75
75
  "'": "&#39;"
76
- }, t = /[&<>"']/g, s = new RegExp(t.source);
77
- return r && s.test(r) ? r.replace(t, (n) => e[n]) : r;
76
+ }, r = /[&<>"']/g, s = new RegExp(r.source);
77
+ return e && s.test(e) ? e.replace(r, (o) => t[o]) : e;
78
78
  });
79
79
  }
80
80
  /**
@@ -84,18 +84,18 @@ let A = class {
84
84
  * @param {boolean} isArray
85
85
  * @return {string} Stringified object
86
86
  */
87
- stringify(r, e, t) {
87
+ stringify(e, t, r) {
88
88
  const s = [];
89
- for (const n in r) {
90
- if (!Object.prototype.hasOwnProperty.call(r, n))
89
+ for (const o in e) {
90
+ if (!Object.prototype.hasOwnProperty.call(e, o))
91
91
  continue;
92
- const o = r[n], i = t ? "" : encodeURIComponent(n);
93
- let l;
94
- typeof o == "object" ? l = this.stringify(
95
- o,
96
- e ? e + encodeURIComponent(`[${i}]`) : i,
97
- Array.isArray(o)
98
- ) : l = `${e ? e + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(o)}`, s.push(l);
92
+ const a = e[o], l = r ? "" : encodeURIComponent(o);
93
+ let i;
94
+ typeof a == "object" ? i = this.stringify(
95
+ a,
96
+ t ? t + encodeURIComponent(`[${l}]`) : l,
97
+ Array.isArray(a)
98
+ ) : i = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(a)}`, s.push(i);
99
99
  }
100
100
  return s.join("&");
101
101
  }
@@ -104,92 +104,92 @@ let A = class {
104
104
  * @param {string} regionCode region code, could be eu, us, cn, ap or ca
105
105
  * @return {string} The base URL of the region
106
106
  */
107
- getRegionURL(r) {
108
- const e = "api.storyblok.com", t = "api-us.storyblok.com", s = "app.storyblokchina.cn", n = "api-ap.storyblok.com", o = "api-ca.storyblok.com";
109
- switch (r) {
107
+ getRegionURL(e) {
108
+ const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", a = "api-ca.storyblok.com";
109
+ switch (e) {
110
110
  case "us":
111
- return t;
111
+ return r;
112
112
  case "cn":
113
113
  return s;
114
114
  case "ap":
115
- return n;
116
- case "ca":
117
115
  return o;
116
+ case "ca":
117
+ return a;
118
118
  default:
119
- return e;
119
+ return t;
120
120
  }
121
121
  }
122
- };
123
- const re = function(r, e) {
122
+ }
123
+ const ae = function(n, e) {
124
124
  const t = {};
125
- for (const s in r) {
126
- const n = r[s];
127
- e.includes(s) && n !== null && (t[s] = n);
125
+ for (const r in n) {
126
+ const s = n[r];
127
+ e.includes(r) && s !== null && (t[r] = s);
128
128
  }
129
129
  return t;
130
- }, se = (r) => r === "email", ne = () => ({
130
+ }, ie = (n) => n === "email", le = () => ({
131
131
  singleTag: "hr"
132
- }), oe = () => ({
132
+ }), ce = () => ({
133
133
  tag: "blockquote"
134
- }), ie = () => ({
134
+ }), he = () => ({
135
135
  tag: "ul"
136
- }), ae = (r) => ({
136
+ }), ue = (n) => ({
137
137
  tag: [
138
138
  "pre",
139
139
  {
140
140
  tag: "code",
141
- attrs: r.attrs
141
+ attrs: n.attrs
142
142
  }
143
143
  ]
144
- }), le = () => ({
144
+ }), de = () => ({
145
145
  singleTag: "br"
146
- }), ce = (r) => ({
147
- tag: `h${r.attrs.level}`
148
- }), he = (r) => ({
146
+ }), pe = (n) => ({
147
+ tag: `h${n.attrs.level}`
148
+ }), ge = (n) => ({
149
149
  singleTag: [
150
150
  {
151
151
  tag: "img",
152
- attrs: re(r.attrs, ["src", "alt", "title"])
152
+ attrs: ae(n.attrs, ["src", "alt", "title"])
153
153
  }
154
154
  ]
155
- }), ue = () => ({
155
+ }), fe = () => ({
156
156
  tag: "li"
157
- }), de = () => ({
157
+ }), me = () => ({
158
158
  tag: "ol"
159
- }), pe = () => ({
159
+ }), ye = () => ({
160
160
  tag: "p"
161
- }), ge = (r) => ({
161
+ }), be = (n) => ({
162
162
  tag: [
163
163
  {
164
164
  tag: "span",
165
165
  attrs: {
166
166
  "data-type": "emoji",
167
- "data-name": r.attrs.name,
168
- emoji: r.attrs.emoji
167
+ "data-name": n.attrs.name,
168
+ emoji: n.attrs.emoji
169
169
  }
170
170
  }
171
171
  ]
172
- }), fe = () => ({
172
+ }), ke = () => ({
173
173
  tag: "b"
174
- }), me = () => ({
174
+ }), $e = () => ({
175
175
  tag: "s"
176
- }), ye = () => ({
176
+ }), ve = () => ({
177
177
  tag: "u"
178
- }), be = () => ({
178
+ }), we = () => ({
179
179
  tag: "strong"
180
- }), ke = () => ({
180
+ }), Te = () => ({
181
181
  tag: "code"
182
- }), $e = () => ({
182
+ }), Re = () => ({
183
183
  tag: "i"
184
- }), ve = (r) => {
185
- if (!r.attrs)
184
+ }), _e = (n) => {
185
+ if (!n.attrs)
186
186
  return {
187
187
  tag: ""
188
188
  };
189
- const e = new A().escapeHTML, t = { ...r.attrs }, { linktype: s = "url" } = r.attrs;
190
- if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), se(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
191
- for (const n in t.custom)
192
- t[n] = t.custom[n];
189
+ const e = new L().escapeHTML, t = { ...n.attrs }, { linktype: r = "url" } = n.attrs;
190
+ if (delete t.linktype, t.href && (t.href = e(n.attrs.href || "")), ie(r) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
191
+ for (const s in t.custom)
192
+ t[s] = t.custom[s];
193
193
  delete t.custom;
194
194
  }
195
195
  return {
@@ -200,95 +200,95 @@ const re = function(r, e) {
200
200
  }
201
201
  ]
202
202
  };
203
- }, Te = (r) => ({
203
+ }, Ee = (n) => ({
204
204
  tag: [
205
205
  {
206
206
  tag: "span",
207
- attrs: r.attrs
207
+ attrs: n.attrs
208
208
  }
209
209
  ]
210
- }), we = () => ({
210
+ }), Se = () => ({
211
211
  tag: "sub"
212
- }), Re = () => ({
212
+ }), je = () => ({
213
213
  tag: "sup"
214
- }), _e = (r) => ({
214
+ }), Ie = (n) => ({
215
215
  tag: [
216
216
  {
217
217
  tag: "span",
218
- attrs: r.attrs
218
+ attrs: n.attrs
219
219
  }
220
220
  ]
221
- }), Se = (r) => {
221
+ }), xe = (n) => {
222
222
  var e;
223
- return (e = r.attrs) != null && e.color ? {
223
+ return (e = n.attrs) != null && e.color ? {
224
224
  tag: [
225
225
  {
226
226
  tag: "span",
227
227
  attrs: {
228
- style: `background-color:${r.attrs.color};`
228
+ style: `background-color:${n.attrs.color};`
229
229
  }
230
230
  }
231
231
  ]
232
232
  } : {
233
233
  tag: ""
234
234
  };
235
- }, Ee = (r) => {
235
+ }, Ae = (n) => {
236
236
  var e;
237
- return (e = r.attrs) != null && e.color ? {
237
+ return (e = n.attrs) != null && e.color ? {
238
238
  tag: [
239
239
  {
240
240
  tag: "span",
241
241
  attrs: {
242
- style: `color:${r.attrs.color}`
242
+ style: `color:${n.attrs.color}`
243
243
  }
244
244
  }
245
245
  ]
246
246
  } : {
247
247
  tag: ""
248
248
  };
249
- }, je = {
249
+ }, Oe = {
250
250
  nodes: {
251
- horizontal_rule: ne,
252
- blockquote: oe,
253
- bullet_list: ie,
254
- code_block: ae,
255
- hard_break: le,
256
- heading: ce,
257
- image: he,
258
- list_item: ue,
259
- ordered_list: de,
260
- paragraph: pe,
261
- emoji: ge
251
+ horizontal_rule: le,
252
+ blockquote: ce,
253
+ bullet_list: he,
254
+ code_block: ue,
255
+ hard_break: de,
256
+ heading: pe,
257
+ image: ge,
258
+ list_item: fe,
259
+ ordered_list: me,
260
+ paragraph: ye,
261
+ emoji: be
262
262
  },
263
263
  marks: {
264
- bold: fe,
265
- strike: me,
266
- underline: ye,
267
- strong: be,
268
- code: ke,
269
- italic: $e,
270
- link: ve,
271
- styled: Te,
272
- subscript: we,
273
- superscript: Re,
274
- anchor: _e,
275
- highlight: Se,
276
- textStyle: Ee
277
- }
278
- }, Ie = function(r) {
264
+ bold: ke,
265
+ strike: $e,
266
+ underline: ve,
267
+ strong: we,
268
+ code: Te,
269
+ italic: Re,
270
+ link: _e,
271
+ styled: Ee,
272
+ subscript: Se,
273
+ superscript: je,
274
+ anchor: Ie,
275
+ highlight: xe,
276
+ textStyle: Ae
277
+ }
278
+ }, Le = function(n) {
279
279
  const e = {
280
280
  "&": "&amp;",
281
281
  "<": "&lt;",
282
282
  ">": "&gt;",
283
283
  '"': "&quot;",
284
284
  "'": "&#39;"
285
- }, t = /[&<>"']/g, s = new RegExp(t.source);
286
- return r && s.test(r) ? r.replace(t, (n) => e[n]) : r;
285
+ }, t = /[&<>"']/g, r = new RegExp(t.source);
286
+ return n && r.test(n) ? n.replace(t, (s) => e[s]) : n;
287
287
  };
288
288
  let z = !1;
289
- class L {
289
+ class C {
290
290
  constructor(e) {
291
- p(this, "marks"), p(this, "nodes"), e || (e = je), this.marks = e.marks || [], this.nodes = e.nodes || [];
291
+ g(this, "marks"), g(this, "nodes"), e || (e = Oe), this.marks = e.marks || [], this.nodes = e.nodes || [];
292
292
  }
293
293
  addNode(e, t) {
294
294
  this.nodes[e] = t;
@@ -296,14 +296,14 @@ class L {
296
296
  addMark(e, t) {
297
297
  this.marks[e] = t;
298
298
  }
299
- render(e, t = { optimizeImages: !1 }, s = !0) {
300
- if (!z && s && (console.warn(
299
+ render(e, t = { optimizeImages: !1 }, r = !0) {
300
+ if (!z && r && (console.warn(
301
301
  "Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
302
302
  ), z = !0), e && e.content && Array.isArray(e.content)) {
303
- let n = "";
303
+ let s = "";
304
304
  return e.content.forEach((o) => {
305
- n += this.renderNode(o);
306
- }), t.optimizeImages ? this.optimizeImages(n, t.optimizeImages) : n;
305
+ s += this.renderNode(o);
306
+ }), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
307
307
  }
308
308
  return console.warn(
309
309
  `The render method must receive an Object with a "content" field.
@@ -333,64 +333,64 @@ class L {
333
333
  ), "";
334
334
  }
335
335
  optimizeImages(e, t) {
336
- let s = 0, n = 0, o = "", i = "";
337
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (o += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (o += `height="${t.height}" `, n = t.height), (t.loading === "lazy" || t.loading === "eager") && (o += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (o += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = `/filters${i}`))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
338
- const l = s > 0 || n > 0 || i.length > 0 ? `${s}x${n}${i}` : "";
336
+ let r = 0, s = 0, o = "", a = "";
337
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (o += `width="${t.width}" `, r = t.width), typeof t.height == "number" && t.height > 0 && (o += `height="${t.height}" `, s = t.height), (t.loading === "lazy" || t.loading === "eager") && (o += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (o += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (a += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (a += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (a += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (a += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (a += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (a += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (a += `:rotate(${t.filters.rotate})`), a.length > 0 && (a = `/filters${a}`))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
338
+ const l = r > 0 || s > 0 || a.length > 0 ? `${r}x${s}${a}` : "";
339
339
  return e = e.replace(
340
340
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
341
341
  `a.storyblok.com/f/$1/$2.$3/m/${l}`
342
- ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
343
- var h, u;
344
- const d = a.match(
342
+ ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (i) => {
343
+ var h, d;
344
+ const p = i.match(
345
345
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
346
346
  );
347
- if (d && d.length > 0) {
348
- const m = {
349
- srcset: (h = t.srcset) == null ? void 0 : h.map((b) => {
350
- if (typeof b == "number")
351
- return `//${d}/m/${b}x0${i} ${b}w`;
352
- if (typeof b == "object" && b.length === 2) {
353
- let _ = 0, j = 0;
354
- return typeof b[0] == "number" && (_ = b[0]), typeof b[1] == "number" && (j = b[1]), `//${d}/m/${_}x${j}${i} ${_}w`;
347
+ if (p && p.length > 0) {
348
+ const b = {
349
+ srcset: (h = t.srcset) == null ? void 0 : h.map((w) => {
350
+ if (typeof w == "number")
351
+ return `//${p}/m/${w}x0${a} ${w}w`;
352
+ if (typeof w == "object" && w.length === 2) {
353
+ let E = 0, j = 0;
354
+ return typeof w[0] == "number" && (E = w[0]), typeof w[1] == "number" && (j = w[1]), `//${p}/m/${E}x${j}${a} ${E}w`;
355
355
  }
356
356
  return "";
357
357
  }).join(", "),
358
- sizes: (u = t.sizes) == null ? void 0 : u.map((b) => b).join(", ")
358
+ sizes: (d = t.sizes) == null ? void 0 : d.map((w) => w).join(", ")
359
359
  };
360
- let y = "";
361
- return m.srcset && (y += `srcset="${m.srcset}" `), m.sizes && (y += `sizes="${m.sizes}" `), a.replace(/<img/g, `<img ${y.trim()}`);
360
+ let k = "";
361
+ return b.srcset && (k += `srcset="${b.srcset}" `), b.sizes && (k += `sizes="${b.sizes}" `), i.replace(/<img/g, `<img ${k.trim()}`);
362
362
  }
363
- return a;
363
+ return i;
364
364
  })), e;
365
365
  }
366
366
  renderNode(e) {
367
367
  const t = [];
368
- e.marks && e.marks.forEach((n) => {
369
- const o = this.getMatchingMark(n);
368
+ e.marks && e.marks.forEach((s) => {
369
+ const o = this.getMatchingMark(s);
370
370
  o && o.tag !== "" && t.push(this.renderOpeningTag(o.tag));
371
371
  });
372
- const s = this.getMatchingNode(e);
373
- return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((n) => {
374
- t.push(this.renderNode(n));
375
- }) : e.text ? t.push(Ie(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((n) => {
376
- const o = this.getMatchingMark(n);
372
+ const r = this.getMatchingNode(e);
373
+ return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((s) => {
374
+ t.push(this.renderNode(s));
375
+ }) : e.text ? t.push(Le(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html ? t.push(r.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((s) => {
376
+ const o = this.getMatchingMark(s);
377
377
  o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
378
378
  }), t.join("");
379
379
  }
380
380
  renderTag(e, t) {
381
- return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
382
- if (s.constructor === String)
383
- return `<${s}${t}>`;
381
+ return e.constructor === String ? `<${e}${t}>` : e.map((r) => {
382
+ if (r.constructor === String)
383
+ return `<${r}${t}>`;
384
384
  {
385
- let n = `<${s.tag}`;
386
- if (s.attrs) {
387
- for (const o in s.attrs)
388
- if (Object.prototype.hasOwnProperty.call(s.attrs, o)) {
389
- const i = s.attrs[o];
390
- i !== null && (n += ` ${o}="${i}"`);
385
+ let s = `<${r.tag}`;
386
+ if (r.attrs) {
387
+ for (const o in r.attrs)
388
+ if (Object.prototype.hasOwnProperty.call(r.attrs, o)) {
389
+ const a = r.attrs[o];
390
+ a !== null && (s += ` ${o}="${a}"`);
391
391
  }
392
392
  }
393
- return `${n}${t}>`;
393
+ return `${s}${t}>`;
394
394
  }
395
395
  }).join("");
396
396
  }
@@ -427,9 +427,9 @@ class L {
427
427
  return this.renderTag(t, " /");
428
428
  }
429
429
  }
430
- class xe {
430
+ class Ce {
431
431
  constructor(e) {
432
- p(this, "baseURL"), p(this, "timeout"), p(this, "headers"), p(this, "responseInterceptor"), p(this, "fetch"), p(this, "ejectInterceptor"), p(this, "url"), p(this, "parameters"), p(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 = {};
432
+ 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 = {};
433
433
  }
434
434
  /**
435
435
  *
@@ -450,47 +450,47 @@ class xe {
450
450
  return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
451
451
  }
452
452
  async _responseHandler(e) {
453
- const t = [], s = {
453
+ const t = [], r = {
454
454
  data: {},
455
455
  headers: {},
456
456
  status: 0,
457
457
  statusText: ""
458
458
  };
459
- e.status !== 204 && await e.json().then((n) => {
460
- s.data = n;
459
+ e.status !== 204 && await e.json().then((s) => {
460
+ r.data = s;
461
461
  });
462
- for (const n of e.headers.entries())
463
- t[n[0]] = n[1];
464
- return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
462
+ for (const s of e.headers.entries())
463
+ t[s[0]] = s[1];
464
+ return r.headers = { ...t }, r.status = e.status, r.statusText = e.statusText, r;
465
465
  }
466
466
  async _methodHandler(e) {
467
- let t = `${this.baseURL}${this.url}`, s = null;
467
+ let t = `${this.baseURL}${this.url}`, r = null;
468
468
  if (e === "get") {
469
- const a = new A();
470
- t = `${this.baseURL}${this.url}?${a.stringify(
469
+ const i = new L();
470
+ t = `${this.baseURL}${this.url}?${i.stringify(
471
471
  this.parameters
472
472
  )}`;
473
473
  } else
474
- s = JSON.stringify(this.parameters);
475
- const n = new URL(t), o = new AbortController(), { signal: i } = o;
474
+ r = JSON.stringify(this.parameters);
475
+ const s = new URL(t), o = new AbortController(), { signal: a } = o;
476
476
  let l;
477
477
  this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
478
478
  try {
479
- const a = await this.fetch(`${n}`, {
479
+ const i = await this.fetch(`${s}`, {
480
480
  method: e,
481
481
  headers: this.headers,
482
- body: s,
483
- signal: i,
482
+ body: r,
483
+ signal: a,
484
484
  ...this.fetchOptions
485
485
  });
486
486
  this.timeout && clearTimeout(l);
487
487
  const h = await this._responseHandler(
488
- a
488
+ i
489
489
  );
490
490
  return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
491
- } catch (a) {
491
+ } catch (i) {
492
492
  return {
493
- message: a
493
+ message: i
494
494
  };
495
495
  }
496
496
  }
@@ -502,65 +502,65 @@ class xe {
502
502
  }
503
503
  _statusHandler(e) {
504
504
  const t = /20[0-6]/g;
505
- return new Promise((s, n) => {
505
+ return new Promise((r, s) => {
506
506
  if (t.test(`${e.status}`))
507
- return s(e);
507
+ return r(e);
508
508
  const o = {
509
509
  message: e.statusText,
510
510
  status: e.status,
511
511
  response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
512
512
  };
513
- n(o);
513
+ s(o);
514
514
  });
515
515
  }
516
516
  }
517
- const D = "SB-Agent", C = {
517
+ const D = "SB-Agent", N = {
518
518
  defaultAgentName: "SB-JS-CLIENT",
519
519
  defaultAgentVersion: "SB-Agent-Version",
520
520
  packageVersion: "6.0.0"
521
521
  };
522
- let O = {};
522
+ let A = {};
523
523
  const S = {};
524
- class Oe {
524
+ class Pe {
525
525
  /**
526
526
  *
527
527
  * @param config ISbConfig interface
528
528
  * @param pEndpoint string, optional
529
529
  */
530
530
  constructor(e, t) {
531
- p(this, "client"), p(this, "maxRetries"), p(this, "retriesDelay"), p(this, "throttle"), p(this, "accessToken"), p(this, "cache"), p(this, "helpers"), p(this, "resolveCounter"), p(this, "relations"), p(this, "links"), p(this, "richTextResolver"), p(this, "resolveNestedRelations"), p(this, "stringifiedStoriesCache");
532
- let s = e.endpoint || t;
533
- if (!s) {
534
- const i = new A().getRegionURL, l = e.https === !1 ? "http" : "https";
535
- e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
531
+ g(this, "client"), g(this, "maxRetries"), g(this, "retriesDelay"), g(this, "throttle"), g(this, "accessToken"), g(this, "cache"), g(this, "helpers"), g(this, "resolveCounter"), g(this, "relations"), g(this, "links"), g(this, "richTextResolver"), g(this, "resolveNestedRelations"), g(this, "stringifiedStoriesCache");
532
+ let r = e.endpoint || t;
533
+ if (!r) {
534
+ const a = new L().getRegionURL, l = e.https === !1 ? "http" : "https";
535
+ e.oauthToken ? r = `${l}://${a(e.region)}/v1` : r = `${l}://${a(e.region)}/v2`;
536
536
  }
537
- const n = new Headers();
538
- n.set("Content-Type", "application/json"), n.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
539
- n.set(i, l);
540
- }), n.has(D) || (n.set(D, C.defaultAgentName), n.set(
541
- C.defaultAgentVersion,
542
- C.packageVersion
537
+ const s = new Headers();
538
+ 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]) => {
539
+ s.set(a, l);
540
+ }), s.has(D) || (s.set(D, N.defaultAgentName), s.set(
541
+ N.defaultAgentVersion,
542
+ N.packageVersion
543
543
  ));
544
544
  let o = 5;
545
- e.oauthToken && (n.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = te(
545
+ e.oauthToken && (s.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new C(e.richTextSchema) : this.richTextResolver = new C(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = oe(
546
546
  this.throttledRequest.bind(this),
547
547
  o,
548
548
  1e3
549
- ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new xe({
550
- baseURL: s,
549
+ ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new L(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ce({
550
+ baseURL: r,
551
551
  timeout: e.timeout || 0,
552
- headers: n,
552
+ headers: s,
553
553
  responseInterceptor: e.responseInterceptor,
554
554
  fetch: e.fetch
555
555
  });
556
556
  }
557
557
  setComponentResolver(e) {
558
558
  this.richTextResolver.addNode("blok", (t) => {
559
- let s = "";
560
- return t.attrs.body && t.attrs.body.forEach((n) => {
561
- s += e(n.component, n);
559
+ let r = "";
560
+ return t.attrs.body && t.attrs.body.forEach((s) => {
561
+ r += e(s.component, s);
562
562
  }), {
563
- html: s
563
+ html: r
564
564
  };
565
565
  });
566
566
  }
@@ -570,55 +570,55 @@ class Oe {
570
570
  factoryParamOptions(e, t) {
571
571
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
572
572
  }
573
- makeRequest(e, t, s, n, o) {
574
- const i = this.factoryParamOptions(
573
+ makeRequest(e, t, r, s, o) {
574
+ const a = this.factoryParamOptions(
575
575
  e,
576
- this.helpers.getOptionsPage(t, s, n)
576
+ this.helpers.getOptionsPage(t, r, s)
577
577
  );
578
- return this.cacheResponse(e, i, void 0, o);
578
+ return this.cacheResponse(e, a, void 0, o);
579
579
  }
580
- get(e, t, s) {
580
+ get(e, t, r) {
581
581
  t || (t = {});
582
- const n = `/${e}`, o = this.factoryParamOptions(n, t);
583
- return this.cacheResponse(n, o, void 0, s);
582
+ const s = `/${e}`, o = this.factoryParamOptions(s, t);
583
+ return this.cacheResponse(s, o, void 0, r);
584
584
  }
585
- async getAll(e, t, s, n) {
586
- const o = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), l = s ?? i.substring(i.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
587
- i,
585
+ async getAll(e, t, r, s) {
586
+ const o = (t == null ? void 0 : t.per_page) || 25, a = `/${e}`.replace(/\/$/, ""), l = r ?? a.substring(a.lastIndexOf("/") + 1), i = 1, h = await this.makeRequest(
587
+ a,
588
588
  t,
589
589
  o,
590
- a,
591
- n
592
- ), u = h.total ? Math.ceil(h.total / o) : 1, d = await this.helpers.asyncMap(
593
- this.helpers.range(a, u),
594
- (m) => this.makeRequest(i, t, o, m + 1, n)
590
+ i,
591
+ s
592
+ ), d = h.total ? Math.ceil(h.total / o) : 1, p = await this.helpers.asyncMap(
593
+ this.helpers.range(i, d),
594
+ (b) => this.makeRequest(a, t, o, b + 1, s)
595
595
  );
596
- return this.helpers.flatMap([h, ...d], (m) => Object.values(m.data[l]));
596
+ return this.helpers.flatMap([h, ...p], (b) => Object.values(b.data[l]));
597
597
  }
598
- post(e, t, s) {
599
- const n = `/${e}`;
598
+ post(e, t, r) {
599
+ const s = `/${e}`;
600
600
  return Promise.resolve(
601
- this.throttle("post", n, t, s)
601
+ this.throttle("post", s, t, r)
602
602
  );
603
603
  }
604
- put(e, t, s) {
605
- const n = `/${e}`;
604
+ put(e, t, r) {
605
+ const s = `/${e}`;
606
606
  return Promise.resolve(
607
- this.throttle("put", n, t, s)
607
+ this.throttle("put", s, t, r)
608
608
  );
609
609
  }
610
- delete(e, t, s) {
610
+ delete(e, t, r) {
611
611
  t || (t = {});
612
- const n = `/${e}`;
612
+ const s = `/${e}`;
613
613
  return Promise.resolve(
614
- this.throttle("delete", n, t, s)
614
+ this.throttle("delete", s, t, r)
615
615
  );
616
616
  }
617
617
  getStories(e, t) {
618
618
  return this._addResolveLevel(e), this.get("cdn/stories", e, t);
619
619
  }
620
- getStory(e, t, s) {
621
- return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
620
+ getStory(e, t, r) {
621
+ return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, r);
622
622
  }
623
623
  getToken() {
624
624
  return this.accessToken;
@@ -632,9 +632,9 @@ class Oe {
632
632
  _cleanCopy(e) {
633
633
  return JSON.parse(JSON.stringify(e));
634
634
  }
635
- _insertLinks(e, t, s) {
636
- const n = e[t];
637
- n && n.fieldtype === "multilink" && n.linktype === "story" && typeof n.id == "string" && this.links[s][n.id] ? n.story = this._cleanCopy(this.links[s][n.id]) : n && n.linktype === "story" && typeof n.uuid == "string" && this.links[s][n.uuid] && (n.story = this._cleanCopy(this.links[s][n.uuid]));
635
+ _insertLinks(e, t, r) {
636
+ const s = e[t];
637
+ s && s.fieldtype === "multilink" && s.linktype === "story" && typeof s.id == "string" && this.links[r][s.id] ? s.story = this._cleanCopy(this.links[r][s.id]) : s && s.linktype === "story" && typeof s.uuid == "string" && this.links[r][s.uuid] && (s.story = this._cleanCopy(this.links[r][s.uuid]));
638
638
  }
639
639
  /**
640
640
  *
@@ -655,10 +655,10 @@ class Oe {
655
655
  * - For single strings: directly replaces the UUID with the story reference
656
656
  * - For arrays: maps through each UUID and replaces with corresponding story references
657
657
  */
658
- _resolveField(e, t, s) {
659
- const n = e[t];
660
- typeof n == "string" ? e[t] = this.getStoryReference(s, n) : Array.isArray(n) && (e[t] = n.map(
661
- (o) => this.getStoryReference(s, o)
658
+ _resolveField(e, t, r) {
659
+ const s = e[t];
660
+ typeof s == "string" ? e[t] = this.getStoryReference(r, s) : Array.isArray(s) && (e[t] = s.map(
661
+ (o) => this.getStoryReference(r, o)
662
662
  ).filter(Boolean));
663
663
  }
664
664
  /**
@@ -678,13 +678,13 @@ class Oe {
678
678
  * The method supports both string and array formats for the fields parameter,
679
679
  * allowing flexible specification of relation patterns.
680
680
  */
681
- _insertRelations(e, t, s, n) {
682
- if (Array.isArray(s) ? s.find((i) => i.endsWith(`.${t}`)) : s.endsWith(`.${t}`)) {
683
- this._resolveField(e, t, n);
681
+ _insertRelations(e, t, r, s) {
682
+ if (Array.isArray(r) ? r.find((a) => a.endsWith(`.${t}`)) : r.endsWith(`.${t}`)) {
683
+ this._resolveField(e, t, s);
684
684
  return;
685
685
  }
686
686
  const o = e.component ? `${e.component}.${t}` : t;
687
- (Array.isArray(s) ? s.includes(o) : s === o) && this._resolveField(e, t, n);
687
+ (Array.isArray(r) ? r.includes(o) : r === o) && this._resolveField(e, t, s);
688
688
  }
689
689
  /**
690
690
  * Recursively traverses and resolves relations in the story content tree
@@ -692,70 +692,72 @@ class Oe {
692
692
  * @param fields - The relation patterns to resolve
693
693
  * @param resolveId - The unique identifier for the current resolution context
694
694
  */
695
- iterateTree(e, t, s) {
696
- const n = (o, i = "") => {
695
+ iterateTree(e, t, r) {
696
+ const s = (o, a = "") => {
697
697
  if (!(!o || o._stopResolving)) {
698
698
  if (Array.isArray(o))
699
- o.forEach((l, a) => n(l, `${i}[${a}]`));
699
+ o.forEach((l, i) => s(l, `${a}[${i}]`));
700
700
  else if (typeof o == "object")
701
701
  for (const l in o) {
702
- const a = i ? `${i}.${l}` : l;
703
- (o.component && o._uid || o.type === "link") && (this._insertRelations(o, l, t, s), this._insertLinks(o, l, s)), n(o[l], a);
702
+ const i = a ? `${a}.${l}` : l;
703
+ (o.component && o._uid || o.type === "link") && (this._insertRelations(o, l, t, r), this._insertLinks(o, l, r)), s(o[l], i);
704
704
  }
705
705
  }
706
706
  };
707
- n(e.content);
707
+ s(e.content);
708
708
  }
709
- async resolveLinks(e, t, s) {
710
- let n = [];
709
+ async resolveLinks(e, t, r) {
710
+ let s = [];
711
711
  if (e.link_uuids) {
712
- const o = e.link_uuids.length, i = [], l = 50;
713
- for (let a = 0; a < o; a += l) {
714
- const h = Math.min(o, a + l);
715
- i.push(e.link_uuids.slice(a, h));
712
+ const o = e.link_uuids.length, a = [], l = 50;
713
+ for (let i = 0; i < o; i += l) {
714
+ const h = Math.min(o, i + l);
715
+ a.push(e.link_uuids.slice(i, h));
716
716
  }
717
- for (let a = 0; a < i.length; a++)
717
+ for (let i = 0; i < a.length; i++)
718
718
  (await this.getStories({
719
719
  per_page: l,
720
720
  language: t.language,
721
721
  version: t.version,
722
- by_uuids: i[a].join(",")
722
+ starts_with: t.starts_with,
723
+ by_uuids: a[i].join(",")
723
724
  })).data.stories.forEach(
724
725
  (h) => {
725
- n.push(h);
726
+ s.push(h);
726
727
  }
727
728
  );
728
729
  } else
729
- n = e.links;
730
- n.forEach((o) => {
731
- this.links[s][o.uuid] = {
730
+ s = e.links;
731
+ s.forEach((o) => {
732
+ this.links[r][o.uuid] = {
732
733
  ...o,
733
734
  _stopResolving: !0
734
735
  };
735
736
  });
736
737
  }
737
- async resolveRelations(e, t, s) {
738
- let n = [];
738
+ async resolveRelations(e, t, r) {
739
+ let s = [];
739
740
  if (e.rel_uuids) {
740
- const o = e.rel_uuids.length, i = [], l = 50;
741
- for (let a = 0; a < o; a += l) {
742
- const h = Math.min(o, a + l);
743
- i.push(e.rel_uuids.slice(a, h));
741
+ const o = e.rel_uuids.length, a = [], l = 50;
742
+ for (let i = 0; i < o; i += l) {
743
+ const h = Math.min(o, i + l);
744
+ a.push(e.rel_uuids.slice(i, h));
744
745
  }
745
- for (let a = 0; a < i.length; a++)
746
+ for (let i = 0; i < a.length; i++)
746
747
  (await this.getStories({
747
748
  per_page: l,
748
749
  language: t.language,
749
750
  version: t.version,
750
- by_uuids: i[a].join(","),
751
+ starts_with: t.starts_with,
752
+ by_uuids: a[i].join(","),
751
753
  excluding_fields: t.excluding_fields
752
754
  })).data.stories.forEach((h) => {
753
- n.push(h);
755
+ s.push(h);
754
756
  });
755
757
  } else
756
- n = e.rels;
757
- n && n.length > 0 && n.forEach((o) => {
758
- this.relations[s][o.uuid] = {
758
+ s = e.rels;
759
+ s && s.length > 0 && s.forEach((o) => {
760
+ this.relations[r][o.uuid] = {
759
761
  ...o,
760
762
  _stopResolving: !0
761
763
  };
@@ -770,60 +772,60 @@ class Oe {
770
772
  * @returns Promise<void>
771
773
  *
772
774
  */
773
- async resolveStories(e, t, s) {
774
- var n, o;
775
- let i = [];
776
- if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((n = e.links) != null && n.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
777
- for (const l in this.relations[s])
775
+ async resolveStories(e, t, r) {
776
+ var s, o;
777
+ let a = [];
778
+ if (this.links[r] = {}, this.relations[r] = {}, 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, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations)
779
+ for (const l in this.relations[r])
778
780
  this.iterateTree(
779
- this.relations[s][l],
780
- i,
781
- s
781
+ this.relations[r][l],
782
+ a,
783
+ r
782
784
  );
783
- e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
784
- this.iterateTree(l, i, s);
785
- }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
785
+ e.story ? this.iterateTree(e.story, a, r) : e.stories.forEach((l) => {
786
+ this.iterateTree(l, a, r);
787
+ }), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
786
788
  }
787
- async cacheResponse(e, t, s, n) {
788
- const o = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
789
+ async cacheResponse(e, t, r, s) {
790
+ const o = this.helpers.stringify({ url: e, params: t }), a = this.cacheProvider();
789
791
  if (t.version === "published" && e !== "/cdn/spaces/me") {
790
- const l = await i.get(o);
792
+ const l = await a.get(o);
791
793
  if (l)
792
794
  return Promise.resolve(l);
793
795
  }
794
- return new Promise(async (l, a) => {
796
+ return new Promise(async (l, i) => {
795
797
  var h;
796
798
  try {
797
- const u = await this.throttle(
799
+ const d = await this.throttle(
798
800
  "get",
799
801
  e,
800
802
  t,
801
- n
803
+ s
802
804
  );
803
- if (u.status !== 200)
804
- return a(u);
805
- let d = { data: u.data, headers: u.headers };
806
- if ((h = u.headers) != null && h["per-page"] && (d = Object.assign({}, d, {
807
- perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
808
- total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
809
- })), d.data.story || d.data.stories) {
810
- const y = this.resolveCounter = ++this.resolveCounter % 1e3;
811
- await this.resolveStories(d.data, t, `${y}`);
805
+ if (d.status !== 200)
806
+ return i(d);
807
+ let p = { data: d.data, headers: d.headers };
808
+ if ((h = d.headers) != null && h["per-page"] && (p = Object.assign({}, p, {
809
+ perPage: d.headers["per-page"] ? Number.parseInt(d.headers["per-page"]) : 0,
810
+ total: d.headers["per-page"] ? Number.parseInt(d.headers.total) : 0
811
+ })), p.data.story || p.data.stories) {
812
+ const k = this.resolveCounter = ++this.resolveCounter % 1e3;
813
+ await this.resolveStories(p.data, t, `${k}`);
812
814
  }
813
- t.version === "published" && e !== "/cdn/spaces/me" && await i.set(o, d);
814
- const m = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
815
- return t.token && d.data.cv && (m && S[t.token] && S[t.token] !== d.data.cv && await this.flushCache(), S[t.token] = d.data.cv), l(d);
816
- } catch (u) {
817
- if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
815
+ t.version === "published" && e !== "/cdn/spaces/me" && await a.set(o, p);
816
+ const b = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
817
+ return t.token && p.data.cv && (b && S[t.token] && S[t.token] !== p.data.cv && await this.flushCache(), S[t.token] = p.data.cv), l(p);
818
+ } catch (d) {
819
+ if (d.response && d.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
818
820
  return console.log(
819
821
  `Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
820
- ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
821
- a(u);
822
+ ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, r).then(l).catch(i);
823
+ i(d);
822
824
  }
823
825
  });
824
826
  }
825
- throttledRequest(e, t, s, n) {
826
- return this.client.setFetchOptions(n), this.client[e](t, s);
827
+ throttledRequest(e, t, r, s) {
828
+ return this.client.setFetchOptions(s), this.client[e](t, r);
827
829
  }
828
830
  cacheVersions() {
829
831
  return S;
@@ -842,16 +844,16 @@ class Oe {
842
844
  case "memory":
843
845
  return {
844
846
  get(e) {
845
- return Promise.resolve(O[e]);
847
+ return Promise.resolve(A[e]);
846
848
  },
847
849
  getAll() {
848
- return Promise.resolve(O);
850
+ return Promise.resolve(A);
849
851
  },
850
852
  set(e, t) {
851
- return O[e] = t, Promise.resolve(void 0);
853
+ return A[e] = t, Promise.resolve(void 0);
852
854
  },
853
855
  flush() {
854
- return O = {}, Promise.resolve(void 0);
856
+ return A = {}, Promise.resolve(void 0);
855
857
  }
856
858
  };
857
859
  case "custom":
@@ -879,21 +881,21 @@ class Oe {
879
881
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
880
882
  }
881
883
  }
882
- const Ue = (r = {}) => {
883
- const { apiOptions: e } = r;
884
+ const De = (n = {}) => {
885
+ const { apiOptions: e } = n;
884
886
  if (!e || !e.accessToken) {
885
887
  console.error(
886
888
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
887
889
  );
888
890
  return;
889
891
  }
890
- return { storyblokApi: new Oe(e) };
891
- }, He = (r) => {
892
- if (typeof r != "object" || typeof r._editable > "u")
892
+ return { storyblokApi: new Pe(e) };
893
+ }, qe = (n) => {
894
+ if (typeof n != "object" || typeof n._editable > "u")
893
895
  return {};
894
896
  try {
895
897
  const e = JSON.parse(
896
- r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
898
+ n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
897
899
  );
898
900
  return e ? {
899
901
  "data-blok-c": JSON.stringify(e),
@@ -903,39 +905,39 @@ const Ue = (r = {}) => {
903
905
  return {};
904
906
  }
905
907
  };
906
- function Ae(r, e) {
908
+ function Ne(n, e) {
907
909
  if (!e)
908
- return { src: r, attrs: {} };
909
- let t = 0, s = 0;
910
- const n = {}, o = [];
911
- function i(a, h, u, d, m) {
912
- typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : m.push(`${d}(${a})`);
910
+ return { src: n, attrs: {} };
911
+ let t = 0, r = 0;
912
+ const s = {}, o = [];
913
+ function a(i, h, d, p, b) {
914
+ typeof i != "number" || i <= h || i >= d ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${d} (inclusive)`) : b.push(`${p}(${i})`);
913
915
  }
914
916
  if (typeof e == "object") {
915
- if (typeof e.width == "number" && e.width > 0 ? (n.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 ? (n.height = e.height, s = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (n.loading = e.loading), e.class && (n.class = e.class), e.filters) {
916
- const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format: m, grayscale: y, quality: b, rotate: _ } = a || {};
917
- h && i(h, 0, 100, "blur", o), b && i(b, 0, 100, "quality", o), u && i(u, 0, 100, "brightness", o), d && o.push(`fill(${d})`), y && o.push("grayscale()"), _ && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${_})`), m && ["webp", "png", "jpeg"].includes(m) && o.push(`format(${m})`);
917
+ 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, r = 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) {
918
+ const { filters: i } = e || {}, { blur: h, brightness: d, fill: p, format: b, grayscale: k, quality: w, rotate: E } = i || {};
919
+ h && a(h, 0, 100, "blur", o), w && a(w, 0, 100, "quality", o), d && a(d, 0, 100, "brightness", o), p && o.push(`fill(${p})`), k && o.push("grayscale()"), E && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${E})`), b && ["webp", "png", "jpeg"].includes(b) && o.push(`format(${b})`);
918
920
  }
919
- e.srcset && (n.srcset = e.srcset.map((a) => {
920
- if (typeof a == "number")
921
- return `${r}/m/${a}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${a}w`;
922
- if (Array.isArray(a) && a.length === 2) {
923
- const [h, u] = a;
924
- return `${r}/m/${h}x${u}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${h}w`;
921
+ e.srcset && (s.srcset = e.srcset.map((i) => {
922
+ if (typeof i == "number")
923
+ return `${n}/m/${i}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${i}w`;
924
+ if (Array.isArray(i) && i.length === 2) {
925
+ const [h, d] = i;
926
+ return `${n}/m/${h}x${d}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${h}w`;
925
927
  } else {
926
928
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
927
929
  return;
928
930
  }
929
- }).join(", ")), e.sizes && (n.sizes = e.sizes.join(", "));
931
+ }).join(", ")), e.sizes && (s.sizes = e.sizes.join(", "));
930
932
  }
931
- let l = `${r}/m/`;
932
- return t > 0 && s > 0 && (l = `${l}${t}x${s}/`), o.length > 0 && (l = `${l}filters:${o.join(":")}`), {
933
+ let l = `${n}/m/`;
934
+ return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), o.length > 0 && (l = `${l}filters:${o.join(":")}`), {
933
935
  src: l,
934
- attrs: n
936
+ attrs: s
935
937
  };
936
938
  }
937
- 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))(v || {}), T = /* @__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))(T || {}), G = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(G || {}), I = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(I || {});
938
- const Le = [
939
+ var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n.TABLE = "table", n.TABLE_ROW = "tableRow", n.TABLE_CELL = "tableCell", n.TABLE_HEADER = "tableHeader", n))(v || {}), _ = /* @__PURE__ */ ((n) => (n.BOLD = "bold", n.STRONG = "strong", n.STRIKE = "strike", n.UNDERLINE = "underline", n.ITALIC = "italic", n.CODE = "code", n.LINK = "link", n.ANCHOR = "anchor", n.STYLED = "styled", n.SUPERSCRIPT = "superscript", n.SUBSCRIPT = "subscript", n.TEXT_STYLE = "textStyle", n.HIGHLIGHT = "highlight", n))(_ || {}), G = /* @__PURE__ */ ((n) => (n.TEXT = "text", n))(G || {}), I = /* @__PURE__ */ ((n) => (n.URL = "url", n.STORY = "story", n.ASSET = "asset", n.EMAIL = "email", n))(I || {});
940
+ const He = [
939
941
  "area",
940
942
  "base",
941
943
  "br",
@@ -950,91 +952,91 @@ const Le = [
950
952
  "source",
951
953
  "track",
952
954
  "wbr"
953
- ], Pe = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), Ce = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
954
- function Ne(r) {
955
- return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
955
+ ], Me = (n = {}) => Object.keys(n).map((e) => `${e}="${n[e]}"`).join(" "), Ue = (n = {}) => Object.keys(n).map((e) => `${e}: ${n[e]}`).join("; ");
956
+ function Be(n) {
957
+ return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
956
958
  }
957
- const B = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
958
- function q(r, e = {}, t) {
959
- const s = Pe(e), n = s ? `${r} ${s}` : r, o = Array.isArray(t) ? t.join("") : t || "";
960
- if (r) {
961
- if (Le.includes(r))
962
- return `<${n}>`;
959
+ const O = (n) => Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0));
960
+ function q(n, e = {}, t) {
961
+ const r = Me(e), s = r ? `${n} ${r}` : n, o = Array.isArray(t) ? t.join("") : t || "";
962
+ if (n) {
963
+ if (He.includes(n))
964
+ return `<${s}>`;
963
965
  } else return o;
964
- return `<${n}>${o}</${r}>`;
966
+ return `<${s}>${o}</${n}>`;
965
967
  }
966
- function ze(r = {}) {
968
+ function Fe(n = {}) {
967
969
  let e = 0;
968
970
  const {
969
971
  renderFn: t = q,
970
- textFn: s = Ne,
971
- resolvers: n = {},
972
+ textFn: r = Be,
973
+ resolvers: s = {},
972
974
  optimizeImages: o = !1,
973
- keyedResolvers: i = !1
974
- } = r, l = t !== q, a = (c) => (g) => {
975
- const f = g.attrs || {};
976
- return i && (f.key = `${c}-${e}`), t(c, f, g.children || null);
975
+ keyedResolvers: a = !1
976
+ } = n, l = t !== q, i = (c) => (u) => {
977
+ const f = u.attrs || {};
978
+ return a && (f.key = `${c}-${e}`), t(c, f, u.children || null);
977
979
  }, h = (c) => {
978
- const { src: g, alt: f, title: k, srcset: R, sizes: $ } = c.attrs || {};
979
- let w = g, E = {};
980
+ const { src: u, alt: f, title: y, srcset: R, sizes: $ } = c.attrs || {};
981
+ let m = u, T = {};
980
982
  if (o) {
981
- const { src: W, attrs: X } = Ae(g, o);
982
- w = W, E = X;
983
+ const { src: ee, attrs: te } = Ne(u, o);
984
+ m = ee, T = te;
983
985
  }
984
- i && (E = {
985
- ...E,
986
+ a && (T = {
987
+ ...T,
986
988
  key: `img-${e}`
987
989
  });
988
- const Y = {
989
- src: w,
990
+ const Z = {
991
+ src: m,
990
992
  alt: f,
991
- title: k,
993
+ title: y,
992
994
  srcset: R,
993
995
  sizes: $,
994
- ...E
996
+ ...T
995
997
  };
996
- return t("img", B(Y));
997
- }, u = (c) => {
998
- const { level: g, ...f } = c.attrs || {}, k = {
998
+ return t("img", O(Z));
999
+ }, d = (c) => {
1000
+ const { level: u, ...f } = c.attrs || {}, y = {
999
1001
  ...f
1000
1002
  };
1001
- return i && (k.key = `h${g}-${e}`), t(`h${g}`, k, c.children);
1002
- }, d = (c) => {
1003
- var g, f, k, R;
1003
+ return a && (y.key = `h${u}-${e}`), t(`h${u}`, y, c.children);
1004
+ }, p = (c) => {
1005
+ var u, f, y, R;
1004
1006
  const $ = t("img", {
1005
- src: (g = c.attrs) == null ? void 0 : g.fallbackImage,
1007
+ src: (u = c.attrs) == null ? void 0 : u.fallbackImage,
1006
1008
  alt: (f = c.attrs) == null ? void 0 : f.alt,
1007
1009
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
1008
1010
  draggable: "false",
1009
1011
  loading: "lazy"
1010
- }), w = {
1012
+ }), m = {
1011
1013
  "data-type": "emoji",
1012
- "data-name": (k = c.attrs) == null ? void 0 : k.name,
1014
+ "data-name": (y = c.attrs) == null ? void 0 : y.name,
1013
1015
  "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
1014
1016
  };
1015
- return i && (w.key = `emoji-${e}`), t("span", w, $);
1016
- }, m = (c) => t("pre", {
1017
+ return a && (m.key = `emoji-${e}`), t("span", m, $);
1018
+ }, b = (c) => t("pre", {
1017
1019
  ...c.attrs,
1018
1020
  key: `code-${e}`
1019
- }, t("code", { key: `code-${e}` }, c.children || "")), y = (c, g = !1) => ({ text: f, attrs: k }) => {
1020
- const { class: R, id: $, ...w } = k || {}, E = g ? {
1021
+ }, t("code", { key: `code-${e}` }, c.children || "")), k = (c, u = !1) => ({ text: f, attrs: y }) => {
1022
+ const { class: R, id: $, ...m } = y || {}, T = u ? {
1021
1023
  class: R,
1022
1024
  id: $,
1023
- style: Ce(w) || void 0
1024
- } : k || {};
1025
- return i && (E.key = `${c}-${e}`), t(c, B(E), f);
1026
- }, b = (c) => P(c), _ = (c) => {
1027
- const { marks: g, ...f } = c;
1028
- return "text" in c ? g ? g.reduce(
1029
- (k, R) => b({ ...R, text: k }),
1025
+ style: Ue(m) || void 0
1026
+ } : y || {};
1027
+ return a && (T.key = `${c}-${e}`), t(c, O(T), f);
1028
+ }, w = (c) => P(c), E = (c) => {
1029
+ const { marks: u, ...f } = c;
1030
+ return "text" in c ? u ? u.reduce(
1031
+ (y, R) => w({ ...R, text: y }),
1030
1032
  // Fix: Ensure render function returns a string
1031
- b({ ...f, children: f.children })
1033
+ w({ ...f, children: f.children })
1032
1034
  // Fix: Cast children to string
1033
- ) : s(f.text) : "";
1035
+ ) : r(f.text) : "";
1034
1036
  }, j = (c) => {
1035
- const { linktype: g, href: f, anchor: k, ...R } = c.attrs || {};
1037
+ const { linktype: u, href: f, anchor: y, ...R } = c.attrs || {};
1036
1038
  let $ = "";
1037
- switch (g) {
1039
+ switch (u) {
1038
1040
  case I.ASSET:
1039
1041
  case I.URL:
1040
1042
  $ = f;
@@ -1043,60 +1045,84 @@ function ze(r = {}) {
1043
1045
  $ = `mailto:${f}`;
1044
1046
  break;
1045
1047
  case I.STORY:
1046
- $ = f, k && ($ = `${$}#${k}`);
1048
+ $ = f, y && ($ = `${$}#${y}`);
1047
1049
  break;
1048
1050
  default:
1049
1051
  $ = f;
1050
1052
  break;
1051
1053
  }
1052
- const w = { ...R };
1053
- return $ && (w.href = $), i && (w.key = `a-${e}`), t("a", w, c.text);
1054
+ const m = { ...R };
1055
+ return $ && (m.href = $), a && (m.key = `a-${e}`), t("a", m, c.text);
1054
1056
  }, J = (c) => {
1055
- var g, f;
1057
+ var u, f;
1056
1058
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
1057
- blok: (g = c == null ? void 0 : c.attrs) == null ? void 0 : g.body[0],
1059
+ blok: (u = c == null ? void 0 : c.attrs) == null ? void 0 : u.body[0],
1058
1060
  id: (f = c.attrs) == null ? void 0 : f.id,
1059
1061
  key: `component-${e}`,
1060
1062
  style: "display: none"
1061
1063
  });
1062
- }, K = new Map([
1063
- [v.DOCUMENT, a("")],
1064
- [v.HEADING, u],
1065
- [v.PARAGRAPH, a("p")],
1066
- [v.UL_LIST, a("ul")],
1067
- [v.OL_LIST, a("ol")],
1068
- [v.LIST_ITEM, a("li")],
1064
+ }, K = (c) => {
1065
+ const u = {};
1066
+ return a && (u.key = `table-${e}`), t("table", u, c.children);
1067
+ }, Y = (c) => {
1068
+ const u = {};
1069
+ return a && (u.key = `tr-${e}`), t("tr", u, c.children);
1070
+ }, W = (c) => {
1071
+ const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1072
+ ...$
1073
+ };
1074
+ u > 1 && (m.colspan = u), f > 1 && (m.rowspan = f);
1075
+ const T = [];
1076
+ return y && T.push(`width: ${y}px;`), R && T.push(`background-color: ${R};`), T.length > 0 && (m.style = T.join(" ")), a && (m.key = `td-${e}`), t("td", O(m), c.children);
1077
+ }, X = (c) => {
1078
+ const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1079
+ ...$
1080
+ };
1081
+ u > 1 && (m.colspan = u), f > 1 && (m.rowspan = f);
1082
+ const T = [];
1083
+ return y && T.push(`width: ${y}px;`), R && T.push(`background-color: ${R};`), T.length > 0 && (m.style = T.join(" ")), a && (m.key = `th-${e}`), t("th", O(m), c.children);
1084
+ }, Q = new Map([
1085
+ [v.DOCUMENT, i("")],
1086
+ [v.HEADING, d],
1087
+ [v.PARAGRAPH, i("p")],
1088
+ [v.UL_LIST, i("ul")],
1089
+ [v.OL_LIST, i("ol")],
1090
+ [v.LIST_ITEM, i("li")],
1069
1091
  [v.IMAGE, h],
1070
- [v.EMOJI, d],
1071
- [v.CODE_BLOCK, m],
1072
- [v.HR, a("hr")],
1073
- [v.BR, a("br")],
1074
- [v.QUOTE, a("blockquote")],
1092
+ [v.EMOJI, p],
1093
+ [v.CODE_BLOCK, b],
1094
+ [v.HR, i("hr")],
1095
+ [v.BR, i("br")],
1096
+ [v.QUOTE, i("blockquote")],
1075
1097
  [v.COMPONENT, J],
1076
- [G.TEXT, _],
1077
- [T.LINK, j],
1078
- [T.ANCHOR, j],
1079
- [T.STYLED, y("span", !0)],
1080
- [T.BOLD, y("strong")],
1081
- [T.TEXT_STYLE, y("span", !0)],
1082
- [T.ITALIC, y("em")],
1083
- [T.UNDERLINE, y("u")],
1084
- [T.STRIKE, y("s")],
1085
- [T.CODE, y("code")],
1086
- [T.SUPERSCRIPT, y("sup")],
1087
- [T.SUBSCRIPT, y("sub")],
1088
- [T.HIGHLIGHT, y("mark")],
1089
- ...Object.entries(n).map(([c, g]) => [c, g])
1098
+ [G.TEXT, E],
1099
+ [_.LINK, j],
1100
+ [_.ANCHOR, j],
1101
+ [_.STYLED, k("span", !0)],
1102
+ [_.BOLD, k("strong")],
1103
+ [_.TEXT_STYLE, k("span", !0)],
1104
+ [_.ITALIC, k("em")],
1105
+ [_.UNDERLINE, k("u")],
1106
+ [_.STRIKE, k("s")],
1107
+ [_.CODE, k("code")],
1108
+ [_.SUPERSCRIPT, k("sup")],
1109
+ [_.SUBSCRIPT, k("sub")],
1110
+ [_.HIGHLIGHT, k("mark")],
1111
+ [v.TABLE, K],
1112
+ [v.TABLE_ROW, Y],
1113
+ [v.TABLE_CELL, W],
1114
+ [v.TABLE_HEADER, X],
1115
+ ...Object.entries(s).map(([c, u]) => [c, u])
1090
1116
  ]);
1091
1117
  function x(c) {
1092
1118
  e += 1;
1093
- const g = K.get(c.type);
1094
- if (!g)
1119
+ const u = Q.get(c.type);
1120
+ if (!u)
1095
1121
  return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
1096
1122
  if (c.type === "text")
1097
- return g(c);
1123
+ return u(c);
1098
1124
  const f = c.content ? c.content.map(P) : void 0;
1099
- return g({
1125
+ return u({
1100
1126
  ...c,
1101
1127
  children: f
1102
1128
  // Fix: Update the type of 'children' to Node[]
@@ -1109,77 +1135,77 @@ function ze(r = {}) {
1109
1135
  render: P
1110
1136
  };
1111
1137
  }
1112
- let N, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1113
- const De = (r, e, t = {}) => {
1114
- var s;
1115
- const n = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
1138
+ let H, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1139
+ const Ge = (n, e, t = {}) => {
1140
+ var r;
1141
+ const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
1116
1142
  "_storyblok"
1117
- ), i = o !== null && +o === r;
1118
- if (!(!n || !i)) {
1119
- if (!r) {
1143
+ ), a = o !== null && +o === n;
1144
+ if (!(!s || !a)) {
1145
+ if (!n) {
1120
1146
  console.warn("Story ID is not defined. Please provide a valid ID.");
1121
1147
  return;
1122
1148
  }
1123
1149
  window.storyblokRegisterEvent(() => {
1124
1150
  new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
1125
- var a;
1126
- l && (l.action === "input" && ((a = l.story) == null ? void 0 : a.id) === r ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === r && window.location.reload());
1151
+ var i;
1152
+ l && (l.action === "input" && ((i = l.story) == null ? void 0 : i.id) === n ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === n && window.location.reload());
1127
1153
  });
1128
1154
  });
1129
1155
  }
1130
- }, V = (r, e) => {
1131
- r.addNode("blok", (t) => {
1132
- let s = "";
1133
- return t.attrs.body.forEach((n) => {
1134
- s += e(n.component, n);
1156
+ }, V = (n, e) => {
1157
+ n.addNode("blok", (t) => {
1158
+ let r = "";
1159
+ return t.attrs.body.forEach((s) => {
1160
+ r += e(s.component, s);
1135
1161
  }), {
1136
- html: s
1162
+ html: r
1137
1163
  };
1138
1164
  });
1139
- }, Be = (r = {}) => {
1165
+ }, Ve = (n = {}) => {
1140
1166
  var e, t;
1141
1167
  const {
1142
- bridge: s,
1143
- accessToken: n,
1168
+ bridge: r,
1169
+ accessToken: s,
1144
1170
  use: o = [],
1145
- apiOptions: i = {},
1171
+ apiOptions: a = {},
1146
1172
  richText: l = {},
1147
- bridgeUrl: a
1148
- } = r;
1149
- i.accessToken = i.accessToken || n;
1150
- const h = { bridge: s, apiOptions: i };
1151
- let u = {};
1152
- o.forEach((m) => {
1153
- u = { ...u, ...m(h) };
1154
- }), a && (M = a);
1155
- const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
1156
- return s !== !1 && d && F(M), N = new L(l.schema), l.resolver && V(N, l.resolver), u;
1157
- }, Me = (r) => {
1173
+ bridgeUrl: i
1174
+ } = n;
1175
+ a.accessToken = a.accessToken || s;
1176
+ const h = { bridge: r, apiOptions: a };
1177
+ let d = {};
1178
+ o.forEach((b) => {
1179
+ d = { ...d, ...b(h) };
1180
+ }), i && (M = i);
1181
+ const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
1182
+ return r !== !1 && p && F(M), H = new C(l.schema), l.resolver && V(H, l.resolver), d;
1183
+ }, ze = (n) => {
1158
1184
  var e;
1159
- return !r || !((e = r == null ? void 0 : r.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1160
- }, qe = (r, e, t) => {
1161
- let s = t || N;
1162
- if (!s) {
1185
+ return !n || !((e = n == null ? void 0 : n.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1186
+ }, Je = (n, e, t) => {
1187
+ let r = t || H;
1188
+ if (!r) {
1163
1189
  console.error(
1164
1190
  "Please initialize the Storyblok SDK before calling the renderRichText function"
1165
1191
  );
1166
1192
  return;
1167
1193
  }
1168
- return Me(r) ? "" : (e && (s = new L(e.schema), e.resolver && V(s, e.resolver)), s.render(r, {}, !1));
1169
- }, Fe = () => F(M);
1194
+ return ze(n) ? "" : (e && (r = new C(e.schema), e.resolver && V(r, e.resolver)), r.render(n, {}, !1));
1195
+ }, Ke = () => F(M);
1170
1196
  export {
1171
1197
  v as BlockTypes,
1172
- T as MarkTypes,
1173
- L as RichTextResolver,
1174
- je as RichTextSchema,
1198
+ _ as MarkTypes,
1199
+ C as RichTextResolver,
1200
+ Oe as RichTextSchema,
1175
1201
  G as TextTypes,
1176
- Ue as apiPlugin,
1177
- Me as isRichTextEmpty,
1178
- Fe as loadStoryblokBridge,
1179
- De as registerStoryblokBridge,
1180
- qe as renderRichText,
1181
- ze as richTextResolver,
1182
- He as storyblokEditable,
1183
- Be as storyblokInit,
1184
- De as useStoryblokBridge
1202
+ De as apiPlugin,
1203
+ ze as isRichTextEmpty,
1204
+ Ke as loadStoryblokBridge,
1205
+ Ge as registerStoryblokBridge,
1206
+ Je as renderRichText,
1207
+ Fe as richTextResolver,
1208
+ qe as storyblokEditable,
1209
+ Ve as storyblokInit,
1210
+ Ge as useStoryblokBridge
1185
1211
  };