@storyblok/js 4.2.4 → 4.2.7

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.
@@ -4,625 +4,346 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- var lt = Object.defineProperty;
8
- var ht = (t, e, s) => e in t ? lt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
9
- var E = (t, e, s) => ht(t, typeof e != "symbol" ? e + "" : e, s);
10
- const Dt = /[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/, dt = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;
11
- function O(t) {
12
- switch (t) {
13
- case 9:
14
- case 32:
15
- return !0;
16
- }
17
- return !1;
18
- }
19
- function G(t) {
20
- if (t >= 8192 && t <= 8202)
21
- return !0;
22
- switch (t) {
23
- case 9:
24
- // \t
25
- case 10:
26
- // \n
27
- case 11:
28
- // \v
29
- case 12:
30
- // \f
31
- case 13:
32
- // \r
33
- case 32:
34
- case 160:
35
- case 5760:
36
- case 8239:
37
- case 8287:
38
- case 12288:
39
- return !0;
40
- }
41
- return !1;
42
- }
43
- function q(t) {
44
- return Dt.test(t) || dt.test(t);
45
- }
46
- function J(t) {
47
- switch (t) {
48
- case 33:
49
- case 34:
50
- case 35:
51
- case 36:
52
- case 37:
53
- case 38:
54
- case 39:
55
- case 40:
56
- case 41:
57
- case 42:
58
- case 43:
59
- case 44:
60
- case 45:
61
- case 46:
62
- case 47:
63
- case 58:
64
- case 59:
65
- case 60:
66
- case 61:
67
- case 62:
68
- case 63:
69
- case 64:
70
- case 91:
71
- case 92:
72
- case 93:
73
- case 94:
74
- case 95:
75
- case 96:
76
- case 123:
77
- case 124:
78
- case 125:
79
- case 126:
80
- return !0;
81
- default:
82
- return !1;
83
- }
84
- }
85
- function x(t, e, s) {
86
- this.type = t, this.tag = e, this.attrs = null, this.map = null, this.nesting = s, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
87
- }
88
- x.prototype.attrIndex = function(e) {
89
- if (!this.attrs)
90
- return -1;
91
- const s = this.attrs;
92
- for (let r = 0, u = s.length; r < u; r++)
93
- if (s[r][0] === e)
94
- return r;
95
- return -1;
96
- };
97
- x.prototype.attrPush = function(e) {
98
- this.attrs ? this.attrs.push(e) : this.attrs = [e];
99
- };
100
- x.prototype.attrSet = function(e, s) {
101
- const r = this.attrIndex(e), u = [e, s];
102
- r < 0 ? this.attrPush(u) : this.attrs[r] = u;
103
- };
104
- x.prototype.attrGet = function(e) {
105
- const s = this.attrIndex(e);
106
- let r = null;
107
- return s >= 0 && (r = this.attrs[s][1]), r;
108
- };
109
- x.prototype.attrJoin = function(e, s) {
110
- const r = this.attrIndex(e);
111
- r < 0 ? this.attrPush([e, s]) : this.attrs[r][1] = this.attrs[r][1] + " " + s;
112
- };
113
- function ft(t, e, s) {
114
- this.src = t, this.env = s, this.tokens = [], this.inlineMode = !1, this.md = e;
115
- }
116
- ft.prototype.Token = x;
117
- function _(t, e, s, r) {
118
- this.src = t, this.md = e, this.env = s, this.tokens = r, this.bMarks = [], this.eMarks = [], this.tShift = [], this.sCount = [], this.bsCount = [], this.blkIndent = 0, this.line = 0, this.lineMax = 0, this.tight = !1, this.ddIndent = -1, this.listIndent = -1, this.parentType = "root", this.level = 0;
119
- const u = this.src;
120
- for (let i = 0, o = 0, n = 0, a = 0, c = u.length, h = !1; o < c; o++) {
121
- const D = u.charCodeAt(o);
122
- if (!h)
123
- if (O(D)) {
124
- n++, D === 9 ? a += 4 - a % 4 : a++;
125
- continue;
126
- } else
127
- h = !0;
128
- (D === 10 || o === c - 1) && (D !== 10 && o++, this.bMarks.push(i), this.eMarks.push(o), this.tShift.push(n), this.sCount.push(a), this.bsCount.push(0), h = !1, n = 0, a = 0, i = o + 1);
129
- }
130
- this.bMarks.push(u.length), this.eMarks.push(u.length), this.tShift.push(0), this.sCount.push(0), this.bsCount.push(0), this.lineMax = this.bMarks.length - 1;
131
- }
132
- _.prototype.push = function(t, e, s) {
133
- const r = new x(t, e, s);
134
- return r.block = !0, s < 0 && this.level--, r.level = this.level, s > 0 && this.level++, this.tokens.push(r), r;
135
- };
136
- _.prototype.isEmpty = function(e) {
137
- return this.bMarks[e] + this.tShift[e] >= this.eMarks[e];
138
- };
139
- _.prototype.skipEmptyLines = function(e) {
140
- for (let s = this.lineMax; e < s && !(this.bMarks[e] + this.tShift[e] < this.eMarks[e]); e++)
141
- ;
142
- return e;
143
- };
144
- _.prototype.skipSpaces = function(e) {
145
- for (let s = this.src.length; e < s; e++) {
146
- const r = this.src.charCodeAt(e);
147
- if (!O(r))
148
- break;
149
- }
150
- return e;
151
- };
152
- _.prototype.skipSpacesBack = function(e, s) {
153
- if (e <= s)
154
- return e;
155
- for (; e > s; )
156
- if (!O(this.src.charCodeAt(--e)))
157
- return e + 1;
158
- return e;
159
- };
160
- _.prototype.skipChars = function(e, s) {
161
- for (let r = this.src.length; e < r && this.src.charCodeAt(e) === s; e++)
162
- ;
163
- return e;
164
- };
165
- _.prototype.skipCharsBack = function(e, s, r) {
166
- if (e <= r)
167
- return e;
168
- for (; e > r; )
169
- if (s !== this.src.charCodeAt(--e))
170
- return e + 1;
171
- return e;
172
- };
173
- _.prototype.getLines = function(e, s, r, u) {
174
- if (e >= s)
175
- return "";
176
- const i = new Array(s - e);
177
- for (let o = 0, n = e; n < s; n++, o++) {
178
- let a = 0;
179
- const c = this.bMarks[n];
180
- let h = c, D;
181
- for (n + 1 < s || u ? D = this.eMarks[n] + 1 : D = this.eMarks[n]; h < D && a < r; ) {
182
- const g = this.src.charCodeAt(h);
183
- if (O(g))
184
- g === 9 ? a += 4 - (a + this.bsCount[n]) % 4 : a++;
185
- else if (h - c < this.tShift[n])
186
- a++;
187
- else
188
- break;
189
- h++;
190
- }
191
- a > r ? i[o] = new Array(a - r + 1).join(" ") + this.src.slice(h, D) : i[o] = this.src.slice(h, D);
192
- }
193
- return i.join("");
194
- };
195
- _.prototype.Token = x;
196
- const Ft = [
197
- "address",
198
- "article",
199
- "aside",
7
+ var re = Object.defineProperty;
8
+ var se = (e, t, s) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
9
+ var b = (e, t, s) => se(e, typeof t != "symbol" ? t + "" : t, s);
10
+ let w = /* @__PURE__ */ function(e) {
11
+ return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
12
+ }({}), S = /* @__PURE__ */ function(e) {
13
+ return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
14
+ }({}), ie = /* @__PURE__ */ function(e) {
15
+ return e.TEXT = "text", e;
16
+ }({}), C = /* @__PURE__ */ function(e) {
17
+ return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
18
+ }({});
19
+ const ne = [
20
+ "area",
200
21
  "base",
201
- "basefont",
202
- "blockquote",
203
- "body",
204
- "caption",
205
- "center",
22
+ "br",
206
23
  "col",
207
- "colgroup",
208
- "dd",
209
- "details",
210
- "dialog",
211
- "dir",
212
- "div",
213
- "dl",
214
- "dt",
215
- "fieldset",
216
- "figcaption",
217
- "figure",
218
- "footer",
219
- "form",
220
- "frame",
221
- "frameset",
222
- "h1",
223
- "h2",
224
- "h3",
225
- "h4",
226
- "h5",
227
- "h6",
228
- "head",
229
- "header",
24
+ "embed",
230
25
  "hr",
231
- "html",
232
- "iframe",
233
- "legend",
234
- "li",
26
+ "img",
27
+ "input",
235
28
  "link",
236
- "main",
237
- "menu",
238
- "menuitem",
239
- "nav",
240
- "noframes",
241
- "ol",
242
- "optgroup",
243
- "option",
244
- "p",
29
+ "meta",
245
30
  "param",
246
- "search",
247
- "section",
248
- "summary",
249
- "table",
250
- "tbody",
251
- "td",
252
- "tfoot",
253
- "th",
254
- "thead",
255
- "title",
256
- "tr",
31
+ "source",
257
32
  "track",
258
- "ul"
259
- ], Et = "[a-zA-Z_:][a-zA-Z0-9:._-]*", pt = "[^\"'=<>`\\x00-\\x20]+", Ct = "'[^']*'", At = '"[^"]*"', gt = "(?:" + pt + "|" + Ct + "|" + At + ")", yt = "(?:\\s+" + Et + "(?:\\s*=\\s*" + gt + ")?)", bt = "<[A-Za-z][A-Za-z0-9\\-]*" + yt + "*\\s*\\/?>", kt = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>", mt = new RegExp("^(?:" + bt + "|" + kt + ")");
260
- new RegExp("^</?(" + Ft.join("|") + ")(?=(\\s|/?>|$))", "i"), new RegExp(mt.source + "\\s*$");
261
- function I(t, e, s, r) {
262
- this.src = t, this.env = s, this.md = e, this.tokens = r, this.tokens_meta = Array(r.length), this.pos = 0, this.posMax = this.src.length, this.level = 0, this.pending = "", this.pendingLevel = 0, this.cache = {}, this.delimiters = [], this._prev_delimiters = [], this.backticks = {}, this.backticksScanned = !1, this.linkLevel = 0;
33
+ "wbr"
34
+ ], oe = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), ae = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
35
+ function le(e) {
36
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
263
37
  }
264
- I.prototype.pushPending = function() {
265
- const t = new x("text", "", 0);
266
- return t.content = this.pending, t.level = this.pendingLevel, this.tokens.push(t), this.pending = "", t;
267
- };
268
- I.prototype.push = function(t, e, s) {
269
- this.pending && this.pushPending();
270
- const r = new x(t, e, s);
271
- let u = null;
272
- return s < 0 && (this.level--, this.delimiters = this._prev_delimiters.pop()), r.level = this.level, s > 0 && (this.level++, this._prev_delimiters.push(this.delimiters), this.delimiters = [], u = { delimiters: this.delimiters }), this.pendingLevel = this.level, this.tokens.push(r), this.tokens_meta.push(u), r;
273
- };
274
- I.prototype.scanDelims = function(t, e) {
275
- const s = this.posMax, r = this.src.charCodeAt(t), u = t > 0 ? this.src.charCodeAt(t - 1) : 32;
276
- let i = t;
277
- for (; i < s && this.src.charCodeAt(i) === r; )
278
- i++;
279
- const o = i - t, n = i < s ? this.src.charCodeAt(i) : 32, a = J(u) || q(String.fromCharCode(u)), c = J(n) || q(String.fromCharCode(n)), h = G(u), D = G(n), g = !D && (!c || h || a), k = !h && (!a || D || c);
280
- return { can_open: g && (e || !k || a), can_close: k && (e || !g || c), length: o };
281
- };
282
- I.prototype.Token = x;
283
- const Q = [];
284
- for (let t = 0; t < 256; t++)
285
- Q.push(0);
286
- "\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t) {
287
- Q[t.charCodeAt(0)] = 1;
288
- });
289
- let b = /* @__PURE__ */ function(t) {
290
- return t.DOCUMENT = "doc", t.HEADING = "heading", t.PARAGRAPH = "paragraph", t.QUOTE = "blockquote", t.OL_LIST = "ordered_list", t.UL_LIST = "bullet_list", t.LIST_ITEM = "list_item", t.CODE_BLOCK = "code_block", t.HR = "horizontal_rule", t.BR = "hard_break", t.IMAGE = "image", t.EMOJI = "emoji", t.COMPONENT = "blok", t.TABLE = "table", t.TABLE_ROW = "tableRow", t.TABLE_CELL = "tableCell", t.TABLE_HEADER = "tableHeader", t;
291
- }({}), v = /* @__PURE__ */ function(t) {
292
- return t.BOLD = "bold", t.STRONG = "strong", t.STRIKE = "strike", t.UNDERLINE = "underline", t.ITALIC = "italic", t.CODE = "code", t.LINK = "link", t.ANCHOR = "anchor", t.STYLED = "styled", t.SUPERSCRIPT = "superscript", t.SUBSCRIPT = "subscript", t.TEXT_STYLE = "textStyle", t.HIGHLIGHT = "highlight", t;
293
- }({}), vt = /* @__PURE__ */ function(t) {
294
- return t.TEXT = "text", t;
295
- }({}), L = /* @__PURE__ */ function(t) {
296
- return t.URL = "url", t.STORY = "story", t.ASSET = "asset", t.EMAIL = "email", t;
297
- }({});
298
- function xt(t, e) {
299
- if (!e) return {
300
- src: t,
38
+ const P = (e) => Object.fromEntries(Object.entries(e).filter(([t, s]) => s !== void 0));
39
+ function ce(e, t) {
40
+ if (!t) return {
41
+ src: e,
301
42
  attrs: {}
302
43
  };
303
44
  let s = 0, r = 0;
304
- const u = {}, i = [];
305
- function o(a, c, h, D, g) {
306
- typeof a != "number" || a <= c || a >= h ? console.warn(`[StoryblokRichText] - ${D.charAt(0).toUpperCase() + D.slice(1)} value must be a number between ${c} and ${h} (inclusive)`) : g.push(`${D}(${a})`);
307
- }
308
- if (typeof e == "object") {
309
- if (typeof e.width == "number" && e.width > 0 ? (u.width = e.width, s = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (u.height = e.height, r = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (u.loading = e.loading), e.class && (u.class = e.class), e.filters) {
310
- const { filters: a } = e || {}, { blur: c, brightness: h, fill: D, format: g, grayscale: k, quality: w, rotate: R } = a || {};
311
- c && o(c, 0, 100, "blur", i), w && o(w, 0, 100, "quality", i), h && o(h, 0, 100, "brightness", i), D && i.push(`fill(${D})`), k && i.push("grayscale()"), R && [
45
+ const i = {}, n = [];
46
+ function l(u, c, f, g, E) {
47
+ typeof u != "number" || u <= c || u >= f ? console.warn(`[StoryblokRichText] - ${g.charAt(0).toUpperCase() + g.slice(1)} value must be a number between ${c} and ${f} (inclusive)`) : E.push(`${g}(${u})`);
48
+ }
49
+ if (typeof t == "object") {
50
+ if (typeof t.width == "number" && t.width > 0 ? (i.width = t.width, s = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (i.height = t.height, r = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (i.loading = t.loading), t.class && (i.class = t.class), t.filters) {
51
+ const { filters: u } = t || {}, { blur: c, brightness: f, fill: g, format: E, grayscale: _, quality: T, rotate: L } = u || {};
52
+ c && l(c, 0, 100, "blur", n), T && l(T, 0, 100, "quality", n), f && l(f, 0, 100, "brightness", n), g && n.push(`fill(${g})`), _ && n.push("grayscale()"), L && [
312
53
  0,
313
54
  90,
314
55
  180,
315
56
  270
316
- ].includes(e.filters.rotate || 0) && i.push(`rotate(${R})`), g && [
57
+ ].includes(t.filters.rotate || 0) && n.push(`rotate(${L})`), E && [
317
58
  "webp",
318
59
  "png",
319
60
  "jpeg"
320
- ].includes(g) && i.push(`format(${g})`);
61
+ ].includes(E) && n.push(`format(${E})`);
321
62
  }
322
- e.srcset && (u.srcset = e.srcset.map((a) => {
323
- if (typeof a == "number") return `${t}/m/${a}x0/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${a}w`;
324
- if (Array.isArray(a) && a.length === 2) {
325
- const [c, h] = a;
326
- return `${t}/m/${c}x${h}/${i.length > 0 ? `filters:${i.join(":")}` : ""} ${c}w`;
63
+ t.srcset && (i.srcset = t.srcset.map((u) => {
64
+ if (typeof u == "number") return `${e}/m/${u}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${u}w`;
65
+ if (Array.isArray(u) && u.length === 2) {
66
+ const [c, f] = u;
67
+ return `${e}/m/${c}x${f}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${c}w`;
327
68
  } else {
328
69
  console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
329
70
  return;
330
71
  }
331
- }).join(", ")), e.sizes && (u.sizes = e.sizes.join(", "));
72
+ }).join(", ")), t.sizes && (i.sizes = t.sizes.join(", "));
332
73
  }
333
- let n = `${t}/m/`;
334
- return s > 0 && r > 0 && (n = `${n}${s}x${r}/`), i.length > 0 && (n = `${n}filters:${i.join(":")}`), {
335
- src: n,
336
- attrs: u
74
+ let a = `${e}/m/`;
75
+ return s > 0 && r > 0 && (a = `${a}${s}x${r}/`), n.length > 0 && (a = `${a}filters:${n.join(":")}`), {
76
+ src: a,
77
+ attrs: i
337
78
  };
338
79
  }
339
- const _t = [
340
- "area",
341
- "base",
342
- "br",
343
- "col",
344
- "embed",
345
- "hr",
346
- "img",
347
- "input",
348
- "link",
349
- "meta",
350
- "param",
351
- "source",
352
- "track",
353
- "wbr"
354
- ], Bt = (t = {}) => Object.keys(t).map((e) => `${e}="${t[e]}"`).join(" "), wt = (t = {}) => Object.keys(t).map((e) => `${e}: ${t[e]}`).join("; ");
355
- function Rt(t) {
356
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
80
+ function F(e, t = {}, s) {
81
+ const r = oe(t), i = r ? `${e} ${r}` : e, n = Array.isArray(s) ? s.join("") : s || "";
82
+ if (e) {
83
+ if (ne.includes(e)) return `<${i}>`;
84
+ } else return n;
85
+ return `<${i}>${n}</${e}>`;
357
86
  }
358
- const T = (t) => Object.fromEntries(Object.entries(t).filter(([e, s]) => s !== void 0));
359
- function V(t, e = {}, s) {
360
- const r = Bt(e), u = r ? `${t} ${r}` : t, i = Array.isArray(s) ? s.join("") : s || "";
361
- if (t) {
362
- if (_t.includes(t)) return `<${u}>`;
363
- } else return i;
364
- return `<${u}>${i}</${t}>`;
365
- }
366
- function St(t = {}) {
367
- const e = /* @__PURE__ */ new Map(), { renderFn: s = V, textFn: r = Rt, resolvers: u = {}, optimizeImages: i = !1, keyedResolvers: o = !1 } = t, n = s !== V, a = (l) => (f, d) => {
368
- const F = f.attrs || {};
369
- return d.render(l, F, f.children || null);
370
- }, c = (l, f) => {
371
- const { src: d, alt: F, title: p, srcset: C, sizes: A } = l.attrs || {};
372
- let y = d, m = {};
373
- if (i) {
374
- const { src: at, attrs: ct } = xt(d, i);
375
- y = at, m = ct;
87
+ function ue(e = {}) {
88
+ const t = /* @__PURE__ */ new Map(), { renderFn: s = F, textFn: r = le, resolvers: i = {}, optimizeImages: n = !1, keyedResolvers: l = !1 } = e, a = s !== F, u = (o) => (d, h) => {
89
+ const y = d.attrs || {};
90
+ return h.render(o, y, d.children || null);
91
+ }, c = (o, d) => {
92
+ const { src: h, alt: y, title: p, srcset: m, sizes: v } = o.attrs || {};
93
+ let R = h, k = {};
94
+ if (n) {
95
+ const { src: ee, attrs: te } = ce(h, n);
96
+ R = ee, k = te;
376
97
  }
377
- const ot = {
378
- src: y,
379
- alt: F,
98
+ const Z = {
99
+ src: R,
100
+ alt: y,
380
101
  title: p,
381
- srcset: C,
382
- sizes: A,
383
- ...m
102
+ srcset: m,
103
+ sizes: v,
104
+ ...k
384
105
  };
385
- return f.render("img", T(ot));
386
- }, h = (l, f) => {
387
- const { level: d, ...F } = l.attrs || {};
388
- return f.render(`h${d}`, F, l.children);
389
- }, D = (l, f) => {
390
- var F, p, C, A;
391
- const d = f.render("img", {
392
- src: (F = l.attrs) == null ? void 0 : F.fallbackImage,
393
- alt: (p = l.attrs) == null ? void 0 : p.alt,
106
+ return d.render("img", P(Z));
107
+ }, f = (o, d) => {
108
+ const { level: h, ...y } = o.attrs || {};
109
+ return d.render(`h${h}`, y, o.children);
110
+ }, g = (o, d) => {
111
+ var y, p, m, v;
112
+ const h = d.render("img", {
113
+ src: (y = o.attrs) == null ? void 0 : y.fallbackImage,
114
+ alt: (p = o.attrs) == null ? void 0 : p.alt,
394
115
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
395
116
  draggable: "false",
396
117
  loading: "lazy"
397
118
  });
398
- return f.render("span", {
119
+ return d.render("span", {
399
120
  "data-type": "emoji",
400
- "data-name": (C = l.attrs) == null ? void 0 : C.name,
401
- "data-emoji": (A = l.attrs) == null ? void 0 : A.emoji
402
- }, d);
403
- }, g = (l, f) => f.render("pre", l.attrs || {}, f.render("code", {}, l.children || "")), k = (l, f = !1) => ({ text: d, attrs: F }, p) => {
404
- const { class: C, id: A, ...y } = F || {}, m = f ? {
405
- class: C,
406
- id: A,
407
- style: wt(y) || void 0
408
- } : F || {};
409
- return p.render(l, T(m), d);
410
- }, w = (l) => N(l), R = (l) => {
411
- const { marks: f, ...d } = l;
412
- if ("text" in l) {
413
- if (f) return f.reduce((p, C) => w({
414
- ...C,
121
+ "data-name": (m = o.attrs) == null ? void 0 : m.name,
122
+ "data-emoji": (v = o.attrs) == null ? void 0 : v.emoji
123
+ }, h);
124
+ }, E = (o, d) => d.render("pre", o.attrs || {}, d.render("code", {}, o.children || "")), _ = (o, d = !1) => ({ text: h, attrs: y }, p) => {
125
+ const { class: m, id: v, ...R } = y || {}, k = d ? {
126
+ class: m,
127
+ id: v,
128
+ style: ae(R) || void 0
129
+ } : y || {};
130
+ return p.render(o, P(k), h);
131
+ }, T = (o) => N(o), L = (o) => {
132
+ const { marks: d, ...h } = o;
133
+ if ("text" in o) {
134
+ if (d) return d.reduce((p, m) => T({
135
+ ...m,
415
136
  text: p
416
- }), w({
417
- ...d,
418
- children: d.children
137
+ }), T({
138
+ ...h,
139
+ children: h.children
419
140
  }));
420
- const F = l.attrs || {};
421
- if (o) {
422
- const p = e.get("txt") || 0;
423
- e.set("txt", p + 1), F.key = `txt-${p}`;
141
+ const y = o.attrs || {};
142
+ if (l) {
143
+ const p = t.get("txt") || 0;
144
+ t.set("txt", p + 1), y.key = `txt-${p}`;
424
145
  }
425
- return r(d.text, F);
146
+ return r(h.text, y);
426
147
  }
427
148
  return "";
428
- }, U = (l, f) => {
429
- const { linktype: d, href: F, anchor: p, ...C } = l.attrs || {};
430
- let A = "";
431
- switch (d) {
432
- case L.ASSET:
433
- case L.URL:
434
- A = F;
149
+ }, j = (o, d) => {
150
+ const { linktype: h, href: y, anchor: p, ...m } = o.attrs || {};
151
+ let v = "";
152
+ switch (h) {
153
+ case C.ASSET:
154
+ case C.URL:
155
+ v = y;
435
156
  break;
436
- case L.EMAIL:
437
- A = `mailto:${F}`;
157
+ case C.EMAIL:
158
+ v = `mailto:${y}`;
438
159
  break;
439
- case L.STORY:
440
- A = F, p && (A = `${A}#${p}`);
160
+ case C.STORY:
161
+ v = y, p && (v = `${v}#${p}`);
441
162
  break;
442
163
  default:
443
- A = F;
164
+ v = y;
444
165
  break;
445
166
  }
446
- const y = { ...C };
447
- return A && (y.href = A), f.render("a", y, l.text);
448
- }, et = (l, f) => {
449
- var d, F;
450
- return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), f.render("span", {
451
- blok: (d = l == null ? void 0 : l.attrs) == null ? void 0 : d.body[0],
452
- id: (F = l.attrs) == null ? void 0 : F.id,
167
+ const R = { ...m };
168
+ return v && (R.href = v), d.render("a", R, o.text);
169
+ }, J = (o, d) => {
170
+ var h, y;
171
+ return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), d.render("span", {
172
+ blok: (h = o == null ? void 0 : o.attrs) == null ? void 0 : h.body[0],
173
+ id: (y = o.attrs) == null ? void 0 : y.id,
453
174
  style: "display: none"
454
175
  });
455
- }, st = (l, f) => {
456
- const d = {}, F = f.render("tbody", {}, l.children);
457
- return f.render("table", d, F);
458
- }, rt = (l, f) => {
459
- const d = {};
460
- return f.render("tr", d, l.children);
461
- }, ut = (l, f) => {
462
- const { colspan: d, rowspan: F, colwidth: p, backgroundColor: C, ...A } = l.attrs || {}, y = { ...A };
463
- d > 1 && (y.colspan = d), F > 1 && (y.rowspan = F);
464
- const m = [];
465
- return p && m.push(`width: ${p}px;`), C && m.push(`background-color: ${C};`), m.length > 0 && (y.style = m.join(" ")), f.render("td", T(y), l.children);
466
- }, it = (l, f) => {
467
- const { colspan: d, rowspan: F, colwidth: p, backgroundColor: C, ...A } = l.attrs || {}, y = { ...A };
468
- d > 1 && (y.colspan = d), F > 1 && (y.rowspan = F);
469
- const m = [];
470
- return p && m.push(`width: ${p}px;`), C && m.push(`background-color: ${C};`), m.length > 0 && (y.style = m.join(" ")), f.render("th", T(y), l.children);
471
- }, M = /* @__PURE__ */ new Map([
472
- [b.DOCUMENT, a("")],
473
- [b.HEADING, h],
474
- [b.PARAGRAPH, a("p")],
475
- [b.UL_LIST, a("ul")],
476
- [b.OL_LIST, a("ol")],
477
- [b.LIST_ITEM, a("li")],
478
- [b.IMAGE, c],
479
- [b.EMOJI, D],
480
- [b.CODE_BLOCK, g],
481
- [b.HR, a("hr")],
482
- [b.BR, a("br")],
483
- [b.QUOTE, a("blockquote")],
484
- [b.COMPONENT, et],
485
- [vt.TEXT, R],
486
- [v.LINK, U],
487
- [v.ANCHOR, U],
488
- [v.STYLED, k("span", !0)],
489
- [v.BOLD, k("strong")],
490
- [v.TEXT_STYLE, k("span", !0)],
491
- [v.ITALIC, k("em")],
492
- [v.UNDERLINE, k("u")],
493
- [v.STRIKE, k("s")],
494
- [v.CODE, k("code")],
495
- [v.SUPERSCRIPT, k("sup")],
496
- [v.SUBSCRIPT, k("sub")],
497
- [v.HIGHLIGHT, k("mark")],
498
- [b.TABLE, st],
499
- [b.TABLE_ROW, rt],
500
- [b.TABLE_CELL, ut],
501
- [b.TABLE_HEADER, it]
502
- ]), z = new Map([...M, ...Object.entries(u).map(([l, f]) => [l, f])]), nt = () => ({
503
- render: (d, F = {}, p) => {
504
- if (o && d) {
505
- const C = e.get(d) || 0;
506
- e.set(d, C + 1), F.key = `${d}-${C}`;
176
+ }, K = (o, d) => {
177
+ const h = {}, y = d.render("tbody", {}, o.children);
178
+ return d.render("table", h, y);
179
+ }, Y = (o, d) => {
180
+ const h = {};
181
+ return d.render("tr", h, o.children);
182
+ }, W = (o, d) => {
183
+ const { colspan: h, rowspan: y, colwidth: p, backgroundColor: m, ...v } = o.attrs || {}, R = { ...v };
184
+ h > 1 && (R.colspan = h), y > 1 && (R.rowspan = y);
185
+ const k = [];
186
+ return p && k.push(`width: ${p}px;`), m && k.push(`background-color: ${m};`), k.length > 0 && (R.style = k.join(" ")), d.render("td", P(R), o.children);
187
+ }, X = (o, d) => {
188
+ const { colspan: h, rowspan: y, colwidth: p, backgroundColor: m, ...v } = o.attrs || {}, R = { ...v };
189
+ h > 1 && (R.colspan = h), y > 1 && (R.rowspan = y);
190
+ const k = [];
191
+ return p && k.push(`width: ${p}px;`), m && k.push(`background-color: ${m};`), k.length > 0 && (R.style = k.join(" ")), d.render("th", P(R), o.children);
192
+ }, U = /* @__PURE__ */ new Map([
193
+ [w.DOCUMENT, u("")],
194
+ [w.HEADING, f],
195
+ [w.PARAGRAPH, u("p")],
196
+ [w.UL_LIST, u("ul")],
197
+ [w.OL_LIST, u("ol")],
198
+ [w.LIST_ITEM, u("li")],
199
+ [w.IMAGE, c],
200
+ [w.EMOJI, g],
201
+ [w.CODE_BLOCK, E],
202
+ [w.HR, u("hr")],
203
+ [w.BR, u("br")],
204
+ [w.QUOTE, u("blockquote")],
205
+ [w.COMPONENT, J],
206
+ [ie.TEXT, L],
207
+ [S.LINK, j],
208
+ [S.ANCHOR, j],
209
+ [S.STYLED, _("span", !0)],
210
+ [S.BOLD, _("strong")],
211
+ [S.TEXT_STYLE, _("span", !0)],
212
+ [S.ITALIC, _("em")],
213
+ [S.UNDERLINE, _("u")],
214
+ [S.STRIKE, _("s")],
215
+ [S.CODE, _("code")],
216
+ [S.SUPERSCRIPT, _("sup")],
217
+ [S.SUBSCRIPT, _("sub")],
218
+ [S.HIGHLIGHT, _("mark")],
219
+ [w.TABLE, K],
220
+ [w.TABLE_ROW, Y],
221
+ [w.TABLE_CELL, W],
222
+ [w.TABLE_HEADER, X]
223
+ ]), B = new Map([...U, ...Object.entries(i).map(([o, d]) => [o, d])]), Q = () => ({
224
+ render: (h, y = {}, p) => {
225
+ if (l && h) {
226
+ const m = t.get(h) || 0;
227
+ t.set(h, m + 1), y.key = `${h}-${m}`;
507
228
  }
508
- return s(d, F, p);
229
+ return s(h, y, p);
509
230
  },
510
- originalResolvers: M,
511
- mergedResolvers: z
231
+ originalResolvers: U,
232
+ mergedResolvers: B
512
233
  });
513
- function S(l) {
514
- const f = z.get(l.type);
515
- if (!f)
516
- return console.error("<Storyblok>", `No resolver found for node type ${l.type}`), "";
517
- const d = nt();
518
- if (l.type === "text") return f(l, d);
519
- const F = l.content ? l.content.map(N) : void 0;
520
- return f({
521
- ...l,
522
- children: F
523
- }, d);
524
- }
525
- function N(l) {
526
- return l.type === "doc" ? n ? l.content.map(S) : l.content.map(S).join("") : Array.isArray(l) ? l.map(S) : S(l);
234
+ function O(o) {
235
+ const d = B.get(o.type);
236
+ if (!d)
237
+ return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
238
+ const h = Q();
239
+ if (o.type === "text") return d(o, h);
240
+ const y = o.content ? o.content.map(N) : void 0;
241
+ return d({
242
+ ...o,
243
+ children: y
244
+ }, h);
245
+ }
246
+ function N(o) {
247
+ return o.type === "doc" ? a ? o.content.map(O) : o.content.map(O).join("") : Array.isArray(o) ? o.map(O) : O(o);
527
248
  }
528
249
  return { render: N };
529
250
  }
530
- let K = !1;
531
- const Y = [], tt = (t) => new Promise((e, s) => {
251
+ let z = !1;
252
+ const G = [], M = (e) => new Promise((t, s) => {
532
253
  if (typeof window > "u") {
533
254
  s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
534
255
  return;
535
256
  }
536
- if (window.storyblokRegisterEvent = (u) => {
257
+ if (window.storyblokRegisterEvent = (i) => {
537
258
  if (!window.location.search.includes("_storyblok")) {
538
259
  console.warn("You are not in Draft Mode or in the Visual Editor.");
539
260
  return;
540
261
  }
541
- K ? u() : Y.push(u);
262
+ z ? i() : G.push(i);
542
263
  }, document.getElementById("storyblok-javascript-bridge")) {
543
- e(void 0);
264
+ t(void 0);
544
265
  return;
545
266
  }
546
267
  const r = document.createElement("script");
547
- r.async = !0, r.src = t, r.id = "storyblok-javascript-bridge", r.onerror = (u) => s(u), r.onload = (u) => {
548
- Y.forEach((i) => i()), K = !0, e(u);
268
+ r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (i) => s(i), r.onload = (i) => {
269
+ G.forEach((n) => n()), z = !0, t(i);
549
270
  }, document.getElementsByTagName("head")[0].appendChild(r);
550
271
  });
551
- var Lt = class extends Error {
552
- constructor(t) {
553
- super(t), this.name = "AbortError";
272
+ var he = class extends Error {
273
+ constructor(e) {
274
+ super(e), this.name = "AbortError";
554
275
  }
555
276
  };
556
- function Tt(t, e, s) {
557
- if (!Number.isFinite(e)) throw new TypeError("Expected `limit` to be a finite number");
277
+ function de(e, t, s) {
278
+ if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
558
279
  if (!Number.isFinite(s)) throw new TypeError("Expected `interval` to be a finite number");
559
280
  const r = [];
560
- let u = [], i = 0, o = !1;
561
- const n = async () => {
562
- i++;
281
+ let i = [], n = 0, l = !1;
282
+ const a = async () => {
283
+ n++;
563
284
  const c = r.shift();
564
285
  if (c) try {
565
- const D = await t(...c.args);
566
- c.resolve(D);
567
- } catch (D) {
568
- c.reject(D);
286
+ const g = await e(...c.args);
287
+ c.resolve(g);
288
+ } catch (g) {
289
+ c.reject(g);
569
290
  }
570
- const h = setTimeout(() => {
571
- i--, r.length > 0 && n(), u = u.filter((D) => D !== h);
291
+ const f = setTimeout(() => {
292
+ n--, r.length > 0 && a(), i = i.filter((g) => g !== f);
572
293
  }, s);
573
- u.includes(h) || u.push(h);
574
- }, a = (...c) => o ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((h, D) => {
294
+ i.includes(f) || i.push(f);
295
+ }, u = (...c) => l ? Promise.reject(/* @__PURE__ */ new Error("Throttled function is already aborted and not accepting new promises")) : new Promise((f, g) => {
575
296
  r.push({
576
- resolve: h,
577
- reject: D,
297
+ resolve: f,
298
+ reject: g,
578
299
  args: c
579
- }), i < e && n();
300
+ }), n < t && a();
580
301
  });
581
- return a.abort = () => {
582
- o = !0, u.forEach(clearTimeout), u = [], r.forEach((c) => c.reject(() => new Lt("Throttle function aborted"))), r.length = 0;
583
- }, a;
302
+ return u.abort = () => {
303
+ l = !0, i.forEach(clearTimeout), i = [], r.forEach((c) => c.reject(() => new he("Throttle function aborted"))), r.length = 0;
304
+ }, u;
584
305
  }
585
- var Pt = Tt;
586
- const W = (t = "") => t.includes("/cdn/"), Ot = (t, e = 25, s = 1) => ({
587
- ...t,
588
- per_page: e,
306
+ var fe = de;
307
+ const q = (e = "") => e.includes("/cdn/"), ye = (e, t = 25, s = 1) => ({
308
+ ...e,
309
+ per_page: t,
589
310
  page: s
590
- }), It = (t) => new Promise((e) => setTimeout(e, t)), Nt = (t = 0, e) => Array.from({ length: t }, e), $t = (t = 0, e = t) => {
591
- const s = Math.abs(e - t) || 0, r = t < e ? 1 : -1;
592
- return Nt(s, (u, i) => i * r + t);
593
- }, jt = async (t, e) => Promise.all(t.map(e)), Ht = (t = [], e) => t.map(e).reduce((s, r) => [...s, ...r], []), H = (t, e, s) => {
311
+ }), ge = (e) => new Promise((t) => setTimeout(t, e)), be = (e = 0, t) => Array.from({ length: e }, t), pe = (e = 0, t = e) => {
312
+ const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
313
+ return be(s, (i, n) => n * r + e);
314
+ }, me = async (e, t) => Promise.all(e.map(t)), ve = (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []), H = (e, t, s) => {
594
315
  const r = [];
595
- for (const u in t) {
596
- if (!Object.prototype.hasOwnProperty.call(t, u)) continue;
597
- const i = t[u];
598
- if (i == null) continue;
599
- const o = s ? "" : encodeURIComponent(u);
600
- let n;
601
- typeof i == "object" ? n = H(i, e ? e + encodeURIComponent(`[${o}]`) : o, Array.isArray(i)) : n = `${e ? e + encodeURIComponent(`[${o}]`) : o}=${encodeURIComponent(i)}`, r.push(n);
316
+ for (const i in e) {
317
+ if (!Object.prototype.hasOwnProperty.call(e, i)) continue;
318
+ const n = e[i];
319
+ if (n == null) continue;
320
+ const l = s ? "" : encodeURIComponent(i);
321
+ let a;
322
+ typeof n == "object" ? a = H(n, t ? t + encodeURIComponent(`[${l}]`) : l, Array.isArray(n)) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(n)}`, r.push(a);
602
323
  }
603
324
  return r.join("&");
604
- }, Z = (t) => {
605
- const e = {
325
+ }, V = (e) => {
326
+ const t = {
606
327
  eu: "api.storyblok.com",
607
328
  us: "api-us.storyblok.com",
608
329
  cn: "app.storyblokchina.cn",
609
330
  ap: "api-ap.storyblok.com",
610
331
  ca: "api-ca.storyblok.com"
611
332
  };
612
- return e[t] ?? e.eu;
333
+ return t[e] ?? t.eu;
613
334
  };
614
- var Ut = class {
615
- constructor(t) {
616
- E(this, "baseURL");
617
- E(this, "timeout");
618
- E(this, "headers");
619
- E(this, "responseInterceptor");
620
- E(this, "fetch");
621
- E(this, "ejectInterceptor");
622
- E(this, "url");
623
- E(this, "parameters");
624
- E(this, "fetchOptions");
625
- this.baseURL = t.baseURL, this.headers = t.headers || new Headers(), this.timeout = t != null && t.timeout ? t.timeout * 1e3 : 0, this.responseInterceptor = t.responseInterceptor, this.fetch = (...e) => t.fetch ? t.fetch(...e) : fetch(...e), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
335
+ var Re = class {
336
+ constructor(e) {
337
+ b(this, "baseURL");
338
+ b(this, "timeout");
339
+ b(this, "headers");
340
+ b(this, "responseInterceptor");
341
+ b(this, "fetch");
342
+ b(this, "ejectInterceptor");
343
+ b(this, "url");
344
+ b(this, "parameters");
345
+ b(this, "fetchOptions");
346
+ this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
626
347
  }
627
348
  /**
628
349
  *
@@ -630,54 +351,54 @@ var Ut = class {
630
351
  * @param params ISbStoriesParams
631
352
  * @returns Promise<ISbResponse | Error>
632
353
  */
633
- get(t, e) {
634
- return this.url = t, this.parameters = e, this._methodHandler("get");
354
+ get(e, t) {
355
+ return this.url = e, this.parameters = t, this._methodHandler("get");
635
356
  }
636
- post(t, e) {
637
- return this.url = t, this.parameters = e, this._methodHandler("post");
357
+ post(e, t) {
358
+ return this.url = e, this.parameters = t, this._methodHandler("post");
638
359
  }
639
- put(t, e) {
640
- return this.url = t, this.parameters = e, this._methodHandler("put");
360
+ put(e, t) {
361
+ return this.url = e, this.parameters = t, this._methodHandler("put");
641
362
  }
642
- delete(t, e) {
643
- return this.url = t, this.parameters = e ?? {}, this._methodHandler("delete");
363
+ delete(e, t) {
364
+ return this.url = e, this.parameters = t ?? {}, this._methodHandler("delete");
644
365
  }
645
- async _responseHandler(t) {
646
- const e = [], s = {
366
+ async _responseHandler(e) {
367
+ const t = [], s = {
647
368
  data: {},
648
369
  headers: {},
649
370
  status: 0,
650
371
  statusText: ""
651
372
  };
652
- t.status !== 204 && await t.json().then((r) => {
373
+ e.status !== 204 && await e.json().then((r) => {
653
374
  s.data = r;
654
375
  });
655
- for (const r of t.headers.entries()) e[r[0]] = r[1];
656
- return s.headers = { ...e }, s.status = t.status, s.statusText = t.statusText, s;
657
- }
658
- async _methodHandler(t) {
659
- let e = `${this.baseURL}${this.url}`, s = null;
660
- t === "get" ? e = `${this.baseURL}${this.url}?${H(this.parameters)}` : s = JSON.stringify(this.parameters);
661
- const r = new URL(e), u = new AbortController(), { signal: i } = u;
662
- let o;
663
- this.timeout && (o = setTimeout(() => u.abort(), this.timeout));
376
+ for (const r of e.headers.entries()) t[r[0]] = r[1];
377
+ return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
378
+ }
379
+ async _methodHandler(e) {
380
+ let t = `${this.baseURL}${this.url}`, s = null;
381
+ e === "get" ? t = `${this.baseURL}${this.url}?${H(this.parameters)}` : s = JSON.stringify(this.parameters);
382
+ const r = new URL(t), i = new AbortController(), { signal: n } = i;
383
+ let l;
384
+ this.timeout && (l = setTimeout(() => i.abort(), this.timeout));
664
385
  try {
665
- const n = await this.fetch(`${r}`, {
666
- method: t,
386
+ const a = await this.fetch(`${r}`, {
387
+ method: e,
667
388
  headers: this.headers,
668
389
  body: s,
669
- signal: i,
390
+ signal: n,
670
391
  ...this.fetchOptions
671
392
  });
672
- this.timeout && clearTimeout(o);
673
- const a = await this._responseHandler(n);
674
- return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(a)) : this._statusHandler(a);
675
- } catch (n) {
676
- return { message: n };
393
+ this.timeout && clearTimeout(l);
394
+ const u = await this._responseHandler(a);
395
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(u)) : this._statusHandler(u);
396
+ } catch (a) {
397
+ return { message: a };
677
398
  }
678
399
  }
679
- setFetchOptions(t = {}) {
680
- Object.keys(t).length > 0 && "method" in t && delete t.method, this.fetchOptions = { ...t };
400
+ setFetchOptions(e = {}) {
401
+ Object.keys(e).length > 0 && "method" in e && delete e.method, this.fetchOptions = { ...e };
681
402
  }
682
403
  eject() {
683
404
  this.ejectInterceptor = !0;
@@ -687,124 +408,124 @@ var Ut = class {
687
408
  * @param data The response data that might contain error information
688
409
  * @returns A normalized error message string
689
410
  */
690
- _normalizeErrorMessage(t) {
691
- if (Array.isArray(t)) return t[0] || "Unknown error";
692
- if (t && typeof t == "object") {
693
- if (t.error) return t.error;
694
- for (const e in t) {
695
- if (Array.isArray(t[e])) return `${e}: ${t[e][0]}`;
696
- if (typeof t[e] == "string") return `${e}: ${t[e]}`;
411
+ _normalizeErrorMessage(e) {
412
+ if (Array.isArray(e)) return e[0] || "Unknown error";
413
+ if (e && typeof e == "object") {
414
+ if (e.error) return e.error;
415
+ for (const t in e) {
416
+ if (Array.isArray(e[t])) return `${t}: ${e[t][0]}`;
417
+ if (typeof e[t] == "string") return `${t}: ${e[t]}`;
697
418
  }
698
- if (t.slug) return t.slug;
419
+ if (e.slug) return e.slug;
699
420
  }
700
421
  return "Unknown error";
701
422
  }
702
- _statusHandler(t) {
703
- const e = /20[0-6]/g;
423
+ _statusHandler(e) {
424
+ const t = /20[0-6]/g;
704
425
  return new Promise((s, r) => {
705
- if (e.test(`${t.status}`)) return s(t);
706
- const u = {
707
- message: this._normalizeErrorMessage(t.data),
708
- status: t.status,
709
- response: t
426
+ if (t.test(`${e.status}`)) return s(e);
427
+ const i = {
428
+ message: this._normalizeErrorMessage(e.data),
429
+ status: e.status,
430
+ response: e
710
431
  };
711
- r(u);
432
+ r(i);
712
433
  });
713
434
  }
714
- }, Mt = Ut;
715
- const X = "SB-Agent", $ = {
435
+ }, we = Re;
436
+ const D = "SB-Agent", x = {
716
437
  defaultAgentName: "SB-JS-CLIENT",
717
438
  defaultAgentVersion: "SB-Agent-Version",
718
439
  packageVersion: "7.0.0"
719
- }, zt = {
440
+ }, ke = {
720
441
  PUBLISHED: "published"
721
442
  };
722
- let P = {};
723
- const B = {};
724
- var Gt = class {
443
+ let I = {};
444
+ const A = {};
445
+ var _e = class {
725
446
  /**
726
447
  *
727
448
  * @param config ISbConfig interface
728
449
  * @param pEndpoint string, optional
729
450
  */
730
- constructor(t, e) {
731
- E(this, "client");
732
- E(this, "maxRetries");
733
- E(this, "retriesDelay");
734
- E(this, "throttle");
735
- E(this, "accessToken");
736
- E(this, "cache");
737
- E(this, "resolveCounter");
738
- E(this, "relations");
739
- E(this, "links");
740
- E(this, "version");
451
+ constructor(e, t) {
452
+ b(this, "client");
453
+ b(this, "maxRetries");
454
+ b(this, "retriesDelay");
455
+ b(this, "throttle");
456
+ b(this, "accessToken");
457
+ b(this, "cache");
458
+ b(this, "resolveCounter");
459
+ b(this, "relations");
460
+ b(this, "links");
461
+ b(this, "version");
741
462
  /**
742
463
  * @deprecated This property is deprecated. Use the standalone `richTextResolver` from `@storyblok/richtext` instead.
743
464
  * @see https://github.com/storyblok/richtext
744
465
  */
745
- E(this, "richTextResolver");
746
- E(this, "resolveNestedRelations");
747
- E(this, "stringifiedStoriesCache");
748
- E(this, "inlineAssets");
749
- let s = t.endpoint || e;
466
+ b(this, "richTextResolver");
467
+ b(this, "resolveNestedRelations");
468
+ b(this, "stringifiedStoriesCache");
469
+ b(this, "inlineAssets");
470
+ let s = e.endpoint || t;
750
471
  if (!s) {
751
- const i = t.https === !1 ? "http" : "https";
752
- t.oauthToken ? s = `${i}://${Z(t.region)}/v1` : s = `${i}://${Z(t.region)}/v2`;
472
+ const n = e.https === !1 ? "http" : "https";
473
+ e.oauthToken ? s = `${n}://${V(e.region)}/v1` : s = `${n}://${V(e.region)}/v2`;
753
474
  }
754
475
  const r = new Headers();
755
- r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), t.headers && (t.headers.constructor.name === "Headers" ? t.headers.entries().toArray() : Object.entries(t.headers)).forEach(([o, n]) => {
756
- r.set(o, n);
757
- }), r.has(X) || (r.set(X, $.defaultAgentName), r.set($.defaultAgentVersion, $.packageVersion));
758
- let u = 5;
759
- t.oauthToken && (r.set("Authorization", t.oauthToken), u = 3), t.rateLimit && (u = t.rateLimit), this.maxRetries = t.maxRetries || 10, this.retriesDelay = 300, this.throttle = Pt(this.throttledRequest.bind(this), u, 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = t.version || zt.PUBLISHED, this.inlineAssets = t.inlineAssets || !1, this.client = new Mt({
476
+ r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([l, a]) => {
477
+ r.set(l, a);
478
+ }), r.has(D) || (r.set(D, x.defaultAgentName), r.set(x.defaultAgentVersion, x.packageVersion));
479
+ let i = 5;
480
+ e.oauthToken && (r.set("Authorization", e.oauthToken), i = 3), e.rateLimit && (i = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = fe(this.throttledRequest.bind(this), i, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ke.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new we({
760
481
  baseURL: s,
761
- timeout: t.timeout || 0,
482
+ timeout: e.timeout || 0,
762
483
  headers: r,
763
- responseInterceptor: t.responseInterceptor,
764
- fetch: t.fetch
484
+ responseInterceptor: e.responseInterceptor,
485
+ fetch: e.fetch
765
486
  });
766
487
  }
767
- parseParams(t) {
768
- return t.token || (t.token = this.getToken()), t.cv || (t.cv = B[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), typeof t.resolve_relations < "u" && (t.resolve_level = 2), t;
488
+ parseParams(e) {
489
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = A[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
769
490
  }
770
- factoryParamOptions(t, e) {
771
- return W(t) ? this.parseParams(e) : e;
491
+ factoryParamOptions(e, t) {
492
+ return q(e) ? this.parseParams(t) : t;
772
493
  }
773
- makeRequest(t, e, s, r, u) {
774
- const i = this.factoryParamOptions(t, Ot(e, s, r));
775
- return this.cacheResponse(t, i, void 0, u);
494
+ makeRequest(e, t, s, r, i) {
495
+ const n = this.factoryParamOptions(e, ye(t, s, r));
496
+ return this.cacheResponse(e, n, void 0, i);
776
497
  }
777
- get(t, e = {}, s) {
778
- e || (e = {});
779
- const r = `/${t}`;
780
- W(r) && (e.version = e.version || this.version);
781
- const u = this.factoryParamOptions(r, e);
782
- return this.cacheResponse(r, u, void 0, s);
498
+ get(e, t = {}, s) {
499
+ t || (t = {});
500
+ const r = `/${e}`;
501
+ q(r) && (t.version = t.version || this.version);
502
+ const i = this.factoryParamOptions(r, t);
503
+ return this.cacheResponse(r, i, void 0, s);
783
504
  }
784
- async getAll(t, e = {}, s, r) {
785
- const u = (e == null ? void 0 : e.per_page) || 25, i = `/${t}`.replace(/\/$/, ""), o = s ?? i.substring(i.lastIndexOf("/") + 1);
786
- e.version = e.version || this.version;
787
- const n = 1, a = await this.makeRequest(i, e, u, n, r), c = a.total ? Math.ceil(a.total / (a.perPage || u)) : 1, h = await jt($t(n, c), (D) => this.makeRequest(i, e, u, D + 1, r));
788
- return Ht([a, ...h], (D) => Object.values(D.data[o]));
505
+ async getAll(e, t = {}, s, r) {
506
+ const i = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), l = s ?? n.substring(n.lastIndexOf("/") + 1);
507
+ t.version = t.version || this.version;
508
+ const a = 1, u = await this.makeRequest(n, t, i, a, r), c = u.total ? Math.ceil(u.total / (u.perPage || i)) : 1, f = await me(pe(a, c), (g) => this.makeRequest(n, t, i, g + 1, r));
509
+ return ve([u, ...f], (g) => Object.values(g.data[l]));
789
510
  }
790
- post(t, e = {}, s) {
791
- const r = `/${t}`;
792
- return this.throttle("post", r, e, s);
511
+ post(e, t = {}, s) {
512
+ const r = `/${e}`;
513
+ return this.throttle("post", r, t, s);
793
514
  }
794
- put(t, e = {}, s) {
795
- const r = `/${t}`;
796
- return this.throttle("put", r, e, s);
515
+ put(e, t = {}, s) {
516
+ const r = `/${e}`;
517
+ return this.throttle("put", r, t, s);
797
518
  }
798
- delete(t, e = {}, s) {
799
- e || (e = {});
800
- const r = `/${t}`;
801
- return this.throttle("delete", r, e, s);
519
+ delete(e, t = {}, s) {
520
+ t || (t = {});
521
+ const r = `/${e}`;
522
+ return this.throttle("delete", r, t, s);
802
523
  }
803
- getStories(t = {}, e) {
804
- return this._addResolveLevel(t), this.get("cdn/stories", t, e);
524
+ getStories(e = {}, t) {
525
+ return this._addResolveLevel(e), this.get("cdn/stories", e, t);
805
526
  }
806
- getStory(t, e = {}, s) {
807
- return this._addResolveLevel(e), this.get(`cdn/stories/${t}`, e, s);
527
+ getStory(e, t = {}, s) {
528
+ return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
808
529
  }
809
530
  getToken() {
810
531
  return this.accessToken;
@@ -812,14 +533,14 @@ var Gt = class {
812
533
  ejectInterceptor() {
813
534
  this.client.eject();
814
535
  }
815
- _addResolveLevel(t) {
816
- typeof t.resolve_relations < "u" && (t.resolve_level = 2);
536
+ _addResolveLevel(e) {
537
+ typeof e.resolve_relations < "u" && (e.resolve_level = 2);
817
538
  }
818
- _cleanCopy(t) {
819
- return JSON.parse(JSON.stringify(t));
539
+ _cleanCopy(e) {
540
+ return JSON.parse(JSON.stringify(e));
820
541
  }
821
- _insertLinks(t, e, s) {
822
- const r = t[e];
542
+ _insertLinks(e, t, s) {
543
+ const r = e[t];
823
544
  r && r.fieldtype === "multilink" && r.linktype === "story" && typeof r.id == "string" && this.links[s][r.id] ? r.story = this._cleanCopy(this.links[s][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[s][r.uuid] && (r.story = this._cleanCopy(this.links[s][r.uuid]));
824
545
  }
825
546
  /**
@@ -828,8 +549,8 @@ var Gt = class {
828
549
  * @param uuid The uuid of the story
829
550
  * @returns string | object
830
551
  */
831
- getStoryReference(t, e) {
832
- return this.relations[t][e] ? JSON.parse(this.stringifiedStoriesCache[e] || JSON.stringify(this.relations[t][e])) : e;
552
+ getStoryReference(e, t) {
553
+ return this.relations[e][t] ? JSON.parse(this.stringifiedStoriesCache[t] || JSON.stringify(this.relations[e][t])) : t;
833
554
  }
834
555
  /**
835
556
  * Resolves a field's value by replacing UUIDs with their corresponding story references
@@ -841,9 +562,9 @@ var Gt = class {
841
562
  * - For single strings: directly replaces the UUID with the story reference
842
563
  * - For arrays: maps through each UUID and replaces with corresponding story references
843
564
  */
844
- _resolveField(t, e, s) {
845
- const r = t[e];
846
- typeof r == "string" ? t[e] = this.getStoryReference(s, r) : Array.isArray(r) && (t[e] = r.map((u) => this.getStoryReference(s, u)).filter(Boolean));
565
+ _resolveField(e, t, s) {
566
+ const r = e[t];
567
+ typeof r == "string" ? e[t] = this.getStoryReference(s, r) : Array.isArray(r) && (e[t] = r.map((i) => this.getStoryReference(s, i)).filter(Boolean));
847
568
  }
848
569
  /**
849
570
  * Inserts relations into the JSON tree by resolving references
@@ -862,13 +583,13 @@ var Gt = class {
862
583
  * The method supports both string and array formats for the fields parameter,
863
584
  * allowing flexible specification of relation patterns.
864
585
  */
865
- _insertRelations(t, e, s, r) {
866
- if (Array.isArray(s) ? s.find((o) => o.endsWith(`.${e}`)) : s.endsWith(`.${e}`)) {
867
- this._resolveField(t, e, r);
586
+ _insertRelations(e, t, s, r) {
587
+ if (Array.isArray(s) ? s.find((l) => l.endsWith(`.${t}`)) : s.endsWith(`.${t}`)) {
588
+ this._resolveField(e, t, r);
868
589
  return;
869
590
  }
870
- const i = t.component ? `${t.component}.${e}` : e;
871
- (Array.isArray(s) ? s.includes(i) : s === i) && this._resolveField(t, e, r);
591
+ const n = e.component ? `${e.component}.${t}` : t;
592
+ (Array.isArray(s) ? s.includes(n) : s === n) && this._resolveField(e, t, r);
872
593
  }
873
594
  /**
874
595
  * Recursively traverses and resolves relations in the story content tree
@@ -876,68 +597,68 @@ var Gt = class {
876
597
  * @param fields - The relation patterns to resolve
877
598
  * @param resolveId - The unique identifier for the current resolution context
878
599
  */
879
- iterateTree(t, e, s) {
880
- const r = (u, i = "") => {
881
- if (!(!u || u._stopResolving)) {
882
- if (Array.isArray(u)) u.forEach((o, n) => r(o, `${i}[${n}]`));
883
- else if (typeof u == "object") for (const o in u) {
884
- const n = i ? `${i}.${o}` : o;
885
- (u.component && u._uid || u.type === "link") && (this._insertRelations(u, o, e, s), this._insertLinks(u, o, s)), r(u[o], n);
600
+ iterateTree(e, t, s) {
601
+ const r = (i, n = "") => {
602
+ if (!(!i || i._stopResolving)) {
603
+ if (Array.isArray(i)) i.forEach((l, a) => r(l, `${n}[${a}]`));
604
+ else if (typeof i == "object") for (const l in i) {
605
+ const a = n ? `${n}.${l}` : l;
606
+ (i.component && i._uid || i.type === "link") && (this._insertRelations(i, l, t, s), this._insertLinks(i, l, s)), r(i[l], a);
886
607
  }
887
608
  }
888
609
  };
889
- r(t.content);
610
+ r(e.content);
890
611
  }
891
- async resolveLinks(t, e, s) {
612
+ async resolveLinks(e, t, s) {
892
613
  let r = [];
893
- if (t.link_uuids) {
894
- const u = t.link_uuids.length, i = [], o = 50;
895
- for (let n = 0; n < u; n += o) {
896
- const a = Math.min(u, n + o);
897
- i.push(t.link_uuids.slice(n, a));
614
+ if (e.link_uuids) {
615
+ const i = e.link_uuids.length, n = [], l = 50;
616
+ for (let a = 0; a < i; a += l) {
617
+ const u = Math.min(i, a + l);
618
+ n.push(e.link_uuids.slice(a, u));
898
619
  }
899
- for (let n = 0; n < i.length; n++)
620
+ for (let a = 0; a < n.length; a++)
900
621
  (await this.getStories({
901
- per_page: o,
902
- language: e.language,
903
- version: e.version,
904
- starts_with: e.starts_with,
905
- by_uuids: i[n].join(",")
622
+ per_page: l,
623
+ language: t.language,
624
+ version: t.version,
625
+ starts_with: t.starts_with,
626
+ by_uuids: n[a].join(",")
906
627
  })).data.stories.forEach((c) => {
907
628
  r.push(c);
908
629
  });
909
- } else r = t.links;
910
- r.forEach((u) => {
911
- this.links[s][u.uuid] = {
912
- ...u,
630
+ } else r = e.links;
631
+ r.forEach((i) => {
632
+ this.links[s][i.uuid] = {
633
+ ...i,
913
634
  _stopResolving: !0
914
635
  };
915
636
  });
916
637
  }
917
- async resolveRelations(t, e, s) {
638
+ async resolveRelations(e, t, s) {
918
639
  let r = [];
919
- if (t.rel_uuids) {
920
- const u = t.rel_uuids.length, i = [], o = 50;
921
- for (let n = 0; n < u; n += o) {
922
- const a = Math.min(u, n + o);
923
- i.push(t.rel_uuids.slice(n, a));
640
+ if (e.rel_uuids) {
641
+ const i = e.rel_uuids.length, n = [], l = 50;
642
+ for (let a = 0; a < i; a += l) {
643
+ const u = Math.min(i, a + l);
644
+ n.push(e.rel_uuids.slice(a, u));
924
645
  }
925
- for (let n = 0; n < i.length; n++)
646
+ for (let a = 0; a < n.length; a++)
926
647
  (await this.getStories({
927
- per_page: o,
928
- language: e.language,
929
- version: e.version,
930
- starts_with: e.starts_with,
931
- by_uuids: i[n].join(","),
932
- excluding_fields: e.excluding_fields
648
+ per_page: l,
649
+ language: t.language,
650
+ version: t.version,
651
+ starts_with: t.starts_with,
652
+ by_uuids: n[a].join(","),
653
+ excluding_fields: t.excluding_fields
933
654
  })).data.stories.forEach((c) => {
934
655
  r.push(c);
935
656
  });
936
- r.length > 0 && (t.rels = r, delete t.rel_uuids);
937
- } else r = t.rels;
938
- r && r.length > 0 && r.forEach((u) => {
939
- this.relations[s][u.uuid] = {
940
- ...u,
657
+ r.length > 0 && (e.rels = r, delete e.rel_uuids);
658
+ } else r = e.rels;
659
+ r && r.length > 0 && r.forEach((i) => {
660
+ this.relations[s][i.uuid] = {
661
+ ...i,
941
662
  _stopResolving: !0
942
663
  };
943
664
  });
@@ -951,84 +672,84 @@ var Gt = class {
951
672
  * @returns Promise<void>
952
673
  *
953
674
  */
954
- async resolveStories(t, e, s) {
955
- var u, i;
675
+ async resolveStories(e, t, s) {
676
+ var i, n;
956
677
  let r = [];
957
- if (this.links[s] = {}, this.relations[s] = {}, typeof e.resolve_relations < "u" && e.resolve_relations.length > 0 && (typeof e.resolve_relations == "string" && (r = e.resolve_relations.split(",")), await this.resolveRelations(t, e, s)), e.resolve_links && [
678
+ if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (r = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && [
958
679
  "1",
959
680
  "story",
960
681
  "url",
961
682
  "link"
962
- ].includes(e.resolve_links) && ((u = t.links) != null && u.length || (i = t.link_uuids) != null && i.length) && await this.resolveLinks(t, e, s), this.resolveNestedRelations) for (const o in this.relations[s]) this.iterateTree(this.relations[s][o], r, s);
963
- t.story ? this.iterateTree(t.story, r, s) : t.stories.forEach((o) => {
964
- this.iterateTree(o, r, s);
683
+ ].includes(t.resolve_links) && ((i = e.links) != null && i.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations) for (const l in this.relations[s]) this.iterateTree(this.relations[s][l], r, s);
684
+ e.story ? this.iterateTree(e.story, r, s) : e.stories.forEach((l) => {
685
+ this.iterateTree(l, r, s);
965
686
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
966
687
  }
967
- async cacheResponse(t, e, s, r) {
968
- const u = H({
969
- url: t,
970
- params: e
971
- }), i = this.cacheProvider();
972
- if (e.version === "published" && t !== "/cdn/spaces/me") {
973
- const o = await i.get(u);
974
- if (o) return Promise.resolve(o);
688
+ async cacheResponse(e, t, s, r) {
689
+ const i = H({
690
+ url: e,
691
+ params: t
692
+ }), n = this.cacheProvider();
693
+ if (t.version === "published" && e !== "/cdn/spaces/me") {
694
+ const l = await n.get(i);
695
+ if (l) return Promise.resolve(l);
975
696
  }
976
- return new Promise(async (o, n) => {
977
- var a;
697
+ return new Promise(async (l, a) => {
698
+ var u;
978
699
  try {
979
- const c = await this.throttle("get", t, e, r);
980
- if (c.status !== 200) return n(c);
981
- let h = {
700
+ const c = await this.throttle("get", e, t, r);
701
+ if (c.status !== 200) return a(c);
702
+ let f = {
982
703
  data: c.data,
983
704
  headers: c.headers
984
705
  };
985
- if ((a = c.headers) != null && a["per-page"] && (h = Object.assign({}, h, {
706
+ if ((u = c.headers) != null && u["per-page"] && (f = Object.assign({}, f, {
986
707
  perPage: c.headers["per-page"] ? Number.parseInt(c.headers["per-page"]) : 0,
987
708
  total: c.headers["per-page"] ? Number.parseInt(c.headers.total) : 0
988
- })), h.data.story || h.data.stories) {
989
- const g = this.resolveCounter = ++this.resolveCounter % 1e3;
990
- await this.resolveStories(h.data, e, `${g}`), h = await this.processInlineAssets(h);
709
+ })), f.data.story || f.data.stories) {
710
+ const E = this.resolveCounter = ++this.resolveCounter % 1e3;
711
+ await this.resolveStories(f.data, t, `${E}`), f = await this.processInlineAssets(f);
991
712
  }
992
- e.version === "published" && t !== "/cdn/spaces/me" && await i.set(u, h);
993
- const D = this.cache.clear === "onpreview" && e.version === "draft" || this.cache.clear === "auto";
994
- return e.token && h.data.cv && (D && B[e.token] && B[e.token] !== h.data.cv && await this.flushCache(), B[e.token] = h.data.cv), o(h);
713
+ t.version === "published" && e !== "/cdn/spaces/me" && await n.set(i, f);
714
+ const g = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
715
+ return t.token && f.data.cv && (g && A[t.token] && A[t.token] !== f.data.cv && await this.flushCache(), A[t.token] = f.data.cv), l(f);
995
716
  } catch (c) {
996
717
  if (c.response && c.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
997
- return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await It(this.retriesDelay), this.cacheResponse(t, e, s).then(o).catch(n);
998
- n(c);
718
+ return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await ge(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
719
+ a(c);
999
720
  }
1000
721
  });
1001
722
  }
1002
- throttledRequest(t, e, s, r) {
1003
- return this.client.setFetchOptions(r), this.client[t](e, s);
723
+ throttledRequest(e, t, s, r) {
724
+ return this.client.setFetchOptions(r), this.client[e](t, s);
1004
725
  }
1005
726
  cacheVersions() {
1006
- return B;
727
+ return A;
1007
728
  }
1008
729
  cacheVersion() {
1009
- return B[this.accessToken];
730
+ return A[this.accessToken];
1010
731
  }
1011
- setCacheVersion(t) {
1012
- this.accessToken && (B[this.accessToken] = t);
732
+ setCacheVersion(e) {
733
+ this.accessToken && (A[this.accessToken] = e);
1013
734
  }
1014
735
  clearCacheVersion() {
1015
- this.accessToken && (B[this.accessToken] = 0);
736
+ this.accessToken && (A[this.accessToken] = 0);
1016
737
  }
1017
738
  cacheProvider() {
1018
739
  switch (this.cache.type) {
1019
740
  case "memory":
1020
741
  return {
1021
- get(t) {
1022
- return Promise.resolve(P[t]);
742
+ get(e) {
743
+ return Promise.resolve(I[e]);
1023
744
  },
1024
745
  getAll() {
1025
- return Promise.resolve(P);
746
+ return Promise.resolve(I);
1026
747
  },
1027
- set(t, e) {
1028
- return P[t] = e, Promise.resolve(void 0);
748
+ set(e, t) {
749
+ return I[e] = t, Promise.resolve(void 0);
1029
750
  },
1030
751
  flush() {
1031
- return P = {}, Promise.resolve(void 0);
752
+ return I = {}, Promise.resolve(void 0);
1032
753
  }
1033
754
  };
1034
755
  case "custom":
@@ -1053,96 +774,96 @@ var Gt = class {
1053
774
  async flushCache() {
1054
775
  return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
1055
776
  }
1056
- async processInlineAssets(t) {
1057
- if (!this.inlineAssets) return t;
1058
- const e = (s) => {
777
+ async processInlineAssets(e) {
778
+ if (!this.inlineAssets) return e;
779
+ const t = (s) => {
1059
780
  if (!s || typeof s != "object") return s;
1060
- if (Array.isArray(s)) return s.map((u) => e(u));
781
+ if (Array.isArray(s)) return s.map((i) => t(i));
1061
782
  let r = { ...s };
1062
- r.fieldtype === "asset" && Array.isArray(t.data.assets) && (r = {
783
+ r.fieldtype === "asset" && Array.isArray(e.data.assets) && (r = {
1063
784
  ...r,
1064
- ...t.data.assets.find((u) => u.id === r.id)
785
+ ...e.data.assets.find((i) => i.id === r.id)
1065
786
  });
1066
- for (const u in r) typeof r[u] == "object" && (r[u] = e(r[u]));
787
+ for (const i in r) typeof r[i] == "object" && (r[i] = t(r[i]));
1067
788
  return r;
1068
789
  };
1069
- return t.data.story && (t.data.story.content = e(t.data.story.content)), t.data.stories && (t.data.stories = t.data.stories.map((s) => (s.content = e(s.content), s))), t;
790
+ return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((s) => (s.content = t(s.content), s))), e;
1070
791
  }
1071
- }, qt = Gt;
1072
- const Vt = (t = {}) => {
1073
- const { apiOptions: e } = t;
1074
- if (!e || !e.accessToken) {
792
+ }, Se = _e;
793
+ const Ae = (e = {}) => {
794
+ const { apiOptions: t } = e;
795
+ if (!t || !t.accessToken) {
1075
796
  console.error(
1076
797
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
1077
798
  );
1078
799
  return;
1079
800
  }
1080
- return { storyblokApi: new qt(e) };
1081
- }, Kt = (t) => {
1082
- if (typeof t != "object" || typeof t._editable > "u")
801
+ return { storyblokApi: new Se(t) };
802
+ }, Te = (e) => {
803
+ if (typeof e != "object" || typeof e._editable > "u")
1083
804
  return {};
1084
805
  try {
1085
- const e = JSON.parse(
1086
- t._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
806
+ const t = JSON.parse(
807
+ e._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
1087
808
  );
1088
- return e ? {
1089
- "data-blok-c": JSON.stringify(e),
1090
- "data-blok-uid": `${e.id}-${e.uid}`
809
+ return t ? {
810
+ "data-blok-c": JSON.stringify(t),
811
+ "data-blok-uid": `${t.id}-${t.uid}`
1091
812
  } : {};
1092
813
  } catch {
1093
814
  return {};
1094
815
  }
1095
816
  };
1096
- let j = "https://app.storyblok.com/f/storyblok-v2-latest.js";
1097
- const Yt = (t, e, s = {}) => {
1098
- var n;
1099
- const u = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = new URL((n = window.location) == null ? void 0 : n.href).searchParams.get(
817
+ let $ = "https://app.storyblok.com/f/storyblok-v2-latest.js";
818
+ const Le = (e, t, s = {}) => {
819
+ var a;
820
+ const i = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = new URL((a = window.location) == null ? void 0 : a.href).searchParams.get(
1100
821
  "_storyblok"
1101
- ), o = i !== null && +i === t;
1102
- if (!(!u || !o)) {
1103
- if (!t) {
822
+ ), l = n !== null && +n === e;
823
+ if (!(!i || !l)) {
824
+ if (!e) {
1104
825
  console.warn("Story ID is not defined. Please provide a valid ID.");
1105
826
  return;
1106
827
  }
1107
828
  window.storyblokRegisterEvent(() => {
1108
829
  new window.StoryblokBridge(s).on(["input", "published", "change"], (c) => {
1109
- var h;
1110
- c && (c.action === "input" && ((h = c.story) == null ? void 0 : h.id) === t ? e(c.story) : (c.action === "change" || c.action === "published") && c.storyId === t && window.location.reload());
830
+ var f;
831
+ c && (c.action === "input" && ((f = c.story) == null ? void 0 : f.id) === e ? t(c.story) : (c.action === "change" || c.action === "published") && c.storyId === e && window.location.reload());
1111
832
  });
1112
833
  });
1113
834
  }
1114
- }, Wt = (t = {}) => {
1115
- var h, D;
835
+ }, Oe = (e = {}) => {
836
+ var f, g;
1116
837
  const {
1117
- bridge: e,
838
+ bridge: t,
1118
839
  accessToken: s,
1119
840
  use: r = [],
1120
- apiOptions: u = {},
1121
- bridgeUrl: i
1122
- } = t;
1123
- u.accessToken = u.accessToken || s;
1124
- const o = { bridge: e, apiOptions: u };
1125
- let n = {};
1126
- r.forEach((g) => {
1127
- n = { ...n, ...g(o) };
1128
- }), i && (j = i);
1129
- const c = !(typeof window > "u") && ((D = (h = window.location) == null ? void 0 : h.search) == null ? void 0 : D.includes("_storyblok_tk"));
1130
- return e !== !1 && c && tt(j), n;
841
+ apiOptions: i = {},
842
+ bridgeUrl: n
843
+ } = e;
844
+ i.accessToken = i.accessToken || s;
845
+ const l = { bridge: t, apiOptions: i };
846
+ let a = {};
847
+ r.forEach((E) => {
848
+ a = { ...a, ...E(l) };
849
+ }), n && ($ = n);
850
+ const c = !(typeof window > "u") && ((g = (f = window.location) == null ? void 0 : f.search) == null ? void 0 : g.includes("_storyblok_tk"));
851
+ return t !== !1 && c && M($), a;
1131
852
  };
1132
- function Zt(t, e) {
1133
- return St(e).render(t);
853
+ function Ce(e, t) {
854
+ return ue(t).render(e);
1134
855
  }
1135
- const Xt = () => tt(j);
856
+ const Pe = () => M($);
1136
857
  export {
1137
- b as BlockTypes,
1138
- v as MarkTypes,
1139
- vt as TextTypes,
1140
- Vt as apiPlugin,
1141
- Xt as loadStoryblokBridge,
1142
- Yt as registerStoryblokBridge,
1143
- Zt as renderRichText,
1144
- St as richTextResolver,
1145
- Kt as storyblokEditable,
1146
- Wt as storyblokInit,
1147
- Yt as useStoryblokBridge
858
+ w as BlockTypes,
859
+ S as MarkTypes,
860
+ ie as TextTypes,
861
+ Ae as apiPlugin,
862
+ Pe as loadStoryblokBridge,
863
+ Le as registerStoryblokBridge,
864
+ Ce as renderRichText,
865
+ ue as richTextResolver,
866
+ Te as storyblokEditable,
867
+ Oe as storyblokInit,
868
+ Le as useStoryblokBridge
1148
869
  };