@storyblok/astro 4.0.5 → 4.1.0-next.2

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 Sr(o, e, r) {
2
+ const s = "virtual:storyblok-init", i = "\0" + s;
3
3
  return {
4
4
  name: "vite-plugin-storyblok-init",
5
- async resolveId(a) {
6
- if (a === o)
7
- return s;
5
+ async resolveId(l) {
6
+ if (l === s)
7
+ return i;
8
8
  },
9
- async load(a) {
10
- if (a === s)
9
+ async load(l) {
10
+ if (l === i)
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 Cr = /[\p{Lu}]/u, $r = /[\p{Ll}]/u, zt = /^[\p{Lu}](?![\p{Lu}])/gu, Gt = /([\p{Alpha}\p{N}_]|$)/u, ft = /[_.\- ]+/, jr = new RegExp("^" + ft.source), Lt = new RegExp(ft.source + Gt.source, "gu"), Dt = new RegExp("\\d+" + Gt.source, "gu"), xr = (o, e, r, s) => {
24
+ let i = !1, l = !1, u = !1, h = !1;
25
+ for (let d = 0; d < o.length; d++) {
26
+ const g = o[d];
27
+ h = d > 2 ? o[d - 3] === "-" : !0, i && Cr.test(g) ? (o = o.slice(0, d) + "-" + o.slice(d), i = !1, u = l, l = !0, d++) : l && u && $r.test(g) && (!h || s) ? (o = o.slice(0, d - 1) + "-" + o.slice(d - 1), u = l, l = !1, i = !0) : (i = e(g) === g && r(g) !== g, u = l, l = r(g) === g && e(g) !== g);
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
+ }, Er = (o, e) => (zt.lastIndex = 0, o.replaceAll(zt, (r) => e(r))), Rr = (o, e) => (Lt.lastIndex = 0, Dt.lastIndex = 0, o.replaceAll(Dt, (r, s, i) => ["_", "-"].includes(o.charAt(i + r.length)) ? r : e(r)).replaceAll(Lt, (r, s) => e(s)));
31
+ function Ut(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), s = e.locale === !1 ? (l) => l.toUpperCase() : (l) => l.toLocaleUpperCase(e.locale);
41
+ return o.length === 1 ? ft.test(o) ? "" : e.pascalCase ? s(o) : r(o) : (o !== r(o) && (o = xr(o, r, s, e.preserveConsecutiveUppercase)), o = o.replace(jr, ""), o = e.preserveConsecutiveUppercase ? Er(o, r) : r(o), e.pascalCase && (o = s(o.charAt(0)) + o.slice(1)), Rr(o, s));
42
42
  }
43
- function N(r, t, e, o) {
44
- const s = "virtual:storyblok-components", a = "\0" + s;
43
+ function Mr(o, e, r, s) {
44
+ const i = "virtual:storyblok-components", l = "\0" + i;
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 === i)
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 h = [], d = [];
54
+ for await (const [v, T] of Object.entries(e)) {
55
+ const w = await this.resolve(
56
+ "/" + o + "/" + T + ".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 (w)
59
+ h.push(`import ${Ut(v)} from "${w.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 + "/" + T}.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 g = "";
68
+ if (r)
69
+ if (g = ",FallbackComponent", s) {
70
+ const v = await this.resolve(
71
+ "/" + o + "/" + s + ".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 + "/" + s}.astro" exist?`
76
76
  );
77
- c.push(
78
- `import FallbackComponent from "${g.id}"`
77
+ h.push(
78
+ `import FallbackComponent from "${v.id}"`
79
79
  );
80
80
  } else
81
- c.push(
81
+ h.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 `${h.join(";")};export default {${Object.keys(e).filter((v) => !d.includes(v)).map((v) => Ut(v)).join(",")}${g}}`;
86
+ if (r)
87
+ return `${h[0]}; export default {${g.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 Pr(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(s) {
102
+ if (s === e)
103
+ return r;
104
+ },
105
+ async load(s) {
106
+ if (s === 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 Nr(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, s = "__lodash_hash_undefined__", i = 800, l = 16, u = 9007199254740991, h = "[object Arguments]", d = "[object Array]", g = "[object AsyncFunction]", v = "[object Boolean]", T = "[object Date]", w = "[object Error]", E = "[object Function]", A = "[object GeneratorFunction]", P = "[object Map]", B = "[object Number]", Jt = "[object Null]", pt = "[object Object]", Kt = "[object Proxy]", Wt = "[object RegExp]", Yt = "[object Set]", Xt = "[object String]", Zt = "[object Undefined]", Qt = "[object WeakMap]", Vt = "[object ArrayBuffer]", te = "[object DataView]", ee = "[object Float32Array]", re = "[object Float64Array]", ne = "[object Int8Array]", oe = "[object Int16Array]", ae = "[object Int32Array]", se = "[object Uint8Array]", ie = "[object Uint8ClampedArray]", le = "[object Uint16Array]", ce = "[object Uint32Array]", ue = /[\\^$.*+?()[\]{}|]/g, fe = /^\[object .+?Constructor\]$/, pe = /^(?:0|[1-9]\d*)$/, b = {};
119
+ b[ee] = b[re] = b[ne] = b[oe] = b[ae] = b[se] = b[ie] = b[le] = b[ce] = !0, b[h] = b[d] = b[Vt] = b[v] = b[te] = b[T] = b[w] = b[E] = b[P] = b[B] = b[pt] = b[Wt] = b[Yt] = b[Xt] = b[Qt] = !1;
120
+ var dt = typeof Z == "object" && Z && Z.Object === Object && Z, de = typeof self == "object" && self && self.Object === Object && self, N = dt || de || 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 ge(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 he(t, n) {
141
+ for (var a = -1, c = Array(t); ++a < t; )
142
+ c[a] = n(a);
143
+ return c;
144
+ }
145
+ function ye(t) {
146
+ return function(n) {
147
+ return t(n);
148
+ };
149
+ }
150
+ function be(t, n) {
151
+ return t == null ? void 0 : t[n];
152
+ }
153
+ function me(t, n) {
154
+ return function(a) {
155
+ return t(n(a));
156
+ };
157
+ }
158
+ var _e = Array.prototype, ve = Function.prototype, H = Object.prototype, tt = N["__core-js_shared__"], q = ve.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, Te = q.call(Object), we = RegExp(
162
+ "^" + q.call(S).replace(ue, "\\$&").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 = me(Object.getPrototypeOf, Object), It = Object.create, Ae = H.propertyIsEnumerable, Ie = _e.splice, $ = vt ? vt.toStringTag : void 0, J = function() {
164
+ try {
165
+ var t = nt(Object, "defineProperty");
166
+ return t({}, "", {}), t;
167
+ } catch {
168
+ }
169
+ }(), ke = G ? G.isBuffer : void 0, kt = Math.max, Oe = Date.now, Ot = nt(N, "Map"), L = nt(Object, "create"), Se = /* @__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 j(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 Ce() {
190
+ this.__data__ = L ? L(null) : {}, this.size = 0;
191
+ }
192
+ function $e(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 === s ? void 0 : a;
201
+ }
202
+ return S.call(n, t) ? n[t] : void 0;
203
+ }
204
+ function xe(t) {
205
+ var n = this.__data__;
206
+ return L ? n[t] !== void 0 : S.call(n, t);
207
+ }
208
+ function Ee(t, n) {
209
+ var a = this.__data__;
210
+ return this.size += this.has(t) ? 0 : 1, a[t] = L && n === void 0 ? s : n, this;
211
+ }
212
+ j.prototype.clear = Ce, j.prototype.delete = $e, j.prototype.get = je, j.prototype.has = xe, j.prototype.set = Ee;
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 Re() {
221
+ this.__data__ = [], this.size = 0;
222
+ }
223
+ function Me(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() : Ie.call(n, a, 1), --this.size, !0;
229
+ }
230
+ function Pe(t) {
231
+ var n = this.__data__, a = K(n, t);
232
+ return a < 0 ? void 0 : n[a][1];
233
+ }
234
+ function Ne(t) {
235
+ return K(this.__data__, t) > -1;
236
+ }
237
+ function ze(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 = Re, C.prototype.delete = Me, C.prototype.get = Pe, C.prototype.has = Ne, C.prototype.set = ze;
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 Le() {
250
+ this.size = 0, this.__data__ = {
251
+ hash: new j(),
252
+ map: new (Ot || C)(),
253
+ string: new j()
254
+ };
255
+ }
256
+ function De(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 Fe(t) {
264
+ return Y(this, t).has(t);
265
+ }
266
+ function Be(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 = Le, R.prototype.delete = De, R.prototype.get = Ue, R.prototype.has = Fe, R.prototype.set = Be;
271
+ function M(t) {
272
+ var n = this.__data__ = new C(t);
273
+ this.size = n.size;
274
+ }
275
+ function He() {
276
+ this.__data__ = new C(), this.size = 0;
277
+ }
278
+ function qe(t) {
279
+ var n = this.__data__, a = n.delete(t);
280
+ return this.size = n.size, a;
281
+ }
282
+ function Ge(t) {
283
+ return this.__data__.get(t);
284
+ }
285
+ function Je(t) {
286
+ return this.__data__.has(t);
287
+ }
288
+ function Ke(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 = He, M.prototype.delete = qe, M.prototype.get = Ge, M.prototype.has = Je, M.prototype.set = Ke;
299
+ function We(t, n) {
300
+ var a = st(t), c = !a && at(t), p = !a && !c && xt(t), y = !a && !c && !p && Rt(t), m = a || c || p || y, f = m ? he(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
+ y && (k == "buffer" || k == "byteLength" || k == "byteOffset") || // Skip index properties.
306
+ $t(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 Ye(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 Xe = cr();
331
+ function W(t) {
332
+ return t == null ? t === void 0 ? Zt : Jt : $ && $ in Object(t) ? ur(t) : yr(t);
333
+ }
334
+ function St(t) {
335
+ return D(t) && W(t) == h;
336
+ }
337
+ function Ze(t) {
338
+ if (!x(t) || gr(t))
339
+ return !1;
340
+ var n = lt(t) ? we : fe;
341
+ return n.test(vr(t));
342
+ }
343
+ function Qe(t) {
344
+ return D(t) && Et(t.length) && !!b[W(t)];
345
+ }
346
+ function Ve(t) {
347
+ if (!x(t))
348
+ return hr(t);
349
+ var n = jt(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 && Xe(n, function(y, m) {
356
+ if (p || (p = new M()), x(y))
357
+ tr(t, n, m, a, Ct, c, p);
358
+ else {
359
+ var f = c ? c(ot(t, m), y, m + "", t, n, p) : void 0;
360
+ f === void 0 && (f = y), et(t, m, f);
361
+ }
362
+ }, Mt);
363
+ }
364
+ function tr(t, n, a, c, p, y, 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 = y ? y(f, _, a + "", t, n, m) : void 0, U = I === void 0;
371
+ if (U) {
372
+ var ct = st(_), ut = !ct && xt(_), Nt = !ct && !ut && Rt(_);
373
+ I = _, ct || ut || Nt ? st(f) ? I = f : Tr(f) ? I = sr(f) : ut ? (U = !1, I = nr(_, !0)) : Nt ? (U = !1, I = ar(_, !0)) : I = [] : wr(_) || at(_) ? (I = f, at(f) ? I = Ar(f) : (!x(f) || lt(f)) && (I = fr(_))) : U = !1;
374
+ }
375
+ U && (m.set(_, I), p(I, _, c, y, m), m.delete(_)), et(t, a, I);
376
+ }
377
+ function er(t, n) {
378
+ return mr(br(t, n, Pt), t + "");
379
+ }
380
+ var rr = J ? function(t, n) {
381
+ return J(t, "toString", {
382
+ configurable: !0,
383
+ enumerable: !1,
384
+ value: kr(n),
385
+ writable: !0
386
+ });
387
+ } : Pt;
388
+ function nr(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 or(t) {
395
+ var n = new t.constructor(t.byteLength);
396
+ return new Tt(n).set(new Tt(t)), n;
397
+ }
398
+ function ar(t, n) {
399
+ var a = n ? or(t.buffer) : t.buffer;
400
+ return new t.constructor(a, t.byteOffset, t.length);
401
+ }
402
+ function sr(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 y = -1, m = n.length; ++y < m; ) {
412
+ var f = n[y], _ = c ? c(a[f], t[f], f, a, t) : void 0;
413
+ _ === void 0 && (_ = t[f]), p ? rt(a, f, _) : Ye(a, f, _);
414
+ }
415
+ return a;
416
+ }
417
+ function lr(t) {
418
+ return er(function(n, a) {
419
+ var c = -1, p = a.length, y = p > 1 ? a[p - 1] : void 0, m = p > 2 ? a[2] : void 0;
420
+ for (y = t.length > 3 && typeof y == "function" ? (p--, y) : void 0, m && pr(a[0], a[1], m) && (y = p < 3 ? void 0 : y, p = 1), n = Object(n); ++c < p; ) {
421
+ var f = a[c];
422
+ f && t(n, f, c, y);
423
+ }
424
+ return n;
425
+ });
426
+ }
427
+ function cr(t) {
428
+ return function(n, a, c) {
429
+ for (var p = -1, y = Object(n), m = c(n), f = m.length; f--; ) {
430
+ var _ = m[t ? f : ++p];
431
+ if (a(y[_], _, y) === !1)
432
+ break;
433
+ }
434
+ return n;
435
+ };
436
+ }
437
+ function Y(t, n) {
438
+ var a = t.__data__;
439
+ return dr(n) ? a[typeof n == "string" ? "string" : "hash"] : a.map;
440
+ }
441
+ function nt(t, n) {
442
+ var a = be(t, n);
443
+ return Ze(a) ? a : void 0;
444
+ }
445
+ function ur(t) {
446
+ var n = S.call(t, $), a = t[$];
447
+ try {
448
+ t[$] = void 0;
449
+ var c = !0;
450
+ } catch {
451
+ }
452
+ var p = _t.call(t);
453
+ return c && (n ? t[$] = a : delete t[$]), p;
454
+ }
455
+ function fr(t) {
456
+ return typeof t.constructor == "function" && !jt(t) ? Se(At(t)) : {};
457
+ }
458
+ function $t(t, n) {
459
+ var a = typeof t;
460
+ return n = n ?? u, !!n && (a == "number" || a != "symbol" && pe.test(t)) && t > -1 && t % 1 == 0 && t < n;
461
+ }
462
+ function pr(t, n, a) {
463
+ if (!x(a))
464
+ return !1;
465
+ var c = typeof n;
466
+ return (c == "number" ? it(a) && $t(n, a.length) : c == "string" && n in a) ? X(a[n], t) : !1;
467
+ }
468
+ function dr(t) {
469
+ var n = typeof t;
470
+ return n == "string" || n == "number" || n == "symbol" || n == "boolean" ? t !== "__proto__" : t === null;
471
+ }
472
+ function gr(t) {
473
+ return !!mt && mt in t;
474
+ }
475
+ function jt(t) {
476
+ var n = t && t.constructor, a = typeof n == "function" && n.prototype || H;
477
+ return t === a;
478
+ }
479
+ function hr(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 yr(t) {
487
+ return _t.call(t);
488
+ }
489
+ function br(t, n, a) {
490
+ return n = kt(n === void 0 ? t.length - 1 : n, 0), function() {
491
+ for (var c = arguments, p = -1, y = kt(c.length - n, 0), m = Array(y); ++p < y; )
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), ge(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 mr = _r(rr);
504
+ function _r(t) {
505
+ var n = 0, a = 0;
506
+ return function() {
507
+ var c = Oe(), p = l - (c - a);
508
+ if (a = c, p > 0) {
509
+ if (++n >= i)
510
+ return arguments[0];
511
+ } else
512
+ n = 0;
513
+ return t.apply(void 0, arguments);
514
+ };
515
+ }
516
+ function vr(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 D(t) && S.call(t, "callee") && !Ae.call(t, "callee");
536
+ }, st = Array.isArray;
537
+ function it(t) {
538
+ return t != null && Et(t.length) && !lt(t);
539
+ }
540
+ function Tr(t) {
541
+ return D(t) && it(t);
542
+ }
543
+ var xt = ke || Or;
544
+ function lt(t) {
545
+ if (!x(t))
546
+ return !1;
547
+ var n = W(t);
548
+ return n == E || n == A || n == g || n == Kt;
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 D(t) {
558
+ return t != null && typeof t == "object";
559
+ }
560
+ function wr(t) {
561
+ if (!D(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) == Te;
568
+ }
569
+ var Rt = bt ? ye(bt) : Qe;
570
+ function Ar(t) {
571
+ return ir(t, Mt(t));
572
+ }
573
+ function Mt(t) {
574
+ return it(t) ? We(t, !0) : Ve(t);
575
+ }
576
+ var Ir = lr(function(t, n, a, c) {
577
+ Ct(t, n, a, c);
578
+ });
579
+ function kr(t) {
580
+ return function() {
581
+ return t;
582
+ };
583
+ }
584
+ function Pt(t) {
585
+ return t;
586
+ }
587
+ function Or() {
588
+ return !1;
589
+ }
590
+ o.exports = Ir;
591
+ })(Q, Q.exports);
592
+ var zr = Q.exports;
593
+ const Lr = /* @__PURE__ */ Nr(zr);
594
+ function Dr(o) {
595
+ let e;
596
+ function r(s, i) {
597
+ var l, u, h, d, g, v, T;
598
+ if ((i == null ? void 0 : i.type) === "AwaitExpression" && ((u = (l = i == null ? void 0 : i.argument) == null ? void 0 : l.callee) == null ? void 0 : u.name) === "useStoryblok") {
599
+ const w = (h = i == null ? void 0 : i.argument) == null ? void 0 : h.arguments;
600
+ ((d = w[1]) == null ? void 0 : d.type) === "ObjectExpression" && (e = {
601
+ ...e,
602
+ apiOptions: Ft((g = w[1]) == null ? void 0 : g.properties)
603
+ }), ((v = w[2]) == null ? void 0 : v.type) === "ObjectExpression" && (e = {
604
+ ...e,
605
+ bridgeOptions: Ft((T = w[2]) == null ? void 0 : T.properties)
606
+ });
607
+ }
608
+ }
609
+ return Lr({}, o, r), e;
610
+ }
611
+ function Ft(o) {
612
+ return o.reduce((e, { key: r, value: s }) => {
613
+ const { type: i } = s;
614
+ return e[r.name] = i === "Literal" ? s.value : i === "ArrayExpression" ? s.elements.map((l) => l.value) : s.value, e;
615
+ }, {});
616
+ }
617
+ function Ur(o) {
618
+ let e = {
619
+ resolveRelations: []
620
+ };
621
+ function r(s) {
622
+ s && (Array.isArray(s) ? e.resolveRelations.push(...s) : e.resolveRelations.push(s));
623
+ }
624
+ for (const s of o)
625
+ if (s.options) {
626
+ const { apiOptions: i, bridgeOptions: l } = s.options;
627
+ if (r(i == null ? void 0 : i.resolve_relations), l) {
628
+ const { resolveRelations: u, ...h } = l;
629
+ r(u), Object.assign(e, h);
630
+ }
631
+ }
632
+ return e.resolveRelations = [...new Set(e.resolveRelations)], e;
633
+ }
634
+ let F = [];
635
+ function Fr() {
636
+ let o = [];
637
+ const e = "virtual:storyblok-bridge", r = "\0" + e;
638
+ let s = null, i = 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 T;
647
+ if (u.includes("node_modules") && !u.includes("/pages/") || !l.includes("useStoryblok") || !((T = this.getModuleInfo(u).meta) != null && T.astro))
648
+ return;
649
+ const [, ...d] = u.split("src/pages/"), g = d.join("/").replace(".astro", ""), v = Dr(this.parse(l));
650
+ F.length && (o = F.filter((w) => w.url !== g)), o.push({
651
+ url: g,
652
+ options: v
653
+ }), s && (i && clearTimeout(i), i = setTimeout(() => {
654
+ Br(F, o) || (F.length !== 0 && (s.restart(), console.info("Updating bridge options...")), F = [...o]);
655
+ }, 1e3));
104
656
  },
105
- async load(o) {
106
- if (o === e)
107
- return `export default ${JSON.stringify(r)}`;
657
+ async load(l) {
658
+ if (l === r)
659
+ return `export const bridgeOptions = ${JSON.stringify(Ur(o))}`;
660
+ },
661
+ configureServer(l) {
662
+ s = l;
108
663
  }
109
664
  };
110
665
  }
111
- let w = !1;
112
- const A = [], M = (r) => new Promise((t, e) => {
113
- if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
666
+ function Br(o = [], e = []) {
667
+ return e.every(({ url: r, options: s }) => {
668
+ const i = o.find((l) => (l == null ? void 0 : l.url) === r);
669
+ return i && JSON.stringify(s) === JSON.stringify(i.options);
670
+ });
671
+ }
672
+ let Bt = !1;
673
+ const Ht = [], Hr = (o) => new Promise((e, r) => {
674
+ if (typeof window > "u" || (window.storyblokRegisterEvent = (i) => {
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 ? i() : Ht.push(i);
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 s = document.createElement("script");
683
+ s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (i) => r(i), s.onload = (i) => {
684
+ Ht.forEach((l) => l()), Bt = !0, e(i);
685
+ }, document.getElementsByTagName("head")[0].appendChild(s);
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 qr = Object.defineProperty, Gr = (o, e, r) => e in o ? qr(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r, O = (o, e, r) => (Gr(o, typeof e != "symbol" ? e + "" : e, r), r);
688
+ class Jr {
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, s = 1) => ({
691
+ ...e,
692
+ per_page: r,
693
+ page: s
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 s = Math.abs(r - e) || 0, i = e < r ? 1 : -1;
696
+ return this.arrayFrom(s, (l, u) => u * i + e);
697
+ }), O(this, "asyncMap", async (e, r) => Promise.all(e.map(r))), O(this, "flatMap", (e = [], r) => e.map(r).reduce((s, i) => [...s, ...i], [])), 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
+ }, s = /[&<>"']/g, i = RegExp(s.source);
705
+ return e && i.test(e) ? e.replace(s, (l) => r[l]) : e;
145
706
  });
146
707
  }
147
708
  /**
@@ -151,223 +712,223 @@ class z {
151
712
  * @param {Boolean} isArray
152
713
  * @return {String} Stringified object
153
714
  */
154
- stringify(t, e, o) {
155
- const s = [];
156
- for (const a in t) {
157
- if (!Object.prototype.hasOwnProperty.call(t, a))
715
+ stringify(e, r, s) {
716
+ const i = [];
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], h = s ? "" : encodeURIComponent(l);
721
+ let d;
722
+ typeof u == "object" ? d = this.stringify(
723
+ u,
724
+ r ? r + encodeURIComponent("[" + h + "]") : h,
725
+ Array.isArray(u)
726
+ ) : d = (r ? r + encodeURIComponent("[" + h + "]") : h) + "=" + encodeURIComponent(u), i.push(d);
166
727
  }
167
- return s.join("&");
728
+ return i.join("&");
168
729
  }
169
730
  /**
170
731
  * @method getRegionURL
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", s = "api-us.storyblok.com", i = "app.storyblokchina.cn", l = "api-ap.storyblok.com", u = "api-ca.storyblok.com";
737
+ switch (e) {
177
738
  case "us":
178
- return o;
179
- case "cn":
180
739
  return s;
740
+ case "cn":
741
+ return i;
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 Kr = function(o, e) {
752
+ const r = {};
753
+ for (const s in o) {
754
+ const i = o[s];
755
+ e.indexOf(s) > -1 && i !== null && (r[s] = i);
756
+ }
757
+ return r;
758
+ }, Wr = (o) => o === "email", Yr = () => ({
198
759
  singleTag: "hr"
199
- }), q = () => ({
760
+ }), Xr = () => ({
200
761
  tag: "blockquote"
201
- }), F = () => ({
762
+ }), Zr = () => ({
202
763
  tag: "ul"
203
- }), J = (r) => ({
764
+ }), Qr = (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
+ }), Vr = () => ({
212
773
  singleTag: "br"
213
- }), V = (r) => ({
214
- tag: `h${r.attrs.level}`
215
- }), H = (r) => ({
774
+ }), tn = (o) => ({
775
+ tag: `h${o.attrs.level}`
776
+ }), en = (o) => ({
216
777
  singleTag: [
217
778
  {
218
779
  tag: "img",
219
- attrs: U(r.attrs, ["src", "alt", "title"])
780
+ attrs: Kr(o.attrs, ["src", "alt", "title"])
220
781
  }
221
782
  ]
222
- }), G = () => ({
783
+ }), rn = () => ({
223
784
  tag: "li"
224
- }), W = () => ({
785
+ }), nn = () => ({
225
786
  tag: "ol"
226
- }), Y = () => ({
787
+ }), on = () => ({
227
788
  tag: "p"
228
- }), Q = (r) => ({
789
+ }), an = (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
+ }), sn = () => ({
240
801
  tag: "b"
241
- }), Z = () => ({
802
+ }), ln = () => ({
242
803
  tag: "s"
243
- }), ee = () => ({
804
+ }), cn = () => ({
244
805
  tag: "u"
245
- }), te = () => ({
806
+ }), un = () => ({
246
807
  tag: "strong"
247
- }), re = () => ({
808
+ }), fn = () => ({
248
809
  tag: "code"
249
- }), oe = () => ({
810
+ }), pn = () => ({
250
811
  tag: "i"
251
- }), se = (r) => {
252
- if (!r.attrs)
812
+ }), dn = (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 Jr().escapeHTML, r = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
818
+ if (delete r.linktype, r.href && (r.href = e(o.attrs.href || "")), Wr(s) && (r.href = `mailto:${r.href}`), r.anchor && (r.href = `${r.href}#${r.anchor}`, delete r.anchor), r.custom) {
819
+ for (const i in r.custom)
820
+ r[i] = r.custom[i];
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
+ }, gn = (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
+ }), hn = () => ({
278
839
  tag: "sub"
279
- }), le = () => ({
840
+ }), yn = () => ({
280
841
  tag: "sup"
281
- }), ie = (r) => ({
842
+ }), bn = (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
+ }), mn = (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
+ }, _n = (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
+ }, vn = {
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: Yr,
880
+ blockquote: Xr,
881
+ bullet_list: Zr,
882
+ code_block: Qr,
883
+ hard_break: Vr,
884
+ heading: tn,
885
+ image: en,
886
+ list_item: rn,
887
+ ordered_list: nn,
888
+ paragraph: on,
889
+ emoji: an
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: sn,
893
+ strike: ln,
894
+ underline: cn,
895
+ strong: un,
896
+ code: fn,
897
+ italic: pn,
898
+ link: dn,
899
+ styled: gn,
900
+ subscript: hn,
901
+ superscript: yn,
902
+ anchor: bn,
903
+ highlight: mn,
904
+ textStyle: _n
905
+ }
906
+ }, Tn = 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, s = RegExp(r.source);
914
+ return o && s.test(o) ? o.replace(r, (i) => e[i]) : 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 wn {
917
+ constructor(e) {
918
+ O(this, "marks"), O(this, "nodes"), e || (e = vn), 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 s = "";
929
+ return e.content.forEach((i) => {
930
+ s += this.renderNode(i);
931
+ }), r.optimizeImages ? this.optimizeImages(s, r.optimizeImages) : s;
371
932
  }
372
933
  return console.warn(
373
934
  `The render method must receive an Object with a "content" field.
@@ -396,222 +957,273 @@ 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 s = 0, i = 0, l = "", u = "";
962
+ typeof r != "boolean" && (typeof r.width == "number" && r.width > 0 && (l += `width="${r.width}" `, s = r.width), typeof r.height == "number" && r.height > 0 && (l += `height="${r.height}" `, i = 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 h = s > 0 || i > 0 || u.length > 0 ? `${s}x${i}${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/${h}`
967
+ ), typeof r != "boolean" && (r.sizes || r.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (d) => {
968
+ var g, v;
969
+ const T = 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 (T && T.length > 0) {
973
+ const w = {
974
+ srcset: (g = r.srcset) == null ? void 0 : g.map((A) => {
975
+ if (typeof A == "number")
976
+ return `//${T}/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]), `//${T}/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 w.srcset && (E += `srcset="${w.srcset}" `), w.sizes && (E += `sizes="${w.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((i) => {
993
+ const l = this.getMatchingMark(i);
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 s = this.getMatchingNode(e);
997
+ return s && s.tag && r.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((i) => {
998
+ r.push(this.renderNode(i));
999
+ }) : e.text ? r.push(Tn(e.text)) : s && s.singleTag ? r.push(this.renderTag(s.singleTag, " /")) : s && s.html ? r.push(s.html) : e.type === "emoji" && r.push(this.renderEmoji(e)), s && s.tag && r.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((i) => {
1000
+ const l = this.getMatchingMark(i);
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((s) => {
1006
+ if (s.constructor === String)
1007
+ return `<${s}${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 i = `<${s.tag}`;
1010
+ if (s.attrs)
1011
+ for (const l in s.attrs) {
1012
+ const u = s.attrs[l];
1013
+ u !== null && (i += ` ${l}="${u}"`);
453
1014
  }
454
- return `${s}${e}>`;
1015
+ return `${i}${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 An, In = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1068
+ const kn = (o, e) => {
1069
+ o.addNode("blok", (r) => {
1070
+ let s = "";
1071
+ return r.attrs.body.forEach((i) => {
1072
+ s += e(i.component, i);
512
1073
  }), {
513
- html: o
1074
+ html: s
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
+ }, On = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Sn = (o, e, r) => {
1078
+ let s = r || An;
1079
+ if (!s) {
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 On(o) ? "" : (e && (s = new wn(e.schema), e.resolver && kn(s, e.resolver)), s.render(o));
1086
+ }, xn = () => Hr(In);
1087
+ let qt;
1088
+ async function En(o) {
1089
+ var s;
1090
+ const { action: e, story: r } = o || {};
1091
+ if (e === "input" && r) {
1092
+ const i = async () => {
1093
+ const u = performance.now(), h = await $n(r), d = performance.now();
1094
+ console.log(`getNewHTMLBody took ${d - u} milliseconds.`);
1095
+ const g = document.body;
1096
+ if (h.outerHTML === g.outerHTML)
1097
+ return;
1098
+ const v = document.querySelector('[data-blok-focused="true"]');
1099
+ Cn(g, h, v);
1100
+ const T = performance.now();
1101
+ console.log(`updateDOMWithNewBody took ${T - d} milliseconds.`), console.log(`total time took ${T - u} milliseconds.`);
1102
+ };
1103
+ clearTimeout(qt), qt = setTimeout(i, 1500);
1104
+ }
1105
+ ["published", "change"].includes((s = o == null ? void 0 : o.data) == null ? void 0 : s.action) && location.reload();
1106
+ }
1107
+ function Cn(o, e, r) {
1108
+ if (r) {
1109
+ const s = r.getAttribute("data-blok-uid"), i = e.querySelector(
1110
+ `[data-blok-uid="${s}"]`
1111
+ );
1112
+ i && (i.setAttribute("data-blok-focused", "true"), console.log("Doing partial replace"), r.replaceWith(i));
1113
+ } else
1114
+ console.log("Doing full replace"), o.replaceWith(e);
1115
+ }
1116
+ async function $n(o) {
1117
+ const r = await (await fetch(location.href, {
1118
+ method: "POST",
1119
+ body: JSON.stringify({
1120
+ ...o,
1121
+ is_storyblok_preview: !0
1122
+ }),
1123
+ headers: {
1124
+ "Content-Type": "application/json"
1125
+ }
1126
+ })).text();
1127
+ return new DOMParser().parseFromString(r, "text/html").body;
1128
+ }
1129
+ function Rn() {
527
1130
  return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
528
1131
  }
529
- function Ie(r, t) {
530
- const e = globalThis.storyblokApiInstance.richTextResolver;
531
- if (!e) {
1132
+ async function Mn(o, e = {}, r = {}, s) {
1133
+ globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly");
1134
+ let i = null;
1135
+ if (s && s.locals._storyblok_preview_data)
1136
+ i = s.locals._storyblok_preview_data;
1137
+ else {
1138
+ const { data: l } = await globalThis.storyblokApiInstance.get(
1139
+ o,
1140
+ e,
1141
+ r
1142
+ );
1143
+ i = l.story;
1144
+ }
1145
+ return i;
1146
+ }
1147
+ function Pn(o, e) {
1148
+ const r = globalThis.storyblokApiInstance.richTextResolver;
1149
+ if (!r) {
532
1150
  console.error(
533
1151
  "Please initialize the Storyblok SDK before calling the renderRichText function"
534
1152
  );
535
1153
  return;
536
1154
  }
537
- return ye(r, t, e);
1155
+ return Sn(o, e, r);
538
1156
  }
539
- function we(r) {
540
- const t = {
1157
+ function Nn(o) {
1158
+ const e = {
541
1159
  useCustomApi: !1,
542
1160
  bridge: !0,
543
1161
  componentsDir: "src",
544
1162
  enableFallbackComponent: !1,
545
- ...r
1163
+ ...o
546
1164
  };
547
1165
  return {
548
1166
  name: "@storyblok/astro",
549
1167
  hooks: {
550
1168
  "astro:config:setup": ({
551
- injectScript: e,
552
- updateConfig: o,
553
- addDevToolbarApp: s
1169
+ injectScript: r,
1170
+ updateConfig: s,
1171
+ addDevToolbarApp: i,
1172
+ addMiddleware: l
554
1173
  }) => {
555
- if (o({
1174
+ s({
556
1175
  vite: {
557
1176
  plugins: [
558
- E(
559
- t.accessToken,
560
- t.useCustomApi,
561
- t.apiOptions
1177
+ Sr(
1178
+ e.accessToken,
1179
+ e.useCustomApi,
1180
+ e.apiOptions
562
1181
  ),
563
- N(
564
- t.componentsDir,
565
- t.components,
566
- t.enableFallbackComponent,
567
- t.customFallbackComponent
1182
+ Mr(
1183
+ e.componentsDir,
1184
+ e.components,
1185
+ e.enableFallbackComponent,
1186
+ e.customFallbackComponent
568
1187
  ),
569
- L(t)
1188
+ Pr(e),
1189
+ Fr()
570
1190
  ]
571
1191
  }
572
- }), e(
1192
+ }), r(
573
1193
  "page-ssr",
574
1194
  `
575
1195
  import { storyblokApiInstance } from "virtual:storyblok-init";
576
1196
  globalThis.storyblokApiInstance = storyblokApiInstance;
577
1197
  `
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";
1198
+ ), e.bridge && (r(
1199
+ "page",
1200
+ `
1201
+ import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
1202
+ import { bridgeOptions } from "virtual:storyblok-bridge";
591
1203
  loadStoryblokBridge().then(() => {
592
1204
  const { StoryblokBridge, location } = window;
593
- ${a}
594
-
595
- storyblokInstance.on(["published", "change"], (event) => {
596
- if (!event.slugChanged) {
597
- location.reload(true);
598
- }
599
- });
1205
+ if(bridgeOptions){
1206
+ const storyblokInstance = new StoryblokBridge(bridgeOptions);
1207
+ storyblokInstance.on(["published", "change","input"], handleStoryblokMessage);
1208
+ };
600
1209
  });
601
1210
  `
602
- );
603
- }
604
- s("@storyblok/astro/toolbarApp.ts");
1211
+ ), l({
1212
+ entrypoint: "@storyblok/astro/middleware.ts",
1213
+ order: "pre"
1214
+ })), i("@storyblok/astro/toolbarApp.ts");
605
1215
  }
606
1216
  }
607
1217
  };
608
1218
  }
609
1219
  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
1220
+ wn as RichTextResolver,
1221
+ vn as RichTextSchema,
1222
+ Nn as default,
1223
+ En as handleStoryblokMessage,
1224
+ xn as loadStoryblokBridge,
1225
+ Pn as renderRichText,
1226
+ jn as storyblokEditable,
1227
+ Mn as useStoryblok,
1228
+ Rn as useStoryblokApi
617
1229
  };