@storyblok/vue 8.1.4 → 8.1.6

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