@storyblok/vue 8.0.5 → 8.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as A, ref as _, resolveDynamicComponent as $, inject as N, openBlock as L, createBlock as M, mergeProps as F, onMounted as z, defineAsyncComponent as U } from "vue";
2
2
  let j = !1;
3
- const x = [], H = (o) => new Promise((t, e) => {
3
+ const x = [], H = (i) => new Promise((e, t) => {
4
4
  if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
5
5
  if (window.location === window.parent.location) {
6
6
  console.warn("You are not in Draft Mode or in the Visual Editor.");
@@ -10,31 +10,31 @@ const x = [], H = (o) => new Promise((t, e) => {
10
10
  }, document.getElementById("storyblok-javascript-bridge")))
11
11
  return;
12
12
  const s = document.createElement("script");
13
- s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => e(r), s.onload = (r) => {
14
- x.forEach((n) => n()), j = !0, t(r);
13
+ s.async = !0, s.src = i, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
14
+ x.forEach((o) => o()), j = !0, e(r);
15
15
  }, document.getElementsByTagName("head")[0].appendChild(s);
16
16
  });
17
- var q = Object.defineProperty, V = (o, t, e) => t in o ? q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, h = (o, t, e) => (V(o, typeof t != "symbol" ? t + "" : t, e), e);
18
- function C(o) {
19
- return !(o !== o || o === 1 / 0 || o === -1 / 0);
17
+ var q = Object.defineProperty, V = (i, e, t) => e in i ? q(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, h = (i, e, t) => (V(i, typeof e != "symbol" ? e + "" : e, t), t);
18
+ function C(i) {
19
+ return !(i !== i || i === 1 / 0 || i === -1 / 0);
20
20
  }
21
- function D(o, t, e) {
22
- if (!C(t))
23
- throw new TypeError("Expected `limit` to be a finite number");
21
+ function D(i, e, t) {
24
22
  if (!C(e))
23
+ throw new TypeError("Expected `limit` to be a finite number");
24
+ if (!C(t))
25
25
  throw new TypeError("Expected `interval` to be a finite number");
26
26
  const s = [];
27
- let r = [], n = 0;
28
- const i = function() {
29
- n++;
27
+ let r = [], o = 0;
28
+ const n = function() {
29
+ o++;
30
30
  const a = setTimeout(function() {
31
- n--, s.length > 0 && i(), r = r.filter(function(u) {
31
+ o--, s.length > 0 && n(), r = r.filter(function(u) {
32
32
  return u !== a;
33
33
  });
34
- }, e);
34
+ }, t);
35
35
  r.indexOf(a) < 0 && r.push(a);
36
36
  const c = s.shift();
37
- c.resolve(o.apply(c.self, c.args));
37
+ c.resolve(i.apply(c.self, c.args));
38
38
  }, l = function(...a) {
39
39
  const c = this;
40
40
  return new Promise(function(u, p) {
@@ -43,7 +43,7 @@ function D(o, t, e) {
43
43
  reject: p,
44
44
  args: a,
45
45
  self: c
46
- }), n < t && i();
46
+ }), o < e && n();
47
47
  });
48
48
  };
49
49
  return l.abort = function() {
@@ -56,22 +56,22 @@ function D(o, t, e) {
56
56
  }
57
57
  class k {
58
58
  constructor() {
59
- h(this, "isCDNUrl", (t = "") => t.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (t, e = 25, s = 1) => ({
60
- ...t,
61
- per_page: e,
59
+ h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, s = 1) => ({
60
+ ...e,
61
+ per_page: t,
62
62
  page: s
63
- })), h(this, "delay", (t) => new Promise((e) => setTimeout(e, t))), h(this, "arrayFrom", (t = 0, e) => [...Array(t)].map(e)), h(this, "range", (t = 0, e = t) => {
64
- const s = Math.abs(e - t) || 0, r = t < e ? 1 : -1;
65
- return this.arrayFrom(s, (n, i) => i * r + t);
66
- }), h(this, "asyncMap", async (t, e) => Promise.all(t.map(e))), h(this, "flatMap", (t = [], e) => t.map(e).reduce((s, r) => [...s, ...r], [])), h(this, "escapeHTML", function(t) {
67
- const e = {
63
+ })), h(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), h(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), h(this, "range", (e = 0, t = e) => {
64
+ const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
65
+ return this.arrayFrom(s, (o, n) => n * r + e);
66
+ }), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), h(this, "escapeHTML", function(e) {
67
+ const t = {
68
68
  "&": "&amp;",
69
69
  "<": "&lt;",
70
70
  ">": "&gt;",
71
71
  '"': "&quot;",
72
72
  "'": "&#39;"
73
73
  }, s = /[&<>"']/g, r = RegExp(s.source);
74
- return t && r.test(t) ? t.replace(s, (n) => e[n]) : t;
74
+ return e && r.test(e) ? e.replace(s, (o) => t[o]) : e;
75
75
  });
76
76
  }
77
77
  /**
@@ -81,18 +81,18 @@ class k {
81
81
  * @param {Boolean} isArray
82
82
  * @return {String} Stringified object
83
83
  */
84
- stringify(t, e, s) {
84
+ stringify(e, t, s) {
85
85
  const r = [];
86
- for (const n in t) {
87
- if (!Object.prototype.hasOwnProperty.call(t, n))
86
+ for (const o in e) {
87
+ if (!Object.prototype.hasOwnProperty.call(e, o))
88
88
  continue;
89
- const i = t[n], l = s ? "" : encodeURIComponent(n);
89
+ const n = e[o], l = s ? "" : encodeURIComponent(o);
90
90
  let a;
91
- typeof i == "object" ? a = this.stringify(
92
- i,
93
- e ? e + encodeURIComponent("[" + l + "]") : l,
94
- Array.isArray(i)
95
- ) : a = (e ? e + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(i), r.push(a);
91
+ typeof n == "object" ? a = this.stringify(
92
+ n,
93
+ t ? t + encodeURIComponent("[" + l + "]") : l,
94
+ Array.isArray(n)
95
+ ) : a = (t ? t + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(n), r.push(a);
96
96
  }
97
97
  return r.join("&");
98
98
  }
@@ -101,149 +101,149 @@ class k {
101
101
  * @param {String} regionCode region code, could be eu, us, cn, ap or ca
102
102
  * @return {String} The base URL of the region
103
103
  */
104
- getRegionURL(t) {
105
- const e = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", n = "api-ap.storyblok.com", i = "api-ca.storyblok.com";
106
- switch (t) {
104
+ getRegionURL(e) {
105
+ const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", o = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
106
+ switch (e) {
107
107
  case "us":
108
108
  return s;
109
109
  case "cn":
110
110
  return r;
111
111
  case "ap":
112
- return n;
112
+ return o;
113
113
  case "ca":
114
- return i;
114
+ return n;
115
115
  default:
116
- return e;
116
+ return t;
117
117
  }
118
118
  }
119
119
  }
120
- const B = function(o, t) {
121
- const e = {};
122
- for (const s in o) {
123
- const r = o[s];
124
- t.indexOf(s) > -1 && r !== null && (e[s] = r);
125
- }
126
- return e;
127
- }, J = (o) => o === "email", K = () => ({
120
+ const B = function(i, e) {
121
+ const t = {};
122
+ for (const s in i) {
123
+ const r = i[s];
124
+ e.indexOf(s) > -1 && r !== null && (t[s] = r);
125
+ }
126
+ return t;
127
+ }, J = (i) => i === "email", K = () => ({
128
128
  singleTag: "hr"
129
129
  }), Y = () => ({
130
130
  tag: "blockquote"
131
131
  }), W = () => ({
132
132
  tag: "ul"
133
- }), G = (o) => ({
133
+ }), G = (i) => ({
134
134
  tag: [
135
135
  "pre",
136
136
  {
137
137
  tag: "code",
138
- attrs: o.attrs
138
+ attrs: i.attrs
139
139
  }
140
140
  ]
141
141
  }), Q = () => ({
142
142
  singleTag: "br"
143
- }), X = (o) => ({
144
- tag: `h${o.attrs.level}`
145
- }), Z = (o) => ({
143
+ }), X = (i) => ({
144
+ tag: `h${i.attrs.level}`
145
+ }), Z = (i) => ({
146
146
  singleTag: [
147
147
  {
148
148
  tag: "img",
149
- attrs: B(o.attrs, ["src", "alt", "title"])
149
+ attrs: B(i.attrs, ["src", "alt", "title"])
150
150
  }
151
151
  ]
152
- }), tt = () => ({
152
+ }), ee = () => ({
153
153
  tag: "li"
154
- }), et = () => ({
154
+ }), te = () => ({
155
155
  tag: "ol"
156
- }), st = () => ({
156
+ }), se = () => ({
157
157
  tag: "p"
158
- }), rt = (o) => ({
158
+ }), re = (i) => ({
159
159
  tag: [
160
160
  {
161
161
  tag: "span",
162
162
  attrs: {
163
163
  "data-type": "emoji",
164
- "data-name": o.attrs.name,
165
- emoji: o.attrs.emoji
164
+ "data-name": i.attrs.name,
165
+ emoji: i.attrs.emoji
166
166
  }
167
167
  }
168
168
  ]
169
- }), ot = () => ({
169
+ }), oe = () => ({
170
170
  tag: "b"
171
- }), nt = () => ({
171
+ }), ie = () => ({
172
172
  tag: "s"
173
- }), it = () => ({
173
+ }), ne = () => ({
174
174
  tag: "u"
175
- }), at = () => ({
175
+ }), ae = () => ({
176
176
  tag: "strong"
177
- }), lt = () => ({
177
+ }), le = () => ({
178
178
  tag: "code"
179
- }), ct = () => ({
179
+ }), ce = () => ({
180
180
  tag: "i"
181
- }), ht = (o) => {
182
- if (!o.attrs)
181
+ }), he = (i) => {
182
+ if (!i.attrs)
183
183
  return {
184
184
  tag: ""
185
185
  };
186
- const t = new k().escapeHTML, e = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
187
- if (delete e.linktype, e.href && (e.href = t(o.attrs.href || "")), J(s) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
188
- for (const r in e.custom)
189
- e[r] = e.custom[r];
190
- delete e.custom;
186
+ const e = new k().escapeHTML, t = { ...i.attrs }, { linktype: s = "url" } = i.attrs;
187
+ if (delete t.linktype, t.href && (t.href = e(i.attrs.href || "")), J(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
188
+ for (const r in t.custom)
189
+ t[r] = t.custom[r];
190
+ delete t.custom;
191
191
  }
192
192
  return {
193
193
  tag: [
194
194
  {
195
195
  tag: "a",
196
- attrs: e
196
+ attrs: t
197
197
  }
198
198
  ]
199
199
  };
200
- }, ut = (o) => ({
200
+ }, ue = (i) => ({
201
201
  tag: [
202
202
  {
203
203
  tag: "span",
204
- attrs: o.attrs
204
+ attrs: i.attrs
205
205
  }
206
206
  ]
207
- }), pt = () => ({
207
+ }), pe = () => ({
208
208
  tag: "sub"
209
- }), dt = () => ({
209
+ }), de = () => ({
210
210
  tag: "sup"
211
- }), gt = (o) => ({
211
+ }), ge = (i) => ({
212
212
  tag: [
213
213
  {
214
214
  tag: "span",
215
- attrs: o.attrs
215
+ attrs: i.attrs
216
216
  }
217
217
  ]
218
- }), ft = (o) => {
219
- var t;
220
- return (t = o.attrs) != null && t.color ? {
218
+ }), fe = (i) => {
219
+ var e;
220
+ return (e = i.attrs) != null && e.color ? {
221
221
  tag: [
222
222
  {
223
223
  tag: "span",
224
224
  attrs: {
225
- style: `background-color:${o.attrs.color};`
225
+ style: `background-color:${i.attrs.color};`
226
226
  }
227
227
  }
228
228
  ]
229
229
  } : {
230
230
  tag: ""
231
231
  };
232
- }, mt = (o) => {
233
- var t;
234
- return (t = o.attrs) != null && t.color ? {
232
+ }, me = (i) => {
233
+ var e;
234
+ return (e = i.attrs) != null && e.color ? {
235
235
  tag: [
236
236
  {
237
237
  tag: "span",
238
238
  attrs: {
239
- style: `color:${o.attrs.color}`
239
+ style: `color:${i.attrs.color}`
240
240
  }
241
241
  }
242
242
  ]
243
243
  } : {
244
244
  tag: ""
245
245
  };
246
- }, yt = {
246
+ }, ye = {
247
247
  nodes: {
248
248
  horizontal_rule: K,
249
249
  blockquote: Y,
@@ -252,52 +252,52 @@ const B = function(o, t) {
252
252
  hard_break: Q,
253
253
  heading: X,
254
254
  image: Z,
255
- list_item: tt,
256
- ordered_list: et,
257
- paragraph: st,
258
- emoji: rt
255
+ list_item: ee,
256
+ ordered_list: te,
257
+ paragraph: se,
258
+ emoji: re
259
259
  },
260
260
  marks: {
261
- bold: ot,
262
- strike: nt,
263
- underline: it,
264
- strong: at,
265
- code: lt,
266
- italic: ct,
267
- link: ht,
268
- styled: ut,
269
- subscript: pt,
270
- superscript: dt,
271
- anchor: gt,
272
- highlight: ft,
273
- textStyle: mt
274
- }
275
- }, bt = function(o) {
276
- const t = {
261
+ bold: oe,
262
+ strike: ie,
263
+ underline: ne,
264
+ strong: ae,
265
+ code: le,
266
+ italic: ce,
267
+ link: he,
268
+ styled: ue,
269
+ subscript: pe,
270
+ superscript: de,
271
+ anchor: ge,
272
+ highlight: fe,
273
+ textStyle: me
274
+ }
275
+ }, be = function(i) {
276
+ const e = {
277
277
  "&": "&amp;",
278
278
  "<": "&lt;",
279
279
  ">": "&gt;",
280
280
  '"': "&quot;",
281
281
  "'": "&#39;"
282
- }, e = /[&<>"']/g, s = RegExp(e.source);
283
- return o && s.test(o) ? o.replace(e, (r) => t[r]) : o;
282
+ }, t = /[&<>"']/g, s = RegExp(t.source);
283
+ return i && s.test(i) ? i.replace(t, (r) => e[r]) : i;
284
284
  };
285
285
  class v {
286
- constructor(t) {
287
- h(this, "marks"), h(this, "nodes"), t || (t = yt), this.marks = t.marks || [], this.nodes = t.nodes || [];
286
+ constructor(e) {
287
+ h(this, "marks"), h(this, "nodes"), e || (e = ye), this.marks = e.marks || [], this.nodes = e.nodes || [];
288
288
  }
289
- addNode(t, e) {
290
- this.nodes[t] = e;
289
+ addNode(e, t) {
290
+ this.nodes[e] = t;
291
291
  }
292
- addMark(t, e) {
293
- this.marks[t] = e;
292
+ addMark(e, t) {
293
+ this.marks[e] = t;
294
294
  }
295
- render(t, e = { optimizeImages: !1 }) {
296
- if (t && t.content && Array.isArray(t.content)) {
295
+ render(e, t = { optimizeImages: !1 }) {
296
+ if (e && e.content && Array.isArray(e.content)) {
297
297
  let s = "";
298
- return t.content.forEach((r) => {
298
+ return e.content.forEach((r) => {
299
299
  s += this.renderNode(r);
300
- }), e.optimizeImages ? this.optimizeImages(s, e.optimizeImages) : s;
300
+ }), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
301
301
  }
302
302
  return console.warn(
303
303
  `The render method must receive an Object with a "content" field.
@@ -326,101 +326,101 @@ class v {
326
326
  }`
327
327
  ), "";
328
328
  }
329
- optimizeImages(t, e) {
330
- let s = 0, r = 0, n = "", i = "";
331
- typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (n += `width="${e.width}" `, s = e.width), typeof e.height == "number" && e.height > 0 && (n += `height="${e.height}" `, r = e.height), (e.loading === "lazy" || e.loading === "eager") && (n += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (n += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (i += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (i += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-Fa-f]{6}/g) || e.filters.fill === "transparent") && (i += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (i += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (i += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (i += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (i += `:rotate(${e.filters.rotate})`), i.length > 0 && (i = "/filters" + i))), n.length > 0 && (t = t.replace(/<img/g, `<img ${n.trim()}`));
332
- const l = s > 0 || r > 0 || i.length > 0 ? `${s}x${r}${i}` : "";
333
- return t = t.replace(
329
+ optimizeImages(e, t) {
330
+ let s = 0, r = 0, o = "", n = "";
331
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (o += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (o += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (o += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (o += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (n += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (n += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (n += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (n += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (n += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (n += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (n += `:rotate(${t.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
332
+ const l = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
333
+ return e = e.replace(
334
334
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
335
335
  `a.storyblok.com/f/$1/$2.$3/m/${l}`
336
- ), typeof e != "boolean" && (e.sizes || e.srcset) && (t = t.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
336
+ ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
337
337
  var c, u;
338
338
  const p = a.match(
339
339
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
340
340
  );
341
341
  if (p && p.length > 0) {
342
342
  const g = {
343
- srcset: (c = e.srcset) == null ? void 0 : c.map((d) => {
343
+ srcset: (c = t.srcset) == null ? void 0 : c.map((d) => {
344
344
  if (typeof d == "number")
345
- return `//${p}/m/${d}x0${i} ${d}w`;
345
+ return `//${p}/m/${d}x0${n} ${d}w`;
346
346
  if (typeof d == "object" && d.length === 2) {
347
347
  let w = 0, S = 0;
348
- return typeof d[0] == "number" && (w = d[0]), typeof d[1] == "number" && (S = d[1]), `//${p}/m/${w}x${S}${i} ${w}w`;
348
+ return typeof d[0] == "number" && (w = d[0]), typeof d[1] == "number" && (S = d[1]), `//${p}/m/${w}x${S}${n} ${w}w`;
349
349
  }
350
350
  }).join(", "),
351
- sizes: (u = e.sizes) == null ? void 0 : u.map((d) => d).join(", ")
351
+ sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
352
352
  };
353
353
  let f = "";
354
354
  return g.srcset && (f += `srcset="${g.srcset}" `), g.sizes && (f += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${f.trim()}`);
355
355
  }
356
356
  return a;
357
- })), t;
357
+ })), e;
358
358
  }
359
- renderNode(t) {
360
- const e = [];
361
- t.marks && t.marks.forEach((r) => {
362
- const n = this.getMatchingMark(r);
363
- n && n.tag !== "" && e.push(this.renderOpeningTag(n.tag));
359
+ renderNode(e) {
360
+ const t = [];
361
+ e.marks && e.marks.forEach((r) => {
362
+ const o = this.getMatchingMark(r);
363
+ o && o.tag !== "" && t.push(this.renderOpeningTag(o.tag));
364
364
  });
365
- const s = this.getMatchingNode(t);
366
- return s && s.tag && e.push(this.renderOpeningTag(s.tag)), t.content ? t.content.forEach((r) => {
367
- e.push(this.renderNode(r));
368
- }) : t.text ? e.push(bt(t.text)) : s && s.singleTag ? e.push(this.renderTag(s.singleTag, " /")) : s && s.html ? e.push(s.html) : t.type === "emoji" && e.push(this.renderEmoji(t)), s && s.tag && e.push(this.renderClosingTag(s.tag)), t.marks && t.marks.slice(0).reverse().forEach((r) => {
369
- const n = this.getMatchingMark(r);
370
- n && n.tag !== "" && e.push(this.renderClosingTag(n.tag));
371
- }), e.join("");
372
- }
373
- renderTag(t, e) {
374
- return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
365
+ const s = this.getMatchingNode(e);
366
+ return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
367
+ t.push(this.renderNode(r));
368
+ }) : 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((r) => {
369
+ const o = this.getMatchingMark(r);
370
+ o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
371
+ }), t.join("");
372
+ }
373
+ renderTag(e, t) {
374
+ return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
375
375
  if (s.constructor === String)
376
- return `<${s}${e}>`;
376
+ return `<${s}${t}>`;
377
377
  {
378
378
  let r = `<${s.tag}`;
379
379
  if (s.attrs)
380
- for (const n in s.attrs) {
381
- const i = s.attrs[n];
382
- i !== null && (r += ` ${n}="${i}"`);
380
+ for (const o in s.attrs) {
381
+ const n = s.attrs[o];
382
+ n !== null && (r += ` ${o}="${n}"`);
383
383
  }
384
- return `${r}${e}>`;
384
+ return `${r}${t}>`;
385
385
  }
386
386
  }).join("");
387
387
  }
388
- renderOpeningTag(t) {
389
- return this.renderTag(t, "");
388
+ renderOpeningTag(e) {
389
+ return this.renderTag(e, "");
390
390
  }
391
- renderClosingTag(t) {
392
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
391
+ renderClosingTag(e) {
392
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
393
393
  }
394
- getMatchingNode(t) {
395
- const e = this.nodes[t.type];
396
- if (typeof e == "function")
397
- return e(t);
394
+ getMatchingNode(e) {
395
+ const t = this.nodes[e.type];
396
+ if (typeof t == "function")
397
+ return t(e);
398
398
  }
399
- getMatchingMark(t) {
400
- const e = this.marks[t.type];
401
- if (typeof e == "function")
402
- return e(t);
399
+ getMatchingMark(e) {
400
+ const t = this.marks[e.type];
401
+ if (typeof t == "function")
402
+ return t(e);
403
403
  }
404
- renderEmoji(t) {
405
- if (t.attrs.emoji)
406
- return t.attrs.emoji;
407
- const e = [
404
+ renderEmoji(e) {
405
+ if (e.attrs.emoji)
406
+ return e.attrs.emoji;
407
+ const t = [
408
408
  {
409
409
  tag: "img",
410
410
  attrs: {
411
- src: t.attrs.fallbackImage,
411
+ src: e.attrs.fallbackImage,
412
412
  draggable: "false",
413
413
  loading: "lazy",
414
414
  align: "absmiddle"
415
415
  }
416
416
  }
417
417
  ];
418
- return this.renderTag(e, " /");
418
+ return this.renderTag(t, " /");
419
419
  }
420
420
  }
421
- class kt {
422
- constructor(t) {
423
- h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), h(this, "fetchOptions"), this.baseURL = t.baseURL, this.headers = t.headers || new Headers(), this.timeout = t != null && t.timeout ? t.timeout * 1e3 : 0, this.responseInterceptor = t.responseInterceptor, this.fetch = (...e) => t.fetch ? t.fetch(...e) : fetch(...e), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
421
+ class ke {
422
+ constructor(e) {
423
+ h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), h(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 = {};
424
424
  }
425
425
  /**
426
426
  *
@@ -428,50 +428,50 @@ class kt {
428
428
  * @param params ISbStoriesParams
429
429
  * @returns Promise<ISbResponse | Error>
430
430
  */
431
- get(t, e) {
432
- return this.url = t, this.parameters = e, this._methodHandler("get");
431
+ get(e, t) {
432
+ return this.url = e, this.parameters = t, this._methodHandler("get");
433
433
  }
434
- post(t, e) {
435
- return this.url = t, this.parameters = e, this._methodHandler("post");
434
+ post(e, t) {
435
+ return this.url = e, this.parameters = t, this._methodHandler("post");
436
436
  }
437
- put(t, e) {
438
- return this.url = t, this.parameters = e, this._methodHandler("put");
437
+ put(e, t) {
438
+ return this.url = e, this.parameters = t, this._methodHandler("put");
439
439
  }
440
- delete(t, e) {
441
- return this.url = t, this.parameters = e, this._methodHandler("delete");
440
+ delete(e, t) {
441
+ return this.url = e, this.parameters = t, this._methodHandler("delete");
442
442
  }
443
- async _responseHandler(t) {
444
- const e = [], s = {
443
+ async _responseHandler(e) {
444
+ const t = [], s = {
445
445
  data: {},
446
446
  headers: {},
447
447
  status: 0,
448
448
  statusText: ""
449
449
  };
450
- t.status !== 204 && await t.json().then((r) => {
450
+ e.status !== 204 && await e.json().then((r) => {
451
451
  s.data = r;
452
452
  });
453
- for (const r of t.headers.entries())
454
- e[r[0]] = r[1];
455
- return s.headers = { ...e }, s.status = t.status, s.statusText = t.statusText, s;
453
+ for (const r of e.headers.entries())
454
+ t[r[0]] = r[1];
455
+ return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
456
456
  }
457
- async _methodHandler(t) {
458
- let e = `${this.baseURL}${this.url}`, s = null;
459
- if (t === "get") {
457
+ async _methodHandler(e) {
458
+ let t = `${this.baseURL}${this.url}`, s = null;
459
+ if (e === "get") {
460
460
  const a = new k();
461
- e = `${this.baseURL}${this.url}?${a.stringify(
461
+ t = `${this.baseURL}${this.url}?${a.stringify(
462
462
  this.parameters
463
463
  )}`;
464
464
  } else
465
465
  s = JSON.stringify(this.parameters);
466
- const r = new URL(e), n = new AbortController(), { signal: i } = n;
466
+ const r = new URL(t), o = new AbortController(), { signal: n } = o;
467
467
  let l;
468
- this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
468
+ this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
469
469
  try {
470
- const a = await fetch(`${r}`, {
471
- method: t,
470
+ const a = await this.fetch(`${r}`, {
471
+ method: e,
472
472
  headers: this.headers,
473
473
  body: s,
474
- signal: i,
474
+ signal: n,
475
475
  ...this.fetchOptions
476
476
  });
477
477
  this.timeout && clearTimeout(l);
@@ -485,119 +485,120 @@ class kt {
485
485
  };
486
486
  }
487
487
  }
488
- setFetchOptions(t = {}) {
489
- Object.keys(t).length > 0 && "method" in t && delete t.method, this.fetchOptions = { ...t };
488
+ setFetchOptions(e = {}) {
489
+ Object.keys(e).length > 0 && "method" in e && delete e.method, this.fetchOptions = { ...e };
490
490
  }
491
491
  eject() {
492
492
  this.ejectInterceptor = !0;
493
493
  }
494
- _statusHandler(t) {
495
- const e = /20[0-6]/g;
494
+ _statusHandler(e) {
495
+ const t = /20[0-6]/g;
496
496
  return new Promise((s, r) => {
497
- if (e.test(`${t.status}`))
498
- return s(t);
499
- const n = {
500
- message: t.statusText,
501
- status: t.status,
502
- response: Array.isArray(t.data) ? t.data[0] : t.data.error || t.data.slug
497
+ if (t.test(`${e.status}`))
498
+ return s(e);
499
+ const o = {
500
+ message: e.statusText,
501
+ status: e.status,
502
+ response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
503
503
  };
504
- r(n);
504
+ r(o);
505
505
  });
506
506
  }
507
507
  }
508
- var vt = { npm_package_version: "6.6.3" };
509
508
  const P = "SB-Agent", R = {
510
509
  defaultAgentName: "SB-JS-CLIENT",
511
510
  defaultAgentVersion: "SB-Agent-Version",
512
- packageVersion: vt.npm_package_version
511
+ packageVersion: "6.0.0"
513
512
  };
514
513
  let b = {};
515
514
  const m = {};
516
- class wt {
515
+ class ve {
517
516
  /**
518
517
  *
519
518
  * @param config ISbConfig interface
520
519
  * @param endpoint string, optional
521
520
  */
522
- constructor(t, e) {
521
+ constructor(e, t) {
523
522
  h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations"), h(this, "stringifiedStoriesCache");
524
- let s = t.endpoint || e;
525
- const r = new k().getRegionURL, n = t.https === !1 ? "http" : "https";
526
- t.oauthToken ? s = `${n}://${r(t.region)}/v1` : s = `${n}://${r(t.region)}/v2`;
527
- const i = new Headers();
528
- if (i.set("Content-Type", "application/json"), i.set("Accept", "application/json"), t.headers)
529
- for (const a in t.headers)
530
- i.set(a, t.headers[a]);
531
- i.has(P) || (i.set(P, R.defaultAgentName), i.set(
523
+ let s = e.endpoint || t;
524
+ if (!s) {
525
+ const n = new k().getRegionURL, l = e.https === !1 ? "http" : "https";
526
+ e.oauthToken ? s = `${l}://${n(e.region)}/v1` : s = `${l}://${n(e.region)}/v2`;
527
+ }
528
+ const r = new Headers();
529
+ if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers)
530
+ for (const n in e.headers)
531
+ r.set(n, e.headers[n]);
532
+ r.has(P) || (r.set(P, R.defaultAgentName), r.set(
532
533
  R.defaultAgentVersion,
533
534
  R.packageVersion
534
535
  ));
535
- let l = 5;
536
- t.oauthToken && (i.set("Authorization", t.oauthToken), l = 3), t.rateLimit && (l = t.rateLimit), t.richTextSchema ? this.richTextResolver = new v(t.richTextSchema) : this.richTextResolver = new v(), t.componentResolver && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = D(this.throttledRequest, l, 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.helpers = new k(), this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new kt({
536
+ let o = 5;
537
+ e.oauthToken && (r.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new v(e.richTextSchema) : this.richTextResolver = new v(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = D(this.throttledRequest, o, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new k(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new ke({
537
538
  baseURL: s,
538
- timeout: t.timeout || 0,
539
- headers: i,
540
- responseInterceptor: t.responseInterceptor,
541
- fetch: t.fetch
539
+ timeout: e.timeout || 0,
540
+ headers: r,
541
+ responseInterceptor: e.responseInterceptor,
542
+ fetch: e.fetch
542
543
  });
543
544
  }
544
- setComponentResolver(t) {
545
- this.richTextResolver.addNode("blok", (e) => {
545
+ setComponentResolver(e) {
546
+ this.richTextResolver.addNode("blok", (t) => {
546
547
  let s = "";
547
- return e.attrs.body && e.attrs.body.forEach((r) => {
548
- s += t(r.component, r);
548
+ return t.attrs.body && t.attrs.body.forEach((r) => {
549
+ s += e(r.component, r);
549
550
  }), {
550
551
  html: s
551
552
  };
552
553
  });
553
554
  }
554
- parseParams(t) {
555
- return t.token || (t.token = this.getToken()), t.cv || (t.cv = m[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
555
+ parseParams(e) {
556
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = m[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
556
557
  }
557
- factoryParamOptions(t, e) {
558
- return this.helpers.isCDNUrl(t) ? this.parseParams(e) : e;
558
+ factoryParamOptions(e, t) {
559
+ return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
559
560
  }
560
- makeRequest(t, e, s, r) {
561
- const n = this.factoryParamOptions(
562
- t,
563
- this.helpers.getOptionsPage(e, s, r)
561
+ makeRequest(e, t, s, r) {
562
+ const o = this.factoryParamOptions(
563
+ e,
564
+ this.helpers.getOptionsPage(t, s, r)
564
565
  );
565
- return this.cacheResponse(t, n);
566
+ return this.cacheResponse(e, o);
566
567
  }
567
- get(t, e, s) {
568
- e || (e = {});
569
- const r = `/${t}`, n = this.factoryParamOptions(r, e);
570
- return this.client.setFetchOptions(s), this.cacheResponse(r, n);
568
+ get(e, t, s) {
569
+ t || (t = {});
570
+ const r = `/${e}`, o = this.factoryParamOptions(r, t);
571
+ return this.client.setFetchOptions(s), this.cacheResponse(r, o);
571
572
  }
572
- async getAll(t, e, s, r) {
573
- const n = (e == null ? void 0 : e.per_page) || 25, i = `/${t}`, l = i.split("/"), a = s || l[l.length - 1], c = 1, u = await this.makeRequest(i, e, n, c), p = u.total ? Math.ceil(u.total / n) : 1;
573
+ async getAll(e, t, s, r) {
574
+ const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, l = n.split("/"), a = s || l[l.length - 1], c = 1, u = await this.makeRequest(n, t, o, c), p = u.total ? Math.ceil(u.total / o) : 1;
574
575
  this.client.setFetchOptions(r);
575
576
  const g = await this.helpers.asyncMap(
576
577
  this.helpers.range(c, p),
577
- (f) => this.makeRequest(i, e, n, f + 1)
578
+ (f) => this.makeRequest(n, t, o, f + 1)
578
579
  );
579
580
  return this.helpers.flatMap(
580
581
  [u, ...g],
581
582
  (f) => Object.values(f.data[a])
582
583
  );
583
584
  }
584
- post(t, e, s) {
585
- const r = `/${t}`;
586
- return this.client.setFetchOptions(s), Promise.resolve(this.throttle("post", r, e));
585
+ post(e, t, s) {
586
+ const r = `/${e}`;
587
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("post", r, t));
587
588
  }
588
- put(t, e, s) {
589
- const r = `/${t}`;
590
- return this.client.setFetchOptions(s), Promise.resolve(this.throttle("put", r, e));
589
+ put(e, t, s) {
590
+ const r = `/${e}`;
591
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("put", r, t));
591
592
  }
592
- delete(t, e, s) {
593
- const r = `/${t}`;
594
- return this.client.setFetchOptions(s), Promise.resolve(this.throttle("delete", r, e));
593
+ delete(e, t, s) {
594
+ const r = `/${e}`;
595
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("delete", r, t));
595
596
  }
596
- getStories(t, e) {
597
- return this.client.setFetchOptions(e), this.get("cdn/stories", t);
597
+ getStories(e, t) {
598
+ return this.client.setFetchOptions(t), this._addResolveLevel(e), this.get("cdn/stories", e);
598
599
  }
599
- getStory(t, e, s) {
600
- return this.client.setFetchOptions(s), this.get(`cdn/stories/${t}`, e);
600
+ getStory(e, t, s) {
601
+ return this.client.setFetchOptions(s), this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t);
601
602
  }
602
603
  getToken() {
603
604
  return this.accessToken;
@@ -605,11 +606,14 @@ class wt {
605
606
  ejectInterceptor() {
606
607
  this.client.eject();
607
608
  }
608
- _cleanCopy(t) {
609
- return JSON.parse(JSON.stringify(t));
609
+ _addResolveLevel(e) {
610
+ typeof e.resolve_relations < "u" && (e.resolve_level = 2);
611
+ }
612
+ _cleanCopy(e) {
613
+ return JSON.parse(JSON.stringify(e));
610
614
  }
611
- _insertLinks(t, e, s) {
612
- const r = t[e];
615
+ _insertLinks(e, t, s) {
616
+ const r = e[t];
613
617
  r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[s][r.id] ? r.story = this._cleanCopy(this.links[s][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[s][r.uuid] && (r.story = this._cleanCopy(this.links[s][r.uuid]));
614
618
  }
615
619
  /**
@@ -618,90 +622,90 @@ class wt {
618
622
  * @param uuid The uuid of the story
619
623
  * @returns string | object
620
624
  */
621
- getStoryReference(t, e) {
622
- return this.relations[t][e] ? (this.stringifiedStoriesCache[e] || (this.stringifiedStoriesCache[e] = JSON.stringify(
623
- this.relations[t][e]
624
- )), JSON.parse(this.stringifiedStoriesCache[e])) : e;
625
- }
626
- _insertRelations(t, e, s, r) {
627
- s.indexOf(`${t.component}.${e}`) > -1 && (typeof t[e] == "string" ? t[e] = this.getStoryReference(r, t[e]) : Array.isArray(t[e]) && (t[e] = t[e].map((n) => this.getStoryReference(r, n)).filter(Boolean)));
628
- }
629
- iterateTree(t, e, s) {
630
- const r = (n) => {
631
- if (n != null) {
632
- if (n.constructor === Array)
633
- for (let i = 0; i < n.length; i++)
634
- r(n[i]);
635
- else if (n.constructor === Object) {
636
- if (n._stopResolving)
625
+ getStoryReference(e, t) {
626
+ return this.relations[e][t] ? (this.stringifiedStoriesCache[t] || (this.stringifiedStoriesCache[t] = JSON.stringify(
627
+ this.relations[e][t]
628
+ )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
629
+ }
630
+ _insertRelations(e, t, s, r) {
631
+ s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(r, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((o) => this.getStoryReference(r, o)).filter(Boolean)));
632
+ }
633
+ iterateTree(e, t, s) {
634
+ const r = (o) => {
635
+ if (o != null) {
636
+ if (o.constructor === Array)
637
+ for (let n = 0; n < o.length; n++)
638
+ r(o[n]);
639
+ else if (o.constructor === Object) {
640
+ if (o._stopResolving)
637
641
  return;
638
- for (const i in n)
639
- (n.component && n._uid || n.type === "link") && (this._insertRelations(
642
+ for (const n in o)
643
+ (o.component && o._uid || o.type === "link") && (this._insertRelations(
644
+ o,
640
645
  n,
641
- i,
642
- e,
646
+ t,
643
647
  s
644
648
  ), this._insertLinks(
649
+ o,
645
650
  n,
646
- i,
647
651
  s
648
- )), r(n[i]);
652
+ )), r(o[n]);
649
653
  }
650
654
  }
651
655
  };
652
- r(t.content);
656
+ r(e.content);
653
657
  }
654
- async resolveLinks(t, e, s) {
658
+ async resolveLinks(e, t, s) {
655
659
  let r = [];
656
- if (t.link_uuids) {
657
- const n = t.link_uuids.length, i = [], l = 50;
658
- for (let a = 0; a < n; a += l) {
659
- const c = Math.min(n, a + l);
660
- i.push(t.link_uuids.slice(a, c));
660
+ if (e.link_uuids) {
661
+ const o = e.link_uuids.length, n = [], l = 50;
662
+ for (let a = 0; a < o; a += l) {
663
+ const c = Math.min(o, a + l);
664
+ n.push(e.link_uuids.slice(a, c));
661
665
  }
662
- for (let a = 0; a < i.length; a++)
666
+ for (let a = 0; a < n.length; a++)
663
667
  (await this.getStories({
664
668
  per_page: l,
665
- language: e.language,
666
- version: e.version,
667
- by_uuids: i[a].join(",")
669
+ language: t.language,
670
+ version: t.version,
671
+ by_uuids: n[a].join(",")
668
672
  })).data.stories.forEach(
669
673
  (c) => {
670
674
  r.push(c);
671
675
  }
672
676
  );
673
677
  } else
674
- r = t.links;
675
- r.forEach((n) => {
676
- this.links[s][n.uuid] = {
677
- ...n,
678
+ r = e.links;
679
+ r.forEach((o) => {
680
+ this.links[s][o.uuid] = {
681
+ ...o,
678
682
  _stopResolving: !0
679
683
  };
680
684
  });
681
685
  }
682
- async resolveRelations(t, e, s) {
686
+ async resolveRelations(e, t, s) {
683
687
  let r = [];
684
- if (t.rel_uuids) {
685
- const n = t.rel_uuids.length, i = [], l = 50;
686
- for (let a = 0; a < n; a += l) {
687
- const c = Math.min(n, a + l);
688
- i.push(t.rel_uuids.slice(a, c));
688
+ if (e.rel_uuids) {
689
+ const o = e.rel_uuids.length, n = [], l = 50;
690
+ for (let a = 0; a < o; a += l) {
691
+ const c = Math.min(o, a + l);
692
+ n.push(e.rel_uuids.slice(a, c));
689
693
  }
690
- for (let a = 0; a < i.length; a++)
694
+ for (let a = 0; a < n.length; a++)
691
695
  (await this.getStories({
692
696
  per_page: l,
693
- language: e.language,
694
- version: e.version,
695
- by_uuids: i[a].join(","),
696
- excluding_fields: e.excluding_fields
697
+ language: t.language,
698
+ version: t.version,
699
+ by_uuids: n[a].join(","),
700
+ excluding_fields: t.excluding_fields
697
701
  })).data.stories.forEach((c) => {
698
702
  r.push(c);
699
703
  });
700
704
  } else
701
- r = t.rels;
702
- r && r.length > 0 && r.forEach((n) => {
703
- this.relations[s][n.uuid] = {
704
- ...n,
705
+ r = e.rels;
706
+ r && r.length > 0 && r.forEach((o) => {
707
+ this.relations[s][o.uuid] = {
708
+ ...o,
705
709
  _stopResolving: !0
706
710
  };
707
711
  });
@@ -715,32 +719,32 @@ class wt {
715
719
  * @returns Promise<void>
716
720
  *
717
721
  */
718
- async resolveStories(t, e, s) {
719
- var r, n;
720
- let i = [];
721
- if (this.links[s] = {}, this.relations[s] = {}, typeof e.resolve_relations < "u" && e.resolve_relations.length > 0 && (typeof e.resolve_relations == "string" && (i = e.resolve_relations.split(",")), await this.resolveRelations(t, e, s)), e.resolve_links && ["1", "story", "url", "link"].indexOf(e.resolve_links) > -1 && ((r = t.links) != null && r.length || (n = t.link_uuids) != null && n.length) && await this.resolveLinks(t, e, s), this.resolveNestedRelations)
722
+ async resolveStories(e, t, s) {
723
+ var r, o;
724
+ let n = [];
725
+ if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
722
726
  for (const l in this.relations[s])
723
727
  this.iterateTree(
724
728
  this.relations[s][l],
725
- i,
729
+ n,
726
730
  s
727
731
  );
728
- t.story ? this.iterateTree(t.story, i, s) : t.stories.forEach((l) => {
729
- this.iterateTree(l, i, s);
732
+ e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((l) => {
733
+ this.iterateTree(l, n, s);
730
734
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
731
735
  }
732
- async cacheResponse(t, e, s) {
736
+ async cacheResponse(e, t, s) {
733
737
  (typeof s > "u" || !s) && (s = 0);
734
- const r = this.helpers.stringify({ url: t, params: e }), n = this.cacheProvider();
735
- if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
736
- const i = await n.get(r);
737
- if (i)
738
- return Promise.resolve(i);
738
+ const r = this.helpers.stringify({ url: e, params: t }), o = this.cacheProvider();
739
+ if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
740
+ const n = await o.get(r);
741
+ if (n)
742
+ return Promise.resolve(n);
739
743
  }
740
- return new Promise(async (i, l) => {
744
+ return new Promise(async (n, l) => {
741
745
  var a;
742
746
  try {
743
- const c = await this.throttle("get", t, e);
747
+ const c = await this.throttle("get", e, t);
744
748
  if (c.status !== 200)
745
749
  return l(c);
746
750
  let u = { data: c.data, headers: c.headers };
@@ -749,18 +753,18 @@ class wt {
749
753
  total: c.headers["per-page"] ? parseInt(c.headers.total) : 0
750
754
  })), u.data.story || u.data.stories) {
751
755
  const p = this.resolveCounter = ++this.resolveCounter % 1e3;
752
- await this.resolveStories(u.data, e, `${p}`);
756
+ await this.resolveStories(u.data, t, `${p}`);
753
757
  }
754
- return e.version === "published" && t != "/cdn/spaces/me" && await n.set(r, u), u.data.cv && e.token && (e.version === "draft" && m[e.token] != u.data.cv && await this.flushCache(), m[e.token] = e.cv ? e.cv : u.data.cv), i(u);
758
+ return t.version === "published" && e != "/cdn/spaces/me" && await o.set(r, u), u.data.cv && t.token && (t.version === "draft" && m[t.token] != u.data.cv && await this.flushCache(), m[t.token] = t.cv ? t.cv : u.data.cv), n(u);
755
759
  } catch (c) {
756
760
  if (c.response && c.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
757
- return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(t, e, s).then(i).catch(l);
761
+ return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(n).catch(l);
758
762
  l(c);
759
763
  }
760
764
  });
761
765
  }
762
- throttledRequest(t, e, s) {
763
- return this.client[t](e, s);
766
+ throttledRequest(e, t, s) {
767
+ return this.client[e](t, s);
764
768
  }
765
769
  cacheVersions() {
766
770
  return m;
@@ -768,21 +772,21 @@ class wt {
768
772
  cacheVersion() {
769
773
  return m[this.accessToken];
770
774
  }
771
- setCacheVersion(t) {
772
- this.accessToken && (m[this.accessToken] = t);
775
+ setCacheVersion(e) {
776
+ this.accessToken && (m[this.accessToken] = e);
773
777
  }
774
778
  cacheProvider() {
775
779
  switch (this.cache.type) {
776
780
  case "memory":
777
781
  return {
778
- get(t) {
779
- return Promise.resolve(b[t]);
782
+ get(e) {
783
+ return Promise.resolve(b[e]);
780
784
  },
781
785
  getAll() {
782
786
  return Promise.resolve(b);
783
787
  },
784
- set(t, e) {
785
- return b[t] = e, Promise.resolve(void 0);
788
+ set(e, t) {
789
+ return b[e] = t, Promise.resolve(void 0);
786
790
  },
787
791
  flush() {
788
792
  return b = {}, Promise.resolve(void 0);
@@ -812,150 +816,150 @@ class wt {
812
816
  return await this.cacheProvider().flush(), this;
813
817
  }
814
818
  }
815
- const Ct = (o = {}) => {
816
- const { apiOptions: t } = o;
817
- if (!t.accessToken) {
819
+ const xe = (i = {}) => {
820
+ const { apiOptions: e } = i;
821
+ if (!e.accessToken) {
818
822
  console.error(
819
823
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
820
824
  );
821
825
  return;
822
826
  }
823
- return { storyblokApi: new wt(t) };
824
- }, $t = (o) => {
825
- if (typeof o != "object" || typeof o._editable > "u")
827
+ return { storyblokApi: new ve(e) };
828
+ }, we = (i) => {
829
+ if (typeof i != "object" || typeof i._editable > "u")
826
830
  return {};
827
831
  try {
828
- const t = JSON.parse(
829
- o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
832
+ const e = JSON.parse(
833
+ i._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
830
834
  );
831
- return t ? {
832
- "data-blok-c": JSON.stringify(t),
833
- "data-blok-uid": t.id + "-" + t.uid
835
+ return e ? {
836
+ "data-blok-c": JSON.stringify(e),
837
+ "data-blok-uid": e.id + "-" + e.uid
834
838
  } : {};
835
839
  } catch {
836
840
  return {};
837
841
  }
838
842
  };
839
843
  let T, O = "https://app.storyblok.com/f/storyblok-v2-latest.js";
840
- const Rt = (o, t, e = {}) => {
844
+ const $e = (i, e, t = {}) => {
841
845
  var s;
842
- const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
846
+ const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
843
847
  "_storyblok"
844
- ) === o;
845
- if (!(!r || !n)) {
846
- if (!o) {
848
+ ) === i;
849
+ if (!(!r || !o)) {
850
+ if (!i) {
847
851
  console.warn("Story ID is not defined. Please provide a valid ID.");
848
852
  return;
849
853
  }
850
854
  window.storyblokRegisterEvent(() => {
851
- new window.StoryblokBridge(e).on(["input", "published", "change"], (i) => {
852
- i.action === "input" && i.story.id === o ? t(i.story) : (i.action === "change" || i.action === "published") && i.storyId === o && window.location.reload();
855
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (n) => {
856
+ n.action === "input" && n.story.id === i ? e(n.story) : (n.action === "change" || n.action === "published") && n.storyId === i && window.location.reload();
853
857
  });
854
858
  });
855
859
  }
856
- }, _t = (o = {}) => {
857
- var t, e;
860
+ }, Re = (i = {}) => {
861
+ var e, t;
858
862
  const {
859
863
  bridge: s,
860
864
  accessToken: r,
861
- use: n = [],
862
- apiOptions: i = {},
865
+ use: o = [],
866
+ apiOptions: n = {},
863
867
  richText: l = {},
864
868
  bridgeUrl: a
865
- } = o;
866
- i.accessToken = i.accessToken || r;
867
- const c = { bridge: s, apiOptions: i };
869
+ } = i;
870
+ n.accessToken = n.accessToken || r;
871
+ const c = { bridge: s, apiOptions: n };
868
872
  let u = {};
869
- n.forEach((g) => {
873
+ o.forEach((g) => {
870
874
  u = { ...u, ...g(c) };
871
875
  }), a && (O = a);
872
- const p = !(typeof window > "u") && ((e = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : e.includes("_storyblok_tk"));
876
+ const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
873
877
  return s !== !1 && p && H(O), T = new v(l.schema), l.resolver && I(T, l.resolver), u;
874
- }, I = (o, t) => {
875
- o.addNode("blok", (e) => {
878
+ }, I = (i, e) => {
879
+ i.addNode("blok", (t) => {
876
880
  let s = "";
877
- return e.attrs.body.forEach((r) => {
878
- s += t(r.component, r);
881
+ return t.attrs.body.forEach((r) => {
882
+ s += e(r.component, r);
879
883
  }), {
880
884
  html: s
881
885
  };
882
886
  });
883
- }, Tt = (o) => !o || !(o != null && o.content.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule")), Pt = (o, t, e) => {
884
- let s = e || T;
887
+ }, _e = (i) => !i || !(i != null && i.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Ce = (i, e, t) => {
888
+ let s = t || T;
885
889
  if (!s) {
886
890
  console.error(
887
891
  "Please initialize the Storyblok SDK before calling the renderRichText function"
888
892
  );
889
893
  return;
890
894
  }
891
- return Tt(o) ? "" : (t && (s = new v(t.schema), t.resolver && I(s, t.resolver)), s.render(o));
892
- }, St = /* @__PURE__ */ A({
895
+ return _e(i) ? "" : (e && (s = new v(e.schema), e.resolver && I(s, e.resolver)), s.render(i));
896
+ }, Te = /* @__PURE__ */ A({
893
897
  __name: "StoryblokComponent",
894
898
  props: {
895
899
  blok: {}
896
900
  },
897
- setup(o, { expose: t }) {
898
- const e = o, s = _();
899
- t({
901
+ setup(i, { expose: e }) {
902
+ const t = i, s = _();
903
+ e({
900
904
  value: s
901
905
  });
902
- const r = typeof $(e.blok.component) != "string", n = N("VueSDKOptions"), i = _(e.blok.component);
903
- return r || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof $(i.value) == "string" && console.error(
904
- `Is the Fallback component "${i.value}" registered properly?`
906
+ const r = typeof $(t.blok.component) != "string", o = N("VueSDKOptions"), n = _(t.blok.component);
907
+ return r || (o.enableFallbackComponent ? (n.value = o.customFallbackComponent ?? "FallbackComponent", typeof $(n.value) == "string" && console.error(
908
+ `Is the Fallback component "${n.value}" registered properly?`
905
909
  )) : console.error(
906
- `Component could not be found for blok "${e.blok.component}"! Is it defined in main.ts as "app.component("${e.blok.component}", ${e.blok.component});"?`
907
- )), (l, a) => (L(), M($(i.value), F({
910
+ `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});"?`
911
+ )), (l, a) => (L(), M($(n.value), F({
908
912
  ref_key: "blokRef",
909
913
  ref: s
910
914
  }, { ...l.$props, ...l.$attrs }), null, 16));
911
915
  }
912
- }), jt = {
913
- beforeMount(o, t) {
914
- if (t.value) {
915
- const e = $t(t.value);
916
- Object.keys(e).length > 0 && (o.setAttribute("data-blok-c", e["data-blok-c"]), o.setAttribute("data-blok-uid", e["data-blok-uid"]), o.classList.add("storyblok__outline"));
916
+ }), Se = {
917
+ beforeMount(i, e) {
918
+ if (e.value) {
919
+ const t = we(e.value);
920
+ Object.keys(t).length > 0 && (i.setAttribute("data-blok-c", t["data-blok-c"]), i.setAttribute("data-blok-uid", t["data-blok-uid"]), i.classList.add("storyblok__outline"));
917
921
  }
918
922
  }
919
- }, E = (o) => {
920
- console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
923
+ }, E = (i) => {
924
+ console.error(`You can't use ${i} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
921
925
  `);
922
926
  };
923
927
  let y = null;
924
- const Ot = () => (y || E("useStoryblokApi"), y), It = async (o, t = {}, e = {}) => {
928
+ const Pe = () => (y || E("useStoryblokApi"), y), Oe = async (i, e = {}, t = {}) => {
925
929
  const s = _(null);
926
- if (e.resolveRelations = e.resolveRelations ?? t.resolve_relations, e.resolveLinks = e.resolveLinks ?? t.resolve_links, z(() => {
927
- s.value && s.value.id && Rt(
930
+ if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, z(() => {
931
+ s.value && s.value.id && $e(
928
932
  s.value.id,
929
933
  (r) => s.value = r,
930
- e
934
+ t
931
935
  );
932
936
  }), y) {
933
937
  const { data: r } = await y.get(
934
- `cdn/stories/${o}`,
935
- t
938
+ `cdn/stories/${i}`,
939
+ e
936
940
  );
937
941
  s.value = r.story;
938
942
  } else
939
943
  E("useStoryblok");
940
944
  return s;
941
- }, Et = {
942
- install(o, t = {}) {
943
- o.directive("editable", jt), o.component("StoryblokComponent", St), t.enableFallbackComponent && !t.customFallbackComponent && o.component(
945
+ }, Ie = {
946
+ install(i, e = {}) {
947
+ i.directive("editable", Se), i.component("StoryblokComponent", Te), e.enableFallbackComponent && !e.customFallbackComponent && i.component(
944
948
  "FallbackComponent",
945
949
  U(() => import("./FallbackComponent-hOszcW1L.mjs"))
946
950
  );
947
- const { storyblokApi: e } = _t(t);
948
- y = e, o.provide("VueSDKOptions", t);
951
+ const { storyblokApi: t } = Re(e);
952
+ y = t, i.provide("VueSDKOptions", e);
949
953
  }
950
954
  };
951
955
  export {
952
956
  v as RichTextResolver,
953
- yt as RichTextSchema,
954
- St as StoryblokComponent,
955
- Et as StoryblokVue,
956
- Ct as apiPlugin,
957
- Pt as renderRichText,
958
- It as useStoryblok,
959
- Ot as useStoryblokApi,
960
- Rt as useStoryblokBridge
957
+ ye as RichTextSchema,
958
+ Te as StoryblokComponent,
959
+ Ie as StoryblokVue,
960
+ xe as apiPlugin,
961
+ Ce as renderRichText,
962
+ Oe as useStoryblok,
963
+ Pe as useStoryblokApi,
964
+ $e as useStoryblokBridge
961
965
  };