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