@storyblok/vue 8.1.6 → 8.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,80 +1,87 @@
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";
1
+ /**
2
+ * name: @storyblok/vue
3
+ * (c) 2024
4
+ * description: SDK to integrate Storyblok into your project using Vue.
5
+ * author: Storyblok
6
+ */
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";
2
8
  let D = !1;
3
- const z = [], he = (r) => new Promise((e, t) => {
9
+ const z = [], de = (s) => new Promise((e, t) => {
4
10
  if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
5
11
  if (window.location === window.parent.location) {
6
12
  console.warn("You are not in Draft Mode or in the Visual Editor.");
7
13
  return;
8
14
  }
9
15
  D ? o() : z.push(o);
10
- }, document.getElementById("storyblok-javascript-bridge"))) return;
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) => {
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) => {
13
20
  z.forEach((n) => n()), D = !0, e(o);
14
- }, document.getElementsByTagName("head")[0].appendChild(s);
21
+ }, document.getElementsByTagName("head")[0].appendChild(r);
15
22
  });
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 {
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 {
18
25
  constructor(e) {
19
26
  super(e), this.name = "AbortError";
20
27
  }
21
28
  }
22
- function ge(r, e, t) {
29
+ function fe(s, e, t) {
23
30
  if (!Number.isFinite(e))
24
31
  throw new TypeError("Expected `limit` to be a finite number");
25
32
  if (!Number.isFinite(t))
26
33
  throw new TypeError("Expected `interval` to be a finite number");
27
- const s = [];
34
+ const r = [];
28
35
  let o = [], n = 0, i = !1;
29
- const a = async () => {
36
+ const l = async () => {
30
37
  n++;
31
- const h = s.shift();
38
+ const h = r.shift();
32
39
  if (h)
33
40
  try {
34
- const d = await r(...h.args);
41
+ const d = await s(...h.args);
35
42
  h.resolve(d);
36
43
  } catch (d) {
37
44
  h.reject(d);
38
45
  }
39
46
  const u = setTimeout(() => {
40
- n--, s.length > 0 && a(), o = o.filter((d) => d !== u);
47
+ n--, r.length > 0 && l(), o = o.filter((d) => d !== u);
41
48
  }, t);
42
49
  o.includes(u) || o.push(u);
43
- }, l = (...h) => i ? Promise.reject(
50
+ }, a = (...h) => i ? Promise.reject(
44
51
  new Error(
45
52
  "Throttled function is already aborted and not accepting new promises"
46
53
  )
47
54
  ) : new Promise((u, d) => {
48
- s.push({
55
+ r.push({
49
56
  resolve: u,
50
57
  reject: d,
51
58
  args: h
52
- }), n < e && a();
59
+ }), n < e && l();
53
60
  });
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;
58
- }, 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;
59
66
  }
60
- let A = class {
67
+ class L {
61
68
  constructor() {
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 = {
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 = {
71
78
  "&": "&amp;",
72
79
  "<": "&lt;",
73
80
  ">": "&gt;",
74
81
  '"': "&quot;",
75
82
  "'": "&#39;"
76
- }, t = /[&<>"']/g, s = new RegExp(t.source);
77
- 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;
78
85
  });
79
86
  }
80
87
  /**
@@ -84,110 +91,110 @@ let A = class {
84
91
  * @param {boolean} isArray
85
92
  * @return {string} Stringified object
86
93
  */
87
- stringify(r, e, t) {
88
- const s = [];
89
- for (const o in r) {
90
- 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))
91
98
  continue;
92
- const n = r[o], i = t ? "" : encodeURIComponent(o);
99
+ const i = e[n], l = r ? "" : encodeURIComponent(n);
93
100
  let 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);
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);
99
106
  }
100
- return s.join("&");
107
+ return o.join("&");
101
108
  }
102
109
  /**
103
110
  * @method getRegionURL
104
111
  * @param {string} regionCode region code, could be eu, us, cn, ap or ca
105
112
  * @return {string} The base URL of the region
106
113
  */
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) {
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) {
110
117
  case "us":
111
- return t;
118
+ return r;
112
119
  case "cn":
113
- return s;
114
- case "ap":
115
120
  return o;
116
- case "ca":
121
+ case "ap":
117
122
  return n;
123
+ case "ca":
124
+ return i;
118
125
  default:
119
- return e;
126
+ return t;
120
127
  }
121
128
  }
122
- };
123
- const me = function(r, e) {
129
+ }
130
+ const ye = function(s, e) {
124
131
  const t = {};
125
- for (const s in r) {
126
- const o = r[s];
127
- 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);
128
135
  }
129
136
  return t;
130
- }, fe = (r) => r === "email", ye = () => ({
137
+ }, be = (s) => s === "email", ke = () => ({
131
138
  singleTag: "hr"
132
- }), be = () => ({
139
+ }), ve = () => ({
133
140
  tag: "blockquote"
134
- }), ke = () => ({
141
+ }), $e = () => ({
135
142
  tag: "ul"
136
- }), ve = (r) => ({
143
+ }), Te = (s) => ({
137
144
  tag: [
138
145
  "pre",
139
146
  {
140
147
  tag: "code",
141
- attrs: r.attrs
148
+ attrs: s.attrs
142
149
  }
143
150
  ]
144
- }), $e = () => ({
151
+ }), we = () => ({
145
152
  singleTag: "br"
146
- }), Te = (r) => ({
147
- tag: `h${r.attrs.level}`
148
- }), we = (r) => ({
153
+ }), Re = (s) => ({
154
+ tag: `h${s.attrs.level}`
155
+ }), _e = (s) => ({
149
156
  singleTag: [
150
157
  {
151
158
  tag: "img",
152
- attrs: me(r.attrs, ["src", "alt", "title"])
159
+ attrs: ye(s.attrs, ["src", "alt", "title"])
153
160
  }
154
161
  ]
155
- }), Re = () => ({
156
- tag: "li"
157
162
  }), Se = () => ({
163
+ tag: "li"
164
+ }), Ee = () => ({
158
165
  tag: "ol"
159
- }), _e = () => ({
166
+ }), je = () => ({
160
167
  tag: "p"
161
- }), Ee = (r) => ({
168
+ }), Ie = (s) => ({
162
169
  tag: [
163
170
  {
164
171
  tag: "span",
165
172
  attrs: {
166
173
  "data-type": "emoji",
167
- "data-name": r.attrs.name,
168
- emoji: r.attrs.emoji
174
+ "data-name": s.attrs.name,
175
+ emoji: s.attrs.emoji
169
176
  }
170
177
  }
171
178
  ]
172
- }), je = () => ({
179
+ }), xe = () => ({
173
180
  tag: "b"
174
- }), Ie = () => ({
181
+ }), Ae = () => ({
175
182
  tag: "s"
176
- }), xe = () => ({
177
- tag: "u"
178
183
  }), Ce = () => ({
179
- tag: "strong"
184
+ tag: "u"
180
185
  }), Oe = () => ({
186
+ tag: "strong"
187
+ }), Le = () => ({
181
188
  tag: "code"
182
- }), Ae = () => ({
189
+ }), Pe = () => ({
183
190
  tag: "i"
184
- }), Le = (r) => {
185
- if (!r.attrs)
191
+ }), Ne = (s) => {
192
+ if (!s.attrs)
186
193
  return {
187
194
  tag: ""
188
195
  };
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) {
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) {
191
198
  for (const o in t.custom)
192
199
  t[o] = t.custom[o];
193
200
  delete t.custom;
@@ -200,95 +207,95 @@ const me = function(r, e) {
200
207
  }
201
208
  ]
202
209
  };
203
- }, Pe = (r) => ({
210
+ }, Me = (s) => ({
204
211
  tag: [
205
212
  {
206
213
  tag: "span",
207
- attrs: r.attrs
214
+ attrs: s.attrs
208
215
  }
209
216
  ]
210
- }), Ne = () => ({
217
+ }), He = () => ({
211
218
  tag: "sub"
212
- }), Me = () => ({
219
+ }), Ue = () => ({
213
220
  tag: "sup"
214
- }), He = (r) => ({
221
+ }), De = (s) => ({
215
222
  tag: [
216
223
  {
217
224
  tag: "span",
218
- attrs: r.attrs
225
+ attrs: s.attrs
219
226
  }
220
227
  ]
221
- }), Ue = (r) => {
228
+ }), ze = (s) => {
222
229
  var e;
223
- return (e = r.attrs) != null && e.color ? {
230
+ return (e = s.attrs) != null && e.color ? {
224
231
  tag: [
225
232
  {
226
233
  tag: "span",
227
234
  attrs: {
228
- style: `background-color:${r.attrs.color};`
235
+ style: `background-color:${s.attrs.color};`
229
236
  }
230
237
  }
231
238
  ]
232
239
  } : {
233
240
  tag: ""
234
241
  };
235
- }, De = (r) => {
242
+ }, Fe = (s) => {
236
243
  var e;
237
- return (e = r.attrs) != null && e.color ? {
244
+ return (e = s.attrs) != null && e.color ? {
238
245
  tag: [
239
246
  {
240
247
  tag: "span",
241
248
  attrs: {
242
- style: `color:${r.attrs.color}`
249
+ style: `color:${s.attrs.color}`
243
250
  }
244
251
  }
245
252
  ]
246
253
  } : {
247
254
  tag: ""
248
255
  };
249
- }, ze = {
256
+ }, Be = {
250
257
  nodes: {
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
+ 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
262
269
  },
263
270
  marks: {
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) {
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) {
279
286
  const e = {
280
287
  "&": "&amp;",
281
288
  "<": "&lt;",
282
289
  ">": "&gt;",
283
290
  '"': "&quot;",
284
291
  "'": "&#39;"
285
- }, t = /[&<>"']/g, s = new RegExp(t.source);
286
- 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;
287
294
  };
288
- let B = !1;
289
- class qe {
295
+ let F = !1;
296
+ class Ve {
290
297
  constructor(e) {
291
- 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 || [];
292
299
  }
293
300
  addNode(e, t) {
294
301
  this.nodes[e] = t;
@@ -296,10 +303,10 @@ class qe {
296
303
  addMark(e, t) {
297
304
  this.marks[e] = t;
298
305
  }
299
- render(e, t = { optimizeImages: !1 }, s = !0) {
300
- if (!B && s && (console.warn(
306
+ render(e, t = { optimizeImages: !1 }, r = !0) {
307
+ if (!F && r && (console.warn(
301
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/"
302
- ), B = !0), e && e.content && Array.isArray(e.content)) {
309
+ ), F = !0), e && e.content && Array.isArray(e.content)) {
303
310
  let o = "";
304
311
  return e.content.forEach((n) => {
305
312
  o += this.renderNode(n);
@@ -333,34 +340,34 @@ class qe {
333
340
  ), "";
334
341
  }
335
342
  optimizeImages(e, t) {
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}` : "";
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}` : "";
339
346
  return e = e.replace(
340
347
  /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) => {
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) => {
343
350
  var h, u;
344
- const d = l.match(
351
+ const d = a.match(
345
352
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
346
353
  );
347
354
  if (d && d.length > 0) {
348
- const g = {
355
+ const f = {
349
356
  srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
350
357
  if (typeof y == "number")
351
358
  return `//${d}/m/${y}x0${i} ${y}w`;
352
359
  if (typeof y == "object" && y.length === 2) {
353
- let w = 0, x = 0;
354
- 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`;
355
362
  }
356
363
  return "";
357
364
  }).join(", "),
358
365
  sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
359
366
  };
360
- let R = "";
361
- 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()}`);
362
369
  }
363
- return l;
370
+ return a;
364
371
  })), e;
365
372
  }
366
373
  renderNode(e) {
@@ -369,24 +376,24 @@ class qe {
369
376
  const n = this.getMatchingMark(o);
370
377
  n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
371
378
  });
372
- const s = this.getMatchingNode(e);
373
- 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) => {
374
381
  t.push(this.renderNode(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) => {
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) => {
376
383
  const n = this.getMatchingMark(o);
377
384
  n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
378
385
  }), t.join("");
379
386
  }
380
387
  renderTag(e, t) {
381
- return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
382
- if (s.constructor === String)
383
- return `<${s}${t}>`;
388
+ return e.constructor === String ? `<${e}${t}>` : e.map((r) => {
389
+ if (r.constructor === String)
390
+ return `<${r}${t}>`;
384
391
  {
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];
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];
390
397
  i !== null && (o += ` ${n}="${i}"`);
391
398
  }
392
399
  }
@@ -427,8 +434,8 @@ class qe {
427
434
  return this.renderTag(t, " /");
428
435
  }
429
436
  }
430
- const L = qe;
431
- class Fe {
437
+ const P = Ve;
438
+ class Ge {
432
439
  constructor(e) {
433
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 = {};
434
441
  }
@@ -448,50 +455,50 @@ class Fe {
448
455
  return this.url = e, this.parameters = t, this._methodHandler("put");
449
456
  }
450
457
  delete(e, t) {
451
- return this.url = e, this.parameters = t, this._methodHandler("delete");
458
+ return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
452
459
  }
453
460
  async _responseHandler(e) {
454
- const t = [], s = {
461
+ const t = [], r = {
455
462
  data: {},
456
463
  headers: {},
457
464
  status: 0,
458
465
  statusText: ""
459
466
  };
460
467
  e.status !== 204 && await e.json().then((o) => {
461
- s.data = o;
468
+ r.data = o;
462
469
  });
463
470
  for (const o of e.headers.entries())
464
471
  t[o[0]] = o[1];
465
- 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;
466
473
  }
467
474
  async _methodHandler(e) {
468
- let t = `${this.baseURL}${this.url}`, s = null;
475
+ let t = `${this.baseURL}${this.url}`, r = null;
469
476
  if (e === "get") {
470
- const l = new A();
471
- t = `${this.baseURL}${this.url}?${l.stringify(
477
+ const a = new L();
478
+ t = `${this.baseURL}${this.url}?${a.stringify(
472
479
  this.parameters
473
480
  )}`;
474
481
  } else
475
- s = JSON.stringify(this.parameters);
482
+ r = JSON.stringify(this.parameters);
476
483
  const o = new URL(t), n = new AbortController(), { signal: i } = n;
477
- let a;
478
- this.timeout && (a = setTimeout(() => n.abort(), this.timeout));
484
+ let l;
485
+ this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
479
486
  try {
480
- const l = await this.fetch(`${o}`, {
487
+ const a = await this.fetch(`${o}`, {
481
488
  method: e,
482
489
  headers: this.headers,
483
- body: s,
490
+ body: r,
484
491
  signal: i,
485
492
  ...this.fetchOptions
486
493
  });
487
- this.timeout && clearTimeout(a);
494
+ this.timeout && clearTimeout(l);
488
495
  const h = await this._responseHandler(
489
- l
496
+ a
490
497
  );
491
498
  return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
492
- } catch (l) {
499
+ } catch (a) {
493
500
  return {
494
- message: l
501
+ message: a
495
502
  };
496
503
  }
497
504
  }
@@ -503,9 +510,9 @@ class Fe {
503
510
  }
504
511
  _statusHandler(e) {
505
512
  const t = /20[0-6]/g;
506
- return new Promise((s, o) => {
513
+ return new Promise((r, o) => {
507
514
  if (t.test(`${e.status}`))
508
- return s(e);
515
+ return r(e);
509
516
  const n = {
510
517
  message: e.statusText,
511
518
  status: e.status,
@@ -515,14 +522,14 @@ class Fe {
515
522
  });
516
523
  }
517
524
  }
518
- const Ve = Fe, q = "SB-Agent", M = {
525
+ const Ke = Ge, B = "SB-Agent", H = {
519
526
  defaultAgentName: "SB-JS-CLIENT",
520
527
  defaultAgentVersion: "SB-Agent-Version",
521
528
  packageVersion: "6.0.0"
522
529
  };
523
530
  let C = {};
524
531
  const E = {};
525
- class Ge {
532
+ class Je {
526
533
  /**
527
534
  *
528
535
  * @param config ISbConfig interface
@@ -530,25 +537,25 @@ class Ge {
530
537
  */
531
538
  constructor(e, t) {
532
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");
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`;
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`;
537
544
  }
538
545
  const o = new Headers();
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
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
544
551
  ));
545
552
  let n = 5;
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(
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(
547
554
  this.throttledRequest.bind(this),
548
555
  n,
549
556
  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,
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,
552
559
  timeout: e.timeout || 0,
553
560
  headers: o,
554
561
  responseInterceptor: e.responseInterceptor,
@@ -557,11 +564,11 @@ class Ge {
557
564
  }
558
565
  setComponentResolver(e) {
559
566
  this.richTextResolver.addNode("blok", (t) => {
560
- let s = "";
567
+ let r = "";
561
568
  return t.attrs.body && t.attrs.body.forEach((o) => {
562
- s += e(o.component, o);
569
+ r += e(o.component, o);
563
570
  }), {
564
- html: s
571
+ html: r
565
572
  };
566
573
  });
567
574
  }
@@ -571,54 +578,55 @@ class Ge {
571
578
  factoryParamOptions(e, t) {
572
579
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
573
580
  }
574
- makeRequest(e, t, s, o, n) {
581
+ makeRequest(e, t, r, o, n) {
575
582
  const i = this.factoryParamOptions(
576
583
  e,
577
- this.helpers.getOptionsPage(t, s, o)
584
+ this.helpers.getOptionsPage(t, r, o)
578
585
  );
579
586
  return this.cacheResponse(e, i, void 0, n);
580
587
  }
581
- get(e, t, s) {
588
+ get(e, t, r) {
582
589
  t || (t = {});
583
590
  const o = `/${e}`, n = this.factoryParamOptions(o, t);
584
- return this.cacheResponse(o, n, void 0, s);
591
+ return this.cacheResponse(o, n, void 0, r);
585
592
  }
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(
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(
588
595
  i,
589
596
  t,
590
597
  n,
591
- l,
598
+ a,
592
599
  o
593
600
  ), 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)
601
+ this.helpers.range(a, u),
602
+ (f) => this.makeRequest(i, t, n, f + 1, o)
596
603
  );
597
- 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]));
598
605
  }
599
- post(e, t, s) {
606
+ post(e, t, r) {
600
607
  const o = `/${e}`;
601
608
  return Promise.resolve(
602
- this.throttle("post", o, t, s)
609
+ this.throttle("post", o, t, r)
603
610
  );
604
611
  }
605
- put(e, t, s) {
612
+ put(e, t, r) {
606
613
  const o = `/${e}`;
607
614
  return Promise.resolve(
608
- this.throttle("put", o, t, s)
615
+ this.throttle("put", o, t, r)
609
616
  );
610
617
  }
611
- delete(e, t, s) {
618
+ delete(e, t, r) {
619
+ t || (t = {});
612
620
  const o = `/${e}`;
613
621
  return Promise.resolve(
614
- this.throttle("delete", o, t, s)
622
+ this.throttle("delete", o, t, r)
615
623
  );
616
624
  }
617
625
  getStories(e, t) {
618
626
  return this._addResolveLevel(e), this.get("cdn/stories", e, t);
619
627
  }
620
- getStory(e, t, s) {
621
- 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);
622
630
  }
623
631
  getToken() {
624
632
  return this.accessToken;
@@ -632,9 +640,9 @@ class Ge {
632
640
  _cleanCopy(e) {
633
641
  return JSON.parse(JSON.stringify(e));
634
642
  }
635
- _insertLinks(e, t, s) {
643
+ _insertLinks(e, t, r) {
636
644
  const o = e[t];
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]));
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]));
638
646
  }
639
647
  /**
640
648
  *
@@ -643,52 +651,83 @@ class Ge {
643
651
  * @returns string | object
644
652
  */
645
653
  getStoryReference(e, t) {
646
- return this.relations[e][t] ? (this.stringifiedStoriesCache[t] || (this.stringifiedStoriesCache[t] = JSON.stringify(
647
- this.relations[e][t]
648
- )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
649
- }
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)));
652
- }
653
- iterateTree(e, t, s) {
654
- const o = (n) => {
655
- if (n != null) {
656
- if (n.constructor === Array)
657
- for (let i = 0; i < n.length; i++)
658
- o(n[i]);
659
- else if (n.constructor === Object) {
660
- if (n._stopResolving)
661
- return;
662
- for (const i in n)
663
- (n.component && n._uid || n.type === "link") && (this._insertRelations(
664
- n,
665
- i,
666
- t,
667
- s
668
- ), this._insertLinks(
669
- n,
670
- i,
671
- s
672
- )), o(n[i]);
673
- }
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
+ }
674
713
  }
675
714
  };
676
715
  o(e.content);
677
716
  }
678
- async resolveLinks(e, t, s) {
717
+ async resolveLinks(e, t, r) {
679
718
  let o = [];
680
719
  if (e.link_uuids) {
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));
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));
685
724
  }
686
- for (let l = 0; l < i.length; l++)
725
+ for (let a = 0; a < i.length; a++)
687
726
  (await this.getStories({
688
- per_page: a,
727
+ per_page: l,
689
728
  language: t.language,
690
729
  version: t.version,
691
- by_uuids: i[l].join(",")
730
+ by_uuids: i[a].join(",")
692
731
  })).data.stories.forEach(
693
732
  (h) => {
694
733
  o.push(h);
@@ -697,26 +736,26 @@ class Ge {
697
736
  } else
698
737
  o = e.links;
699
738
  o.forEach((n) => {
700
- this.links[s][n.uuid] = {
739
+ this.links[r][n.uuid] = {
701
740
  ...n,
702
741
  _stopResolving: !0
703
742
  };
704
743
  });
705
744
  }
706
- async resolveRelations(e, t, s) {
745
+ async resolveRelations(e, t, r) {
707
746
  let o = [];
708
747
  if (e.rel_uuids) {
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));
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));
713
752
  }
714
- for (let l = 0; l < i.length; l++)
753
+ for (let a = 0; a < i.length; a++)
715
754
  (await this.getStories({
716
- per_page: a,
755
+ per_page: l,
717
756
  language: t.language,
718
757
  version: t.version,
719
- by_uuids: i[l].join(","),
758
+ by_uuids: i[a].join(","),
720
759
  excluding_fields: t.excluding_fields
721
760
  })).data.stories.forEach((h) => {
722
761
  o.push(h);
@@ -724,7 +763,7 @@ class Ge {
724
763
  } else
725
764
  o = e.rels;
726
765
  o && o.length > 0 && o.forEach((n) => {
727
- this.relations[s][n.uuid] = {
766
+ this.relations[r][n.uuid] = {
728
767
  ...n,
729
768
  _stopResolving: !0
730
769
  };
@@ -739,28 +778,28 @@ class Ge {
739
778
  * @returns Promise<void>
740
779
  *
741
780
  */
742
- async resolveStories(e, t, s) {
781
+ async resolveStories(e, t, r) {
743
782
  var o, n;
744
783
  let i = [];
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])
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])
747
786
  this.iterateTree(
748
- this.relations[s][a],
787
+ this.relations[r][l],
749
788
  i,
750
- s
789
+ r
751
790
  );
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];
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];
755
794
  }
756
- async cacheResponse(e, t, s, o) {
795
+ async cacheResponse(e, t, r, o) {
757
796
  const n = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
758
797
  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);
798
+ const l = await i.get(n);
799
+ if (l)
800
+ return Promise.resolve(l);
762
801
  }
763
- return new Promise(async (a, l) => {
802
+ return new Promise(async (l, a) => {
764
803
  var h;
765
804
  try {
766
805
  const u = await this.throttle(
@@ -770,27 +809,27 @@ class Ge {
770
809
  o
771
810
  );
772
811
  if (u.status !== 200)
773
- return l(u);
812
+ return a(u);
774
813
  let d = { data: u.data, headers: u.headers };
775
814
  if ((h = u.headers) != null && h["per-page"] && (d = Object.assign({}, d, {
776
815
  perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
777
816
  total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
778
817
  })), d.data.story || d.data.stories) {
779
- const g = this.resolveCounter = ++this.resolveCounter % 1e3;
780
- await this.resolveStories(d.data, t, `${g}`);
818
+ const f = this.resolveCounter = ++this.resolveCounter % 1e3;
819
+ await this.resolveStories(d.data, t, `${f}`);
781
820
  }
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);
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);
783
822
  } catch (u) {
784
- 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))
785
824
  return console.log(
786
825
  `Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
787
- ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(a).catch(l);
788
- l(u);
826
+ ), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, r).then(l).catch(a);
827
+ a(u);
789
828
  }
790
829
  });
791
830
  }
792
- throttledRequest(e, t, s, o) {
793
- 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);
794
833
  }
795
834
  cacheVersions() {
796
835
  return E;
@@ -845,63 +884,63 @@ class Ge {
845
884
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
846
885
  }
847
886
  }
848
- const ct = (r = {}) => {
849
- const { apiOptions: e } = r;
850
- if (!e.accessToken) {
887
+ const ht = (s = {}) => {
888
+ const { apiOptions: e } = s;
889
+ if (!e || !e.accessToken) {
851
890
  console.error(
852
891
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
853
892
  );
854
893
  return;
855
894
  }
856
- return { storyblokApi: new Ge(e) };
857
- }, Ke = (r) => {
858
- 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")
859
898
  return {};
860
899
  try {
861
900
  const e = JSON.parse(
862
- r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
901
+ s._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
863
902
  );
864
903
  return e ? {
865
904
  "data-blok-c": JSON.stringify(e),
866
- "data-blok-uid": e.id + "-" + e.uid
905
+ "data-blok-uid": `${e.id}-${e.uid}`
867
906
  } : {};
868
907
  } catch {
869
908
  return {};
870
909
  }
871
910
  };
872
- function Je(r, e) {
911
+ function We(s, e) {
873
912
  if (!e)
874
- return { src: r, attrs: {} };
875
- let t = 0, s = 0;
913
+ return { src: s, attrs: {} };
914
+ let t = 0, r = 0;
876
915
  const o = {}, n = [];
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})`);
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})`);
879
918
  }
880
919
  if (typeof e == "object") {
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})`);
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})`);
884
923
  }
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`;
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`;
891
930
  } else {
892
931
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
893
932
  return;
894
933
  }
895
934
  }).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
896
935
  }
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,
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,
900
939
  attrs: o
901
940
  };
902
941
  }
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 = [
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 = [
905
944
  "area",
906
945
  "base",
907
946
  "br",
@@ -916,265 +955,277 @@ const Ye = [
916
955
  "source",
917
956
  "track",
918
957
  "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;");
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;");
922
961
  }
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}>`;
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}>`;
927
970
  }
928
- function et(r = {}) {
971
+ function tt(s = {}) {
929
972
  let e = 0;
930
973
  const {
931
- renderFn: t = Ze,
932
- textFn: s = Qe,
974
+ renderFn: t = V,
975
+ textFn: r = et,
933
976
  resolvers: o = {},
934
977
  optimizeImages: n = !1,
935
978
  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, _ = {};
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 = {};
942
985
  if (n) {
943
- const { src: re, attrs: se } = Je(m, n);
944
- S = re, _ = se;
986
+ const { src: oe, attrs: ne } = We(g, n);
987
+ w = oe, S = ne;
945
988
  }
946
- i && (_ = {
947
- ..._,
989
+ i && (S = {
990
+ ...S,
948
991
  key: `img-${e}`
949
992
  });
950
- const te = {
951
- src: S,
952
- alt: f,
953
- title: b,
954
- srcset: T,
993
+ const se = {
994
+ src: w,
995
+ alt: m,
996
+ title: k,
997
+ srcset: R,
955
998
  sizes: $,
956
- ..._
999
+ ...S
957
1000
  };
958
- return t("img", F(te));
959
- }, h = (c) => {
960
- const { level: m, ...f } = c.attrs || {}, b = {
961
- ...f
962
- };
963
- return i && (b.key = `h${m}-${e}`), t(`h${m}`, b, c.children);
1001
+ return t("img", q(se));
964
1002
  }, u = (c) => {
965
- 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;
966
1009
  const $ = t("img", {
967
- src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
968
- 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,
969
1012
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
970
1013
  draggable: "false",
971
1014
  loading: "lazy"
972
- }), S = {
1015
+ }), w = {
973
1016
  "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
1017
+ "data-name": (k = c.attrs) == null ? void 0 : k.name,
1018
+ "data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
976
1019
  };
977
- return i && (S.key = `emoji-${e}`), t("span", S, $);
978
- }, d = (c) => t("pre", {
1020
+ return i && (w.key = `emoji-${e}`), t("span", w, $);
1021
+ }, f = (c) => t("pre", {
979
1022
  ...c.attrs,
980
1023
  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,
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,
984
1027
  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 }),
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 }),
992
1035
  // Fix: Ensure render function returns a string
993
- R({ ...f, children: f.children })
1036
+ y({ ...m, children: m.children })
994
1037
  // Fix: Cast children to string
995
- ) : s(f.text) : "";
996
- }, w = (c) => {
997
- 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 || {};
998
1041
  let $ = "";
999
- switch (m) {
1000
- case j.ASSET:
1001
- case j.URL:
1002
- $ = f;
1042
+ switch (g) {
1043
+ case I.ASSET:
1044
+ case I.URL:
1045
+ $ = m;
1003
1046
  break;
1004
- case j.EMAIL:
1005
- $ = `mailto:${f}`;
1047
+ case I.EMAIL:
1048
+ $ = `mailto:${m}`;
1006
1049
  break;
1007
- case j.STORY:
1008
- $ = f;
1050
+ case I.STORY:
1051
+ $ = m, k && ($ = `${$}#${k}`);
1052
+ break;
1053
+ default:
1054
+ $ = m;
1009
1055
  break;
1010
1056
  }
1011
- return b && ($ = `${$}#${b}`), t("a", { ...T, href: $, key: `a-${e}` }, c.text);
1012
- }, x = (c) => {
1013
- 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;
1014
1061
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
1015
- blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
1016
- 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,
1017
1064
  key: `component-${e}`,
1018
1065
  style: "display: none"
1019
1066
  });
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])
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])
1048
1095
  ]);
1049
- function U(c) {
1096
+ function A(c) {
1050
1097
  e += 1;
1051
- const m = ee.get(c.type);
1052
- if (!m)
1098
+ const g = re.get(c.type);
1099
+ if (!g)
1053
1100
  return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
1054
1101
  if (c.type === "text")
1055
- return m(c);
1056
- const f = c.content ? c.content.map(P) : void 0;
1057
- return m({
1102
+ return g(c);
1103
+ const m = c.content ? c.content.map(N) : void 0;
1104
+ return g({
1058
1105
  ...c,
1059
- children: f
1106
+ children: m
1060
1107
  // Fix: Update the type of 'children' to Node[]
1061
1108
  });
1062
1109
  }
1063
- function P(c) {
1064
- 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);
1065
1112
  }
1066
1113
  return {
1067
- render: P
1114
+ render: N
1068
1115
  };
1069
1116
  }
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(
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(
1074
1121
  "_storyblok"
1075
- ) === r;
1076
- if (!(!o || !n)) {
1077
- if (!r) {
1122
+ ), i = n !== null && +n === s;
1123
+ if (!(!o || !i)) {
1124
+ if (!s) {
1078
1125
  console.warn("Story ID is not defined. Please provide a valid ID.");
1079
1126
  return;
1080
1127
  }
1081
1128
  window.storyblokRegisterEvent(() => {
1082
- new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
1083
- 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());
1084
1132
  });
1085
1133
  });
1086
1134
  }
1087
- }, 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 = {}) => {
1088
1145
  var e, t;
1089
1146
  const {
1090
- bridge: s,
1147
+ bridge: r,
1091
1148
  accessToken: o,
1092
1149
  use: n = [],
1093
1150
  apiOptions: i = {},
1094
- richText: a = {},
1095
- bridgeUrl: l
1096
- } = r;
1151
+ richText: l = {},
1152
+ bridgeUrl: a
1153
+ } = s;
1097
1154
  i.accessToken = i.accessToken || o;
1098
- const h = { bridge: s, apiOptions: i };
1155
+ const h = { bridge: r, apiOptions: i };
1099
1156
  let u = {};
1100
- n.forEach((g) => {
1101
- u = { ...u, ...g(h) };
1102
- }), l && (V = l);
1157
+ n.forEach((f) => {
1158
+ u = { ...u, ...f(h) };
1159
+ }), a && (G = a);
1103
1160
  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 = "";
1108
- return t.attrs.body.forEach((o) => {
1109
- s += e(o.component, o);
1110
- }), {
1111
- html: s
1112
- };
1113
- });
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) {
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) {
1117
1168
  console.error(
1118
1169
  "Please initialize the Storyblok SDK before calling the renderRichText function"
1119
1170
  );
1120
1171
  return;
1121
1172
  }
1122
- return st(r) ? "" : (e && (s = new L(e.schema), e.resolver && W(s, e.resolver)), s.render(r, {}, !1));
1123
- }, 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({
1124
1175
  __name: "StoryblokComponent",
1125
1176
  props: {
1126
1177
  blok: {}
1127
1178
  },
1128
- setup(r, { expose: e }) {
1129
- const t = r, s = O();
1179
+ setup(s, { expose: e }) {
1180
+ const t = s, r = O();
1130
1181
  e({
1131
- value: s
1182
+ value: r
1132
1183
  });
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(
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(
1135
1186
  `Is the Fallback component "${i.value}" registered properly?`
1136
1187
  )) : console.error(
1137
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});"?`
1138
- )), (a, l) => (K(), J(N(i.value), ne({
1189
+ )), (l, a) => (J(), Y(M(i.value), ae({
1139
1190
  ref_key: "blokRef",
1140
- ref: s
1141
- }, { ...a.$props, ...a.$attrs }), null, 16));
1191
+ ref: r
1192
+ }, { ...l.$props, ...l.$attrs }), null, 16));
1142
1193
  }
1143
- }), ot = (r) => {
1194
+ }), nt = (s) => {
1144
1195
  var e, t;
1145
- return Y(
1146
- Q,
1196
+ return W(
1197
+ Z,
1147
1198
  {
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
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
1150
1201
  },
1151
- r.children
1202
+ s.children
1152
1203
  );
1153
1204
  };
1154
- function nt(r) {
1205
+ function it(s) {
1155
1206
  const e = {
1156
- renderFn: Y,
1157
- textFn: ie,
1207
+ renderFn: W,
1208
+ textFn: le,
1158
1209
  keyedResolvers: !0,
1159
1210
  resolvers: {
1160
- [k.COMPONENT]: ot,
1161
- ...r.resolvers
1211
+ [v.COMPONENT]: nt,
1212
+ ...s.resolvers
1162
1213
  }
1163
1214
  };
1164
- return et(e);
1215
+ return tt(e);
1165
1216
  }
1166
- const it = /* @__PURE__ */ G({
1217
+ const at = /* @__PURE__ */ K({
1167
1218
  __name: "StoryblokRichText",
1168
1219
  props: {
1169
1220
  doc: {},
1170
1221
  resolvers: {}
1171
1222
  },
1172
- setup(r) {
1173
- const e = r, t = O(), s = () => t.value;
1174
- return ae(
1223
+ setup(s) {
1224
+ const e = s, t = O(), r = () => t.value;
1225
+ return ce(
1175
1226
  [e.doc, e.resolvers],
1176
1227
  ([o, n]) => {
1177
- const { render: i } = nt({
1228
+ const { render: i } = it({
1178
1229
  resolvers: n ?? {}
1179
1230
  });
1180
1231
  t.value = i(o);
@@ -1182,60 +1233,61 @@ const it = /* @__PURE__ */ G({
1182
1233
  {
1183
1234
  immediate: !0
1184
1235
  }
1185
- ), (o, n) => (K(), J(s));
1236
+ ), (o, n) => (J(), Y(r));
1186
1237
  }
1187
- }), at = {
1188
- beforeMount(r, e) {
1238
+ }), lt = {
1239
+ beforeMount(s, e) {
1189
1240
  if (e.value) {
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"));
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"));
1192
1243
  }
1193
1244
  }
1194
- }, Z = (r) => {
1195
- 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.
1196
1247
  `);
1197
1248
  };
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,
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,
1205
1256
  t
1206
1257
  );
1207
- }), I) {
1208
- const { data: o } = await I.get(
1209
- `cdn/stories/${r}`,
1258
+ }), x) {
1259
+ const { data: o } = await x.get(
1260
+ `cdn/stories/${s}`,
1210
1261
  e
1211
1262
  );
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(
1263
+ r.value = o.story;
1264
+ } else
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(
1218
1270
  "FallbackComponent",
1219
- ce(() => import("./FallbackComponent-C2j8Ky5h.mjs"))
1271
+ ue(() => import("./FallbackComponent-U_HRL08c.js"))
1220
1272
  );
1221
- const { storyblokApi: t } = rt(e);
1222
- I = t, r.provide("VueSDKOptions", e);
1273
+ const { storyblokApi: t } = st(e);
1274
+ x = t || null, s.provide("VueSDKOptions", e);
1223
1275
  }
1224
1276
  };
1225
1277
  export {
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,
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,
1233
1285
  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
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
1241
1293
  };