@storyblok/astro 5.0.2 → 5.1.0-alpha.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
@@ -375,33 +375,47 @@ export default defineConfig({
375
375
  });
376
376
  ```
377
377
 
378
- 2. Additionally, please use `useStoryblok` on your Astro pages for story fetching. This replaces the previously used `useStoryblokApi` method.
378
+ 1. Additionally, please use `getLiveStory` on your Astro pages for getting live story.
379
379
 
380
380
  ```jsx
381
381
  //pages/[...slug].astro
382
382
  ---
383
- import { useStoryblok } from "@storyblok/astro";
383
+ import { getLiveStory, useStoryblokApi, type ISbStoryData } from "@storyblok/astro";
384
384
  import StoryblokComponent from "@storyblok/astro/StoryblokComponent.astro";
385
385
 
386
386
  const { slug } = Astro.params;
387
387
 
388
- const story = await useStoryblok(
389
- // The slug to fetch
390
- `cdn/stories/${slug === undefined ? "home" : slug}`,
391
- // The API options
392
- {
393
- version: "draft",
394
- },
395
- // The Bridge options (optional, if an empty object, null, or false are set, the API options will be considered automatically as far as applicable)
396
- {},
397
- // The Astro object (essential for the live preview functionality)
398
- Astro
399
- );
388
+ let story: ISbStoryData = null;
389
+
390
+ const liveStory = await getLiveStory(Astro);
391
+
392
+ if (liveStory) {
393
+ story = liveStory;
394
+ } else {
395
+ const sbApi = useStoryblokApi();
396
+ const { data } = await sbApi.get(
397
+ `cdn/stories/${slug === undefined ? "home" : slug}`,
398
+ {
399
+ version: "draft",
400
+ resolve_relations: ["featured-articles.posts"],
401
+ }
402
+ );
403
+ story = data?.story;
404
+ }
400
405
  ---
401
406
 
402
407
  <StoryblokComponent blok={story.content} />
403
408
  ```
409
+ 2. You can also listen to when the live preview is updated.
404
410
 
411
+ ```js
412
+ <script>
413
+ document.addEventListener("storyblok-live-preview-updated", () => {
414
+ // console.log("Live preview: body updated");
415
+ // initUnoCssRuntime(); regenerate all the css
416
+ });
417
+ </script>
418
+ ```
405
419
  ## The Storyblok JavaScript SDK Ecosystem
406
420
 
407
421
  ![A visual representation of the Storyblok JavaScript SDK Ecosystem](https://a.storyblok.com/f/88751/2400x1350/be4a4a4180/sdk-ecosystem.png/m/1200x0)
@@ -1,14 +1,14 @@
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 i="virtual:storyblok-init",s="\0"+i;return{name:"vite-plugin-storyblok-init",async resolveId(l){if(l===i)return s},async load(l){if(l===s)return`
1
+ (function(d,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(d=typeof globalThis<"u"?globalThis:d||self,y(d.storyblokAstro={}))})(this,function(d){"use strict";function y(r,t,e){const o="virtual:storyblok-init",s="\0"+o;return{name:"vite-plugin-storyblok-init",async resolveId(n){if(n===o)return s},async load(n){if(n===s)return`
2
2
  import { storyblokInit, apiPlugin } from "@storyblok/js";
3
3
  const { storyblokApi } = storyblokInit({
4
- accessToken: "${o}",
5
- use: ${r?"[]":"[apiPlugin]"},
6
- apiOptions: ${JSON.stringify(t)},
4
+ accessToken: "${r}",
5
+ use: ${t?"[]":"[apiPlugin]"},
6
+ apiOptions: ${JSON.stringify(e)},
7
7
  });
8
8
  export const storyblokApiInstance = storyblokApi;
9
- `}}}const Ye=/[\p{Lu}]/u,Ze=/[\p{Ll}]/u,ge=/^[\p{Lu}](?![\p{Lu}])/gu,he=/([\p{Alpha}\p{N}_]|$)/u,te=/[_.\- ]+/,Qe=new RegExp("^"+te.source),be=new RegExp(te.source+he.source,"gu"),ye=new RegExp("\\d+"+he.source,"gu"),Ve=(o,r,t,i)=>{let s=!1,l=!1,u=!1,f=!1;for(let p=0;p<o.length;p++){const y=o[p];f=p>2?o[p-3]==="-":!0,s&&Ye.test(y)?(o=o.slice(0,p)+"-"+o.slice(p),s=!1,u=l,l=!0,p++):l&&u&&Ze.test(y)&&(!f||i)?(o=o.slice(0,p-1)+"-"+o.slice(p-1),u=l,l=!1,s=!0):(s=r(y)===y&&t(y)!==y,u=l,l=t(y)===y&&r(y)!==y)}return o},et=(o,r)=>(ge.lastIndex=0,o.replaceAll(ge,t=>r(t))),tt=(o,r)=>(be.lastIndex=0,ye.lastIndex=0,o.replaceAll(ye,(t,i,s)=>["_","-"].includes(o.charAt(s+t.length))?t:r(t)).replaceAll(be,(t,i)=>r(i)));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),i=r.locale===!1?l=>l.toUpperCase():l=>l.toLocaleUpperCase(r.locale);return o.length===1?te.test(o)?"":r.pascalCase?i(o):t(o):(o!==t(o)&&(o=Ve(o,t,i,r.preserveConsecutiveUppercase)),o=o.replace(Qe,""),o=r.preserveConsecutiveUppercase?et(o,t):t(o),r.pascalCase&&(o=i(o.charAt(0))+o.slice(1)),tt(o,i))}function rt(o,r,t,i){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=[],p=[];for await(const[_,A]of Object.entries(r)){const S=await this.resolve("/"+o+"/"+A+".astro");if(S)f.push(`import ${me(_)} from "${S.id}"`);else if(t)p.push(_);else throw new Error(`Component could not be found for blok "${_}"! Does "${"/"+o+"/"+A}.astro" exist?`)}let y="";if(t)if(y=",FallbackComponent",i){const _=await this.resolve("/"+o+"/"+i+".astro");if(!_)throw new Error(`Custom fallback component could not be found. Does "${"/"+o+"/"+i}.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(_=>!p.includes(_)).map(_=>me(_)).join(",")}${y}}`;if(t)return`${f[0]}; export default {${y.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
9
+ `}}}const M=/[\p{Lu}]/u,O=/[\p{Ll}]/u,w=/^[\p{Lu}](?![\p{Lu}])/gu,v=/([\p{Alpha}\p{N}_]|$)/u,b=/[_.\- ]+/,_=new RegExp("^"+b.source),$=new RegExp(b.source+v.source,"gu"),S=new RegExp("\\d+"+v.source,"gu"),L=(r,t,e,o)=>{let s=!1,n=!1,a=!1,i=!1;for(let l=0;l<r.length;l++){const c=r[l];i=l>2?r[l-3]==="-":!0,s&&M.test(c)?(r=r.slice(0,l)+"-"+r.slice(l),s=!1,a=n,n=!0,l++):n&&a&&O.test(c)&&(!i||o)?(r=r.slice(0,l-1)+"-"+r.slice(l-1),a=n,n=!1,s=!0):(s=t(c)===c&&e(c)!==c,a=n,n=e(c)===c&&t(c)!==c)}return r},P=(r,t)=>(w.lastIndex=0,r.replaceAll(w,e=>t(e))),N=(r,t)=>($.lastIndex=0,S.lastIndex=0,r.replaceAll(S,(e,o,s)=>["_","-"].includes(r.charAt(s+e.length))?e:t(e)).replaceAll($,(e,o)=>t(o)));function I(r,t){if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(r)?r=r.map(n=>n.trim()).filter(n=>n.length).join("-"):r=r.trim(),r.length===0)return"";const e=t.locale===!1?n=>n.toLowerCase():n=>n.toLocaleLowerCase(t.locale),o=t.locale===!1?n=>n.toUpperCase():n=>n.toLocaleUpperCase(t.locale);return r.length===1?b.test(r)?"":t.pascalCase?o(r):e(r):(r!==e(r)&&(r=L(r,e,o,t.preserveConsecutiveUppercase)),r=r.replace(_,""),r=t.preserveConsecutiveUppercase?P(r,e):e(r),t.pascalCase&&(r=o(r.charAt(0))+r.slice(1)),N(r,o))}function z(r,t,e,o){const s="virtual:storyblok-components",n="\0"+s;return{name:"vite-plugin-storyblok-components",async resolveId(a){if(a===s)return n},async load(a){if(a===n){const i=[],l=[];for await(const[u,h]of Object.entries(t)){const p=await this.resolve("/"+r+"/"+h+".astro");if(p)i.push(`import ${I(u)} from "${p.id}"`);else if(e)l.push(u);else throw new Error(`Component could not be found for blok "${u}"! Does "${"/"+r+"/"+h}.astro" exist?`)}let c="";if(e)if(c=",FallbackComponent",o){const u=await this.resolve("/"+r+"/"+o+".astro");if(!u)throw new Error(`Custom fallback component could not be found. Does "${"/"+r+"/"+o}.astro" exist?`);i.push(`import FallbackComponent from "${u.id}"`)}else i.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${i.join(";")};export default {${Object.keys(t).filter(u=>!l.includes(u)).map(u=>I(u)).join(",")}${c}}`;if(e)return`${i[0]}; export default {${c.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(i){if(i===r)return t},async load(i){if(i===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 i=document.createElement("script");i.async=!0,i.src=o,i.id="storyblok-javascript-bridge",i.onerror=s=>t(s),i.onload=s=>{_e.forEach(l=>l()),ve=!0,r(s)},document.getElementsByTagName("head")[0].appendChild(i)});var at=Object.defineProperty,it=(o,r,t)=>r in o?at(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,O=(o,r,t)=>it(o,typeof r!="symbol"?r+"":r,t);class st{constructor(){O(this,"isCDNUrl",(r="")=>r.indexOf("/cdn/")>-1),O(this,"getOptionsPage",(r,t=25,i=1)=>({...r,per_page:t,page:i})),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 i=Math.abs(t-r)||0,s=r<t?1:-1;return this.arrayFrom(i,(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((i,s)=>[...i,...s],[])),O(this,"escapeHTML",function(r){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},i=/[&<>"']/g,s=RegExp(i.source);return r&&s.test(r)?r.replace(i,l=>t[l]):r})}stringify(r,t,i){const s=[];for(const l in r){if(!Object.prototype.hasOwnProperty.call(r,l))continue;const u=r[l],f=i?"":encodeURIComponent(l);let p;typeof u=="object"?p=this.stringify(u,t?t+encodeURIComponent("["+f+"]"):f,Array.isArray(u)):p=(t?t+encodeURIComponent("["+f+"]"):f)+"="+encodeURIComponent(u),s.push(p)}return s.join("&")}getRegionURL(r){const t="api.storyblok.com",i="api-us.storyblok.com",s="app.storyblokchina.cn",l="api-ap.storyblok.com",u="api-ca.storyblok.com";switch(r){case"us":return i;case"cn":return s;case"ap":return l;case"ca":return u;default:return t}}}const lt=function(o,r){const t={};for(const i in o){const s=o[i];r.indexOf(i)>-1&&s!==null&&(t[i]=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}`}),bt=o=>({singleTag:[{tag:"img",attrs:lt(o.attrs,["src","alt","title"])}]}),yt=()=>({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:i="url"}=o.attrs;if(delete t.linktype,t.href&&(t.href=r(o.attrs.href||"")),ct(i)&&(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}]}},jt=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Ct=()=>({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:bt,list_item:yt,ordered_list:mt,paragraph:vt,emoji:_t},marks:{bold:wt,strike:Tt,underline:kt,strong:At,code:St,italic:It,link:Ot,styled:jt,subscript:Ct,superscript:$t,anchor:xt,highlight:Et,textStyle:Rt}},Pt=function(o){const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,i=RegExp(t.source);return o&&i.test(o)?o.replace(t,s=>r[s]):o};let Te=!1;class Mt{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},i=!0){if(!Te&&i&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),Te=!0),r&&r.content&&Array.isArray(r.content)){let s="";return r.content.forEach(l=>{s+=this.renderNode(l)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}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 D(r){const t="virtual:storyblok-options",e="\0"+t;return{name:"vite-plugin-storyblok-options",async resolveId(o){if(o===t)return e},async load(o){if(o===e)return`export default ${JSON.stringify(r)}`}}}let T=!1;const A=[],U=r=>new Promise((t,e)=>{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}T?s():A.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=>e(s),o.onload=s=>{A.forEach(n=>n()),T=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(o)});var B=Object.defineProperty,q=(r,t,e)=>t in r?B(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,g=(r,t,e)=>q(r,typeof t!="symbol"?t+"":t,e);class F{constructor(){g(this,"isCDNUrl",(t="")=>t.indexOf("/cdn/")>-1),g(this,"getOptionsPage",(t,e=25,o=1)=>({...t,per_page:e,page:o})),g(this,"delay",t=>new Promise(e=>setTimeout(e,t))),g(this,"arrayFrom",(t=0,e)=>[...Array(t)].map(e)),g(this,"range",(t=0,e=t)=>{const o=Math.abs(e-t)||0,s=t<e?1:-1;return this.arrayFrom(o,(n,a)=>a*s+t)}),g(this,"asyncMap",async(t,e)=>Promise.all(t.map(e))),g(this,"flatMap",(t=[],e)=>t.map(e).reduce((o,s)=>[...o,...s],[])),g(this,"escapeHTML",function(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},o=/[&<>"']/g,s=RegExp(o.source);return t&&s.test(t)?t.replace(o,n=>e[n]):t})}stringify(t,e,o){const s=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const a=t[n],i=o?"":encodeURIComponent(n);let l;typeof a=="object"?l=this.stringify(a,e?e+encodeURIComponent("["+i+"]"):i,Array.isArray(a)):l=(e?e+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(a),s.push(l)}return s.join("&")}getRegionURL(t){const e="api.storyblok.com",o="api-us.storyblok.com",s="app.storyblokchina.cn",n="api-ap.storyblok.com",a="api-ca.storyblok.com";switch(t){case"us":return o;case"cn":return s;case"ap":return n;case"ca":return a;default:return e}}}const H=function(r,t){const e={};for(const o in r){const s=r[o];t.indexOf(o)>-1&&s!==null&&(e[o]=s)}return e},W=r=>r==="email",J=()=>({singleTag:"hr"}),K=()=>({tag:"blockquote"}),V=()=>({tag:"ul"}),G=r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),Q=()=>({singleTag:"br"}),X=r=>({tag:`h${r.attrs.level}`}),Y=r=>({singleTag:[{tag:"img",attrs:H(r.attrs,["src","alt","title"])}]}),Z=()=>({tag:"li"}),ee=()=>({tag:"ol"}),te=()=>({tag:"p"}),re=r=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":r.attrs.name,emoji:r.attrs.emoji}}]}),oe=()=>({tag:"b"}),se=()=>({tag:"s"}),ne=()=>({tag:"u"}),ae=()=>({tag:"strong"}),le=()=>({tag:"code"}),ie=()=>({tag:"i"}),ce=r=>{if(!r.attrs)return{tag:""};const t=new F().escapeHTML,e={...r.attrs},{linktype:o="url"}=r.attrs;if(delete e.linktype,e.href&&(e.href=t(r.attrs.href||"")),W(o)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const s in e.custom)e[s]=e.custom[s];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},ue=r=>({tag:[{tag:"span",attrs:r.attrs}]}),de=()=>({tag:"sub"}),pe=()=>({tag:"sup"}),fe=r=>({tag:[{tag:"span",attrs:r.attrs}]}),ge=r=>{var t;return(t=r.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${r.attrs.color};`}}]}:{tag:""}},he=r=>{var t;return(t=r.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${r.attrs.color}`}}]}:{tag:""}},E={nodes:{horizontal_rule:J,blockquote:K,bullet_list:V,code_block:G,hard_break:Q,heading:X,image:Y,list_item:Z,ordered_list:ee,paragraph:te,emoji:re},marks:{bold:oe,strike:se,underline:ne,strong:ae,code:le,italic:ie,link:ce,styled:ue,subscript:de,superscript:pe,anchor:fe,highlight:ge,textStyle:he}},ye=function(r){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},e=/[&<>"']/g,o=RegExp(e.source);return r&&o.test(r)?r.replace(e,s=>t[s]):r};let C=!1;class be{constructor(t){g(this,"marks"),g(this,"nodes"),t||(t=E),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t,e={optimizeImages:!1},o=!0){if(!C&&o&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),C=!0),t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach(n=>{s+=this.renderNode(n)}),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}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,30 +31,26 @@ 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 i=0,s=0,l="",u="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(l+=`width="${t.width}" `,i=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=i>0||s>0||u.length>0?`${i}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,p=>{var y,_;const A=p.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(A&&A.length>0){const S={srcset:(y=t.srcset)==null?void 0:y.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 j="";return S.srcset&&(j+=`srcset="${S.srcset}" `),S.sizes&&(j+=`sizes="${S.sizes}" `),p.replace(/<img/g,`<img ${j.trim()}`)}return p})),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 i=this.getMatchingNode(r);return i&&i.tag&&t.push(this.renderOpeningTag(i.tag)),r.content?r.content.forEach(s=>{t.push(this.renderNode(s))}):r.text?t.push(Pt(r.text)):i&&i.singleTag?t.push(this.renderTag(i.singleTag," /")):i&&i.html?t.push(i.html):r.type==="emoji"&&t.push(this.renderEmoji(r)),i&&i.tag&&t.push(this.renderClosingTag(i.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(i=>{if(i.constructor===String)return`<${i}${t}>`;{let s=`<${i.tag}`;if(i.attrs){for(const l in i.attrs)if(Object.prototype.hasOwnProperty.call(i.attrs,l)){const u=i.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 ke=Mt,Nt=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 zt,Lt="https://app.storyblok.com/f/storyblok-v2-latest.js";const Dt=(o,r)=>{o.addNode("blok",t=>{let i="";return t.attrs.body.forEach(s=>{i+=r(s.component,s)}),{html:i}})},Ut=o=>!o||!(o!=null&&o.content.some(r=>r.content||r.type==="blok"||r.type==="horizontal_rule")),Bt=(o,r,t)=>{let i=t||zt;if(!i){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ut(o)?"":(r&&(i=new ke(r.schema),r.resolver&&Dt(i,r.resolver)),i.render(o,{},!1))},Ft=()=>ot(Lt);function Ht(o){let r={resolveRelations:[]};function t(i){i&&Array.isArray(r.resolveRelations)&&r.resolveRelations.push(...Array.isArray(i)?i:[i])}for(const i of o)if(i.options){const{apiOptions:s,bridgeOptions:l}=i.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 qt(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,i="__lodash_hash_undefined__",s=800,l=16,u=9007199254740991,f="[object Arguments]",p="[object Array]",y="[object AsyncFunction]",_="[object Boolean]",A="[object Date]",S="[object Error]",j="[object Function]",w="[object GeneratorFunction]",L="[object Map]",J="[object Number]",nr="[object Null]",Ie="[object Object]",or="[object Proxy]",ar="[object RegExp]",ir="[object Set]",sr="[object String]",lr="[object Undefined]",cr="[object WeakMap]",ur="[object ArrayBuffer]",fr="[object DataView]",dr="[object Float32Array]",pr="[object Float64Array]",gr="[object Int8Array]",hr="[object Int16Array]",br="[object Int32Array]",yr="[object Uint8Array]",mr="[object Uint8ClampedArray]",vr="[object Uint16Array]",_r="[object Uint32Array]",wr=/[\\^$.*+?()[\]{}|]/g,Tr=/^\[object .+?Constructor\]$/,kr=/^(?:0|[1-9]\d*)$/,b={};b[dr]=b[pr]=b[gr]=b[hr]=b[br]=b[yr]=b[mr]=b[vr]=b[_r]=!0,b[f]=b[p]=b[ur]=b[_]=b[fr]=b[A]=b[S]=b[j]=b[L]=b[J]=b[Ie]=b[ar]=b[ir]=b[sr]=b[cr]=!1;var Oe=typeof q=="object"&&q&&q.Object===Object&&q,Ar=typeof self=="object"&&self&&self.Object===Object&&self,D=Oe||Ar||Function("return this")(),je=r&&!r.nodeType&&r,U=je&&!0&&o&&!o.nodeType&&o,Ce=U&&U.exports===je,re=Ce&&Oe.process,$e=function(){try{var e=U&&U.require&&U.require("util").types;return e||re&&re.binding&&re.binding("util")}catch{}}(),xe=$e&&$e.isTypedArray;function Sr(e,n,a){switch(a.length){case 0:return e.call(n);case 1:return e.call(n,a[0]);case 2:return e.call(n,a[0],a[1]);case 3:return e.call(n,a[0],a[1],a[2])}return e.apply(n,a)}function Ir(e,n){for(var a=-1,c=Array(e);++a<e;)c[a]=n(a);return c}function Or(e){return function(n){return e(n)}}function jr(e,n){return e==null?void 0:e[n]}function Cr(e,n){return function(a){return e(n(a))}}var $r=Array.prototype,xr=Function.prototype,K=Object.prototype,ne=D["__core-js_shared__"],W=xr.toString,$=K.hasOwnProperty,Ee=function(){var e=/[^.]+$/.exec(ne&&ne.keys&&ne.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Re=K.toString,Er=W.call(Object),Rr=RegExp("^"+W.call($).replace(wr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),X=Ce?D.Buffer:void 0,Pe=D.Symbol,Me=D.Uint8Array;X&&X.allocUnsafe;var Ne=Cr(Object.getPrototypeOf,Object),ze=Object.create,Pr=K.propertyIsEnumerable,Mr=$r.splice,x=Pe?Pe.toStringTag:void 0,Y=function(){try{var e=ie(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Nr=X?X.isBuffer:void 0,Le=Math.max,zr=Date.now,De=ie(D,"Map"),B=ie(Object,"create"),Lr=function(){function e(){}return function(n){if(!R(n))return{};if(ze)return ze(n);e.prototype=n;var a=new e;return e.prototype=void 0,a}}();function E(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var c=e[n];this.set(c[0],c[1])}}function Dr(){this.__data__=B?B(null):{},this.size=0}function Ur(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}function Br(e){var n=this.__data__;if(B){var a=n[e];return a===i?void 0:a}return $.call(n,e)?n[e]:void 0}function Fr(e){var n=this.__data__;return B?n[e]!==void 0:$.call(n,e)}function Hr(e,n){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=B&&n===void 0?i:n,this}E.prototype.clear=Dr,E.prototype.delete=Ur,E.prototype.get=Br,E.prototype.has=Fr,E.prototype.set=Hr;function C(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var c=e[n];this.set(c[0],c[1])}}function qr(){this.__data__=[],this.size=0}function Gr(e){var n=this.__data__,a=Z(n,e);if(a<0)return!1;var c=n.length-1;return a==c?n.pop():Mr.call(n,a,1),--this.size,!0}function Jr(e){var n=this.__data__,a=Z(n,e);return a<0?void 0:n[a][1]}function Kr(e){return Z(this.__data__,e)>-1}function Wr(e,n){var a=this.__data__,c=Z(a,e);return c<0?(++this.size,a.push([e,n])):a[c][1]=n,this}C.prototype.clear=qr,C.prototype.delete=Gr,C.prototype.get=Jr,C.prototype.has=Kr,C.prototype.set=Wr;function P(e){var n=-1,a=e==null?0:e.length;for(this.clear();++n<a;){var c=e[n];this.set(c[0],c[1])}}function Xr(){this.size=0,this.__data__={hash:new E,map:new(De||C),string:new E}}function Yr(e){var n=V(this,e).delete(e);return this.size-=n?1:0,n}function Zr(e){return V(this,e).get(e)}function Qr(e){return V(this,e).has(e)}function Vr(e,n){var a=V(this,e),c=a.size;return a.set(e,n),this.size+=a.size==c?0:1,this}P.prototype.clear=Xr,P.prototype.delete=Yr,P.prototype.get=Zr,P.prototype.has=Qr,P.prototype.set=Vr;function M(e){var n=this.__data__=new C(e);this.size=n.size}function en(){this.__data__=new C,this.size=0}function tn(e){var n=this.__data__,a=n.delete(e);return this.size=n.size,a}function rn(e){return this.__data__.get(e)}function nn(e){return this.__data__.has(e)}function on(e,n){var a=this.__data__;if(a instanceof C){var c=a.__data__;if(!De||c.length<t-1)return c.push([e,n]),this.size=++a.size,this;a=this.__data__=new P(c)}return a.set(e,n),this.size=a.size,this}M.prototype.clear=en,M.prototype.delete=tn,M.prototype.get=rn,M.prototype.has=nn,M.prototype.set=on;function an(e,n){var a=ce(e),c=!a&&le(e),d=!a&&!c&&qe(e),h=!a&&!c&&!d&&Je(e),m=a||c||d||h,g=m?Ir(e.length,String):[],v=g.length;for(var I in e)m&&(I=="length"||d&&(I=="offset"||I=="parent")||h&&(I=="buffer"||I=="byteLength"||I=="byteOffset")||Fe(I,v))||g.push(I);return g}function oe(e,n,a){(a!==void 0&&!ee(e[n],a)||a===void 0&&!(n in e))&&ae(e,n,a)}function sn(e,n,a){var c=e[n];(!($.call(e,n)&&ee(c,a))||a===void 0&&!(n in e))&&ae(e,n,a)}function Z(e,n){for(var a=e.length;a--;)if(ee(e[a][0],n))return a;return-1}function ae(e,n,a){n=="__proto__"&&Y?Y(e,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):e[n]=a}var ln=wn();function Q(e){return e==null?e===void 0?lr:nr:x&&x in Object(e)?Tn(e):jn(e)}function Ue(e){return F(e)&&Q(e)==f}function cn(e){if(!R(e)||In(e))return!1;var n=fe(e)?Rr:Tr;return n.test(En(e))}function un(e){return F(e)&&Ge(e.length)&&!!b[Q(e)]}function fn(e){if(!R(e))return On(e);var n=He(e),a=[];for(var c in e)c=="constructor"&&(n||!$.call(e,c))||a.push(c);return a}function Be(e,n,a,c,d){e!==n&&ln(n,function(h,m){if(d||(d=new M),R(h))dn(e,n,m,a,Be,c,d);else{var g=c?c(se(e,m),h,m+"",e,n,d):void 0;g===void 0&&(g=h),oe(e,m,g)}},Ke)}function dn(e,n,a,c,d,h,m){var g=se(e,a),v=se(n,a),I=m.get(v);if(I){oe(e,a,I);return}var k=h?h(g,v,a+"",e,n,m):void 0,H=k===void 0;if(H){var de=ce(v),pe=!de&&qe(v),Xe=!de&&!pe&&Je(v);k=v,de||pe||Xe?ce(g)?k=g:Rn(g)?k=mn(g):pe?(H=!1,k=hn(v)):Xe?(H=!1,k=yn(v)):k=[]:Pn(v)||le(v)?(k=g,le(g)?k=Mn(g):(!R(g)||fe(g))&&(k=kn(v))):H=!1}H&&(m.set(v,k),d(k,v,c,h,m),m.delete(v)),oe(e,a,k)}function pn(e,n){return $n(Cn(e,n,We),e+"")}var gn=Y?function(e,n){return Y(e,"toString",{configurable:!0,enumerable:!1,value:zn(n),writable:!0})}:We;function hn(e,n){return e.slice()}function bn(e){var n=new e.constructor(e.byteLength);return new Me(n).set(new Me(e)),n}function yn(e,n){var a=bn(e.buffer);return new e.constructor(a,e.byteOffset,e.length)}function mn(e,n){var a=-1,c=e.length;for(n||(n=Array(c));++a<c;)n[a]=e[a];return n}function vn(e,n,a,c){var d=!a;a||(a={});for(var h=-1,m=n.length;++h<m;){var g=n[h],v=void 0;v===void 0&&(v=e[g]),d?ae(a,g,v):sn(a,g,v)}return a}function _n(e){return pn(function(n,a){var c=-1,d=a.length,h=d>1?a[d-1]:void 0,m=d>2?a[2]:void 0;for(h=e.length>3&&typeof h=="function"?(d--,h):void 0,m&&An(a[0],a[1],m)&&(h=d<3?void 0:h,d=1),n=Object(n);++c<d;){var g=a[c];g&&e(n,g,c,h)}return n})}function wn(e){return function(n,a,c){for(var d=-1,h=Object(n),m=c(n),g=m.length;g--;){var v=m[++d];if(a(h[v],v,h)===!1)break}return n}}function V(e,n){var a=e.__data__;return Sn(n)?a[typeof n=="string"?"string":"hash"]:a.map}function ie(e,n){var a=jr(e,n);return cn(a)?a:void 0}function Tn(e){var n=$.call(e,x),a=e[x];try{e[x]=void 0;var c=!0}catch{}var d=Re.call(e);return c&&(n?e[x]=a:delete e[x]),d}function kn(e){return typeof e.constructor=="function"&&!He(e)?Lr(Ne(e)):{}}function Fe(e,n){var a=typeof e;return n=n??u,!!n&&(a=="number"||a!="symbol"&&kr.test(e))&&e>-1&&e%1==0&&e<n}function An(e,n,a){if(!R(a))return!1;var c=typeof n;return(c=="number"?ue(a)&&Fe(n,a.length):c=="string"&&n in a)?ee(a[n],e):!1}function Sn(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function In(e){return!!Ee&&Ee in e}function He(e){var n=e&&e.constructor,a=typeof n=="function"&&n.prototype||K;return e===a}function On(e){var n=[];if(e!=null)for(var a in Object(e))n.push(a);return n}function jn(e){return Re.call(e)}function Cn(e,n,a){return n=Le(n===void 0?e.length-1:n,0),function(){for(var c=arguments,d=-1,h=Le(c.length-n,0),m=Array(h);++d<h;)m[d]=c[n+d];d=-1;for(var g=Array(n+1);++d<n;)g[d]=c[d];return g[n]=a(m),Sr(e,this,g)}}function se(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}var $n=xn(gn);function xn(e){var n=0,a=0;return function(){var c=zr(),d=l-(c-a);if(a=c,d>0){if(++n>=s)return arguments[0]}else n=0;return e.apply(void 0,arguments)}}function En(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)&&$.call(e,"callee")&&!Pr.call(e,"callee")},ce=Array.isArray;function ue(e){return e!=null&&Ge(e.length)&&!fe(e)}function Rn(e){return F(e)&&ue(e)}var qe=Nr||Ln;function fe(e){if(!R(e))return!1;var n=Q(e);return n==j||n==w||n==y||n==or}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 Pn(e){if(!F(e)||Q(e)!=Ie)return!1;var n=Ne(e);if(n===null)return!0;var a=$.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&W.call(a)==Er}var Je=xe?Or(xe):un;function Mn(e){return vn(e,Ke(e))}function Ke(e){return ue(e)?an(e):fn(e)}var Nn=_n(function(e,n,a,c){Be(e,n,a,c)});function zn(e){return function(){return e}}function We(e){return e}function Ln(){return!1}o.exports=Nn}(G,G.exports);var Gt=G.exports;const Jt=qt(Gt);function Kt(o){let r={};function t(i,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=Ae(l[1].properties);r={...r,apiOptions:u}}if(l&&l[2].type==="ObjectExpression"){const u=Ae(l[2].properties);r={...r,bridgeOptions:u}}}}return Jt({},o,t),r}function Ae(o){const r={};return o.reduce((t,i)=>{if(i.type!=="Property")return t;const{key:s,value:l}=i,{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((p,y)=>y.type==="Literal"&&y.value?[...p,y.value]:p,[]);t[s.name]=f}return t},r)}let z=[];function Wt(o,r){const t="virtual:storyblok-bridge",i="\0"+t;if(!o||r!=="server")return{name:"vite-plugin-storyblok-bridge",resolveId(f){if(f===t)return i},load(f){if(f===i)return"export const bridgeOptions = null"}};let s=[],l=null,u;return{name:"vite-plugin-storyblok-bridge",async resolveId(f){if(f===t)return i},async transform(f,p){var j;if(p.includes("node_modules")&&!p.includes("/pages/")||!f.includes("useStoryblok")||!((j=this.getModuleInfo(p).meta)!=null&&j.astro))return;const[,..._]=p.split("src/pages/"),A=_.join("/").replace(".astro",""),S=Kt(this.parse(f));z.length&&(s=z.filter(w=>w.url!==A)),s.push({url:A,options:S}),l&&(u&&clearTimeout(u),u=setTimeout(()=>{Xt(z,s)||(z.length!==0&&(l.restart(),console.info("Bridge options updated. Restarting...")),z=[...s])},1e3))},async load(f){if(f===i)return`export const bridgeOptions = ${JSON.stringify(Ht(s))}`},configureServer(f){l=f}}}function Xt(o=[],r=[]){return r.every(({url:t,options:i})=>{const s=o.find(l=>(l==null?void 0:l.url)===t);return s&&JSON.stringify(i)===JSON.stringify(s.options)})}let Se;async function Yt(o){const{action:r,story:t}=o||{};if(r==="input"&&t){const i=async()=>{const l=await Qt(t),u=document.body;if(l.outerHTML===u.outerHTML)return;const f=document.querySelector('[data-blok-focused="true"]');Zt(u,l,f)};clearTimeout(Se),Se=setTimeout(i,500)}["published","change"].includes(o==null?void 0:o.action)&&location.reload()}function Zt(o,r,t){if(t){const i=t.getAttribute("data-blok-uid"),s=r.querySelector(`[data-blok-uid="${i}"]`);s&&(s.setAttribute("data-blok-focused","true"),t.replaceWith(s))}else o.replaceWith(r)}async function Qt(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 Vt(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}async function er(o,r={},t={},i){globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly");let s=null;if(i&&i.locals._storyblok_preview_data)s=i.locals._storyblok_preview_data;else{const{data:l}=await globalThis.storyblokApiInstance.get(o,r,t);s=l.story}return s}function tr(o,r){const t=globalThis.storyblokApiInstance.richTextResolver;if(!t){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Bt(o,r,t)}function rr(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:i,addDevToolbarApp:s,addMiddleware:l,config:u})=>{if(i({vite:{plugins:[N(r.accessToken,r.useCustomApi,r.apiOptions),rt(r.componentsDir,r.components,r.enableFallbackComponent,r.customFallbackComponent),nt(r),Wt(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(t,e){let o=0,s=0,n="",a="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(n+=`width="${e.width}" `,o=e.width),typeof e.height=="number"&&e.height>0&&(n+=`height="${e.height}" `,s=e.height),(e.loading==="lazy"||e.loading==="eager")&&(n+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(n+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(a+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(a+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||e.filters.fill==="transparent")&&(a+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(a+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(a+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(a+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(a+=`:rotate(${e.filters.rotate})`),a.length>0&&(a="/filters"+a))),n.length>0&&(t=t.replace(/<img/g,`<img ${n.trim()}`));const i=o>0||s>0||a.length>0?`${o}x${s}${a}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${i}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,l=>{var c,u;const h=l.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(h&&h.length>0){const p={srcset:(c=e.srcset)==null?void 0:c.map(f=>{if(typeof f=="number")return`//${h}/m/${f}x0${a} ${f}w`;if(typeof f=="object"&&f.length===2){let k=0,R=0;return typeof f[0]=="number"&&(k=f[0]),typeof f[1]=="number"&&(R=f[1]),`//${h}/m/${k}x${R}${a} ${k}w`}}).join(", "),sizes:(u=e.sizes)==null?void 0:u.map(f=>f).join(", ")};let m="";return p.srcset&&(m+=`srcset="${p.srcset}" `),p.sizes&&(m+=`sizes="${p.sizes}" `),l.replace(/<img/g,`<img ${m.trim()}`)}return l})),t}renderNode(t){const e=[];t.marks&&t.marks.forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&e.push(this.renderOpeningTag(n.tag))});const o=this.getMatchingNode(t);return o&&o.tag&&e.push(this.renderOpeningTag(o.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(ye(t.text)):o&&o.singleTag?e.push(this.renderTag(o.singleTag," /")):o&&o.html?e.push(o.html):t.type==="emoji"&&e.push(this.renderEmoji(t)),o&&o.tag&&e.push(this.renderClosingTag(o.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const n=this.getMatchingMark(s);n&&n.tag!==""&&e.push(this.renderClosingTag(n.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(o=>{if(o.constructor===String)return`<${o}${e}>`;{let s=`<${o.tag}`;if(o.attrs){for(const n in o.attrs)if(Object.prototype.hasOwnProperty.call(o.attrs,n)){const a=o.attrs[n];a!==null&&(s+=` ${n}="${a}"`)}}return`${s}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){const e=this.nodes[t.type];if(typeof e=="function")return e(t)}getMatchingMark(t){const e=this.marks[t.type];if(typeof e=="function")return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}const j=be,me=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};try{const t=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}:{}}catch{return{}}};let ke,we="https://app.storyblok.com/f/storyblok-v2-latest.js";const ve=(r,t)=>{r.addNode("blok",e=>{let o="";return e.attrs.body.forEach(s=>{o+=t(s.component,s)}),{html:o}})},$e=r=>!r||!(r!=null&&r.content.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule")),Se=(r,t,e)=>{let o=e||ke;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return $e(r)?"":(t&&(o=new j(t.schema),t.resolver&&ve(o,t.resolver)),o.render(r,{},!1))},Ie=()=>U(we);function Te(r){return typeof r=="object"?`const storyblokInstance = new StoryblokBridge(${JSON.stringify(r)});`:"const storyblokInstance = new StoryblokBridge();"}let x;async function Ae(r){const{action:t,story:e}=r||{};if(t==="input"&&e){const o=async()=>{const n=await Ce(e),a=document.body;if(n.outerHTML===a.outerHTML)return;const i=document.querySelector('[data-blok-focused="true"]');Ee(a,n,i),document.dispatchEvent(new Event("storyblok-live-preview-updated"))};clearTimeout(x),x=setTimeout(o,500)}["published","change"].includes(r==null?void 0:r.action)&&location.reload()}function Ee(r,t,e){if(e){const o=e.getAttribute("data-blok-uid"),s=t.querySelector(`[data-blok-uid="${o}"]`);s&&(s.setAttribute("data-blok-focused","true"),e.replaceWith(s))}else r.replaceWith(t)}async function Ce(r){const e=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...r,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(e,"text/html").body}function je(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}async function xe(r){let t=null;return r&&r.locals._storyblok_preview_data&&(t=r.locals._storyblok_preview_data),t}function Re(r,t){const e=globalThis.storyblokApiInstance.richTextResolver;if(!e){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Se(r,t,e)}function Me({useCustomApi:r=!1,bridge:t=!0,componentsDir:e="src",enableFallbackComponent:o=!1,livePreview:s=!1,...n}){const a={useCustomApi:r,bridge:t,componentsDir:e,enableFallbackComponent:o,livePreview:s,...n},i=Te(t);return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:l,updateConfig:c,addDevToolbarApp:u,addMiddleware:h,config:p})=>{if(c({vite:{plugins:[y(a.accessToken,a.useCustomApi,a.apiOptions),z(a.componentsDir,a.components,a.enableFallbackComponent,a.customFallbackComponent),D(a)]}}),a.livePreview&&(p==null?void 0:p.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.");l("page-ssr",`
35
35
  import { storyblokApiInstance } from "virtual:storyblok-init";
36
36
  globalThis.storyblokApiInstance = storyblokApiInstance;
37
- `),r.bridge&&!r.livePreview){let f="";if(typeof r.bridge=="object"){const p={...r.bridge};f=`const storyblokInstance = new StoryblokBridge(${JSON.stringify(p)});`}else f="const storyblokInstance = new StoryblokBridge()";t("page",`
37
+ `),t&&!s&&l("page",`
38
38
  import { loadStoryblokBridge } from "@storyblok/astro";
39
39
  loadStoryblokBridge().then(() => {
40
40
  const { StoryblokBridge, location } = window;
41
- ${f}
42
-
41
+ ${i}
43
42
  storyblokInstance.on(["published", "change"], (event) => {
44
43
  if (!event.slugChanged) {
45
44
  location.reload(true);
46
45
  }
47
46
  });
48
47
  });
49
- `)}r.livePreview&&(t("page",`
48
+ `),s&&(l("page",`
50
49
  import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
51
- import { bridgeOptions } from "virtual:storyblok-bridge";
52
50
  console.info("The Storyblok Astro live preview feature is currently in an experimental phase, and its API is subject to change in the future.")
53
51
  loadStoryblokBridge().then(() => {
54
52
  const { StoryblokBridge, location } = window;
55
- if(bridgeOptions){
56
- const storyblokInstance = new StoryblokBridge(bridgeOptions);
57
- storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
58
- };
53
+ ${i}
54
+ storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
59
55
  });
60
- `),l({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),s("@storyblok/astro/toolbarApp.ts")}}}}T.RichTextResolver=ke,T.RichTextSchema=we,T.default=rr,T.handleStoryblokMessage=Yt,T.loadStoryblokBridge=Ft,T.renderRichText=tr,T.storyblokEditable=Nt,T.useStoryblok=er,T.useStoryblokApi=Vt,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
56
+ `),h({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),u("@storyblok/astro/toolbarApp.ts")}}}}d.RichTextResolver=j,d.RichTextSchema=E,d.default=Me,d.getLiveStory=xe,d.handleStoryblokMessage=Ae,d.loadStoryblokBridge=Ie,d.renderRichText=Re,d.storyblokEditable=me,d.useStoryblokApi=je,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});