@storyblok/astro 4.1.1 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,9 +28,11 @@
28
28
  </p>
29
29
 
30
30
  ## Kickstart a new project
31
+
31
32
  Are you eager to dive into coding? **[Follow these steps to kickstart a new project with Storyblok and Astro](https://www.storyblok.com/technologies#astro?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)**, and get started in just a few minutes!
32
33
 
33
34
  ## Ultimate Tutorial
35
+
34
36
  Are you looking for a hands-on, step-by-step tutorial? The **[Astro Ultimate Tutorial](https://www.storyblok.com/tp/the-storyblok-astro-ultimate-tutorial?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro)** has you covered! It provides comprehensive instructions on building a complete, multilingual website using Storyblok and Astro from start to finish.
35
37
 
36
38
  ## Installation
@@ -43,7 +45,7 @@ npm install @storyblok/astro
43
45
  # See below for pnpm
44
46
  ```
45
47
 
46
- > **Note**
48
+ > [!NOTE]
47
49
  > With pnpm, hoist Storyblok dependencies publicly with `.npmrc`. For more information, check pnpm documentation on [here](https://pnpm.io/npmrc).
48
50
 
49
51
  Add the following code to `astro.config.mjs` and replace the `accessToken` with the preview API token of your Storyblok space.
@@ -61,7 +63,7 @@ export default defineConfig({
61
63
  });
62
64
  ```
63
65
 
64
- > **Warning**
66
+ > [!WARNING]
65
67
  > 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).
66
68
 
67
69
  ### Options
@@ -82,7 +84,7 @@ storyblok({
82
84
  });
83
85
  ```
84
86
 
85
- > **Note**
87
+ > [!NOTE]
86
88
  > By default, the `apiPlugin` from `@storyblok/js` is loaded. If you want to use your own method to fetch data from Storyblok, you can disable this behavior by setting `useCustomApi` to `true`, resulting in an optimized final bundle.
87
89
 
88
90
  #### Region parameter
@@ -106,7 +108,7 @@ storyblok({
106
108
  });
107
109
  ```
108
110
 
109
- > **Warning**
111
+ > [!WARNING]
110
112
  > For spaces created in the United States or China, the `region` parameter **must** be specified.
111
113
 
112
114
  ## Getting started
@@ -126,7 +128,7 @@ components: {
126
128
  },
127
129
  ```
128
130
 
129
- > **Note**
131
+ > [!NOTE]
130
132
  > The `src` folder is automatically added to the beginning of the path, so in this example your Astro components should be located here:
131
133
  >
132
134
  > - `src/storyblok/Page.astro`
@@ -136,7 +138,7 @@ components: {
136
138
  >
137
139
  > You can choose any other folder in the `src` directory for your Astro components.
138
140
 
139
- > **Note**
141
+ > [!NOTE]
140
142
  > If you prefer to use a different folder than `src`, you can specify one using the `componentsDir` option:
141
143
  >
142
144
  > ```js
@@ -176,7 +178,7 @@ const { blok } = Astro.props
176
178
  </main>
177
179
  ```
178
180
 
179
- > **Note**
181
+ > [!NOTE]
180
182
  > The `blok` is the actual blok data coming from [Storblok's Content Delivery API](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro).
181
183
 
182
184
  #### Using fallback components
@@ -215,7 +217,7 @@ const story = data.story;
215
217
  <StoryblokComponent blok="{story.content}" />
216
218
  ```
217
219
 
218
- > **Note**
220
+ > [!NOTE]
219
221
  > The available methods are described in the [storyblok-js-client] repository(https://github.com/storyblok/storyblok-js-client#method-storyblokget)
220
222
 
221
223
  #### Dynamic Routing
@@ -261,7 +263,7 @@ const story = data.story;
261
263
 
262
264
  The Storyblok Bridge is enabled by default. If you would like to disable it or enable it conditionally (e.g. depending on the environment) you can set the `bridge` parameter to `true` or `false` in `astro.config.mjs`:
263
265
 
264
- > **Note**
266
+ > [!NOTE]
265
267
  > Since Astro is not a reactive JavaScript framework and renders everything as HTML, the Storyblok Bridge will not provide real-time editing as you may know it from other frameworks. However, it automatically refreshes the site for you whenever you save or publish a story.
266
268
 
267
269
  You can also provide a `StoryblokBridgeConfigV2` configuration object to the `bridge` parameter.
@@ -280,7 +282,7 @@ bridge: {
280
282
  - `resolveRelations` may be needed to resolve the same relations that are already resolved in the API requests via the `resolve_relations` parameter.
281
283
  - `resolveLinks` may be needed to resolve link fields.
282
284
 
283
- > **Note**
285
+ > [!NOTE]
284
286
  > `resolveRelations` and `resolveLinks` will not have any effect in Astro, since the Storyblok Bridge is configured to reload the page. Thus, all the requests needed will be performed after the reload.
285
287
 
286
288
  The provided options will be used when initializing the Storyblok Bridge. You can find more information about the Storyblok Bridge and its configuration options on the [In Depth Storyblok Bridge guide](https://www.storyblok.com/docs/guide/in-depth/storyblok-latest-js-v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-astro).
@@ -289,10 +291,10 @@ If you want to deploy a dedicated preview environment with the Bridge enabled, a
289
291
 
290
292
  ### Rendering Rich Text
291
293
 
292
- > **Note**
294
+ > [!NOTE]
293
295
  > While @storyblok/astro provides basic richtext rendering capabilities, for advanced use cases, it is highly recommended to use [storyblok-rich-text-astro-renderer](https://github.com/NordSecurity/storyblok-rich-text-astro-renderer).
294
296
 
295
- You can easily render rich text by using either the `renderRichText` function or the `<RichTextRenderer />` component, both of which are included in `@storyblok/astro`.
297
+ You can easily render rich text by using either the `renderRichText` function included in `@storyblok/astro`.
296
298
  Use `renderRichText`, which only supports parsing and returning native HTML tags, if you are not embedding `bloks` in your rich text. Then you can use the [`set:html` directive](https://docs.astro.build/en/reference/directives-reference/#sethtml):
297
299
 
298
300
  ```jsx
@@ -307,18 +309,6 @@ const renderedRichText = renderRichText(blok.text)
307
309
  <div set:html="{renderedRichText}"></div>
308
310
  ```
309
311
 
310
- Use the `<RichTextRenderer />` component if you are embedding `bloks` in your rich text:
311
-
312
- ```jsx
313
- ---
314
- import RichTextRenderer from "@storyblok/astro/RichTextRenderer.astro";
315
-
316
- const { blok } = Astro.props
317
- ---
318
-
319
- <RichTextRenderer richTextData={blok.richtext} />
320
- ```
321
-
322
312
  You can also set a **custom Schema and component resolver** by passing the options as the second parameter of the `renderRichText` function:
323
313
 
324
314
  ```jsx
@@ -345,41 +335,12 @@ const renderedRichText = renderRichText(blok.text, {
345
335
  });
346
336
  ```
347
337
 
348
- The same can be done with the `<RichTextRenderer />` component by passing along the options via the `richTextOptions` prop:
349
-
350
- ```jsx
351
- ---
352
- import { RichTextSchema } from "@storyblok/astro";
353
- import RichTextRenderer from "@storyblok/astro/RichTextRenderer.astro";
354
-
355
- import cloneDeep from "clone-deep";
356
-
357
- const mySchema = cloneDeep(RichTextSchema); // you can make a copy of the default RichTextSchema
358
- // ... and edit the nodes and marks, or add your own.
359
- // Check the base RichTextSchema source here https://github.com/storyblok/storyblok-js-client/blob/v4/source/schema.js
360
-
361
- const { blok } = Astro.props;
362
-
363
- const options = {
364
- schema: mySchema,
365
- resolver: (component, blok) => {
366
- switch (component) {
367
- case "my-custom-component":
368
- return `<div class="my-component-class">${blok.text}</div>`;
369
- break;
370
- default:
371
- return `Component ${component} not found`;
372
- }
373
- },
374
- };
375
- ---
376
-
377
- <RichTextRenderer richTextData={blok.richtext} richTextOptions={options} />
338
+ ### RichTextRenderer `deprecated`
378
339
 
379
- ```
340
+ ~~Use the `<RichTextRenderer />` component if you are embedding `bloks` in your rich text:~~
380
341
 
381
- > **Note**
382
- > Please be aware that the `<RichTextRenderer />` component is **not** supported when using Astro v1. Make sure to use Astro v2 or v3.
342
+ > [!IMPORTANT]
343
+ > As of `@storyblok/astro` v5, the `<RichTextRenderer />` component has been removed. Use the `renderRichText` function instead.
383
344
 
384
345
  ## API
385
346
 
@@ -389,12 +350,12 @@ Returns the instance of the `storyblok-js-client`.
389
350
 
390
351
  ## Enabling Live Preview for Storyblok's Visual Editor
391
352
 
392
- > **Warning**
353
+ > [!WARNING]
393
354
  > This feature is currently experimental and optional. You may encounters bugs or performance issues.
394
355
 
395
356
  The Astro SDK now provides a live preview feature, designed to offer real-time editing capabilities for an enhanced user experience in Storyblok's Visual Editor.
396
357
 
397
- > **Note**
358
+ > [!NOTE]
398
359
  > To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode.
399
360
 
400
361
  To activate the experimental live preview feature, follow these steps:
@@ -1,4 +1,4 @@
1
- (function(w,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(w=typeof globalThis<"u"?globalThis:w||self,N(w.storyblokAstro={}))})(this,function(w){"use strict";function N(o,r,t){const a="virtual:storyblok-init",s="\0"+a;return{name:"vite-plugin-storyblok-init",async resolveId(l){if(l===a)return s},async load(l){if(l===s)return`
1
+ (function(T,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(T=typeof globalThis<"u"?globalThis:T||self,N(T.storyblokAstro={}))})(this,function(T){"use strict";function N(o,r,t){const a="virtual:storyblok-init",s="\0"+a;return{name:"vite-plugin-storyblok-init",async resolveId(l){if(l===a)return s},async load(l){if(l===s)return`
2
2
  import { storyblokInit, apiPlugin } from "@storyblok/js";
3
3
  const { storyblokApi } = storyblokInit({
4
4
  accessToken: "${o}",
@@ -8,7 +8,7 @@
8
8
  export const storyblokApiInstance = storyblokApi;
9
9
  `}}}const Ve=/[\p{Lu}]/u,Xe=/[\p{Ll}]/u,ge=/^[\p{Lu}](?![\p{Lu}])/gu,he=/([\p{Alpha}\p{N}_]|$)/u,te=/[_.\- ]+/,Ze=new RegExp("^"+te.source),ye=new RegExp(te.source+he.source,"gu"),be=new RegExp("\\d+"+he.source,"gu"),Qe=(o,r,t,a)=>{let s=!1,l=!1,u=!1,f=!1;for(let g=0;g<o.length;g++){const b=o[g];f=g>2?o[g-3]==="-":!0,s&&Ve.test(b)?(o=o.slice(0,g)+"-"+o.slice(g),s=!1,u=l,l=!0,g++):l&&u&&Xe.test(b)&&(!f||a)?(o=o.slice(0,g-1)+"-"+o.slice(g-1),u=l,l=!1,s=!0):(s=r(b)===b&&t(b)!==b,u=l,l=t(b)===b&&r(b)!==b)}return o},et=(o,r)=>(ge.lastIndex=0,o.replaceAll(ge,t=>r(t))),tt=(o,r)=>(ye.lastIndex=0,be.lastIndex=0,o.replaceAll(be,(t,a,s)=>["_","-"].includes(o.charAt(s+t.length))?t:r(t)).replaceAll(ye,(t,a)=>r(a)));function me(o,r){if(!(typeof o=="string"||Array.isArray(o)))throw new TypeError("Expected the input to be `string | string[]`");if(r={pascalCase:!1,preserveConsecutiveUppercase:!1,...r},Array.isArray(o)?o=o.map(l=>l.trim()).filter(l=>l.length).join("-"):o=o.trim(),o.length===0)return"";const t=r.locale===!1?l=>l.toLowerCase():l=>l.toLocaleLowerCase(r.locale),a=r.locale===!1?l=>l.toUpperCase():l=>l.toLocaleUpperCase(r.locale);return o.length===1?te.test(o)?"":r.pascalCase?a(o):t(o):(o!==t(o)&&(o=Qe(o,t,a,r.preserveConsecutiveUppercase)),o=o.replace(Ze,""),o=r.preserveConsecutiveUppercase?et(o,t):t(o),r.pascalCase&&(o=a(o.charAt(0))+o.slice(1)),tt(o,a))}function rt(o,r,t,a){const s="virtual:storyblok-components",l="\0"+s;return{name:"vite-plugin-storyblok-components",async resolveId(u){if(u===s)return l},async load(u){if(u===l){const f=[],g=[];for await(const[_,A]of Object.entries(r)){const I=await this.resolve("/"+o+"/"+A+".astro");if(I)f.push(`import ${me(_)} from "${I.id}"`);else if(t)g.push(_);else throw new Error(`Component could not be found for blok "${_}"! Does "${"/"+o+"/"+A}.astro" exist?`)}let b="";if(t)if(b=",FallbackComponent",a){const _=await this.resolve("/"+o+"/"+a+".astro");if(!_)throw new Error(`Custom fallback component could not be found. Does "${"/"+o+"/"+a}.astro" exist?`);f.push(`import FallbackComponent from "${_.id}"`)}else f.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(r).length)return`${f.join(";")};export default {${Object.keys(r).filter(_=>!g.includes(_)).map(_=>me(_)).join(",")}${b}}`;if(t)return`${f[0]}; export default {${b.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
10
10
  Please register your components or enable the fallback component.
11
- Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function nt(o){const r="virtual:storyblok-options",t="\0"+r;return{name:"vite-plugin-storyblok-options",async resolveId(a){if(a===r)return t},async load(a){if(a===t)return`export default ${JSON.stringify(o)}`}}}let ve=!1;const _e=[],ot=o=>new Promise((r,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}ve?s():_e.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const a=document.createElement("script");a.async=!0,a.src=o,a.id="storyblok-javascript-bridge",a.onerror=s=>t(s),a.onload=s=>{_e.forEach(l=>l()),ve=!0,r(s)},document.getElementsByTagName("head")[0].appendChild(a)});var it=Object.defineProperty,at=(o,r,t)=>r in o?it(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,O=(o,r,t)=>(at(o,typeof r!="symbol"?r+"":r,t),t);class st{constructor(){O(this,"isCDNUrl",(r="")=>r.indexOf("/cdn/")>-1),O(this,"getOptionsPage",(r,t=25,a=1)=>({...r,per_page:t,page:a})),O(this,"delay",r=>new Promise(t=>setTimeout(t,r))),O(this,"arrayFrom",(r=0,t)=>[...Array(r)].map(t)),O(this,"range",(r=0,t=r)=>{const a=Math.abs(t-r)||0,s=r<t?1:-1;return this.arrayFrom(a,(l,u)=>u*s+r)}),O(this,"asyncMap",async(r,t)=>Promise.all(r.map(t))),O(this,"flatMap",(r=[],t)=>r.map(t).reduce((a,s)=>[...a,...s],[])),O(this,"escapeHTML",function(r){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,s=RegExp(a.source);return r&&s.test(r)?r.replace(a,l=>t[l]):r})}stringify(r,t,a){const s=[];for(const l in r){if(!Object.prototype.hasOwnProperty.call(r,l))continue;const u=r[l],f=a?"":encodeURIComponent(l);let g;typeof u=="object"?g=this.stringify(u,t?t+encodeURIComponent("["+f+"]"):f,Array.isArray(u)):g=(t?t+encodeURIComponent("["+f+"]"):f)+"="+encodeURIComponent(u),s.push(g)}return s.join("&")}getRegionURL(r){const t="api.storyblok.com",a="api-us.storyblok.com",s="app.storyblokchina.cn",l="api-ap.storyblok.com",u="api-ca.storyblok.com";switch(r){case"us":return a;case"cn":return s;case"ap":return l;case"ca":return u;default:return t}}}const lt=function(o,r){const t={};for(const a in o){const s=o[a];r.indexOf(a)>-1&&s!==null&&(t[a]=s)}return t},ct=o=>o==="email",ut=()=>({singleTag:"hr"}),ft=()=>({tag:"blockquote"}),dt=()=>({tag:"ul"}),pt=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),gt=()=>({singleTag:"br"}),ht=o=>({tag:`h${o.attrs.level}`}),yt=o=>({singleTag:[{tag:"img",attrs:lt(o.attrs,["src","alt","title"])}]}),bt=()=>({tag:"li"}),mt=()=>({tag:"ol"}),vt=()=>({tag:"p"}),_t=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),Tt=()=>({tag:"b"}),wt=()=>({tag:"s"}),kt=()=>({tag:"u"}),At=()=>({tag:"strong"}),St=()=>({tag:"code"}),It=()=>({tag:"i"}),Ot=o=>{if(!o.attrs)return{tag:""};const r=new st().escapeHTML,t={...o.attrs},{linktype:a="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=r(o.attrs.href||"")),ct(a)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},Ct=o=>({tag:[{tag:"span",attrs:o.attrs}]}),jt=()=>({tag:"sub"}),$t=()=>({tag:"sup"}),xt=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Et=o=>{var r;return(r=o.attrs)!=null&&r.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Rt=o=>{var r;return(r=o.attrs)!=null&&r.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},Te={nodes:{horizontal_rule:ut,blockquote:ft,bullet_list:dt,code_block:pt,hard_break:gt,heading:ht,image:yt,list_item:bt,ordered_list:mt,paragraph:vt,emoji:_t},marks:{bold:Tt,strike:wt,underline:kt,strong:At,code:St,italic:It,link:Ot,styled:Ct,subscript:jt,superscript:$t,anchor:xt,highlight:Et,textStyle:Rt}},Pt=function(o){const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,a=RegExp(t.source);return o&&a.test(o)?o.replace(t,s=>r[s]):o};class we{constructor(r){O(this,"marks"),O(this,"nodes"),r||(r=Te),this.marks=r.marks||[],this.nodes=r.nodes||[]}addNode(r,t){this.nodes[r]=t}addMark(r,t){this.marks[r]=t}render(r,t={optimizeImages:!1}){if(r&&r.content&&Array.isArray(r.content)){let a="";return r.content.forEach(s=>{a+=this.renderNode(s)}),t.optimizeImages?this.optimizeImages(a,t.optimizeImages):a}return console.warn(`The render method must receive an Object with a "content" field.
11
+ Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function nt(o){const r="virtual:storyblok-options",t="\0"+r;return{name:"vite-plugin-storyblok-options",async resolveId(a){if(a===r)return t},async load(a){if(a===t)return`export default ${JSON.stringify(o)}`}}}let ve=!1;const _e=[],ot=o=>new Promise((r,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}ve?s():_e.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const a=document.createElement("script");a.async=!0,a.src=o,a.id="storyblok-javascript-bridge",a.onerror=s=>t(s),a.onload=s=>{_e.forEach(l=>l()),ve=!0,r(s)},document.getElementsByTagName("head")[0].appendChild(a)});var it=Object.defineProperty,at=(o,r,t)=>r in o?it(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,O=(o,r,t)=>(at(o,typeof r!="symbol"?r+"":r,t),t);class st{constructor(){O(this,"isCDNUrl",(r="")=>r.indexOf("/cdn/")>-1),O(this,"getOptionsPage",(r,t=25,a=1)=>({...r,per_page:t,page:a})),O(this,"delay",r=>new Promise(t=>setTimeout(t,r))),O(this,"arrayFrom",(r=0,t)=>[...Array(r)].map(t)),O(this,"range",(r=0,t=r)=>{const a=Math.abs(t-r)||0,s=r<t?1:-1;return this.arrayFrom(a,(l,u)=>u*s+r)}),O(this,"asyncMap",async(r,t)=>Promise.all(r.map(t))),O(this,"flatMap",(r=[],t)=>r.map(t).reduce((a,s)=>[...a,...s],[])),O(this,"escapeHTML",function(r){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,s=RegExp(a.source);return r&&s.test(r)?r.replace(a,l=>t[l]):r})}stringify(r,t,a){const s=[];for(const l in r){if(!Object.prototype.hasOwnProperty.call(r,l))continue;const u=r[l],f=a?"":encodeURIComponent(l);let g;typeof u=="object"?g=this.stringify(u,t?t+encodeURIComponent("["+f+"]"):f,Array.isArray(u)):g=(t?t+encodeURIComponent("["+f+"]"):f)+"="+encodeURIComponent(u),s.push(g)}return s.join("&")}getRegionURL(r){const t="api.storyblok.com",a="api-us.storyblok.com",s="app.storyblokchina.cn",l="api-ap.storyblok.com",u="api-ca.storyblok.com";switch(r){case"us":return a;case"cn":return s;case"ap":return l;case"ca":return u;default:return t}}}const lt=function(o,r){const t={};for(const a in o){const s=o[a];r.indexOf(a)>-1&&s!==null&&(t[a]=s)}return t},ct=o=>o==="email",ut=()=>({singleTag:"hr"}),ft=()=>({tag:"blockquote"}),dt=()=>({tag:"ul"}),pt=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),gt=()=>({singleTag:"br"}),ht=o=>({tag:`h${o.attrs.level}`}),yt=o=>({singleTag:[{tag:"img",attrs:lt(o.attrs,["src","alt","title"])}]}),bt=()=>({tag:"li"}),mt=()=>({tag:"ol"}),vt=()=>({tag:"p"}),_t=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),wt=()=>({tag:"b"}),Tt=()=>({tag:"s"}),kt=()=>({tag:"u"}),At=()=>({tag:"strong"}),St=()=>({tag:"code"}),It=()=>({tag:"i"}),Ot=o=>{if(!o.attrs)return{tag:""};const r=new st().escapeHTML,t={...o.attrs},{linktype:a="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=r(o.attrs.href||"")),ct(a)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},Ct=o=>({tag:[{tag:"span",attrs:o.attrs}]}),jt=()=>({tag:"sub"}),$t=()=>({tag:"sup"}),xt=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Et=o=>{var r;return(r=o.attrs)!=null&&r.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Rt=o=>{var r;return(r=o.attrs)!=null&&r.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},we={nodes:{horizontal_rule:ut,blockquote:ft,bullet_list:dt,code_block:pt,hard_break:gt,heading:ht,image:yt,list_item:bt,ordered_list:mt,paragraph:vt,emoji:_t},marks:{bold:wt,strike:Tt,underline:kt,strong:At,code:St,italic:It,link:Ot,styled:Ct,subscript:jt,superscript:$t,anchor:xt,highlight:Et,textStyle:Rt}},Pt=function(o){const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,a=RegExp(t.source);return o&&a.test(o)?o.replace(t,s=>r[s]):o};class Te{constructor(r){O(this,"marks"),O(this,"nodes"),r||(r=we),this.marks=r.marks||[],this.nodes=r.nodes||[]}addNode(r,t){this.nodes[r]=t}addMark(r,t){this.marks[r]=t}render(r,t={optimizeImages:!1}){if(r&&r.content&&Array.isArray(r.content)){let a="";return r.content.forEach(s=>{a+=this.renderNode(s)}),t.optimizeImages?this.optimizeImages(a,t.optimizeImages):a}return console.warn(`The render method must receive an Object with a "content" field.
12
12
  The "content" field must be an array of nodes as the type ISbRichtext.
13
13
  ISbRichtext:
14
14
  content?: ISbRichtext[]
@@ -31,7 +31,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
31
31
  }
32
32
  ],
33
33
  type: 'doc'
34
- }`),""}optimizeImages(r,t){let a=0,s=0,l="",u="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(l+=`width="${t.width}" `,a=t.width),typeof t.height=="number"&&t.height>0&&(l+=`height="${t.height}" `,s=t.height),(t.loading==="lazy"||t.loading==="eager")&&(l+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(l+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(u+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(u+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(u+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(u+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(u+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(u+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(u+=`:rotate(${t.filters.rotate})`),u.length>0&&(u="/filters"+u))),l.length>0&&(r=r.replace(/<img/g,`<img ${l.trim()}`));const f=a>0||s>0||u.length>0?`${a}x${s}${u}`:"";return r=r.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${f}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(r=r.replace(/<img.*?src=["|'](.*?)["|']/g,g=>{var b,_;const A=g.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(A&&A.length>0){const I={srcset:(b=t.srcset)==null?void 0:b.map(T=>{if(typeof T=="number")return`//${A}/m/${T}x0${u} ${T}w`;if(typeof T=="object"&&T.length===2){let L=0,J=0;return typeof T[0]=="number"&&(L=T[0]),typeof T[1]=="number"&&(J=T[1]),`//${A}/m/${L}x${J}${u} ${L}w`}}).join(", "),sizes:(_=t.sizes)==null?void 0:_.map(T=>T).join(", ")};let C="";return I.srcset&&(C+=`srcset="${I.srcset}" `),I.sizes&&(C+=`sizes="${I.sizes}" `),g.replace(/<img/g,`<img ${C.trim()}`)}return g})),r}renderNode(r){const t=[];r.marks&&r.marks.forEach(s=>{const l=this.getMatchingMark(s);l&&l.tag!==""&&t.push(this.renderOpeningTag(l.tag))});const a=this.getMatchingNode(r);return a&&a.tag&&t.push(this.renderOpeningTag(a.tag)),r.content?r.content.forEach(s=>{t.push(this.renderNode(s))}):r.text?t.push(Pt(r.text)):a&&a.singleTag?t.push(this.renderTag(a.singleTag," /")):a&&a.html?t.push(a.html):r.type==="emoji"&&t.push(this.renderEmoji(r)),a&&a.tag&&t.push(this.renderClosingTag(a.tag)),r.marks&&r.marks.slice(0).reverse().forEach(s=>{const l=this.getMatchingMark(s);l&&l.tag!==""&&t.push(this.renderClosingTag(l.tag))}),t.join("")}renderTag(r,t){return r.constructor===String?`<${r}${t}>`:r.map(a=>{if(a.constructor===String)return`<${a}${t}>`;{let s=`<${a.tag}`;if(a.attrs)for(const l in a.attrs){const u=a.attrs[l];u!==null&&(s+=` ${l}="${u}"`)}return`${s}${t}>`}}).join("")}renderOpeningTag(r){return this.renderTag(r,"")}renderClosingTag(r){return r.constructor===String?`</${r}>`:r.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(r){const t=this.nodes[r.type];if(typeof t=="function")return t(r)}getMatchingMark(r){const t=this.marks[r.type];if(typeof t=="function")return t(r)}renderEmoji(r){if(r.attrs.emoji)return r.attrs.emoji;const t=[{tag:"img",attrs:{src:r.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}const Mt=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const r=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return r?{"data-blok-c":JSON.stringify(r),"data-blok-uid":r.id+"-"+r.uid}:{}}catch{return{}}};let Nt,zt="https://app.storyblok.com/f/storyblok-v2-latest.js";const Lt=(o,r)=>{o.addNode("blok",t=>{let a="";return t.attrs.body.forEach(s=>{a+=r(s.component,s)}),{html:a}})},Dt=o=>!o||!(o!=null&&o.content.some(r=>r.content||r.type==="blok"||r.type==="horizontal_rule")),Ut=(o,r,t)=>{let a=t||Nt;if(!a){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Dt(o)?"":(r&&(a=new we(r.schema),r.resolver&&Lt(a,r.resolver)),a.render(o))},Bt=()=>ot(zt);function Ft(o){let r={resolveRelations:[]};function t(a){a&&Array.isArray(r.resolveRelations)&&r.resolveRelations.push(...Array.isArray(a)?a:[a])}for(const a of o)if(a.options){const{apiOptions:s,bridgeOptions:l}=a.options;if(t(s==null?void 0:s.resolve_relations),l){const{resolveRelations:u,...f}=l;t(u),Object.assign(r,f)}}return r.resolveRelations=[...new Set(r.resolveRelations)],r}var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ht(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var G={exports:{}};G.exports,function(o,r){var t=200,a="__lodash_hash_undefined__",s=800,l=16,u=9007199254740991,f="[object Arguments]",g="[object Array]",b="[object AsyncFunction]",_="[object Boolean]",A="[object Date]",I="[object Error]",C="[object Function]",T="[object GeneratorFunction]",L="[object Map]",J="[object Number]",rr="[object Null]",Se="[object Object]",nr="[object Proxy]",or="[object RegExp]",ir="[object Set]",ar="[object String]",sr="[object Undefined]",lr="[object WeakMap]",cr="[object ArrayBuffer]",ur="[object DataView]",fr="[object Float32Array]",dr="[object Float64Array]",pr="[object Int8Array]",gr="[object Int16Array]",hr="[object Int32Array]",yr="[object Uint8Array]",br="[object Uint8ClampedArray]",mr="[object Uint16Array]",vr="[object Uint32Array]",_r=/[\\^$.*+?()[\]{}|]/g,Tr=/^\[object .+?Constructor\]$/,wr=/^(?:0|[1-9]\d*)$/,y={};y[fr]=y[dr]=y[pr]=y[gr]=y[hr]=y[yr]=y[br]=y[mr]=y[vr]=!0,y[f]=y[g]=y[cr]=y[_]=y[ur]=y[A]=y[I]=y[C]=y[L]=y[J]=y[Se]=y[or]=y[ir]=y[ar]=y[lr]=!1;var Ie=typeof q=="object"&&q&&q.Object===Object&&q,kr=typeof self=="object"&&self&&self.Object===Object&&self,D=Ie||kr||Function("return this")(),Oe=r&&!r.nodeType&&r,U=Oe&&!0&&o&&!o.nodeType&&o,Ce=U&&U.exports===Oe,re=Ce&&Ie.process,je=function(){try{var e=U&&U.require&&U.require("util").types;return e||re&&re.binding&&re.binding("util")}catch{}}(),$e=je&&je.isTypedArray;function Ar(e,n,i){switch(i.length){case 0:return e.call(n);case 1:return e.call(n,i[0]);case 2:return e.call(n,i[0],i[1]);case 3:return e.call(n,i[0],i[1],i[2])}return e.apply(n,i)}function Sr(e,n){for(var i=-1,c=Array(e);++i<e;)c[i]=n(i);return c}function Ir(e){return function(n){return e(n)}}function Or(e,n){return e==null?void 0:e[n]}function Cr(e,n){return function(i){return e(n(i))}}var jr=Array.prototype,$r=Function.prototype,K=Object.prototype,ne=D["__core-js_shared__"],W=$r.toString,j=K.hasOwnProperty,xe=function(){var e=/[^.]+$/.exec(ne&&ne.keys&&ne.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ee=K.toString,xr=W.call(Object),Er=RegExp("^"+W.call(j).replace(_r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Y=Ce?D.Buffer:void 0,Re=D.Symbol,Pe=D.Uint8Array,Me=Y?Y.allocUnsafe:void 0,Ne=Cr(Object.getPrototypeOf,Object),ze=Object.create,Rr=K.propertyIsEnumerable,Pr=jr.splice,x=Re?Re.toStringTag:void 0,V=function(){try{var e=ae(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Mr=Y?Y.isBuffer:void 0,Le=Math.max,Nr=Date.now,De=ae(D,"Map"),B=ae(Object,"create"),zr=function(){function e(){}return function(n){if(!R(n))return{};if(ze)return ze(n);e.prototype=n;var i=new e;return e.prototype=void 0,i}}();function E(e){var n=-1,i=e==null?0:e.length;for(this.clear();++n<i;){var c=e[n];this.set(c[0],c[1])}}function Lr(){this.__data__=B?B(null):{},this.size=0}function Dr(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}function Ur(e){var n=this.__data__;if(B){var i=n[e];return i===a?void 0:i}return j.call(n,e)?n[e]:void 0}function Br(e){var n=this.__data__;return B?n[e]!==void 0:j.call(n,e)}function Fr(e,n){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=B&&n===void 0?a:n,this}E.prototype.clear=Lr,E.prototype.delete=Dr,E.prototype.get=Ur,E.prototype.has=Br,E.prototype.set=Fr;function $(e){var n=-1,i=e==null?0:e.length;for(this.clear();++n<i;){var c=e[n];this.set(c[0],c[1])}}function Hr(){this.__data__=[],this.size=0}function qr(e){var n=this.__data__,i=X(n,e);if(i<0)return!1;var c=n.length-1;return i==c?n.pop():Pr.call(n,i,1),--this.size,!0}function Gr(e){var n=this.__data__,i=X(n,e);return i<0?void 0:n[i][1]}function Jr(e){return X(this.__data__,e)>-1}function Kr(e,n){var i=this.__data__,c=X(i,e);return c<0?(++this.size,i.push([e,n])):i[c][1]=n,this}$.prototype.clear=Hr,$.prototype.delete=qr,$.prototype.get=Gr,$.prototype.has=Jr,$.prototype.set=Kr;function P(e){var n=-1,i=e==null?0:e.length;for(this.clear();++n<i;){var c=e[n];this.set(c[0],c[1])}}function Wr(){this.size=0,this.__data__={hash:new E,map:new(De||$),string:new E}}function Yr(e){var n=Q(this,e).delete(e);return this.size-=n?1:0,n}function Vr(e){return Q(this,e).get(e)}function Xr(e){return Q(this,e).has(e)}function Zr(e,n){var i=Q(this,e),c=i.size;return i.set(e,n),this.size+=i.size==c?0:1,this}P.prototype.clear=Wr,P.prototype.delete=Yr,P.prototype.get=Vr,P.prototype.has=Xr,P.prototype.set=Zr;function M(e){var n=this.__data__=new $(e);this.size=n.size}function Qr(){this.__data__=new $,this.size=0}function en(e){var n=this.__data__,i=n.delete(e);return this.size=n.size,i}function tn(e){return this.__data__.get(e)}function rn(e){return this.__data__.has(e)}function nn(e,n){var i=this.__data__;if(i instanceof $){var c=i.__data__;if(!De||c.length<t-1)return c.push([e,n]),this.size=++i.size,this;i=this.__data__=new P(c)}return i.set(e,n),this.size=i.size,this}M.prototype.clear=Qr,M.prototype.delete=en,M.prototype.get=tn,M.prototype.has=rn,M.prototype.set=nn;function on(e,n){var i=ce(e),c=!i&&le(e),p=!i&&!c&&qe(e),h=!i&&!c&&!p&&Je(e),m=i||c||p||h,d=m?Sr(e.length,String):[],v=d.length;for(var S in e)(n||j.call(e,S))&&!(m&&(S=="length"||p&&(S=="offset"||S=="parent")||h&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||Fe(S,v)))&&d.push(S);return d}function oe(e,n,i){(i!==void 0&&!ee(e[n],i)||i===void 0&&!(n in e))&&ie(e,n,i)}function an(e,n,i){var c=e[n];(!(j.call(e,n)&&ee(c,i))||i===void 0&&!(n in e))&&ie(e,n,i)}function X(e,n){for(var i=e.length;i--;)if(ee(e[i][0],n))return i;return-1}function ie(e,n,i){n=="__proto__"&&V?V(e,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[n]=i}var sn=_n();function Z(e){return e==null?e===void 0?sr:rr:x&&x in Object(e)?Tn(e):On(e)}function Ue(e){return F(e)&&Z(e)==f}function ln(e){if(!R(e)||Sn(e))return!1;var n=fe(e)?Er:Tr;return n.test(xn(e))}function cn(e){return F(e)&&Ge(e.length)&&!!y[Z(e)]}function un(e){if(!R(e))return In(e);var n=He(e),i=[];for(var c in e)c=="constructor"&&(n||!j.call(e,c))||i.push(c);return i}function Be(e,n,i,c,p){e!==n&&sn(n,function(h,m){if(p||(p=new M),R(h))fn(e,n,m,i,Be,c,p);else{var d=c?c(se(e,m),h,m+"",e,n,p):void 0;d===void 0&&(d=h),oe(e,m,d)}},Ke)}function fn(e,n,i,c,p,h,m){var d=se(e,i),v=se(n,i),S=m.get(v);if(S){oe(e,i,S);return}var k=h?h(d,v,i+"",e,n,m):void 0,H=k===void 0;if(H){var de=ce(v),pe=!de&&qe(v),Ye=!de&&!pe&&Je(v);k=v,de||pe||Ye?ce(d)?k=d:En(d)?k=bn(d):pe?(H=!1,k=gn(v,!0)):Ye?(H=!1,k=yn(v,!0)):k=[]:Rn(v)||le(v)?(k=d,le(d)?k=Pn(d):(!R(d)||fe(d))&&(k=wn(v))):H=!1}H&&(m.set(v,k),p(k,v,c,h,m),m.delete(v)),oe(e,i,k)}function dn(e,n){return jn(Cn(e,n,We),e+"")}var pn=V?function(e,n){return V(e,"toString",{configurable:!0,enumerable:!1,value:Nn(n),writable:!0})}:We;function gn(e,n){if(n)return e.slice();var i=e.length,c=Me?Me(i):new e.constructor(i);return e.copy(c),c}function hn(e){var n=new e.constructor(e.byteLength);return new Pe(n).set(new Pe(e)),n}function yn(e,n){var i=n?hn(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}function bn(e,n){var i=-1,c=e.length;for(n||(n=Array(c));++i<c;)n[i]=e[i];return n}function mn(e,n,i,c){var p=!i;i||(i={});for(var h=-1,m=n.length;++h<m;){var d=n[h],v=c?c(i[d],e[d],d,i,e):void 0;v===void 0&&(v=e[d]),p?ie(i,d,v):an(i,d,v)}return i}function vn(e){return dn(function(n,i){var c=-1,p=i.length,h=p>1?i[p-1]:void 0,m=p>2?i[2]:void 0;for(h=e.length>3&&typeof h=="function"?(p--,h):void 0,m&&kn(i[0],i[1],m)&&(h=p<3?void 0:h,p=1),n=Object(n);++c<p;){var d=i[c];d&&e(n,d,c,h)}return n})}function _n(e){return function(n,i,c){for(var p=-1,h=Object(n),m=c(n),d=m.length;d--;){var v=m[e?d:++p];if(i(h[v],v,h)===!1)break}return n}}function Q(e,n){var i=e.__data__;return An(n)?i[typeof n=="string"?"string":"hash"]:i.map}function ae(e,n){var i=Or(e,n);return ln(i)?i:void 0}function Tn(e){var n=j.call(e,x),i=e[x];try{e[x]=void 0;var c=!0}catch{}var p=Ee.call(e);return c&&(n?e[x]=i:delete e[x]),p}function wn(e){return typeof e.constructor=="function"&&!He(e)?zr(Ne(e)):{}}function Fe(e,n){var i=typeof e;return n=n??u,!!n&&(i=="number"||i!="symbol"&&wr.test(e))&&e>-1&&e%1==0&&e<n}function kn(e,n,i){if(!R(i))return!1;var c=typeof n;return(c=="number"?ue(i)&&Fe(n,i.length):c=="string"&&n in i)?ee(i[n],e):!1}function An(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function Sn(e){return!!xe&&xe in e}function He(e){var n=e&&e.constructor,i=typeof n=="function"&&n.prototype||K;return e===i}function In(e){var n=[];if(e!=null)for(var i in Object(e))n.push(i);return n}function On(e){return Ee.call(e)}function Cn(e,n,i){return n=Le(n===void 0?e.length-1:n,0),function(){for(var c=arguments,p=-1,h=Le(c.length-n,0),m=Array(h);++p<h;)m[p]=c[n+p];p=-1;for(var d=Array(n+1);++p<n;)d[p]=c[p];return d[n]=i(m),Ar(e,this,d)}}function se(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}var jn=$n(pn);function $n(e){var n=0,i=0;return function(){var c=Nr(),p=l-(c-i);if(i=c,p>0){if(++n>=s)return arguments[0]}else n=0;return e.apply(void 0,arguments)}}function xn(e){if(e!=null){try{return W.call(e)}catch{}try{return e+""}catch{}}return""}function ee(e,n){return e===n||e!==e&&n!==n}var le=Ue(function(){return arguments}())?Ue:function(e){return F(e)&&j.call(e,"callee")&&!Rr.call(e,"callee")},ce=Array.isArray;function ue(e){return e!=null&&Ge(e.length)&&!fe(e)}function En(e){return F(e)&&ue(e)}var qe=Mr||zn;function fe(e){if(!R(e))return!1;var n=Z(e);return n==C||n==T||n==b||n==nr}function Ge(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=u}function R(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}function F(e){return e!=null&&typeof e=="object"}function Rn(e){if(!F(e)||Z(e)!=Se)return!1;var n=Ne(e);if(n===null)return!0;var i=j.call(n,"constructor")&&n.constructor;return typeof i=="function"&&i instanceof i&&W.call(i)==xr}var Je=$e?Ir($e):cn;function Pn(e){return mn(e,Ke(e))}function Ke(e){return ue(e)?on(e,!0):un(e)}var Mn=vn(function(e,n,i,c){Be(e,n,i,c)});function Nn(e){return function(){return e}}function We(e){return e}function zn(){return!1}o.exports=Mn}(G,G.exports);var qt=G.exports;const Gt=Ht(qt);function Jt(o){let r={};function t(a,s){if((s==null?void 0:s.type)==="AwaitExpression"&&s.argument.type==="CallExpression"&&s.argument.callee.type==="Identifier"&&s.argument.callee.name==="useStoryblok"){const l=s.argument.arguments;if(l&&l[1].type==="ObjectExpression"){const u=ke(l[1].properties);r={...r,apiOptions:u}}if(l&&l[2].type==="ObjectExpression"){const u=ke(l[2].properties);r={...r,bridgeOptions:u}}}}return Gt({},o,t),r}function ke(o){const r={};return o.reduce((t,a)=>{if(a.type!=="Property")return t;const{key:s,value:l}=a,{type:u}=l;if(s.type!=="Identifier")return t;if(u==="Literal")t[s.name]=l.value;else if(u==="ArrayExpression"){const f=l.elements.reduce((g,b)=>b.type==="Literal"&&b.value?[...g,b.value]:g,[]);t[s.name]=f}return t},r)}let z=[];function Kt(o,r){const t="virtual:storyblok-bridge",a="\0"+t;if(!o||r!=="server")return{name:"vite-plugin-storyblok-bridge",resolveId(f){if(f===t)return a},load(f){if(f===a)return"export const bridgeOptions = null"}};let s=[],l=null,u;return{name:"vite-plugin-storyblok-bridge",async resolveId(f){if(f===t)return a},async transform(f,g){var C;if(g.includes("node_modules")&&!g.includes("/pages/")||!f.includes("useStoryblok")||!((C=this.getModuleInfo(g).meta)!=null&&C.astro))return;const[,..._]=g.split("src/pages/"),A=_.join("/").replace(".astro",""),I=Jt(this.parse(f));z.length&&(s=z.filter(T=>T.url!==A)),s.push({url:A,options:I}),l&&(u&&clearTimeout(u),u=setTimeout(()=>{Wt(z,s)||(z.length!==0&&(l.restart(),console.info("Bridge options updated. Restarting...")),z=[...s])},1e3))},async load(f){if(f===a)return`export const bridgeOptions = ${JSON.stringify(Ft(s))}`},configureServer(f){l=f}}}function Wt(o=[],r=[]){return r.every(({url:t,options:a})=>{const s=o.find(l=>(l==null?void 0:l.url)===t);return s&&JSON.stringify(a)===JSON.stringify(s.options)})}let Ae;async function Yt(o){const{action:r,story:t}=o||{};if(r==="input"&&t){const a=async()=>{const l=await Xt(t),u=document.body;if(l.outerHTML===u.outerHTML)return;const f=document.querySelector('[data-blok-focused="true"]');Vt(u,l,f)};clearTimeout(Ae),Ae=setTimeout(a,500)}["published","change"].includes(o==null?void 0:o.action)&&location.reload()}function Vt(o,r,t){if(t){const a=t.getAttribute("data-blok-uid"),s=r.querySelector(`[data-blok-uid="${a}"]`);s&&(s.setAttribute("data-blok-focused","true"),t.replaceWith(s))}else o.replaceWith(r)}async function Xt(o){const t=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...o,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(t,"text/html").body}function Zt(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}async function Qt(o,r={},t={},a){globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly");let s=null;if(a&&a.locals._storyblok_preview_data)s=a.locals._storyblok_preview_data;else{const{data:l}=await globalThis.storyblokApiInstance.get(o,r,t);s=l.story}return s}function er(o,r){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ut(o,r,t)}function tr(o){const r={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...o};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:t,updateConfig:a,addDevToolbarApp:s,addMiddleware:l,config:u})=>{if(a({vite:{plugins:[N(r.accessToken,r.useCustomApi,r.apiOptions),rt(r.componentsDir,r.components,r.enableFallbackComponent,r.customFallbackComponent),nt(r),Kt(r.livePreview,u.output)]}}),r.livePreview&&(u==null?void 0:u.output)!=="server")throw new Error("To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode.");if(t("page-ssr",`
34
+ }`),""}optimizeImages(r,t){let a=0,s=0,l="",u="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(l+=`width="${t.width}" `,a=t.width),typeof t.height=="number"&&t.height>0&&(l+=`height="${t.height}" `,s=t.height),(t.loading==="lazy"||t.loading==="eager")&&(l+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(l+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(u+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(u+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(u+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(u+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(u+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(u+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(u+=`:rotate(${t.filters.rotate})`),u.length>0&&(u="/filters"+u))),l.length>0&&(r=r.replace(/<img/g,`<img ${l.trim()}`));const f=a>0||s>0||u.length>0?`${a}x${s}${u}`:"";return r=r.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${f}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(r=r.replace(/<img.*?src=["|'](.*?)["|']/g,g=>{var b,_;const A=g.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(A&&A.length>0){const I={srcset:(b=t.srcset)==null?void 0:b.map(w=>{if(typeof w=="number")return`//${A}/m/${w}x0${u} ${w}w`;if(typeof w=="object"&&w.length===2){let L=0,J=0;return typeof w[0]=="number"&&(L=w[0]),typeof w[1]=="number"&&(J=w[1]),`//${A}/m/${L}x${J}${u} ${L}w`}}).join(", "),sizes:(_=t.sizes)==null?void 0:_.map(w=>w).join(", ")};let C="";return I.srcset&&(C+=`srcset="${I.srcset}" `),I.sizes&&(C+=`sizes="${I.sizes}" `),g.replace(/<img/g,`<img ${C.trim()}`)}return g})),r}renderNode(r){const t=[];r.marks&&r.marks.forEach(s=>{const l=this.getMatchingMark(s);l&&l.tag!==""&&t.push(this.renderOpeningTag(l.tag))});const a=this.getMatchingNode(r);return a&&a.tag&&t.push(this.renderOpeningTag(a.tag)),r.content?r.content.forEach(s=>{t.push(this.renderNode(s))}):r.text?t.push(Pt(r.text)):a&&a.singleTag?t.push(this.renderTag(a.singleTag," /")):a&&a.html?t.push(a.html):r.type==="emoji"&&t.push(this.renderEmoji(r)),a&&a.tag&&t.push(this.renderClosingTag(a.tag)),r.marks&&r.marks.slice(0).reverse().forEach(s=>{const l=this.getMatchingMark(s);l&&l.tag!==""&&t.push(this.renderClosingTag(l.tag))}),t.join("")}renderTag(r,t){return r.constructor===String?`<${r}${t}>`:r.map(a=>{if(a.constructor===String)return`<${a}${t}>`;{let s=`<${a.tag}`;if(a.attrs){for(const l in a.attrs)if(Object.prototype.hasOwnProperty.call(a.attrs,l)){const u=a.attrs[l];u!==null&&(s+=` ${l}="${u}"`)}}return`${s}${t}>`}}).join("")}renderOpeningTag(r){return this.renderTag(r,"")}renderClosingTag(r){return r.constructor===String?`</${r}>`:r.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(r){const t=this.nodes[r.type];if(typeof t=="function")return t(r)}getMatchingMark(r){const t=this.marks[r.type];if(typeof t=="function")return t(r)}renderEmoji(r){if(r.attrs.emoji)return r.attrs.emoji;const t=[{tag:"img",attrs:{src:r.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}const Mt=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const r=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return r?{"data-blok-c":JSON.stringify(r),"data-blok-uid":r.id+"-"+r.uid}:{}}catch{return{}}};let Nt,zt="https://app.storyblok.com/f/storyblok-v2-latest.js";const Lt=(o,r)=>{o.addNode("blok",t=>{let a="";return t.attrs.body.forEach(s=>{a+=r(s.component,s)}),{html:a}})},Dt=o=>!o||!(o!=null&&o.content.some(r=>r.content||r.type==="blok"||r.type==="horizontal_rule")),Ut=(o,r,t)=>{let a=t||Nt;if(!a){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Dt(o)?"":(r&&(a=new Te(r.schema),r.resolver&&Lt(a,r.resolver)),a.render(o))},Bt=()=>ot(zt);function Ft(o){let r={resolveRelations:[]};function t(a){a&&Array.isArray(r.resolveRelations)&&r.resolveRelations.push(...Array.isArray(a)?a:[a])}for(const a of o)if(a.options){const{apiOptions:s,bridgeOptions:l}=a.options;if(t(s==null?void 0:s.resolve_relations),l){const{resolveRelations:u,...f}=l;t(u),Object.assign(r,f)}}return r.resolveRelations=[...new Set(r.resolveRelations)],r}var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ht(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var G={exports:{}};G.exports,function(o,r){var t=200,a="__lodash_hash_undefined__",s=800,l=16,u=9007199254740991,f="[object Arguments]",g="[object Array]",b="[object AsyncFunction]",_="[object Boolean]",A="[object Date]",I="[object Error]",C="[object Function]",w="[object GeneratorFunction]",L="[object Map]",J="[object Number]",rr="[object Null]",Se="[object Object]",nr="[object Proxy]",or="[object RegExp]",ir="[object Set]",ar="[object String]",sr="[object Undefined]",lr="[object WeakMap]",cr="[object ArrayBuffer]",ur="[object DataView]",fr="[object Float32Array]",dr="[object Float64Array]",pr="[object Int8Array]",gr="[object Int16Array]",hr="[object Int32Array]",yr="[object Uint8Array]",br="[object Uint8ClampedArray]",mr="[object Uint16Array]",vr="[object Uint32Array]",_r=/[\\^$.*+?()[\]{}|]/g,wr=/^\[object .+?Constructor\]$/,Tr=/^(?:0|[1-9]\d*)$/,y={};y[fr]=y[dr]=y[pr]=y[gr]=y[hr]=y[yr]=y[br]=y[mr]=y[vr]=!0,y[f]=y[g]=y[cr]=y[_]=y[ur]=y[A]=y[I]=y[C]=y[L]=y[J]=y[Se]=y[or]=y[ir]=y[ar]=y[lr]=!1;var Ie=typeof q=="object"&&q&&q.Object===Object&&q,kr=typeof self=="object"&&self&&self.Object===Object&&self,D=Ie||kr||Function("return this")(),Oe=r&&!r.nodeType&&r,U=Oe&&!0&&o&&!o.nodeType&&o,Ce=U&&U.exports===Oe,re=Ce&&Ie.process,je=function(){try{var e=U&&U.require&&U.require("util").types;return e||re&&re.binding&&re.binding("util")}catch{}}(),$e=je&&je.isTypedArray;function Ar(e,n,i){switch(i.length){case 0:return e.call(n);case 1:return e.call(n,i[0]);case 2:return e.call(n,i[0],i[1]);case 3:return e.call(n,i[0],i[1],i[2])}return e.apply(n,i)}function Sr(e,n){for(var i=-1,c=Array(e);++i<e;)c[i]=n(i);return c}function Ir(e){return function(n){return e(n)}}function Or(e,n){return e==null?void 0:e[n]}function Cr(e,n){return function(i){return e(n(i))}}var jr=Array.prototype,$r=Function.prototype,K=Object.prototype,ne=D["__core-js_shared__"],W=$r.toString,j=K.hasOwnProperty,xe=function(){var e=/[^.]+$/.exec(ne&&ne.keys&&ne.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ee=K.toString,xr=W.call(Object),Er=RegExp("^"+W.call(j).replace(_r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Y=Ce?D.Buffer:void 0,Re=D.Symbol,Pe=D.Uint8Array,Me=Y?Y.allocUnsafe:void 0,Ne=Cr(Object.getPrototypeOf,Object),ze=Object.create,Rr=K.propertyIsEnumerable,Pr=jr.splice,x=Re?Re.toStringTag:void 0,V=function(){try{var e=ae(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Mr=Y?Y.isBuffer:void 0,Le=Math.max,Nr=Date.now,De=ae(D,"Map"),B=ae(Object,"create"),zr=function(){function e(){}return function(n){if(!R(n))return{};if(ze)return ze(n);e.prototype=n;var i=new e;return e.prototype=void 0,i}}();function E(e){var n=-1,i=e==null?0:e.length;for(this.clear();++n<i;){var c=e[n];this.set(c[0],c[1])}}function Lr(){this.__data__=B?B(null):{},this.size=0}function Dr(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}function Ur(e){var n=this.__data__;if(B){var i=n[e];return i===a?void 0:i}return j.call(n,e)?n[e]:void 0}function Br(e){var n=this.__data__;return B?n[e]!==void 0:j.call(n,e)}function Fr(e,n){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=B&&n===void 0?a:n,this}E.prototype.clear=Lr,E.prototype.delete=Dr,E.prototype.get=Ur,E.prototype.has=Br,E.prototype.set=Fr;function $(e){var n=-1,i=e==null?0:e.length;for(this.clear();++n<i;){var c=e[n];this.set(c[0],c[1])}}function Hr(){this.__data__=[],this.size=0}function qr(e){var n=this.__data__,i=X(n,e);if(i<0)return!1;var c=n.length-1;return i==c?n.pop():Pr.call(n,i,1),--this.size,!0}function Gr(e){var n=this.__data__,i=X(n,e);return i<0?void 0:n[i][1]}function Jr(e){return X(this.__data__,e)>-1}function Kr(e,n){var i=this.__data__,c=X(i,e);return c<0?(++this.size,i.push([e,n])):i[c][1]=n,this}$.prototype.clear=Hr,$.prototype.delete=qr,$.prototype.get=Gr,$.prototype.has=Jr,$.prototype.set=Kr;function P(e){var n=-1,i=e==null?0:e.length;for(this.clear();++n<i;){var c=e[n];this.set(c[0],c[1])}}function Wr(){this.size=0,this.__data__={hash:new E,map:new(De||$),string:new E}}function Yr(e){var n=Q(this,e).delete(e);return this.size-=n?1:0,n}function Vr(e){return Q(this,e).get(e)}function Xr(e){return Q(this,e).has(e)}function Zr(e,n){var i=Q(this,e),c=i.size;return i.set(e,n),this.size+=i.size==c?0:1,this}P.prototype.clear=Wr,P.prototype.delete=Yr,P.prototype.get=Vr,P.prototype.has=Xr,P.prototype.set=Zr;function M(e){var n=this.__data__=new $(e);this.size=n.size}function Qr(){this.__data__=new $,this.size=0}function en(e){var n=this.__data__,i=n.delete(e);return this.size=n.size,i}function tn(e){return this.__data__.get(e)}function rn(e){return this.__data__.has(e)}function nn(e,n){var i=this.__data__;if(i instanceof $){var c=i.__data__;if(!De||c.length<t-1)return c.push([e,n]),this.size=++i.size,this;i=this.__data__=new P(c)}return i.set(e,n),this.size=i.size,this}M.prototype.clear=Qr,M.prototype.delete=en,M.prototype.get=tn,M.prototype.has=rn,M.prototype.set=nn;function on(e,n){var i=ce(e),c=!i&&le(e),p=!i&&!c&&qe(e),h=!i&&!c&&!p&&Je(e),m=i||c||p||h,d=m?Sr(e.length,String):[],v=d.length;for(var S in e)(n||j.call(e,S))&&!(m&&(S=="length"||p&&(S=="offset"||S=="parent")||h&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||Fe(S,v)))&&d.push(S);return d}function oe(e,n,i){(i!==void 0&&!ee(e[n],i)||i===void 0&&!(n in e))&&ie(e,n,i)}function an(e,n,i){var c=e[n];(!(j.call(e,n)&&ee(c,i))||i===void 0&&!(n in e))&&ie(e,n,i)}function X(e,n){for(var i=e.length;i--;)if(ee(e[i][0],n))return i;return-1}function ie(e,n,i){n=="__proto__"&&V?V(e,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[n]=i}var sn=_n();function Z(e){return e==null?e===void 0?sr:rr:x&&x in Object(e)?wn(e):On(e)}function Ue(e){return F(e)&&Z(e)==f}function ln(e){if(!R(e)||Sn(e))return!1;var n=fe(e)?Er:wr;return n.test(xn(e))}function cn(e){return F(e)&&Ge(e.length)&&!!y[Z(e)]}function un(e){if(!R(e))return In(e);var n=He(e),i=[];for(var c in e)c=="constructor"&&(n||!j.call(e,c))||i.push(c);return i}function Be(e,n,i,c,p){e!==n&&sn(n,function(h,m){if(p||(p=new M),R(h))fn(e,n,m,i,Be,c,p);else{var d=c?c(se(e,m),h,m+"",e,n,p):void 0;d===void 0&&(d=h),oe(e,m,d)}},Ke)}function fn(e,n,i,c,p,h,m){var d=se(e,i),v=se(n,i),S=m.get(v);if(S){oe(e,i,S);return}var k=h?h(d,v,i+"",e,n,m):void 0,H=k===void 0;if(H){var de=ce(v),pe=!de&&qe(v),Ye=!de&&!pe&&Je(v);k=v,de||pe||Ye?ce(d)?k=d:En(d)?k=bn(d):pe?(H=!1,k=gn(v,!0)):Ye?(H=!1,k=yn(v,!0)):k=[]:Rn(v)||le(v)?(k=d,le(d)?k=Pn(d):(!R(d)||fe(d))&&(k=Tn(v))):H=!1}H&&(m.set(v,k),p(k,v,c,h,m),m.delete(v)),oe(e,i,k)}function dn(e,n){return jn(Cn(e,n,We),e+"")}var pn=V?function(e,n){return V(e,"toString",{configurable:!0,enumerable:!1,value:Nn(n),writable:!0})}:We;function gn(e,n){if(n)return e.slice();var i=e.length,c=Me?Me(i):new e.constructor(i);return e.copy(c),c}function hn(e){var n=new e.constructor(e.byteLength);return new Pe(n).set(new Pe(e)),n}function yn(e,n){var i=n?hn(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}function bn(e,n){var i=-1,c=e.length;for(n||(n=Array(c));++i<c;)n[i]=e[i];return n}function mn(e,n,i,c){var p=!i;i||(i={});for(var h=-1,m=n.length;++h<m;){var d=n[h],v=c?c(i[d],e[d],d,i,e):void 0;v===void 0&&(v=e[d]),p?ie(i,d,v):an(i,d,v)}return i}function vn(e){return dn(function(n,i){var c=-1,p=i.length,h=p>1?i[p-1]:void 0,m=p>2?i[2]:void 0;for(h=e.length>3&&typeof h=="function"?(p--,h):void 0,m&&kn(i[0],i[1],m)&&(h=p<3?void 0:h,p=1),n=Object(n);++c<p;){var d=i[c];d&&e(n,d,c,h)}return n})}function _n(e){return function(n,i,c){for(var p=-1,h=Object(n),m=c(n),d=m.length;d--;){var v=m[e?d:++p];if(i(h[v],v,h)===!1)break}return n}}function Q(e,n){var i=e.__data__;return An(n)?i[typeof n=="string"?"string":"hash"]:i.map}function ae(e,n){var i=Or(e,n);return ln(i)?i:void 0}function wn(e){var n=j.call(e,x),i=e[x];try{e[x]=void 0;var c=!0}catch{}var p=Ee.call(e);return c&&(n?e[x]=i:delete e[x]),p}function Tn(e){return typeof e.constructor=="function"&&!He(e)?zr(Ne(e)):{}}function Fe(e,n){var i=typeof e;return n=n??u,!!n&&(i=="number"||i!="symbol"&&Tr.test(e))&&e>-1&&e%1==0&&e<n}function kn(e,n,i){if(!R(i))return!1;var c=typeof n;return(c=="number"?ue(i)&&Fe(n,i.length):c=="string"&&n in i)?ee(i[n],e):!1}function An(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function Sn(e){return!!xe&&xe in e}function He(e){var n=e&&e.constructor,i=typeof n=="function"&&n.prototype||K;return e===i}function In(e){var n=[];if(e!=null)for(var i in Object(e))n.push(i);return n}function On(e){return Ee.call(e)}function Cn(e,n,i){return n=Le(n===void 0?e.length-1:n,0),function(){for(var c=arguments,p=-1,h=Le(c.length-n,0),m=Array(h);++p<h;)m[p]=c[n+p];p=-1;for(var d=Array(n+1);++p<n;)d[p]=c[p];return d[n]=i(m),Ar(e,this,d)}}function se(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}var jn=$n(pn);function $n(e){var n=0,i=0;return function(){var c=Nr(),p=l-(c-i);if(i=c,p>0){if(++n>=s)return arguments[0]}else n=0;return e.apply(void 0,arguments)}}function xn(e){if(e!=null){try{return W.call(e)}catch{}try{return e+""}catch{}}return""}function ee(e,n){return e===n||e!==e&&n!==n}var le=Ue(function(){return arguments}())?Ue:function(e){return F(e)&&j.call(e,"callee")&&!Rr.call(e,"callee")},ce=Array.isArray;function ue(e){return e!=null&&Ge(e.length)&&!fe(e)}function En(e){return F(e)&&ue(e)}var qe=Mr||zn;function fe(e){if(!R(e))return!1;var n=Z(e);return n==C||n==w||n==b||n==nr}function Ge(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=u}function R(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}function F(e){return e!=null&&typeof e=="object"}function Rn(e){if(!F(e)||Z(e)!=Se)return!1;var n=Ne(e);if(n===null)return!0;var i=j.call(n,"constructor")&&n.constructor;return typeof i=="function"&&i instanceof i&&W.call(i)==xr}var Je=$e?Ir($e):cn;function Pn(e){return mn(e,Ke(e))}function Ke(e){return ue(e)?on(e,!0):un(e)}var Mn=vn(function(e,n,i,c){Be(e,n,i,c)});function Nn(e){return function(){return e}}function We(e){return e}function zn(){return!1}o.exports=Mn}(G,G.exports);var qt=G.exports;const Gt=Ht(qt);function Jt(o){let r={};function t(a,s){if((s==null?void 0:s.type)==="AwaitExpression"&&s.argument.type==="CallExpression"&&s.argument.callee.type==="Identifier"&&s.argument.callee.name==="useStoryblok"){const l=s.argument.arguments;if(l&&l[1].type==="ObjectExpression"){const u=ke(l[1].properties);r={...r,apiOptions:u}}if(l&&l[2].type==="ObjectExpression"){const u=ke(l[2].properties);r={...r,bridgeOptions:u}}}}return Gt({},o,t),r}function ke(o){const r={};return o.reduce((t,a)=>{if(a.type!=="Property")return t;const{key:s,value:l}=a,{type:u}=l;if(s.type!=="Identifier")return t;if(u==="Literal")t[s.name]=l.value;else if(u==="ArrayExpression"){const f=l.elements.reduce((g,b)=>b.type==="Literal"&&b.value?[...g,b.value]:g,[]);t[s.name]=f}return t},r)}let z=[];function Kt(o,r){const t="virtual:storyblok-bridge",a="\0"+t;if(!o||r!=="server")return{name:"vite-plugin-storyblok-bridge",resolveId(f){if(f===t)return a},load(f){if(f===a)return"export const bridgeOptions = null"}};let s=[],l=null,u;return{name:"vite-plugin-storyblok-bridge",async resolveId(f){if(f===t)return a},async transform(f,g){var C;if(g.includes("node_modules")&&!g.includes("/pages/")||!f.includes("useStoryblok")||!((C=this.getModuleInfo(g).meta)!=null&&C.astro))return;const[,..._]=g.split("src/pages/"),A=_.join("/").replace(".astro",""),I=Jt(this.parse(f));z.length&&(s=z.filter(w=>w.url!==A)),s.push({url:A,options:I}),l&&(u&&clearTimeout(u),u=setTimeout(()=>{Wt(z,s)||(z.length!==0&&(l.restart(),console.info("Bridge options updated. Restarting...")),z=[...s])},1e3))},async load(f){if(f===a)return`export const bridgeOptions = ${JSON.stringify(Ft(s))}`},configureServer(f){l=f}}}function Wt(o=[],r=[]){return r.every(({url:t,options:a})=>{const s=o.find(l=>(l==null?void 0:l.url)===t);return s&&JSON.stringify(a)===JSON.stringify(s.options)})}let Ae;async function Yt(o){const{action:r,story:t}=o||{};if(r==="input"&&t){const a=async()=>{const l=await Xt(t),u=document.body;if(l.outerHTML===u.outerHTML)return;const f=document.querySelector('[data-blok-focused="true"]');Vt(u,l,f)};clearTimeout(Ae),Ae=setTimeout(a,500)}["published","change"].includes(o==null?void 0:o.action)&&location.reload()}function Vt(o,r,t){if(t){const a=t.getAttribute("data-blok-uid"),s=r.querySelector(`[data-blok-uid="${a}"]`);s&&(s.setAttribute("data-blok-focused","true"),t.replaceWith(s))}else o.replaceWith(r)}async function Xt(o){const t=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...o,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(t,"text/html").body}function Zt(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}async function Qt(o,r={},t={},a){globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly");let s=null;if(a&&a.locals._storyblok_preview_data)s=a.locals._storyblok_preview_data;else{const{data:l}=await globalThis.storyblokApiInstance.get(o,r,t);s=l.story}return s}function er(o,r){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ut(o,r,t)}function tr(o){const r={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,livePreview:!1,...o};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:t,updateConfig:a,addDevToolbarApp:s,addMiddleware:l,config:u})=>{if(a({vite:{plugins:[N(r.accessToken,r.useCustomApi,r.apiOptions),rt(r.componentsDir,r.components,r.enableFallbackComponent,r.customFallbackComponent),nt(r),Kt(r.livePreview,u.output)]}}),r.livePreview&&(u==null?void 0:u.output)!=="server")throw new Error("To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode.");if(t("page-ssr",`
35
35
  import { storyblokApiInstance } from "virtual:storyblok-init";
36
36
  globalThis.storyblokApiInstance = storyblokApiInstance;
37
37
  `),r.bridge&&!r.livePreview){let f="";if(typeof r.bridge=="object"){const g={...r.bridge};f=`const storyblokInstance = new StoryblokBridge(${JSON.stringify(g)});`}else f="const storyblokInstance = new StoryblokBridge()";t("page",`
@@ -57,4 +57,4 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
57
57
  storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
58
58
  };
59
59
  });
60
- `),l({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),s("@storyblok/astro/toolbarApp.ts")}}}}w.RichTextResolver=we,w.RichTextSchema=Te,w.default=tr,w.handleStoryblokMessage=Yt,w.loadStoryblokBridge=Bt,w.renderRichText=er,w.storyblokEditable=Mt,w.useStoryblok=Qt,w.useStoryblokApi=Zt,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
60
+ `),l({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),s("@storyblok/astro/toolbarApp.ts")}}}}T.RichTextResolver=Te,T.RichTextSchema=we,T.default=tr,T.handleStoryblokMessage=Yt,T.loadStoryblokBridge=Bt,T.renderRichText=er,T.storyblokEditable=Mt,T.useStoryblok=Qt,T.useStoryblokApi=Zt,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});