@storyblok/vue 6.1.0 → 6.3.0

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,407 +1,561 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a2, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a2, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a2, prop, b[prop]);
1
+ import { defineComponent as P, openBlock as j, createBlock as x, resolveDynamicComponent as A, normalizeProps as C, guardReactiveProps as M, ref as N, onMounted as I } from "vue";
2
+ import q from "axios";
3
+ var L = Object.defineProperty, z = Object.defineProperties, B = Object.getOwnPropertyDescriptors, v = Object.getOwnPropertySymbols, D = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable, b = (n, t, e) => t in n ? L(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, h = (n, t) => {
4
+ for (var e in t || (t = {}))
5
+ D.call(t, e) && b(n, e, t[e]);
6
+ if (v)
7
+ for (var e of v(t))
8
+ U.call(t, e) && b(n, e, t[e]);
9
+ return n;
10
+ }, y = (n, t) => z(n, B(t));
11
+ let _ = !1;
12
+ const T = [], V = (n) => new Promise((t, e) => {
13
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
14
+ if (window.location === window.parent.location) {
15
+ console.warn("You are not in Draft Mode or in the Visual Editor.");
16
+ return;
14
17
  }
15
- return a2;
16
- };
17
- import { defineComponent, openBlock, createBlock, resolveDynamicComponent, normalizeProps, guardReactiveProps, ref, onMounted } from "vue";
18
- import e from "axios";
19
- var __defProp2 = Object.defineProperty;
20
- var __defProps = Object.defineProperties;
21
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
22
- var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
23
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
24
- var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
25
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
26
- var __spreadValues2 = (a2, b) => {
27
- for (var prop in b || (b = {}))
28
- if (__hasOwnProp2.call(b, prop))
29
- __defNormalProp2(a2, prop, b[prop]);
30
- if (__getOwnPropSymbols2)
31
- for (var prop of __getOwnPropSymbols2(b)) {
32
- if (__propIsEnum2.call(b, prop))
33
- __defNormalProp2(a2, prop, b[prop]);
18
+ _ ? s() : T.push(s);
19
+ }, document.getElementById("storyblok-javascript-bridge")))
20
+ return;
21
+ const r = document.createElement("script");
22
+ r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
23
+ T.forEach((o) => o()), _ = !0, t(s);
24
+ }, document.getElementsByTagName("head")[0].appendChild(r);
25
+ }), H = function(n, t) {
26
+ if (!n)
27
+ return null;
28
+ let e = {};
29
+ for (let r in n) {
30
+ let s = n[r];
31
+ t.indexOf(r) > -1 && s !== null && (e[r] = s);
32
+ }
33
+ return e;
34
+ }, J = (n) => n === "email";
35
+ var Y = {
36
+ nodes: {
37
+ horizontal_rule() {
38
+ return {
39
+ singleTag: "hr"
40
+ };
41
+ },
42
+ blockquote() {
43
+ return {
44
+ tag: "blockquote"
45
+ };
46
+ },
47
+ bullet_list() {
48
+ return {
49
+ tag: "ul"
50
+ };
51
+ },
52
+ code_block(n) {
53
+ return {
54
+ tag: [
55
+ "pre",
56
+ {
57
+ tag: "code",
58
+ attrs: n.attrs
59
+ }
60
+ ]
61
+ };
62
+ },
63
+ hard_break() {
64
+ return {
65
+ singleTag: "br"
66
+ };
67
+ },
68
+ heading(n) {
69
+ return {
70
+ tag: `h${n.attrs.level}`
71
+ };
72
+ },
73
+ image(n) {
74
+ return {
75
+ singleTag: [
76
+ {
77
+ tag: "img",
78
+ attrs: H(n.attrs, ["src", "alt", "title"])
79
+ }
80
+ ]
81
+ };
82
+ },
83
+ list_item() {
84
+ return {
85
+ tag: "li"
86
+ };
87
+ },
88
+ ordered_list() {
89
+ return {
90
+ tag: "ol"
91
+ };
92
+ },
93
+ paragraph() {
94
+ return {
95
+ tag: "p"
96
+ };
97
+ }
98
+ },
99
+ marks: {
100
+ bold() {
101
+ return {
102
+ tag: "b"
103
+ };
104
+ },
105
+ strike() {
106
+ return {
107
+ tag: "strike"
108
+ };
109
+ },
110
+ underline() {
111
+ return {
112
+ tag: "u"
113
+ };
114
+ },
115
+ strong() {
116
+ return {
117
+ tag: "strong"
118
+ };
119
+ },
120
+ code() {
121
+ return {
122
+ tag: "code"
123
+ };
124
+ },
125
+ italic() {
126
+ return {
127
+ tag: "i"
128
+ };
129
+ },
130
+ link(n) {
131
+ const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
132
+ return J(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
133
+ tag: [
134
+ {
135
+ tag: "a",
136
+ attrs: t
137
+ }
138
+ ]
139
+ };
140
+ },
141
+ styled(n) {
142
+ return {
143
+ tag: [
144
+ {
145
+ tag: "span",
146
+ attrs: n.attrs
147
+ }
148
+ ]
149
+ };
34
150
  }
35
- return a2;
151
+ }
36
152
  };
37
- var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
38
- let loaded = false;
39
- const callbacks = [];
40
- const loadBridge = (src) => {
41
- return new Promise((resolve, reject) => {
42
- if (typeof window === "undefined")
43
- return;
44
- window.storyblokRegisterEvent = (cb) => {
45
- if (window.location === window.parent.location) {
46
- console.warn("You are not in Draft Mode or in the Visual Editor.");
47
- return;
48
- }
49
- if (!loaded)
50
- callbacks.push(cb);
51
- else
52
- cb();
53
- };
54
- if (document.getElementById("storyblok-javascript-bridge"))
55
- return;
56
- const script = document.createElement("script");
57
- script.async = true;
58
- script.src = src;
59
- script.id = "storyblok-javascript-bridge";
60
- script.onerror = (error) => reject(error);
61
- script.onload = (ev) => {
62
- callbacks.forEach((cb) => cb());
63
- loaded = true;
64
- resolve(ev);
65
- };
66
- document.getElementsByTagName("head")[0].appendChild(script);
67
- });
153
+ const F = function(n) {
154
+ const t = {
155
+ "&": "&",
156
+ "<": "&lt;",
157
+ ">": "&gt;",
158
+ '"': "&quot;",
159
+ "'": "&#39;"
160
+ }, e = /[&<>"']/g, r = RegExp(e.source);
161
+ return n && r.test(n) ? n.replace(e, (s) => t[s]) : n;
68
162
  };
163
+ class R {
164
+ constructor(t) {
165
+ t || (t = Y), this.marks = t.marks || [], this.nodes = t.nodes || [];
166
+ }
167
+ addNode(t, e) {
168
+ this.nodes[t] = e;
169
+ }
170
+ addMark(t, e) {
171
+ this.marks[t] = e;
172
+ }
173
+ render(t = {}) {
174
+ if (t.content && Array.isArray(t.content)) {
175
+ let e = "";
176
+ return t.content.forEach((r) => {
177
+ e += this.renderNode(r);
178
+ }), e;
179
+ }
180
+ return console.warn("The render method must receive an object with a content field, which is an array"), "";
181
+ }
182
+ renderNode(t) {
183
+ let e = [];
184
+ t.marks && t.marks.forEach((s) => {
185
+ const o = this.getMatchingMark(s);
186
+ o && e.push(this.renderOpeningTag(o.tag));
187
+ });
188
+ const r = this.getMatchingNode(t);
189
+ return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
190
+ e.push(this.renderNode(s));
191
+ }) : t.text ? e.push(F(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
192
+ const o = this.getMatchingMark(s);
193
+ o && e.push(this.renderClosingTag(o.tag));
194
+ }), e.join("");
195
+ }
196
+ renderTag(t, e) {
197
+ return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
198
+ if (s.constructor === String)
199
+ return `<${s}${e}>`;
200
+ {
201
+ let o = `<${s.tag}`;
202
+ if (s.attrs)
203
+ for (let a in s.attrs) {
204
+ let i = s.attrs[a];
205
+ i !== null && (o += ` ${a}="${i}"`);
206
+ }
207
+ return `${o}${e}>`;
208
+ }
209
+ }).join("");
210
+ }
211
+ renderOpeningTag(t) {
212
+ return this.renderTag(t, "");
213
+ }
214
+ renderClosingTag(t) {
215
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
216
+ }
217
+ getMatchingNode(t) {
218
+ if (typeof this.nodes[t.type] == "function")
219
+ return this.nodes[t.type](t);
220
+ }
221
+ getMatchingMark(t) {
222
+ if (typeof this.marks[t.type] == "function")
223
+ return this.marks[t.type](t);
224
+ }
225
+ }
69
226
  /*!
70
227
  * storyblok-js-client v4.5.2
71
228
  * Universal JavaScript SDK for Storyblok's API
72
229
  * (c) 2020-2022 Stobylok Team
73
230
  */
74
- function t(e2) {
75
- return typeof e2 == "number" && (e2 == e2 && e2 !== 1 / 0 && e2 !== -1 / 0);
231
+ function w(n) {
232
+ return typeof n == "number" && n == n && n !== 1 / 0 && n !== -1 / 0;
76
233
  }
77
- function s(e2, s2, r2) {
78
- if (!t(s2))
234
+ function $(n, t, e) {
235
+ if (!w(t))
79
236
  throw new TypeError("Expected `limit` to be a finite number");
80
- if (!t(r2))
237
+ if (!w(e))
81
238
  throw new TypeError("Expected `interval` to be a finite number");
82
- var i2 = [], n2 = [], o2 = 0, a2 = function() {
83
- o2++;
84
- var t2 = setTimeout(function() {
85
- o2--, i2.length > 0 && a2(), n2 = n2.filter(function(e3) {
86
- return e3 !== t2;
239
+ var r = [], s = [], o = 0, a = function() {
240
+ o++;
241
+ var c = setTimeout(function() {
242
+ o--, r.length > 0 && a(), s = s.filter(function(u) {
243
+ return u !== c;
87
244
  });
88
- }, r2);
89
- n2.indexOf(t2) < 0 && n2.push(t2);
90
- var s3 = i2.shift();
91
- s3.resolve(e2.apply(s3.self, s3.args));
92
- }, l2 = function() {
93
- var e3 = arguments, t2 = this;
94
- return new Promise(function(r3, n3) {
95
- i2.push({ resolve: r3, reject: n3, args: e3, self: t2 }), o2 < s2 && a2();
245
+ }, e);
246
+ s.indexOf(c) < 0 && s.push(c);
247
+ var l = r.shift();
248
+ l.resolve(n.apply(l.self, l.args));
249
+ }, i = function() {
250
+ var c = arguments, l = this;
251
+ return new Promise(function(u, p) {
252
+ r.push({ resolve: u, reject: p, args: c, self: l }), o < t && a();
96
253
  });
97
254
  };
98
- return l2.abort = function() {
99
- n2.forEach(clearTimeout), n2 = [], i2.forEach(function(e3) {
100
- e3.reject(new throttle.AbortError());
101
- }), i2.length = 0;
102
- }, l2;
255
+ return i.abort = function() {
256
+ s.forEach(clearTimeout), s = [], r.forEach(function(c) {
257
+ c.reject(new throttle.AbortError());
258
+ }), r.length = 0;
259
+ }, i;
103
260
  }
104
- s.AbortError = function() {
261
+ $.AbortError = function() {
105
262
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
106
263
  };
107
- const r = function(e2, t2) {
108
- if (!e2)
264
+ const K = function(n, t) {
265
+ if (!n)
109
266
  return null;
110
- let s2 = {};
111
- for (let r2 in e2) {
112
- let i2 = e2[r2];
113
- t2.indexOf(r2) > -1 && i2 !== null && (s2[r2] = i2);
267
+ let e = {};
268
+ for (let r in n) {
269
+ let s = n[r];
270
+ t.indexOf(r) > -1 && s !== null && (e[r] = s);
114
271
  }
115
- return s2;
272
+ return e;
116
273
  };
117
- var i = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (e2) => ({ tag: ["pre", { tag: "code", attrs: e2.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (e2) => ({ tag: `h${e2.attrs.level}` }), image: (e2) => ({ singleTag: [{ tag: "img", attrs: r(e2.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(e2) {
118
- const t2 = __spreadValues2({}, e2.attrs), { linktype: s2 = "url" } = e2.attrs;
119
- return s2 === "email" && (t2.href = `mailto:${t2.href}`), t2.anchor && (t2.href = `${t2.href}#${t2.anchor}`, delete t2.anchor), { tag: [{ tag: "a", attrs: t2 }] };
120
- }, styled: (e2) => ({ tag: [{ tag: "span", attrs: e2.attrs }] }) } };
121
- class n {
122
- constructor(e2) {
123
- e2 || (e2 = i), this.marks = e2.marks || [], this.nodes = e2.nodes || [];
124
- }
125
- addNode(e2, t2) {
126
- this.nodes[e2] = t2;
127
- }
128
- addMark(e2, t2) {
129
- this.marks[e2] = t2;
130
- }
131
- render(e2 = {}) {
132
- if (e2.content && Array.isArray(e2.content)) {
133
- let t2 = "";
134
- return e2.content.forEach((e3) => {
135
- t2 += this.renderNode(e3);
136
- }), t2;
274
+ var G = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (n) => ({ tag: ["pre", { tag: "code", attrs: n.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (n) => ({ tag: `h${n.attrs.level}` }), image: (n) => ({ singleTag: [{ tag: "img", attrs: K(n.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(n) {
275
+ const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
276
+ return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
277
+ }, styled: (n) => ({ tag: [{ tag: "span", attrs: n.attrs }] }) } };
278
+ class Q {
279
+ constructor(t) {
280
+ t || (t = G), this.marks = t.marks || [], this.nodes = t.nodes || [];
281
+ }
282
+ addNode(t, e) {
283
+ this.nodes[t] = e;
284
+ }
285
+ addMark(t, e) {
286
+ this.marks[t] = e;
287
+ }
288
+ render(t = {}) {
289
+ if (t.content && Array.isArray(t.content)) {
290
+ let e = "";
291
+ return t.content.forEach((r) => {
292
+ e += this.renderNode(r);
293
+ }), e;
137
294
  }
138
295
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
139
296
  }
140
- renderNode(e2) {
141
- let t2 = [];
142
- e2.marks && e2.marks.forEach((e3) => {
143
- const s3 = this.getMatchingMark(e3);
144
- s3 && t2.push(this.renderOpeningTag(s3.tag));
297
+ renderNode(t) {
298
+ let e = [];
299
+ t.marks && t.marks.forEach((s) => {
300
+ const o = this.getMatchingMark(s);
301
+ o && e.push(this.renderOpeningTag(o.tag));
145
302
  });
146
- const s2 = this.getMatchingNode(e2);
147
- return s2 && s2.tag && t2.push(this.renderOpeningTag(s2.tag)), e2.content ? e2.content.forEach((e3) => {
148
- t2.push(this.renderNode(e3));
149
- }) : e2.text ? t2.push(function(e3) {
150
- const t3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, s3 = /[&<>"']/g, r2 = RegExp(s3.source);
151
- return e3 && r2.test(e3) ? e3.replace(s3, (e4) => t3[e4]) : e3;
152
- }(e2.text)) : s2 && s2.singleTag ? t2.push(this.renderTag(s2.singleTag, " /")) : s2 && s2.html && t2.push(s2.html), s2 && s2.tag && t2.push(this.renderClosingTag(s2.tag)), e2.marks && e2.marks.slice(0).reverse().forEach((e3) => {
153
- const s3 = this.getMatchingMark(e3);
154
- s3 && t2.push(this.renderClosingTag(s3.tag));
155
- }), t2.join("");
156
- }
157
- renderTag(e2, t2) {
158
- if (e2.constructor === String)
159
- return `<${e2}${t2}>`;
160
- return e2.map((e3) => {
161
- if (e3.constructor === String)
162
- return `<${e3}${t2}>`;
303
+ const r = this.getMatchingNode(t);
304
+ return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
305
+ e.push(this.renderNode(s));
306
+ }) : t.text ? e.push(function(s) {
307
+ const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
308
+ return s && i.test(s) ? s.replace(a, (c) => o[c]) : s;
309
+ }(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
310
+ const o = this.getMatchingMark(s);
311
+ o && e.push(this.renderClosingTag(o.tag));
312
+ }), e.join("");
313
+ }
314
+ renderTag(t, e) {
315
+ return t.constructor === String ? `<${t}${e}>` : t.map((r) => {
316
+ if (r.constructor === String)
317
+ return `<${r}${e}>`;
163
318
  {
164
- let s2 = `<${e3.tag}`;
165
- if (e3.attrs)
166
- for (let t3 in e3.attrs) {
167
- let r2 = e3.attrs[t3];
168
- r2 !== null && (s2 += ` ${t3}="${r2}"`);
319
+ let s = `<${r.tag}`;
320
+ if (r.attrs)
321
+ for (let o in r.attrs) {
322
+ let a = r.attrs[o];
323
+ a !== null && (s += ` ${o}="${a}"`);
169
324
  }
170
- return `${s2}${t2}>`;
325
+ return `${s}${e}>`;
171
326
  }
172
327
  }).join("");
173
328
  }
174
- renderOpeningTag(e2) {
175
- return this.renderTag(e2, "");
329
+ renderOpeningTag(t) {
330
+ return this.renderTag(t, "");
176
331
  }
177
- renderClosingTag(e2) {
178
- if (e2.constructor === String)
179
- return `</${e2}>`;
180
- return e2.slice(0).reverse().map((e3) => e3.constructor === String ? `</${e3}>` : `</${e3.tag}>`).join("");
332
+ renderClosingTag(t) {
333
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
181
334
  }
182
- getMatchingNode(e2) {
183
- if (typeof this.nodes[e2.type] == "function")
184
- return this.nodes[e2.type](e2);
335
+ getMatchingNode(t) {
336
+ if (typeof this.nodes[t.type] == "function")
337
+ return this.nodes[t.type](t);
185
338
  }
186
- getMatchingMark(e2) {
187
- if (typeof this.marks[e2.type] == "function")
188
- return this.marks[e2.type](e2);
339
+ getMatchingMark(t) {
340
+ if (typeof this.marks[t.type] == "function")
341
+ return this.marks[t.type](t);
189
342
  }
190
343
  }
191
- const o = (e2 = 0, t2 = e2) => {
192
- const s2 = Math.abs(t2 - e2) || 0, r2 = e2 < t2 ? 1 : -1;
193
- return ((e3 = 0, t3) => [...Array(e3)].map(t3))(s2, (t3, s3) => s3 * r2 + e2);
194
- }, a = (e2, t2, s2) => {
195
- const r2 = [];
196
- for (const i2 in e2) {
197
- if (!Object.prototype.hasOwnProperty.call(e2, i2))
344
+ const W = (n = 0, t = n) => {
345
+ const e = Math.abs(t - n) || 0, r = n < t ? 1 : -1;
346
+ return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * r + n);
347
+ }, k = (n, t, e) => {
348
+ const r = [];
349
+ for (const s in n) {
350
+ if (!Object.prototype.hasOwnProperty.call(n, s))
198
351
  continue;
199
- const n2 = e2[i2], o2 = s2 ? "" : encodeURIComponent(i2);
200
- let l2;
201
- l2 = typeof n2 == "object" ? a(n2, t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(n2)) : (t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(n2), r2.push(l2);
352
+ const o = n[s], a = e ? "" : encodeURIComponent(s);
353
+ let i;
354
+ i = typeof o == "object" ? k(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), r.push(i);
202
355
  }
203
- return r2.join("&");
356
+ return r.join("&");
204
357
  };
205
- let l = {}, c = {};
206
- class h {
207
- constructor(t2, r2) {
208
- if (!r2) {
209
- let e2 = t2.region ? `-${t2.region}` : "", s2 = t2.https === false ? "http" : "https";
210
- r2 = t2.oauthToken === void 0 ? `${s2}://api${e2}.storyblok.com/v2` : `${s2}://api${e2}.storyblok.com/v1`;
358
+ let f = {}, d = {};
359
+ class X {
360
+ constructor(t, e) {
361
+ if (!e) {
362
+ let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
363
+ e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
211
364
  }
212
- let i2 = Object.assign({}, t2.headers), o2 = 5;
213
- t2.oauthToken !== void 0 && (i2.Authorization = t2.oauthToken, o2 = 3), t2.rateLimit !== void 0 && (o2 = t2.rateLimit), this.richTextResolver = new n(t2.richTextSchema), typeof t2.componentResolver == "function" && this.setComponentResolver(t2.componentResolver), this.maxRetries = t2.maxRetries || 5, this.throttle = s(this.throttledRequest, o2, 1e3), this.accessToken = t2.accessToken, this.relations = {}, this.links = {}, this.cache = t2.cache || { clear: "manual" }, this.client = e.create({ baseURL: r2, timeout: t2.timeout || 0, headers: i2, proxy: t2.proxy || false }), t2.responseInterceptor && this.client.interceptors.response.use((e2) => t2.responseInterceptor(e2)), this.resolveNestedRelations = t2.resolveNestedRelations || true;
214
- }
215
- setComponentResolver(e2) {
216
- this.richTextResolver.addNode("blok", (t2) => {
217
- let s2 = "";
218
- return t2.attrs.body.forEach((t3) => {
219
- s2 += e2(t3.component, t3);
220
- }), { html: s2 };
365
+ let r = Object.assign({}, t.headers), s = 5;
366
+ t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new Q(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = $(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = q.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
367
+ }
368
+ setComponentResolver(t) {
369
+ this.richTextResolver.addNode("blok", (e) => {
370
+ let r = "";
371
+ return e.attrs.body.forEach((s) => {
372
+ r += t(s.component, s);
373
+ }), { html: r };
221
374
  });
222
375
  }
223
- parseParams(e2 = {}) {
224
- return e2.version || (e2.version = "published"), e2.token || (e2.token = this.getToken()), e2.cv || (e2.cv = c[e2.token]), Array.isArray(e2.resolve_relations) && (e2.resolve_relations = e2.resolve_relations.join(",")), e2;
376
+ parseParams(t = {}) {
377
+ return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = d[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
225
378
  }
226
- factoryParamOptions(e2, t2 = {}) {
227
- return ((e3 = "") => e3.indexOf("/cdn/") > -1)(e2) ? this.parseParams(t2) : t2;
379
+ factoryParamOptions(t, e = {}) {
380
+ return ((r = "") => r.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
228
381
  }
229
- makeRequest(e2, t2, s2, r2) {
230
- const i2 = this.factoryParamOptions(e2, ((e3 = {}, t3 = 25, s3 = 1) => __spreadProps(__spreadValues2({}, e3), { per_page: t3, page: s3 }))(t2, s2, r2));
231
- return this.cacheResponse(e2, i2);
382
+ makeRequest(t, e, r, s) {
383
+ const o = this.factoryParamOptions(t, ((a = {}, i = 25, c = 1) => y(h({}, a), { per_page: i, page: c }))(e, r, s));
384
+ return this.cacheResponse(t, o);
232
385
  }
233
- get(e2, t2) {
234
- let s2 = `/${e2}`;
235
- const r2 = this.factoryParamOptions(s2, t2);
236
- return this.cacheResponse(s2, r2);
386
+ get(t, e) {
387
+ let r = `/${t}`;
388
+ const s = this.factoryParamOptions(r, e);
389
+ return this.cacheResponse(r, s);
237
390
  }
238
- async getAll(e2, t2 = {}, s2) {
239
- const r2 = t2.per_page || 25, i2 = `/${e2}`, n2 = i2.split("/");
240
- s2 = s2 || n2[n2.length - 1];
241
- const a2 = await this.makeRequest(i2, t2, r2, 1), l2 = Math.ceil(a2.total / r2);
242
- return ((e3 = [], t3) => e3.map(t3).reduce((e4, t4) => [...e4, ...t4], []))([a2, ...await (async (e3 = [], t3) => Promise.all(e3.map(t3)))(o(1, l2), async (e3) => this.makeRequest(i2, t2, r2, e3 + 1))], (e3) => Object.values(e3.data[s2]));
391
+ async getAll(t, e = {}, r) {
392
+ const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
393
+ r = r || a[a.length - 1];
394
+ const i = await this.makeRequest(o, e, s, 1), c = Math.ceil(i.total / s);
395
+ return ((l = [], u) => l.map(u).reduce((p, S) => [...p, ...S], []))([i, ...await (async (l = [], u) => Promise.all(l.map(u)))(W(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
243
396
  }
244
- post(e2, t2) {
245
- let s2 = `/${e2}`;
246
- return this.throttle("post", s2, t2);
397
+ post(t, e) {
398
+ let r = `/${t}`;
399
+ return this.throttle("post", r, e);
247
400
  }
248
- put(e2, t2) {
249
- let s2 = `/${e2}`;
250
- return this.throttle("put", s2, t2);
401
+ put(t, e) {
402
+ let r = `/${t}`;
403
+ return this.throttle("put", r, e);
251
404
  }
252
- delete(e2, t2) {
253
- let s2 = `/${e2}`;
254
- return this.throttle("delete", s2, t2);
405
+ delete(t, e) {
406
+ let r = `/${t}`;
407
+ return this.throttle("delete", r, e);
255
408
  }
256
- getStories(e2) {
257
- return this.get("cdn/stories", e2);
409
+ getStories(t) {
410
+ return this.get("cdn/stories", t);
258
411
  }
259
- getStory(e2, t2) {
260
- return this.get(`cdn/stories/${e2}`, t2);
412
+ getStory(t, e) {
413
+ return this.get(`cdn/stories/${t}`, e);
261
414
  }
262
- setToken(e2) {
263
- this.accessToken = e2;
415
+ setToken(t) {
416
+ this.accessToken = t;
264
417
  }
265
418
  getToken() {
266
419
  return this.accessToken;
267
420
  }
268
- _cleanCopy(e2) {
269
- return JSON.parse(JSON.stringify(e2));
270
- }
271
- _insertLinks(e2, t2) {
272
- const s2 = e2[t2];
273
- s2 && s2.fieldtype == "multilink" && s2.linktype == "story" && typeof s2.id == "string" && this.links[s2.id] ? s2.story = this._cleanCopy(this.links[s2.id]) : s2 && s2.linktype === "story" && typeof s2.uuid == "string" && this.links[s2.uuid] && (s2.story = this._cleanCopy(this.links[s2.uuid]));
274
- }
275
- _insertRelations(e2, t2, s2) {
276
- if (s2.indexOf(e2.component + "." + t2) > -1) {
277
- if (typeof e2[t2] == "string")
278
- this.relations[e2[t2]] && (e2[t2] = this._cleanCopy(this.relations[e2[t2]]));
279
- else if (e2[t2].constructor === Array) {
280
- let s3 = [];
281
- e2[t2].forEach((e3) => {
282
- this.relations[e3] && s3.push(this._cleanCopy(this.relations[e3]));
283
- }), e2[t2] = s3;
421
+ _cleanCopy(t) {
422
+ return JSON.parse(JSON.stringify(t));
423
+ }
424
+ _insertLinks(t, e) {
425
+ const r = t[e];
426
+ r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[r.id] ? r.story = this._cleanCopy(this.links[r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[r.uuid] && (r.story = this._cleanCopy(this.links[r.uuid]));
427
+ }
428
+ _insertRelations(t, e, r) {
429
+ if (r.indexOf(t.component + "." + e) > -1) {
430
+ if (typeof t[e] == "string")
431
+ this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
432
+ else if (t[e].constructor === Array) {
433
+ let s = [];
434
+ t[e].forEach((o) => {
435
+ this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
436
+ }), t[e] = s;
284
437
  }
285
438
  }
286
439
  }
287
- _insertAssetsRelations(e2, t2) {
288
- t2.forEach((t3) => {
289
- e2.id === t3.id && (e2.original = t3, e2.original.filename = e2.filename, e2.original.filename = e2.original.filename.includes("https://s3.amazonaws.com/") ? e2.original.filename : e2.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete e2.original.s3_filename);
440
+ _insertAssetsRelations(t, e) {
441
+ e.forEach((r) => {
442
+ t.id === r.id && (t.original = r, t.original.filename = t.filename, t.original.filename = t.original.filename.includes("https://s3.amazonaws.com/") ? t.original.filename : t.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete t.original.s3_filename);
290
443
  });
291
444
  }
292
- iterateTree(e2, t2) {
293
- let s2 = (e3) => {
294
- if (e3 != null) {
295
- if (e3.constructor === Array)
296
- for (let t3 = 0; t3 < e3.length; t3++)
297
- s2(e3[t3]);
298
- else if (e3.constructor === Object) {
299
- if (e3._stopResolving)
445
+ iterateTree(t, e) {
446
+ let r = (s) => {
447
+ if (s != null) {
448
+ if (s.constructor === Array)
449
+ for (let o = 0; o < s.length; o++)
450
+ r(s[o]);
451
+ else if (s.constructor === Object) {
452
+ if (s._stopResolving)
300
453
  return;
301
- for (let r2 in e3)
302
- e3.component && e3._uid || e3.type === "link" ? (this._insertRelations(e3, r2, t2), this._insertLinks(e3, r2)) : e3.fieldtype === "asset" && this._insertAssetsRelations(e3, t2), s2(e3[r2]);
454
+ for (let o in s)
455
+ s.component && s._uid || s.type === "link" ? (this._insertRelations(s, o, e), this._insertLinks(s, o)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), r(s[o]);
303
456
  }
304
457
  }
305
458
  };
306
- s2(e2.content);
307
- }
308
- async resolveLinks(e2, t2) {
309
- let s2 = [];
310
- if (e2.link_uuids) {
311
- const r2 = e2.link_uuids.length;
312
- let i2 = [];
313
- const n2 = 50;
314
- for (let t3 = 0; t3 < r2; t3 += n2) {
315
- const s3 = Math.min(r2, t3 + n2);
316
- i2.push(e2.link_uuids.slice(t3, s3));
459
+ r(t.content);
460
+ }
461
+ async resolveLinks(t, e) {
462
+ let r = [];
463
+ if (t.link_uuids) {
464
+ const s = t.link_uuids.length;
465
+ let o = [];
466
+ const a = 50;
467
+ for (let i = 0; i < s; i += a) {
468
+ const c = Math.min(s, i + a);
469
+ o.push(t.link_uuids.slice(i, c));
317
470
  }
318
- for (let e3 = 0; e3 < i2.length; e3++) {
319
- (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
320
- s2.push(e4);
471
+ for (let i = 0; i < o.length; i++)
472
+ (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
473
+ r.push(c);
321
474
  });
322
- }
323
475
  } else
324
- s2 = e2.links;
325
- s2.forEach((e3) => {
326
- this.links[e3.uuid] = __spreadProps(__spreadValues2({}, e3), { _stopResolving: true });
476
+ r = t.links;
477
+ r.forEach((s) => {
478
+ this.links[s.uuid] = y(h({}, s), { _stopResolving: !0 });
327
479
  });
328
480
  }
329
- async resolveRelations(e2, t2) {
330
- let s2 = [];
331
- if (e2.rel_uuids) {
332
- const r2 = e2.rel_uuids.length;
333
- let i2 = [];
334
- const n2 = 50;
335
- for (let t3 = 0; t3 < r2; t3 += n2) {
336
- const s3 = Math.min(r2, t3 + n2);
337
- i2.push(e2.rel_uuids.slice(t3, s3));
481
+ async resolveRelations(t, e) {
482
+ let r = [];
483
+ if (t.rel_uuids) {
484
+ const s = t.rel_uuids.length;
485
+ let o = [];
486
+ const a = 50;
487
+ for (let i = 0; i < s; i += a) {
488
+ const c = Math.min(s, i + a);
489
+ o.push(t.rel_uuids.slice(i, c));
338
490
  }
339
- for (let e3 = 0; e3 < i2.length; e3++) {
340
- (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
341
- s2.push(e4);
491
+ for (let i = 0; i < o.length; i++)
492
+ (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
493
+ r.push(c);
342
494
  });
343
- }
344
495
  } else
345
- s2 = e2.rels;
346
- s2.forEach((e3) => {
347
- this.relations[e3.uuid] = __spreadProps(__spreadValues2({}, e3), { _stopResolving: true });
496
+ r = t.rels;
497
+ r.forEach((s) => {
498
+ this.relations[s.uuid] = y(h({}, s), { _stopResolving: !0 });
348
499
  });
349
500
  }
350
- async resolveStories(e2, t2) {
351
- let s2 = [];
352
- if (t2.resolve_relations !== void 0 && t2.resolve_relations.length > 0 && (s2 = t2.resolve_relations.split(","), await this.resolveRelations(e2, t2)), ["1", "story", "url"].indexOf(t2.resolve_links) > -1 && await this.resolveLinks(e2, t2), this.resolveNestedRelations)
353
- for (const e3 in this.relations)
354
- this.iterateTree(this.relations[e3], s2);
355
- e2.story ? this.iterateTree(e2.story, s2) : e2.stories.forEach((e3) => {
356
- this.iterateTree(e3, s2);
501
+ async resolveStories(t, e) {
502
+ let r = [];
503
+ if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (r = e.resolve_relations.split(","), await this.resolveRelations(t, e)), ["1", "story", "url"].indexOf(e.resolve_links) > -1 && (t.links || t.link_uuids) && await this.resolveLinks(t, e), this.resolveNestedRelations)
504
+ for (const s in this.relations)
505
+ this.iterateTree(this.relations[s], r);
506
+ t.story ? this.iterateTree(t.story, r) : t.stories.forEach((s) => {
507
+ this.iterateTree(s, r);
357
508
  });
358
509
  }
359
- resolveAssetsRelations(e2) {
360
- const { assets: t2, stories: s2, story: r2 } = e2;
361
- if (s2)
362
- for (const e3 of s2)
363
- this.iterateTree(e3, t2);
364
- else
365
- this.iterateTree(r2, t2);
366
- }
367
- cacheResponse(e2, t2, s2) {
368
- return s2 === void 0 && (s2 = 0), new Promise(async (r2, i2) => {
369
- let n2 = a({ url: e2, params: t2 }), o2 = this.cacheProvider();
370
- if (this.cache.clear === "auto" && t2.version === "draft" && await this.flushCache(), t2.version === "published" && e2 != "/cdn/spaces/me") {
371
- const e3 = await o2.get(n2);
372
- if (e3)
373
- return r2(e3);
510
+ resolveAssetsRelations(t) {
511
+ const { assets: e, stories: r, story: s } = t;
512
+ if (r)
513
+ for (const o of r)
514
+ this.iterateTree(o, e);
515
+ else {
516
+ if (!s)
517
+ return t;
518
+ this.iterateTree(s, e);
519
+ }
520
+ }
521
+ cacheResponse(t, e, r) {
522
+ return r === void 0 && (r = 0), new Promise(async (s, o) => {
523
+ let a = k({ url: t, params: e }), i = this.cacheProvider();
524
+ if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
525
+ const l = await i.get(a);
526
+ if (l)
527
+ return s(l);
374
528
  }
375
529
  try {
376
- let s3 = await this.throttle("get", e2, { params: t2, paramsSerializer: (e3) => a(e3) }), l3 = { data: s3.data, headers: s3.headers };
377
- if (l3.data.assets && l3.data.assets.length && this.resolveAssetsRelations(l3.data), s3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(s3.headers["per-page"]), total: parseInt(s3.headers.total) })), s3.status != 200)
378
- return i2(s3);
379
- (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, t2), t2.version === "published" && e2 != "/cdn/spaces/me" && o2.set(n2, l3), l3.data.cv && (t2.version == "draft" && c[t2.token] != l3.data.cv && this.flushCache(), c[t2.token] = l3.data.cv), r2(l3);
380
- } catch (n3) {
381
- if (n3.response && n3.response.status === 429 && (s2 += 1) < this.maxRetries)
382
- return console.log(`Hit rate limit. Retrying in ${s2} seconds.`), await (l2 = 1e3 * s2, new Promise((e3) => setTimeout(e3, l2))), this.cacheResponse(e2, t2, s2).then(r2).catch(i2);
383
- i2(n3);
530
+ let l = await this.throttle("get", t, { params: e, paramsSerializer: (p) => k(p) }), u = { data: l.data, headers: l.headers };
531
+ if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), l.headers["per-page"] && (u = Object.assign({}, u, { perPage: parseInt(l.headers["per-page"]), total: parseInt(l.headers.total) })), l.status != 200)
532
+ return o(l);
533
+ (u.data.story || u.data.stories) && await this.resolveStories(u.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, u), u.data.cv && (e.version == "draft" && d[e.token] != u.data.cv && this.flushCache(), d[e.token] = u.data.cv), s(u);
534
+ } catch (l) {
535
+ if (l.response && l.response.status === 429 && (r += 1) < this.maxRetries)
536
+ return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((u) => setTimeout(u, c))), this.cacheResponse(t, e, r).then(s).catch(o);
537
+ o(l);
384
538
  }
385
- var l2;
539
+ var c;
386
540
  });
387
541
  }
388
- throttledRequest(e2, t2, s2) {
389
- return this.client[e2](t2, s2);
542
+ throttledRequest(t, e, r) {
543
+ return this.client[t](e, r);
390
544
  }
391
545
  cacheVersions() {
392
- return c;
546
+ return d;
393
547
  }
394
548
  cacheVersion() {
395
- return c[this.accessToken];
549
+ return d[this.accessToken];
396
550
  }
397
- setCacheVersion(e2) {
398
- this.accessToken && (c[this.accessToken] = e2);
551
+ setCacheVersion(t) {
552
+ this.accessToken && (d[this.accessToken] = t);
399
553
  }
400
554
  cacheProvider() {
401
- return this.cache.type === "memory" ? { get: (e2) => l[e2], getAll: () => l, set(e2, t2) {
402
- l[e2] = t2;
555
+ return this.cache.type === "memory" ? { get: (t) => f[t], getAll: () => f, set(t, e) {
556
+ f[t] = e;
403
557
  }, flush() {
404
- l = {};
558
+ f = {};
405
559
  } } : { get() {
406
560
  }, getAll() {
407
561
  }, set() {
@@ -412,113 +566,126 @@ class h {
412
566
  return await this.cacheProvider().flush(), this;
413
567
  }
414
568
  }
415
- const apiFactory = (options = {}) => {
416
- const { apiOptions } = options;
417
- if (!apiOptions.accessToken) {
569
+ const at = (n = {}) => {
570
+ const { apiOptions: t } = n;
571
+ if (!t.accessToken) {
418
572
  console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");
419
573
  return;
420
574
  }
421
- const storyblokApi = new h(apiOptions);
422
- return { storyblokApi };
575
+ return { storyblokApi: new X(t) };
423
576
  };
424
- var editable = (blok) => {
425
- if (typeof blok !== "object" || typeof blok._editable === "undefined") {
577
+ var Z = (n) => {
578
+ if (typeof n != "object" || typeof n._editable > "u")
426
579
  return {};
427
- }
428
- const options = JSON.parse(blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
580
+ const t = JSON.parse(n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
429
581
  return {
430
- "data-blok-c": JSON.stringify(options),
431
- "data-blok-uid": options.id + "-" + options.uid
582
+ "data-blok-c": JSON.stringify(t),
583
+ "data-blok-uid": t.id + "-" + t.uid
432
584
  };
433
585
  };
434
- const bridgeLatest = "https://app.storyblok.com/f/storyblok-v2-latest.js";
435
- const useStoryblokBridge = (id, cb, options = {}) => {
436
- if (typeof window === "undefined") {
437
- return;
438
- }
439
- if (typeof window.storyblokRegisterEvent === "undefined") {
440
- console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
441
- return;
442
- }
443
- if (!id) {
444
- console.warn("Story ID is not defined. Please provide a valid ID.");
445
- return;
446
- }
447
- window.storyblokRegisterEvent(() => {
448
- const sbBridge = new window.StoryblokBridge(options);
449
- sbBridge.on(["input", "published", "change"], (event) => {
450
- if (event.action == "input" && event.story.id === id) {
451
- cb(event.story);
452
- } else {
453
- window.location.reload();
454
- }
586
+ let m;
587
+ const tt = "https://app.storyblok.com/f/storyblok-v2-latest.js", et = (n, t, e = {}) => {
588
+ if (!(typeof window > "u")) {
589
+ if (typeof window.storyblokRegisterEvent > "u") {
590
+ console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
591
+ return;
592
+ }
593
+ if (!n) {
594
+ console.warn("Story ID is not defined. Please provide a valid ID.");
595
+ return;
596
+ }
597
+ window.storyblokRegisterEvent(() => {
598
+ new window.StoryblokBridge(e).on(["input", "published", "change"], (s) => {
599
+ s.story.id === n && (s.action === "input" ? t(s.story) : window.location.reload());
600
+ });
455
601
  });
602
+ }
603
+ }, rt = (n = {}) => {
604
+ const {
605
+ bridge: t,
606
+ accessToken: e,
607
+ use: r = [],
608
+ apiOptions: s = {},
609
+ richText: o = {}
610
+ } = n;
611
+ s.accessToken = s.accessToken || e;
612
+ const a = { bridge: t, apiOptions: s };
613
+ let i = {};
614
+ return r.forEach((c) => {
615
+ i = h(h({}, i), c(a));
616
+ }), t !== !1 && V(tt), m = new R(o.schema), o.resolver && E(m, o.resolver), i;
617
+ }, E = (n, t) => {
618
+ n.addNode("blok", (e) => {
619
+ let r = "";
620
+ return e.attrs.body.forEach((s) => {
621
+ r += t(s.component, s);
622
+ }), {
623
+ html: r
624
+ };
456
625
  });
457
- };
458
- const storyblokInit = (pluginOptions = {}) => {
459
- const { bridge, accessToken, use = [], apiOptions = {} } = pluginOptions;
460
- apiOptions.accessToken = apiOptions.accessToken || accessToken;
461
- const options = { bridge, apiOptions };
462
- let result = {};
463
- use.forEach((pluginFactory) => {
464
- result = __spreadValues2(__spreadValues2({}, result), pluginFactory(options));
465
- });
466
- if (bridge !== false) {
467
- loadBridge(bridgeLatest);
626
+ }, lt = (n, t) => {
627
+ if (!m) {
628
+ console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
629
+ return;
468
630
  }
469
- return result;
470
- };
471
- const _sfc_main = /* @__PURE__ */ defineComponent({
631
+ if (n === "")
632
+ return "";
633
+ if (!n)
634
+ return console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
635
+
636
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "";
637
+ let e = m;
638
+ return t && (e = new R(t.schema), t.resolver && E(e, t.resolver)), e.render(n);
639
+ }, st = /* @__PURE__ */ P({
472
640
  __name: "StoryblokComponent",
473
641
  props: {
474
642
  blok: null
475
643
  },
476
- setup(__props) {
477
- return (_ctx, _cache) => {
478
- return openBlock(), createBlock(resolveDynamicComponent(__props.blok.component), normalizeProps(guardReactiveProps(__spreadValues(__spreadValues({}, _ctx.$props), _ctx.$attrs))), null, 16);
479
- };
480
- }
481
- });
482
- const vEditableDirective = {
483
- beforeMount(el, binding) {
484
- if (binding.value) {
485
- const options = editable(binding.value);
486
- el.setAttribute("data-blok-c", options["data-blok-c"]);
487
- el.setAttribute("data-blok-uid", options["data-blok-uid"]);
488
- el.classList.add("storyblok__outline");
644
+ setup(n) {
645
+ return (t, e) => (j(), x(A(n.blok.component), C(M({ ...t.$props, ...t.$attrs })), null, 16));
646
+ }
647
+ }), nt = {
648
+ beforeMount(n, t) {
649
+ if (t.value) {
650
+ const e = Z(t.value);
651
+ n.setAttribute("data-blok-c", e["data-blok-c"]), n.setAttribute("data-blok-uid", e["data-blok-uid"]), n.classList.add("storyblok__outline");
489
652
  }
490
653
  }
491
- };
492
- const printError = (fnName) => {
493
- console.error(`You can't use ${fnName} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
654
+ }, O = (n) => {
655
+ console.error(`You can't use ${n} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
494
656
  `);
495
657
  };
496
- let storyblokApiInstance = null;
497
- const useStoryblokApi = () => {
498
- if (!storyblokApiInstance)
499
- printError("useStoryblokApi");
500
- return storyblokApiInstance;
501
- };
502
- const useStoryblok = async (url, apiOptions = {}, bridgeOptions = {}) => {
503
- const story = ref(null);
504
- onMounted(() => {
505
- if (story.value && story.value.id) {
506
- useStoryblokBridge(story.value.id, (evStory) => story.value = evStory, bridgeOptions);
507
- }
508
- });
509
- if (storyblokApiInstance) {
510
- const { data } = await storyblokApiInstance.get(`cdn/stories/${url}`, apiOptions);
511
- story.value = data.story;
658
+ let g = null;
659
+ const ct = () => (g || O("useStoryblokApi"), g), ut = async (n, t = {}, e = {}) => {
660
+ const r = N(null);
661
+ if (I(() => {
662
+ r.value && r.value.id && et(
663
+ r.value.id,
664
+ (s) => r.value = s,
665
+ e
666
+ );
667
+ }), g) {
668
+ const { data: s } = await g.get(
669
+ `cdn/stories/${n}`,
670
+ t
671
+ );
672
+ r.value = s.story;
512
673
  } else
513
- printError("useStoryblok");
514
- return story;
515
- };
516
- const StoryblokVue = {
517
- install(app, pluginOptions = {}) {
518
- app.directive("editable", vEditableDirective);
519
- app.component("StoryblokComponent", _sfc_main);
520
- const { storyblokApi } = storyblokInit(pluginOptions);
521
- storyblokApiInstance = storyblokApi;
674
+ O("useStoryblok");
675
+ return r;
676
+ }, ht = {
677
+ install(n, t = {}) {
678
+ n.directive("editable", nt), n.component("StoryblokComponent", st);
679
+ const { storyblokApi: e } = rt(t);
680
+ g = e;
522
681
  }
523
682
  };
524
- export { _sfc_main as StoryblokComponent, StoryblokVue, apiFactory as apiPlugin, useStoryblok, useStoryblokApi, useStoryblokBridge };
683
+ export {
684
+ st as StoryblokComponent,
685
+ ht as StoryblokVue,
686
+ at as apiPlugin,
687
+ lt as renderRichText,
688
+ ut as useStoryblok,
689
+ ct as useStoryblokApi,
690
+ et as useStoryblokBridge
691
+ };