@storyblok/astro 4.0.5 → 4.1.0-next.1

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,90 +1,90 @@
1
- function E(r, t, e) {
2
- const o = "virtual:storyblok-init", s = "\0" + o;
1
+ function Or(o, e, r) {
2
+ const i = "virtual:storyblok-init", s = "\0" + i;
3
3
  return {
4
4
  name: "vite-plugin-storyblok-init",
5
- async resolveId(a) {
6
- if (a === o)
5
+ async resolveId(l) {
6
+ if (l === i)
7
7
  return s;
8
8
  },
9
- async load(a) {
10
- if (a === s)
9
+ async load(l) {
10
+ if (l === s)
11
11
  return `
12
12
  import { storyblokInit, apiPlugin } from "@storyblok/js";
13
13
  const { storyblokApi } = storyblokInit({
14
- accessToken: "${r}",
15
- use: ${t ? "[]" : "[apiPlugin]"},
16
- apiOptions: ${JSON.stringify(e)},
14
+ accessToken: "${o}",
15
+ use: ${e ? "[]" : "[apiPlugin]"},
16
+ apiOptions: ${JSON.stringify(r)},
17
17
  });
18
18
  export const storyblokApiInstance = storyblokApi;
19
19
  `;
20
20
  }
21
21
  };
22
22
  }
23
- const T = /[\p{Lu}]/u, x = /[\p{Ll}]/u, k = /^[\p{Lu}](?![\p{Lu}])/gu, C = /([\p{Alpha}\p{N}_]|$)/u, m = /[_.\- ]+/, S = new RegExp("^" + m.source), $ = new RegExp(m.source + C.source, "gu"), v = new RegExp("\\d+" + C.source, "gu"), j = (r, t, e, o) => {
24
- let s = !1, a = !1, n = !1, c = !1;
25
- for (let l = 0; l < r.length; l++) {
26
- const i = r[l];
27
- c = l > 2 ? r[l - 3] === "-" : !0, s && T.test(i) ? (r = r.slice(0, l) + "-" + r.slice(l), s = !1, n = a, a = !0, l++) : a && n && x.test(i) && (!c || o) ? (r = r.slice(0, l - 1) + "-" + r.slice(l - 1), n = a, a = !1, s = !0) : (s = t(i) === i && e(i) !== i, n = a, a = e(i) === i && t(i) !== i);
23
+ const Sr = /[\p{Lu}]/u, Cr = /[\p{Ll}]/u, zt = /^[\p{Lu}](?![\p{Lu}])/gu, qt = /([\p{Alpha}\p{N}_]|$)/u, ft = /[_.\- ]+/, jr = new RegExp("^" + ft.source), Lt = new RegExp(ft.source + qt.source, "gu"), Ut = new RegExp("\\d+" + qt.source, "gu"), $r = (o, e, r, i) => {
24
+ let s = !1, l = !1, u = !1, b = !1;
25
+ for (let d = 0; d < o.length; d++) {
26
+ const h = o[d];
27
+ b = d > 2 ? o[d - 3] === "-" : !0, s && Sr.test(h) ? (o = o.slice(0, d) + "-" + o.slice(d), s = !1, u = l, l = !0, d++) : l && u && Cr.test(h) && (!b || i) ? (o = o.slice(0, d - 1) + "-" + o.slice(d - 1), u = l, l = !1, s = !0) : (s = e(h) === h && r(h) !== h, u = l, l = r(h) === h && e(h) !== h);
28
28
  }
29
- return r;
30
- }, R = (r, t) => (k.lastIndex = 0, r.replaceAll(k, (e) => t(e))), O = (r, t) => ($.lastIndex = 0, v.lastIndex = 0, r.replaceAll(v, (e, o, s) => ["_", "-"].includes(r.charAt(s + e.length)) ? e : t(e)).replaceAll($, (e, o) => t(o)));
31
- function I(r, t) {
32
- if (!(typeof r == "string" || Array.isArray(r)))
29
+ return o;
30
+ }, xr = (o, e) => (zt.lastIndex = 0, o.replaceAll(zt, (r) => e(r))), Er = (o, e) => (Lt.lastIndex = 0, Ut.lastIndex = 0, o.replaceAll(Ut, (r, i, s) => ["_", "-"].includes(o.charAt(s + r.length)) ? r : e(r)).replaceAll(Lt, (r, i) => e(i)));
31
+ function Dt(o, e) {
32
+ if (!(typeof o == "string" || Array.isArray(o)))
33
33
  throw new TypeError("Expected the input to be `string | string[]`");
34
- if (t = {
34
+ if (e = {
35
35
  pascalCase: !1,
36
36
  preserveConsecutiveUppercase: !1,
37
- ...t
38
- }, Array.isArray(r) ? r = r.map((a) => a.trim()).filter((a) => a.length).join("-") : r = r.trim(), r.length === 0)
37
+ ...e
38
+ }, Array.isArray(o) ? o = o.map((l) => l.trim()).filter((l) => l.length).join("-") : o = o.trim(), o.length === 0)
39
39
  return "";
40
- const e = t.locale === !1 ? (a) => a.toLowerCase() : (a) => a.toLocaleLowerCase(t.locale), o = t.locale === !1 ? (a) => a.toUpperCase() : (a) => a.toLocaleUpperCase(t.locale);
41
- return r.length === 1 ? m.test(r) ? "" : t.pascalCase ? o(r) : e(r) : (r !== e(r) && (r = j(r, e, o, t.preserveConsecutiveUppercase)), r = r.replace(S, ""), r = t.preserveConsecutiveUppercase ? R(r, e) : e(r), t.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), O(r, o));
40
+ const r = e.locale === !1 ? (l) => l.toLowerCase() : (l) => l.toLocaleLowerCase(e.locale), i = e.locale === !1 ? (l) => l.toUpperCase() : (l) => l.toLocaleUpperCase(e.locale);
41
+ return o.length === 1 ? ft.test(o) ? "" : e.pascalCase ? i(o) : r(o) : (o !== r(o) && (o = $r(o, r, i, e.preserveConsecutiveUppercase)), o = o.replace(jr, ""), o = e.preserveConsecutiveUppercase ? xr(o, r) : r(o), e.pascalCase && (o = i(o.charAt(0)) + o.slice(1)), Er(o, i));
42
42
  }
43
- function N(r, t, e, o) {
44
- const s = "virtual:storyblok-components", a = "\0" + s;
43
+ function Rr(o, e, r, i) {
44
+ const s = "virtual:storyblok-components", l = "\0" + s;
45
45
  return {
46
46
  name: "vite-plugin-storyblok-components",
47
- async resolveId(n) {
48
- if (n === s)
49
- return a;
47
+ async resolveId(u) {
48
+ if (u === s)
49
+ return l;
50
50
  },
51
- async load(n) {
52
- if (n === a) {
53
- const c = [], l = [];
54
- for await (const [g, f] of Object.entries(t)) {
55
- const d = await this.resolve(
56
- "/" + r + "/" + f + ".astro"
51
+ async load(u) {
52
+ if (u === l) {
53
+ const b = [], d = [];
54
+ for await (const [v, w] of Object.entries(e)) {
55
+ const T = await this.resolve(
56
+ "/" + o + "/" + w + ".astro"
57
57
  );
58
- if (d)
59
- c.push(`import ${I(g)} from "${d.id}"`);
60
- else if (e)
61
- l.push(g);
58
+ if (T)
59
+ b.push(`import ${Dt(v)} from "${T.id}"`);
60
+ else if (r)
61
+ d.push(v);
62
62
  else
63
63
  throw new Error(
64
- `Component could not be found for blok "${g}"! Does "${"/" + r + "/" + f}.astro" exist?`
64
+ `Component could not be found for blok "${v}"! Does "${"/" + o + "/" + w}.astro" exist?`
65
65
  );
66
66
  }
67
- let i = "";
68
- if (e)
69
- if (i = ",FallbackComponent", o) {
70
- const g = await this.resolve(
71
- "/" + r + "/" + o + ".astro"
67
+ let h = "";
68
+ if (r)
69
+ if (h = ",FallbackComponent", i) {
70
+ const v = await this.resolve(
71
+ "/" + o + "/" + i + ".astro"
72
72
  );
73
- if (!g)
73
+ if (!v)
74
74
  throw new Error(
75
- `Custom fallback component could not be found. Does "${"/" + r + "/" + o}.astro" exist?`
75
+ `Custom fallback component could not be found. Does "${"/" + o + "/" + i}.astro" exist?`
76
76
  );
77
- c.push(
78
- `import FallbackComponent from "${g.id}"`
77
+ b.push(
78
+ `import FallbackComponent from "${v.id}"`
79
79
  );
80
80
  } else
81
- c.push(
81
+ b.push(
82
82
  "import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
83
83
  );
84
- if (Object.values(t).length)
85
- return `${c.join(";")};export default {${Object.keys(t).filter((g) => !l.includes(g)).map((g) => I(g)).join(",")}${i}}`;
86
- if (e)
87
- return `${c[0]}; export default {${i.replace(",", "")}}`;
84
+ if (Object.values(e).length)
85
+ return `${b.join(";")};export default {${Object.keys(e).filter((v) => !d.includes(v)).map((v) => Dt(v)).join(",")}${h}}`;
86
+ if (r)
87
+ return `${b[0]}; export default {${h.replace(",", "")}}`;
88
88
  throw new Error(
89
89
  `Currently, no Storyblok components are registered in astro.config.mjs.
90
90
  Please register your components or enable the fallback component.
@@ -94,54 +94,615 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
94
94
  }
95
95
  };
96
96
  }
97
- function L(r) {
98
- const t = "virtual:storyblok-options", e = "\0" + t;
97
+ function Mr(o) {
98
+ const e = "virtual:storyblok-options", r = "\0" + e;
99
99
  return {
100
100
  name: "vite-plugin-storyblok-options",
101
- async resolveId(o) {
102
- if (o === t)
103
- return e;
101
+ async resolveId(i) {
102
+ if (i === e)
103
+ return r;
104
+ },
105
+ async load(i) {
106
+ if (i === r)
107
+ return `export default ${JSON.stringify(o)}`;
108
+ }
109
+ };
110
+ }
111
+ var Z = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
112
+ function Pr(o) {
113
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
114
+ }
115
+ var Q = { exports: {} };
116
+ Q.exports;
117
+ (function(o, e) {
118
+ var r = 200, i = "__lodash_hash_undefined__", s = 800, l = 16, u = 9007199254740991, b = "[object Arguments]", d = "[object Array]", h = "[object AsyncFunction]", v = "[object Boolean]", w = "[object Date]", T = "[object Error]", E = "[object Function]", A = "[object GeneratorFunction]", P = "[object Map]", B = "[object Number]", Gt = "[object Null]", pt = "[object Object]", Jt = "[object Proxy]", Kt = "[object RegExp]", Wt = "[object Set]", Yt = "[object String]", Xt = "[object Undefined]", Zt = "[object WeakMap]", Qt = "[object ArrayBuffer]", Vt = "[object DataView]", te = "[object Float32Array]", ee = "[object Float64Array]", re = "[object Int8Array]", ne = "[object Int16Array]", oe = "[object Int32Array]", ae = "[object Uint8Array]", ie = "[object Uint8ClampedArray]", se = "[object Uint16Array]", le = "[object Uint32Array]", ce = /[\\^$.*+?()[\]{}|]/g, ue = /^\[object .+?Constructor\]$/, fe = /^(?:0|[1-9]\d*)$/, y = {};
119
+ y[te] = y[ee] = y[re] = y[ne] = y[oe] = y[ae] = y[ie] = y[se] = y[le] = !0, y[b] = y[d] = y[Qt] = y[v] = y[Vt] = y[w] = y[T] = y[E] = y[P] = y[B] = y[pt] = y[Kt] = y[Wt] = y[Yt] = y[Zt] = !1;
120
+ var dt = typeof Z == "object" && Z && Z.Object === Object && Z, pe = typeof self == "object" && self && self.Object === Object && self, N = dt || pe || Function("return this")(), gt = e && !e.nodeType && e, z = gt && !0 && o && !o.nodeType && o, ht = z && z.exports === gt, V = ht && dt.process, yt = function() {
121
+ try {
122
+ var t = z && z.require && z.require("util").types;
123
+ return t || V && V.binding && V.binding("util");
124
+ } catch {
125
+ }
126
+ }(), bt = yt && yt.isTypedArray;
127
+ function de(t, n, a) {
128
+ switch (a.length) {
129
+ case 0:
130
+ return t.call(n);
131
+ case 1:
132
+ return t.call(n, a[0]);
133
+ case 2:
134
+ return t.call(n, a[0], a[1]);
135
+ case 3:
136
+ return t.call(n, a[0], a[1], a[2]);
137
+ }
138
+ return t.apply(n, a);
139
+ }
140
+ function ge(t, n) {
141
+ for (var a = -1, c = Array(t); ++a < t; )
142
+ c[a] = n(a);
143
+ return c;
144
+ }
145
+ function he(t) {
146
+ return function(n) {
147
+ return t(n);
148
+ };
149
+ }
150
+ function ye(t, n) {
151
+ return t == null ? void 0 : t[n];
152
+ }
153
+ function be(t, n) {
154
+ return function(a) {
155
+ return t(n(a));
156
+ };
157
+ }
158
+ var me = Array.prototype, _e = Function.prototype, H = Object.prototype, tt = N["__core-js_shared__"], q = _e.toString, S = H.hasOwnProperty, mt = function() {
159
+ var t = /[^.]+$/.exec(tt && tt.keys && tt.keys.IE_PROTO || "");
160
+ return t ? "Symbol(src)_1." + t : "";
161
+ }(), _t = H.toString, ve = q.call(Object), Te = RegExp(
162
+ "^" + q.call(S).replace(ce, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
163
+ ), G = ht ? N.Buffer : void 0, vt = N.Symbol, Tt = N.Uint8Array, wt = G ? G.allocUnsafe : void 0, At = be(Object.getPrototypeOf, Object), It = Object.create, we = H.propertyIsEnumerable, Ae = me.splice, j = vt ? vt.toStringTag : void 0, J = function() {
164
+ try {
165
+ var t = nt(Object, "defineProperty");
166
+ return t({}, "", {}), t;
167
+ } catch {
168
+ }
169
+ }(), Ie = G ? G.isBuffer : void 0, kt = Math.max, ke = Date.now, Ot = nt(N, "Map"), L = nt(Object, "create"), Oe = /* @__PURE__ */ function() {
170
+ function t() {
171
+ }
172
+ return function(n) {
173
+ if (!x(n))
174
+ return {};
175
+ if (It)
176
+ return It(n);
177
+ t.prototype = n;
178
+ var a = new t();
179
+ return t.prototype = void 0, a;
180
+ };
181
+ }();
182
+ function $(t) {
183
+ var n = -1, a = t == null ? 0 : t.length;
184
+ for (this.clear(); ++n < a; ) {
185
+ var c = t[n];
186
+ this.set(c[0], c[1]);
187
+ }
188
+ }
189
+ function Se() {
190
+ this.__data__ = L ? L(null) : {}, this.size = 0;
191
+ }
192
+ function Ce(t) {
193
+ var n = this.has(t) && delete this.__data__[t];
194
+ return this.size -= n ? 1 : 0, n;
195
+ }
196
+ function je(t) {
197
+ var n = this.__data__;
198
+ if (L) {
199
+ var a = n[t];
200
+ return a === i ? void 0 : a;
201
+ }
202
+ return S.call(n, t) ? n[t] : void 0;
203
+ }
204
+ function $e(t) {
205
+ var n = this.__data__;
206
+ return L ? n[t] !== void 0 : S.call(n, t);
207
+ }
208
+ function xe(t, n) {
209
+ var a = this.__data__;
210
+ return this.size += this.has(t) ? 0 : 1, a[t] = L && n === void 0 ? i : n, this;
211
+ }
212
+ $.prototype.clear = Se, $.prototype.delete = Ce, $.prototype.get = je, $.prototype.has = $e, $.prototype.set = xe;
213
+ function C(t) {
214
+ var n = -1, a = t == null ? 0 : t.length;
215
+ for (this.clear(); ++n < a; ) {
216
+ var c = t[n];
217
+ this.set(c[0], c[1]);
218
+ }
219
+ }
220
+ function Ee() {
221
+ this.__data__ = [], this.size = 0;
222
+ }
223
+ function Re(t) {
224
+ var n = this.__data__, a = K(n, t);
225
+ if (a < 0)
226
+ return !1;
227
+ var c = n.length - 1;
228
+ return a == c ? n.pop() : Ae.call(n, a, 1), --this.size, !0;
229
+ }
230
+ function Me(t) {
231
+ var n = this.__data__, a = K(n, t);
232
+ return a < 0 ? void 0 : n[a][1];
233
+ }
234
+ function Pe(t) {
235
+ return K(this.__data__, t) > -1;
236
+ }
237
+ function Ne(t, n) {
238
+ var a = this.__data__, c = K(a, t);
239
+ return c < 0 ? (++this.size, a.push([t, n])) : a[c][1] = n, this;
240
+ }
241
+ C.prototype.clear = Ee, C.prototype.delete = Re, C.prototype.get = Me, C.prototype.has = Pe, C.prototype.set = Ne;
242
+ function R(t) {
243
+ var n = -1, a = t == null ? 0 : t.length;
244
+ for (this.clear(); ++n < a; ) {
245
+ var c = t[n];
246
+ this.set(c[0], c[1]);
247
+ }
248
+ }
249
+ function ze() {
250
+ this.size = 0, this.__data__ = {
251
+ hash: new $(),
252
+ map: new (Ot || C)(),
253
+ string: new $()
254
+ };
255
+ }
256
+ function Le(t) {
257
+ var n = Y(this, t).delete(t);
258
+ return this.size -= n ? 1 : 0, n;
259
+ }
260
+ function Ue(t) {
261
+ return Y(this, t).get(t);
262
+ }
263
+ function De(t) {
264
+ return Y(this, t).has(t);
265
+ }
266
+ function Fe(t, n) {
267
+ var a = Y(this, t), c = a.size;
268
+ return a.set(t, n), this.size += a.size == c ? 0 : 1, this;
269
+ }
270
+ R.prototype.clear = ze, R.prototype.delete = Le, R.prototype.get = Ue, R.prototype.has = De, R.prototype.set = Fe;
271
+ function M(t) {
272
+ var n = this.__data__ = new C(t);
273
+ this.size = n.size;
274
+ }
275
+ function Be() {
276
+ this.__data__ = new C(), this.size = 0;
277
+ }
278
+ function He(t) {
279
+ var n = this.__data__, a = n.delete(t);
280
+ return this.size = n.size, a;
281
+ }
282
+ function qe(t) {
283
+ return this.__data__.get(t);
284
+ }
285
+ function Ge(t) {
286
+ return this.__data__.has(t);
287
+ }
288
+ function Je(t, n) {
289
+ var a = this.__data__;
290
+ if (a instanceof C) {
291
+ var c = a.__data__;
292
+ if (!Ot || c.length < r - 1)
293
+ return c.push([t, n]), this.size = ++a.size, this;
294
+ a = this.__data__ = new R(c);
295
+ }
296
+ return a.set(t, n), this.size = a.size, this;
297
+ }
298
+ M.prototype.clear = Be, M.prototype.delete = He, M.prototype.get = qe, M.prototype.has = Ge, M.prototype.set = Je;
299
+ function Ke(t, n) {
300
+ var a = it(t), c = !a && at(t), p = !a && !c && xt(t), g = !a && !c && !p && Rt(t), m = a || c || p || g, f = m ? ge(t.length, String) : [], _ = f.length;
301
+ for (var k in t)
302
+ (n || S.call(t, k)) && !(m && // Safari 9 has enumerable `arguments.length` in strict mode.
303
+ (k == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
304
+ p && (k == "offset" || k == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
305
+ g && (k == "buffer" || k == "byteLength" || k == "byteOffset") || // Skip index properties.
306
+ jt(k, _))) && f.push(k);
307
+ return f;
308
+ }
309
+ function et(t, n, a) {
310
+ (a !== void 0 && !X(t[n], a) || a === void 0 && !(n in t)) && rt(t, n, a);
311
+ }
312
+ function We(t, n, a) {
313
+ var c = t[n];
314
+ (!(S.call(t, n) && X(c, a)) || a === void 0 && !(n in t)) && rt(t, n, a);
315
+ }
316
+ function K(t, n) {
317
+ for (var a = t.length; a--; )
318
+ if (X(t[a][0], n))
319
+ return a;
320
+ return -1;
321
+ }
322
+ function rt(t, n, a) {
323
+ n == "__proto__" && J ? J(t, n, {
324
+ configurable: !0,
325
+ enumerable: !0,
326
+ value: a,
327
+ writable: !0
328
+ }) : t[n] = a;
329
+ }
330
+ var Ye = lr();
331
+ function W(t) {
332
+ return t == null ? t === void 0 ? Xt : Gt : j && j in Object(t) ? cr(t) : hr(t);
333
+ }
334
+ function St(t) {
335
+ return U(t) && W(t) == b;
336
+ }
337
+ function Xe(t) {
338
+ if (!x(t) || dr(t))
339
+ return !1;
340
+ var n = lt(t) ? Te : ue;
341
+ return n.test(_r(t));
342
+ }
343
+ function Ze(t) {
344
+ return U(t) && Et(t.length) && !!y[W(t)];
345
+ }
346
+ function Qe(t) {
347
+ if (!x(t))
348
+ return gr(t);
349
+ var n = $t(t), a = [];
350
+ for (var c in t)
351
+ c == "constructor" && (n || !S.call(t, c)) || a.push(c);
352
+ return a;
353
+ }
354
+ function Ct(t, n, a, c, p) {
355
+ t !== n && Ye(n, function(g, m) {
356
+ if (p || (p = new M()), x(g))
357
+ Ve(t, n, m, a, Ct, c, p);
358
+ else {
359
+ var f = c ? c(ot(t, m), g, m + "", t, n, p) : void 0;
360
+ f === void 0 && (f = g), et(t, m, f);
361
+ }
362
+ }, Mt);
363
+ }
364
+ function Ve(t, n, a, c, p, g, m) {
365
+ var f = ot(t, a), _ = ot(n, a), k = m.get(_);
366
+ if (k) {
367
+ et(t, a, k);
368
+ return;
369
+ }
370
+ var I = g ? g(f, _, a + "", t, n, m) : void 0, D = I === void 0;
371
+ if (D) {
372
+ var ct = it(_), ut = !ct && xt(_), Nt = !ct && !ut && Rt(_);
373
+ I = _, ct || ut || Nt ? it(f) ? I = f : vr(f) ? I = ar(f) : ut ? (D = !1, I = rr(_, !0)) : Nt ? (D = !1, I = or(_, !0)) : I = [] : Tr(_) || at(_) ? (I = f, at(f) ? I = wr(f) : (!x(f) || lt(f)) && (I = ur(_))) : D = !1;
374
+ }
375
+ D && (m.set(_, I), p(I, _, c, g, m), m.delete(_)), et(t, a, I);
376
+ }
377
+ function tr(t, n) {
378
+ return br(yr(t, n, Pt), t + "");
379
+ }
380
+ var er = J ? function(t, n) {
381
+ return J(t, "toString", {
382
+ configurable: !0,
383
+ enumerable: !1,
384
+ value: Ir(n),
385
+ writable: !0
386
+ });
387
+ } : Pt;
388
+ function rr(t, n) {
389
+ if (n)
390
+ return t.slice();
391
+ var a = t.length, c = wt ? wt(a) : new t.constructor(a);
392
+ return t.copy(c), c;
393
+ }
394
+ function nr(t) {
395
+ var n = new t.constructor(t.byteLength);
396
+ return new Tt(n).set(new Tt(t)), n;
397
+ }
398
+ function or(t, n) {
399
+ var a = n ? nr(t.buffer) : t.buffer;
400
+ return new t.constructor(a, t.byteOffset, t.length);
401
+ }
402
+ function ar(t, n) {
403
+ var a = -1, c = t.length;
404
+ for (n || (n = Array(c)); ++a < c; )
405
+ n[a] = t[a];
406
+ return n;
407
+ }
408
+ function ir(t, n, a, c) {
409
+ var p = !a;
410
+ a || (a = {});
411
+ for (var g = -1, m = n.length; ++g < m; ) {
412
+ var f = n[g], _ = c ? c(a[f], t[f], f, a, t) : void 0;
413
+ _ === void 0 && (_ = t[f]), p ? rt(a, f, _) : We(a, f, _);
414
+ }
415
+ return a;
416
+ }
417
+ function sr(t) {
418
+ return tr(function(n, a) {
419
+ var c = -1, p = a.length, g = p > 1 ? a[p - 1] : void 0, m = p > 2 ? a[2] : void 0;
420
+ for (g = t.length > 3 && typeof g == "function" ? (p--, g) : void 0, m && fr(a[0], a[1], m) && (g = p < 3 ? void 0 : g, p = 1), n = Object(n); ++c < p; ) {
421
+ var f = a[c];
422
+ f && t(n, f, c, g);
423
+ }
424
+ return n;
425
+ });
426
+ }
427
+ function lr(t) {
428
+ return function(n, a, c) {
429
+ for (var p = -1, g = Object(n), m = c(n), f = m.length; f--; ) {
430
+ var _ = m[t ? f : ++p];
431
+ if (a(g[_], _, g) === !1)
432
+ break;
433
+ }
434
+ return n;
435
+ };
436
+ }
437
+ function Y(t, n) {
438
+ var a = t.__data__;
439
+ return pr(n) ? a[typeof n == "string" ? "string" : "hash"] : a.map;
440
+ }
441
+ function nt(t, n) {
442
+ var a = ye(t, n);
443
+ return Xe(a) ? a : void 0;
444
+ }
445
+ function cr(t) {
446
+ var n = S.call(t, j), a = t[j];
447
+ try {
448
+ t[j] = void 0;
449
+ var c = !0;
450
+ } catch {
451
+ }
452
+ var p = _t.call(t);
453
+ return c && (n ? t[j] = a : delete t[j]), p;
454
+ }
455
+ function ur(t) {
456
+ return typeof t.constructor == "function" && !$t(t) ? Oe(At(t)) : {};
457
+ }
458
+ function jt(t, n) {
459
+ var a = typeof t;
460
+ return n = n ?? u, !!n && (a == "number" || a != "symbol" && fe.test(t)) && t > -1 && t % 1 == 0 && t < n;
461
+ }
462
+ function fr(t, n, a) {
463
+ if (!x(a))
464
+ return !1;
465
+ var c = typeof n;
466
+ return (c == "number" ? st(a) && jt(n, a.length) : c == "string" && n in a) ? X(a[n], t) : !1;
467
+ }
468
+ function pr(t) {
469
+ var n = typeof t;
470
+ return n == "string" || n == "number" || n == "symbol" || n == "boolean" ? t !== "__proto__" : t === null;
471
+ }
472
+ function dr(t) {
473
+ return !!mt && mt in t;
474
+ }
475
+ function $t(t) {
476
+ var n = t && t.constructor, a = typeof n == "function" && n.prototype || H;
477
+ return t === a;
478
+ }
479
+ function gr(t) {
480
+ var n = [];
481
+ if (t != null)
482
+ for (var a in Object(t))
483
+ n.push(a);
484
+ return n;
485
+ }
486
+ function hr(t) {
487
+ return _t.call(t);
488
+ }
489
+ function yr(t, n, a) {
490
+ return n = kt(n === void 0 ? t.length - 1 : n, 0), function() {
491
+ for (var c = arguments, p = -1, g = kt(c.length - n, 0), m = Array(g); ++p < g; )
492
+ m[p] = c[n + p];
493
+ p = -1;
494
+ for (var f = Array(n + 1); ++p < n; )
495
+ f[p] = c[p];
496
+ return f[n] = a(m), de(t, this, f);
497
+ };
498
+ }
499
+ function ot(t, n) {
500
+ if (!(n === "constructor" && typeof t[n] == "function") && n != "__proto__")
501
+ return t[n];
502
+ }
503
+ var br = mr(er);
504
+ function mr(t) {
505
+ var n = 0, a = 0;
506
+ return function() {
507
+ var c = ke(), p = l - (c - a);
508
+ if (a = c, p > 0) {
509
+ if (++n >= s)
510
+ return arguments[0];
511
+ } else
512
+ n = 0;
513
+ return t.apply(void 0, arguments);
514
+ };
515
+ }
516
+ function _r(t) {
517
+ if (t != null) {
518
+ try {
519
+ return q.call(t);
520
+ } catch {
521
+ }
522
+ try {
523
+ return t + "";
524
+ } catch {
525
+ }
526
+ }
527
+ return "";
528
+ }
529
+ function X(t, n) {
530
+ return t === n || t !== t && n !== n;
531
+ }
532
+ var at = St(/* @__PURE__ */ function() {
533
+ return arguments;
534
+ }()) ? St : function(t) {
535
+ return U(t) && S.call(t, "callee") && !we.call(t, "callee");
536
+ }, it = Array.isArray;
537
+ function st(t) {
538
+ return t != null && Et(t.length) && !lt(t);
539
+ }
540
+ function vr(t) {
541
+ return U(t) && st(t);
542
+ }
543
+ var xt = Ie || kr;
544
+ function lt(t) {
545
+ if (!x(t))
546
+ return !1;
547
+ var n = W(t);
548
+ return n == E || n == A || n == h || n == Jt;
549
+ }
550
+ function Et(t) {
551
+ return typeof t == "number" && t > -1 && t % 1 == 0 && t <= u;
552
+ }
553
+ function x(t) {
554
+ var n = typeof t;
555
+ return t != null && (n == "object" || n == "function");
556
+ }
557
+ function U(t) {
558
+ return t != null && typeof t == "object";
559
+ }
560
+ function Tr(t) {
561
+ if (!U(t) || W(t) != pt)
562
+ return !1;
563
+ var n = At(t);
564
+ if (n === null)
565
+ return !0;
566
+ var a = S.call(n, "constructor") && n.constructor;
567
+ return typeof a == "function" && a instanceof a && q.call(a) == ve;
568
+ }
569
+ var Rt = bt ? he(bt) : Ze;
570
+ function wr(t) {
571
+ return ir(t, Mt(t));
572
+ }
573
+ function Mt(t) {
574
+ return st(t) ? Ke(t, !0) : Qe(t);
575
+ }
576
+ var Ar = sr(function(t, n, a, c) {
577
+ Ct(t, n, a, c);
578
+ });
579
+ function Ir(t) {
580
+ return function() {
581
+ return t;
582
+ };
583
+ }
584
+ function Pt(t) {
585
+ return t;
586
+ }
587
+ function kr() {
588
+ return !1;
589
+ }
590
+ o.exports = Ar;
591
+ })(Q, Q.exports);
592
+ var Nr = Q.exports;
593
+ const zr = /* @__PURE__ */ Pr(Nr);
594
+ function Lr(o) {
595
+ let e;
596
+ function r(i, s) {
597
+ var l, u, b, d, h, v, w;
598
+ if ((s == null ? void 0 : s.type) === "AwaitExpression" && ((u = (l = s == null ? void 0 : s.argument) == null ? void 0 : l.callee) == null ? void 0 : u.name) === "useStoryblok") {
599
+ const T = (b = s == null ? void 0 : s.argument) == null ? void 0 : b.arguments;
600
+ ((d = T[1]) == null ? void 0 : d.type) === "ObjectExpression" && (e = {
601
+ ...e,
602
+ apiOptions: Ft((h = T[1]) == null ? void 0 : h.properties)
603
+ }), ((v = T[2]) == null ? void 0 : v.type) === "ObjectExpression" && (e = {
604
+ ...e,
605
+ bridgeOptions: Ft((w = T[2]) == null ? void 0 : w.properties)
606
+ });
607
+ }
608
+ }
609
+ return zr({}, o, r), e;
610
+ }
611
+ function Ft(o) {
612
+ return o.reduce((e, { key: r, value: i }) => {
613
+ const { type: s } = i;
614
+ return e[r.name] = s === "Literal" ? i.value : s === "ArrayExpression" ? i.elements.map((l) => l.value) : i.value, e;
615
+ }, {});
616
+ }
617
+ function Ur(o) {
618
+ let e = {
619
+ resolveRelations: []
620
+ };
621
+ function r(i) {
622
+ i && (Array.isArray(i) ? e.resolveRelations.push(...i) : e.resolveRelations.push(i));
623
+ }
624
+ for (const i of o)
625
+ if (i.options) {
626
+ const { apiOptions: s, bridgeOptions: l } = i.options;
627
+ if (r(s == null ? void 0 : s.resolve_relations), l) {
628
+ const { resolveRelations: u, ...b } = l;
629
+ r(u), Object.assign(e, b);
630
+ }
631
+ }
632
+ return e.resolveRelations = [...new Set(e.resolveRelations)], e;
633
+ }
634
+ let F = [];
635
+ function Dr() {
636
+ let o = [];
637
+ const e = "virtual:storyblok-bridge", r = "\0" + e;
638
+ let i = null, s = null;
639
+ return {
640
+ name: "vite-plugin-storyblok-bridge",
641
+ async resolveId(l) {
642
+ if (l === e)
643
+ return r;
644
+ },
645
+ async transform(l, u) {
646
+ var w;
647
+ if (u.includes("node_modules") && !u.includes("/pages/") || !l.includes("useStoryblok") || !((w = this.getModuleInfo(u).meta) != null && w.astro))
648
+ return;
649
+ const [, ...d] = u.split("src/pages/"), h = d.join("/").replace(".astro", ""), v = Lr(this.parse(l));
650
+ F.length && (o = F.filter((T) => T.url !== h)), o.push({
651
+ url: h,
652
+ options: v
653
+ }), i && (s && clearTimeout(s), s = setTimeout(() => {
654
+ Fr(F, o) || (F.length !== 0 && (i.restart(), console.info("Updating bridge options...")), F = [...o]);
655
+ }, 1e3));
656
+ },
657
+ async load(l) {
658
+ if (l === r)
659
+ return `export const bridgeOptions = ${JSON.stringify(Ur(o))}`;
104
660
  },
105
- async load(o) {
106
- if (o === e)
107
- return `export default ${JSON.stringify(r)}`;
661
+ configureServer(l) {
662
+ i = l;
108
663
  }
109
664
  };
110
665
  }
111
- let w = !1;
112
- const A = [], M = (r) => new Promise((t, e) => {
666
+ function Fr(o = [], e = []) {
667
+ return e.every(({ url: r, options: i }) => {
668
+ const s = o.find((l) => (l == null ? void 0 : l.url) === r);
669
+ return s && JSON.stringify(i) === JSON.stringify(s.options);
670
+ });
671
+ }
672
+ let Bt = !1;
673
+ const Ht = [], Br = (o) => new Promise((e, r) => {
113
674
  if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
114
675
  if (window.location === window.parent.location) {
115
676
  console.warn("You are not in Draft Mode or in the Visual Editor.");
116
677
  return;
117
678
  }
118
- w ? s() : A.push(s);
679
+ Bt ? s() : Ht.push(s);
119
680
  }, document.getElementById("storyblok-javascript-bridge")))
120
681
  return;
121
- const o = document.createElement("script");
122
- o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (s) => e(s), o.onload = (s) => {
123
- A.forEach((a) => a()), w = !0, t(s);
124
- }, document.getElementsByTagName("head")[0].appendChild(o);
682
+ const i = document.createElement("script");
683
+ i.async = !0, i.src = o, i.id = "storyblok-javascript-bridge", i.onerror = (s) => r(s), i.onload = (s) => {
684
+ Ht.forEach((l) => l()), Bt = !0, e(s);
685
+ }, document.getElementsByTagName("head")[0].appendChild(i);
125
686
  });
126
- var P = Object.defineProperty, _ = (r, t, e) => t in r ? P(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, p = (r, t, e) => (_(r, typeof t != "symbol" ? t + "" : t, e), e);
127
- class z {
687
+ var Hr = Object.defineProperty, qr = (o, e, r) => e in o ? Hr(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r, O = (o, e, r) => (qr(o, typeof e != "symbol" ? e + "" : e, r), r);
688
+ class Gr {
128
689
  constructor() {
129
- p(this, "isCDNUrl", (t = "") => t.indexOf("/cdn/") > -1), p(this, "getOptionsPage", (t, e = 25, o = 1) => ({
130
- ...t,
131
- per_page: e,
132
- page: o
133
- })), p(this, "delay", (t) => new Promise((e) => setTimeout(e, t))), p(this, "arrayFrom", (t = 0, e) => [...Array(t)].map(e)), p(this, "range", (t = 0, e = t) => {
134
- const o = Math.abs(e - t) || 0, s = t < e ? 1 : -1;
135
- return this.arrayFrom(o, (a, n) => n * s + t);
136
- }), p(this, "asyncMap", async (t, e) => Promise.all(t.map(e))), p(this, "flatMap", (t = [], e) => t.map(e).reduce((o, s) => [...o, ...s], [])), p(this, "escapeHTML", function(t) {
137
- const e = {
690
+ O(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), O(this, "getOptionsPage", (e, r = 25, i = 1) => ({
691
+ ...e,
692
+ per_page: r,
693
+ page: i
694
+ })), O(this, "delay", (e) => new Promise((r) => setTimeout(r, e))), O(this, "arrayFrom", (e = 0, r) => [...Array(e)].map(r)), O(this, "range", (e = 0, r = e) => {
695
+ const i = Math.abs(r - e) || 0, s = e < r ? 1 : -1;
696
+ return this.arrayFrom(i, (l, u) => u * s + e);
697
+ }), O(this, "asyncMap", async (e, r) => Promise.all(e.map(r))), O(this, "flatMap", (e = [], r) => e.map(r).reduce((i, s) => [...i, ...s], [])), O(this, "escapeHTML", function(e) {
698
+ const r = {
138
699
  "&": "&amp;",
139
700
  "<": "&lt;",
140
701
  ">": "&gt;",
141
702
  '"': "&quot;",
142
703
  "'": "&#39;"
143
- }, o = /[&<>"']/g, s = RegExp(o.source);
144
- return t && s.test(t) ? t.replace(o, (a) => e[a]) : t;
704
+ }, i = /[&<>"']/g, s = RegExp(i.source);
705
+ return e && s.test(e) ? e.replace(i, (l) => r[l]) : e;
145
706
  });
146
707
  }
147
708
  /**
@@ -151,18 +712,18 @@ class z {
151
712
  * @param {Boolean} isArray
152
713
  * @return {String} Stringified object
153
714
  */
154
- stringify(t, e, o) {
715
+ stringify(e, r, i) {
155
716
  const s = [];
156
- for (const a in t) {
157
- if (!Object.prototype.hasOwnProperty.call(t, a))
717
+ for (const l in e) {
718
+ if (!Object.prototype.hasOwnProperty.call(e, l))
158
719
  continue;
159
- const n = t[a], c = o ? "" : encodeURIComponent(a);
160
- let l;
161
- typeof n == "object" ? l = this.stringify(
162
- n,
163
- e ? e + encodeURIComponent("[" + c + "]") : c,
164
- Array.isArray(n)
165
- ) : l = (e ? e + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(n), s.push(l);
720
+ const u = e[l], b = i ? "" : encodeURIComponent(l);
721
+ let d;
722
+ typeof u == "object" ? d = this.stringify(
723
+ u,
724
+ r ? r + encodeURIComponent("[" + b + "]") : b,
725
+ Array.isArray(u)
726
+ ) : d = (r ? r + encodeURIComponent("[" + b + "]") : b) + "=" + encodeURIComponent(u), s.push(d);
166
727
  }
167
728
  return s.join("&");
168
729
  }
@@ -171,203 +732,203 @@ class z {
171
732
  * @param {String} regionCode region code, could be eu, us, cn, ap or ca
172
733
  * @return {String} The base URL of the region
173
734
  */
174
- getRegionURL(t) {
175
- const e = "api.storyblok.com", o = "api-us.storyblok.com", s = "app.storyblokchina.cn", a = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
176
- switch (t) {
735
+ getRegionURL(e) {
736
+ const r = "api.storyblok.com", i = "api-us.storyblok.com", s = "app.storyblokchina.cn", l = "api-ap.storyblok.com", u = "api-ca.storyblok.com";
737
+ switch (e) {
177
738
  case "us":
178
- return o;
739
+ return i;
179
740
  case "cn":
180
741
  return s;
181
742
  case "ap":
182
- return a;
743
+ return l;
183
744
  case "ca":
184
- return n;
745
+ return u;
185
746
  default:
186
- return e;
747
+ return r;
187
748
  }
188
749
  }
189
750
  }
190
- const U = function(r, t) {
191
- const e = {};
192
- for (const o in r) {
193
- const s = r[o];
194
- t.indexOf(o) > -1 && s !== null && (e[o] = s);
195
- }
196
- return e;
197
- }, D = (r) => r === "email", B = () => ({
751
+ const Jr = function(o, e) {
752
+ const r = {};
753
+ for (const i in o) {
754
+ const s = o[i];
755
+ e.indexOf(i) > -1 && s !== null && (r[i] = s);
756
+ }
757
+ return r;
758
+ }, Kr = (o) => o === "email", Wr = () => ({
198
759
  singleTag: "hr"
199
- }), q = () => ({
760
+ }), Yr = () => ({
200
761
  tag: "blockquote"
201
- }), F = () => ({
762
+ }), Xr = () => ({
202
763
  tag: "ul"
203
- }), J = (r) => ({
764
+ }), Zr = (o) => ({
204
765
  tag: [
205
766
  "pre",
206
767
  {
207
768
  tag: "code",
208
- attrs: r.attrs
769
+ attrs: o.attrs
209
770
  }
210
771
  ]
211
- }), K = () => ({
772
+ }), Qr = () => ({
212
773
  singleTag: "br"
213
- }), V = (r) => ({
214
- tag: `h${r.attrs.level}`
215
- }), H = (r) => ({
774
+ }), Vr = (o) => ({
775
+ tag: `h${o.attrs.level}`
776
+ }), tn = (o) => ({
216
777
  singleTag: [
217
778
  {
218
779
  tag: "img",
219
- attrs: U(r.attrs, ["src", "alt", "title"])
780
+ attrs: Jr(o.attrs, ["src", "alt", "title"])
220
781
  }
221
782
  ]
222
- }), G = () => ({
783
+ }), en = () => ({
223
784
  tag: "li"
224
- }), W = () => ({
785
+ }), rn = () => ({
225
786
  tag: "ol"
226
- }), Y = () => ({
787
+ }), nn = () => ({
227
788
  tag: "p"
228
- }), Q = (r) => ({
789
+ }), on = (o) => ({
229
790
  tag: [
230
791
  {
231
792
  tag: "span",
232
793
  attrs: {
233
794
  "data-type": "emoji",
234
- "data-name": r.attrs.name,
235
- emoji: r.attrs.emoji
795
+ "data-name": o.attrs.name,
796
+ emoji: o.attrs.emoji
236
797
  }
237
798
  }
238
799
  ]
239
- }), X = () => ({
800
+ }), an = () => ({
240
801
  tag: "b"
241
- }), Z = () => ({
802
+ }), sn = () => ({
242
803
  tag: "s"
243
- }), ee = () => ({
804
+ }), ln = () => ({
244
805
  tag: "u"
245
- }), te = () => ({
806
+ }), cn = () => ({
246
807
  tag: "strong"
247
- }), re = () => ({
808
+ }), un = () => ({
248
809
  tag: "code"
249
- }), oe = () => ({
810
+ }), fn = () => ({
250
811
  tag: "i"
251
- }), se = (r) => {
252
- if (!r.attrs)
812
+ }), pn = (o) => {
813
+ if (!o.attrs)
253
814
  return {
254
815
  tag: ""
255
816
  };
256
- const t = new z().escapeHTML, e = { ...r.attrs }, { linktype: o = "url" } = r.attrs;
257
- if (delete e.linktype, e.href && (e.href = t(r.attrs.href || "")), D(o) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
258
- for (const s in e.custom)
259
- e[s] = e.custom[s];
260
- delete e.custom;
817
+ const e = new Gr().escapeHTML, r = { ...o.attrs }, { linktype: i = "url" } = o.attrs;
818
+ if (delete r.linktype, r.href && (r.href = e(o.attrs.href || "")), Kr(i) && (r.href = `mailto:${r.href}`), r.anchor && (r.href = `${r.href}#${r.anchor}`, delete r.anchor), r.custom) {
819
+ for (const s in r.custom)
820
+ r[s] = r.custom[s];
821
+ delete r.custom;
261
822
  }
262
823
  return {
263
824
  tag: [
264
825
  {
265
826
  tag: "a",
266
- attrs: e
827
+ attrs: r
267
828
  }
268
829
  ]
269
830
  };
270
- }, ae = (r) => ({
831
+ }, dn = (o) => ({
271
832
  tag: [
272
833
  {
273
834
  tag: "span",
274
- attrs: r.attrs
835
+ attrs: o.attrs
275
836
  }
276
837
  ]
277
- }), ne = () => ({
838
+ }), gn = () => ({
278
839
  tag: "sub"
279
- }), le = () => ({
840
+ }), hn = () => ({
280
841
  tag: "sup"
281
- }), ie = (r) => ({
842
+ }), yn = (o) => ({
282
843
  tag: [
283
844
  {
284
845
  tag: "span",
285
- attrs: r.attrs
846
+ attrs: o.attrs
286
847
  }
287
848
  ]
288
- }), ce = (r) => {
289
- var t;
290
- return (t = r.attrs) != null && t.color ? {
849
+ }), bn = (o) => {
850
+ var e;
851
+ return (e = o.attrs) != null && e.color ? {
291
852
  tag: [
292
853
  {
293
854
  tag: "span",
294
855
  attrs: {
295
- style: `background-color:${r.attrs.color};`
856
+ style: `background-color:${o.attrs.color};`
296
857
  }
297
858
  }
298
859
  ]
299
860
  } : {
300
861
  tag: ""
301
862
  };
302
- }, ge = (r) => {
303
- var t;
304
- return (t = r.attrs) != null && t.color ? {
863
+ }, mn = (o) => {
864
+ var e;
865
+ return (e = o.attrs) != null && e.color ? {
305
866
  tag: [
306
867
  {
307
868
  tag: "span",
308
869
  attrs: {
309
- style: `color:${r.attrs.color}`
870
+ style: `color:${o.attrs.color}`
310
871
  }
311
872
  }
312
873
  ]
313
874
  } : {
314
875
  tag: ""
315
876
  };
316
- }, ue = {
877
+ }, _n = {
317
878
  nodes: {
318
- horizontal_rule: B,
319
- blockquote: q,
320
- bullet_list: F,
321
- code_block: J,
322
- hard_break: K,
323
- heading: V,
324
- image: H,
325
- list_item: G,
326
- ordered_list: W,
327
- paragraph: Y,
328
- emoji: Q
879
+ horizontal_rule: Wr,
880
+ blockquote: Yr,
881
+ bullet_list: Xr,
882
+ code_block: Zr,
883
+ hard_break: Qr,
884
+ heading: Vr,
885
+ image: tn,
886
+ list_item: en,
887
+ ordered_list: rn,
888
+ paragraph: nn,
889
+ emoji: on
329
890
  },
330
891
  marks: {
331
- bold: X,
332
- strike: Z,
333
- underline: ee,
334
- strong: te,
335
- code: re,
336
- italic: oe,
337
- link: se,
338
- styled: ae,
339
- subscript: ne,
340
- superscript: le,
341
- anchor: ie,
342
- highlight: ce,
343
- textStyle: ge
344
- }
345
- }, pe = function(r) {
346
- const t = {
892
+ bold: an,
893
+ strike: sn,
894
+ underline: ln,
895
+ strong: cn,
896
+ code: un,
897
+ italic: fn,
898
+ link: pn,
899
+ styled: dn,
900
+ subscript: gn,
901
+ superscript: hn,
902
+ anchor: yn,
903
+ highlight: bn,
904
+ textStyle: mn
905
+ }
906
+ }, vn = function(o) {
907
+ const e = {
347
908
  "&": "&amp;",
348
909
  "<": "&lt;",
349
910
  ">": "&gt;",
350
911
  '"': "&quot;",
351
912
  "'": "&#39;"
352
- }, e = /[&<>"']/g, o = RegExp(e.source);
353
- return r && o.test(r) ? r.replace(e, (s) => t[s]) : r;
913
+ }, r = /[&<>"']/g, i = RegExp(r.source);
914
+ return o && i.test(o) ? o.replace(r, (s) => e[s]) : o;
354
915
  };
355
- class fe {
356
- constructor(t) {
357
- p(this, "marks"), p(this, "nodes"), t || (t = ue), this.marks = t.marks || [], this.nodes = t.nodes || [];
358
- }
359
- addNode(t, e) {
360
- this.nodes[t] = e;
361
- }
362
- addMark(t, e) {
363
- this.marks[t] = e;
364
- }
365
- render(t, e = { optimizeImages: !1 }) {
366
- if (t && t.content && Array.isArray(t.content)) {
367
- let o = "";
368
- return t.content.forEach((s) => {
369
- o += this.renderNode(s);
370
- }), e.optimizeImages ? this.optimizeImages(o, e.optimizeImages) : o;
916
+ class Tn {
917
+ constructor(e) {
918
+ O(this, "marks"), O(this, "nodes"), e || (e = _n), this.marks = e.marks || [], this.nodes = e.nodes || [];
919
+ }
920
+ addNode(e, r) {
921
+ this.nodes[e] = r;
922
+ }
923
+ addMark(e, r) {
924
+ this.marks[e] = r;
925
+ }
926
+ render(e, r = { optimizeImages: !1 }) {
927
+ if (e && e.content && Array.isArray(e.content)) {
928
+ let i = "";
929
+ return e.content.forEach((s) => {
930
+ i += this.renderNode(s);
931
+ }), r.optimizeImages ? this.optimizeImages(i, r.optimizeImages) : i;
371
932
  }
372
933
  return console.warn(
373
934
  `The render method must receive an Object with a "content" field.
@@ -396,222 +957,265 @@ class fe {
396
957
  }`
397
958
  ), "";
398
959
  }
399
- optimizeImages(t, e) {
400
- let o = 0, s = 0, a = "", n = "";
401
- typeof e != "boolean" && (typeof e.width == "number" && e.width > 0 && (a += `width="${e.width}" `, o = e.width), typeof e.height == "number" && e.height > 0 && (a += `height="${e.height}" `, s = e.height), (e.loading === "lazy" || e.loading === "eager") && (a += `loading="${e.loading}" `), typeof e.class == "string" && e.class.length > 0 && (a += `class="${e.class}" `), e.filters && (typeof e.filters.blur == "number" && e.filters.blur >= 0 && e.filters.blur <= 100 && (n += `:blur(${e.filters.blur})`), typeof e.filters.brightness == "number" && e.filters.brightness >= -100 && e.filters.brightness <= 100 && (n += `:brightness(${e.filters.brightness})`), e.filters.fill && (e.filters.fill.match(/[0-9A-Fa-f]{6}/g) || e.filters.fill === "transparent") && (n += `:fill(${e.filters.fill})`), e.filters.format && ["webp", "png", "jpeg"].includes(e.filters.format) && (n += `:format(${e.filters.format})`), typeof e.filters.grayscale == "boolean" && e.filters.grayscale && (n += ":grayscale()"), typeof e.filters.quality == "number" && e.filters.quality >= 0 && e.filters.quality <= 100 && (n += `:quality(${e.filters.quality})`), e.filters.rotate && [90, 180, 270].includes(e.filters.rotate) && (n += `:rotate(${e.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), a.length > 0 && (t = t.replace(/<img/g, `<img ${a.trim()}`));
402
- const c = o > 0 || s > 0 || n.length > 0 ? `${o}x${s}${n}` : "";
403
- return t = t.replace(
960
+ optimizeImages(e, r) {
961
+ let i = 0, s = 0, l = "", u = "";
962
+ typeof r != "boolean" && (typeof r.width == "number" && r.width > 0 && (l += `width="${r.width}" `, i = r.width), typeof r.height == "number" && r.height > 0 && (l += `height="${r.height}" `, s = r.height), (r.loading === "lazy" || r.loading === "eager") && (l += `loading="${r.loading}" `), typeof r.class == "string" && r.class.length > 0 && (l += `class="${r.class}" `), r.filters && (typeof r.filters.blur == "number" && r.filters.blur >= 0 && r.filters.blur <= 100 && (u += `:blur(${r.filters.blur})`), typeof r.filters.brightness == "number" && r.filters.brightness >= -100 && r.filters.brightness <= 100 && (u += `:brightness(${r.filters.brightness})`), r.filters.fill && (r.filters.fill.match(/[0-9A-Fa-f]{6}/g) || r.filters.fill === "transparent") && (u += `:fill(${r.filters.fill})`), r.filters.format && ["webp", "png", "jpeg"].includes(r.filters.format) && (u += `:format(${r.filters.format})`), typeof r.filters.grayscale == "boolean" && r.filters.grayscale && (u += ":grayscale()"), typeof r.filters.quality == "number" && r.filters.quality >= 0 && r.filters.quality <= 100 && (u += `:quality(${r.filters.quality})`), r.filters.rotate && [90, 180, 270].includes(r.filters.rotate) && (u += `:rotate(${r.filters.rotate})`), u.length > 0 && (u = "/filters" + u))), l.length > 0 && (e = e.replace(/<img/g, `<img ${l.trim()}`));
963
+ const b = i > 0 || s > 0 || u.length > 0 ? `${i}x${s}${u}` : "";
964
+ return e = e.replace(
404
965
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
405
- `a.storyblok.com/f/$1/$2.$3/m/${c}`
406
- ), typeof e != "boolean" && (e.sizes || e.srcset) && (t = t.replace(/<img.*?src=["|'](.*?)["|']/g, (l) => {
407
- var i, g;
408
- const f = l.match(
966
+ `a.storyblok.com/f/$1/$2.$3/m/${b}`
967
+ ), typeof r != "boolean" && (r.sizes || r.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (d) => {
968
+ var h, v;
969
+ const w = d.match(
409
970
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
410
971
  );
411
- if (f && f.length > 0) {
412
- const d = {
413
- srcset: (i = e.srcset) == null ? void 0 : i.map((u) => {
414
- if (typeof u == "number")
415
- return `//${f}/m/${u}x0${n} ${u}w`;
416
- if (typeof u == "object" && u.length === 2) {
417
- let b = 0, y = 0;
418
- return typeof u[0] == "number" && (b = u[0]), typeof u[1] == "number" && (y = u[1]), `//${f}/m/${b}x${y}${n} ${b}w`;
972
+ if (w && w.length > 0) {
973
+ const T = {
974
+ srcset: (h = r.srcset) == null ? void 0 : h.map((A) => {
975
+ if (typeof A == "number")
976
+ return `//${w}/m/${A}x0${u} ${A}w`;
977
+ if (typeof A == "object" && A.length === 2) {
978
+ let P = 0, B = 0;
979
+ return typeof A[0] == "number" && (P = A[0]), typeof A[1] == "number" && (B = A[1]), `//${w}/m/${P}x${B}${u} ${P}w`;
419
980
  }
420
981
  }).join(", "),
421
- sizes: (g = e.sizes) == null ? void 0 : g.map((u) => u).join(", ")
982
+ sizes: (v = r.sizes) == null ? void 0 : v.map((A) => A).join(", ")
422
983
  };
423
- let h = "";
424
- return d.srcset && (h += `srcset="${d.srcset}" `), d.sizes && (h += `sizes="${d.sizes}" `), l.replace(/<img/g, `<img ${h.trim()}`);
984
+ let E = "";
985
+ return T.srcset && (E += `srcset="${T.srcset}" `), T.sizes && (E += `sizes="${T.sizes}" `), d.replace(/<img/g, `<img ${E.trim()}`);
425
986
  }
426
- return l;
427
- })), t;
428
- }
429
- renderNode(t) {
430
- const e = [];
431
- t.marks && t.marks.forEach((s) => {
432
- const a = this.getMatchingMark(s);
433
- a && a.tag !== "" && e.push(this.renderOpeningTag(a.tag));
987
+ return d;
988
+ })), e;
989
+ }
990
+ renderNode(e) {
991
+ const r = [];
992
+ e.marks && e.marks.forEach((s) => {
993
+ const l = this.getMatchingMark(s);
994
+ l && l.tag !== "" && r.push(this.renderOpeningTag(l.tag));
434
995
  });
435
- const o = this.getMatchingNode(t);
436
- return o && o.tag && e.push(this.renderOpeningTag(o.tag)), t.content ? t.content.forEach((s) => {
437
- e.push(this.renderNode(s));
438
- }) : t.text ? e.push(pe(t.text)) : o && o.singleTag ? e.push(this.renderTag(o.singleTag, " /")) : o && o.html ? e.push(o.html) : t.type === "emoji" && e.push(this.renderEmoji(t)), o && o.tag && e.push(this.renderClosingTag(o.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
439
- const a = this.getMatchingMark(s);
440
- a && a.tag !== "" && e.push(this.renderClosingTag(a.tag));
441
- }), e.join("");
442
- }
443
- renderTag(t, e) {
444
- return t.constructor === String ? `<${t}${e}>` : t.map((o) => {
445
- if (o.constructor === String)
446
- return `<${o}${e}>`;
996
+ const i = this.getMatchingNode(e);
997
+ return i && i.tag && r.push(this.renderOpeningTag(i.tag)), e.content ? e.content.forEach((s) => {
998
+ r.push(this.renderNode(s));
999
+ }) : e.text ? r.push(vn(e.text)) : i && i.singleTag ? r.push(this.renderTag(i.singleTag, " /")) : i && i.html ? r.push(i.html) : e.type === "emoji" && r.push(this.renderEmoji(e)), i && i.tag && r.push(this.renderClosingTag(i.tag)), e.marks && e.marks.slice(0).reverse().forEach((s) => {
1000
+ const l = this.getMatchingMark(s);
1001
+ l && l.tag !== "" && r.push(this.renderClosingTag(l.tag));
1002
+ }), r.join("");
1003
+ }
1004
+ renderTag(e, r) {
1005
+ return e.constructor === String ? `<${e}${r}>` : e.map((i) => {
1006
+ if (i.constructor === String)
1007
+ return `<${i}${r}>`;
447
1008
  {
448
- let s = `<${o.tag}`;
449
- if (o.attrs)
450
- for (const a in o.attrs) {
451
- const n = o.attrs[a];
452
- n !== null && (s += ` ${a}="${n}"`);
1009
+ let s = `<${i.tag}`;
1010
+ if (i.attrs)
1011
+ for (const l in i.attrs) {
1012
+ const u = i.attrs[l];
1013
+ u !== null && (s += ` ${l}="${u}"`);
453
1014
  }
454
- return `${s}${e}>`;
1015
+ return `${s}${r}>`;
455
1016
  }
456
1017
  }).join("");
457
1018
  }
458
- renderOpeningTag(t) {
459
- return this.renderTag(t, "");
1019
+ renderOpeningTag(e) {
1020
+ return this.renderTag(e, "");
460
1021
  }
461
- renderClosingTag(t) {
462
- return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
1022
+ renderClosingTag(e) {
1023
+ return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
463
1024
  }
464
- getMatchingNode(t) {
465
- const e = this.nodes[t.type];
466
- if (typeof e == "function")
467
- return e(t);
1025
+ getMatchingNode(e) {
1026
+ const r = this.nodes[e.type];
1027
+ if (typeof r == "function")
1028
+ return r(e);
468
1029
  }
469
- getMatchingMark(t) {
470
- const e = this.marks[t.type];
471
- if (typeof e == "function")
472
- return e(t);
1030
+ getMatchingMark(e) {
1031
+ const r = this.marks[e.type];
1032
+ if (typeof r == "function")
1033
+ return r(e);
473
1034
  }
474
- renderEmoji(t) {
475
- if (t.attrs.emoji)
476
- return t.attrs.emoji;
477
- const e = [
1035
+ renderEmoji(e) {
1036
+ if (e.attrs.emoji)
1037
+ return e.attrs.emoji;
1038
+ const r = [
478
1039
  {
479
1040
  tag: "img",
480
1041
  attrs: {
481
- src: t.attrs.fallbackImage,
1042
+ src: e.attrs.fallbackImage,
482
1043
  draggable: "false",
483
1044
  loading: "lazy",
484
1045
  align: "absmiddle"
485
1046
  }
486
1047
  }
487
1048
  ];
488
- return this.renderTag(e, " /");
1049
+ return this.renderTag(r, " /");
489
1050
  }
490
1051
  }
491
- const ke = (r) => {
492
- if (typeof r != "object" || typeof r._editable > "u")
1052
+ const jn = (o) => {
1053
+ if (typeof o != "object" || typeof o._editable > "u")
493
1054
  return {};
494
1055
  try {
495
- const t = JSON.parse(
496
- r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
1056
+ const e = JSON.parse(
1057
+ o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
497
1058
  );
498
- return t ? {
499
- "data-blok-c": JSON.stringify(t),
500
- "data-blok-uid": t.id + "-" + t.uid
1059
+ return e ? {
1060
+ "data-blok-c": JSON.stringify(e),
1061
+ "data-blok-uid": e.id + "-" + e.uid
501
1062
  } : {};
502
1063
  } catch {
503
1064
  return {};
504
1065
  }
505
1066
  };
506
- let de, he = "https://app.storyblok.com/f/storyblok-v2-latest.js";
507
- const be = (r, t) => {
508
- r.addNode("blok", (e) => {
509
- let o = "";
510
- return e.attrs.body.forEach((s) => {
511
- o += t(s.component, s);
1067
+ let wn, An = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1068
+ const In = (o, e) => {
1069
+ o.addNode("blok", (r) => {
1070
+ let i = "";
1071
+ return r.attrs.body.forEach((s) => {
1072
+ i += e(s.component, s);
512
1073
  }), {
513
- html: o
1074
+ html: i
514
1075
  };
515
1076
  });
516
- }, me = (r) => !r || !(r != null && r.content.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule")), ye = (r, t, e) => {
517
- let o = e || de;
518
- if (!o) {
1077
+ }, kn = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), On = (o, e, r) => {
1078
+ let i = r || wn;
1079
+ if (!i) {
519
1080
  console.error(
520
1081
  "Please initialize the Storyblok SDK before calling the renderRichText function"
521
1082
  );
522
1083
  return;
523
1084
  }
524
- return me(r) ? "" : (t && (o = new fe(t.schema), t.resolver && be(o, t.resolver)), o.render(r));
525
- }, $e = () => M(he);
526
- function ve() {
1085
+ return kn(o) ? "" : (e && (i = new Tn(e.schema), e.resolver && In(i, e.resolver)), i.render(o));
1086
+ }, $n = () => Br(An);
1087
+ async function xn(o) {
1088
+ var i;
1089
+ const { action: e, story: r } = o || {};
1090
+ if (e === "input" && r) {
1091
+ const s = document.body, l = await Cn(r);
1092
+ if (l.outerHTML === s.outerHTML)
1093
+ return;
1094
+ const u = document.querySelector('[data-blok-focused="true"]');
1095
+ Sn(s, l, u);
1096
+ } else
1097
+ ["published", "change"].includes((i = o == null ? void 0 : o.data) == null ? void 0 : i.action) && location.reload();
1098
+ }
1099
+ function Sn(o, e, r) {
1100
+ if (r) {
1101
+ const i = r.getAttribute("data-blok-uid"), s = e.querySelector(
1102
+ `[data-blok-uid="${i}"]`
1103
+ );
1104
+ s && (s.setAttribute("data-blok-focused", "true"), console.log("Doing partial replace"), r.replaceWith(s));
1105
+ } else
1106
+ console.log("Doing full replace"), o.replaceWith(e);
1107
+ }
1108
+ async function Cn(o) {
1109
+ const r = await (await fetch(location.href, {
1110
+ method: "POST",
1111
+ body: JSON.stringify({
1112
+ ...o,
1113
+ is_storyblok_preview: !0
1114
+ }),
1115
+ headers: {
1116
+ "Content-Type": "application/json"
1117
+ }
1118
+ })).text();
1119
+ return new DOMParser().parseFromString(r, "text/html").body;
1120
+ }
1121
+ function En() {
527
1122
  return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
528
1123
  }
529
- function Ie(r, t) {
530
- const e = globalThis.storyblokApiInstance.richTextResolver;
531
- if (!e) {
1124
+ async function Rn(o, e = {}, r = {}, i) {
1125
+ globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly");
1126
+ let s = null;
1127
+ if (i && i.locals._storyblok_preview_data)
1128
+ s = i.locals._storyblok_preview_data;
1129
+ else {
1130
+ const { data: l } = await globalThis.storyblokApiInstance.get(
1131
+ o,
1132
+ e,
1133
+ r
1134
+ );
1135
+ s = l.story;
1136
+ }
1137
+ return s;
1138
+ }
1139
+ function Mn(o, e) {
1140
+ const r = globalThis.storyblokApiInstance.richTextResolver;
1141
+ if (!r) {
532
1142
  console.error(
533
1143
  "Please initialize the Storyblok SDK before calling the renderRichText function"
534
1144
  );
535
1145
  return;
536
1146
  }
537
- return ye(r, t, e);
1147
+ return On(o, e, r);
538
1148
  }
539
- function we(r) {
540
- const t = {
1149
+ function Pn(o) {
1150
+ const e = {
541
1151
  useCustomApi: !1,
542
1152
  bridge: !0,
543
1153
  componentsDir: "src",
544
1154
  enableFallbackComponent: !1,
545
- ...r
1155
+ ...o
546
1156
  };
547
1157
  return {
548
1158
  name: "@storyblok/astro",
549
1159
  hooks: {
550
1160
  "astro:config:setup": ({
551
- injectScript: e,
552
- updateConfig: o,
553
- addDevToolbarApp: s
1161
+ injectScript: r,
1162
+ updateConfig: i,
1163
+ addDevToolbarApp: s,
1164
+ addMiddleware: l
554
1165
  }) => {
555
- if (o({
1166
+ i({
556
1167
  vite: {
557
1168
  plugins: [
558
- E(
559
- t.accessToken,
560
- t.useCustomApi,
561
- t.apiOptions
1169
+ Or(
1170
+ e.accessToken,
1171
+ e.useCustomApi,
1172
+ e.apiOptions
562
1173
  ),
563
- N(
564
- t.componentsDir,
565
- t.components,
566
- t.enableFallbackComponent,
567
- t.customFallbackComponent
1174
+ Rr(
1175
+ e.componentsDir,
1176
+ e.components,
1177
+ e.enableFallbackComponent,
1178
+ e.customFallbackComponent
568
1179
  ),
569
- L(t)
1180
+ Mr(e),
1181
+ Dr()
570
1182
  ]
571
1183
  }
572
- }), e(
1184
+ }), r(
573
1185
  "page-ssr",
574
1186
  `
575
1187
  import { storyblokApiInstance } from "virtual:storyblok-init";
576
1188
  globalThis.storyblokApiInstance = storyblokApiInstance;
577
1189
  `
578
- ), t.bridge) {
579
- let a = "";
580
- if (typeof t.bridge == "object") {
581
- const n = { ...t.bridge };
582
- a = `const storyblokInstance = new StoryblokBridge(${JSON.stringify(
583
- n
584
- )});`;
585
- } else
586
- a = "const storyblokInstance = new StoryblokBridge()";
587
- e(
588
- "page",
589
- `
590
- import { loadStoryblokBridge } from "@storyblok/astro";
1190
+ ), e.bridge && (r(
1191
+ "page",
1192
+ `
1193
+ import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
1194
+ import { bridgeOptions } from "virtual:storyblok-bridge";
591
1195
  loadStoryblokBridge().then(() => {
592
1196
  const { StoryblokBridge, location } = window;
593
- ${a}
594
-
595
- storyblokInstance.on(["published", "change"], (event) => {
596
- if (!event.slugChanged) {
597
- location.reload(true);
598
- }
599
- });
1197
+ if(bridgeOptions){
1198
+ const storyblokInstance = new StoryblokBridge(bridgeOptions);
1199
+ storyblokInstance.on(["published", "change","input"], handleStoryblokMessage);
1200
+ };
600
1201
  });
601
1202
  `
602
- );
603
- }
604
- s("@storyblok/astro/toolbarApp.ts");
1203
+ ), l({
1204
+ entrypoint: "@storyblok/astro/middleware.ts",
1205
+ order: "pre"
1206
+ })), s("@storyblok/astro/toolbarApp.ts");
605
1207
  }
606
1208
  }
607
1209
  };
608
1210
  }
609
1211
  export {
610
- fe as RichTextResolver,
611
- ue as RichTextSchema,
612
- we as default,
613
- $e as loadStoryblokBridge,
614
- Ie as renderRichText,
615
- ke as storyblokEditable,
616
- ve as useStoryblokApi
1212
+ Tn as RichTextResolver,
1213
+ _n as RichTextSchema,
1214
+ Pn as default,
1215
+ xn as handleStoryblokMessage,
1216
+ $n as loadStoryblokBridge,
1217
+ Mn as renderRichText,
1218
+ jn as storyblokEditable,
1219
+ Rn as useStoryblok,
1220
+ En as useStoryblokApi
617
1221
  };