@storyblok/vue 8.1.7 → 8.1.9

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