@storyblok/react 4.5.3 → 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 = (n) => 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 = 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);
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 = (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 {
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 oe(n, 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 = [], o = 0, a = !1;
29
- const l = async () => {
27
+ const n = [];
28
+ let s = [], o = 0, l = !1;
29
+ const a = async () => {
30
30
  o++;
31
- const h = r.shift();
31
+ const h = n.shift();
32
32
  if (h)
33
33
  try {
34
- const p = await n(...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
- o--, 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
- }), o < 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 ne("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, (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) {
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, (o) => t[o]) : 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
89
  for (const o in e) {
90
90
  if (!Object.prototype.hasOwnProperty.call(e, o))
91
91
  continue;
92
- const a = e[o];
93
- if (a == null)
92
+ const l = e[o];
93
+ if (l == null)
94
94
  continue;
95
- const l = r ? "" : encodeURIComponent(o);
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", o = "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
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(n, e) {
126
+ const le = function(r, e) {
127
127
  const t = {};
128
- for (const r in n) {
129
- const s = n[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 = (n) => n === "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 = (n) => ({
139
+ }), pe = (r) => ({
140
140
  tag: [
141
141
  "pre",
142
142
  {
143
143
  tag: "code",
144
- attrs: n.attrs
144
+ attrs: r.attrs
145
145
  }
146
146
  ]
147
- }), de = () => ({
147
+ }), ge = () => ({
148
148
  singleTag: "br"
149
- }), pe = (n) => ({
150
- tag: `h${n.attrs.level}`
151
- }), ge = (n) => ({
149
+ }), fe = (r) => ({
150
+ tag: `h${r.attrs.level}`
151
+ }), me = (r) => ({
152
152
  singleTag: [
153
153
  {
154
154
  tag: "img",
155
- attrs: ae(n.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 = (n) => ({
164
+ }), ke = (r) => ({
165
165
  tag: [
166
166
  {
167
167
  tag: "span",
168
168
  attrs: {
169
169
  "data-type": "emoji",
170
- "data-name": n.attrs.name,
171
- emoji: n.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
- }), $e = () => ({
177
+ }), we = () => ({
178
178
  tag: "s"
179
- }), ve = () => ({
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 = (n) => {
188
- if (!n.attrs)
187
+ }), Se = (r) => {
188
+ if (!r.attrs)
189
189
  return {
190
190
  tag: ""
191
191
  };
192
- const e = new L().escapeHTML, t = { ...n.attrs }, { linktype: r = "url" } = n.attrs;
193
- 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) {
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(n, e) {
203
203
  }
204
204
  ]
205
205
  };
206
- }, Ee = (n) => ({
206
+ }, je = (r) => ({
207
207
  tag: [
208
208
  {
209
209
  tag: "span",
210
- attrs: n.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 = (n) => ({
217
+ }), Ae = (r) => ({
218
218
  tag: [
219
219
  {
220
220
  tag: "span",
221
- attrs: n.attrs
221
+ attrs: r.attrs
222
222
  }
223
223
  ]
224
- }), xe = (n) => {
224
+ }), Oe = (r) => {
225
225
  var e;
226
- return (e = n.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:${n.attrs.color};`
231
+ style: `background-color:${r.attrs.color};`
232
232
  }
233
233
  }
234
234
  ]
235
235
  } : {
236
236
  tag: ""
237
237
  };
238
- }, Ae = (n) => {
238
+ }, Le = (r) => {
239
239
  var e;
240
- return (e = n.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:${n.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: $e,
269
- underline: ve,
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(n) {
267
+ bold: Te,
268
+ strike: we,
269
+ underline: $e,
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 n && r.test(n) ? n.replace(t, (s) => e[s]) : n;
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((o) => {
308
- s += this.renderNode(o);
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, o = "", a = "";
340
- 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()}`));
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 o = this.getMatchingMark(s);
373
- o && o.tag !== "" && t.push(this.renderOpeningTag(o.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 o = this.getMatchingMark(s);
380
- o && o.tag !== "" && t.push(this.renderClosingTag(o.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 o in r.attrs)
391
- if (Object.prototype.hasOwnProperty.call(r.attrs, o)) {
392
- const a = r.attrs[o];
393
- a !== null && (s += ` ${o}="${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), o = new AbortController(), { signal: a } = o;
479
- let l;
480
- this.timeout && (l = setTimeout(() => o.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,9 +504,9 @@ 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);
509
+ return n(e);
511
510
  const o = {
512
511
  message: e.statusText,
513
512
  status: e.status,
@@ -517,40 +516,40 @@ class Ce {
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
546
  let o = 5;
548
- 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(
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
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, o) {
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, o);
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
584
  const s = `/${e}`, o = this.factoryParamOptions(s, t);
586
- return this.cacheResponse(s, o, void 0, r);
585
+ return this.cacheResponse(s, o, void 0, n);
587
586
  }
588
- async getAll(e, t, r, s) {
589
- 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(
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
591
  o,
593
592
  i,
594
593
  s
595
- ), d = h.total ? Math.ceil(h.total / o) : 1, p = await this.helpers.asyncMap(
596
- this.helpers.range(i, d),
597
- (b) => this.makeRequest(a, t, o, 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
- (o) => this.getStoryReference(r, o)
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
688
  const o = e.component ? `${e.component}.${t}` : t;
690
- (Array.isArray(r) ? r.includes(o) : r === o) && this._resolveField(e, t, s);
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 = (o, a = "") => {
697
+ iterateTree(e, t, n) {
698
+ const s = (o, l = "") => {
700
699
  if (!(!o || o._stopResolving)) {
701
700
  if (Array.isArray(o))
702
- o.forEach((l, i) => s(l, `${a}[${i}]`));
701
+ o.forEach((a, i) => s(a, `${l}[${i}]`));
703
702
  else if (typeof o == "object")
704
- for (const l in o) {
705
- const i = a ? `${a}.${l}` : l;
706
- (o.component && o._uid || o.type === "link") && (this._insertRelations(o, l, t, r), this._insertLinks(o, l, r)), s(o[l], i);
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 o = e.link_uuids.length, a = [], l = 50;
716
- for (let i = 0; i < o; i += l) {
717
- const h = Math.min(o, 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);
@@ -732,27 +731,27 @@ class Pe {
732
731
  } else
733
732
  s = e.links;
734
733
  s.forEach((o) => {
735
- this.links[r][o.uuid] = {
734
+ this.links[n][o.uuid] = {
736
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 o = e.rel_uuids.length, a = [], l = 50;
745
- for (let i = 0; i < o; i += l) {
746
- const h = Math.min(o, 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);
@@ -760,7 +759,7 @@ class Pe {
760
759
  } else
761
760
  s = e.rels;
762
761
  s && s.length > 0 && s.forEach((o) => {
763
- this.relations[r][o.uuid] = {
762
+ this.relations[n][o.uuid] = {
764
763
  ...o,
765
764
  _stopResolving: !0
766
765
  };
@@ -775,72 +774,72 @@ class Pe {
775
774
  * @returns Promise<void>
776
775
  *
777
776
  */
778
- async resolveStories(e, t, r) {
777
+ async resolveStories(e, t, n) {
779
778
  var s, o;
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 || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations)
782
- for (const l in this.relations[r])
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 o = 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(o);
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(o, 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) {
@@ -862,7 +861,6 @@ class Pe {
862
861
  case "custom":
863
862
  if (this.cache.custom)
864
863
  return this.cache.custom;
865
- // eslint-disable-next-line no-fallthrough
866
864
  default:
867
865
  return {
868
866
  get() {
@@ -884,21 +882,21 @@ class Pe {
884
882
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
885
883
  }
886
884
  }
887
- const De = (n = {}) => {
888
- const { apiOptions: e } = n;
885
+ const Fe = (r = {}) => {
886
+ const { apiOptions: e } = r;
889
887
  if (!e || !e.accessToken) {
890
888
  console.error(
891
889
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
892
890
  );
893
891
  return;
894
892
  }
895
- return { storyblokApi: new Pe(e) };
896
- }, qe = (n) => {
897
- if (typeof n != "object" || typeof n._editable > "u")
893
+ return { storyblokApi: new He(e) };
894
+ }, Ge = (r) => {
895
+ if (typeof r != "object" || typeof r._editable > "u")
898
896
  return {};
899
897
  try {
900
898
  const e = JSON.parse(
901
- n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
899
+ r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
902
900
  );
903
901
  return e ? {
904
902
  "data-blok-c": JSON.stringify(e),
@@ -908,39 +906,39 @@ const De = (n = {}) => {
908
906
  return {};
909
907
  }
910
908
  };
911
- function Ne(n, e) {
909
+ function Me(r, e) {
912
910
  if (!e)
913
- return { src: n, attrs: {} };
914
- let t = 0, r = 0;
911
+ return { src: r, attrs: {} };
912
+ let t = 0, n = 0;
915
913
  const s = {}, o = [];
916
- function a(i, h, d, p, b) {
917
- 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})`);
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})`);
918
916
  }
919
917
  if (typeof e == "object") {
920
- 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) {
921
- const { filters: i } = e || {}, { blur: h, brightness: d, fill: p, format: b, grayscale: k, quality: w, rotate: E } = i || {};
922
- 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
+ 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})`);
923
921
  }
924
922
  e.srcset && (s.srcset = e.srcset.map((i) => {
925
923
  if (typeof i == "number")
926
- return `${n}/m/${i}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${i}w`;
924
+ return `${r}/m/${i}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${i}w`;
927
925
  if (Array.isArray(i) && i.length === 2) {
928
- const [h, d] = i;
929
- return `${n}/m/${h}x${d}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${h}w`;
926
+ const [h, u] = i;
927
+ return `${r}/m/${h}x${u}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${h}w`;
930
928
  } else {
931
929
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
932
930
  return;
933
931
  }
934
932
  }).join(", ")), e.sizes && (s.sizes = e.sizes.join(", "));
935
933
  }
936
- let l = `${n}/m/`;
937
- return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), o.length > 0 && (l = `${l}filters:${o.join(":")}`), {
938
- 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,
939
937
  attrs: s
940
938
  };
941
939
  }
942
- 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 || {});
943
- 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 = [
944
942
  "area",
945
943
  "base",
946
944
  "br",
@@ -955,260 +953,266 @@ const He = [
955
953
  "source",
956
954
  "track",
957
955
  "wbr"
958
- ], Me = (n = {}) => Object.keys(n).map((e) => `${e}="${n[e]}"`).join(" "), Ue = (n = {}) => Object.keys(n).map((e) => `${e}: ${n[e]}`).join("; ");
959
- function Be(n) {
960
- return n.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;");
961
959
  }
962
- const O = (n) => Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0));
963
- function q(n, e = {}, t) {
964
- const r = Me(e), s = r ? `${n} ${r}` : n, o = Array.isArray(t) ? t.join("") : t || "";
965
- if (n) {
966
- if (He.includes(n))
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))
967
965
  return `<${s}>`;
968
966
  } else return o;
969
- return `<${s}>${o}</${n}>`;
967
+ return `<${s}>${o}</${r}>`;
970
968
  }
971
- function Fe(n = {}) {
972
- let e = 0;
973
- const {
974
- renderFn: t = q,
975
- textFn: r = Be,
969
+ function Ve(r = {}) {
970
+ const e = /* @__PURE__ */ new Map(), {
971
+ renderFn: t = F,
972
+ textFn: n = De,
976
973
  resolvers: s = {},
977
974
  optimizeImages: o = !1,
978
- keyedResolvers: a = !1
979
- } = n, l = t !== q, i = (c) => (u) => {
980
- const f = u.attrs || {};
981
- return a && (f.key = `${c}-${e}`), t(c, f, u.children || null);
982
- }, h = (c) => {
983
- const { src: u, alt: f, title: y, srcset: R, sizes: $ } = c.attrs || {};
984
- let m = u, T = {};
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}`;
980
+ }
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, _ = {};
985
988
  if (o) {
986
- const { src: ee, attrs: te } = Ne(u, o);
987
- m = ee, T = te;
989
+ const { src: re, attrs: se } = Me(g, o);
990
+ $ = re, _ = se;
988
991
  }
989
- a && (T = {
990
- ...T,
991
- key: `img-${e}`
992
- });
993
- const Z = {
994
- src: m,
992
+ const te = {
993
+ src: $,
995
994
  alt: f,
996
995
  title: y,
997
996
  srcset: R,
998
- sizes: $,
999
- ...T
997
+ sizes: v,
998
+ ..._
1000
999
  };
1001
- return t("img", O(Z));
1002
- }, d = (c) => {
1003
- const { level: u, ...f } = c.attrs || {}, y = {
1004
- ...f
1005
- };
1006
- return a && (y.key = `h${u}-${e}`), t(`h${u}`, y, c.children);
1007
- }, p = (c) => {
1008
- var u, f, y, R;
1009
- const $ = t("img", {
1010
- 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,
1011
1008
  alt: (f = c.attrs) == null ? void 0 : f.alt,
1012
1009
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
1013
1010
  draggable: "false",
1014
1011
  loading: "lazy"
1015
- }), m = {
1012
+ });
1013
+ return d.render("span", {
1016
1014
  "data-type": "emoji",
1017
1015
  "data-name": (y = c.attrs) == null ? void 0 : y.name,
1018
1016
  "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
1019
- };
1020
- return a && (m.key = `emoji-${e}`), t("span", m, $);
1021
- }, b = (c) => t("pre", {
1022
- ...c.attrs,
1023
- key: `code-${e}`
1024
- }, t("code", { key: `code-${e}` }, c.children || "")), k = (c, u = !1) => ({ text: f, attrs: y }) => {
1025
- const { class: R, id: $, ...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 ? {
1026
1024
  class: R,
1027
- id: $,
1028
- style: Ue(m) || void 0
1029
- } : y || {};
1030
- return a && (T.key = `${c}-${e}`), t(c, O(T), f);
1031
- }, w = (c) => P(c), E = (c) => {
1032
- const { marks: u, ...f } = c;
1033
- return "text" in c ? u ? u.reduce(
1034
- (y, R) => w({ ...R, text: y }),
1035
- // Fix: Ensure render function returns a string
1036
- w({ ...f, children: f.children })
1037
- // Fix: Cast children to string
1038
- ) : r(f.text) : "";
1039
- }, j = (c) => {
1040
- const { linktype: u, href: f, anchor: y, ...R } = c.attrs || {};
1041
- let $ = "";
1042
- switch (u) {
1043
- case I.ASSET:
1044
- case I.URL:
1045
- $ = f;
1025
+ id: v,
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 || {};
1047
+ let v = "";
1048
+ switch (g) {
1049
+ case x.ASSET:
1050
+ case x.URL:
1051
+ v = f;
1046
1052
  break;
1047
- case I.EMAIL:
1048
- $ = `mailto:${f}`;
1053
+ case x.EMAIL:
1054
+ v = `mailto:${f}`;
1049
1055
  break;
1050
- case I.STORY:
1051
- $ = f, y && ($ = `${$}#${y}`);
1056
+ case x.STORY:
1057
+ v = f, y && (v = `${v}#${y}`);
1052
1058
  break;
1053
1059
  default:
1054
- $ = f;
1060
+ v = f;
1055
1061
  break;
1056
1062
  }
1057
- const m = { ...R };
1058
- return $ && (m.href = $), a && (m.key = `a-${e}`), t("a", m, c.text);
1059
- }, J = (c) => {
1060
- var u, f;
1061
- return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
1062
- 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],
1063
1069
  id: (f = c.attrs) == null ? void 0 : f.id,
1064
- key: `component-${e}`,
1065
1070
  style: "display: none"
1066
1071
  });
1067
- }, K = (c) => {
1068
- const u = {};
1069
- return a && (u.key = `table-${e}`), t("table", u, c.children);
1070
- }, Y = (c) => {
1071
- const u = {};
1072
- return a && (u.key = `tr-${e}`), t("tr", u, c.children);
1073
- }, W = (c) => {
1074
- const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1075
- ...$
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 || {}, $ = {
1080
+ ...v
1076
1081
  };
1077
- u > 1 && (m.colspan = u), f > 1 && (m.rowspan = f);
1078
- const T = [];
1079
- 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);
1080
- }, X = (c) => {
1081
- const { colspan: u, rowspan: f, colwidth: y, backgroundColor: R, ...$ } = c.attrs || {}, m = {
1082
- ...$
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 || {}, $ = {
1087
+ ...v
1083
1088
  };
1084
- u > 1 && (m.colspan = u), f > 1 && (m.rowspan = f);
1085
- const T = [];
1086
- 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);
1087
- }, Q = new Map([
1088
- [v.DOCUMENT, i("")],
1089
- [v.HEADING, d],
1090
- [v.PARAGRAPH, i("p")],
1091
- [v.UL_LIST, i("ul")],
1092
- [v.OL_LIST, i("ol")],
1093
- [v.LIST_ITEM, i("li")],
1094
- [v.IMAGE, h],
1095
- [v.EMOJI, p],
1096
- [v.CODE_BLOCK, b],
1097
- [v.HR, i("hr")],
1098
- [v.BR, i("br")],
1099
- [v.QUOTE, i("blockquote")],
1100
- [v.COMPONENT, J],
1101
- [G.TEXT, E],
1102
- [_.LINK, j],
1103
- [_.ANCHOR, j],
1104
- [_.STYLED, k("span", !0)],
1105
- [_.BOLD, k("strong")],
1106
- [_.TEXT_STYLE, k("span", !0)],
1107
- [_.ITALIC, k("em")],
1108
- [_.UNDERLINE, k("u")],
1109
- [_.STRIKE, k("s")],
1110
- [_.CODE, k("code")],
1111
- [_.SUPERSCRIPT, k("sup")],
1112
- [_.SUBSCRIPT, k("sub")],
1113
- [_.HIGHLIGHT, k("mark")],
1114
- [v.TABLE, K],
1115
- [v.TABLE_ROW, Y],
1116
- [v.TABLE_CELL, W],
1117
- [v.TABLE_HEADER, X],
1118
- ...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])
1119
1124
  ]);
1120
- function x(c) {
1121
- e += 1;
1122
- const u = Q.get(c.type);
1123
- if (!u)
1125
+ function I(c) {
1126
+ const d = ee.get(c.type);
1127
+ if (!d)
1124
1128
  return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
1129
+ const g = i();
1125
1130
  if (c.type === "text")
1126
- return u(c);
1131
+ return d(c, g);
1127
1132
  const f = c.content ? c.content.map(P) : void 0;
1128
- return u({
1133
+ return d({
1129
1134
  ...c,
1130
1135
  children: f
1131
- // Fix: Update the type of 'children' to Node[]
1132
- });
1136
+ }, g);
1133
1137
  }
1134
1138
  function P(c) {
1135
- 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);
1136
1140
  }
1137
1141
  return {
1138
1142
  render: P
1139
1143
  };
1140
1144
  }
1141
1145
  let H, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1142
- const Ge = (n, e, t = {}) => {
1143
- var r;
1144
- const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = 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(
1145
1149
  "_storyblok"
1146
- ), a = o !== null && +o === n;
1147
- if (!(!s || !a)) {
1148
- if (!n) {
1150
+ ), l = o !== null && +o === r;
1151
+ if (!(!s || !l)) {
1152
+ if (!r) {
1149
1153
  console.warn("Story ID is not defined. Please provide a valid ID.");
1150
1154
  return;
1151
1155
  }
1152
1156
  window.storyblokRegisterEvent(() => {
1153
- new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
1157
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (a) => {
1154
1158
  var i;
1155
- 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());
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());
1156
1160
  });
1157
1161
  });
1158
1162
  }
1159
- }, V = (n, e) => {
1160
- n.addNode("blok", (t) => {
1161
- let r = "";
1163
+ }, J = (r, e) => {
1164
+ r.addNode("blok", (t) => {
1165
+ let n = "";
1162
1166
  return t.attrs.body.forEach((s) => {
1163
- r += e(s.component, s);
1167
+ n += e(s.component, s);
1164
1168
  }), {
1165
- html: r
1169
+ html: n
1166
1170
  };
1167
1171
  });
1168
- }, Ve = (n = {}) => {
1172
+ }, Ke = (r = {}) => {
1169
1173
  var e, t;
1170
1174
  const {
1171
- bridge: r,
1175
+ bridge: n,
1172
1176
  accessToken: s,
1173
1177
  use: o = [],
1174
- apiOptions: a = {},
1175
- richText: l = {},
1178
+ apiOptions: l = {},
1179
+ richText: a = {},
1176
1180
  bridgeUrl: i
1177
- } = n;
1178
- a.accessToken = a.accessToken || s;
1179
- const h = { bridge: r, apiOptions: a };
1180
- let d = {};
1181
+ } = r;
1182
+ l.accessToken = l.accessToken || s;
1183
+ const h = { bridge: n, apiOptions: l };
1184
+ let u = {};
1181
1185
  o.forEach((b) => {
1182
- d = { ...d, ...b(h) };
1186
+ u = { ...u, ...b(h) };
1183
1187
  }), i && (M = i);
1184
1188
  const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
1185
- return r !== !1 && p && F(M), H = new C(l.schema), l.resolver && V(H, l.resolver), d;
1186
- }, ze = (n) => {
1189
+ return n !== !1 && p && G(M), H = new C(a.schema), a.resolver && J(H, a.resolver), u;
1190
+ }, qe = (r) => {
1187
1191
  var e;
1188
- return !n || !((e = n == null ? void 0 : n.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
1189
- }, Je = (n, e, t) => {
1190
- let r = t || H;
1191
- 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) {
1192
1196
  console.error(
1193
1197
  "Please initialize the Storyblok SDK before calling the renderRichText function"
1194
1198
  );
1195
1199
  return;
1196
1200
  }
1197
- return ze(n) ? "" : (e && (r = new C(e.schema), e.resolver && V(r, e.resolver)), r.render(n, {}, !1));
1198
- }, 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);
1199
1203
  export {
1200
- v as BlockTypes,
1201
- _ as MarkTypes,
1204
+ k as BlockTypes,
1205
+ E as MarkTypes,
1202
1206
  C as RichTextResolver,
1203
- Oe as RichTextSchema,
1204
- G as TextTypes,
1205
- De as apiPlugin,
1206
- ze as isRichTextEmpty,
1207
- Ke as loadStoryblokBridge,
1208
- Ge as registerStoryblokBridge,
1209
- Je as renderRichText,
1210
- Fe as richTextResolver,
1211
- qe as storyblokEditable,
1212
- Ve as storyblokInit,
1213
- 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
1214
1218
  };