@storyblok/svelte 2.3.8 → 2.4.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,589 +1,572 @@
1
- import st from "axios";
2
- var ot = Object.defineProperty, it = Object.defineProperties, at = Object.getOwnPropertyDescriptors, B = Object.getOwnPropertySymbols, lt = Object.prototype.hasOwnProperty, ct = Object.prototype.propertyIsEnumerable, z = (r, t, e) => t in r ? ot(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, d = (r, t) => {
3
- for (var e in t || (t = {}))
4
- lt.call(t, e) && z(r, e, t[e]);
5
- if (B)
6
- for (var e of B(t))
7
- ct.call(t, e) && z(r, e, t[e]);
1
+ var ne = Object.defineProperty, oe = Object.defineProperties, ie = Object.getOwnPropertyDescriptors, q = Object.getOwnPropertySymbols, ae = Object.prototype.hasOwnProperty, ce = Object.prototype.propertyIsEnumerable, B = (r, e, t) => e in r ? ne(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
2
+ for (var t in e || (e = {}))
3
+ ae.call(e, t) && B(r, t, e[t]);
4
+ if (q)
5
+ for (var t of q(e))
6
+ ce.call(e, t) && B(r, t, e[t]);
8
7
  return r;
9
- }, T = (r, t) => it(r, at(t));
8
+ }, j = (r, e) => oe(r, ie(e));
10
9
  let D = !1;
11
- const U = [], ut = (r) => new Promise((t, e) => {
12
- if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
10
+ const F = [], le = (r) => new Promise((e, t) => {
11
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
13
12
  if (window.location === window.parent.location) {
14
13
  console.warn("You are not in Draft Mode or in the Visual Editor.");
15
14
  return;
16
15
  }
17
- D ? s() : U.push(s);
16
+ D ? n() : F.push(n);
18
17
  }, document.getElementById("storyblok-javascript-bridge")))
19
18
  return;
20
- const n = document.createElement("script");
21
- n.async = !0, n.src = r, n.id = "storyblok-javascript-bridge", n.onerror = (s) => e(s), n.onload = (s) => {
22
- U.forEach((o) => o()), D = !0, t(s);
23
- }, document.getElementsByTagName("head")[0].appendChild(n);
24
- }), ht = function(r, t) {
25
- if (!r)
26
- return null;
27
- let e = {};
28
- for (let n in r) {
29
- let s = r[n];
30
- t.indexOf(n) > -1 && s !== null && (e[n] = s);
19
+ const s = document.createElement("script");
20
+ s.async = !0, s.src = r, s.id = "storyblok-javascript-bridge", s.onerror = (n) => t(n), s.onload = (n) => {
21
+ F.forEach((o) => o()), D = !0, e(n);
22
+ }, document.getElementsByTagName("head")[0].appendChild(s);
23
+ });
24
+ var he = Object.defineProperty, ue = (r, e, t) => e in r ? he(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, h = (r, e, t) => (ue(r, typeof e != "symbol" ? e + "" : e, t), t);
25
+ function J(r) {
26
+ return !(r !== r || r === 1 / 0 || r === -1 / 0);
27
+ }
28
+ function de(r, e, t) {
29
+ if (!J(e))
30
+ throw new TypeError("Expected `limit` to be a finite number");
31
+ if (!J(t))
32
+ throw new TypeError("Expected `interval` to be a finite number");
33
+ const s = [];
34
+ let n = [], o = 0;
35
+ const a = function() {
36
+ o++;
37
+ const c = setTimeout(function() {
38
+ o--, s.length > 0 && a(), n = n.filter(function(u) {
39
+ return u !== c;
40
+ });
41
+ }, t);
42
+ n.indexOf(c) < 0 && n.push(c);
43
+ const l = s.shift();
44
+ l.resolve(r.apply(l.self, l.args));
45
+ }, i = function(...c) {
46
+ const l = this;
47
+ return new Promise(function(u, d) {
48
+ s.push({
49
+ resolve: u,
50
+ reject: d,
51
+ args: c,
52
+ self: l
53
+ }), o < e && a();
54
+ });
55
+ };
56
+ return i.abort = function() {
57
+ n.forEach(clearTimeout), n = [], s.forEach(function(c) {
58
+ c.reject(function() {
59
+ Error.call(this, "Throttled function aborted"), this.name = "AbortError";
60
+ });
61
+ }), s.length = 0;
62
+ }, i;
63
+ }
64
+ const fe = function(r, e) {
65
+ const t = {};
66
+ for (const s in r) {
67
+ const n = r[s];
68
+ e.indexOf(s) > -1 && n !== null && (t[s] = n);
31
69
  }
32
- return e;
33
- }, ft = (r) => r === "email";
34
- var dt = {
35
- nodes: {
36
- horizontal_rule() {
37
- return {
38
- singleTag: "hr"
39
- };
40
- },
41
- blockquote() {
42
- return {
43
- tag: "blockquote"
44
- };
45
- },
46
- bullet_list() {
47
- return {
48
- tag: "ul"
49
- };
50
- },
51
- code_block(r) {
52
- return {
53
- tag: [
54
- "pre",
55
- {
56
- tag: "code",
57
- attrs: r.attrs
58
- }
59
- ]
60
- };
61
- },
62
- hard_break() {
63
- return {
64
- singleTag: "br"
65
- };
66
- },
67
- heading(r) {
68
- return {
69
- tag: `h${r.attrs.level}`
70
- };
71
- },
72
- image(r) {
73
- return {
74
- singleTag: [
75
- {
76
- tag: "img",
77
- attrs: ht(r.attrs, ["src", "alt", "title"])
78
- }
79
- ]
80
- };
81
- },
82
- list_item() {
83
- return {
84
- tag: "li"
85
- };
86
- },
87
- ordered_list() {
88
- return {
89
- tag: "ol"
90
- };
91
- },
92
- paragraph() {
93
- return {
94
- tag: "p"
95
- };
70
+ return t;
71
+ }, pe = (r) => r === "email", ge = () => ({
72
+ singleTag: "hr"
73
+ }), me = () => ({
74
+ tag: "blockquote"
75
+ }), ye = () => ({
76
+ tag: "ul"
77
+ }), _e = (r) => ({
78
+ tag: [
79
+ "pre",
80
+ {
81
+ tag: "code",
82
+ attrs: r.attrs
96
83
  }
84
+ ]
85
+ }), be = () => ({
86
+ singleTag: "br"
87
+ }), ke = (r) => ({
88
+ tag: `h${r.attrs.level}`
89
+ }), ve = (r) => ({
90
+ singleTag: [
91
+ {
92
+ tag: "img",
93
+ attrs: fe(r.attrs, ["src", "alt", "title"])
94
+ }
95
+ ]
96
+ }), we = () => ({
97
+ tag: "li"
98
+ }), $e = () => ({
99
+ tag: "ol"
100
+ }), Te = () => ({
101
+ tag: "p"
102
+ }), Re = () => ({
103
+ tag: "b"
104
+ }), xe = () => ({
105
+ tag: "strike"
106
+ }), je = () => ({
107
+ tag: "u"
108
+ }), Pe = () => ({
109
+ tag: "strong"
110
+ }), Oe = () => ({
111
+ tag: "code"
112
+ }), Ee = () => ({
113
+ tag: "i"
114
+ }), Se = (r) => {
115
+ const e = p({}, r.attrs), { linktype: t = "url" } = r.attrs;
116
+ return pe(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
117
+ tag: [
118
+ {
119
+ tag: "a",
120
+ attrs: e
121
+ }
122
+ ]
123
+ };
124
+ }, Ie = (r) => ({
125
+ tag: [
126
+ {
127
+ tag: "span",
128
+ attrs: r.attrs
129
+ }
130
+ ]
131
+ }), Ce = {
132
+ nodes: {
133
+ horizontal_rule: ge,
134
+ blockquote: me,
135
+ bullet_list: ye,
136
+ code_block: _e,
137
+ hard_break: be,
138
+ heading: ke,
139
+ image: ve,
140
+ list_item: we,
141
+ ordered_list: $e,
142
+ paragraph: Te
97
143
  },
98
144
  marks: {
99
- bold() {
100
- return {
101
- tag: "b"
102
- };
103
- },
104
- strike() {
105
- return {
106
- tag: "strike"
107
- };
108
- },
109
- underline() {
110
- return {
111
- tag: "u"
112
- };
113
- },
114
- strong() {
115
- return {
116
- tag: "strong"
117
- };
118
- },
119
- code() {
120
- return {
121
- tag: "code"
122
- };
123
- },
124
- italic() {
125
- return {
126
- tag: "i"
127
- };
128
- },
129
- link(r) {
130
- const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
131
- return ft(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
132
- tag: [
133
- {
134
- tag: "a",
135
- attrs: t
136
- }
137
- ]
138
- };
139
- },
140
- styled(r) {
141
- return {
142
- tag: [
143
- {
144
- tag: "span",
145
- attrs: r.attrs
146
- }
147
- ]
148
- };
149
- }
150
- }
151
- };
152
- const pt = function(r) {
153
- const t = {
145
+ bold: Re,
146
+ strike: xe,
147
+ underline: je,
148
+ strong: Pe,
149
+ code: Oe,
150
+ italic: Ee,
151
+ link: Se,
152
+ styled: Ie
153
+ }
154
+ }, Ae = function(r) {
155
+ const e = {
154
156
  "&": "&amp;",
155
157
  "<": "&lt;",
156
158
  ">": "&gt;",
157
159
  '"': "&quot;",
158
160
  "'": "&#39;"
159
- }, e = /[&<>"']/g, n = RegExp(e.source);
160
- return r && n.test(r) ? r.replace(e, (s) => t[s]) : r;
161
+ }, t = /[&<>"']/g, s = RegExp(t.source);
162
+ return r && s.test(r) ? r.replace(t, (n) => e[n]) : r;
161
163
  };
162
- class W {
163
- constructor(t) {
164
- t || (t = dt), this.marks = t.marks || [], this.nodes = t.nodes || [];
165
- }
166
- addNode(t, e) {
167
- this.nodes[t] = e;
168
- }
169
- addMark(t, e) {
170
- this.marks[t] = e;
171
- }
172
- render(t = {}) {
173
- if (t.content && Array.isArray(t.content)) {
174
- let e = "";
175
- return t.content.forEach((n) => {
176
- e += this.renderNode(n);
177
- }), e;
164
+ class R {
165
+ constructor(e) {
166
+ h(this, "marks"), h(this, "nodes"), e || (e = Ce), this.marks = e.marks || [], this.nodes = e.nodes || [];
167
+ }
168
+ addNode(e, t) {
169
+ this.nodes[e] = t;
170
+ }
171
+ addMark(e, t) {
172
+ this.marks[e] = t;
173
+ }
174
+ render(e) {
175
+ if (e && e.content && Array.isArray(e.content)) {
176
+ let t = "";
177
+ return e.content.forEach((s) => {
178
+ t += this.renderNode(s);
179
+ }), t;
178
180
  }
179
181
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
180
182
  }
181
- renderNode(t) {
182
- let e = [];
183
- t.marks && t.marks.forEach((s) => {
184
- const o = this.getMatchingMark(s);
185
- o && e.push(this.renderOpeningTag(o.tag));
183
+ renderNode(e) {
184
+ const t = [];
185
+ e.marks && e.marks.forEach((n) => {
186
+ const o = this.getMatchingMark(n);
187
+ o && t.push(this.renderOpeningTag(o.tag));
186
188
  });
187
- const n = this.getMatchingNode(t);
188
- return n && n.tag && e.push(this.renderOpeningTag(n.tag)), t.content ? t.content.forEach((s) => {
189
- e.push(this.renderNode(s));
190
- }) : t.text ? e.push(pt(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
191
- const o = this.getMatchingMark(s);
192
- o && e.push(this.renderClosingTag(o.tag));
193
- }), e.join("");
194
- }
195
- renderTag(t, e) {
196
- return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
189
+ const s = this.getMatchingNode(e);
190
+ return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((n) => {
191
+ t.push(this.renderNode(n));
192
+ }) : e.text ? t.push(Ae(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((n) => {
193
+ const o = this.getMatchingMark(n);
194
+ o && t.push(this.renderClosingTag(o.tag));
195
+ }), t.join("");
196
+ }
197
+ renderTag(e, t) {
198
+ return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
197
199
  if (s.constructor === String)
198
- return `<${s}${e}>`;
200
+ return `<${s}${t}>`;
199
201
  {
200
- let o = `<${s.tag}`;
202
+ let n = `<${s.tag}`;
201
203
  if (s.attrs)
202
- for (let a in s.attrs) {
203
- let i = s.attrs[a];
204
- i !== null && (o += ` ${a}="${i}"`);
204
+ for (const o in s.attrs) {
205
+ const a = s.attrs[o];
206
+ a !== null && (n += ` ${o}="${a}"`);
205
207
  }
206
- return `${o}${e}>`;
208
+ return `${n}${t}>`;
207
209
  }
208
210
  }).join("");
209
211
  }
210
- renderOpeningTag(t) {
211
- return this.renderTag(t, "");
212
+ renderOpeningTag(e) {
213
+ return this.renderTag(e, "");
214
+ }
215
+ renderClosingTag(e) {
216
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
217
+ }
218
+ getMatchingNode(e) {
219
+ const t = this.nodes[e.type];
220
+ if (typeof t == "function")
221
+ return t(e);
222
+ }
223
+ getMatchingMark(e) {
224
+ const t = this.marks[e.type];
225
+ if (typeof t == "function")
226
+ return t(e);
227
+ }
228
+ }
229
+ class X {
230
+ constructor() {
231
+ h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, s = 1) => j(p({}, e), {
232
+ per_page: t,
233
+ page: s
234
+ })), 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) => {
235
+ const s = Math.abs(t - e) || 0, n = e < t ? 1 : -1;
236
+ return this.arrayFrom(s, (o, a) => a * n + e);
237
+ }), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, n) => [...s, ...n], []));
238
+ }
239
+ stringify(e, t, s) {
240
+ const n = [];
241
+ for (const o in e) {
242
+ if (!Object.prototype.hasOwnProperty.call(e, o))
243
+ continue;
244
+ const a = e[o], i = s ? "" : encodeURIComponent(o);
245
+ let c;
246
+ typeof a == "object" ? c = this.stringify(a, t ? t + encodeURIComponent("[" + i + "]") : i, Array.isArray(a)) : c = (t ? t + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(a), n.push(c);
247
+ }
248
+ return n.join("&");
212
249
  }
213
- renderClosingTag(t) {
214
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((n) => n.constructor === String ? `</${n}>` : `</${n.tag}>`).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.timeout ? e.timeout * 1e3 : 1e3, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {};
215
254
  }
216
- getMatchingNode(t) {
217
- if (typeof this.nodes[t.type] == "function")
218
- return this.nodes[t.type](t);
255
+ get(e, t) {
256
+ return this.url = e, this.parameters = t, this._methodHandler("get");
219
257
  }
220
- getMatchingMark(t) {
221
- if (typeof this.marks[t.type] == "function")
222
- return this.marks[t.type](t);
258
+ post(e, t) {
259
+ return this.url = e, this.parameters = t, this._methodHandler("post");
223
260
  }
224
- }
225
- /*!
226
- * storyblok-js-client v4.5.2
227
- * Universal JavaScript SDK for Storyblok's API
228
- * (c) 2020-2022 Stobylok Team
229
- */
230
- function H(r) {
231
- return typeof r == "number" && r == r && r !== 1 / 0 && r !== -1 / 0;
232
- }
233
- function X(r, t, e) {
234
- if (!H(t))
235
- throw new TypeError("Expected `limit` to be a finite number");
236
- if (!H(e))
237
- throw new TypeError("Expected `interval` to be a finite number");
238
- var n = [], s = [], o = 0, a = function() {
239
- o++;
240
- var l = setTimeout(function() {
241
- o--, n.length > 0 && a(), s = s.filter(function(u) {
242
- return u !== l;
243
- });
244
- }, e);
245
- s.indexOf(l) < 0 && s.push(l);
246
- var c = n.shift();
247
- c.resolve(r.apply(c.self, c.args));
248
- }, i = function() {
249
- var l = arguments, c = this;
250
- return new Promise(function(u, h) {
251
- n.push({ resolve: u, reject: h, args: l, self: c }), o < t && a();
252
- });
253
- };
254
- return i.abort = function() {
255
- s.forEach(clearTimeout), s = [], n.forEach(function(l) {
256
- l.reject(new throttle.AbortError());
257
- }), n.length = 0;
258
- }, i;
259
- }
260
- X.AbortError = function() {
261
- Error.call(this, "Throttled function aborted"), this.name = "AbortError";
262
- };
263
- const gt = function(r, t) {
264
- if (!r)
265
- return null;
266
- let e = {};
267
- for (let n in r) {
268
- let s = r[n];
269
- t.indexOf(n) > -1 && s !== null && (e[n] = s);
261
+ put(e, t) {
262
+ return this.url = e, this.parameters = t, this._methodHandler("put");
270
263
  }
271
- return e;
272
- };
273
- var mt = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (r) => ({ tag: ["pre", { tag: "code", attrs: r.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (r) => ({ tag: `h${r.attrs.level}` }), image: (r) => ({ singleTag: [{ tag: "img", attrs: gt(r.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(r) {
274
- const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
275
- return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
276
- }, styled: (r) => ({ tag: [{ tag: "span", attrs: r.attrs }] }) } };
277
- class yt {
278
- constructor(t) {
279
- t || (t = mt), this.marks = t.marks || [], this.nodes = t.nodes || [];
280
- }
281
- addNode(t, e) {
282
- this.nodes[t] = e;
283
- }
284
- addMark(t, e) {
285
- this.marks[t] = e;
286
- }
287
- render(t = {}) {
288
- if (t.content && Array.isArray(t.content)) {
289
- let e = "";
290
- return t.content.forEach((n) => {
291
- e += this.renderNode(n);
292
- }), e;
293
- }
294
- return console.warn("The render method must receive an object with a content field, which is an array"), "";
264
+ delete(e, t) {
265
+ return this.url = e, this.parameters = t, this._methodHandler("delete");
295
266
  }
296
- renderNode(t) {
297
- let e = [];
298
- t.marks && t.marks.forEach((s) => {
299
- const o = this.getMatchingMark(s);
300
- o && e.push(this.renderOpeningTag(o.tag));
267
+ async _responseHandler(e) {
268
+ const t = [], s = {
269
+ data: {},
270
+ headers: {},
271
+ status: 0,
272
+ statusText: ""
273
+ };
274
+ await e.json().then((n) => {
275
+ s.data = n;
301
276
  });
302
- const n = this.getMatchingNode(t);
303
- return n && n.tag && e.push(this.renderOpeningTag(n.tag)), t.content ? t.content.forEach((s) => {
304
- e.push(this.renderNode(s));
305
- }) : t.text ? e.push(function(s) {
306
- const o = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, a = /[&<>"']/g, i = RegExp(a.source);
307
- return s && i.test(s) ? s.replace(a, (l) => o[l]) : s;
308
- }(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
309
- const o = this.getMatchingMark(s);
310
- o && e.push(this.renderClosingTag(o.tag));
311
- }), e.join("");
312
- }
313
- renderTag(t, e) {
314
- return t.constructor === String ? `<${t}${e}>` : t.map((n) => {
315
- if (n.constructor === String)
316
- return `<${n}${e}>`;
317
- {
318
- let s = `<${n.tag}`;
319
- if (n.attrs)
320
- for (let o in n.attrs) {
321
- let a = n.attrs[o];
322
- a !== null && (s += ` ${o}="${a}"`);
323
- }
324
- return `${s}${e}>`;
325
- }
326
- }).join("");
327
- }
328
- renderOpeningTag(t) {
329
- return this.renderTag(t, "");
330
- }
331
- renderClosingTag(t) {
332
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
277
+ for (const n of e.headers.entries())
278
+ t[n[0]] = n[1];
279
+ return s.headers = p({}, t), s.status = e.status, s.statusText = e.statusText, s;
280
+ }
281
+ async _methodHandler(e) {
282
+ const t = new URL(`${this.baseURL}${this.url}`);
283
+ let s = null;
284
+ if (e === "get") {
285
+ const i = new X();
286
+ t.search = i.stringify(this.parameters);
287
+ } else
288
+ s = JSON.stringify(this.parameters);
289
+ const n = new AbortController(), { signal: o } = n, a = setTimeout(() => n.abort(), this.timeout);
290
+ try {
291
+ const i = await this.fetch(`${t}`, {
292
+ method: e,
293
+ headers: this.headers,
294
+ body: s,
295
+ signal: o
296
+ });
297
+ clearTimeout(a);
298
+ const c = await this._responseHandler(i);
299
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
300
+ } catch (i) {
301
+ return i;
302
+ }
333
303
  }
334
- getMatchingNode(t) {
335
- if (typeof this.nodes[t.type] == "function")
336
- return this.nodes[t.type](t);
304
+ eject() {
305
+ this.ejectInterceptor = !0;
337
306
  }
338
- getMatchingMark(t) {
339
- if (typeof this.marks[t.type] == "function")
340
- return this.marks[t.type](t);
307
+ _statusHandler(e) {
308
+ if (/20[01]/g.test(`${e.status}`))
309
+ return e;
310
+ throw {
311
+ message: new Error(e.statusText || `status: ${e.status}`),
312
+ response: e
313
+ };
341
314
  }
342
315
  }
343
- const kt = (r = 0, t = r) => {
344
- const e = Math.abs(t - r) || 0, n = r < t ? 1 : -1;
345
- return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * n + r);
346
- }, x = (r, t, e) => {
347
- const n = [];
348
- for (const s in r) {
349
- if (!Object.prototype.hasOwnProperty.call(r, s))
350
- continue;
351
- const o = r[s], a = e ? "" : encodeURIComponent(s);
352
- let i;
353
- i = typeof o == "object" ? x(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), n.push(i);
354
- }
355
- return n.join("&");
356
- };
357
- let _ = {}, p = {};
358
- class _t {
359
- constructor(t, e) {
360
- if (!e) {
361
- let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
362
- e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
316
+ let k = {};
317
+ const m = {};
318
+ class Me {
319
+ constructor(e, t) {
320
+ 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) {
321
+ const o = e.region ? `-${e.region}` : "", a = e.https === !1 ? "http" : "https";
322
+ e.oauthToken ? t = `${a}://api${o}.storyblok.com/v1` : t = `${a}://api${o}.storyblok.com/v2`;
363
323
  }
364
- let n = Object.assign({}, t.headers), s = 5;
365
- t.oauthToken !== void 0 && (n.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new yt(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = X(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = st.create({ baseURL: e, timeout: t.timeout || 0, headers: n, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
366
- }
367
- setComponentResolver(t) {
368
- this.richTextResolver.addNode("blok", (e) => {
369
- let n = "";
370
- return e.attrs.body.forEach((s) => {
371
- n += t(s.component, s);
372
- }), { html: n };
324
+ const s = new Headers();
325
+ s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), s.forEach((o, a) => {
326
+ e.headers && e.headers[a] && s.set(a, e.headers[a]);
327
+ });
328
+ let n = 5;
329
+ e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new R(e.richTextSchema) : this.richTextResolver = new R(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries, this.throttle = de(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new X(), this.resolveNestedRelations = !1, this.client = new Ne({
330
+ baseURL: t,
331
+ timeout: e.timeout || 0,
332
+ headers: s,
333
+ responseInterceptor: e.responseInterceptor,
334
+ fetch: e.fetch
373
335
  });
374
336
  }
375
- parseParams(t = {}) {
376
- return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = p[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
337
+ setComponentResolver(e) {
338
+ this.richTextResolver.addNode("blok", (t) => {
339
+ let s = "";
340
+ return t.attrs.body.forEach((n) => {
341
+ s += e(n.component, n);
342
+ }), {
343
+ html: s
344
+ };
345
+ });
377
346
  }
378
- factoryParamOptions(t, e = {}) {
379
- return ((n = "") => n.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
347
+ parseParams(e) {
348
+ return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv = m[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
380
349
  }
381
- makeRequest(t, e, n, s) {
382
- const o = this.factoryParamOptions(t, ((a = {}, i = 25, l = 1) => T(d({}, a), { per_page: i, page: l }))(e, n, s));
383
- return this.cacheResponse(t, o);
350
+ factoryParamOptions(e, t) {
351
+ return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
384
352
  }
385
- get(t, e) {
386
- let n = `/${t}`;
387
- const s = this.factoryParamOptions(n, e);
388
- return this.cacheResponse(n, s);
353
+ makeRequest(e, t, s, n) {
354
+ const o = this.factoryParamOptions(e, this.helpers.getOptionsPage(t, s, n));
355
+ return this.cacheResponse(e, o);
389
356
  }
390
- async getAll(t, e = {}, n) {
391
- const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
392
- n = n || a[a.length - 1];
393
- const i = await this.makeRequest(o, e, s, 1), l = i.total ? Math.ceil(i.total / s) : 1;
394
- return ((c = [], u) => c.map(u).reduce((h, k) => [...h, ...k], []))([i, ...await (async (c = [], u) => Promise.all(c.map(u)))(kt(1, l), async (c) => this.makeRequest(o, e, s, c + 1))], (c) => Object.values(c.data[n]));
357
+ get(e, t) {
358
+ t || (t = {});
359
+ const s = `/${e}`, n = this.factoryParamOptions(s, t);
360
+ return this.cacheResponse(s, n);
395
361
  }
396
- post(t, e) {
397
- let n = `/${t}`;
398
- return this.throttle("post", n, e);
362
+ async getAll(e, t, s) {
363
+ const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`, a = o.split("/"), i = s || a[a.length - 1], c = 1, l = await this.makeRequest(o, t, n, c), u = l.total ? Math.ceil(l.total / n) : 1, d = await this.helpers.asyncMap(this.helpers.range(c, u), (g) => this.makeRequest(o, t, n, g + 1));
364
+ return this.helpers.flatMap([l, ...d], (g) => Object.values(g.data[i]));
399
365
  }
400
- put(t, e) {
401
- let n = `/${t}`;
402
- return this.throttle("put", n, e);
366
+ post(e, t) {
367
+ const s = `/${e}`;
368
+ return Promise.resolve(this.throttle("post", s, t));
403
369
  }
404
- delete(t, e) {
405
- let n = `/${t}`;
406
- return this.throttle("delete", n, e);
370
+ put(e, t) {
371
+ const s = `/${e}`;
372
+ return Promise.resolve(this.throttle("put", s, t));
407
373
  }
408
- getStories(t) {
409
- return this.get("cdn/stories", t);
374
+ delete(e, t) {
375
+ const s = `/${e}`;
376
+ return Promise.resolve(this.throttle("delete", s, t));
410
377
  }
411
- getStory(t, e) {
412
- return this.get(`cdn/stories/${t}`, e);
378
+ getStories(e) {
379
+ return this.get("cdn/stories", e);
413
380
  }
414
- setToken(t) {
415
- this.accessToken = t;
381
+ getStory(e, t) {
382
+ return this.get(`cdn/stories/${e}`, t);
416
383
  }
417
384
  getToken() {
418
385
  return this.accessToken;
419
386
  }
420
- _cleanCopy(t) {
421
- return JSON.parse(JSON.stringify(t));
422
- }
423
- _insertLinks(t, e) {
424
- const n = t[e];
425
- n && n.fieldtype == "multilink" && n.linktype == "story" && typeof n.id == "string" && this.links[n.id] ? n.story = this._cleanCopy(this.links[n.id]) : n && n.linktype === "story" && typeof n.uuid == "string" && this.links[n.uuid] && (n.story = this._cleanCopy(this.links[n.uuid]));
426
- }
427
- _insertRelations(t, e, n) {
428
- if (n.indexOf(t.component + "." + e) > -1) {
429
- if (typeof t[e] == "string")
430
- this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
431
- else if (t[e].constructor === Array) {
432
- let s = [];
433
- t[e].forEach((o) => {
434
- this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
435
- }), t[e] = s;
387
+ ejectInterceptor() {
388
+ this.client.eject();
389
+ }
390
+ _cleanCopy(e) {
391
+ return JSON.parse(JSON.stringify(e));
392
+ }
393
+ _insertLinks(e, t) {
394
+ const s = e[t];
395
+ 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]));
396
+ }
397
+ _insertRelations(e, t, s) {
398
+ if (s.indexOf(`${e.component}.${t}`) > -1) {
399
+ if (typeof e[t] == "string")
400
+ this.relations[e[t]] && (e[t] = this._cleanCopy(this.relations[e[t]]));
401
+ else if (e[t] && e[t].constructor === Array) {
402
+ const n = [];
403
+ e[t].forEach((o) => {
404
+ this.relations[o] && n.push(this._cleanCopy(this.relations[o]));
405
+ }), e[t] = n;
436
406
  }
437
407
  }
438
408
  }
439
- _insertAssetsRelations(t, e) {
440
- e.forEach((n) => {
441
- t.id === n.id && (t.original = n, 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);
442
- });
443
- }
444
- iterateTree(t, e) {
445
- let n = (s) => {
446
- if (s != null) {
447
- if (s.constructor === Array)
448
- for (let o = 0; o < s.length; o++)
449
- n(s[o]);
450
- else if (s.constructor === Object) {
451
- if (s._stopResolving)
409
+ iterateTree(e, t) {
410
+ const s = (n) => {
411
+ if (n != null) {
412
+ if (n.constructor === Array)
413
+ for (let o = 0; o < n.length; o++)
414
+ s(n[o]);
415
+ else if (n.constructor === Object) {
416
+ if (n._stopResolving)
452
417
  return;
453
- for (let o in s)
454
- 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), n(s[o]);
418
+ for (const o in n)
419
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(n, o, t), this._insertLinks(n, o)), s(n[o]);
455
420
  }
456
421
  }
457
422
  };
458
- n(t.content);
459
- }
460
- async resolveLinks(t, e) {
461
- let n = [];
462
- if (t.link_uuids) {
463
- const s = t.link_uuids.length;
464
- let o = [];
465
- const a = 50;
466
- for (let i = 0; i < s; i += a) {
467
- const l = Math.min(s, i + a);
468
- o.push(t.link_uuids.slice(i, l));
423
+ s(e.content);
424
+ }
425
+ async resolveLinks(e, t) {
426
+ let s = [];
427
+ if (e.link_uuids) {
428
+ const n = e.link_uuids.length, o = [], a = 50;
429
+ for (let i = 0; i < n; i += a) {
430
+ const c = Math.min(n, i + a);
431
+ o.push(e.link_uuids.slice(i, c));
469
432
  }
470
433
  for (let i = 0; i < o.length; i++)
471
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((l) => {
472
- n.push(l);
434
+ (await this.getStories({
435
+ per_page: a,
436
+ language: t.language,
437
+ version: t.version,
438
+ by_uuids: o[i].join(",")
439
+ })).data.stories.forEach((c) => {
440
+ s.push(c);
473
441
  });
474
442
  } else
475
- n = t.links;
476
- n.forEach((s) => {
477
- this.links[s.uuid] = T(d({}, s), { _stopResolving: !0 });
443
+ s = e.links;
444
+ s.forEach((n) => {
445
+ this.links[n.uuid] = j(p({}, n), { _stopResolving: !0 });
478
446
  });
479
447
  }
480
- async resolveRelations(t, e) {
481
- let n = [];
482
- if (t.rel_uuids) {
483
- const s = t.rel_uuids.length;
484
- let o = [];
485
- const a = 50;
486
- for (let i = 0; i < s; i += a) {
487
- const l = Math.min(s, i + a);
488
- o.push(t.rel_uuids.slice(i, l));
448
+ async resolveRelations(e, t) {
449
+ let s = [];
450
+ if (e.rel_uuids) {
451
+ const n = e.rel_uuids.length, o = [], a = 50;
452
+ for (let i = 0; i < n; i += a) {
453
+ const c = Math.min(n, i + a);
454
+ o.push(e.rel_uuids.slice(i, c));
489
455
  }
490
456
  for (let i = 0; i < o.length; i++)
491
- (await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((l) => {
492
- n.push(l);
457
+ (await this.getStories({
458
+ per_page: a,
459
+ language: t.language,
460
+ version: t.version,
461
+ by_uuids: o[i].join(",")
462
+ })).data.stories.forEach((c) => {
463
+ s.push(c);
493
464
  });
494
465
  } else
495
- n = t.rels;
496
- n.forEach((s) => {
497
- this.relations[s.uuid] = T(d({}, s), { _stopResolving: !0 });
466
+ s = e.rels;
467
+ s && s.length > 0 && s.forEach((n) => {
468
+ this.relations[n.uuid] = j(p({}, n), { _stopResolving: !0 });
498
469
  });
499
470
  }
500
- async resolveStories(t, e) {
501
- let n = [];
502
- if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (n = 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)
503
- for (const s in this.relations)
504
- this.iterateTree(this.relations[s], n);
505
- t.story ? this.iterateTree(t.story, n) : t.stories.forEach((s) => {
506
- this.iterateTree(s, n);
471
+ async resolveStories(e, t) {
472
+ var s, n;
473
+ let o = [];
474
+ if (typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (o = 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 || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t), this.resolveNestedRelations)
475
+ for (const a in this.relations)
476
+ this.iterateTree(this.relations[a], o);
477
+ e.story ? this.iterateTree(e.story, o) : e.stories.forEach((a) => {
478
+ this.iterateTree(a, o);
507
479
  });
508
480
  }
509
- resolveAssetsRelations(t) {
510
- const { assets: e, stories: n, story: s } = t;
511
- if (n)
512
- for (const o of n)
513
- this.iterateTree(o, e);
514
- else {
515
- if (!s)
516
- return t;
517
- this.iterateTree(s, e);
518
- }
519
- }
520
- cacheResponse(t, e, n) {
521
- return n === void 0 && (n = 0), new Promise(async (s, o) => {
522
- let a = x({ url: t, params: e }), i = this.cacheProvider();
523
- if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
524
- const c = await i.get(a);
481
+ cacheResponse(e, t, s) {
482
+ return new Promise((n, o) => {
483
+ const a = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
484
+ if (this.cache.clear === "auto" && t.version === "draft" && this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
485
+ const c = i.get(a);
525
486
  if (c)
526
- return s(c);
487
+ return n(c);
527
488
  }
528
489
  try {
529
- let c = await this.throttle("get", t, { params: e, paramsSerializer: (h) => x(h) }), u = { data: c.data, headers: c.headers };
530
- if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), u = Object.assign({}, u, { perPage: c.headers["per-page"] ? parseInt(c.headers["per-page"]) : 0, total: c.headers["per-page"] ? parseInt(c.headers.total) : 0 }), c.status != 200)
531
- return o(c);
532
- (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" && p[e.token] != u.data.cv && this.flushCache(), p[e.token] = u.data.cv), s(u);
533
- } catch (c) {
534
- if (c.response && c.response.status === 429 && (n += 1) < this.maxRetries)
535
- return console.log(`Hit rate limit. Retrying in ${n} seconds.`), await (l = 1e3 * n, new Promise((u) => setTimeout(u, l))), this.cacheResponse(t, e, n).then(s).catch(o);
536
- o(c);
490
+ (async () => {
491
+ var c;
492
+ const l = await this.throttle("get", e, t);
493
+ let u = { data: l.data, headers: l.headers };
494
+ if ((c = l.headers) != null && c["per-page"] && (u = Object.assign({}, u, {
495
+ perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
496
+ total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
497
+ })), l.status != 200)
498
+ return o(l);
499
+ (u.data.story || u.data.stories) && await this.resolveStories(u.data, t), t.version === "published" && e != "/cdn/spaces/me" && i.set(a, u), u.data.cv && t.token && (t.version == "draft" && m[t.token] != u.data.cv && this.flushCache(), m[t.token] = u.data.cv), n(u);
500
+ })();
501
+ } catch {
537
502
  }
538
- var l;
539
503
  });
540
504
  }
541
- throttledRequest(t, e, n) {
542
- return this.client[t](e, n);
505
+ throttledRequest(e, t, s) {
506
+ return this.client[e](t, s);
543
507
  }
544
508
  cacheVersions() {
545
- return p;
509
+ return m;
546
510
  }
547
511
  cacheVersion() {
548
- return p[this.accessToken];
512
+ return m[this.accessToken];
549
513
  }
550
- setCacheVersion(t) {
551
- this.accessToken && (p[this.accessToken] = t);
514
+ setCacheVersion(e) {
515
+ this.accessToken && (m[this.accessToken] = e);
552
516
  }
553
517
  cacheProvider() {
554
- return this.cache.type === "memory" ? { get: (t) => _[t], getAll: () => _, set(t, e) {
555
- _[t] = e;
556
- }, flush() {
557
- _ = {};
558
- } } : { get() {
559
- }, getAll() {
560
- }, set() {
561
- }, flush() {
562
- } };
563
- }
564
- async flushCache() {
565
- return await this.cacheProvider().flush(), this;
566
- }
567
- }
568
- const Vt = (r = {}) => {
569
- const { apiOptions: t } = r;
570
- if (!t.accessToken) {
518
+ switch (this.cache.type) {
519
+ case "memory":
520
+ return {
521
+ get(e) {
522
+ return k[e];
523
+ },
524
+ getAll() {
525
+ return k;
526
+ },
527
+ set(e, t) {
528
+ k[e] = t;
529
+ },
530
+ flush() {
531
+ k = {};
532
+ }
533
+ };
534
+ default:
535
+ return {
536
+ get() {
537
+ },
538
+ getAll() {
539
+ },
540
+ set() {
541
+ },
542
+ flush() {
543
+ }
544
+ };
545
+ }
546
+ }
547
+ flushCache() {
548
+ return this.cacheProvider().flush(), this;
549
+ }
550
+ }
551
+ const it = (r = {}) => {
552
+ const { apiOptions: e } = r;
553
+ if (!e.accessToken) {
571
554
  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");
572
555
  return;
573
556
  }
574
- return { storyblokApi: new _t(t) };
557
+ return { storyblokApi: new Me(e) };
575
558
  };
576
- var bt = (r) => {
559
+ var Le = (r) => {
577
560
  if (typeof r != "object" || typeof r._editable > "u")
578
561
  return {};
579
- const t = JSON.parse(r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
562
+ const e = JSON.parse(r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
580
563
  return {
581
- "data-blok-c": JSON.stringify(t),
582
- "data-blok-uid": t.id + "-" + t.uid
564
+ "data-blok-c": JSON.stringify(e),
565
+ "data-blok-uid": e.id + "-" + e.uid
583
566
  };
584
567
  };
585
- let E;
586
- const vt = "https://app.storyblok.com/f/storyblok-v2-latest.js", Jt = (r, t, e = {}) => {
568
+ let P;
569
+ const Ue = "https://app.storyblok.com/f/storyblok-v2-latest.js", at = (r, e, t = {}) => {
587
570
  if (!(typeof window > "u")) {
588
571
  if (typeof window.storyblokRegisterEvent > "u") {
589
572
  console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
@@ -594,353 +577,377 @@ const vt = "https://app.storyblok.com/f/storyblok-v2-latest.js", Jt = (r, t, e =
594
577
  return;
595
578
  }
596
579
  window.storyblokRegisterEvent(() => {
597
- new window.StoryblokBridge(e).on(["input", "published", "change"], (s) => {
598
- s.action === "input" && s.story.id === r ? t(s.story) : (s.action === "change" || s.action === "published") && s.storyId === r && window.location.reload();
580
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (n) => {
581
+ n.action === "input" && n.story.id === r ? e(n.story) : (n.action === "change" || n.action === "published") && n.storyId === r && window.location.reload();
599
582
  });
600
583
  });
601
584
  }
602
- }, $t = (r = {}) => {
585
+ }, He = (r = {}) => {
603
586
  const {
604
- bridge: t,
605
- accessToken: e,
606
- use: n = [],
607
- apiOptions: s = {},
587
+ bridge: e,
588
+ accessToken: t,
589
+ use: s = [],
590
+ apiOptions: n = {},
608
591
  richText: o = {}
609
592
  } = r;
610
- s.accessToken = s.accessToken || e;
611
- const a = { bridge: t, apiOptions: s };
593
+ n.accessToken = n.accessToken || t;
594
+ const a = { bridge: e, apiOptions: n };
612
595
  let i = {};
613
- return n.forEach((l) => {
614
- i = d(d({}, i), l(a));
615
- }), t !== !1 && ut(vt), E = new W(o.schema), o.resolver && Z(E, o.resolver), i;
616
- }, Z = (r, t) => {
617
- r.addNode("blok", (e) => {
618
- let n = "";
619
- return e.attrs.body.forEach((s) => {
620
- n += t(s.component, s);
596
+ return s.forEach((c) => {
597
+ i = p(p({}, i), c(a));
598
+ }), e !== !1 && le(Ue), P = new R(o.schema), o.resolver && Z(P, o.resolver), i;
599
+ }, Z = (r, e) => {
600
+ r.addNode("blok", (t) => {
601
+ let s = "";
602
+ return t.attrs.body.forEach((n) => {
603
+ s += e(n.component, n);
621
604
  }), {
622
- html: n
605
+ html: s
623
606
  };
624
607
  });
625
- }, Yt = (r, t, e) => {
626
- let n = e || E;
627
- if (!n) {
608
+ }, ct = (r, e, t) => {
609
+ let s = t || P;
610
+ if (!s) {
628
611
  console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
629
612
  return;
630
613
  }
631
- return r === "" ? "" : r ? (t && (n = new W(t.schema), t.resolver && Z(n, t.resolver)), n.render(r)) : (console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
614
+ return r === "" ? "" : r ? (e && (s = new R(e.schema), e.resolver && Z(s, e.resolver)), s.render(r)) : (console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
632
615
 
633
616
  For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
634
617
  };
635
618
  function O() {
636
619
  }
637
- function S(r, t) {
638
- for (const e in t)
639
- r[e] = t[e];
620
+ function E(r, e) {
621
+ for (const t in e)
622
+ r[t] = e[t];
640
623
  return r;
641
624
  }
642
- function tt(r) {
625
+ function ee(r) {
643
626
  return r();
644
627
  }
645
628
  function V() {
646
629
  return /* @__PURE__ */ Object.create(null);
647
630
  }
648
- function y(r) {
649
- r.forEach(tt);
631
+ function b(r) {
632
+ r.forEach(ee);
650
633
  }
651
- function et(r) {
634
+ function te(r) {
652
635
  return typeof r == "function";
653
636
  }
654
- function wt(r, t) {
655
- return r != r ? t == t : r !== t || r && typeof r == "object" || typeof r == "function";
637
+ function qe(r, e) {
638
+ return r != r ? e == e : r !== e || r && typeof r == "object" || typeof r == "function";
656
639
  }
657
- function Tt(r) {
640
+ function Be(r) {
658
641
  return Object.keys(r).length === 0;
659
642
  }
660
- function Rt(r) {
661
- const t = {};
662
- for (const e in r)
663
- e[0] !== "$" && (t[e] = r[e]);
664
- return t;
665
- }
666
- function J(r, t) {
643
+ function De(r) {
667
644
  const e = {};
668
- t = new Set(t);
669
- for (const n in r)
670
- !t.has(n) && n[0] !== "$" && (e[n] = r[n]);
645
+ for (const t in r)
646
+ t[0] !== "$" && (e[t] = r[t]);
671
647
  return e;
672
648
  }
673
- function xt(r, t, e) {
674
- r.insertBefore(t, e || null);
649
+ function z(r, e) {
650
+ const t = {};
651
+ e = new Set(e);
652
+ for (const s in r)
653
+ !e.has(s) && s[0] !== "$" && (t[s] = r[s]);
654
+ return t;
675
655
  }
676
- function rt(r) {
656
+ function Fe(r, e, t) {
657
+ r.insertBefore(e, t || null);
658
+ }
659
+ function re(r) {
677
660
  r.parentNode && r.parentNode.removeChild(r);
678
661
  }
679
- function Et(r) {
662
+ function Je(r) {
680
663
  return document.createTextNode(r);
681
664
  }
682
- function Ot() {
683
- return Et("");
665
+ function Ve() {
666
+ return Je("");
684
667
  }
685
- function St(r) {
668
+ function ze(r) {
686
669
  return Array.from(r.childNodes);
687
670
  }
688
- function Y(r, t) {
689
- return new r(t);
671
+ function Y(r, e) {
672
+ return new r(e);
690
673
  }
691
- let I;
692
- function m(r) {
693
- I = r;
674
+ let L;
675
+ function _(r) {
676
+ L = r;
694
677
  }
695
- const g = [], F = [], v = [], K = [], jt = Promise.resolve();
696
- let j = !1;
697
- function Pt() {
698
- j || (j = !0, jt.then(nt));
678
+ const y = [], K = [], w = [], Q = [], Ye = Promise.resolve();
679
+ let S = !1;
680
+ function Ke() {
681
+ S || (S = !0, Ye.then(se));
699
682
  }
700
- function P(r) {
701
- v.push(r);
683
+ function I(r) {
684
+ w.push(r);
702
685
  }
703
- const R = /* @__PURE__ */ new Set();
704
- let b = 0;
705
- function nt() {
706
- const r = I;
686
+ const x = /* @__PURE__ */ new Set();
687
+ let v = 0;
688
+ function se() {
689
+ const r = L;
707
690
  do {
708
- for (; b < g.length; ) {
709
- const t = g[b];
710
- b++, m(t), At(t.$$);
691
+ for (; v < y.length; ) {
692
+ const e = y[v];
693
+ v++, _(e), Qe(e.$$);
711
694
  }
712
- for (m(null), g.length = 0, b = 0; F.length; )
713
- F.pop()();
714
- for (let t = 0; t < v.length; t += 1) {
715
- const e = v[t];
716
- R.has(e) || (R.add(e), e());
695
+ for (_(null), y.length = 0, v = 0; K.length; )
696
+ K.pop()();
697
+ for (let e = 0; e < w.length; e += 1) {
698
+ const t = w[e];
699
+ x.has(t) || (x.add(t), t());
717
700
  }
718
- v.length = 0;
719
- } while (g.length);
720
- for (; K.length; )
721
- K.pop()();
722
- j = !1, R.clear(), m(r);
701
+ w.length = 0;
702
+ } while (y.length);
703
+ for (; Q.length; )
704
+ Q.pop()();
705
+ S = !1, x.clear(), _(r);
723
706
  }
724
- function At(r) {
707
+ function Qe(r) {
725
708
  if (r.fragment !== null) {
726
- r.update(), y(r.before_update);
727
- const t = r.dirty;
728
- r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(P);
709
+ r.update(), b(r.before_update);
710
+ const e = r.dirty;
711
+ r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, e), r.after_update.forEach(I);
729
712
  }
730
713
  }
731
714
  const $ = /* @__PURE__ */ new Set();
732
715
  let f;
733
- function Ct() {
716
+ function Ge() {
734
717
  f = {
735
718
  r: 0,
736
719
  c: [],
737
720
  p: f
721
+ // parent group
738
722
  };
739
723
  }
740
- function Mt() {
741
- f.r || y(f.c), f = f.p;
724
+ function We() {
725
+ f.r || b(f.c), f = f.p;
742
726
  }
743
- function A(r, t) {
744
- r && r.i && ($.delete(r), r.i(t));
727
+ function C(r, e) {
728
+ r && r.i && ($.delete(r), r.i(e));
745
729
  }
746
- function G(r, t, e, n) {
730
+ function G(r, e, t, s) {
747
731
  if (r && r.o) {
748
732
  if ($.has(r))
749
733
  return;
750
734
  $.add(r), f.c.push(() => {
751
- $.delete(r), n && (e && r.d(1), n());
752
- }), r.o(t);
735
+ $.delete(r), s && (t && r.d(1), s());
736
+ }), r.o(e);
753
737
  } else
754
- n && n();
738
+ s && s();
755
739
  }
756
- function Nt(r, t) {
757
- const e = {}, n = {}, s = { $$scope: 1 };
740
+ function Xe(r, e) {
741
+ const t = {}, s = {}, n = { $$scope: 1 };
758
742
  let o = r.length;
759
743
  for (; o--; ) {
760
- const a = r[o], i = t[o];
744
+ const a = r[o], i = e[o];
761
745
  if (i) {
762
- for (const l in a)
763
- l in i || (n[l] = 1);
764
- for (const l in i)
765
- s[l] || (e[l] = i[l], s[l] = 1);
746
+ for (const c in a)
747
+ c in i || (s[c] = 1);
748
+ for (const c in i)
749
+ n[c] || (t[c] = i[c], n[c] = 1);
766
750
  r[o] = i;
767
751
  } else
768
- for (const l in a)
769
- s[l] = 1;
752
+ for (const c in a)
753
+ n[c] = 1;
770
754
  }
771
- for (const a in n)
772
- a in e || (e[a] = void 0);
773
- return e;
755
+ for (const a in s)
756
+ a in t || (t[a] = void 0);
757
+ return t;
774
758
  }
775
- function It(r) {
759
+ function Ze(r) {
776
760
  return typeof r == "object" && r !== null ? r : {};
777
761
  }
778
- function Q(r) {
762
+ function W(r) {
779
763
  r && r.c();
780
764
  }
781
- function C(r, t, e, n) {
782
- const { fragment: s, after_update: o } = r.$$;
783
- s && s.m(t, e), n || P(() => {
784
- const a = r.$$.on_mount.map(tt).filter(et);
785
- r.$$.on_destroy ? r.$$.on_destroy.push(...a) : y(a), r.$$.on_mount = [];
786
- }), o.forEach(P);
765
+ function A(r, e, t, s) {
766
+ const { fragment: n, after_update: o } = r.$$;
767
+ n && n.m(e, t), s || I(() => {
768
+ const a = r.$$.on_mount.map(ee).filter(te);
769
+ r.$$.on_destroy ? r.$$.on_destroy.push(...a) : b(a), r.$$.on_mount = [];
770
+ }), o.forEach(I);
787
771
  }
788
- function M(r, t) {
789
- const e = r.$$;
790
- e.fragment !== null && (y(e.on_destroy), e.fragment && e.fragment.d(t), e.on_destroy = e.fragment = null, e.ctx = []);
772
+ function N(r, e) {
773
+ const t = r.$$;
774
+ t.fragment !== null && (b(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
791
775
  }
792
- function qt(r, t) {
793
- r.$$.dirty[0] === -1 && (g.push(r), Pt(), r.$$.dirty.fill(0)), r.$$.dirty[t / 31 | 0] |= 1 << t % 31;
776
+ function et(r, e) {
777
+ r.$$.dirty[0] === -1 && (y.push(r), Ke(), r.$$.dirty.fill(0)), r.$$.dirty[e / 31 | 0] |= 1 << e % 31;
794
778
  }
795
- function Lt(r, t, e, n, s, o, a, i = [-1]) {
796
- const l = I;
797
- m(r);
798
- const c = r.$$ = {
779
+ function tt(r, e, t, s, n, o, a, i = [-1]) {
780
+ const c = L;
781
+ _(r);
782
+ const l = r.$$ = {
799
783
  fragment: null,
800
784
  ctx: [],
785
+ // state
801
786
  props: o,
802
787
  update: O,
803
- not_equal: s,
788
+ not_equal: n,
804
789
  bound: V(),
790
+ // lifecycle
805
791
  on_mount: [],
806
792
  on_destroy: [],
807
793
  on_disconnect: [],
808
794
  before_update: [],
809
795
  after_update: [],
810
- context: new Map(t.context || (l ? l.$$.context : [])),
796
+ context: new Map(e.context || (c ? c.$$.context : [])),
797
+ // everything else
811
798
  callbacks: V(),
812
799
  dirty: i,
813
800
  skip_bound: !1,
814
- root: t.target || l.$$.root
801
+ root: e.target || c.$$.root
815
802
  };
816
- a && a(c.root);
803
+ a && a(l.root);
817
804
  let u = !1;
818
- if (c.ctx = e ? e(r, t.props || {}, (h, k, ...q) => {
819
- const L = q.length ? q[0] : k;
820
- return c.ctx && s(c.ctx[h], c.ctx[h] = L) && (!c.skip_bound && c.bound[h] && c.bound[h](L), u && qt(r, h)), k;
821
- }) : [], c.update(), u = !0, y(c.before_update), c.fragment = n ? n(c.ctx) : !1, t.target) {
822
- if (t.hydrate) {
823
- const h = St(t.target);
824
- c.fragment && c.fragment.l(h), h.forEach(rt);
805
+ if (l.ctx = t ? t(r, e.props || {}, (d, g, ...U) => {
806
+ const H = U.length ? U[0] : g;
807
+ return l.ctx && n(l.ctx[d], l.ctx[d] = H) && (!l.skip_bound && l.bound[d] && l.bound[d](H), u && et(r, d)), g;
808
+ }) : [], l.update(), u = !0, b(l.before_update), l.fragment = s ? s(l.ctx) : !1, e.target) {
809
+ if (e.hydrate) {
810
+ const d = ze(e.target);
811
+ l.fragment && l.fragment.l(d), d.forEach(re);
825
812
  } else
826
- c.fragment && c.fragment.c();
827
- t.intro && A(r.$$.fragment), C(r, t.target, t.anchor, t.customElement), nt();
813
+ l.fragment && l.fragment.c();
814
+ e.intro && C(r.$$.fragment), A(r, e.target, e.anchor, e.customElement), se();
828
815
  }
829
- m(l);
816
+ _(c);
830
817
  }
831
- class Bt {
818
+ class rt {
832
819
  $destroy() {
833
- M(this, 1), this.$destroy = O;
820
+ N(this, 1), this.$destroy = O;
834
821
  }
835
- $on(t, e) {
836
- if (!et(e))
822
+ $on(e, t) {
823
+ if (!te(t))
837
824
  return O;
838
- const n = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
839
- return n.push(e), () => {
840
- const s = n.indexOf(e);
841
- s !== -1 && n.splice(s, 1);
825
+ const s = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
826
+ return s.push(t), () => {
827
+ const n = s.indexOf(t);
828
+ n !== -1 && s.splice(n, 1);
842
829
  };
843
830
  }
844
- $set(t) {
845
- this.$$set && !Tt(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
846
- }
847
- }
848
- function zt(r) {
849
- let t, e, n;
850
- const s = [{ blok: r[0] }, r[2]];
851
- var o = r[1];
831
+ $set(e) {
832
+ this.$$set && !Be(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
833
+ }
834
+ }
835
+ function st(r) {
836
+ let e, t, s;
837
+ const n = [
838
+ { blok: (
839
+ /*blok*/
840
+ r[0]
841
+ ) },
842
+ /*$$restProps*/
843
+ r[2]
844
+ ];
845
+ var o = (
846
+ /*component*/
847
+ r[1]
848
+ );
852
849
  function a(i) {
853
- let l = {};
854
- for (let c = 0; c < s.length; c += 1)
855
- l = S(l, s[c]);
856
- return { props: l };
850
+ let c = {};
851
+ for (let l = 0; l < n.length; l += 1)
852
+ c = E(c, n[l]);
853
+ return { props: c };
857
854
  }
858
- return o && (t = Y(o, a())), {
855
+ return o && (e = Y(o, a())), {
859
856
  c() {
860
- t && Q(t.$$.fragment), e = Ot();
857
+ e && W(e.$$.fragment), t = Ve();
861
858
  },
862
- m(i, l) {
863
- t && C(t, i, l), xt(i, e, l), n = !0;
859
+ m(i, c) {
860
+ e && A(e, i, c), Fe(i, t, c), s = !0;
864
861
  },
865
- p(i, [l]) {
866
- const c = l & 5 ? Nt(s, [
867
- l & 1 && { blok: i[0] },
868
- l & 4 && It(i[2])
862
+ p(i, [c]) {
863
+ const l = c & /*blok, $$restProps*/
864
+ 5 ? Xe(n, [
865
+ c & /*blok*/
866
+ 1 && { blok: (
867
+ /*blok*/
868
+ i[0]
869
+ ) },
870
+ c & /*$$restProps*/
871
+ 4 && Ze(
872
+ /*$$restProps*/
873
+ i[2]
874
+ )
869
875
  ]) : {};
870
- if (o !== (o = i[1])) {
871
- if (t) {
872
- Ct();
873
- const u = t;
876
+ if (o !== (o = /*component*/
877
+ i[1])) {
878
+ if (e) {
879
+ Ge();
880
+ const u = e;
874
881
  G(u.$$.fragment, 1, 0, () => {
875
- M(u, 1);
876
- }), Mt();
882
+ N(u, 1);
883
+ }), We();
877
884
  }
878
- o ? (t = Y(o, a()), Q(t.$$.fragment), A(t.$$.fragment, 1), C(t, e.parentNode, e)) : t = null;
885
+ o ? (e = Y(o, a()), W(e.$$.fragment), C(e.$$.fragment, 1), A(e, t.parentNode, t)) : e = null;
879
886
  } else
880
- o && t.$set(c);
887
+ o && e.$set(l);
881
888
  },
882
889
  i(i) {
883
- n || (t && A(t.$$.fragment, i), n = !0);
890
+ s || (e && C(e.$$.fragment, i), s = !0);
884
891
  },
885
892
  o(i) {
886
- t && G(t.$$.fragment, i), n = !1;
893
+ e && G(e.$$.fragment, i), s = !1;
887
894
  },
888
895
  d(i) {
889
- i && rt(e), t && M(t, i);
896
+ i && re(t), e && N(e, i);
890
897
  }
891
898
  };
892
899
  }
893
- function Dt(r, t, e) {
894
- const n = ["blok"];
895
- let s = J(t, n), o, { blok: a } = t;
896
- return a ? o = Ut(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), r.$$set = (i) => {
897
- t = S(S({}, t), Rt(i)), e(2, s = J(t, n)), "blok" in i && e(0, a = i.blok);
898
- }, [a, o, s];
900
+ function nt(r, e, t) {
901
+ const s = ["blok"];
902
+ let n = z(e, s), o, { blok: a } = e;
903
+ return a ? o = ot(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), r.$$set = (i) => {
904
+ e = E(E({}, e), De(i)), t(2, n = z(e, s)), "blok" in i && t(0, a = i.blok);
905
+ }, [a, o, n];
899
906
  }
900
- class Ft extends Bt {
901
- constructor(t) {
902
- super(), Lt(this, t, Dt, zt, wt, { blok: 0 });
907
+ class lt extends rt {
908
+ constructor(e) {
909
+ super(), tt(this, e, nt, st, qe, { blok: 0 });
903
910
  }
904
911
  }
905
- const Kt = (r, t) => {
906
- const e = (n) => {
907
- const s = bt(n);
908
- s["data-blok-c"] && (r.setAttribute("data-blok-c", s["data-blok-c"]), r.setAttribute("data-blok-uid", s["data-blok-uid"]), r.classList.add("storyblok__outline"));
912
+ const ht = (r, e) => {
913
+ const t = (s) => {
914
+ const n = Le(s);
915
+ n["data-blok-c"] && (r.setAttribute("data-blok-c", n["data-blok-c"]), r.setAttribute("data-blok-uid", n["data-blok-uid"]), r.classList.add("storyblok__outline"));
909
916
  };
910
- return e(t), {
911
- update(n) {
912
- e(n);
917
+ return t(e), {
918
+ update(s) {
919
+ t(s);
913
920
  }
914
921
  };
915
922
  };
916
- let N = null;
917
- const Gt = () => (N || console.log(
923
+ let M = null;
924
+ const ut = () => (M || console.log(
918
925
  "You can't use getStoryblokApi if you're not loading apiPlugin."
919
- ), N);
920
- let w = null;
921
- const Qt = (r) => {
922
- const { storyblokApi: t } = $t(r);
923
- N = t, w = r.components || {};
924
- }, Ut = (r) => {
925
- let t = null;
926
- return t = typeof w == "function" ? w()[r] : w[r], t || console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
926
+ ), M);
927
+ let T = null;
928
+ const dt = (r) => {
929
+ const { storyblokApi: e } = He(r);
930
+ M = e, T = r.components || {};
931
+ }, ot = (r) => {
932
+ let e = null;
933
+ return e = typeof T == "function" ? T()[r] : T[r], e || console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
927
934
  storyblokInit({
928
935
  accessToken: "<your-token>",
929
936
  components: {
930
937
  "teaser": Teaser
931
938
  }
932
939
  })
933
- `), t;
940
+ `), e;
934
941
  };
935
942
  export {
936
- dt as RichTextSchema,
937
- Ft as StoryblokComponent,
938
- Vt as apiPlugin,
939
- Ut as getComponent,
940
- Gt as getStoryblokApi,
941
- Yt as renderRichText,
942
- Kt as storyblokEditable,
943
- Qt as storyblokInit,
944
- Gt as useStoryblokApi,
945
- Jt as useStoryblokBridge
943
+ Ce as RichTextSchema,
944
+ lt as StoryblokComponent,
945
+ it as apiPlugin,
946
+ ot as getComponent,
947
+ ut as getStoryblokApi,
948
+ ct as renderRichText,
949
+ ht as storyblokEditable,
950
+ dt as storyblokInit,
951
+ ut as useStoryblokApi,
952
+ at as useStoryblokBridge
946
953
  };