@storyblok/js 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,280 +1,72 @@
1
1
  <div align="center">
2
- <a href="https://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js" align="center">
3
- <img src="https://a.storyblok.com/f/88751/1776x360/296788fb19/sb-js.png" alt="Storyblok Logo">
4
- </a>
5
- <h1 align="center">@storyblok/js</h1>
6
- <p align="center">
7
- The JavaScript SDK you need to interact with <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js" target="_blank">Storyblok API</a> and enable the <a href="https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js" target="_blank">Real-time Visual Editing Experience</a>.
2
+
3
+ ![Storyblok ImagoType](https://raw.githubusercontent.com/storyblok/.github/refs/heads/main/profile/public/github-banner.png)
4
+
5
+ <h1 align="center">@storyblok/js</h1>
6
+ <p>
7
+ The JavaScript SDK to interact with <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js" target="_blank">Storyblok API</a> and enable the <a href="https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js" target="_blank">Real-time Visual Editing Experience</a>.
8
8
  </p>
9
9
  <br />
10
10
  </div>
11
11
 
12
12
  <p align="center">
13
13
  <a href="https://npmjs.com/package/@storyblok/js">
14
- <img src="https://img.shields.io/npm/v/@storyblok/js/latest.svg?style=flat-square" alt="Storyblok JS" />
14
+ <img src="https://img.shields.io/npm/v/@storyblok/js/latest.svg?style=flat-square&color=8d60ff" alt="Storyblok JS SDK" />
15
15
  </a>
16
16
  <a href="https://npmjs.com/package/@storyblok/js" rel="nofollow">
17
- <img src="https://img.shields.io/npm/dt/@storyblok/js.svg?style=flat-square" alt="npm">
17
+ <img src="https://img.shields.io/npm/dt/@storyblok/js.svg?style=appveyor&color=8d60ff" alt="npm">
18
18
  </a>
19
- </p>
20
-
21
- <p align="center">
22
19
  <a href="https://discord.gg/jKrbAMz">
23
- <img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=09b3af">
20
+ <img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=8d60ff">
24
21
  </a>
25
22
  <a href="https://twitter.com/intent/follow?screen_name=storyblok">
26
- <img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
27
- </a>
28
- <a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js">
29
- <img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
23
+ <img src="https://img.shields.io/badge/Follow-%40storyblok-8d60ff?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
24
+ </a><br/>
25
+ <a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=@storyblok/js">
26
+ <img src="https://img.shields.io/badge/Try%20Storyblok-Free-8d60ff?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
30
27
  </a>
31
28
  </p>
32
29
 
33
- ## Kickstart a new project
34
- Are you eager to dive into coding? **[Follow these steps to kickstart a new project with Storyblok and a JavaScript frontend framework](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)**, and get started in just a few minutes!
35
-
36
- ## Installation
37
-
38
- Install `@storyblok/js`:
39
-
40
- ```bash
41
- npm install @storyblok/js
42
- // yarn add @storyblok/js
43
- ```
44
-
45
- > ⚠️ This SDK uses the Fetch API under the hood. If your environment doesn't support it, you need to install a polyfill like [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch). More info on [storyblok-js-client docs](https://github.com/storyblok/storyblok-js-client#fetch-use-polyfill-if-needed---version-5).
46
-
47
- ### From a CDN
48
-
49
- Install the file from the CDN:
50
-
51
- ```html
52
- <script src="https://unpkg.com/@storyblok/js"></script>
53
- ```
54
-
55
- ## Initialization
56
-
57
- Register the plugin on your application and add the [access token](https://www.storyblok.com/docs/api/content-delivery#topics/authentication?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) of your Storyblok space. You can also add the `apiPlugin` in case that you want to use the Storyblok API Client:
58
-
59
- ```js
60
- import { apiPlugin, storyblokInit } from '@storyblok/js';
61
-
62
- const { storyblokApi } = storyblokInit({
63
- accessToken: 'YOUR_ACCESS_TOKEN',
64
- use: [apiPlugin],
65
- });
66
- ```
67
-
68
- That's it! All the features are enabled for you: the _Api Client_ for interacting with [Storyblok CDN API](https://www.storyblok.com/docs/api/content-delivery#topics/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js), and _Storyblok Bridge_ for [real-time visual editing experience](https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
69
-
70
- > You can enable/disable some of these features if you don't need them, so you save some KB. Please read the "Features and API" section
71
-
72
- ### Region parameter
73
-
74
- Possible values:
75
-
76
- - `eu` (default): For spaces created in the EU
77
- - `us`: For spaces created in the US
78
- - `ap`: For spaces created in Australia
79
- - `ca`: For spaces created in Canada
80
- - `cn`: For spaces created in China
81
-
82
- Full example for a space created in the US:
83
-
84
- ```js
85
- import { apiPlugin, storyblokInit } from '@storyblok/js';
86
-
87
- const { storyblokApi } = storyblokInit({
88
- accessToken: 'YOUR_ACCESS_TOKEN',
89
- use: [apiPlugin],
90
- apiOptions: {
91
- region: 'us',
92
- },
93
- });
94
- ```
95
-
96
- > Note: For spaces created in the United States or China, the `region` parameter **must** be specified.
97
-
98
- ## Getting Started
99
-
100
- `@storyblok/js` does three actions when you initialize it:
101
-
102
- - Provides a `storyblokApi` object in your app, which is an instance of [storyblok-js-client](https://github.com/storyblok/storyblok-js-client).
103
- - Loads [Storyblok Bridge](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) for real-time visual updates.
104
- - Provides a `storyblokEditable` function to link editable components to the Storyblok Visual Editor.
105
-
106
- ### 1. Fetching Content
107
-
108
- Inject `storyblokApi`:
109
-
110
- ```js
111
- import { apiPlugin, storyblokInit } from '@storyblok/js';
112
-
113
- const { storyblokApi } = storyblokInit({
114
- accessToken: 'YOUR_ACCESS_TOKEN',
115
- use: [apiPlugin],
116
- });
30
+ ## Features
117
31
 
118
- const { data } = await storyblokApi.get('cdn/stories', { version: 'draft' });
119
- ```
32
+ - Fetch content from the Content Delivery API
33
+ - Connect frontend components with the Visual Editor via StoryblokBridge
34
+ - Render rich text content with the Storyblok Rich Text Renderer based on `@storyblok/richtext`
120
35
 
121
- > Note: if you don't use `apiPlugin`, you can use your prefered method or function to fetch your data.
36
+ ## Documentation
122
37
 
123
- ### 2. Listen to Storyblok Visual Editor events
38
+ For complete documentation, please visit [package reference](https://www.storyblok.com/docs/packages/storyblok-js)
124
39
 
125
- Use `useStoryblokBridge` or `registerStoryblokBridge` to get the new story every time is triggered a `change` event from the Visual Editor. You need to pass the story id as first param, and a callback function as second param to update the new story:
126
-
127
- ```js
128
- import { apiPlugin, storyblokInit, useStoryblokBridge } from '@storyblok/js';
129
-
130
- const { storyblokApi } = storyblokInit({
131
- accessToken: 'YOUR_ACCESS_TOKEN',
132
- use: [apiPlugin],
133
- });
134
-
135
- const { data } = await storyblokApi.get('cdn/stories', { version: 'draft' });
136
-
137
- const story = data ? data.story : null;
138
-
139
- useStoryblokBridge(story.id, story => (state.story = story));
140
- ```
141
-
142
- You can pass [Bridge options](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js) as a third parameter as well:
143
-
144
- ```js
145
- useStoryblokBridge(story.id, story => (state.story = story), {
146
- resolveRelations: ['Article.author'],
147
- resolveLinks: 'url'
148
- });
149
- ```
150
-
151
- ### 3. Link your components to Storyblok Visual Editor
152
-
153
- To link your app and Storyblok components together will depend on the framework you are using. But, in the end, you must add the `data-blok-c` and `data-blok-uid` attributes, and the `storyblok__outline` class.
154
-
155
- We provide you a `storyblokEditable` function to make that easier. As an example, you can check in [@storyblok/vue](https://github.com/storyblok/storyblok-vue/blob/master/lib/index.js#L7-L9) how we use a `v-editable` directive for that:
156
-
157
- ```js
158
- import { storyblokEditable } from '@storyblok/js';
159
-
160
- const vEditableDirective = {
161
- bind(el, binding) {
162
- if (binding.value) {
163
- const options = storyblokEditable(binding.value);
164
- el.setAttribute('data-blok-c', options['data-blok-c']);
165
- el.setAttribute('data-blok-uid', options['data-blok-uid']);
166
- el.classList.add('storyblok__outline');
167
- }
168
- },
169
- };
170
- ```
171
-
172
- At this point, you'll have your app connected to Storyblok with the real-time editing experience fully enabled.
173
-
174
- ## Features and API
175
-
176
- You can **choose the features to use** when you initialize the plugin. In that way, you can improve Web Performance by optimizing your page load and save some bytes.
177
-
178
- ### Storyblok API
179
-
180
- You can use an `apiOptions` object. This is passed down to the (storyblok-js-client config object](https://github.com/storyblok/storyblok-js-client#class-storyblok):
181
-
182
- ```js
183
- const { storyblokApi } = storyblokInit({
184
- accessToken: 'YOUR_ACCESS_TOKEN',
185
- apiOptions: {
186
- // storyblok-js-client config object
187
- cache: { type: 'memory' },
188
- },
189
- use: [apiPlugin],
190
- });
191
- ```
192
-
193
- If you prefer to use your own fetch method, just remove the `apiPlugin` and `storyblok-js-client` won't be added to your application.
194
-
195
- ```js
196
- storyblokInit({});
197
- ```
198
-
199
- ### Storyblok Bridge
200
-
201
- You can conditionally load it by using the `bridge` option. Very useful if you want to disable it in production:
202
-
203
- ```js
204
- const { storyblokApi } = storyblokInit({
205
- bridge: process.env.NODE_ENV !== 'production',
206
- });
207
- ```
208
-
209
- If you don't use `useStoryblokBridge` or `registerStoryblokBridge`, you have still access to the raw `window.StoryblokBridge`:
210
-
211
- ```js
212
- const sbBridge = new window.StoryblokBridge(options);
213
-
214
- sbBridge.on(['input', 'published', 'change'], (event) => {
215
- // ...
216
- });
217
- ```
218
-
219
- ### Rendering Rich Text
220
-
221
- You can easily render rich text by using the `renderRichText` method. This function is a wrapper of the `render` method of the [`@storyblok/richtext` package](https://github.com/storyblok/richtext).
222
-
223
- ```ts
224
- import { apiPlugin, storyblokInit, renderRichText } from '@storyblok/js';
225
-
226
- const { storyblokApi } = storyblokInit({
227
- accessToken: 'YOUR_ACCESS_TOKEN',
228
- use: [apiPlugin],
229
- });
40
+ ## Contributing
230
41
 
231
- const { data } = await storyblokApi!.get('cdn/stories/richtext');
42
+ If you'd like to contribute, please refer to the [contributing guidelines](CONTRIBUTING.md).
232
43
 
233
- const html = renderRichText(data.story.content.body);
234
- ```
44
+ ## Community
235
45
 
236
- #### Overwrite resolvers
46
+ For help, discussion about best practices, or any other conversation that would benefit from being searchable:
237
47
 
238
- You can overwrite the default resolvers by passing a custom `resolvers` object to the `renderRichText` function.
48
+ - [Discuss Storyblok on Github Discussions](https://github.com/storyblok/storyblok/discussions)
239
49
 
240
- ```ts
241
- import { apiPlugin, storyblokInit, renderRichText } from '@storyblok/js';
50
+ For community support, chatting with other users, please visit:
242
51
 
243
- const { storyblokApi } = storyblokInit({
244
- accessToken: 'YOUR_ACCESS_TOKEN',
245
- use: [apiPlugin],
246
- });
247
- const { data } = await storyblokApi!.get('cdn/stories/richtext');
52
+ - [Discuss Storyblok on Discord](https://discord.gg/jKrbAMz)
248
53
 
249
- const html = renderRichText(data.story.content.body, {
250
- resolvers: {
251
- [MarkTypes.LINK]: (node) => {
252
- return `<button href="${node.attrs?.href}" target="${node.attrs?.target}">${node.content[0].text}</button>`;
253
- },
254
- },
255
- });
256
- ```
54
+ ## Support
257
55
 
258
- For more options available, like optimizing images, please refer to the [@storyblok/richtext documentation](https://github.com/storyblok/richtext?tab=readme-ov-file#optimize-images).
56
+ For bugs or feature requests, please [submit an issue](https://github.com/storyblok/storyblok-js/issues/new/choose).
259
57
 
260
- ## The Storyblok JavaScript SDK Ecosystem
58
+ > [!IMPORTANT]
59
+ > Please search existing issues before submitting a new one. Issues without a minimal reproducible example will be closed. [Why reproductions are Required](https://antfu.me/posts/why-reproductions-are-required).
261
60
 
262
- ![A visual representation of the Storyblok JavaScript SDK Ecosystem](https://a.storyblok.com/f/88751/2400x1350/be4a4a4180/sdk-ecosystem.png/m/1200x0)
61
+ ### I can't share my company project code
263
62
 
264
- ## Further Resources
63
+ We understand that you might not be able to share your company's project code. Please provide a minimal reproducible example that demonstrates the issue by using tools like [Stackblitz](https://stackblitz.com) or a link to a Github Repo lease make sure you include a README file with the instructions to build and run the project, important not to include any access token, password or personal information of any kind.
265
64
 
266
- - [Quick Start](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)
267
- - [API Documentation](https://www.storyblok.com/docs/api?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)
268
- - [Developer Tutorials](https://www.storyblok.com/tutorials?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)
269
- - [Developer Guides](https://www.storyblok.com/docs/guide/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)
270
- - [FAQs](https://www.storyblok.com/faqs?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js)
65
+ ### Feedback
271
66
 
272
- ## Support
67
+ If you have a question, please ask in the [Discuss Storyblok on Discord](https://discord.gg/jKrbAMz) channel.
273
68
 
274
- - Bugs or Feature Requests? [Submit an issue](/../../issues/new).
275
- - Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
276
69
 
277
- ## Contributing
70
+ ## License
278
71
 
279
- Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/main/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-js).
280
- This project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ
72
+ [License](/LICENSE)
@@ -4,4 +4,4 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- (function(w,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(w=typeof globalThis<"u"?globalThis:w||self,S(w.storyblok={}))})(this,function(w){"use strict";function S(r,e){if(!e)return{src:r,attrs:{}};let t=0,o=0;const s={},n=[];function a(h,c,d,y,$){typeof h!="number"||h<=c||h>=d?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${c} and ${d} (inclusive)`):$.push(`${y}(${h})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(s.height=e.height,o=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:h}=e||{},{blur:c,brightness:d,fill:y,format:$,grayscale:L,quality:E,rotate:O}=h||{};c&&a(c,0,100,"blur",n),E&&a(E,0,100,"quality",n),d&&a(d,0,100,"brightness",n),y&&n.push(`fill(${y})`),L&&n.push("grayscale()"),O&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${O})`),$&&["webp","png","jpeg"].includes($)&&n.push(`format(${$})`)}e.srcset&&(s.srcset=e.srcset.map(h=>{if(typeof h=="number")return`${r}/m/${h}x0/${n.length>0?`filters:${n.join(":")}`:""} ${h}w`;if(Array.isArray(h)&&h.length===2){const[c,d]=h;return`${r}/m/${c}x${d}/${n.length>0?`filters:${n.join(":")}`:""} ${c}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let l=`${r}/m/`;return t>0&&o>0&&(l=`${l}${t}x${o}/`),n.length>0&&(l=`${l}filters:${n.join(":")}`),{src:l,attrs:s}}var b=(r=>(r.DOCUMENT="doc",r.HEADING="heading",r.PARAGRAPH="paragraph",r.QUOTE="blockquote",r.OL_LIST="ordered_list",r.UL_LIST="bullet_list",r.LIST_ITEM="list_item",r.CODE_BLOCK="code_block",r.HR="horizontal_rule",r.BR="hard_break",r.IMAGE="image",r.EMOJI="emoji",r.COMPONENT="blok",r.TABLE="table",r.TABLE_ROW="tableRow",r.TABLE_CELL="tableCell",r.TABLE_HEADER="tableHeader",r))(b||{}),_=(r=>(r.BOLD="bold",r.STRONG="strong",r.STRIKE="strike",r.UNDERLINE="underline",r.ITALIC="italic",r.CODE="code",r.LINK="link",r.ANCHOR="anchor",r.STYLED="styled",r.SUPERSCRIPT="superscript",r.SUBSCRIPT="subscript",r.TEXT_STYLE="textStyle",r.HIGHLIGHT="highlight",r))(_||{}),N=(r=>(r.TEXT="text",r))(N||{}),I=(r=>(r.URL="url",r.STORY="story",r.ASSET="asset",r.EMAIL="email",r))(I||{});const K=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],W=(r={})=>Object.keys(r).map(e=>`${e}="${r[e]}"`).join(" "),X=(r={})=>Object.keys(r).map(e=>`${e}: ${r[e]}`).join("; ");function Q(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const j=r=>Object.fromEntries(Object.entries(r).filter(([e,t])=>t!==void 0));function D(r,e={},t){const o=W(e),s=o?`${r} ${o}`:r,n=Array.isArray(t)?t.join(""):t||"";if(r){if(K.includes(r))return`<${s}>`}else return n;return`<${s}>${n}</${r}>`}function M(r={}){const e=new Map,{renderFn:t=D,textFn:o=Q,resolvers:s={},optimizeImages:n=!1,keyedResolvers:a=!1}=r,l=t!==D,h=()=>({render:(i,u={},p)=>{if(a&&i){const f=e.get(i)||0;e.set(i,f+1),u.key=`${i}-${f}`}return t(i,u,p)}}),c=i=>(u,p)=>{const f=u.attrs||{};return p.render(i,f,u.children||null)},d=(i,u)=>{const{src:p,alt:f,title:m,srcset:T,sizes:v}=i.attrs||{};let k=p,R={};if(n){const{src:Ee,attrs:Ae}=S(p,n);k=Ee,R=Ae}const Re={src:k,alt:f,title:m,srcset:T,sizes:v,...R};return u.render("img",j(Re))},y=(i,u)=>{const{level:p,...f}=i.attrs||{};return u.render(`h${p}`,f,i.children)},$=(i,u)=>{var p,f,m,T;const v=u.render("img",{src:(p=i.attrs)==null?void 0:p.fallbackImage,alt:(f=i.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return u.render("span",{"data-type":"emoji","data-name":(m=i.attrs)==null?void 0:m.name,"data-emoji":(T=i.attrs)==null?void 0:T.emoji},v)},L=(i,u)=>u.render("pre",i.attrs||{},u.render("code",{},i.children||"")),E=(i,u=!1)=>({text:p,attrs:f},m)=>{const{class:T,id:v,...k}=f||{},R=u?{class:T,id:v,style:X(k)||void 0}:f||{};return m.render(i,j(R),p)},O=i=>U(i),be=i=>{const{marks:u,...p}=i;if("text"in i){if(u)return u.reduce((m,T)=>O({...T,text:m}),O({...p,children:p.children}));const f=i.attrs||{};if(a){const m=e.get("txt")||0;e.set("txt",m+1),f.key=`txt-${m}`}return o(p.text,f)}return""},Y=(i,u)=>{const{linktype:p,href:f,anchor:m,...T}=i.attrs||{};let v="";switch(p){case I.ASSET:case I.URL:v=f;break;case I.EMAIL:v=`mailto:${f}`;break;case I.STORY:v=f,m&&(v=`${v}#${m}`);break;default:v=f;break}const k={...T};return v&&(k.href=v),u.render("a",k,i.text)},ve=(i,u)=>{var p,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.render("span",{blok:(p=i==null?void 0:i.attrs)==null?void 0:p.body[0],id:(f=i.attrs)==null?void 0:f.id,style:"display: none"})},ke=(i,u)=>{const p={},f=u.render("tbody",{},i.children);return u.render("table",p,f)},we=(i,u)=>{const p={};return u.render("tr",p,i.children)},Te=(i,u)=>{const{colspan:p,rowspan:f,colwidth:m,backgroundColor:T,...v}=i.attrs||{},k={...v};p>1&&(k.colspan=p),f>1&&(k.rowspan=f);const R=[];return m&&R.push(`width: ${m}px;`),T&&R.push(`background-color: ${T};`),R.length>0&&(k.style=R.join(" ")),u.render("td",j(k),i.children)},$e=(i,u)=>{const{colspan:p,rowspan:f,colwidth:m,backgroundColor:T,...v}=i.attrs||{},k={...v};p>1&&(k.colspan=p),f>1&&(k.rowspan=f);const R=[];return m&&R.push(`width: ${m}px;`),T&&R.push(`background-color: ${T};`),R.length>0&&(k.style=R.join(" ")),u.render("th",j(k),i.children)},_e=new Map([[b.DOCUMENT,c("")],[b.HEADING,y],[b.PARAGRAPH,c("p")],[b.UL_LIST,c("ul")],[b.OL_LIST,c("ol")],[b.LIST_ITEM,c("li")],[b.IMAGE,d],[b.EMOJI,$],[b.CODE_BLOCK,L],[b.HR,c("hr")],[b.BR,c("br")],[b.QUOTE,c("blockquote")],[b.COMPONENT,ve],[N.TEXT,be],[_.LINK,Y],[_.ANCHOR,Y],[_.STYLED,E("span",!0)],[_.BOLD,E("strong")],[_.TEXT_STYLE,E("span",!0)],[_.ITALIC,E("em")],[_.UNDERLINE,E("u")],[_.STRIKE,E("s")],[_.CODE,E("code")],[_.SUPERSCRIPT,E("sup")],[_.SUBSCRIPT,E("sub")],[_.HIGHLIGHT,E("mark")],[b.TABLE,ke],[b.TABLE_ROW,we],[b.TABLE_CELL,Te],[b.TABLE_HEADER,$e],...Object.entries(s).map(([i,u])=>[i,u])]);function P(i){const u=_e.get(i.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const p=h();if(i.type==="text")return u(i,p);const f=i.content?i.content.map(U):void 0;return u({...i,children:f},p)}function U(i){return i.type==="doc"?l?i.content.map(P):i.content.map(P).join(""):Array.isArray(i)?i.map(P):P(i)}return{render:U}}let z=!1;const F=[],G=r=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?s():F.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=r,o.id="storyblok-javascript-bridge",o.onerror=s=>t(s),o.onload=s=>{F.forEach(n=>n()),z=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(o)});var Z=Object.defineProperty,ee=(r,e,t)=>e in r?Z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,g=(r,e,t)=>ee(r,typeof e!="symbol"?e+"":e,t);class te extends Error{constructor(e){super(e),this.name="AbortError"}}function se(r,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const o=[];let s=[],n=0,a=!1;const l=async()=>{n++;const c=o.shift();if(c)try{const y=await r(...c.args);c.resolve(y)}catch(y){c.reject(y)}const d=setTimeout(()=>{n--,o.length>0&&l(),s=s.filter(y=>y!==d)},t);s.includes(d)||s.push(d)},h=(...c)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,y)=>{o.push({resolve:d,reject:y,args:c}),n<e&&l()});return h.abort=()=>{a=!0,s.forEach(clearTimeout),s=[],o.forEach(c=>c.reject(()=>new te("Throttle function aborted"))),o.length=0},h}const re=(r="")=>r.includes("/cdn/"),oe=(r,e=25,t=1)=>({...r,per_page:e,page:t}),ne=r=>new Promise(e=>setTimeout(e,r)),ie=(r=0,e)=>Array.from({length:r},e),ae=(r=0,e=r)=>{const t=Math.abs(e-r)||0,o=r<e?1:-1;return ie(t,(s,n)=>n*o+r)},le=async(r,e)=>Promise.all(r.map(e)),ce=(r=[],e)=>r.map(e).reduce((t,o)=>[...t,...o],[]),B=(r,e,t)=>{const o=[];for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const n=r[s];if(n==null)continue;const a=t?"":encodeURIComponent(s);let l;typeof n=="object"?l=B(n,e?e+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):l=`${e?e+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,o.push(l)}return o.join("&")},V=r=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[r]??e.eu};class he{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),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={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],o={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{o.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return o.headers={...t},o.status=e.status,o.statusText=e.statusText,o}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,o=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:o=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:a}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const h=await this.fetch(`${s}`,{method:e,headers:this.headers,body:o,signal:a,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(h);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(h){return{message:h}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((o,s)=>{if(t.test(`${e.status}`))return o(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(n)})}}const q="SB-Agent",x={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"},ue={DRAFT:"draft"};let C={};const A={};class de{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"version"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache"),g(this,"inlineAssets");let o=e.endpoint||t;if(!o){const a=e.https===!1?"http":"https";e.oauthToken?o=`${a}://${V(e.region)}/v1`:o=`${a}://${V(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([a,l])=>{s.set(a,l)}),s.has(q)||(s.set(q,x.defaultAgentName),s.set(x.defaultAgentVersion,x.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=se(this.throttledRequest.bind(this),n,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||ue.DRAFT,this.inlineAssets=e.inlineAssets||!1,this.client=new he({baseURL:o,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){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}factoryParamOptions(e,t){return re(e)?this.parseParams(t):t}makeRequest(e,t,o,s,n){const a=this.factoryParamOptions(e,oe(t,o,s));return this.cacheResponse(e,a,void 0,n)}get(e,t={},o){t||(t={});const s=`/${e}`;t.version=t.version||this.version;const n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,o)}async getAll(e,t={},o,s){const n=(t==null?void 0:t.per_page)||25,a=`/${e}`.replace(/\/$/,""),l=o??a.substring(a.lastIndexOf("/")+1);t.version=t.version||this.version;const h=1,c=await this.makeRequest(a,t,n,h,s),d=c.total?Math.ceil(c.total/n):1,y=await le(ae(h,d),$=>this.makeRequest(a,t,n,$+1,s));return ce([c,...y],$=>Object.values($.data[l]))}post(e,t={},o){const s=`/${e}`;return this.throttle("post",s,t,o)}put(e,t={},o){const s=`/${e}`;return this.throttle("put",s,t,o)}delete(e,t={},o){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,o)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},o){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,o)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,o){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[o][s.id]?s.story=this._cleanCopy(this.links[o][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[o][s.uuid]&&(s.story=this._cleanCopy(this.links[o][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,o){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(o,s):Array.isArray(s)&&(e[t]=s.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(e,t,o,s){if(Array.isArray(o)?o.find(a=>a.endsWith(`.${t}`)):o.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(e,t,s)}iterateTree(e,t,o){const s=(n,a="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,h)=>s(l,`${a}[${h}]`));else if(typeof n=="object")for(const l in n){const h=a?`${a}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,o),this._insertLinks(n,l,o)),s(n[l],h)}}};s(e.content)}async resolveLinks(e,t,o){let s=[];if(e.link_uuids){const n=e.link_uuids.length,a=[],l=50;for(let h=0;h<n;h+=l){const c=Math.min(n,h+l);a.push(e.link_uuids.slice(h,c))}for(let h=0;h<a.length;h++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[h].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.links;s.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,o){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,a=[],l=50;for(let h=0;h<n;h+=l){const c=Math.min(n,h+l);a.push(e.rel_uuids.slice(h,c))}for(let h=0;h<a.length;h++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[h].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{s.push(c)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,o){var s,n;let a=[];if(this.links[o]={},this.relations[o]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(a=t.resolve_relations.split(",")),await this.resolveRelations(e,t,o)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,o),this.resolveNestedRelations)for(const l in this.relations[o])this.iterateTree(this.relations[o][l],a,o);e.story?this.iterateTree(e.story,a,o):e.stories.forEach(l=>{this.iterateTree(l,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(e,t,o,s){const n=B({url:e,params:t}),a=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await a.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,h)=>{var c;try{const d=await this.throttle("get",e,t,s);if(d.status!==200)return h(d);let y={data:d.data,headers:d.headers};if((c=d.headers)!=null&&c["per-page"]&&(y=Object.assign({},y,{perPage:d.headers["per-page"]?Number.parseInt(d.headers["per-page"]):0,total:d.headers["per-page"]?Number.parseInt(d.headers.total):0})),y.data.story||y.data.stories){const L=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${L}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await a.set(n,y);const $=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&($&&A[t.token]&&A[t.token]!==y.data.cv&&await this.flushCache(),A[t.token]=y.data.cv),l(y)}catch(d){if(d.response&&d.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ne(this.retriesDelay),this.cacheResponse(e,t,o).then(l).catch(h);h(d)}})}throttledRequest(e,t,o,s){return this.client.setFetchOptions(s),this.client[e](t,o)}cacheVersions(){return A}cacheVersion(){return A[this.accessToken]}setCacheVersion(e){this.accessToken&&(A[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(A[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(C[e])},getAll(){return Promise.resolve(C)},set(e,t){return C[e]=t,Promise.resolve(void 0)},flush(){return C={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>t(n));let s={...o};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(n=>n.id===s.id)});for(const n in s)typeof s[n]=="object"&&(s[n]=t(s[n]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(o=>(o.content=t(o.content),o))),e}}const pe=(r={})=>{const{apiOptions:e}=r;if(!e||!e.accessToken){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");return}return{storyblokApi:new de(e)}},fe=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};try{const e=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let H="https://app.storyblok.com/f/storyblok-v2-latest.js";const J=(r,e,t={})=>{var l;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((l=window.location)==null?void 0:l.href).searchParams.get("_storyblok"),a=n!==null&&+n===r;if(!(!s||!a)){if(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],c=>{var d;c&&(c.action==="input"&&((d=c.story)==null?void 0:d.id)===r?e(c.story):(c.action==="change"||c.action==="published")&&c.storyId===r&&window.location.reload())})})}},ye=(r={})=>{var d,y;const{bridge:e,accessToken:t,use:o=[],apiOptions:s={},bridgeUrl:n}=r;s.accessToken=s.accessToken||t;const a={bridge:e,apiOptions:s};let l={};o.forEach($=>{l={...l,...$(a)}}),n&&(H=n);const c=!(typeof window>"u")&&((y=(d=window.location)==null?void 0:d.search)==null?void 0:y.includes("_storyblok_tk"));return e!==!1&&c&&G(H),l};function ge(r,e){return M(e).render(r)}const me=()=>G(H);w.BlockTypes=b,w.MarkTypes=_,w.TextTypes=N,w.apiPlugin=pe,w.loadStoryblokBridge=me,w.registerStoryblokBridge=J,w.renderRichText=ge,w.richTextResolver=M,w.storyblokEditable=fe,w.storyblokInit=ye,w.useStoryblokBridge=J,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
7
+ (function(w,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(w=typeof globalThis<"u"?globalThis:w||self,S(w.storyblok={}))})(this,function(w){"use strict";function S(r,e){if(!e)return{src:r,attrs:{}};let t=0,o=0;const s={},n=[];function l(a,h,d,y,R){typeof a!="number"||a<=h||a>=d?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${h} and ${d} (inclusive)`):R.push(`${y}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(s.height=e.height,o=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:a}=e||{},{blur:h,brightness:d,fill:y,format:R,grayscale:_,quality:L,rotate:C}=a||{};h&&l(h,0,100,"blur",n),L&&l(L,0,100,"quality",n),d&&l(d,0,100,"brightness",n),y&&n.push(`fill(${y})`),_&&n.push("grayscale()"),C&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${C})`),R&&["webp","png","jpeg"].includes(R)&&n.push(`format(${R})`)}e.srcset&&(s.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${r}/m/${a}x0/${n.length>0?`filters:${n.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[h,d]=a;return`${r}/m/${h}x${d}/${n.length>0?`filters:${n.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let c=`${r}/m/`;return t>0&&o>0&&(c=`${c}${t}x${o}/`),n.length>0&&(c=`${c}filters:${n.join(":")}`),{src:c,attrs:s}}var b=(r=>(r.DOCUMENT="doc",r.HEADING="heading",r.PARAGRAPH="paragraph",r.QUOTE="blockquote",r.OL_LIST="ordered_list",r.UL_LIST="bullet_list",r.LIST_ITEM="list_item",r.CODE_BLOCK="code_block",r.HR="horizontal_rule",r.BR="hard_break",r.IMAGE="image",r.EMOJI="emoji",r.COMPONENT="blok",r.TABLE="table",r.TABLE_ROW="tableRow",r.TABLE_CELL="tableCell",r.TABLE_HEADER="tableHeader",r))(b||{}),$=(r=>(r.BOLD="bold",r.STRONG="strong",r.STRIKE="strike",r.UNDERLINE="underline",r.ITALIC="italic",r.CODE="code",r.LINK="link",r.ANCHOR="anchor",r.STYLED="styled",r.SUPERSCRIPT="superscript",r.SUBSCRIPT="subscript",r.TEXT_STYLE="textStyle",r.HIGHLIGHT="highlight",r))($||{}),N=(r=>(r.TEXT="text",r))(N||{}),I=(r=>(r.URL="url",r.STORY="story",r.ASSET="asset",r.EMAIL="email",r))(I||{});const X=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Q=(r={})=>Object.keys(r).map(e=>`${e}="${r[e]}"`).join(" "),Z=(r={})=>Object.keys(r).map(e=>`${e}: ${r[e]}`).join("; ");function ee(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const O=r=>Object.fromEntries(Object.entries(r).filter(([e,t])=>t!==void 0));function D(r,e={},t){const o=Q(e),s=o?`${r} ${o}`:r,n=Array.isArray(t)?t.join(""):t||"";if(r){if(X.includes(r))return`<${s}>`}else return n;return`<${s}>${n}</${r}>`}function M(r={}){const e=new Map,{renderFn:t=D,textFn:o=ee,resolvers:s={},optimizeImages:n=!1,keyedResolvers:l=!1}=r,c=t!==D,a=i=>(u,p)=>{const f=u.attrs||{};return p.render(i,f,u.children||null)},h=(i,u)=>{const{src:p,alt:f,title:m,srcset:T,sizes:v}=i.attrs||{};let k=p,E={};if(n){const{src:Ae,attrs:Se}=S(p,n);k=Ae,E=Se}const Ee={src:k,alt:f,title:m,srcset:T,sizes:v,...E};return u.render("img",O(Ee))},d=(i,u)=>{const{level:p,...f}=i.attrs||{};return u.render(`h${p}`,f,i.children)},y=(i,u)=>{var p,f,m,T;const v=u.render("img",{src:(p=i.attrs)==null?void 0:p.fallbackImage,alt:(f=i.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return u.render("span",{"data-type":"emoji","data-name":(m=i.attrs)==null?void 0:m.name,"data-emoji":(T=i.attrs)==null?void 0:T.emoji},v)},R=(i,u)=>u.render("pre",i.attrs||{},u.render("code",{},i.children||"")),_=(i,u=!1)=>({text:p,attrs:f},m)=>{const{class:T,id:v,...k}=f||{},E=u?{class:T,id:v,style:Z(k)||void 0}:f||{};return m.render(i,O(E),p)},L=i=>U(i),C=i=>{const{marks:u,...p}=i;if("text"in i){if(u)return u.reduce((m,T)=>L({...T,text:m}),L({...p,children:p.children}));const f=i.attrs||{};if(l){const m=e.get("txt")||0;e.set("txt",m+1),f.key=`txt-${m}`}return o(p.text,f)}return""},Y=(i,u)=>{const{linktype:p,href:f,anchor:m,...T}=i.attrs||{};let v="";switch(p){case I.ASSET:case I.URL:v=f;break;case I.EMAIL:v=`mailto:${f}`;break;case I.STORY:v=f,m&&(v=`${v}#${m}`);break;default:v=f;break}const k={...T};return v&&(k.href=v),u.render("a",k,i.text)},ke=(i,u)=>{var p,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.render("span",{blok:(p=i==null?void 0:i.attrs)==null?void 0:p.body[0],id:(f=i.attrs)==null?void 0:f.id,style:"display: none"})},we=(i,u)=>{const p={},f=u.render("tbody",{},i.children);return u.render("table",p,f)},Te=(i,u)=>{const p={};return u.render("tr",p,i.children)},Re=(i,u)=>{const{colspan:p,rowspan:f,colwidth:m,backgroundColor:T,...v}=i.attrs||{},k={...v};p>1&&(k.colspan=p),f>1&&(k.rowspan=f);const E=[];return m&&E.push(`width: ${m}px;`),T&&E.push(`background-color: ${T};`),E.length>0&&(k.style=E.join(" ")),u.render("td",O(k),i.children)},$e=(i,u)=>{const{colspan:p,rowspan:f,colwidth:m,backgroundColor:T,...v}=i.attrs||{},k={...v};p>1&&(k.colspan=p),f>1&&(k.rowspan=f);const E=[];return m&&E.push(`width: ${m}px;`),T&&E.push(`background-color: ${T};`),E.length>0&&(k.style=E.join(" ")),u.render("th",O(k),i.children)},K=new Map([[b.DOCUMENT,a("")],[b.HEADING,d],[b.PARAGRAPH,a("p")],[b.UL_LIST,a("ul")],[b.OL_LIST,a("ol")],[b.LIST_ITEM,a("li")],[b.IMAGE,h],[b.EMOJI,y],[b.CODE_BLOCK,R],[b.HR,a("hr")],[b.BR,a("br")],[b.QUOTE,a("blockquote")],[b.COMPONENT,ke],[N.TEXT,C],[$.LINK,Y],[$.ANCHOR,Y],[$.STYLED,_("span",!0)],[$.BOLD,_("strong")],[$.TEXT_STYLE,_("span",!0)],[$.ITALIC,_("em")],[$.UNDERLINE,_("u")],[$.STRIKE,_("s")],[$.CODE,_("code")],[$.SUPERSCRIPT,_("sup")],[$.SUBSCRIPT,_("sub")],[$.HIGHLIGHT,_("mark")],[b.TABLE,we],[b.TABLE_ROW,Te],[b.TABLE_CELL,Re],[b.TABLE_HEADER,$e]]),W=new Map([...K,...Object.entries(s).map(([i,u])=>[i,u])]),_e=()=>({render:(i,u={},p)=>{if(l&&i){const f=e.get(i)||0;e.set(i,f+1),u.key=`${i}-${f}`}return t(i,u,p)},originalResolvers:K,mergedResolvers:W});function P(i){const u=W.get(i.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const p=_e();if(i.type==="text")return u(i,p);const f=i.content?i.content.map(U):void 0;return u({...i,children:f},p)}function U(i){return i.type==="doc"?c?i.content.map(P):i.content.map(P).join(""):Array.isArray(i)?i.map(P):P(i)}return{render:U}}let z=!1;const F=[],G=r=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?s():F.push(s)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const o=document.createElement("script");o.async=!0,o.src=r,o.id="storyblok-javascript-bridge",o.onerror=s=>t(s),o.onload=s=>{F.forEach(n=>n()),z=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(o)});var te=Object.defineProperty,se=(r,e,t)=>e in r?te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,g=(r,e,t)=>se(r,typeof e!="symbol"?e+"":e,t);class re extends Error{constructor(e){super(e),this.name="AbortError"}}function oe(r,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const o=[];let s=[],n=0,l=!1;const c=async()=>{n++;const h=o.shift();if(h)try{const y=await r(...h.args);h.resolve(y)}catch(y){h.reject(y)}const d=setTimeout(()=>{n--,o.length>0&&c(),s=s.filter(y=>y!==d)},t);s.includes(d)||s.push(d)},a=(...h)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,y)=>{o.push({resolve:d,reject:y,args:h}),n<e&&c()});return a.abort=()=>{l=!0,s.forEach(clearTimeout),s=[],o.forEach(h=>h.reject(()=>new re("Throttle function aborted"))),o.length=0},a}const ne=(r="")=>r.includes("/cdn/"),ie=(r,e=25,t=1)=>({...r,per_page:e,page:t}),ae=r=>new Promise(e=>setTimeout(e,r)),le=(r=0,e)=>Array.from({length:r},e),ce=(r=0,e=r)=>{const t=Math.abs(e-r)||0,o=r<e?1:-1;return le(t,(s,n)=>n*o+r)},he=async(r,e)=>Promise.all(r.map(e)),ue=(r=[],e)=>r.map(e).reduce((t,o)=>[...t,...o],[]),x=(r,e,t)=>{const o=[];for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const n=r[s];if(n==null)continue;const l=t?"":encodeURIComponent(s);let c;typeof n=="object"?c=x(n,e?e+encodeURIComponent(`[${l}]`):l,Array.isArray(n)):c=`${e?e+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(n)}`,o.push(c)}return o.join("&")},V=r=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[r]??e.eu};class de{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),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={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],o={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{o.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return o.headers={...t},o.status=e.status,o.statusText=e.statusText,o}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,o=null;e==="get"?t=`${this.baseURL}${this.url}?${x(this.parameters)}`:o=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:l}=n;let c;this.timeout&&(c=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:o,signal:l,...this.fetchOptions});this.timeout&&clearTimeout(c);const h=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((o,s)=>{if(t.test(`${e.status}`))return o(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(n)})}}const q="SB-Agent",B={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"},pe={DRAFT:"draft"};let j={};const A={};class fe{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"version"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache"),g(this,"inlineAssets");let o=e.endpoint||t;if(!o){const l=e.https===!1?"http":"https";e.oauthToken?o=`${l}://${V(e.region)}/v1`:o=`${l}://${V(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([l,c])=>{s.set(l,c)}),s.has(q)||(s.set(q,B.defaultAgentName),s.set(B.defaultAgentVersion,B.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=oe(this.throttledRequest.bind(this),n,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||pe.DRAFT,this.inlineAssets=e.inlineAssets||!1,this.client=new de({baseURL:o,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){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}factoryParamOptions(e,t){return ne(e)?this.parseParams(t):t}makeRequest(e,t,o,s,n){const l=this.factoryParamOptions(e,ie(t,o,s));return this.cacheResponse(e,l,void 0,n)}get(e,t={},o){t||(t={});const s=`/${e}`;t.version=t.version||this.version;const n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,o)}async getAll(e,t={},o,s){const n=(t==null?void 0:t.per_page)||25,l=`/${e}`.replace(/\/$/,""),c=o??l.substring(l.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,h=await this.makeRequest(l,t,n,a,s),d=h.total?Math.ceil(h.total/n):1,y=await he(ce(a,d),R=>this.makeRequest(l,t,n,R+1,s));return ue([h,...y],R=>Object.values(R.data[c]))}post(e,t={},o){const s=`/${e}`;return this.throttle("post",s,t,o)}put(e,t={},o){const s=`/${e}`;return this.throttle("put",s,t,o)}delete(e,t={},o){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,o)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},o){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,o)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,o){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[o][s.id]?s.story=this._cleanCopy(this.links[o][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[o][s.uuid]&&(s.story=this._cleanCopy(this.links[o][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,o){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(o,s):Array.isArray(s)&&(e[t]=s.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(e,t,o,s){if(Array.isArray(o)?o.find(l=>l.endsWith(`.${t}`)):o.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(e,t,s)}iterateTree(e,t,o){const s=(n,l="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((c,a)=>s(c,`${l}[${a}]`));else if(typeof n=="object")for(const c in n){const a=l?`${l}.${c}`:c;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,c,t,o),this._insertLinks(n,c,o)),s(n[c],a)}}};s(e.content)}async resolveLinks(e,t,o){let s=[];if(e.link_uuids){const n=e.link_uuids.length,l=[],c=50;for(let a=0;a<n;a+=c){const h=Math.min(n,a+c);l.push(e.link_uuids.slice(a,h))}for(let a=0;a<l.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:l[a].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,o){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,l=[],c=50;for(let a=0;a<n;a+=c){const h=Math.min(n,a+c);l.push(e.rel_uuids.slice(a,h))}for(let a=0;a<l.length;a++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:l[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,o){var s,n;let l=[];if(this.links[o]={},this.relations[o]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(l=t.resolve_relations.split(",")),await this.resolveRelations(e,t,o)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,o),this.resolveNestedRelations)for(const c in this.relations[o])this.iterateTree(this.relations[o][c],l,o);e.story?this.iterateTree(e.story,l,o):e.stories.forEach(c=>{this.iterateTree(c,l,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(e,t,o,s){const n=x({url:e,params:t}),l=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await l.get(n);if(c)return Promise.resolve(c)}return new Promise(async(c,a)=>{var h;try{const d=await this.throttle("get",e,t,s);if(d.status!==200)return a(d);let y={data:d.data,headers:d.headers};if((h=d.headers)!=null&&h["per-page"]&&(y=Object.assign({},y,{perPage:d.headers["per-page"]?Number.parseInt(d.headers["per-page"]):0,total:d.headers["per-page"]?Number.parseInt(d.headers.total):0})),y.data.story||y.data.stories){const _=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${_}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await l.set(n,y);const R=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(R&&A[t.token]&&A[t.token]!==y.data.cv&&await this.flushCache(),A[t.token]=y.data.cv),c(y)}catch(d){if(d.response&&d.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ae(this.retriesDelay),this.cacheResponse(e,t,o).then(c).catch(a);a(d)}})}throttledRequest(e,t,o,s){return this.client.setFetchOptions(s),this.client[e](t,o)}cacheVersions(){return A}cacheVersion(){return A[this.accessToken]}setCacheVersion(e){this.accessToken&&(A[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(A[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>t(n));let s={...o};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(n=>n.id===s.id)});for(const n in s)typeof s[n]=="object"&&(s[n]=t(s[n]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(o=>(o.content=t(o.content),o))),e}}const ye=(r={})=>{const{apiOptions:e}=r;if(!e||!e.accessToken){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");return}return{storyblokApi:new fe(e)}},ge=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};try{const e=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let H="https://app.storyblok.com/f/storyblok-v2-latest.js";const J=(r,e,t={})=>{var c;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((c=window.location)==null?void 0:c.href).searchParams.get("_storyblok"),l=n!==null&&+n===r;if(!(!s||!l)){if(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],h=>{var d;h&&(h.action==="input"&&((d=h.story)==null?void 0:d.id)===r?e(h.story):(h.action==="change"||h.action==="published")&&h.storyId===r&&window.location.reload())})})}},me=(r={})=>{var d,y;const{bridge:e,accessToken:t,use:o=[],apiOptions:s={},bridgeUrl:n}=r;s.accessToken=s.accessToken||t;const l={bridge:e,apiOptions:s};let c={};o.forEach(R=>{c={...c,...R(l)}}),n&&(H=n);const h=!(typeof window>"u")&&((y=(d=window.location)==null?void 0:d.search)==null?void 0:y.includes("_storyblok_tk"));return e!==!1&&h&&G(H),c};function be(r,e){return M(e).render(r)}const ve=()=>G(H);w.BlockTypes=b,w.MarkTypes=$,w.TextTypes=N,w.apiPlugin=ye,w.loadStoryblokBridge=ve,w.registerStoryblokBridge=J,w.renderRichText=be,w.richTextResolver=M,w.storyblokEditable=ge,w.storyblokInit=me,w.useStoryblokBridge=J,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});