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