@storyblok/vue 8.0.1 → 8.0.3

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,27 +1,27 @@
1
- import { defineComponent as O, ref as S, resolveDynamicComponent as R, inject as N, openBlock as P, createBlock as L, mergeProps as M, onMounted as D, defineAsyncComponent as F } from "vue";
2
- let $ = !1;
3
- const E = [], B = (o) => new Promise((e, t) => {
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
+ let j = !1;
3
+ const x = [], H = (o) => new Promise((t, e) => {
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.");
7
7
  return;
8
8
  }
9
- $ ? r() : E.push(r);
9
+ j ? r() : x.push(r);
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) => t(r), s.onload = (r) => {
14
- E.forEach((n) => n()), $ = !0, e(r);
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);
15
15
  }, document.getElementsByTagName("head")[0].appendChild(s);
16
16
  });
17
- var H = Object.defineProperty, V = (o, e, t) => e in o ? H(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, h = (o, e, t) => (V(o, typeof e != "symbol" ? e + "" : e, t), t);
18
- function x(o) {
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
19
  return !(o !== o || o === 1 / 0 || o === -1 / 0);
20
20
  }
21
- function z(o, e, t) {
22
- if (!x(e))
21
+ function D(o, t, e) {
22
+ if (!C(t))
23
23
  throw new TypeError("Expected `limit` to be a finite number");
24
- if (!x(t))
24
+ if (!C(e))
25
25
  throw new TypeError("Expected `interval` to be a finite number");
26
26
  const s = [];
27
27
  let r = [], n = 0;
@@ -31,7 +31,7 @@ function z(o, e, t) {
31
31
  n--, s.length > 0 && i(), r = r.filter(function(u) {
32
32
  return u !== a;
33
33
  });
34
- }, t);
34
+ }, e);
35
35
  r.indexOf(a) < 0 && r.push(a);
36
36
  const c = s.shift();
37
37
  c.resolve(o.apply(c.self, c.args));
@@ -43,7 +43,7 @@ function z(o, e, t) {
43
43
  reject: p,
44
44
  args: a,
45
45
  self: c
46
- }), n < e && i();
46
+ }), n < t && i();
47
47
  });
48
48
  };
49
49
  return l.abort = function() {
@@ -54,24 +54,24 @@ function z(o, e, t) {
54
54
  }), s.length = 0;
55
55
  }, l;
56
56
  }
57
- class b {
57
+ class k {
58
58
  constructor() {
59
- h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, s = 1) => ({
60
- ...e,
61
- per_page: t,
59
+ h(this, "isCDNUrl", (t = "") => t.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (t, e = 25, s = 1) => ({
60
+ ...t,
61
+ per_page: e,
62
62
  page: s
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, (n, i) => i * 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 = {
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 = {
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 e && r.test(e) ? e.replace(s, (n) => t[n]) : e;
74
+ return t && r.test(t) ? t.replace(s, (n) => e[n]) : t;
75
75
  });
76
76
  }
77
77
  /**
@@ -81,18 +81,18 @@ class b {
81
81
  * @param {Boolean} isArray
82
82
  * @return {String} Stringified object
83
83
  */
84
- stringify(e, t, s) {
84
+ stringify(t, e, s) {
85
85
  const r = [];
86
- for (const n in e) {
87
- if (!Object.prototype.hasOwnProperty.call(e, n))
86
+ for (const n in t) {
87
+ if (!Object.prototype.hasOwnProperty.call(t, n))
88
88
  continue;
89
- const i = e[n], l = s ? "" : encodeURIComponent(n);
89
+ const i = t[n], l = s ? "" : encodeURIComponent(n);
90
90
  let a;
91
91
  typeof i == "object" ? a = this.stringify(
92
92
  i,
93
- t ? t + encodeURIComponent("[" + l + "]") : l,
93
+ e ? e + encodeURIComponent("[" + l + "]") : l,
94
94
  Array.isArray(i)
95
- ) : a = (t ? t + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(i), r.push(a);
95
+ ) : a = (e ? e + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(i), r.push(a);
96
96
  }
97
97
  return r.join("&");
98
98
  }
@@ -101,9 +101,9 @@ class b {
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(e) {
105
- const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", n = "api-ap.storyblok.com", i = "api-ca.storyblok.com";
106
- switch (e) {
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) {
107
107
  case "us":
108
108
  return s;
109
109
  case "cn":
@@ -113,24 +113,24 @@ class b {
113
113
  case "ca":
114
114
  return i;
115
115
  default:
116
- return t;
116
+ return e;
117
117
  }
118
118
  }
119
119
  }
120
- const q = function(o, e) {
121
- const t = {};
120
+ const B = function(o, t) {
121
+ const e = {};
122
122
  for (const s in o) {
123
123
  const r = o[s];
124
- e.indexOf(s) > -1 && r !== null && (t[s] = r);
124
+ t.indexOf(s) > -1 && r !== null && (e[s] = r);
125
125
  }
126
- return t;
127
- }, G = (o) => o === "email", J = () => ({
126
+ return e;
127
+ }, J = (o) => o === "email", K = () => ({
128
128
  singleTag: "hr"
129
- }), K = () => ({
130
- tag: "blockquote"
131
129
  }), Y = () => ({
130
+ tag: "blockquote"
131
+ }), W = () => ({
132
132
  tag: "ul"
133
- }), W = (o) => ({
133
+ }), G = (o) => ({
134
134
  tag: [
135
135
  "pre",
136
136
  {
@@ -138,24 +138,24 @@ const q = function(o, e) {
138
138
  attrs: o.attrs
139
139
  }
140
140
  ]
141
- }), X = () => ({
141
+ }), Q = () => ({
142
142
  singleTag: "br"
143
- }), Z = (o) => ({
143
+ }), X = (o) => ({
144
144
  tag: `h${o.attrs.level}`
145
- }), Q = (o) => ({
145
+ }), Z = (o) => ({
146
146
  singleTag: [
147
147
  {
148
148
  tag: "img",
149
- attrs: q(o.attrs, ["src", "alt", "title"])
149
+ attrs: B(o.attrs, ["src", "alt", "title"])
150
150
  }
151
151
  ]
152
- }), ee = () => ({
152
+ }), tt = () => ({
153
153
  tag: "li"
154
- }), te = () => ({
154
+ }), et = () => ({
155
155
  tag: "ol"
156
- }), se = () => ({
156
+ }), st = () => ({
157
157
  tag: "p"
158
- }), re = (o) => ({
158
+ }), rt = (o) => ({
159
159
  tag: [
160
160
  {
161
161
  tag: "span",
@@ -166,58 +166,58 @@ const q = function(o, e) {
166
166
  }
167
167
  }
168
168
  ]
169
- }), oe = () => ({
169
+ }), ot = () => ({
170
170
  tag: "b"
171
- }), ne = () => ({
171
+ }), nt = () => ({
172
172
  tag: "s"
173
- }), ie = () => ({
173
+ }), it = () => ({
174
174
  tag: "u"
175
- }), ae = () => ({
175
+ }), at = () => ({
176
176
  tag: "strong"
177
- }), le = () => ({
177
+ }), lt = () => ({
178
178
  tag: "code"
179
- }), ce = () => ({
179
+ }), ct = () => ({
180
180
  tag: "i"
181
- }), he = (o) => {
181
+ }), ht = (o) => {
182
182
  if (!o.attrs)
183
183
  return {
184
184
  tag: ""
185
185
  };
186
- const e = new b().escapeHTML, t = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
187
- if (delete t.linktype, t.href && (t.href = e(o.attrs.href || "")), G(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;
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;
191
191
  }
192
192
  return {
193
193
  tag: [
194
194
  {
195
195
  tag: "a",
196
- attrs: t
196
+ attrs: e
197
197
  }
198
198
  ]
199
199
  };
200
- }, ue = (o) => ({
200
+ }, ut = (o) => ({
201
201
  tag: [
202
202
  {
203
203
  tag: "span",
204
204
  attrs: o.attrs
205
205
  }
206
206
  ]
207
- }), pe = () => ({
207
+ }), pt = () => ({
208
208
  tag: "sub"
209
- }), de = () => ({
209
+ }), dt = () => ({
210
210
  tag: "sup"
211
- }), me = (o) => ({
211
+ }), gt = (o) => ({
212
212
  tag: [
213
213
  {
214
214
  tag: "span",
215
215
  attrs: o.attrs
216
216
  }
217
217
  ]
218
- }), ge = (o) => {
219
- var e;
220
- return (e = o.attrs) != null && e.color ? {
218
+ }), ft = (o) => {
219
+ var t;
220
+ return (t = o.attrs) != null && t.color ? {
221
221
  tag: [
222
222
  {
223
223
  tag: "span",
@@ -229,9 +229,9 @@ const q = function(o, e) {
229
229
  } : {
230
230
  tag: ""
231
231
  };
232
- }, fe = (o) => {
233
- var e;
234
- return (e = o.attrs) != null && e.color ? {
232
+ }, mt = (o) => {
233
+ var t;
234
+ return (t = o.attrs) != null && t.color ? {
235
235
  tag: [
236
236
  {
237
237
  tag: "span",
@@ -243,61 +243,61 @@ const q = function(o, e) {
243
243
  } : {
244
244
  tag: ""
245
245
  };
246
- }, ye = {
246
+ }, yt = {
247
247
  nodes: {
248
- horizontal_rule: J,
249
- blockquote: K,
250
- bullet_list: Y,
251
- code_block: W,
252
- hard_break: X,
253
- heading: Z,
254
- image: Q,
255
- list_item: ee,
256
- ordered_list: te,
257
- paragraph: se,
258
- emoji: re
248
+ horizontal_rule: K,
249
+ blockquote: Y,
250
+ bullet_list: W,
251
+ code_block: G,
252
+ hard_break: Q,
253
+ heading: X,
254
+ image: Z,
255
+ list_item: tt,
256
+ ordered_list: et,
257
+ paragraph: st,
258
+ emoji: rt
259
259
  },
260
260
  marks: {
261
- bold: oe,
262
- strike: ne,
263
- underline: ie,
264
- strong: ae,
265
- code: le,
266
- italic: ce,
267
- link: he,
268
- styled: ue,
269
- subscript: pe,
270
- superscript: de,
271
- anchor: me,
272
- highlight: ge,
273
- textStyle: fe
274
- }
275
- }, be = function(o) {
276
- const e = {
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 = {
277
277
  "&": "&amp;",
278
278
  "<": "&lt;",
279
279
  ">": "&gt;",
280
280
  '"': "&quot;",
281
281
  "'": "&#39;"
282
- }, t = /[&<>"']/g, s = RegExp(t.source);
283
- return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
282
+ }, e = /[&<>"']/g, s = RegExp(e.source);
283
+ return o && s.test(o) ? o.replace(e, (r) => t[r]) : o;
284
284
  };
285
285
  class v {
286
- constructor(e) {
287
- h(this, "marks"), h(this, "nodes"), e || (e = ye), this.marks = e.marks || [], this.nodes = e.nodes || [];
286
+ constructor(t) {
287
+ h(this, "marks"), h(this, "nodes"), t || (t = yt), this.marks = t.marks || [], this.nodes = t.nodes || [];
288
288
  }
289
- addNode(e, t) {
290
- this.nodes[e] = t;
289
+ addNode(t, e) {
290
+ this.nodes[t] = e;
291
291
  }
292
- addMark(e, t) {
293
- this.marks[e] = t;
292
+ addMark(t, e) {
293
+ this.marks[t] = e;
294
294
  }
295
- render(e, t = { optimizeImages: !1 }) {
296
- if (e && e.content && Array.isArray(e.content)) {
295
+ render(t, e = { optimizeImages: !1 }) {
296
+ if (t && t.content && Array.isArray(t.content)) {
297
297
  let s = "";
298
- return e.content.forEach((r) => {
298
+ return t.content.forEach((r) => {
299
299
  s += this.renderNode(r);
300
- }), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
300
+ }), e.optimizeImages ? this.optimizeImages(s, e.optimizeImages) : s;
301
301
  }
302
302
  return console.warn(
303
303
  `The render method must receive an Object with a "content" field.
@@ -326,54 +326,54 @@ class v {
326
326
  }`
327
327
  ), "";
328
328
  }
329
- optimizeImages(e, t) {
329
+ optimizeImages(t, e) {
330
330
  let s = 0, r = 0, n = "", i = "";
331
- 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}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = "/filters" + i))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
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
332
  const l = s > 0 || r > 0 || i.length > 0 ? `${s}x${r}${i}` : "";
333
- return e = e.replace(
333
+ return t = t.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 t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
336
+ ), typeof e != "boolean" && (e.sizes || e.srcset) && (t = t.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
- const m = {
343
- srcset: (c = t.srcset) == null ? void 0 : c.map((d) => {
342
+ const g = {
343
+ srcset: (c = e.srcset) == null ? void 0 : c.map((d) => {
344
344
  if (typeof d == "number")
345
345
  return `//${p}/m/${d}x0${i} ${d}w`;
346
346
  if (typeof d == "object" && d.length === 2) {
347
- let k = 0, C = 0;
348
- return typeof d[0] == "number" && (k = d[0]), typeof d[1] == "number" && (C = d[1]), `//${p}/m/${k}x${C}${i} ${k}w`;
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`;
349
349
  }
350
350
  }).join(", "),
351
- sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
351
+ sizes: (u = e.sizes) == null ? void 0 : u.map((d) => d).join(", ")
352
352
  };
353
- let _ = "";
354
- return m.srcset && (_ += `srcset="${m.srcset}" `), m.sizes && (_ += `sizes="${m.sizes}" `), a.replace(/<img/g, `<img ${_.trim()}`);
353
+ let f = "";
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
- })), e;
357
+ })), t;
358
358
  }
359
- renderNode(e) {
360
- const t = [];
361
- e.marks && e.marks.forEach((r) => {
359
+ renderNode(t) {
360
+ const e = [];
361
+ t.marks && t.marks.forEach((r) => {
362
362
  const n = this.getMatchingMark(r);
363
- n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
363
+ n && n.tag !== "" && e.push(this.renderOpeningTag(n.tag));
364
364
  });
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) => {
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
369
  const n = this.getMatchingMark(r);
370
- n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
371
- }), t.join("");
370
+ n && n.tag !== "" && e.push(this.renderClosingTag(n.tag));
371
+ }), e.join("");
372
372
  }
373
- renderTag(e, t) {
374
- return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
373
+ renderTag(t, e) {
374
+ return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
375
375
  if (s.constructor === String)
376
- return `<${s}${t}>`;
376
+ return `<${s}${e}>`;
377
377
  {
378
378
  let r = `<${s.tag}`;
379
379
  if (s.attrs)
@@ -381,46 +381,46 @@ class v {
381
381
  const i = s.attrs[n];
382
382
  i !== null && (r += ` ${n}="${i}"`);
383
383
  }
384
- return `${r}${t}>`;
384
+ return `${r}${e}>`;
385
385
  }
386
386
  }).join("");
387
387
  }
388
- renderOpeningTag(e) {
389
- return this.renderTag(e, "");
388
+ renderOpeningTag(t) {
389
+ return this.renderTag(t, "");
390
390
  }
391
- renderClosingTag(e) {
392
- return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
391
+ renderClosingTag(t) {
392
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
393
393
  }
394
- getMatchingNode(e) {
395
- const t = this.nodes[e.type];
396
- if (typeof t == "function")
397
- return t(e);
394
+ getMatchingNode(t) {
395
+ const e = this.nodes[t.type];
396
+ if (typeof e == "function")
397
+ return e(t);
398
398
  }
399
- getMatchingMark(e) {
400
- const t = this.marks[e.type];
401
- if (typeof t == "function")
402
- return t(e);
399
+ getMatchingMark(t) {
400
+ const e = this.marks[t.type];
401
+ if (typeof e == "function")
402
+ return e(t);
403
403
  }
404
- renderEmoji(e) {
405
- if (e.attrs.emoji)
406
- return e.attrs.emoji;
407
- const t = [
404
+ renderEmoji(t) {
405
+ if (t.attrs.emoji)
406
+ return t.attrs.emoji;
407
+ const e = [
408
408
  {
409
409
  tag: "img",
410
410
  attrs: {
411
- src: e.attrs.fallbackImage,
411
+ src: t.attrs.fallbackImage,
412
412
  draggable: "false",
413
413
  loading: "lazy",
414
414
  align: "absmiddle"
415
415
  }
416
416
  }
417
417
  ];
418
- return this.renderTag(t, " /");
418
+ return this.renderTag(e, " /");
419
419
  }
420
420
  }
421
- class ve {
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"), 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 = {};
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 = {};
424
424
  }
425
425
  /**
426
426
  *
@@ -428,53 +428,56 @@ class ve {
428
428
  * @param params ISbStoriesParams
429
429
  * @returns Promise<ISbResponse | Error>
430
430
  */
431
- get(e, t) {
432
- return this.url = e, this.parameters = t, this._methodHandler("get");
431
+ get(t, e) {
432
+ return this.url = t, this.parameters = e, this._methodHandler("get");
433
433
  }
434
- post(e, t) {
435
- return this.url = e, this.parameters = t, this._methodHandler("post");
434
+ post(t, e) {
435
+ return this.url = t, this.parameters = e, this._methodHandler("post");
436
436
  }
437
- put(e, t) {
438
- return this.url = e, this.parameters = t, this._methodHandler("put");
437
+ put(t, e) {
438
+ return this.url = t, this.parameters = e, this._methodHandler("put");
439
439
  }
440
- delete(e, t) {
441
- return this.url = e, this.parameters = t, this._methodHandler("delete");
440
+ delete(t, e) {
441
+ return this.url = t, this.parameters = e, this._methodHandler("delete");
442
442
  }
443
- async _responseHandler(e) {
444
- const t = [], s = {
443
+ async _responseHandler(t) {
444
+ const e = [], s = {
445
445
  data: {},
446
446
  headers: {},
447
447
  status: 0,
448
448
  statusText: ""
449
449
  };
450
- e.status !== 204 && await e.json().then((r) => {
450
+ t.status !== 204 && await t.json().then((r) => {
451
451
  s.data = r;
452
452
  });
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
- }
457
- async _methodHandler(e) {
458
- let t = `${this.baseURL}${this.url}`, s = null;
459
- if (e === "get") {
460
- const a = new b();
461
- t = `${this.baseURL}${this.url}?${a.stringify(
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;
456
+ }
457
+ async _methodHandler(t) {
458
+ let e = `${this.baseURL}${this.url}`, s = null;
459
+ if (t === "get") {
460
+ const a = new k();
461
+ e = `${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(t), n = new AbortController(), { signal: i } = n;
466
+ const r = new URL(e), n = new AbortController(), { signal: i } = n;
467
467
  let l;
468
468
  this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
469
469
  try {
470
470
  const a = await fetch(`${r}`, {
471
- method: e,
471
+ method: t,
472
472
  headers: this.headers,
473
473
  body: s,
474
- signal: i
474
+ signal: i,
475
+ ...this.fetchOptions
475
476
  });
476
477
  this.timeout && clearTimeout(l);
477
- const c = await this._responseHandler(a);
478
+ const c = await this._responseHandler(
479
+ a
480
+ );
478
481
  return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
479
482
  } catch (a) {
480
483
  return {
@@ -482,116 +485,119 @@ class ve {
482
485
  };
483
486
  }
484
487
  }
488
+ setFetchOptions(t = {}) {
489
+ Object.keys(t).length > 0 && "method" in t && delete t.method, this.fetchOptions = { ...t };
490
+ }
485
491
  eject() {
486
492
  this.ejectInterceptor = !0;
487
493
  }
488
- _statusHandler(e) {
489
- const t = /20[0-6]/g;
494
+ _statusHandler(t) {
495
+ const e = /20[0-6]/g;
490
496
  return new Promise((s, r) => {
491
- if (t.test(`${e.status}`))
492
- return s(e);
497
+ if (e.test(`${t.status}`))
498
+ return s(t);
493
499
  const n = {
494
- message: e.statusText,
495
- status: e.status,
496
- response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
500
+ message: t.statusText,
501
+ status: t.status,
502
+ response: Array.isArray(t.data) ? t.data[0] : t.data.error || t.data.slug
497
503
  };
498
504
  r(n);
499
505
  });
500
506
  }
501
507
  }
502
- var _e = { NVM_INC: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/include/node", TERM_PROGRAM: "iTerm.app", NODE: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node", NVM_CD_FLAGS: "-q", INIT_CWD: "/Users/lisilinhart/Code/storyblok-js-client", SHELL: "/bin/zsh", TERM: "xterm-256color", TMPDIR: "/var/folders/9v/t3hq3s9n2rj6_x9jlsjjq95w0000gn/T/", npm_config_metrics_registry: "https://registry.npmjs.org/", npm_config_global_prefix: "/Users/lisilinhart/.nvm/versions/node/v18.16.0", TERM_PROGRAM_VERSION: "3.4.20", TERM_SESSION_ID: "w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF", COLOR: "0", npm_config_noproxy: "", ZSH: "/Users/lisilinhart/.oh-my-zsh", npm_config_local_prefix: "/Users/lisilinhart/Code/storyblok-js-client", USER: "lisilinhart", NVM_DIR: "/Users/lisilinhart/.nvm", COMMAND_MODE: "unix2003", npm_config_globalconfig: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/etc/npmrc", SSH_AUTH_SOCK: "/private/tmp/com.apple.launchd.oUounWp9qr/Listeners", __CF_USER_TEXT_ENCODING: "0x1F5:0x0:0x5C", npm_execpath: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/bin/npm-cli.js", PAGER: "less", npm_package_integrity: "null", LSCOLORS: "Gxfxcxdxbxegedabagacad", PATH: "/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/usr/local/sbin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.yarn/bin:/Users/lisilinhart/.config/yarn/global/node_modules/.bin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin:/Users/lisilinhart/bin:/usr/local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/lisilinhart/.cargo/bin", RUBY_CONFIGURE_OPTS: "--with-openssl-dir=/usr/local/opt/openssl@1.1", LaunchInstanceID: "9D2A03D3-35CC-4CDD-810D-0D5C25991BBB", _: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node", npm_package_json: "/Users/lisilinhart/Code/storyblok-js-client/package.json", __CFBundleIdentifier: "com.googlecode.iterm2", npm_config_init_module: "/Users/lisilinhart/.npm-init.js", npm_config_userconfig: "/Users/lisilinhart/.npmrc", PWD: "/Users/lisilinhart/Code/storyblok-js-client", npm_command: "run-script", P9K_SSH: "0", EDITOR: "vi", npm_lifecycle_event: "build", LANG: "de_AT.UTF-8", P9K_TTY: "old", npm_package_name: "storyblok-js-client", ITERM_PROFILE: "Default", XPC_FLAGS: "0x0", RBENV_SHELL: "zsh", npm_config_node_gyp: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js", XPC_SERVICE_NAME: "0", npm_package_version: "6.4.1", COLORFGBG: "7;0", HOME: "/Users/lisilinhart", SHLVL: "3", npm_package_resolved: "/Users/lisilinhart/Code/storyblok-js-client", LC_TERMINAL_VERSION: "3.4.20", ITERM_SESSION_ID: "w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF", LOGNAME: "lisilinhart", LESS: "-R", npm_config_cache: "/Users/lisilinhart/.npm", npm_lifecycle_script: "node vite.build.mjs && tsc", NVM_BIN: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin", npm_config_user_agent: "npm/9.5.1 node/v18.16.0 darwin x64 workspaces/false", LC_TERMINAL: "iTerm2", SECURITYSESSIONID: "186a1", COLORTERM: "truecolor", npm_config_prefix: "/Users/lisilinhart/.nvm/versions/node/v18.16.0", npm_node_execpath: "/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node", NODE_ENV: "production" };
503
- const j = "SB-Agent", w = {
508
+ var vt = { npm_package_version: "6.6.2" };
509
+ const P = "SB-Agent", R = {
504
510
  defaultAgentName: "SB-JS-CLIENT",
505
511
  defaultAgentVersion: "SB-Agent-Version",
506
- packageVersion: _e.npm_package_version
512
+ packageVersion: vt.npm_package_version
507
513
  };
508
- let y = {};
509
- const g = {};
510
- class ke {
514
+ let b = {};
515
+ const m = {};
516
+ class wt {
511
517
  /**
512
518
  *
513
519
  * @param config ISbConfig interface
514
520
  * @param endpoint string, optional
515
521
  */
516
- constructor(e, t) {
522
+ constructor(t, e) {
517
523
  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");
518
- let s = e.endpoint || t;
519
- if (!s) {
520
- const i = new b().getRegionURL, l = e.https === !1 ? "http" : "https";
521
- e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
522
- }
523
- const r = new Headers();
524
- if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers)
525
- for (const i in e.headers)
526
- r.set(i, e.headers[i]);
527
- r.has(j) || (r.set(j, w.defaultAgentName), r.set(
528
- w.defaultAgentVersion,
529
- w.packageVersion
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(
532
+ R.defaultAgentVersion,
533
+ R.packageVersion
530
534
  ));
531
- let n = 5;
532
- e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = 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 = z(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new ve({
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({
533
537
  baseURL: s,
534
- timeout: e.timeout || 0,
535
- headers: r,
536
- responseInterceptor: e.responseInterceptor,
537
- fetch: e.fetch
538
+ timeout: t.timeout || 0,
539
+ headers: i,
540
+ responseInterceptor: t.responseInterceptor,
541
+ fetch: t.fetch
538
542
  });
539
543
  }
540
- setComponentResolver(e) {
541
- this.richTextResolver.addNode("blok", (t) => {
544
+ setComponentResolver(t) {
545
+ this.richTextResolver.addNode("blok", (e) => {
542
546
  let s = "";
543
- return t.attrs.body && t.attrs.body.forEach((r) => {
544
- s += e(r.component, r);
547
+ return e.attrs.body && e.attrs.body.forEach((r) => {
548
+ s += t(r.component, r);
545
549
  }), {
546
550
  html: s
547
551
  };
548
552
  });
549
553
  }
550
- parseParams(e) {
551
- return e.token || (e.token = this.getToken()), e.cv || (e.cv = g[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
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;
552
556
  }
553
- factoryParamOptions(e, t) {
554
- return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
557
+ factoryParamOptions(t, e) {
558
+ return this.helpers.isCDNUrl(t) ? this.parseParams(e) : e;
555
559
  }
556
- makeRequest(e, t, s, r) {
560
+ makeRequest(t, e, s, r) {
557
561
  const n = this.factoryParamOptions(
558
- e,
559
- this.helpers.getOptionsPage(t, s, r)
562
+ t,
563
+ this.helpers.getOptionsPage(e, s, r)
560
564
  );
561
- return this.cacheResponse(e, n);
562
- }
563
- get(e, t) {
564
- t || (t = {});
565
- const s = `/${e}`, r = this.factoryParamOptions(s, t);
566
- return this.cacheResponse(s, r);
567
- }
568
- async getAll(e, t, s) {
569
- const r = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, i = n.split("/"), l = s || i[i.length - 1], a = 1, c = await this.makeRequest(n, t, r, a), u = c.total ? Math.ceil(c.total / r) : 1, p = await this.helpers.asyncMap(
570
- this.helpers.range(a, u),
571
- (m) => this.makeRequest(n, t, r, m + 1)
565
+ return this.cacheResponse(t, n);
566
+ }
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);
571
+ }
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;
574
+ this.client.setFetchOptions(r);
575
+ const g = await this.helpers.asyncMap(
576
+ this.helpers.range(c, p),
577
+ (f) => this.makeRequest(i, e, n, f + 1)
572
578
  );
573
579
  return this.helpers.flatMap(
574
- [c, ...p],
575
- (m) => Object.values(m.data[l])
580
+ [u, ...g],
581
+ (f) => Object.values(f.data[a])
576
582
  );
577
583
  }
578
- post(e, t) {
579
- const s = `/${e}`;
580
- return Promise.resolve(this.throttle("post", s, t));
584
+ post(t, e, s) {
585
+ const r = `/${t}`;
586
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("post", r, e));
581
587
  }
582
- put(e, t) {
583
- const s = `/${e}`;
584
- return Promise.resolve(this.throttle("put", s, t));
588
+ put(t, e, s) {
589
+ const r = `/${t}`;
590
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("put", r, e));
585
591
  }
586
- delete(e, t) {
587
- const s = `/${e}`;
588
- return Promise.resolve(this.throttle("delete", s, t));
592
+ delete(t, e, s) {
593
+ const r = `/${t}`;
594
+ return this.client.setFetchOptions(s), Promise.resolve(this.throttle("delete", r, e));
589
595
  }
590
- getStories(e) {
591
- return this.get("cdn/stories", e);
596
+ getStories(t, e) {
597
+ return this.client.setFetchOptions(e), this.get("cdn/stories", t);
592
598
  }
593
- getStory(e, t) {
594
- return this.get(`cdn/stories/${e}`, t);
599
+ getStory(t, e, s) {
600
+ return this.client.setFetchOptions(s), this.get(`cdn/stories/${t}`, e);
595
601
  }
596
602
  getToken() {
597
603
  return this.accessToken;
@@ -599,11 +605,11 @@ class ke {
599
605
  ejectInterceptor() {
600
606
  this.client.eject();
601
607
  }
602
- _cleanCopy(e) {
603
- return JSON.parse(JSON.stringify(e));
608
+ _cleanCopy(t) {
609
+ return JSON.parse(JSON.stringify(t));
604
610
  }
605
- _insertLinks(e, t, s) {
606
- const r = e[t];
611
+ _insertLinks(t, e, s) {
612
+ const r = t[e];
607
613
  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]));
608
614
  }
609
615
  /**
@@ -612,15 +618,15 @@ class ke {
612
618
  * @param uuid The uuid of the story
613
619
  * @returns string | object
614
620
  */
615
- getStoryReference(e, t) {
616
- return this.relations[e][t] ? (this.stringifiedStoriesCache[t] || (this.stringifiedStoriesCache[t] = JSON.stringify(
617
- this.relations[e][t]
618
- )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
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;
619
625
  }
620
- _insertRelations(e, t, s, r) {
621
- 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((n) => this.getStoryReference(r, n)).filter(Boolean)));
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)));
622
628
  }
623
- iterateTree(e, t, s) {
629
+ iterateTree(t, e, s) {
624
630
  const r = (n) => {
625
631
  if (n != null) {
626
632
  if (n.constructor === Array)
@@ -633,7 +639,7 @@ class ke {
633
639
  (n.component && n._uid || n.type === "link") && (this._insertRelations(
634
640
  n,
635
641
  i,
636
- t,
642
+ e,
637
643
  s
638
644
  ), this._insertLinks(
639
645
  n,
@@ -643,21 +649,21 @@ class ke {
643
649
  }
644
650
  }
645
651
  };
646
- r(e.content);
652
+ r(t.content);
647
653
  }
648
- async resolveLinks(e, t, s) {
654
+ async resolveLinks(t, e, s) {
649
655
  let r = [];
650
- if (e.link_uuids) {
651
- const n = e.link_uuids.length, i = [], l = 50;
656
+ if (t.link_uuids) {
657
+ const n = t.link_uuids.length, i = [], l = 50;
652
658
  for (let a = 0; a < n; a += l) {
653
659
  const c = Math.min(n, a + l);
654
- i.push(e.link_uuids.slice(a, c));
660
+ i.push(t.link_uuids.slice(a, c));
655
661
  }
656
662
  for (let a = 0; a < i.length; a++)
657
663
  (await this.getStories({
658
664
  per_page: l,
659
- language: t.language,
660
- version: t.version,
665
+ language: e.language,
666
+ version: e.version,
661
667
  by_uuids: i[a].join(",")
662
668
  })).data.stories.forEach(
663
669
  (c) => {
@@ -665,7 +671,7 @@ class ke {
665
671
  }
666
672
  );
667
673
  } else
668
- r = e.links;
674
+ r = t.links;
669
675
  r.forEach((n) => {
670
676
  this.links[s][n.uuid] = {
671
677
  ...n,
@@ -673,26 +679,26 @@ class ke {
673
679
  };
674
680
  });
675
681
  }
676
- async resolveRelations(e, t, s) {
682
+ async resolveRelations(t, e, s) {
677
683
  let r = [];
678
- if (e.rel_uuids) {
679
- const n = e.rel_uuids.length, i = [], l = 50;
684
+ if (t.rel_uuids) {
685
+ const n = t.rel_uuids.length, i = [], l = 50;
680
686
  for (let a = 0; a < n; a += l) {
681
687
  const c = Math.min(n, a + l);
682
- i.push(e.rel_uuids.slice(a, c));
688
+ i.push(t.rel_uuids.slice(a, c));
683
689
  }
684
690
  for (let a = 0; a < i.length; a++)
685
691
  (await this.getStories({
686
692
  per_page: l,
687
- language: t.language,
688
- version: t.version,
693
+ language: e.language,
694
+ version: e.version,
689
695
  by_uuids: i[a].join(","),
690
- excluding_fields: t.excluding_fields
696
+ excluding_fields: e.excluding_fields
691
697
  })).data.stories.forEach((c) => {
692
698
  r.push(c);
693
699
  });
694
700
  } else
695
- r = e.rels;
701
+ r = t.rels;
696
702
  r && r.length > 0 && r.forEach((n) => {
697
703
  this.relations[s][n.uuid] = {
698
704
  ...n,
@@ -700,24 +706,33 @@ class ke {
700
706
  };
701
707
  });
702
708
  }
703
- async resolveStories(e, t, s) {
709
+ /**
710
+ *
711
+ * @param responseData
712
+ * @param params
713
+ * @param resolveId
714
+ * @description Resolves the relations and links of the stories
715
+ * @returns Promise<void>
716
+ *
717
+ */
718
+ async resolveStories(t, e, s) {
704
719
  var r, n;
705
720
  let i = [];
706
- 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"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
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)
707
722
  for (const l in this.relations[s])
708
723
  this.iterateTree(
709
724
  this.relations[s][l],
710
725
  i,
711
726
  s
712
727
  );
713
- e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
728
+ t.story ? this.iterateTree(t.story, i, s) : t.stories.forEach((l) => {
714
729
  this.iterateTree(l, i, s);
715
730
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
716
731
  }
717
- async cacheResponse(e, t, s) {
732
+ async cacheResponse(t, e, s) {
718
733
  (typeof s > "u" || !s) && (s = 0);
719
- const r = this.helpers.stringify({ url: e, params: t }), n = this.cacheProvider();
720
- if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
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") {
721
736
  const i = await n.get(r);
722
737
  if (i)
723
738
  return Promise.resolve(i);
@@ -725,7 +740,9 @@ class ke {
725
740
  return new Promise(async (i, l) => {
726
741
  var a;
727
742
  try {
728
- const c = await this.throttle("get", e, t);
743
+ const c = await this.throttle("get", t, e);
744
+ if (c.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
745
+ 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);
729
746
  if (c.status !== 200)
730
747
  return l(c);
731
748
  let u = { data: c.data, headers: c.headers };
@@ -734,40 +751,41 @@ class ke {
734
751
  total: c.headers["per-page"] ? parseInt(c.headers.total) : 0
735
752
  })), u.data.story || u.data.stories) {
736
753
  const p = this.resolveCounter = ++this.resolveCounter % 1e3;
737
- await this.resolveStories(u.data, t, `${p}`);
754
+ await this.resolveStories(u.data, e, `${p}`);
738
755
  }
739
- return t.version === "published" && e != "/cdn/spaces/me" && await n.set(r, u), u.data.cv && t.token && (t.version === "draft" && g[t.token] != u.data.cv && await this.flushCache(), g[t.token] = t.cv ? t.cv : u.data.cv), i(u);
756
+ 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);
740
757
  } catch (c) {
741
- if (c.response && c.response.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
742
- return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(i).catch(l);
743
758
  l(c);
744
759
  }
745
760
  });
746
761
  }
747
- throttledRequest(e, t, s) {
748
- return this.client[e](t, s);
762
+ throttledRequest(t, e, s) {
763
+ return this.client[t](e, s);
749
764
  }
750
765
  cacheVersions() {
751
- return g;
766
+ return m;
752
767
  }
753
768
  cacheVersion() {
754
- return g[this.accessToken];
769
+ return m[this.accessToken];
770
+ }
771
+ setCacheVersion(t) {
772
+ this.accessToken && (m[this.accessToken] = t);
755
773
  }
756
774
  cacheProvider() {
757
775
  switch (this.cache.type) {
758
776
  case "memory":
759
777
  return {
760
- get(e) {
761
- return Promise.resolve(y[e]);
778
+ get(t) {
779
+ return Promise.resolve(b[t]);
762
780
  },
763
781
  getAll() {
764
- return Promise.resolve(y);
782
+ return Promise.resolve(b);
765
783
  },
766
- set(e, t) {
767
- return y[e] = t, Promise.resolve(void 0);
784
+ set(t, e) {
785
+ return b[t] = e, Promise.resolve(void 0);
768
786
  },
769
787
  flush() {
770
- return y = {}, Promise.resolve(void 0);
788
+ return b = {}, Promise.resolve(void 0);
771
789
  }
772
790
  };
773
791
  case "custom":
@@ -794,32 +812,32 @@ class ke {
794
812
  return await this.cacheProvider().flush(), this;
795
813
  }
796
814
  }
797
- const xe = (o = {}) => {
798
- const { apiOptions: e } = o;
799
- if (!e.accessToken) {
815
+ const Ct = (o = {}) => {
816
+ const { apiOptions: t } = o;
817
+ if (!t.accessToken) {
800
818
  console.error(
801
819
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
802
820
  );
803
821
  return;
804
822
  }
805
- return { storyblokApi: new ke(e) };
806
- }, Re = (o) => {
823
+ return { storyblokApi: new wt(t) };
824
+ }, $t = (o) => {
807
825
  if (typeof o != "object" || typeof o._editable > "u")
808
826
  return {};
809
827
  try {
810
- const e = JSON.parse(
828
+ const t = JSON.parse(
811
829
  o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
812
830
  );
813
- return e ? {
814
- "data-blok-c": JSON.stringify(e),
815
- "data-blok-uid": e.id + "-" + e.uid
831
+ return t ? {
832
+ "data-blok-c": JSON.stringify(t),
833
+ "data-blok-uid": t.id + "-" + t.uid
816
834
  } : {};
817
835
  } catch {
818
836
  return {};
819
837
  }
820
838
  };
821
- let T, I = "https://app.storyblok.com/f/storyblok-v2-latest.js";
822
- const we = (o, e, t = {}) => {
839
+ let T, O = "https://app.storyblok.com/f/storyblok-v2-latest.js";
840
+ const Rt = (o, t, e = {}) => {
823
841
  var s;
824
842
  const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
825
843
  "_storyblok"
@@ -830,13 +848,13 @@ const we = (o, e, t = {}) => {
830
848
  return;
831
849
  }
832
850
  window.storyblokRegisterEvent(() => {
833
- new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
834
- i.action === "input" && i.story.id === o ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === o && window.location.reload();
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();
835
853
  });
836
854
  });
837
855
  }
838
- }, Se = (o = {}) => {
839
- var e, t;
856
+ }, _t = (o = {}) => {
857
+ var t, e;
840
858
  const {
841
859
  bridge: s,
842
860
  accessToken: r,
@@ -848,96 +866,96 @@ const we = (o, e, t = {}) => {
848
866
  i.accessToken = i.accessToken || r;
849
867
  const c = { bridge: s, apiOptions: i };
850
868
  let u = {};
851
- n.forEach((m) => {
852
- u = { ...u, ...m(c) };
853
- }), a && (I = a);
854
- const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
855
- return s !== !1 && p && B(I), T = new v(l.schema), l.resolver && U(T, l.resolver), u;
856
- }, U = (o, e) => {
857
- o.addNode("blok", (t) => {
869
+ n.forEach((g) => {
870
+ u = { ...u, ...g(c) };
871
+ }), 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"));
873
+ 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) => {
858
876
  let s = "";
859
- return t.attrs.body.forEach((r) => {
860
- s += e(r.component, r);
877
+ return e.attrs.body.forEach((r) => {
878
+ s += t(r.component, r);
861
879
  }), {
862
880
  html: s
863
881
  };
864
882
  });
865
- }, Te = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), je = (o, e, t) => {
866
- let s = t || T;
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;
867
885
  if (!s) {
868
886
  console.error(
869
887
  "Please initialize the Storyblok SDK before calling the renderRichText function"
870
888
  );
871
889
  return;
872
890
  }
873
- return Te(o) ? "" : (e && (s = new v(e.schema), e.resolver && U(s, e.resolver)), s.render(o));
874
- }, Ce = /* @__PURE__ */ O({
891
+ return Tt(o) ? "" : (t && (s = new v(t.schema), t.resolver && I(s, t.resolver)), s.render(o));
892
+ }, St = /* @__PURE__ */ A({
875
893
  __name: "StoryblokComponent",
876
894
  props: {
877
895
  blok: {}
878
896
  },
879
- setup(o, { expose: e }) {
880
- const t = o, s = S();
881
- e({
897
+ setup(o, { expose: t }) {
898
+ const e = o, s = _();
899
+ t({
882
900
  value: s
883
901
  });
884
- const r = typeof R(t.blok.component) != "string", n = N("VueSDKOptions"), i = S(t.blok.component);
885
- return r || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof R(i.value) == "string" && console.error(
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(
886
904
  `Is the Fallback component "${i.value}" registered properly?`
887
905
  )) : console.error(
888
- `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});"?`
889
- )), (l, a) => (P(), L(R(i.value), M({
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({
890
908
  ref_key: "blokRef",
891
909
  ref: s
892
910
  }, { ...l.$props, ...l.$attrs }), null, 16));
893
911
  }
894
- }), $e = {
895
- beforeMount(o, e) {
896
- if (e.value) {
897
- const t = Re(e.value);
898
- Object.keys(t).length > 0 && (o.setAttribute("data-blok-c", t["data-blok-c"]), o.setAttribute("data-blok-uid", t["data-blok-uid"]), o.classList.add("storyblok__outline"));
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"));
899
917
  }
900
918
  }
901
- }, A = (o) => {
919
+ }, E = (o) => {
902
920
  console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
903
921
  `);
904
922
  };
905
- let f = null;
906
- const Ie = () => (f || A("useStoryblokApi"), f), Ue = async (o, e = {}, t = {}) => {
907
- const s = S(null);
908
- if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, D(() => {
909
- s.value && s.value.id && we(
923
+ let y = null;
924
+ const Ot = () => (y || E("useStoryblokApi"), y), It = async (o, t = {}, e = {}) => {
925
+ 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(
910
928
  s.value.id,
911
929
  (r) => s.value = r,
912
- t
930
+ e
913
931
  );
914
- }), f) {
915
- const { data: r } = await f.get(
932
+ }), y) {
933
+ const { data: r } = await y.get(
916
934
  `cdn/stories/${o}`,
917
- e
935
+ t
918
936
  );
919
937
  s.value = r.story;
920
938
  } else
921
- A("useStoryblok");
939
+ E("useStoryblok");
922
940
  return s;
923
- }, Ae = {
924
- install(o, e = {}) {
925
- o.directive("editable", $e), o.component("StoryblokComponent", Ce), e.enableFallbackComponent && !e.customFallbackComponent && o.component(
941
+ }, Et = {
942
+ install(o, t = {}) {
943
+ o.directive("editable", jt), o.component("StoryblokComponent", St), t.enableFallbackComponent && !t.customFallbackComponent && o.component(
926
944
  "FallbackComponent",
927
- F(() => import("./FallbackComponent-hOszcW1L.mjs"))
945
+ U(() => import("./FallbackComponent-hOszcW1L.mjs"))
928
946
  );
929
- const { storyblokApi: t } = Se(e);
930
- f = t, o.provide("VueSDKOptions", e);
947
+ const { storyblokApi: e } = _t(t);
948
+ y = e, o.provide("VueSDKOptions", t);
931
949
  }
932
950
  };
933
951
  export {
934
952
  v as RichTextResolver,
935
- ye as RichTextSchema,
936
- Ce as StoryblokComponent,
937
- Ae as StoryblokVue,
938
- xe as apiPlugin,
939
- je as renderRichText,
940
- Ue as useStoryblok,
941
- Ie as useStoryblokApi,
942
- we as useStoryblokBridge
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
943
961
  };