@storyblok/vue 8.2.0 → 8.2.2

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