@storyblok/svelte 2.3.3 → 2.3.5

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,69 +1,37 @@
1
- import e from "axios";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a2, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a2, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a2, prop, b[prop]);
17
- }
18
- return a2;
19
- };
20
- var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
21
- let loaded = false;
22
- const callbacks = [];
23
- const loadBridge = (src) => {
24
- return new Promise((resolve, reject) => {
25
- if (typeof window === "undefined")
26
- return;
27
- window.storyblokRegisterEvent = (cb) => {
28
- if (window.location === window.parent.location) {
29
- console.warn("You are not in Draft Mode or in the Visual Editor.");
30
- return;
31
- }
32
- if (!loaded)
33
- callbacks.push(cb);
34
- else
35
- cb();
36
- };
37
- if (document.getElementById("storyblok-javascript-bridge"))
1
+ import rt from "axios";
2
+ var nt = Object.defineProperty, st = Object.defineProperties, ot = Object.getOwnPropertyDescriptors, q = Object.getOwnPropertySymbols, it = Object.prototype.hasOwnProperty, at = Object.prototype.propertyIsEnumerable, L = (r, t, e) => t in r ? nt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, d = (r, t) => {
3
+ for (var e in t || (t = {}))
4
+ it.call(t, e) && L(r, e, t[e]);
5
+ if (q)
6
+ for (var e of q(t))
7
+ at.call(t, e) && L(r, e, t[e]);
8
+ return r;
9
+ }, $ = (r, t) => st(r, ot(t));
10
+ let B = !1;
11
+ const z = [], lt = (r) => new Promise((t, e) => {
12
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
13
+ if (window.location === window.parent.location) {
14
+ console.warn("You are not in Draft Mode or in the Visual Editor.");
38
15
  return;
39
- const script = document.createElement("script");
40
- script.async = true;
41
- script.src = src;
42
- script.id = "storyblok-javascript-bridge";
43
- script.onerror = (error) => reject(error);
44
- script.onload = (ev) => {
45
- callbacks.forEach((cb) => cb());
46
- loaded = true;
47
- resolve(ev);
48
- };
49
- document.getElementsByTagName("head")[0].appendChild(script);
50
- });
51
- };
52
- const pick = function(attrs, allowed) {
53
- if (!attrs) {
54
- return null;
55
- }
56
- let h2 = {};
57
- for (let key in attrs) {
58
- let value = attrs[key];
59
- if (allowed.indexOf(key) > -1 && value !== null) {
60
- h2[key] = value;
61
16
  }
62
- }
63
- return h2;
64
- };
65
- const isEmailLinkType = (type) => type === "email";
66
- var defaultHtmlSerializer = {
17
+ B ? s() : z.push(s);
18
+ }, document.getElementById("storyblok-javascript-bridge")))
19
+ 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
+ z.forEach((o) => o()), B = !0, t(s);
23
+ }, document.getElementsByTagName("head")[0].appendChild(n);
24
+ }), ct = 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);
31
+ }
32
+ return e;
33
+ }, ut = (r) => r === "email";
34
+ var ht = {
67
35
  nodes: {
68
36
  horizontal_rule() {
69
37
  return {
@@ -80,13 +48,13 @@ var defaultHtmlSerializer = {
80
48
  tag: "ul"
81
49
  };
82
50
  },
83
- code_block(node) {
51
+ code_block(r) {
84
52
  return {
85
53
  tag: [
86
54
  "pre",
87
55
  {
88
56
  tag: "code",
89
- attrs: node.attrs
57
+ attrs: r.attrs
90
58
  }
91
59
  ]
92
60
  };
@@ -96,17 +64,17 @@ var defaultHtmlSerializer = {
96
64
  singleTag: "br"
97
65
  };
98
66
  },
99
- heading(node) {
67
+ heading(r) {
100
68
  return {
101
- tag: `h${node.attrs.level}`
69
+ tag: `h${r.attrs.level}`
102
70
  };
103
71
  },
104
- image(node) {
72
+ image(r) {
105
73
  return {
106
74
  singleTag: [
107
75
  {
108
76
  tag: "img",
109
- attrs: pick(node.attrs, ["src", "alt", "title"])
77
+ attrs: ct(r.attrs, ["src", "alt", "title"])
110
78
  }
111
79
  ]
112
80
  };
@@ -158,161 +126,100 @@ var defaultHtmlSerializer = {
158
126
  tag: "i"
159
127
  };
160
128
  },
161
- link(node) {
162
- const attrs = __spreadValues({}, node.attrs);
163
- const { linktype = "url" } = node.attrs;
164
- if (isEmailLinkType(linktype)) {
165
- attrs.href = `mailto:${attrs.href}`;
166
- }
167
- if (attrs.anchor) {
168
- attrs.href = `${attrs.href}#${attrs.anchor}`;
169
- delete attrs.anchor;
170
- }
171
- return {
129
+ link(r) {
130
+ const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
131
+ return ut(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
172
132
  tag: [
173
133
  {
174
134
  tag: "a",
175
- attrs
135
+ attrs: t
176
136
  }
177
137
  ]
178
138
  };
179
139
  },
180
- styled(node) {
140
+ styled(r) {
181
141
  return {
182
142
  tag: [
183
143
  {
184
144
  tag: "span",
185
- attrs: node.attrs
145
+ attrs: r.attrs
186
146
  }
187
147
  ]
188
148
  };
189
149
  }
190
150
  }
191
151
  };
192
- const escapeHTML = function(string) {
193
- const htmlEscapes = {
152
+ const ft = function(r) {
153
+ const t = {
194
154
  "&": "&",
195
155
  "<": "&lt;",
196
156
  ">": "&gt;",
197
157
  '"': "&quot;",
198
158
  "'": "&#39;"
199
- };
200
- const reUnescapedHtml = /[&<>"']/g;
201
- const reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
202
- return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr]) : string;
159
+ }, e = /[&<>"']/g, n = RegExp(e.source);
160
+ return r && n.test(r) ? r.replace(e, (s) => t[s]) : r;
203
161
  };
204
- class RichTextResolver {
205
- constructor(schema) {
206
- if (!schema) {
207
- schema = defaultHtmlSerializer;
208
- }
209
- this.marks = schema.marks || [];
210
- this.nodes = schema.nodes || [];
211
- }
212
- addNode(key, schema) {
213
- this.nodes[key] = schema;
214
- }
215
- addMark(key, schema) {
216
- this.marks[key] = schema;
217
- }
218
- render(data = {}) {
219
- if (data.content && Array.isArray(data.content)) {
220
- let html = "";
221
- data.content.forEach((node) => {
222
- html += this.renderNode(node);
223
- });
224
- return html;
225
- }
226
- console.warn("The render method must receive an object with a content field, which is an array");
227
- return "";
228
- }
229
- renderNode(item) {
230
- let html = [];
231
- if (item.marks) {
232
- item.marks.forEach((m) => {
233
- const mark = this.getMatchingMark(m);
234
- if (mark) {
235
- html.push(this.renderOpeningTag(mark.tag));
236
- }
237
- });
238
- }
239
- const node = this.getMatchingNode(item);
240
- if (node && node.tag) {
241
- html.push(this.renderOpeningTag(node.tag));
242
- }
243
- if (item.content) {
244
- item.content.forEach((content) => {
245
- html.push(this.renderNode(content));
246
- });
247
- } else if (item.text) {
248
- html.push(escapeHTML(item.text));
249
- } else if (node && node.singleTag) {
250
- html.push(this.renderTag(node.singleTag, " /"));
251
- } else if (node && node.html) {
252
- html.push(node.html);
162
+ class K {
163
+ constructor(t) {
164
+ t || (t = ht), 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;
253
178
  }
254
- if (node && node.tag) {
255
- html.push(this.renderClosingTag(node.tag));
256
- }
257
- if (item.marks) {
258
- item.marks.slice(0).reverse().forEach((m) => {
259
- const mark = this.getMatchingMark(m);
260
- if (mark) {
261
- html.push(this.renderClosingTag(mark.tag));
262
- }
263
- });
264
- }
265
- return html.join("");
179
+ return console.warn("The render method must receive an object with a content field, which is an array"), "";
266
180
  }
267
- renderTag(tags, ending) {
268
- if (tags.constructor === String) {
269
- return `<${tags}${ending}>`;
270
- }
271
- const all = tags.map((tag) => {
272
- if (tag.constructor === String) {
273
- return `<${tag}${ending}>`;
274
- } else {
275
- let h2 = `<${tag.tag}`;
276
- if (tag.attrs) {
277
- for (let key in tag.attrs) {
278
- let value = tag.attrs[key];
279
- if (value !== null) {
280
- h2 += ` ${key}="${value}"`;
281
- }
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));
186
+ });
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(ft(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) => {
197
+ if (s.constructor === String)
198
+ return `<${s}${e}>`;
199
+ {
200
+ let o = `<${s.tag}`;
201
+ if (s.attrs)
202
+ for (let a in s.attrs) {
203
+ let i = s.attrs[a];
204
+ i !== null && (o += ` ${a}="${i}"`);
282
205
  }
283
- }
284
- return `${h2}${ending}>`;
206
+ return `${o}${e}>`;
285
207
  }
286
- });
287
- return all.join("");
208
+ }).join("");
288
209
  }
289
- renderOpeningTag(tags) {
290
- return this.renderTag(tags, "");
210
+ renderOpeningTag(t) {
211
+ return this.renderTag(t, "");
291
212
  }
292
- renderClosingTag(tags) {
293
- if (tags.constructor === String) {
294
- return `</${tags}>`;
295
- }
296
- const all = tags.slice(0).reverse().map((tag) => {
297
- if (tag.constructor === String) {
298
- return `</${tag}>`;
299
- } else {
300
- return `</${tag.tag}>`;
301
- }
302
- });
303
- return all.join("");
213
+ renderClosingTag(t) {
214
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((n) => n.constructor === String ? `</${n}>` : `</${n.tag}>`).join("");
304
215
  }
305
- getMatchingNode(item) {
306
- if (typeof this.nodes[item.type] !== "function") {
307
- return;
308
- }
309
- return this.nodes[item.type](item);
216
+ getMatchingNode(t) {
217
+ if (typeof this.nodes[t.type] == "function")
218
+ return this.nodes[t.type](t);
310
219
  }
311
- getMatchingMark(item) {
312
- if (typeof this.marks[item.type] !== "function") {
313
- return;
314
- }
315
- return this.marks[item.type](item);
220
+ getMatchingMark(t) {
221
+ if (typeof this.marks[t.type] == "function")
222
+ return this.marks[t.type](t);
316
223
  }
317
224
  }
318
225
  /*!
@@ -320,340 +227,334 @@ class RichTextResolver {
320
227
  * Universal JavaScript SDK for Storyblok's API
321
228
  * (c) 2020-2022 Stobylok Team
322
229
  */
323
- function t(e2) {
324
- return typeof e2 == "number" && (e2 == e2 && e2 !== 1 / 0 && e2 !== -1 / 0);
230
+ function D(r) {
231
+ return typeof r == "number" && r == r && r !== 1 / 0 && r !== -1 / 0;
325
232
  }
326
- function s(e2, s2, r2) {
327
- if (!t(s2))
233
+ function G(r, t, e) {
234
+ if (!D(t))
328
235
  throw new TypeError("Expected `limit` to be a finite number");
329
- if (!t(r2))
236
+ if (!D(e))
330
237
  throw new TypeError("Expected `interval` to be a finite number");
331
- var i2 = [], n2 = [], o2 = 0, a2 = function() {
332
- o2++;
333
- var t2 = setTimeout(function() {
334
- o2--, i2.length > 0 && a2(), n2 = n2.filter(function(e3) {
335
- return e3 !== t2;
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;
336
243
  });
337
- }, r2);
338
- n2.indexOf(t2) < 0 && n2.push(t2);
339
- var s3 = i2.shift();
340
- s3.resolve(e2.apply(s3.self, s3.args));
341
- }, l2 = function() {
342
- var e3 = arguments, t2 = this;
343
- return new Promise(function(r3, n3) {
344
- i2.push({ resolve: r3, reject: n3, args: e3, self: t2 }), o2 < s2 && a2();
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();
345
252
  });
346
253
  };
347
- return l2.abort = function() {
348
- n2.forEach(clearTimeout), n2 = [], i2.forEach(function(e3) {
349
- e3.reject(new throttle.AbortError());
350
- }), i2.length = 0;
351
- }, l2;
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;
352
259
  }
353
- s.AbortError = function() {
260
+ G.AbortError = function() {
354
261
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
355
262
  };
356
- const r = function(e2, t2) {
357
- if (!e2)
263
+ const dt = function(r, t) {
264
+ if (!r)
358
265
  return null;
359
- let s2 = {};
360
- for (let r2 in e2) {
361
- let i2 = e2[r2];
362
- t2.indexOf(r2) > -1 && i2 !== null && (s2[r2] = i2);
266
+ let e = {};
267
+ for (let n in r) {
268
+ let s = r[n];
269
+ t.indexOf(n) > -1 && s !== null && (e[n] = s);
363
270
  }
364
- return s2;
271
+ return e;
365
272
  };
366
- var i = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (e2) => ({ tag: ["pre", { tag: "code", attrs: e2.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (e2) => ({ tag: `h${e2.attrs.level}` }), image: (e2) => ({ singleTag: [{ tag: "img", attrs: r(e2.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(e2) {
367
- const t2 = __spreadValues({}, e2.attrs), { linktype: s2 = "url" } = e2.attrs;
368
- return s2 === "email" && (t2.href = `mailto:${t2.href}`), t2.anchor && (t2.href = `${t2.href}#${t2.anchor}`, delete t2.anchor), { tag: [{ tag: "a", attrs: t2 }] };
369
- }, styled: (e2) => ({ tag: [{ tag: "span", attrs: e2.attrs }] }) } };
370
- class n {
371
- constructor(e2) {
372
- e2 || (e2 = i), this.marks = e2.marks || [], this.nodes = e2.nodes || [];
373
- }
374
- addNode(e2, t2) {
375
- this.nodes[e2] = t2;
376
- }
377
- addMark(e2, t2) {
378
- this.marks[e2] = t2;
379
- }
380
- render(e2 = {}) {
381
- if (e2.content && Array.isArray(e2.content)) {
382
- let t2 = "";
383
- return e2.content.forEach((e3) => {
384
- t2 += this.renderNode(e3);
385
- }), t2;
273
+ var pt = { 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: dt(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 gt {
278
+ constructor(t) {
279
+ t || (t = pt), 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;
386
293
  }
387
294
  return console.warn("The render method must receive an object with a content field, which is an array"), "";
388
295
  }
389
- renderNode(e2) {
390
- let t2 = [];
391
- e2.marks && e2.marks.forEach((e3) => {
392
- const s3 = this.getMatchingMark(e3);
393
- s3 && t2.push(this.renderOpeningTag(s3.tag));
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));
394
301
  });
395
- const s2 = this.getMatchingNode(e2);
396
- return s2 && s2.tag && t2.push(this.renderOpeningTag(s2.tag)), e2.content ? e2.content.forEach((e3) => {
397
- t2.push(this.renderNode(e3));
398
- }) : e2.text ? t2.push(function(e3) {
399
- const t3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, s3 = /[&<>"']/g, r2 = RegExp(s3.source);
400
- return e3 && r2.test(e3) ? e3.replace(s3, (e4) => t3[e4]) : e3;
401
- }(e2.text)) : s2 && s2.singleTag ? t2.push(this.renderTag(s2.singleTag, " /")) : s2 && s2.html && t2.push(s2.html), s2 && s2.tag && t2.push(this.renderClosingTag(s2.tag)), e2.marks && e2.marks.slice(0).reverse().forEach((e3) => {
402
- const s3 = this.getMatchingMark(e3);
403
- s3 && t2.push(this.renderClosingTag(s3.tag));
404
- }), t2.join("");
405
- }
406
- renderTag(e2, t2) {
407
- if (e2.constructor === String)
408
- return `<${e2}${t2}>`;
409
- return e2.map((e3) => {
410
- if (e3.constructor === String)
411
- return `<${e3}${t2}>`;
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}>`;
412
317
  {
413
- let s2 = `<${e3.tag}`;
414
- if (e3.attrs)
415
- for (let t3 in e3.attrs) {
416
- let r2 = e3.attrs[t3];
417
- r2 !== null && (s2 += ` ${t3}="${r2}"`);
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}"`);
418
323
  }
419
- return `${s2}${t2}>`;
324
+ return `${s}${e}>`;
420
325
  }
421
326
  }).join("");
422
327
  }
423
- renderOpeningTag(e2) {
424
- return this.renderTag(e2, "");
328
+ renderOpeningTag(t) {
329
+ return this.renderTag(t, "");
425
330
  }
426
- renderClosingTag(e2) {
427
- if (e2.constructor === String)
428
- return `</${e2}>`;
429
- return e2.slice(0).reverse().map((e3) => e3.constructor === String ? `</${e3}>` : `</${e3.tag}>`).join("");
331
+ renderClosingTag(t) {
332
+ return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
430
333
  }
431
- getMatchingNode(e2) {
432
- if (typeof this.nodes[e2.type] == "function")
433
- return this.nodes[e2.type](e2);
334
+ getMatchingNode(t) {
335
+ if (typeof this.nodes[t.type] == "function")
336
+ return this.nodes[t.type](t);
434
337
  }
435
- getMatchingMark(e2) {
436
- if (typeof this.marks[e2.type] == "function")
437
- return this.marks[e2.type](e2);
338
+ getMatchingMark(t) {
339
+ if (typeof this.marks[t.type] == "function")
340
+ return this.marks[t.type](t);
438
341
  }
439
342
  }
440
- const o = (e2 = 0, t2 = e2) => {
441
- const s2 = Math.abs(t2 - e2) || 0, r2 = e2 < t2 ? 1 : -1;
442
- return ((e3 = 0, t3) => [...Array(e3)].map(t3))(s2, (t3, s3) => s3 * r2 + e2);
443
- }, a = (e2, t2, s2) => {
444
- const r2 = [];
445
- for (const i2 in e2) {
446
- if (!Object.prototype.hasOwnProperty.call(e2, i2))
343
+ const mt = (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
+ }, R = (r, t, e) => {
347
+ const n = [];
348
+ for (const s in r) {
349
+ if (!Object.prototype.hasOwnProperty.call(r, s))
447
350
  continue;
448
- const n2 = e2[i2], o2 = s2 ? "" : encodeURIComponent(i2);
449
- let l2;
450
- l2 = typeof n2 == "object" ? a(n2, t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(n2)) : (t2 ? t2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(n2), r2.push(l2);
351
+ const o = r[s], a = e ? "" : encodeURIComponent(s);
352
+ let i;
353
+ i = typeof o == "object" ? R(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), n.push(i);
451
354
  }
452
- return r2.join("&");
355
+ return n.join("&");
453
356
  };
454
- let l = {}, c = {};
455
- class h {
456
- constructor(t2, r2) {
457
- if (!r2) {
458
- let e2 = t2.region ? `-${t2.region}` : "", s2 = t2.https === false ? "http" : "https";
459
- r2 = t2.oauthToken === void 0 ? `${s2}://api${e2}.storyblok.com/v2` : `${s2}://api${e2}.storyblok.com/v1`;
357
+ let _ = {}, p = {};
358
+ class yt {
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`;
460
363
  }
461
- let i2 = Object.assign({}, t2.headers), o2 = 5;
462
- t2.oauthToken !== void 0 && (i2.Authorization = t2.oauthToken, o2 = 3), t2.rateLimit !== void 0 && (o2 = t2.rateLimit), this.richTextResolver = new n(t2.richTextSchema), typeof t2.componentResolver == "function" && this.setComponentResolver(t2.componentResolver), this.maxRetries = t2.maxRetries || 5, this.throttle = s(this.throttledRequest, o2, 1e3), this.accessToken = t2.accessToken, this.relations = {}, this.links = {}, this.cache = t2.cache || { clear: "manual" }, this.client = e.create({ baseURL: r2, timeout: t2.timeout || 0, headers: i2, proxy: t2.proxy || false }), t2.responseInterceptor && this.client.interceptors.response.use((e2) => t2.responseInterceptor(e2)), this.resolveNestedRelations = t2.resolveNestedRelations || true;
463
- }
464
- setComponentResolver(e2) {
465
- this.richTextResolver.addNode("blok", (t2) => {
466
- let s2 = "";
467
- return t2.attrs.body.forEach((t3) => {
468
- s2 += e2(t3.component, t3);
469
- }), { html: s2 };
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 gt(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = G(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = rt.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 };
470
373
  });
471
374
  }
472
- parseParams(e2 = {}) {
473
- return e2.version || (e2.version = "published"), e2.token || (e2.token = this.getToken()), e2.cv || (e2.cv = c[e2.token]), Array.isArray(e2.resolve_relations) && (e2.resolve_relations = e2.resolve_relations.join(",")), e2;
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;
474
377
  }
475
- factoryParamOptions(e2, t2 = {}) {
476
- return ((e3 = "") => e3.indexOf("/cdn/") > -1)(e2) ? this.parseParams(t2) : t2;
378
+ factoryParamOptions(t, e = {}) {
379
+ return ((n = "") => n.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
477
380
  }
478
- makeRequest(e2, t2, s2, r2) {
479
- const i2 = this.factoryParamOptions(e2, ((e3 = {}, t3 = 25, s3 = 1) => __spreadProps(__spreadValues({}, e3), { per_page: t3, page: s3 }))(t2, s2, r2));
480
- return this.cacheResponse(e2, i2);
381
+ makeRequest(t, e, n, s) {
382
+ const o = this.factoryParamOptions(t, ((a = {}, i = 25, l = 1) => $(d({}, a), { per_page: i, page: l }))(e, n, s));
383
+ return this.cacheResponse(t, o);
481
384
  }
482
- get(e2, t2) {
483
- let s2 = `/${e2}`;
484
- const r2 = this.factoryParamOptions(s2, t2);
485
- return this.cacheResponse(s2, r2);
385
+ get(t, e) {
386
+ let n = `/${t}`;
387
+ const s = this.factoryParamOptions(n, e);
388
+ return this.cacheResponse(n, s);
486
389
  }
487
- async getAll(e2, t2 = {}, s2) {
488
- const r2 = t2.per_page || 25, i2 = `/${e2}`, n2 = i2.split("/");
489
- s2 = s2 || n2[n2.length - 1];
490
- const a2 = await this.makeRequest(i2, t2, r2, 1), l2 = Math.ceil(a2.total / r2);
491
- return ((e3 = [], t3) => e3.map(t3).reduce((e4, t4) => [...e4, ...t4], []))([a2, ...await (async (e3 = [], t3) => Promise.all(e3.map(t3)))(o(1, l2), async (e3) => this.makeRequest(i2, t2, r2, e3 + 1))], (e3) => Object.values(e3.data[s2]));
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)))(mt(1, l), async (c) => this.makeRequest(o, e, s, c + 1))], (c) => Object.values(c.data[n]));
492
395
  }
493
- post(e2, t2) {
494
- let s2 = `/${e2}`;
495
- return this.throttle("post", s2, t2);
396
+ post(t, e) {
397
+ let n = `/${t}`;
398
+ return this.throttle("post", n, e);
496
399
  }
497
- put(e2, t2) {
498
- let s2 = `/${e2}`;
499
- return this.throttle("put", s2, t2);
400
+ put(t, e) {
401
+ let n = `/${t}`;
402
+ return this.throttle("put", n, e);
500
403
  }
501
- delete(e2, t2) {
502
- let s2 = `/${e2}`;
503
- return this.throttle("delete", s2, t2);
404
+ delete(t, e) {
405
+ let n = `/${t}`;
406
+ return this.throttle("delete", n, e);
504
407
  }
505
- getStories(e2) {
506
- return this.get("cdn/stories", e2);
408
+ getStories(t) {
409
+ return this.get("cdn/stories", t);
507
410
  }
508
- getStory(e2, t2) {
509
- return this.get(`cdn/stories/${e2}`, t2);
411
+ getStory(t, e) {
412
+ return this.get(`cdn/stories/${t}`, e);
510
413
  }
511
- setToken(e2) {
512
- this.accessToken = e2;
414
+ setToken(t) {
415
+ this.accessToken = t;
513
416
  }
514
417
  getToken() {
515
418
  return this.accessToken;
516
419
  }
517
- _cleanCopy(e2) {
518
- return JSON.parse(JSON.stringify(e2));
519
- }
520
- _insertLinks(e2, t2) {
521
- const s2 = e2[t2];
522
- s2 && s2.fieldtype == "multilink" && s2.linktype == "story" && typeof s2.id == "string" && this.links[s2.id] ? s2.story = this._cleanCopy(this.links[s2.id]) : s2 && s2.linktype === "story" && typeof s2.uuid == "string" && this.links[s2.uuid] && (s2.story = this._cleanCopy(this.links[s2.uuid]));
523
- }
524
- _insertRelations(e2, t2, s2) {
525
- if (s2.indexOf(e2.component + "." + t2) > -1) {
526
- if (typeof e2[t2] == "string")
527
- this.relations[e2[t2]] && (e2[t2] = this._cleanCopy(this.relations[e2[t2]]));
528
- else if (e2[t2].constructor === Array) {
529
- let s3 = [];
530
- e2[t2].forEach((e3) => {
531
- this.relations[e3] && s3.push(this._cleanCopy(this.relations[e3]));
532
- }), e2[t2] = s3;
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;
533
436
  }
534
437
  }
535
438
  }
536
- _insertAssetsRelations(e2, t2) {
537
- t2.forEach((t3) => {
538
- e2.id === t3.id && (e2.original = t3, e2.original.filename = e2.filename, e2.original.filename = e2.original.filename.includes("https://s3.amazonaws.com/") ? e2.original.filename : e2.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete e2.original.s3_filename);
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);
539
442
  });
540
443
  }
541
- iterateTree(e2, t2) {
542
- let s2 = (e3) => {
543
- if (e3 != null) {
544
- if (e3.constructor === Array)
545
- for (let t3 = 0; t3 < e3.length; t3++)
546
- s2(e3[t3]);
547
- else if (e3.constructor === Object) {
548
- if (e3._stopResolving)
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)
549
452
  return;
550
- for (let r2 in e3)
551
- e3.component && e3._uid || e3.type === "link" ? (this._insertRelations(e3, r2, t2), this._insertLinks(e3, r2)) : "id" in e3 && e3.fieldtype === "asset" && this._insertAssetsRelations(e3, t2), s2(e3[r2]);
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]);
552
455
  }
553
456
  }
554
457
  };
555
- s2(e2.content);
556
- }
557
- async resolveLinks(e2, t2) {
558
- let s2 = [];
559
- if (e2.link_uuids) {
560
- const r2 = e2.link_uuids.length;
561
- let i2 = [];
562
- const n2 = 50;
563
- for (let t3 = 0; t3 < r2; t3 += n2) {
564
- const s3 = Math.min(r2, t3 + n2);
565
- i2.push(e2.link_uuids.slice(t3, s3));
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));
566
469
  }
567
- for (let e3 = 0; e3 < i2.length; e3++) {
568
- (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
569
- s2.push(e4);
470
+ 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);
570
473
  });
571
- }
572
474
  } else
573
- s2 = e2.links;
574
- s2.forEach((e3) => {
575
- this.links[e3.uuid] = __spreadProps(__spreadValues({}, e3), { _stopResolving: true });
475
+ n = t.links;
476
+ n.forEach((s) => {
477
+ this.links[s.uuid] = $(d({}, s), { _stopResolving: !0 });
576
478
  });
577
479
  }
578
- async resolveRelations(e2, t2) {
579
- let s2 = [];
580
- if (e2.rel_uuids) {
581
- const r2 = e2.rel_uuids.length;
582
- let i2 = [];
583
- const n2 = 50;
584
- for (let t3 = 0; t3 < r2; t3 += n2) {
585
- const s3 = Math.min(r2, t3 + n2);
586
- i2.push(e2.rel_uuids.slice(t3, s3));
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));
587
489
  }
588
- for (let e3 = 0; e3 < i2.length; e3++) {
589
- (await this.getStories({ per_page: n2, language: t2.language, version: t2.version, by_uuids: i2[e3].join(",") })).data.stories.forEach((e4) => {
590
- s2.push(e4);
490
+ 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);
591
493
  });
592
- }
593
494
  } else
594
- s2 = e2.rels;
595
- s2.forEach((e3) => {
596
- this.relations[e3.uuid] = __spreadProps(__spreadValues({}, e3), { _stopResolving: true });
495
+ n = t.rels;
496
+ n.forEach((s) => {
497
+ this.relations[s.uuid] = $(d({}, s), { _stopResolving: !0 });
597
498
  });
598
499
  }
599
- async resolveStories(e2, t2) {
600
- let s2 = [];
601
- if (t2.resolve_relations !== void 0 && t2.resolve_relations.length > 0 && (e2.rels || e2.rel_uuids) && (s2 = t2.resolve_relations.split(","), await this.resolveRelations(e2, t2)), ["1", "story", "url"].indexOf(t2.resolve_links) > -1 && (e2.links || e2.link_uuids) && await this.resolveLinks(e2, t2), this.resolveNestedRelations)
602
- for (const e3 in this.relations)
603
- this.iterateTree(this.relations[e3], s2);
604
- e2.story ? this.iterateTree(e2.story, s2) : e2.stories.forEach((e3) => {
605
- this.iterateTree(e3, s2);
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);
606
507
  });
607
508
  }
608
- resolveAssetsRelations(e2) {
609
- const { assets: t2, stories: s2, story: r2 } = e2;
610
- if (s2)
611
- for (const e3 of s2)
612
- this.iterateTree(e3, t2);
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);
613
514
  else {
614
- if (!r2)
615
- return e2;
616
- this.iterateTree(r2, t2);
515
+ if (!s)
516
+ return t;
517
+ this.iterateTree(s, e);
617
518
  }
618
519
  }
619
- cacheResponse(e2, t2, s2) {
620
- return s2 === void 0 && (s2 = 0), new Promise(async (r2, i2) => {
621
- let n2 = a({ url: e2, params: t2 }), o2 = this.cacheProvider();
622
- if (this.cache.clear === "auto" && t2.version === "draft" && await this.flushCache(), t2.version === "published" && e2 != "/cdn/spaces/me") {
623
- const e3 = await o2.get(n2);
624
- if (e3)
625
- return r2(e3);
520
+ cacheResponse(t, e, n) {
521
+ return n === void 0 && (n = 0), new Promise(async (s, o) => {
522
+ let a = R({ 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);
525
+ if (c)
526
+ return s(c);
626
527
  }
627
528
  try {
628
- let s3 = await this.throttle("get", e2, { params: t2, paramsSerializer: (e3) => a(e3) }), l3 = { data: s3.data, headers: s3.headers };
629
- if (l3.data.assets && l3.data.assets.length && this.resolveAssetsRelations(l3.data), s3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(s3.headers["per-page"]), total: parseInt(s3.headers.total) })), s3.status != 200)
630
- return i2(s3);
631
- (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, t2), t2.version === "published" && e2 != "/cdn/spaces/me" && o2.set(n2, l3), l3.data.cv && (t2.version == "draft" && c[t2.token] != l3.data.cv && this.flushCache(), c[t2.token] = l3.data.cv), r2(l3);
632
- } catch (n3) {
633
- if (n3.response && n3.response.status === 429 && (s2 += 1) < this.maxRetries)
634
- return console.log(`Hit rate limit. Retrying in ${s2} seconds.`), await (l2 = 1e3 * s2, new Promise((e3) => setTimeout(e3, l2))), this.cacheResponse(e2, t2, s2).then(r2).catch(i2);
635
- i2(n3);
529
+ let c = await this.throttle("get", t, { params: e, paramsSerializer: (h) => R(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);
636
537
  }
637
- var l2;
538
+ var l;
638
539
  });
639
540
  }
640
- throttledRequest(e2, t2, s2) {
641
- return this.client[e2](t2, s2);
541
+ throttledRequest(t, e, n) {
542
+ return this.client[t](e, n);
642
543
  }
643
544
  cacheVersions() {
644
- return c;
545
+ return p;
645
546
  }
646
547
  cacheVersion() {
647
- return c[this.accessToken];
548
+ return p[this.accessToken];
648
549
  }
649
- setCacheVersion(e2) {
650
- this.accessToken && (c[this.accessToken] = e2);
550
+ setCacheVersion(t) {
551
+ this.accessToken && (p[this.accessToken] = t);
651
552
  }
652
553
  cacheProvider() {
653
- return this.cache.type === "memory" ? { get: (e2) => l[e2], getAll: () => l, set(e2, t2) {
654
- l[e2] = t2;
554
+ return this.cache.type === "memory" ? { get: (t) => _[t], getAll: () => _, set(t, e) {
555
+ _[t] = e;
655
556
  }, flush() {
656
- l = {};
557
+ _ = {};
657
558
  } } : { get() {
658
559
  }, getAll() {
659
560
  }, set() {
@@ -664,548 +565,377 @@ class h {
664
565
  return await this.cacheProvider().flush(), this;
665
566
  }
666
567
  }
667
- const apiFactory = (options = {}) => {
668
- const { apiOptions } = options;
669
- if (!apiOptions.accessToken) {
568
+ const Ht = (r = {}) => {
569
+ const { apiOptions: t } = r;
570
+ if (!t.accessToken) {
670
571
  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");
671
572
  return;
672
573
  }
673
- const storyblokApi = new h(apiOptions);
674
- return { storyblokApi };
574
+ return { storyblokApi: new yt(t) };
675
575
  };
676
- var editable = (blok) => {
677
- if (typeof blok !== "object" || typeof blok._editable === "undefined") {
576
+ var kt = (r) => {
577
+ if (typeof r != "object" || typeof r._editable > "u")
678
578
  return {};
679
- }
680
- const options = JSON.parse(blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
579
+ const t = JSON.parse(r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
681
580
  return {
682
- "data-blok-c": JSON.stringify(options),
683
- "data-blok-uid": options.id + "-" + options.uid
581
+ "data-blok-c": JSON.stringify(t),
582
+ "data-blok-uid": t.id + "-" + t.uid
684
583
  };
685
584
  };
686
- let richTextResolver;
687
- const bridgeLatest = "https://app.storyblok.com/f/storyblok-v2-latest.js";
688
- const useStoryblokBridge = (id, cb, options = {}) => {
689
- if (typeof window === "undefined") {
690
- return;
691
- }
692
- if (typeof window.storyblokRegisterEvent === "undefined") {
693
- console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
694
- return;
695
- }
696
- if (!id) {
697
- console.warn("Story ID is not defined. Please provide a valid ID.");
698
- return;
699
- }
700
- window.storyblokRegisterEvent(() => {
701
- const sbBridge = new window.StoryblokBridge(options);
702
- sbBridge.on(["input", "published", "change"], (event) => {
703
- if (event.action === "input" && event.story.id === id) {
704
- cb(event.story);
705
- } else if ((event.action === "change" || event.action === "published") && event.storyId === id) {
706
- window.location.reload();
707
- }
585
+ let x;
586
+ const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e = {}) => {
587
+ if (!(typeof window > "u")) {
588
+ if (typeof window.storyblokRegisterEvent > "u") {
589
+ console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
590
+ return;
591
+ }
592
+ if (!r) {
593
+ console.warn("Story ID is not defined. Please provide a valid ID.");
594
+ return;
595
+ }
596
+ 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();
599
+ });
708
600
  });
709
- });
710
- };
711
- const storyblokInit$1 = (pluginOptions = {}) => {
712
- const {
713
- bridge,
714
- accessToken,
715
- use = [],
716
- apiOptions = {},
717
- richText = {}
718
- } = pluginOptions;
719
- apiOptions.accessToken = apiOptions.accessToken || accessToken;
720
- const options = { bridge, apiOptions };
721
- let result = {};
722
- use.forEach((pluginFactory) => {
723
- result = __spreadValues(__spreadValues({}, result), pluginFactory(options));
724
- });
725
- if (bridge !== false) {
726
- loadBridge(bridgeLatest);
727
- }
728
- richTextResolver = new RichTextResolver(richText.schema);
729
- if (richText.resolver) {
730
- setComponentResolver(richTextResolver, richText.resolver);
731
601
  }
732
- return result;
733
- };
734
- const setComponentResolver = (resolver, resolveFn) => {
735
- resolver.addNode("blok", (node) => {
736
- let html = "";
737
- node.attrs.body.forEach((blok) => {
738
- html += resolveFn(blok.component, blok);
739
- });
740
- return {
741
- html
602
+ }, bt = (r = {}) => {
603
+ const {
604
+ bridge: t,
605
+ accessToken: e,
606
+ use: n = [],
607
+ apiOptions: s = {},
608
+ richText: o = {}
609
+ } = r;
610
+ s.accessToken = s.accessToken || e;
611
+ const a = { bridge: t, apiOptions: s };
612
+ let i = {};
613
+ return n.forEach((l) => {
614
+ i = d(d({}, i), l(a));
615
+ }), t !== !1 && lt(_t), x = new K(o.schema), o.resolver && Q(x, o.resolver), i;
616
+ }, Q = (r, t) => {
617
+ r.addNode("blok", (e) => {
618
+ let n = "";
619
+ return e.attrs.body.forEach((s) => {
620
+ n += t(s.component, s);
621
+ }), {
622
+ html: n
742
623
  };
743
624
  });
744
- };
745
- const renderRichText = (data, options) => {
746
- if (!richTextResolver) {
625
+ }, Jt = (r, t, e) => {
626
+ let n = e || x;
627
+ if (!n) {
747
628
  console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
748
629
  return;
749
630
  }
750
- if (data === "") {
751
- return "";
752
- } else if (!data) {
753
- console.warn(`${data} is not a valid Richtext object. This might be because the value of the richtext field is empty.
631
+ return r === "" ? "" : r ? (t && (n = new K(t.schema), t.resolver && Q(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.
754
632
 
755
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`);
756
- return "";
757
- }
758
- let localResolver = richTextResolver;
759
- if (options) {
760
- localResolver = new RichTextResolver(options.schema);
761
- if (options.resolver) {
762
- setComponentResolver(localResolver, options.resolver);
763
- }
764
- }
765
- return localResolver.render(data);
633
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
766
634
  };
767
- function noop() {
635
+ function W() {
768
636
  }
769
- function assign(tar, src) {
770
- for (const k in src)
771
- tar[k] = src[k];
772
- return tar;
637
+ function E(r, t) {
638
+ for (const e in t)
639
+ r[e] = t[e];
640
+ return r;
773
641
  }
774
- function run(fn) {
775
- return fn();
642
+ function X(r) {
643
+ return r();
776
644
  }
777
- function blank_object() {
645
+ function U() {
778
646
  return /* @__PURE__ */ Object.create(null);
779
647
  }
780
- function run_all(fns) {
781
- fns.forEach(run);
648
+ function y(r) {
649
+ r.forEach(X);
782
650
  }
783
- function is_function(thing) {
784
- return typeof thing === "function";
651
+ function vt(r) {
652
+ return typeof r == "function";
785
653
  }
786
- function safe_not_equal(a2, b) {
787
- return a2 != a2 ? b == b : a2 !== b || (a2 && typeof a2 === "object" || typeof a2 === "function");
654
+ function wt(r, t) {
655
+ return r != r ? t == t : r !== t || r && typeof r == "object" || typeof r == "function";
788
656
  }
789
- function is_empty(obj) {
790
- return Object.keys(obj).length === 0;
657
+ function $t(r) {
658
+ return Object.keys(r).length === 0;
791
659
  }
792
- function exclude_internal_props(props) {
793
- const result = {};
794
- for (const k in props)
795
- if (k[0] !== "$")
796
- result[k] = props[k];
797
- return result;
660
+ function Tt(r) {
661
+ const t = {};
662
+ for (const e in r)
663
+ e[0] !== "$" && (t[e] = r[e]);
664
+ return t;
798
665
  }
799
- function compute_rest_props(props, keys) {
800
- const rest = {};
801
- keys = new Set(keys);
802
- for (const k in props)
803
- if (!keys.has(k) && k[0] !== "$")
804
- rest[k] = props[k];
805
- return rest;
666
+ function H(r, t) {
667
+ const e = {};
668
+ t = new Set(t);
669
+ for (const n in r)
670
+ !t.has(n) && n[0] !== "$" && (e[n] = r[n]);
671
+ return e;
806
672
  }
807
- function insert(target, node, anchor) {
808
- target.insertBefore(node, anchor || null);
673
+ function Rt(r, t, e) {
674
+ r.insertBefore(t, e || null);
809
675
  }
810
- function detach(node) {
811
- node.parentNode.removeChild(node);
676
+ function Z(r) {
677
+ r.parentNode.removeChild(r);
812
678
  }
813
- function text(data) {
814
- return document.createTextNode(data);
679
+ function xt(r) {
680
+ return document.createTextNode(r);
815
681
  }
816
- function empty() {
817
- return text("");
682
+ function Et() {
683
+ return xt("");
818
684
  }
819
- function children(element) {
820
- return Array.from(element.childNodes);
685
+ function Ot(r) {
686
+ return Array.from(r.childNodes);
821
687
  }
822
- let current_component;
823
- function set_current_component(component) {
824
- current_component = component;
688
+ let M;
689
+ function m(r) {
690
+ M = r;
825
691
  }
826
- const dirty_components = [];
827
- const binding_callbacks = [];
828
- const render_callbacks = [];
829
- const flush_callbacks = [];
830
- const resolved_promise = Promise.resolve();
831
- let update_scheduled = false;
832
- function schedule_update() {
833
- if (!update_scheduled) {
834
- update_scheduled = true;
835
- resolved_promise.then(flush);
836
- }
692
+ const g = [], V = [], v = [], J = [], St = Promise.resolve();
693
+ let O = !1;
694
+ function jt() {
695
+ O || (O = !0, St.then(tt));
837
696
  }
838
- function add_render_callback(fn) {
839
- render_callbacks.push(fn);
697
+ function S(r) {
698
+ v.push(r);
840
699
  }
841
- const seen_callbacks = /* @__PURE__ */ new Set();
842
- let flushidx = 0;
843
- function flush() {
844
- const saved_component = current_component;
700
+ const T = /* @__PURE__ */ new Set();
701
+ let b = 0;
702
+ function tt() {
703
+ const r = M;
845
704
  do {
846
- while (flushidx < dirty_components.length) {
847
- const component = dirty_components[flushidx];
848
- flushidx++;
849
- set_current_component(component);
850
- update(component.$$);
705
+ for (; b < g.length; ) {
706
+ const t = g[b];
707
+ b++, m(t), Pt(t.$$);
851
708
  }
852
- set_current_component(null);
853
- dirty_components.length = 0;
854
- flushidx = 0;
855
- while (binding_callbacks.length)
856
- binding_callbacks.pop()();
857
- for (let i2 = 0; i2 < render_callbacks.length; i2 += 1) {
858
- const callback = render_callbacks[i2];
859
- if (!seen_callbacks.has(callback)) {
860
- seen_callbacks.add(callback);
861
- callback();
862
- }
709
+ for (m(null), g.length = 0, b = 0; V.length; )
710
+ V.pop()();
711
+ for (let t = 0; t < v.length; t += 1) {
712
+ const e = v[t];
713
+ T.has(e) || (T.add(e), e());
863
714
  }
864
- render_callbacks.length = 0;
865
- } while (dirty_components.length);
866
- while (flush_callbacks.length) {
867
- flush_callbacks.pop()();
868
- }
869
- update_scheduled = false;
870
- seen_callbacks.clear();
871
- set_current_component(saved_component);
872
- }
873
- function update($$) {
874
- if ($$.fragment !== null) {
875
- $$.update();
876
- run_all($$.before_update);
877
- const dirty = $$.dirty;
878
- $$.dirty = [-1];
879
- $$.fragment && $$.fragment.p($$.ctx, dirty);
880
- $$.after_update.forEach(add_render_callback);
881
- }
882
- }
883
- const outroing = /* @__PURE__ */ new Set();
884
- let outros;
885
- function group_outros() {
886
- outros = {
715
+ v.length = 0;
716
+ } while (g.length);
717
+ for (; J.length; )
718
+ J.pop()();
719
+ O = !1, T.clear(), m(r);
720
+ }
721
+ function Pt(r) {
722
+ if (r.fragment !== null) {
723
+ r.update(), y(r.before_update);
724
+ const t = r.dirty;
725
+ r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(S);
726
+ }
727
+ }
728
+ const w = /* @__PURE__ */ new Set();
729
+ let f;
730
+ function At() {
731
+ f = {
887
732
  r: 0,
888
733
  c: [],
889
- p: outros
734
+ p: f
890
735
  };
891
736
  }
892
- function check_outros() {
893
- if (!outros.r) {
894
- run_all(outros.c);
895
- }
896
- outros = outros.p;
737
+ function Ct() {
738
+ f.r || y(f.c), f = f.p;
897
739
  }
898
- function transition_in(block, local) {
899
- if (block && block.i) {
900
- outroing.delete(block);
901
- block.i(local);
902
- }
740
+ function j(r, t) {
741
+ r && r.i && (w.delete(r), r.i(t));
903
742
  }
904
- function transition_out(block, local, detach2, callback) {
905
- if (block && block.o) {
906
- if (outroing.has(block))
743
+ function Y(r, t, e, n) {
744
+ if (r && r.o) {
745
+ if (w.has(r))
907
746
  return;
908
- outroing.add(block);
909
- outros.c.push(() => {
910
- outroing.delete(block);
911
- if (callback) {
912
- if (detach2)
913
- block.d(1);
914
- callback();
915
- }
916
- });
917
- block.o(local);
918
- } else if (callback) {
919
- callback();
920
- }
921
- }
922
- function get_spread_update(levels, updates) {
923
- const update2 = {};
924
- const to_null_out = {};
925
- const accounted_for = { $$scope: 1 };
926
- let i2 = levels.length;
927
- while (i2--) {
928
- const o2 = levels[i2];
929
- const n2 = updates[i2];
930
- if (n2) {
931
- for (const key in o2) {
932
- if (!(key in n2))
933
- to_null_out[key] = 1;
934
- }
935
- for (const key in n2) {
936
- if (!accounted_for[key]) {
937
- update2[key] = n2[key];
938
- accounted_for[key] = 1;
939
- }
940
- }
941
- levels[i2] = n2;
942
- } else {
943
- for (const key in o2) {
944
- accounted_for[key] = 1;
945
- }
946
- }
947
- }
948
- for (const key in to_null_out) {
949
- if (!(key in update2))
950
- update2[key] = void 0;
747
+ w.add(r), f.c.push(() => {
748
+ w.delete(r), n && (e && r.d(1), n());
749
+ }), r.o(t);
750
+ } else
751
+ n && n();
752
+ }
753
+ function Mt(r, t) {
754
+ const e = {}, n = {}, s = { $$scope: 1 };
755
+ let o = r.length;
756
+ for (; o--; ) {
757
+ const a = r[o], i = t[o];
758
+ if (i) {
759
+ for (const l in a)
760
+ l in i || (n[l] = 1);
761
+ for (const l in i)
762
+ s[l] || (e[l] = i[l], s[l] = 1);
763
+ r[o] = i;
764
+ } else
765
+ for (const l in a)
766
+ s[l] = 1;
951
767
  }
952
- return update2;
768
+ for (const a in n)
769
+ a in e || (e[a] = void 0);
770
+ return e;
953
771
  }
954
- function get_spread_object(spread_props) {
955
- return typeof spread_props === "object" && spread_props !== null ? spread_props : {};
772
+ function Nt(r) {
773
+ return typeof r == "object" && r !== null ? r : {};
956
774
  }
957
- function create_component(block) {
958
- block && block.c();
775
+ function F(r) {
776
+ r && r.c();
959
777
  }
960
- function mount_component(component, target, anchor, customElement) {
961
- const { fragment, on_mount, on_destroy, after_update } = component.$$;
962
- fragment && fragment.m(target, anchor);
963
- if (!customElement) {
964
- add_render_callback(() => {
965
- const new_on_destroy = on_mount.map(run).filter(is_function);
966
- if (on_destroy) {
967
- on_destroy.push(...new_on_destroy);
968
- } else {
969
- run_all(new_on_destroy);
970
- }
971
- component.$$.on_mount = [];
972
- });
973
- }
974
- after_update.forEach(add_render_callback);
778
+ function P(r, t, e, n) {
779
+ const { fragment: s, on_mount: o, on_destroy: a, after_update: i } = r.$$;
780
+ s && s.m(t, e), n || S(() => {
781
+ const l = o.map(X).filter(vt);
782
+ a ? a.push(...l) : y(l), r.$$.on_mount = [];
783
+ }), i.forEach(S);
975
784
  }
976
- function destroy_component(component, detaching) {
977
- const $$ = component.$$;
978
- if ($$.fragment !== null) {
979
- run_all($$.on_destroy);
980
- $$.fragment && $$.fragment.d(detaching);
981
- $$.on_destroy = $$.fragment = null;
982
- $$.ctx = [];
983
- }
785
+ function A(r, t) {
786
+ const e = r.$$;
787
+ e.fragment !== null && (y(e.on_destroy), e.fragment && e.fragment.d(t), e.on_destroy = e.fragment = null, e.ctx = []);
984
788
  }
985
- function make_dirty(component, i2) {
986
- if (component.$$.dirty[0] === -1) {
987
- dirty_components.push(component);
988
- schedule_update();
989
- component.$$.dirty.fill(0);
990
- }
991
- component.$$.dirty[i2 / 31 | 0] |= 1 << i2 % 31;
789
+ function It(r, t) {
790
+ r.$$.dirty[0] === -1 && (g.push(r), jt(), r.$$.dirty.fill(0)), r.$$.dirty[t / 31 | 0] |= 1 << t % 31;
992
791
  }
993
- function init(component, options, instance2, create_fragment2, not_equal, props, append_styles, dirty = [-1]) {
994
- const parent_component = current_component;
995
- set_current_component(component);
996
- const $$ = component.$$ = {
792
+ function qt(r, t, e, n, s, o, a, i = [-1]) {
793
+ const l = M;
794
+ m(r);
795
+ const c = r.$$ = {
997
796
  fragment: null,
998
797
  ctx: null,
999
- props,
1000
- update: noop,
1001
- not_equal,
1002
- bound: blank_object(),
798
+ props: o,
799
+ update: W,
800
+ not_equal: s,
801
+ bound: U(),
1003
802
  on_mount: [],
1004
803
  on_destroy: [],
1005
804
  on_disconnect: [],
1006
805
  before_update: [],
1007
806
  after_update: [],
1008
- context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
1009
- callbacks: blank_object(),
1010
- dirty,
1011
- skip_bound: false,
1012
- root: options.target || parent_component.$$.root
807
+ context: new Map(t.context || (l ? l.$$.context : [])),
808
+ callbacks: U(),
809
+ dirty: i,
810
+ skip_bound: !1,
811
+ root: t.target || l.$$.root
1013
812
  };
1014
- append_styles && append_styles($$.root);
1015
- let ready = false;
1016
- $$.ctx = instance2 ? instance2(component, options.props || {}, (i2, ret, ...rest) => {
1017
- const value = rest.length ? rest[0] : ret;
1018
- if ($$.ctx && not_equal($$.ctx[i2], $$.ctx[i2] = value)) {
1019
- if (!$$.skip_bound && $$.bound[i2])
1020
- $$.bound[i2](value);
1021
- if (ready)
1022
- make_dirty(component, i2);
1023
- }
1024
- return ret;
1025
- }) : [];
1026
- $$.update();
1027
- ready = true;
1028
- run_all($$.before_update);
1029
- $$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
1030
- if (options.target) {
1031
- if (options.hydrate) {
1032
- const nodes = children(options.target);
1033
- $$.fragment && $$.fragment.l(nodes);
1034
- nodes.forEach(detach);
1035
- } else {
1036
- $$.fragment && $$.fragment.c();
1037
- }
1038
- if (options.intro)
1039
- transition_in(component.$$.fragment);
1040
- mount_component(component, options.target, options.anchor, options.customElement);
1041
- flush();
813
+ a && a(c.root);
814
+ let u = !1;
815
+ if (c.ctx = e ? e(r, t.props || {}, (h, k, ...N) => {
816
+ const I = N.length ? N[0] : k;
817
+ return c.ctx && s(c.ctx[h], c.ctx[h] = I) && (!c.skip_bound && c.bound[h] && c.bound[h](I), u && It(r, h)), k;
818
+ }) : [], c.update(), u = !0, y(c.before_update), c.fragment = n ? n(c.ctx) : !1, t.target) {
819
+ if (t.hydrate) {
820
+ const h = Ot(t.target);
821
+ c.fragment && c.fragment.l(h), h.forEach(Z);
822
+ } else
823
+ c.fragment && c.fragment.c();
824
+ t.intro && j(r.$$.fragment), P(r, t.target, t.anchor, t.customElement), tt();
1042
825
  }
1043
- set_current_component(parent_component);
826
+ m(l);
1044
827
  }
1045
- class SvelteComponent {
828
+ class Lt {
1046
829
  $destroy() {
1047
- destroy_component(this, 1);
1048
- this.$destroy = noop;
1049
- }
1050
- $on(type, callback) {
1051
- const callbacks2 = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
1052
- callbacks2.push(callback);
1053
- return () => {
1054
- const index = callbacks2.indexOf(callback);
1055
- if (index !== -1)
1056
- callbacks2.splice(index, 1);
830
+ A(this, 1), this.$destroy = W;
831
+ }
832
+ $on(t, e) {
833
+ const n = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
834
+ return n.push(e), () => {
835
+ const s = n.indexOf(e);
836
+ s !== -1 && n.splice(s, 1);
1057
837
  };
1058
838
  }
1059
- $set($$props) {
1060
- if (this.$$set && !is_empty($$props)) {
1061
- this.$$.skip_bound = true;
1062
- this.$$set($$props);
1063
- this.$$.skip_bound = false;
1064
- }
839
+ $set(t) {
840
+ this.$$set && !$t(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
1065
841
  }
1066
842
  }
1067
- function create_fragment(ctx) {
1068
- let switch_instance;
1069
- let switch_instance_anchor;
1070
- let current;
1071
- const switch_instance_spread_levels = [{ blok: ctx[0] }, ctx[2]];
1072
- var switch_value = ctx[1];
1073
- function switch_props(ctx2) {
1074
- let switch_instance_props = {};
1075
- for (let i2 = 0; i2 < switch_instance_spread_levels.length; i2 += 1) {
1076
- switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i2]);
1077
- }
1078
- return { props: switch_instance_props };
843
+ function Bt(r) {
844
+ let t, e, n;
845
+ const s = [{ blok: r[0] }, r[2]];
846
+ var o = r[1];
847
+ function a(i) {
848
+ let l = {};
849
+ for (let c = 0; c < s.length; c += 1)
850
+ l = E(l, s[c]);
851
+ return { props: l };
1079
852
  }
1080
- if (switch_value) {
1081
- switch_instance = new switch_value(switch_props());
1082
- }
1083
- return {
853
+ return o && (t = new o(a())), {
1084
854
  c() {
1085
- if (switch_instance)
1086
- create_component(switch_instance.$$.fragment);
1087
- switch_instance_anchor = empty();
855
+ t && F(t.$$.fragment), e = Et();
1088
856
  },
1089
- m(target, anchor) {
1090
- if (switch_instance) {
1091
- mount_component(switch_instance, target, anchor);
1092
- }
1093
- insert(target, switch_instance_anchor, anchor);
1094
- current = true;
857
+ m(i, l) {
858
+ t && P(t, i, l), Rt(i, e, l), n = !0;
1095
859
  },
1096
- p(ctx2, [dirty]) {
1097
- const switch_instance_changes = dirty & 5 ? get_spread_update(switch_instance_spread_levels, [
1098
- dirty & 1 && { blok: ctx2[0] },
1099
- dirty & 4 && get_spread_object(ctx2[2])
860
+ p(i, [l]) {
861
+ const c = l & 5 ? Mt(s, [
862
+ l & 1 && { blok: i[0] },
863
+ l & 4 && Nt(i[2])
1100
864
  ]) : {};
1101
- if (switch_value !== (switch_value = ctx2[1])) {
1102
- if (switch_instance) {
1103
- group_outros();
1104
- const old_component = switch_instance;
1105
- transition_out(old_component.$$.fragment, 1, 0, () => {
1106
- destroy_component(old_component, 1);
1107
- });
1108
- check_outros();
1109
- }
1110
- if (switch_value) {
1111
- switch_instance = new switch_value(switch_props());
1112
- create_component(switch_instance.$$.fragment);
1113
- transition_in(switch_instance.$$.fragment, 1);
1114
- mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
1115
- } else {
1116
- switch_instance = null;
865
+ if (o !== (o = i[1])) {
866
+ if (t) {
867
+ At();
868
+ const u = t;
869
+ Y(u.$$.fragment, 1, 0, () => {
870
+ A(u, 1);
871
+ }), Ct();
1117
872
  }
1118
- } else if (switch_value) {
1119
- switch_instance.$set(switch_instance_changes);
1120
- }
873
+ o ? (t = new o(a()), F(t.$$.fragment), j(t.$$.fragment, 1), P(t, e.parentNode, e)) : t = null;
874
+ } else
875
+ o && t.$set(c);
1121
876
  },
1122
- i(local) {
1123
- if (current)
1124
- return;
1125
- if (switch_instance)
1126
- transition_in(switch_instance.$$.fragment, local);
1127
- current = true;
877
+ i(i) {
878
+ n || (t && j(t.$$.fragment, i), n = !0);
1128
879
  },
1129
- o(local) {
1130
- if (switch_instance)
1131
- transition_out(switch_instance.$$.fragment, local);
1132
- current = false;
880
+ o(i) {
881
+ t && Y(t.$$.fragment, i), n = !1;
1133
882
  },
1134
- d(detaching) {
1135
- if (detaching)
1136
- detach(switch_instance_anchor);
1137
- if (switch_instance)
1138
- destroy_component(switch_instance, detaching);
883
+ d(i) {
884
+ i && Z(e), t && A(t, i);
1139
885
  }
1140
886
  };
1141
887
  }
1142
- function instance($$self, $$props, $$invalidate) {
1143
- const omit_props_names = ["blok"];
1144
- let $$restProps = compute_rest_props($$props, omit_props_names);
1145
- let component;
1146
- let { blok } = $$props;
1147
- if (blok) {
1148
- component = getComponent(blok.component);
1149
- } else {
1150
- console.error("Please provide a 'blok' property to the StoryblokComponent");
1151
- }
1152
- $$self.$$set = ($$new_props) => {
1153
- $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1154
- $$invalidate(2, $$restProps = compute_rest_props($$props, omit_props_names));
1155
- if ("blok" in $$new_props)
1156
- $$invalidate(0, blok = $$new_props.blok);
1157
- };
1158
- return [blok, component, $$restProps];
888
+ function zt(r, t, e) {
889
+ const n = ["blok"];
890
+ let s = H(t, n), o, { blok: a } = t;
891
+ return a ? o = Dt(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), r.$$set = (i) => {
892
+ t = E(E({}, t), Tt(i)), e(2, s = H(t, n)), "blok" in i && e(0, a = i.blok);
893
+ }, [a, o, s];
1159
894
  }
1160
- class StoryblokComponent extends SvelteComponent {
1161
- constructor(options) {
1162
- super();
1163
- init(this, options, instance, create_fragment, safe_not_equal, { blok: 0 });
895
+ class Yt extends Lt {
896
+ constructor(t) {
897
+ super(), qt(this, t, zt, Bt, wt, { blok: 0 });
1164
898
  }
1165
899
  }
1166
- const storyblokEditable = (node, value) => {
1167
- const updateDom = (value2) => {
1168
- const options = editable(value2);
1169
- if (options["data-blok-c"]) {
1170
- node.setAttribute("data-blok-c", options["data-blok-c"]);
1171
- node.setAttribute("data-blok-uid", options["data-blok-uid"]);
1172
- node.classList.add("storyblok__outline");
1173
- }
900
+ const Ft = (r, t) => {
901
+ const e = (n) => {
902
+ const s = kt(n);
903
+ 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"));
1174
904
  };
1175
- updateDom(value);
1176
- return {
1177
- update(newValue) {
1178
- updateDom(newValue);
905
+ return e(t), {
906
+ update(n) {
907
+ e(n);
1179
908
  }
1180
909
  };
1181
910
  };
1182
- let storyblokApiInstance = null;
1183
- const useStoryblokApi = () => {
1184
- if (!storyblokApiInstance) {
1185
- console.log(
1186
- `You can't use getStoryblokApi if you're not loading apiPlugin.`
1187
- );
1188
- }
1189
- return storyblokApiInstance;
1190
- };
1191
- let componentsMap = null;
1192
- const storyblokInit = (options) => {
1193
- const { storyblokApi } = storyblokInit$1(options);
1194
- storyblokApiInstance = storyblokApi;
1195
- componentsMap = options.components || {};
1196
- };
1197
- const getComponent = (componentName) => {
1198
- const component = componentsMap[componentName];
1199
- if (!component) {
1200
- console.error(`You didn't load the ${componentName} component. Please load it in storyblokInit. For example:
911
+ let C = null;
912
+ const Kt = () => (C || console.log(
913
+ "You can't use getStoryblokApi if you're not loading apiPlugin."
914
+ ), C);
915
+ let et = null;
916
+ const Gt = (r) => {
917
+ const { storyblokApi: t } = bt(r);
918
+ C = t, et = r.components || {};
919
+ }, Dt = (r) => {
920
+ const t = et[r];
921
+ return t || console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
1201
922
  storyblokInit({
1202
923
  accessToken: "<your-token>",
1203
924
  components: {
1204
925
  "teaser": Teaser
1205
926
  }
1206
927
  })
1207
- `);
1208
- }
1209
- return component;
928
+ `), t;
929
+ };
930
+ export {
931
+ ht as RichTextSchema,
932
+ Yt as StoryblokComponent,
933
+ Ht as apiPlugin,
934
+ Dt as getComponent,
935
+ Kt as getStoryblokApi,
936
+ Jt as renderRichText,
937
+ Ft as storyblokEditable,
938
+ Gt as storyblokInit,
939
+ Kt as useStoryblokApi,
940
+ Vt as useStoryblokBridge
1210
941
  };
1211
- export { defaultHtmlSerializer as RichTextSchema, StoryblokComponent, apiFactory as apiPlugin, getComponent, useStoryblokApi as getStoryblokApi, renderRichText, storyblokEditable, storyblokInit, useStoryblokApi, useStoryblokBridge };