@storyblok/js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1527 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a2, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a2, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a2, prop, b[prop]);
16
+ }
17
+ return a2;
18
+ };
19
+ var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
20
+ let loaded = false;
21
+ const callbacks = [];
22
+ const loadBridge = (src) => {
23
+ window.storyblokRegisterEvent = (cb) => {
24
+ if (window.location === window.parent.location) {
25
+ console.warn("You are not in Draft Mode or in the Visual Editor.");
26
+ return;
27
+ }
28
+ if (!loaded)
29
+ callbacks.push(cb);
30
+ else
31
+ cb();
32
+ };
33
+ return new Promise((resolve, reject) => {
34
+ if (document.getElementById("storyblok-javascript-bridge"))
35
+ return;
36
+ const script = document.createElement("script");
37
+ script.async = true;
38
+ script.src = src;
39
+ script.id = "storyblok-javascript-bridge";
40
+ script.onerror = (error) => reject(error);
41
+ script.onload = (ev) => {
42
+ callbacks.forEach((cb) => cb());
43
+ loaded = true;
44
+ resolve(ev);
45
+ };
46
+ document.getElementsByTagName("head")[0].appendChild(script);
47
+ });
48
+ };
49
+ var axios$2 = { exports: {} };
50
+ var bind$2 = function bind(fn, thisArg) {
51
+ return function wrap() {
52
+ var args = new Array(arguments.length);
53
+ for (var i2 = 0; i2 < args.length; i2++) {
54
+ args[i2] = arguments[i2];
55
+ }
56
+ return fn.apply(thisArg, args);
57
+ };
58
+ };
59
+ var bind$1 = bind$2;
60
+ var toString = Object.prototype.toString;
61
+ function isArray(val) {
62
+ return toString.call(val) === "[object Array]";
63
+ }
64
+ function isUndefined(val) {
65
+ return typeof val === "undefined";
66
+ }
67
+ function isBuffer(val) {
68
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
69
+ }
70
+ function isArrayBuffer(val) {
71
+ return toString.call(val) === "[object ArrayBuffer]";
72
+ }
73
+ function isFormData(val) {
74
+ return typeof FormData !== "undefined" && val instanceof FormData;
75
+ }
76
+ function isArrayBufferView(val) {
77
+ var result;
78
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
79
+ result = ArrayBuffer.isView(val);
80
+ } else {
81
+ result = val && val.buffer && val.buffer instanceof ArrayBuffer;
82
+ }
83
+ return result;
84
+ }
85
+ function isString(val) {
86
+ return typeof val === "string";
87
+ }
88
+ function isNumber(val) {
89
+ return typeof val === "number";
90
+ }
91
+ function isObject(val) {
92
+ return val !== null && typeof val === "object";
93
+ }
94
+ function isPlainObject(val) {
95
+ if (toString.call(val) !== "[object Object]") {
96
+ return false;
97
+ }
98
+ var prototype = Object.getPrototypeOf(val);
99
+ return prototype === null || prototype === Object.prototype;
100
+ }
101
+ function isDate(val) {
102
+ return toString.call(val) === "[object Date]";
103
+ }
104
+ function isFile(val) {
105
+ return toString.call(val) === "[object File]";
106
+ }
107
+ function isBlob(val) {
108
+ return toString.call(val) === "[object Blob]";
109
+ }
110
+ function isFunction(val) {
111
+ return toString.call(val) === "[object Function]";
112
+ }
113
+ function isStream(val) {
114
+ return isObject(val) && isFunction(val.pipe);
115
+ }
116
+ function isURLSearchParams(val) {
117
+ return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
118
+ }
119
+ function trim(str) {
120
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
121
+ }
122
+ function isStandardBrowserEnv() {
123
+ if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
124
+ return false;
125
+ }
126
+ return typeof window !== "undefined" && typeof document !== "undefined";
127
+ }
128
+ function forEach(obj, fn) {
129
+ if (obj === null || typeof obj === "undefined") {
130
+ return;
131
+ }
132
+ if (typeof obj !== "object") {
133
+ obj = [obj];
134
+ }
135
+ if (isArray(obj)) {
136
+ for (var i2 = 0, l2 = obj.length; i2 < l2; i2++) {
137
+ fn.call(null, obj[i2], i2, obj);
138
+ }
139
+ } else {
140
+ for (var key in obj) {
141
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
142
+ fn.call(null, obj[key], key, obj);
143
+ }
144
+ }
145
+ }
146
+ }
147
+ function merge() {
148
+ var result = {};
149
+ function assignValue(val, key) {
150
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
151
+ result[key] = merge(result[key], val);
152
+ } else if (isPlainObject(val)) {
153
+ result[key] = merge({}, val);
154
+ } else if (isArray(val)) {
155
+ result[key] = val.slice();
156
+ } else {
157
+ result[key] = val;
158
+ }
159
+ }
160
+ for (var i2 = 0, l2 = arguments.length; i2 < l2; i2++) {
161
+ forEach(arguments[i2], assignValue);
162
+ }
163
+ return result;
164
+ }
165
+ function extend(a2, b, thisArg) {
166
+ forEach(b, function assignValue(val, key) {
167
+ if (thisArg && typeof val === "function") {
168
+ a2[key] = bind$1(val, thisArg);
169
+ } else {
170
+ a2[key] = val;
171
+ }
172
+ });
173
+ return a2;
174
+ }
175
+ function stripBOM(content) {
176
+ if (content.charCodeAt(0) === 65279) {
177
+ content = content.slice(1);
178
+ }
179
+ return content;
180
+ }
181
+ var utils$d = {
182
+ isArray,
183
+ isArrayBuffer,
184
+ isBuffer,
185
+ isFormData,
186
+ isArrayBufferView,
187
+ isString,
188
+ isNumber,
189
+ isObject,
190
+ isPlainObject,
191
+ isUndefined,
192
+ isDate,
193
+ isFile,
194
+ isBlob,
195
+ isFunction,
196
+ isStream,
197
+ isURLSearchParams,
198
+ isStandardBrowserEnv,
199
+ forEach,
200
+ merge,
201
+ extend,
202
+ trim,
203
+ stripBOM
204
+ };
205
+ var utils$c = utils$d;
206
+ function encode(val) {
207
+ return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
208
+ }
209
+ var buildURL$2 = function buildURL(url, params, paramsSerializer) {
210
+ if (!params) {
211
+ return url;
212
+ }
213
+ var serializedParams;
214
+ if (paramsSerializer) {
215
+ serializedParams = paramsSerializer(params);
216
+ } else if (utils$c.isURLSearchParams(params)) {
217
+ serializedParams = params.toString();
218
+ } else {
219
+ var parts = [];
220
+ utils$c.forEach(params, function serialize(val, key) {
221
+ if (val === null || typeof val === "undefined") {
222
+ return;
223
+ }
224
+ if (utils$c.isArray(val)) {
225
+ key = key + "[]";
226
+ } else {
227
+ val = [val];
228
+ }
229
+ utils$c.forEach(val, function parseValue(v) {
230
+ if (utils$c.isDate(v)) {
231
+ v = v.toISOString();
232
+ } else if (utils$c.isObject(v)) {
233
+ v = JSON.stringify(v);
234
+ }
235
+ parts.push(encode(key) + "=" + encode(v));
236
+ });
237
+ });
238
+ serializedParams = parts.join("&");
239
+ }
240
+ if (serializedParams) {
241
+ var hashmarkIndex = url.indexOf("#");
242
+ if (hashmarkIndex !== -1) {
243
+ url = url.slice(0, hashmarkIndex);
244
+ }
245
+ url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
246
+ }
247
+ return url;
248
+ };
249
+ var utils$b = utils$d;
250
+ function InterceptorManager$1() {
251
+ this.handlers = [];
252
+ }
253
+ InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) {
254
+ this.handlers.push({
255
+ fulfilled,
256
+ rejected,
257
+ synchronous: options ? options.synchronous : false,
258
+ runWhen: options ? options.runWhen : null
259
+ });
260
+ return this.handlers.length - 1;
261
+ };
262
+ InterceptorManager$1.prototype.eject = function eject(id) {
263
+ if (this.handlers[id]) {
264
+ this.handlers[id] = null;
265
+ }
266
+ };
267
+ InterceptorManager$1.prototype.forEach = function forEach2(fn) {
268
+ utils$b.forEach(this.handlers, function forEachHandler(h) {
269
+ if (h !== null) {
270
+ fn(h);
271
+ }
272
+ });
273
+ };
274
+ var InterceptorManager_1 = InterceptorManager$1;
275
+ var utils$a = utils$d;
276
+ var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
277
+ utils$a.forEach(headers, function processHeader(value, name2) {
278
+ if (name2 !== normalizedName && name2.toUpperCase() === normalizedName.toUpperCase()) {
279
+ headers[normalizedName] = value;
280
+ delete headers[name2];
281
+ }
282
+ });
283
+ };
284
+ var enhanceError$2 = function enhanceError(error, config, code, request2, response) {
285
+ error.config = config;
286
+ if (code) {
287
+ error.code = code;
288
+ }
289
+ error.request = request2;
290
+ error.response = response;
291
+ error.isAxiosError = true;
292
+ error.toJSON = function toJSON() {
293
+ return {
294
+ message: this.message,
295
+ name: this.name,
296
+ description: this.description,
297
+ number: this.number,
298
+ fileName: this.fileName,
299
+ lineNumber: this.lineNumber,
300
+ columnNumber: this.columnNumber,
301
+ stack: this.stack,
302
+ config: this.config,
303
+ code: this.code
304
+ };
305
+ };
306
+ return error;
307
+ };
308
+ var enhanceError$1 = enhanceError$2;
309
+ var createError$2 = function createError(message, config, code, request2, response) {
310
+ var error = new Error(message);
311
+ return enhanceError$1(error, config, code, request2, response);
312
+ };
313
+ var createError$1 = createError$2;
314
+ var settle$1 = function settle(resolve, reject, response) {
315
+ var validateStatus2 = response.config.validateStatus;
316
+ if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
317
+ resolve(response);
318
+ } else {
319
+ reject(createError$1("Request failed with status code " + response.status, response.config, null, response.request, response));
320
+ }
321
+ };
322
+ var utils$9 = utils$d;
323
+ var cookies$1 = utils$9.isStandardBrowserEnv() ? function standardBrowserEnv() {
324
+ return {
325
+ write: function write(name2, value, expires, path, domain, secure) {
326
+ var cookie = [];
327
+ cookie.push(name2 + "=" + encodeURIComponent(value));
328
+ if (utils$9.isNumber(expires)) {
329
+ cookie.push("expires=" + new Date(expires).toGMTString());
330
+ }
331
+ if (utils$9.isString(path)) {
332
+ cookie.push("path=" + path);
333
+ }
334
+ if (utils$9.isString(domain)) {
335
+ cookie.push("domain=" + domain);
336
+ }
337
+ if (secure === true) {
338
+ cookie.push("secure");
339
+ }
340
+ document.cookie = cookie.join("; ");
341
+ },
342
+ read: function read(name2) {
343
+ var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name2 + ")=([^;]*)"));
344
+ return match ? decodeURIComponent(match[3]) : null;
345
+ },
346
+ remove: function remove(name2) {
347
+ this.write(name2, "", Date.now() - 864e5);
348
+ }
349
+ };
350
+ }() : function nonStandardBrowserEnv() {
351
+ return {
352
+ write: function write() {
353
+ },
354
+ read: function read() {
355
+ return null;
356
+ },
357
+ remove: function remove() {
358
+ }
359
+ };
360
+ }();
361
+ var isAbsoluteURL$1 = function isAbsoluteURL(url) {
362
+ return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
363
+ };
364
+ var combineURLs$1 = function combineURLs(baseURL, relativeURL) {
365
+ return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
366
+ };
367
+ var isAbsoluteURL2 = isAbsoluteURL$1;
368
+ var combineURLs2 = combineURLs$1;
369
+ var buildFullPath$1 = function buildFullPath(baseURL, requestedURL) {
370
+ if (baseURL && !isAbsoluteURL2(requestedURL)) {
371
+ return combineURLs2(baseURL, requestedURL);
372
+ }
373
+ return requestedURL;
374
+ };
375
+ var utils$8 = utils$d;
376
+ var ignoreDuplicateOf = [
377
+ "age",
378
+ "authorization",
379
+ "content-length",
380
+ "content-type",
381
+ "etag",
382
+ "expires",
383
+ "from",
384
+ "host",
385
+ "if-modified-since",
386
+ "if-unmodified-since",
387
+ "last-modified",
388
+ "location",
389
+ "max-forwards",
390
+ "proxy-authorization",
391
+ "referer",
392
+ "retry-after",
393
+ "user-agent"
394
+ ];
395
+ var parseHeaders$1 = function parseHeaders(headers) {
396
+ var parsed = {};
397
+ var key;
398
+ var val;
399
+ var i2;
400
+ if (!headers) {
401
+ return parsed;
402
+ }
403
+ utils$8.forEach(headers.split("\n"), function parser(line) {
404
+ i2 = line.indexOf(":");
405
+ key = utils$8.trim(line.substr(0, i2)).toLowerCase();
406
+ val = utils$8.trim(line.substr(i2 + 1));
407
+ if (key) {
408
+ if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
409
+ return;
410
+ }
411
+ if (key === "set-cookie") {
412
+ parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
413
+ } else {
414
+ parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
415
+ }
416
+ }
417
+ });
418
+ return parsed;
419
+ };
420
+ var utils$7 = utils$d;
421
+ var isURLSameOrigin$1 = utils$7.isStandardBrowserEnv() ? function standardBrowserEnv2() {
422
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
423
+ var urlParsingNode = document.createElement("a");
424
+ var originURL;
425
+ function resolveURL(url) {
426
+ var href = url;
427
+ if (msie) {
428
+ urlParsingNode.setAttribute("href", href);
429
+ href = urlParsingNode.href;
430
+ }
431
+ urlParsingNode.setAttribute("href", href);
432
+ return {
433
+ href: urlParsingNode.href,
434
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
435
+ host: urlParsingNode.host,
436
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
437
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
438
+ hostname: urlParsingNode.hostname,
439
+ port: urlParsingNode.port,
440
+ pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
441
+ };
442
+ }
443
+ originURL = resolveURL(window.location.href);
444
+ return function isURLSameOrigin2(requestURL) {
445
+ var parsed = utils$7.isString(requestURL) ? resolveURL(requestURL) : requestURL;
446
+ return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
447
+ };
448
+ }() : function nonStandardBrowserEnv2() {
449
+ return function isURLSameOrigin2() {
450
+ return true;
451
+ };
452
+ }();
453
+ var utils$6 = utils$d;
454
+ var settle2 = settle$1;
455
+ var cookies = cookies$1;
456
+ var buildURL$1 = buildURL$2;
457
+ var buildFullPath2 = buildFullPath$1;
458
+ var parseHeaders2 = parseHeaders$1;
459
+ var isURLSameOrigin = isURLSameOrigin$1;
460
+ var createError2 = createError$2;
461
+ var xhr = function xhrAdapter(config) {
462
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
463
+ var requestData = config.data;
464
+ var requestHeaders = config.headers;
465
+ var responseType = config.responseType;
466
+ if (utils$6.isFormData(requestData)) {
467
+ delete requestHeaders["Content-Type"];
468
+ }
469
+ var request2 = new XMLHttpRequest();
470
+ if (config.auth) {
471
+ var username = config.auth.username || "";
472
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
473
+ requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
474
+ }
475
+ var fullPath = buildFullPath2(config.baseURL, config.url);
476
+ request2.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true);
477
+ request2.timeout = config.timeout;
478
+ function onloadend() {
479
+ if (!request2) {
480
+ return;
481
+ }
482
+ var responseHeaders = "getAllResponseHeaders" in request2 ? parseHeaders2(request2.getAllResponseHeaders()) : null;
483
+ var responseData = !responseType || responseType === "text" || responseType === "json" ? request2.responseText : request2.response;
484
+ var response = {
485
+ data: responseData,
486
+ status: request2.status,
487
+ statusText: request2.statusText,
488
+ headers: responseHeaders,
489
+ config,
490
+ request: request2
491
+ };
492
+ settle2(resolve, reject, response);
493
+ request2 = null;
494
+ }
495
+ if ("onloadend" in request2) {
496
+ request2.onloadend = onloadend;
497
+ } else {
498
+ request2.onreadystatechange = function handleLoad() {
499
+ if (!request2 || request2.readyState !== 4) {
500
+ return;
501
+ }
502
+ if (request2.status === 0 && !(request2.responseURL && request2.responseURL.indexOf("file:") === 0)) {
503
+ return;
504
+ }
505
+ setTimeout(onloadend);
506
+ };
507
+ }
508
+ request2.onabort = function handleAbort() {
509
+ if (!request2) {
510
+ return;
511
+ }
512
+ reject(createError2("Request aborted", config, "ECONNABORTED", request2));
513
+ request2 = null;
514
+ };
515
+ request2.onerror = function handleError() {
516
+ reject(createError2("Network Error", config, null, request2));
517
+ request2 = null;
518
+ };
519
+ request2.ontimeout = function handleTimeout() {
520
+ var timeoutErrorMessage = "timeout of " + config.timeout + "ms exceeded";
521
+ if (config.timeoutErrorMessage) {
522
+ timeoutErrorMessage = config.timeoutErrorMessage;
523
+ }
524
+ reject(createError2(timeoutErrorMessage, config, config.transitional && config.transitional.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", request2));
525
+ request2 = null;
526
+ };
527
+ if (utils$6.isStandardBrowserEnv()) {
528
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : void 0;
529
+ if (xsrfValue) {
530
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
531
+ }
532
+ }
533
+ if ("setRequestHeader" in request2) {
534
+ utils$6.forEach(requestHeaders, function setRequestHeader(val, key) {
535
+ if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
536
+ delete requestHeaders[key];
537
+ } else {
538
+ request2.setRequestHeader(key, val);
539
+ }
540
+ });
541
+ }
542
+ if (!utils$6.isUndefined(config.withCredentials)) {
543
+ request2.withCredentials = !!config.withCredentials;
544
+ }
545
+ if (responseType && responseType !== "json") {
546
+ request2.responseType = config.responseType;
547
+ }
548
+ if (typeof config.onDownloadProgress === "function") {
549
+ request2.addEventListener("progress", config.onDownloadProgress);
550
+ }
551
+ if (typeof config.onUploadProgress === "function" && request2.upload) {
552
+ request2.upload.addEventListener("progress", config.onUploadProgress);
553
+ }
554
+ if (config.cancelToken) {
555
+ config.cancelToken.promise.then(function onCanceled(cancel) {
556
+ if (!request2) {
557
+ return;
558
+ }
559
+ request2.abort();
560
+ reject(cancel);
561
+ request2 = null;
562
+ });
563
+ }
564
+ if (!requestData) {
565
+ requestData = null;
566
+ }
567
+ request2.send(requestData);
568
+ });
569
+ };
570
+ var utils$5 = utils$d;
571
+ var normalizeHeaderName2 = normalizeHeaderName$1;
572
+ var enhanceError2 = enhanceError$2;
573
+ var DEFAULT_CONTENT_TYPE = {
574
+ "Content-Type": "application/x-www-form-urlencoded"
575
+ };
576
+ function setContentTypeIfUnset(headers, value) {
577
+ if (!utils$5.isUndefined(headers) && utils$5.isUndefined(headers["Content-Type"])) {
578
+ headers["Content-Type"] = value;
579
+ }
580
+ }
581
+ function getDefaultAdapter() {
582
+ var adapter;
583
+ if (typeof XMLHttpRequest !== "undefined") {
584
+ adapter = xhr;
585
+ } else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
586
+ adapter = xhr;
587
+ }
588
+ return adapter;
589
+ }
590
+ function stringifySafely(rawValue, parser, encoder) {
591
+ if (utils$5.isString(rawValue)) {
592
+ try {
593
+ (parser || JSON.parse)(rawValue);
594
+ return utils$5.trim(rawValue);
595
+ } catch (e2) {
596
+ if (e2.name !== "SyntaxError") {
597
+ throw e2;
598
+ }
599
+ }
600
+ }
601
+ return (encoder || JSON.stringify)(rawValue);
602
+ }
603
+ var defaults$3 = {
604
+ transitional: {
605
+ silentJSONParsing: true,
606
+ forcedJSONParsing: true,
607
+ clarifyTimeoutError: false
608
+ },
609
+ adapter: getDefaultAdapter(),
610
+ transformRequest: [function transformRequest(data, headers) {
611
+ normalizeHeaderName2(headers, "Accept");
612
+ normalizeHeaderName2(headers, "Content-Type");
613
+ if (utils$5.isFormData(data) || utils$5.isArrayBuffer(data) || utils$5.isBuffer(data) || utils$5.isStream(data) || utils$5.isFile(data) || utils$5.isBlob(data)) {
614
+ return data;
615
+ }
616
+ if (utils$5.isArrayBufferView(data)) {
617
+ return data.buffer;
618
+ }
619
+ if (utils$5.isURLSearchParams(data)) {
620
+ setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8");
621
+ return data.toString();
622
+ }
623
+ if (utils$5.isObject(data) || headers && headers["Content-Type"] === "application/json") {
624
+ setContentTypeIfUnset(headers, "application/json");
625
+ return stringifySafely(data);
626
+ }
627
+ return data;
628
+ }],
629
+ transformResponse: [function transformResponse(data) {
630
+ var transitional2 = this.transitional;
631
+ var silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
632
+ var forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
633
+ var strictJSONParsing = !silentJSONParsing && this.responseType === "json";
634
+ if (strictJSONParsing || forcedJSONParsing && utils$5.isString(data) && data.length) {
635
+ try {
636
+ return JSON.parse(data);
637
+ } catch (e2) {
638
+ if (strictJSONParsing) {
639
+ if (e2.name === "SyntaxError") {
640
+ throw enhanceError2(e2, this, "E_JSON_PARSE");
641
+ }
642
+ throw e2;
643
+ }
644
+ }
645
+ }
646
+ return data;
647
+ }],
648
+ timeout: 0,
649
+ xsrfCookieName: "XSRF-TOKEN",
650
+ xsrfHeaderName: "X-XSRF-TOKEN",
651
+ maxContentLength: -1,
652
+ maxBodyLength: -1,
653
+ validateStatus: function validateStatus(status) {
654
+ return status >= 200 && status < 300;
655
+ }
656
+ };
657
+ defaults$3.headers = {
658
+ common: {
659
+ "Accept": "application/json, text/plain, */*"
660
+ }
661
+ };
662
+ utils$5.forEach(["delete", "get", "head"], function forEachMethodNoData(method) {
663
+ defaults$3.headers[method] = {};
664
+ });
665
+ utils$5.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
666
+ defaults$3.headers[method] = utils$5.merge(DEFAULT_CONTENT_TYPE);
667
+ });
668
+ var defaults_1 = defaults$3;
669
+ var utils$4 = utils$d;
670
+ var defaults$2 = defaults_1;
671
+ var transformData$1 = function transformData(data, headers, fns) {
672
+ var context = this || defaults$2;
673
+ utils$4.forEach(fns, function transform(fn) {
674
+ data = fn.call(context, data, headers);
675
+ });
676
+ return data;
677
+ };
678
+ var isCancel$1 = function isCancel(value) {
679
+ return !!(value && value.__CANCEL__);
680
+ };
681
+ var utils$3 = utils$d;
682
+ var transformData2 = transformData$1;
683
+ var isCancel2 = isCancel$1;
684
+ var defaults$1 = defaults_1;
685
+ function throwIfCancellationRequested(config) {
686
+ if (config.cancelToken) {
687
+ config.cancelToken.throwIfRequested();
688
+ }
689
+ }
690
+ var dispatchRequest$1 = function dispatchRequest(config) {
691
+ throwIfCancellationRequested(config);
692
+ config.headers = config.headers || {};
693
+ config.data = transformData2.call(config, config.data, config.headers, config.transformRequest);
694
+ config.headers = utils$3.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
695
+ utils$3.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
696
+ delete config.headers[method];
697
+ });
698
+ var adapter = config.adapter || defaults$1.adapter;
699
+ return adapter(config).then(function onAdapterResolution(response) {
700
+ throwIfCancellationRequested(config);
701
+ response.data = transformData2.call(config, response.data, response.headers, config.transformResponse);
702
+ return response;
703
+ }, function onAdapterRejection(reason) {
704
+ if (!isCancel2(reason)) {
705
+ throwIfCancellationRequested(config);
706
+ if (reason && reason.response) {
707
+ reason.response.data = transformData2.call(config, reason.response.data, reason.response.headers, config.transformResponse);
708
+ }
709
+ }
710
+ return Promise.reject(reason);
711
+ });
712
+ };
713
+ var utils$2 = utils$d;
714
+ var mergeConfig$2 = function mergeConfig(config1, config2) {
715
+ config2 = config2 || {};
716
+ var config = {};
717
+ var valueFromConfig2Keys = ["url", "method", "data"];
718
+ var mergeDeepPropertiesKeys = ["headers", "auth", "proxy", "params"];
719
+ var defaultToConfig2Keys = [
720
+ "baseURL",
721
+ "transformRequest",
722
+ "transformResponse",
723
+ "paramsSerializer",
724
+ "timeout",
725
+ "timeoutMessage",
726
+ "withCredentials",
727
+ "adapter",
728
+ "responseType",
729
+ "xsrfCookieName",
730
+ "xsrfHeaderName",
731
+ "onUploadProgress",
732
+ "onDownloadProgress",
733
+ "decompress",
734
+ "maxContentLength",
735
+ "maxBodyLength",
736
+ "maxRedirects",
737
+ "transport",
738
+ "httpAgent",
739
+ "httpsAgent",
740
+ "cancelToken",
741
+ "socketPath",
742
+ "responseEncoding"
743
+ ];
744
+ var directMergeKeys = ["validateStatus"];
745
+ function getMergedValue(target, source2) {
746
+ if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source2)) {
747
+ return utils$2.merge(target, source2);
748
+ } else if (utils$2.isPlainObject(source2)) {
749
+ return utils$2.merge({}, source2);
750
+ } else if (utils$2.isArray(source2)) {
751
+ return source2.slice();
752
+ }
753
+ return source2;
754
+ }
755
+ function mergeDeepProperties(prop) {
756
+ if (!utils$2.isUndefined(config2[prop])) {
757
+ config[prop] = getMergedValue(config1[prop], config2[prop]);
758
+ } else if (!utils$2.isUndefined(config1[prop])) {
759
+ config[prop] = getMergedValue(void 0, config1[prop]);
760
+ }
761
+ }
762
+ utils$2.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
763
+ if (!utils$2.isUndefined(config2[prop])) {
764
+ config[prop] = getMergedValue(void 0, config2[prop]);
765
+ }
766
+ });
767
+ utils$2.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
768
+ utils$2.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
769
+ if (!utils$2.isUndefined(config2[prop])) {
770
+ config[prop] = getMergedValue(void 0, config2[prop]);
771
+ } else if (!utils$2.isUndefined(config1[prop])) {
772
+ config[prop] = getMergedValue(void 0, config1[prop]);
773
+ }
774
+ });
775
+ utils$2.forEach(directMergeKeys, function merge2(prop) {
776
+ if (prop in config2) {
777
+ config[prop] = getMergedValue(config1[prop], config2[prop]);
778
+ } else if (prop in config1) {
779
+ config[prop] = getMergedValue(void 0, config1[prop]);
780
+ }
781
+ });
782
+ var axiosKeys = valueFromConfig2Keys.concat(mergeDeepPropertiesKeys).concat(defaultToConfig2Keys).concat(directMergeKeys);
783
+ var otherKeys = Object.keys(config1).concat(Object.keys(config2)).filter(function filterAxiosKeys(key) {
784
+ return axiosKeys.indexOf(key) === -1;
785
+ });
786
+ utils$2.forEach(otherKeys, mergeDeepProperties);
787
+ return config;
788
+ };
789
+ const name = "axios";
790
+ const version = "0.21.4";
791
+ const description = "Promise based HTTP client for the browser and node.js";
792
+ const main = "index.js";
793
+ const scripts = {
794
+ test: "grunt test",
795
+ start: "node ./sandbox/server.js",
796
+ build: "NODE_ENV=production grunt build",
797
+ preversion: "npm test",
798
+ version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
799
+ postversion: "git push && git push --tags",
800
+ examples: "node ./examples/server.js",
801
+ coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
802
+ fix: "eslint --fix lib/**/*.js"
803
+ };
804
+ const repository = {
805
+ type: "git",
806
+ url: "https://github.com/axios/axios.git"
807
+ };
808
+ const keywords = [
809
+ "xhr",
810
+ "http",
811
+ "ajax",
812
+ "promise",
813
+ "node"
814
+ ];
815
+ const author = "Matt Zabriskie";
816
+ const license = "MIT";
817
+ const bugs = {
818
+ url: "https://github.com/axios/axios/issues"
819
+ };
820
+ const homepage = "https://axios-http.com";
821
+ const devDependencies = {
822
+ coveralls: "^3.0.0",
823
+ "es6-promise": "^4.2.4",
824
+ grunt: "^1.3.0",
825
+ "grunt-banner": "^0.6.0",
826
+ "grunt-cli": "^1.2.0",
827
+ "grunt-contrib-clean": "^1.1.0",
828
+ "grunt-contrib-watch": "^1.0.0",
829
+ "grunt-eslint": "^23.0.0",
830
+ "grunt-karma": "^4.0.0",
831
+ "grunt-mocha-test": "^0.13.3",
832
+ "grunt-ts": "^6.0.0-beta.19",
833
+ "grunt-webpack": "^4.0.2",
834
+ "istanbul-instrumenter-loader": "^1.0.0",
835
+ "jasmine-core": "^2.4.1",
836
+ karma: "^6.3.2",
837
+ "karma-chrome-launcher": "^3.1.0",
838
+ "karma-firefox-launcher": "^2.1.0",
839
+ "karma-jasmine": "^1.1.1",
840
+ "karma-jasmine-ajax": "^0.1.13",
841
+ "karma-safari-launcher": "^1.0.0",
842
+ "karma-sauce-launcher": "^4.3.6",
843
+ "karma-sinon": "^1.0.5",
844
+ "karma-sourcemap-loader": "^0.3.8",
845
+ "karma-webpack": "^4.0.2",
846
+ "load-grunt-tasks": "^3.5.2",
847
+ minimist: "^1.2.0",
848
+ mocha: "^8.2.1",
849
+ sinon: "^4.5.0",
850
+ "terser-webpack-plugin": "^4.2.3",
851
+ typescript: "^4.0.5",
852
+ "url-search-params": "^0.10.0",
853
+ webpack: "^4.44.2",
854
+ "webpack-dev-server": "^3.11.0"
855
+ };
856
+ const browser = {
857
+ "./lib/adapters/http.js": "./lib/adapters/xhr.js"
858
+ };
859
+ const jsdelivr = "dist/axios.min.js";
860
+ const unpkg = "dist/axios.min.js";
861
+ const typings = "./index.d.ts";
862
+ const dependencies = {
863
+ "follow-redirects": "^1.14.0"
864
+ };
865
+ const bundlesize = [
866
+ {
867
+ path: "./dist/axios.min.js",
868
+ threshold: "5kB"
869
+ }
870
+ ];
871
+ var require$$0 = {
872
+ name,
873
+ version,
874
+ description,
875
+ main,
876
+ scripts,
877
+ repository,
878
+ keywords,
879
+ author,
880
+ license,
881
+ bugs,
882
+ homepage,
883
+ devDependencies,
884
+ browser,
885
+ jsdelivr,
886
+ unpkg,
887
+ typings,
888
+ dependencies,
889
+ bundlesize
890
+ };
891
+ var pkg = require$$0;
892
+ var validators$1 = {};
893
+ ["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i2) {
894
+ validators$1[type] = function validator2(thing) {
895
+ return typeof thing === type || "a" + (i2 < 1 ? "n " : " ") + type;
896
+ };
897
+ });
898
+ var deprecatedWarnings = {};
899
+ var currentVerArr = pkg.version.split(".");
900
+ function isOlderVersion(version2, thanVersion) {
901
+ var pkgVersionArr = thanVersion ? thanVersion.split(".") : currentVerArr;
902
+ var destVer = version2.split(".");
903
+ for (var i2 = 0; i2 < 3; i2++) {
904
+ if (pkgVersionArr[i2] > destVer[i2]) {
905
+ return true;
906
+ } else if (pkgVersionArr[i2] < destVer[i2]) {
907
+ return false;
908
+ }
909
+ }
910
+ return false;
911
+ }
912
+ validators$1.transitional = function transitional(validator2, version2, message) {
913
+ var isDeprecated = version2 && isOlderVersion(version2);
914
+ function formatMessage(opt, desc) {
915
+ return "[Axios v" + pkg.version + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
916
+ }
917
+ return function(value, opt, opts) {
918
+ if (validator2 === false) {
919
+ throw new Error(formatMessage(opt, " has been removed in " + version2));
920
+ }
921
+ if (isDeprecated && !deprecatedWarnings[opt]) {
922
+ deprecatedWarnings[opt] = true;
923
+ console.warn(formatMessage(opt, " has been deprecated since v" + version2 + " and will be removed in the near future"));
924
+ }
925
+ return validator2 ? validator2(value, opt, opts) : true;
926
+ };
927
+ };
928
+ function assertOptions(options, schema, allowUnknown) {
929
+ if (typeof options !== "object") {
930
+ throw new TypeError("options must be an object");
931
+ }
932
+ var keys = Object.keys(options);
933
+ var i2 = keys.length;
934
+ while (i2-- > 0) {
935
+ var opt = keys[i2];
936
+ var validator2 = schema[opt];
937
+ if (validator2) {
938
+ var value = options[opt];
939
+ var result = value === void 0 || validator2(value, opt, options);
940
+ if (result !== true) {
941
+ throw new TypeError("option " + opt + " must be " + result);
942
+ }
943
+ continue;
944
+ }
945
+ if (allowUnknown !== true) {
946
+ throw Error("Unknown option " + opt);
947
+ }
948
+ }
949
+ }
950
+ var validator$1 = {
951
+ isOlderVersion,
952
+ assertOptions,
953
+ validators: validators$1
954
+ };
955
+ var utils$1 = utils$d;
956
+ var buildURL2 = buildURL$2;
957
+ var InterceptorManager = InterceptorManager_1;
958
+ var dispatchRequest2 = dispatchRequest$1;
959
+ var mergeConfig$1 = mergeConfig$2;
960
+ var validator = validator$1;
961
+ var validators = validator.validators;
962
+ function Axios$1(instanceConfig) {
963
+ this.defaults = instanceConfig;
964
+ this.interceptors = {
965
+ request: new InterceptorManager(),
966
+ response: new InterceptorManager()
967
+ };
968
+ }
969
+ Axios$1.prototype.request = function request(config) {
970
+ if (typeof config === "string") {
971
+ config = arguments[1] || {};
972
+ config.url = arguments[0];
973
+ } else {
974
+ config = config || {};
975
+ }
976
+ config = mergeConfig$1(this.defaults, config);
977
+ if (config.method) {
978
+ config.method = config.method.toLowerCase();
979
+ } else if (this.defaults.method) {
980
+ config.method = this.defaults.method.toLowerCase();
981
+ } else {
982
+ config.method = "get";
983
+ }
984
+ var transitional2 = config.transitional;
985
+ if (transitional2 !== void 0) {
986
+ validator.assertOptions(transitional2, {
987
+ silentJSONParsing: validators.transitional(validators.boolean, "1.0.0"),
988
+ forcedJSONParsing: validators.transitional(validators.boolean, "1.0.0"),
989
+ clarifyTimeoutError: validators.transitional(validators.boolean, "1.0.0")
990
+ }, false);
991
+ }
992
+ var requestInterceptorChain = [];
993
+ var synchronousRequestInterceptors = true;
994
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
995
+ if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
996
+ return;
997
+ }
998
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
999
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
1000
+ });
1001
+ var responseInterceptorChain = [];
1002
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
1003
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
1004
+ });
1005
+ var promise;
1006
+ if (!synchronousRequestInterceptors) {
1007
+ var chain = [dispatchRequest2, void 0];
1008
+ Array.prototype.unshift.apply(chain, requestInterceptorChain);
1009
+ chain = chain.concat(responseInterceptorChain);
1010
+ promise = Promise.resolve(config);
1011
+ while (chain.length) {
1012
+ promise = promise.then(chain.shift(), chain.shift());
1013
+ }
1014
+ return promise;
1015
+ }
1016
+ var newConfig = config;
1017
+ while (requestInterceptorChain.length) {
1018
+ var onFulfilled = requestInterceptorChain.shift();
1019
+ var onRejected = requestInterceptorChain.shift();
1020
+ try {
1021
+ newConfig = onFulfilled(newConfig);
1022
+ } catch (error) {
1023
+ onRejected(error);
1024
+ break;
1025
+ }
1026
+ }
1027
+ try {
1028
+ promise = dispatchRequest2(newConfig);
1029
+ } catch (error) {
1030
+ return Promise.reject(error);
1031
+ }
1032
+ while (responseInterceptorChain.length) {
1033
+ promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
1034
+ }
1035
+ return promise;
1036
+ };
1037
+ Axios$1.prototype.getUri = function getUri(config) {
1038
+ config = mergeConfig$1(this.defaults, config);
1039
+ return buildURL2(config.url, config.params, config.paramsSerializer).replace(/^\?/, "");
1040
+ };
1041
+ utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData2(method) {
1042
+ Axios$1.prototype[method] = function(url, config) {
1043
+ return this.request(mergeConfig$1(config || {}, {
1044
+ method,
1045
+ url,
1046
+ data: (config || {}).data
1047
+ }));
1048
+ };
1049
+ });
1050
+ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData2(method) {
1051
+ Axios$1.prototype[method] = function(url, data, config) {
1052
+ return this.request(mergeConfig$1(config || {}, {
1053
+ method,
1054
+ url,
1055
+ data
1056
+ }));
1057
+ };
1058
+ });
1059
+ var Axios_1 = Axios$1;
1060
+ function Cancel$1(message) {
1061
+ this.message = message;
1062
+ }
1063
+ Cancel$1.prototype.toString = function toString2() {
1064
+ return "Cancel" + (this.message ? ": " + this.message : "");
1065
+ };
1066
+ Cancel$1.prototype.__CANCEL__ = true;
1067
+ var Cancel_1 = Cancel$1;
1068
+ var Cancel = Cancel_1;
1069
+ function CancelToken(executor) {
1070
+ if (typeof executor !== "function") {
1071
+ throw new TypeError("executor must be a function.");
1072
+ }
1073
+ var resolvePromise;
1074
+ this.promise = new Promise(function promiseExecutor(resolve) {
1075
+ resolvePromise = resolve;
1076
+ });
1077
+ var token = this;
1078
+ executor(function cancel(message) {
1079
+ if (token.reason) {
1080
+ return;
1081
+ }
1082
+ token.reason = new Cancel(message);
1083
+ resolvePromise(token.reason);
1084
+ });
1085
+ }
1086
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
1087
+ if (this.reason) {
1088
+ throw this.reason;
1089
+ }
1090
+ };
1091
+ CancelToken.source = function source() {
1092
+ var cancel;
1093
+ var token = new CancelToken(function executor(c2) {
1094
+ cancel = c2;
1095
+ });
1096
+ return {
1097
+ token,
1098
+ cancel
1099
+ };
1100
+ };
1101
+ var CancelToken_1 = CancelToken;
1102
+ var spread = function spread2(callback) {
1103
+ return function wrap(arr) {
1104
+ return callback.apply(null, arr);
1105
+ };
1106
+ };
1107
+ var isAxiosError = function isAxiosError2(payload) {
1108
+ return typeof payload === "object" && payload.isAxiosError === true;
1109
+ };
1110
+ var utils = utils$d;
1111
+ var bind2 = bind$2;
1112
+ var Axios = Axios_1;
1113
+ var mergeConfig2 = mergeConfig$2;
1114
+ var defaults = defaults_1;
1115
+ function createInstance(defaultConfig) {
1116
+ var context = new Axios(defaultConfig);
1117
+ var instance = bind2(Axios.prototype.request, context);
1118
+ utils.extend(instance, Axios.prototype, context);
1119
+ utils.extend(instance, context);
1120
+ return instance;
1121
+ }
1122
+ var axios$1 = createInstance(defaults);
1123
+ axios$1.Axios = Axios;
1124
+ axios$1.create = function create(instanceConfig) {
1125
+ return createInstance(mergeConfig2(axios$1.defaults, instanceConfig));
1126
+ };
1127
+ axios$1.Cancel = Cancel_1;
1128
+ axios$1.CancelToken = CancelToken_1;
1129
+ axios$1.isCancel = isCancel$1;
1130
+ axios$1.all = function all(promises) {
1131
+ return Promise.all(promises);
1132
+ };
1133
+ axios$1.spread = spread;
1134
+ axios$1.isAxiosError = isAxiosError;
1135
+ axios$2.exports = axios$1;
1136
+ axios$2.exports.default = axios$1;
1137
+ var axios = axios$2.exports;
1138
+ /*!
1139
+ * storyblok-js-client v0.0.0-development
1140
+ * Universal JavaScript SDK for Storyblok's API
1141
+ * (c) 2020-2022 Stobylok Team
1142
+ */
1143
+ function e(t) {
1144
+ return typeof t == "number" && (t == t && t !== 1 / 0 && t !== -1 / 0);
1145
+ }
1146
+ function r(t, r2, s2) {
1147
+ if (!e(r2))
1148
+ throw new TypeError("Expected `limit` to be a finite number");
1149
+ if (!e(s2))
1150
+ throw new TypeError("Expected `interval` to be a finite number");
1151
+ var n2 = [], i2 = [], o2 = 0, a2 = function() {
1152
+ o2++;
1153
+ var e2 = setTimeout(function() {
1154
+ o2--, n2.length > 0 && a2(), i2 = i2.filter(function(t2) {
1155
+ return t2 !== e2;
1156
+ });
1157
+ }, s2);
1158
+ i2.indexOf(e2) < 0 && i2.push(e2);
1159
+ var r3 = n2.shift();
1160
+ r3.resolve(t.apply(r3.self, r3.args));
1161
+ }, l2 = function() {
1162
+ var t2 = arguments, e2 = this;
1163
+ return new Promise(function(s3, i3) {
1164
+ n2.push({ resolve: s3, reject: i3, args: t2, self: e2 }), o2 < r2 && a2();
1165
+ });
1166
+ };
1167
+ return l2.abort = function() {
1168
+ i2.forEach(clearTimeout), i2 = [], n2.forEach(function(t2) {
1169
+ t2.reject(new throttle.AbortError());
1170
+ }), n2.length = 0;
1171
+ }, l2;
1172
+ }
1173
+ r.AbortError = function() {
1174
+ Error.call(this, "Throttled function aborted"), this.name = "AbortError";
1175
+ };
1176
+ const s = function(t, e2) {
1177
+ if (!t)
1178
+ return null;
1179
+ let r2 = {};
1180
+ for (let s2 in t) {
1181
+ let n2 = t[s2];
1182
+ e2.indexOf(s2) > -1 && n2 !== null && (r2[s2] = n2);
1183
+ }
1184
+ return r2;
1185
+ };
1186
+ var n = { nodes: { horizontal_rule: (t) => ({ singleTag: "hr" }), blockquote: (t) => ({ tag: "blockquote" }), bullet_list: (t) => ({ tag: "ul" }), code_block: (t) => ({ tag: ["pre", { tag: "code", attrs: t.attrs }] }), hard_break: (t) => ({ singleTag: "br" }), heading: (t) => ({ tag: "h" + t.attrs.level }), image: (t) => ({ singleTag: [{ tag: "img", attrs: s(t.attrs, ["src", "alt", "title"]) }] }), list_item: (t) => ({ tag: "li" }), ordered_list: (t) => ({ tag: "ol" }), paragraph: (t) => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(t) {
1187
+ const e2 = __spreadValues({}, t.attrs), { linktype: r2 = "url" } = t.attrs;
1188
+ return r2 === "email" && (e2.href = "mailto:" + e2.href), e2.anchor && (e2.href = `${e2.href}#${e2.anchor}`, delete e2.anchor), { tag: [{ tag: "a", attrs: e2 }] };
1189
+ }, styled: (t) => ({ tag: [{ tag: "span", attrs: t.attrs }] }) } };
1190
+ class i {
1191
+ constructor(t) {
1192
+ t || (t = n), this.marks = t.marks || [], this.nodes = t.nodes || [];
1193
+ }
1194
+ addNode(t, e2) {
1195
+ this.nodes[t] = e2;
1196
+ }
1197
+ addMark(t, e2) {
1198
+ this.marks[t] = e2;
1199
+ }
1200
+ render(t = {}) {
1201
+ if (t.content && Array.isArray(t.content)) {
1202
+ let e2 = "";
1203
+ return t.content.forEach((t2) => {
1204
+ e2 += this.renderNode(t2);
1205
+ }), e2;
1206
+ }
1207
+ return console.warn("The render method must receive an object with a content field, which is an array"), "";
1208
+ }
1209
+ renderNode(t) {
1210
+ let e2 = [];
1211
+ t.marks && t.marks.forEach((t2) => {
1212
+ const r3 = this.getMatchingMark(t2);
1213
+ r3 && e2.push(this.renderOpeningTag(r3.tag));
1214
+ });
1215
+ const r2 = this.getMatchingNode(t);
1216
+ return r2 && r2.tag && e2.push(this.renderOpeningTag(r2.tag)), t.content ? t.content.forEach((t2) => {
1217
+ e2.push(this.renderNode(t2));
1218
+ }) : t.text ? e2.push(function(t2) {
1219
+ const e3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, r3 = /[&<>"']/g, s2 = RegExp(r3.source);
1220
+ return t2 && s2.test(t2) ? t2.replace(r3, (t3) => e3[t3]) : t2;
1221
+ }(t.text)) : r2 && r2.singleTag ? e2.push(this.renderTag(r2.singleTag, " /")) : r2 && r2.html && e2.push(r2.html), r2 && r2.tag && e2.push(this.renderClosingTag(r2.tag)), t.marks && t.marks.slice(0).reverse().forEach((t2) => {
1222
+ const r3 = this.getMatchingMark(t2);
1223
+ r3 && e2.push(this.renderClosingTag(r3.tag));
1224
+ }), e2.join("");
1225
+ }
1226
+ renderTag(t, e2) {
1227
+ if (t.constructor === String)
1228
+ return `<${t}${e2}>`;
1229
+ return t.map((t2) => {
1230
+ if (t2.constructor === String)
1231
+ return `<${t2}${e2}>`;
1232
+ {
1233
+ let r2 = "<" + t2.tag;
1234
+ if (t2.attrs)
1235
+ for (let e3 in t2.attrs) {
1236
+ let s2 = t2.attrs[e3];
1237
+ s2 !== null && (r2 += ` ${e3}="${s2}"`);
1238
+ }
1239
+ return `${r2}${e2}>`;
1240
+ }
1241
+ }).join("");
1242
+ }
1243
+ renderOpeningTag(t) {
1244
+ return this.renderTag(t, "");
1245
+ }
1246
+ renderClosingTag(t) {
1247
+ if (t.constructor === String)
1248
+ return `</${t}>`;
1249
+ return t.slice(0).reverse().map((t2) => t2.constructor === String ? `</${t2}>` : `</${t2.tag}>`).join("");
1250
+ }
1251
+ getMatchingNode(t) {
1252
+ if (typeof this.nodes[t.type] == "function")
1253
+ return this.nodes[t.type](t);
1254
+ }
1255
+ getMatchingMark(t) {
1256
+ if (typeof this.marks[t.type] == "function")
1257
+ return this.marks[t.type](t);
1258
+ }
1259
+ }
1260
+ const o = (t = 0, e2 = t) => {
1261
+ const r2 = Math.abs(e2 - t) || 0, s2 = t < e2 ? 1 : -1;
1262
+ return ((t2 = 0, e3) => [...Array(t2)].map(e3))(r2, (e3, r3) => r3 * s2 + t);
1263
+ }, a = (t, e2, r2) => {
1264
+ const s2 = [];
1265
+ for (const n2 in t) {
1266
+ if (!Object.prototype.hasOwnProperty.call(t, n2))
1267
+ continue;
1268
+ const i2 = t[n2], o2 = r2 ? "" : encodeURIComponent(n2);
1269
+ let l2;
1270
+ l2 = typeof i2 == "object" ? a(i2, e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(i2)) : (e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(i2), s2.push(l2);
1271
+ }
1272
+ return s2.join("&");
1273
+ };
1274
+ let l = {}, c = {};
1275
+ class StoryblokClient {
1276
+ constructor(e2, s2) {
1277
+ if (!s2) {
1278
+ let t = e2.region ? "-" + e2.region : "", r2 = e2.https === false ? "http" : "https";
1279
+ s2 = e2.oauthToken === void 0 ? `${r2}://api${t}.storyblok.com/v2` : `${r2}://api${t}.storyblok.com/v1`;
1280
+ }
1281
+ let n2 = Object.assign({}, e2.headers), o2 = 5;
1282
+ e2.oauthToken !== void 0 && (n2.Authorization = e2.oauthToken, o2 = 3), e2.rateLimit !== void 0 && (o2 = e2.rateLimit), this.richTextResolver = new i(e2.richTextSchema), typeof e2.componentResolver == "function" && this.setComponentResolver(e2.componentResolver), this.maxRetries = e2.maxRetries || 5, this.throttle = r(this.throttledRequest, o2, 1e3), this.accessToken = e2.accessToken, this.relations = {}, this.links = {}, this.cache = e2.cache || { clear: "manual" }, this.client = axios.create({ baseURL: s2, timeout: e2.timeout || 0, headers: n2, proxy: e2.proxy || false }), e2.responseInterceptor && this.client.interceptors.response.use((t) => e2.responseInterceptor(t));
1283
+ }
1284
+ setComponentResolver(t) {
1285
+ this.richTextResolver.addNode("blok", (e2) => {
1286
+ let r2 = "";
1287
+ return e2.attrs.body.forEach((e3) => {
1288
+ r2 += t(e3.component, e3);
1289
+ }), { html: r2 };
1290
+ });
1291
+ }
1292
+ parseParams(t = {}) {
1293
+ return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = c[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
1294
+ }
1295
+ factoryParamOptions(t, e2 = {}) {
1296
+ return ((t2 = "") => t2.indexOf("/cdn/") > -1)(t) ? this.parseParams(e2) : e2;
1297
+ }
1298
+ makeRequest(t, e2, r2, s2) {
1299
+ const n2 = this.factoryParamOptions(t, ((t2 = {}, e3 = 25, r3 = 1) => __spreadProps(__spreadValues({}, t2), { per_page: e3, page: r3 }))(e2, r2, s2));
1300
+ return this.cacheResponse(t, n2);
1301
+ }
1302
+ get(t, e2) {
1303
+ let r2 = "/" + t;
1304
+ const s2 = this.factoryParamOptions(r2, e2);
1305
+ return this.cacheResponse(r2, s2);
1306
+ }
1307
+ async getAll(t, e2 = {}, r2) {
1308
+ const s2 = e2.per_page || 25, n2 = "/" + t, i2 = n2.split("/");
1309
+ r2 = r2 || i2[i2.length - 1];
1310
+ const a2 = await this.makeRequest(n2, e2, s2, 1), l2 = Math.ceil(a2.total / s2);
1311
+ return ((t2 = [], e3) => t2.map(e3).reduce((t3, e4) => [...t3, ...e4], []))([a2, ...await (async (t2 = [], e3) => Promise.all(t2.map(e3)))(o(1, l2), async (t2) => this.makeRequest(n2, e2, s2, t2 + 1))], (t2) => Object.values(t2.data[r2]));
1312
+ }
1313
+ post(t, e2) {
1314
+ let r2 = "/" + t;
1315
+ return this.throttle("post", r2, e2);
1316
+ }
1317
+ put(t, e2) {
1318
+ let r2 = "/" + t;
1319
+ return this.throttle("put", r2, e2);
1320
+ }
1321
+ delete(t, e2) {
1322
+ let r2 = "/" + t;
1323
+ return this.throttle("delete", r2, e2);
1324
+ }
1325
+ getStories(t) {
1326
+ return this.get("cdn/stories", t);
1327
+ }
1328
+ getStory(t, e2) {
1329
+ return this.get("cdn/stories/" + t, e2);
1330
+ }
1331
+ setToken(t) {
1332
+ this.accessToken = t;
1333
+ }
1334
+ getToken() {
1335
+ return this.accessToken;
1336
+ }
1337
+ _cleanCopy(t) {
1338
+ return JSON.parse(JSON.stringify(t));
1339
+ }
1340
+ _insertLinks(t, e2) {
1341
+ const r2 = t[e2];
1342
+ r2 && r2.fieldtype == "multilink" && r2.linktype == "story" && typeof r2.id == "string" && this.links[r2.id] ? r2.story = this._cleanCopy(this.links[r2.id]) : r2 && r2.linktype === "story" && typeof r2.uuid == "string" && this.links[r2.uuid] && (r2.story = this._cleanCopy(this.links[r2.uuid]));
1343
+ }
1344
+ _insertRelations(t, e2, r2) {
1345
+ if (r2.indexOf(t.component + "." + e2) > -1) {
1346
+ if (typeof t[e2] == "string")
1347
+ this.relations[t[e2]] && (t[e2] = this._cleanCopy(this.relations[t[e2]]));
1348
+ else if (t[e2].constructor === Array) {
1349
+ let r3 = [];
1350
+ t[e2].forEach((t2) => {
1351
+ this.relations[t2] && r3.push(this._cleanCopy(this.relations[t2]));
1352
+ }), t[e2] = r3;
1353
+ }
1354
+ }
1355
+ }
1356
+ iterateTree(t, e2) {
1357
+ let r2 = (t2) => {
1358
+ if (t2 != null) {
1359
+ if (t2.constructor === Array)
1360
+ for (let e3 = 0; e3 < t2.length; e3++)
1361
+ r2(t2[e3]);
1362
+ else if (t2.constructor === Object) {
1363
+ if (t2._stopResolving)
1364
+ return;
1365
+ for (let s2 in t2)
1366
+ (t2.component && t2._uid || t2.type === "link") && (this._insertRelations(t2, s2, e2), this._insertLinks(t2, s2)), r2(t2[s2]);
1367
+ }
1368
+ }
1369
+ };
1370
+ r2(t.content);
1371
+ }
1372
+ async resolveLinks(t, e2) {
1373
+ let r2 = [];
1374
+ if (t.link_uuids) {
1375
+ const s2 = t.link_uuids.length;
1376
+ let n2 = [];
1377
+ const i2 = 50;
1378
+ for (let e3 = 0; e3 < s2; e3 += i2) {
1379
+ const r3 = Math.min(s2, e3 + i2);
1380
+ n2.push(t.link_uuids.slice(e3, r3));
1381
+ }
1382
+ for (let t2 = 0; t2 < n2.length; t2++) {
1383
+ (await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t2].join(",") })).data.stories.forEach((t3) => {
1384
+ r2.push(t3);
1385
+ });
1386
+ }
1387
+ } else
1388
+ r2 = t.links;
1389
+ r2.forEach((t2) => {
1390
+ this.links[t2.uuid] = __spreadProps(__spreadValues({}, t2), { _stopResolving: true });
1391
+ });
1392
+ }
1393
+ async resolveRelations(t, e2) {
1394
+ let r2 = [];
1395
+ if (t.rel_uuids) {
1396
+ const s2 = t.rel_uuids.length;
1397
+ let n2 = [];
1398
+ const i2 = 50;
1399
+ for (let e3 = 0; e3 < s2; e3 += i2) {
1400
+ const r3 = Math.min(s2, e3 + i2);
1401
+ n2.push(t.rel_uuids.slice(e3, r3));
1402
+ }
1403
+ for (let t2 = 0; t2 < n2.length; t2++) {
1404
+ (await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t2].join(",") })).data.stories.forEach((t3) => {
1405
+ r2.push(t3);
1406
+ });
1407
+ }
1408
+ } else
1409
+ r2 = t.rels;
1410
+ r2.forEach((t2) => {
1411
+ this.relations[t2.uuid] = __spreadProps(__spreadValues({}, t2), { _stopResolving: true });
1412
+ });
1413
+ }
1414
+ async resolveStories(t, e2) {
1415
+ let r2 = [];
1416
+ e2.resolve_relations !== void 0 && e2.resolve_relations.length > 0 && (r2 = e2.resolve_relations.split(","), await this.resolveRelations(t, e2)), ["1", "story", "url"].indexOf(e2.resolve_links) > -1 && await this.resolveLinks(t, e2);
1417
+ for (const t2 in this.relations)
1418
+ this.iterateTree(this.relations[t2], r2);
1419
+ t.story ? this.iterateTree(t.story, r2) : t.stories.forEach((t2) => {
1420
+ this.iterateTree(t2, r2);
1421
+ });
1422
+ }
1423
+ cacheResponse(t, e2, r2) {
1424
+ return r2 === void 0 && (r2 = 0), new Promise(async (s2, n2) => {
1425
+ let i2 = a({ url: t, params: e2 }), o2 = this.cacheProvider();
1426
+ if (this.cache.clear === "auto" && e2.version === "draft" && await this.flushCache(), e2.version === "published" && t != "/cdn/spaces/me") {
1427
+ const t2 = await o2.get(i2);
1428
+ if (t2)
1429
+ return s2(t2);
1430
+ }
1431
+ try {
1432
+ let r3 = await this.throttle("get", t, { params: e2, paramsSerializer: (t2) => a(t2) }), l3 = { data: r3.data, headers: r3.headers };
1433
+ if (r3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(r3.headers["per-page"]), total: parseInt(r3.headers.total) })), r3.status != 200)
1434
+ return n2(r3);
1435
+ (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, e2), e2.version === "published" && t != "/cdn/spaces/me" && o2.set(i2, l3), l3.data.cv && (e2.version == "draft" && c[e2.token] != l3.data.cv && this.flushCache(), c[e2.token] = l3.data.cv), s2(l3);
1436
+ } catch (i3) {
1437
+ if (i3.response && i3.response.status === 429 && (r2 += 1) < this.maxRetries)
1438
+ return console.log(`Hit rate limit. Retrying in ${r2} seconds.`), await (l2 = 1e3 * r2, new Promise((t2) => setTimeout(t2, l2))), this.cacheResponse(t, e2, r2).then(s2).catch(n2);
1439
+ n2(i3);
1440
+ }
1441
+ var l2;
1442
+ });
1443
+ }
1444
+ throttledRequest(t, e2, r2) {
1445
+ return this.client[t](e2, r2);
1446
+ }
1447
+ cacheVersions() {
1448
+ return c;
1449
+ }
1450
+ cacheVersion() {
1451
+ return c[this.accessToken];
1452
+ }
1453
+ setCacheVersion(t) {
1454
+ this.accessToken && (c[this.accessToken] = t);
1455
+ }
1456
+ cacheProvider() {
1457
+ switch (this.cache.type) {
1458
+ case "memory":
1459
+ return { get: (t) => l[t], getAll: () => l, set(t, e2) {
1460
+ l[t] = e2;
1461
+ }, flush() {
1462
+ l = {};
1463
+ } };
1464
+ default:
1465
+ return { get() {
1466
+ }, getAll() {
1467
+ }, set() {
1468
+ }, flush() {
1469
+ } };
1470
+ }
1471
+ }
1472
+ async flushCache() {
1473
+ return await this.cacheProvider().flush(), this;
1474
+ }
1475
+ }
1476
+ var api = (options = {}) => {
1477
+ const { apiOptions } = options;
1478
+ if (!apiOptions.accessToken) {
1479
+ console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");
1480
+ return;
1481
+ }
1482
+ const storyblokApi = new StoryblokClient(apiOptions);
1483
+ return { storyblokApi };
1484
+ };
1485
+ var editable = (blok) => {
1486
+ if (typeof blok !== "object" || typeof blok._editable === "undefined") {
1487
+ return {};
1488
+ }
1489
+ const options = JSON.parse(blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
1490
+ return {
1491
+ "data-blok-c": JSON.stringify(options),
1492
+ "data-blok-uid": options.id + "-" + options.uid
1493
+ };
1494
+ };
1495
+ const useStoryblokBridge = (id, cb, options = {}) => {
1496
+ if (typeof window === "undefined") {
1497
+ return;
1498
+ }
1499
+ if (typeof window.storyblokRegisterEvent === "undefined") {
1500
+ console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
1501
+ return;
1502
+ }
1503
+ window.storyblokRegisterEvent(() => {
1504
+ const sbBridge = new window.StoryblokBridge(options);
1505
+ sbBridge.on(["input", "published", "change"], (event) => {
1506
+ if (event.action == "input" && event.story.id === id) {
1507
+ cb(event.story);
1508
+ } else {
1509
+ window.location.reload();
1510
+ }
1511
+ });
1512
+ });
1513
+ };
1514
+ const storyblokInit = (pluginOptions = {}) => {
1515
+ const { bridge, accessToken, use: use2 = [], apiOptions = {} } = pluginOptions;
1516
+ apiOptions.accessToken = apiOptions.accessToken || accessToken;
1517
+ const options = { bridge, apiOptions };
1518
+ let result = {};
1519
+ use2.forEach((pluginFactory) => {
1520
+ result = __spreadValues(__spreadValues({}, result), pluginFactory(options));
1521
+ });
1522
+ if (bridge !== false) {
1523
+ loadBridge("https://app.storyblok.com/f/storyblok-v2-latest.js");
1524
+ }
1525
+ return result;
1526
+ };
1527
+ export { api as apiPlugin, editable as storyblokEditable, storyblokInit, useStoryblokBridge };