@storyblok/react 5.0.2-rc.0 → 5.1.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
@@ -19,14 +19,14 @@
19
19
  </p>
20
20
 
21
21
  <p align="center">
22
- <a href="https://discord.gg/jKrbAMz">
23
- <img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=09b3af">
22
+ <a href="https://storyblok.com/join-discord">
23
+ <img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=8d60ff">
24
24
  </a>
25
25
  <a href="https://twitter.com/intent/follow?screen_name=storyblok">
26
- <img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
26
+ <img src="https://img.shields.io/badge/Follow-%40storyblok-8d60ff?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
27
27
  </a>
28
28
  <a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-react">
29
- <img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
29
+ <img src="https://img.shields.io/badge/Try%20Storyblok-Free-8d60ff?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
30
30
  </a>
31
31
  </p>
32
32
 
@@ -761,7 +761,7 @@ By using these techniques, you can ensure that only the necessary components and
761
761
  ## Support
762
762
 
763
763
  - Bugs or Feature Requests? [Submit an issue](/../../issues/new).
764
- - Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
764
+ - Do you have questions about Storyblok or you need help? [Join our Discord Community](https://storyblok.com/join-discord).
765
765
 
766
766
  ## Contributing
767
767
 
package/dist/index.mjs CHANGED
@@ -2,9 +2,9 @@ import { useState as f, useEffect as k } from "react";
2
2
  import { registerStoryblokBridge as u } from "./storyblok-js.mjs";
3
3
  import { BlockTypes as T, MarkTypes as B, TextTypes as C, apiPlugin as E, loadStoryblokBridge as h, renderRichText as w, richTextResolver as A, storyblokEditable as I } from "./storyblok-js.mjs";
4
4
  import { useStoryblokApi as c } from "./index2.mjs";
5
- import { getComponent as L, getCustomFallbackComponent as P, getEnableFallbackComponent as _, setComponents as $, storyblokInit as J } from "./index2.mjs";
5
+ import { getComponent as L, getCustomFallbackComponent as P, getEnableFallbackComponent as _, setComponents as J, storyblokInit as M } from "./index2.mjs";
6
6
  import { useStoryblokRichText as m } from "./richtext.mjs";
7
- import { useStoryblokState as N } from "./client.mjs";
7
+ import { useStoryblokState as Y } from "./client.mjs";
8
8
  import { default as j } from "./storyblok-rich-text.mjs";
9
9
  import { convertAttributesInElement as z } from "./utils.mjs";
10
10
  import { default as G } from "./storyblok-component.mjs";
@@ -47,13 +47,13 @@ export {
47
47
  u as registerStoryblokBridge,
48
48
  w as renderRichText,
49
49
  A as richTextResolver,
50
- $ as setComponents,
50
+ J as setComponents,
51
51
  I as storyblokEditable,
52
- J as storyblokInit,
52
+ M as storyblokInit,
53
53
  x as useStoryblok,
54
54
  c as useStoryblokApi,
55
55
  u as useStoryblokBridge,
56
56
  m as useStoryblokRichText,
57
57
  g as useStoryblokRichTextResolver,
58
- N as useStoryblokState
58
+ Y as useStoryblokState
59
59
  };
package/dist/richtext.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import o from "react";
2
2
  import n from "./storyblok-component.mjs";
3
- import { BlockTypes as a, richTextResolver as m } from "./storyblok-js.mjs";
3
+ import { BlockTypes as m, richTextResolver as a } from "./storyblok-js.mjs";
4
4
  function i(e) {
5
5
  var t, s;
6
6
  const r = (t = e == null ? void 0 : e.attrs) == null ? void 0 : t.body;
@@ -16,12 +16,12 @@ function p(e) {
16
16
  key: Math.random().toString(36).substring(2, 15)
17
17
  }, t),
18
18
  resolvers: {
19
- [a.COMPONENT]: i,
19
+ [m.COMPONENT]: i,
20
20
  ...e.resolvers
21
21
  },
22
22
  keyedResolvers: !0
23
23
  };
24
- return m(r);
24
+ return a(r);
25
25
  }
26
26
  export {
27
27
  i as componentResolver,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function ne(n,e){if(!e)return{src:n,attrs:{}};let t=0,r=0;const s={},o=[];function c(i,h,f,y,$){typeof i!="number"||i<=h||i>=f?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${h} and ${f} (inclusive)`):$.push(`${y}(${i})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(s.height=e.height,r=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:i}=e||{},{blur:h,brightness:f,fill:y,format:$,grayscale:T,quality:A,rotate:I}=i||{};h&&c(h,0,100,"blur",o),A&&c(A,0,100,"quality",o),f&&c(f,0,100,"brightness",o),y&&o.push(`fill(${y})`),T&&o.push("grayscale()"),I&&[0,90,180,270].includes(e.filters.rotate||0)&&o.push(`rotate(${I})`),$&&["webp","png","jpeg"].includes($)&&o.push(`format(${$})`)}e.srcset&&(s.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${n}/m/${i}x0/${o.length>0?`filters:${o.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[h,f]=i;return`${n}/m/${h}x${f}/${o.length>0?`filters:${o.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let l=`${n}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),o.length>0&&(l=`${l}filters:${o.join(":")}`),{src:l,attrs:s}}var b=(n=>(n.DOCUMENT="doc",n.HEADING="heading",n.PARAGRAPH="paragraph",n.QUOTE="blockquote",n.OL_LIST="ordered_list",n.UL_LIST="bullet_list",n.LIST_ITEM="list_item",n.CODE_BLOCK="code_block",n.HR="horizontal_rule",n.BR="hard_break",n.IMAGE="image",n.EMOJI="emoji",n.COMPONENT="blok",n.TABLE="table",n.TABLE_ROW="tableRow",n.TABLE_CELL="tableCell",n.TABLE_HEADER="tableHeader",n))(b||{}),_=(n=>(n.BOLD="bold",n.STRONG="strong",n.STRIKE="strike",n.UNDERLINE="underline",n.ITALIC="italic",n.CODE="code",n.LINK="link",n.ANCHOR="anchor",n.STYLED="styled",n.SUPERSCRIPT="superscript",n.SUBSCRIPT="subscript",n.TEXT_STYLE="textStyle",n.HIGHLIGHT="highlight",n))(_||{}),N=(n=>(n.TEXT="text",n))(N||{}),S=(n=>(n.URL="url",n.STORY="story",n.ASSET="asset",n.EMAIL="email",n))(S||{});const oe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ie=(n={})=>Object.keys(n).map(e=>`${e}="${n[e]}"`).join(" "),ae=(n={})=>Object.keys(n).map(e=>`${e}: ${n[e]}`).join("; ");function le(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const O=n=>Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0));function M(n,e={},t){const r=ie(e),s=r?`${n} ${r}`:n,o=Array.isArray(t)?t.join(""):t||"";if(n){if(oe.includes(n))return`<${s}>`}else return o;return`<${s}>${o}</${n}>`}function q(n={}){const e=new Map,{renderFn:t=M,textFn:r=le,resolvers:s={},optimizeImages:o=!1,keyedResolvers:c=!1}=n,l=t!==M,i=a=>(u,d)=>{const p=u.attrs||{};return d.render(a,p,u.children||null)},h=(a,u)=>{const{src:d,alt:p,title:m,srcset:w,sizes:v}=a.attrs||{};let k=d,R={};if(o){const{src:se,attrs:re}=ne(d,o);k=se,R=re}const te={src:k,alt:p,title:m,srcset:w,sizes:v,...R};return u.render("img",O(te))},f=(a,u)=>{const{level:d,...p}=a.attrs||{};return u.render(`h${d}`,p,a.children)},y=(a,u)=>{var d,p,m,w;const v=u.render("img",{src:(d=a.attrs)==null?void 0:d.fallbackImage,alt:(p=a.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return u.render("span",{"data-type":"emoji","data-name":(m=a.attrs)==null?void 0:m.name,"data-emoji":(w=a.attrs)==null?void 0:w.emoji},v)},$=(a,u)=>u.render("pre",a.attrs||{},u.render("code",{},a.children||"")),T=(a,u=!1)=>({text:d,attrs:p},m)=>{const{class:w,id:v,...k}=p||{},R=u?{class:w,id:v,style:ae(k)||void 0}:p||{};return m.render(a,O(R),d)},A=a=>C(a),I=a=>{const{marks:u,...d}=a;if("text"in a){if(u)return u.reduce((m,w)=>A({...w,text:m}),A({...d,children:d.children}));const p=a.attrs||{};if(c){const m=e.get("txt")||0;e.set("txt",m+1),p.key=`txt-${m}`}return r(d.text,p)}return""},U=(a,u)=>{const{linktype:d,href:p,anchor:m,...w}=a.attrs||{};let v="";switch(d){case S.ASSET:case S.URL:v=p;break;case S.EMAIL:v=`mailto:${p}`;break;case S.STORY:v=p,m&&(v=`${v}#${m}`);break;default:v=p;break}const k={...w};return v&&(k.href=v),u.render("a",k,a.text)},K=(a,u)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.render("span",{blok:(d=a==null?void 0:a.attrs)==null?void 0:d.body[0],id:(p=a.attrs)==null?void 0:p.id,style:"display: none"})},W=(a,u)=>{const d={},p=u.render("tbody",{},a.children);return u.render("table",d,p)},X=(a,u)=>{const d={};return u.render("tr",d,a.children)},Q=(a,u)=>{const{colspan:d,rowspan:p,colwidth:m,backgroundColor:w,...v}=a.attrs||{},k={...v};d>1&&(k.colspan=d),p>1&&(k.rowspan=p);const R=[];return m&&R.push(`width: ${m}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(k.style=R.join(" ")),u.render("td",O(k),a.children)},Z=(a,u)=>{const{colspan:d,rowspan:p,colwidth:m,backgroundColor:w,...v}=a.attrs||{},k={...v};d>1&&(k.colspan=d),p>1&&(k.rowspan=p);const R=[];return m&&R.push(`width: ${m}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(k.style=R.join(" ")),u.render("th",O(k),a.children)},B=new Map([[b.DOCUMENT,i("")],[b.HEADING,f],[b.PARAGRAPH,i("p")],[b.UL_LIST,i("ul")],[b.OL_LIST,i("ol")],[b.LIST_ITEM,i("li")],[b.IMAGE,h],[b.EMOJI,y],[b.CODE_BLOCK,$],[b.HR,i("hr")],[b.BR,i("br")],[b.QUOTE,i("blockquote")],[b.COMPONENT,K],[N.TEXT,I],[_.LINK,U],[_.ANCHOR,U],[_.STYLED,T("span",!0)],[_.BOLD,T("strong")],[_.TEXT_STYLE,T("span",!0)],[_.ITALIC,T("em")],[_.UNDERLINE,T("u")],[_.STRIKE,T("s")],[_.CODE,T("code")],[_.SUPERSCRIPT,T("sup")],[_.SUBSCRIPT,T("sub")],[_.HIGHLIGHT,T("mark")],[b.TABLE,W],[b.TABLE_ROW,X],[b.TABLE_CELL,Q],[b.TABLE_HEADER,Z]]),D=new Map([...B,...Object.entries(s).map(([a,u])=>[a,u])]),ee=()=>({render:(a,u={},d)=>{if(c&&a){const p=e.get(a)||0;e.set(a,p+1),u.key=`${a}-${p}`}return t(a,u,d)},originalResolvers:B,mergedResolvers:D});function L(a){const u=D.get(a.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${a.type}`),"";const d=ee();if(a.type==="text")return u(a,d);const p=a.content?a.content.map(C):void 0;return u({...a,children:p},d)}function C(a){return a.type==="doc"?l?a.content.map(L):a.content.map(L).join(""):Array.isArray(a)?a.map(L):L(a)}return{render:C}}let z=!1;const F=[],J=n=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?s():F.push(s)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{F.forEach(o=>o()),z=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var ce=Object.defineProperty,he=(n,e,t)=>e in n?ce(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e,t)=>he(n,typeof e!="symbol"?e+"":e,t);class ue extends Error{constructor(e){super(e),this.name="AbortError"}}function de(n,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let s=[],o=0,c=!1;const l=async()=>{o++;const h=r.shift();if(h)try{const y=await n(...h.args);h.resolve(y)}catch(y){h.reject(y)}const f=setTimeout(()=>{o--,r.length>0&&l(),s=s.filter(y=>y!==f)},t);s.includes(f)||s.push(f)},i=(...h)=>c?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((f,y)=>{r.push({resolve:f,reject:y,args:h}),o<e&&l()});return i.abort=()=>{c=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new ue("Throttle function aborted"))),r.length=0},i}const pe=(n="")=>n.includes("/cdn/"),fe=(n,e=25,t=1)=>({...n,per_page:e,page:t}),ye=n=>new Promise(e=>setTimeout(e,n)),ge=(n=0,e)=>Array.from({length:n},e),me=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return ge(t,(s,o)=>o*r+n)},be=async(n,e)=>Promise.all(n.map(e)),ve=(n=[],e)=>n.map(e).reduce((t,r)=>[...t,...r],[]),H=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s];if(o==null)continue;const c=t?"":encodeURIComponent(s);let l;typeof o=="object"?l=H(o,e?e+encodeURIComponent(`[${c}]`):c,Array.isArray(o)):l=`${e?e+encodeURIComponent(`[${c}]`):c}=${encodeURIComponent(o)}`,r.push(l)}return r.join("&")},G=n=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[n]??e.eu};class ke{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${H(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),o=new AbortController,{signal:c}=o;let l;this.timeout&&(l=setTimeout(()=>o.abort(),this.timeout));try{const i=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:c,...this.fetchOptions});this.timeout&&clearTimeout(l);const h=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(i){return{message:i}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const o={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(o)})}}const V="SB-Agent",P={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"},we={DRAFT:"draft"};let j={};const E={};class Te{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"version"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache"),g(this,"inlineAssets");let r=e.endpoint||t;if(!r){const c=e.https===!1?"http":"https";e.oauthToken?r=`${c}://${G(e.region)}/v1`:r=`${c}://${G(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([c,l])=>{s.set(c,l)}),s.has(V)||(s.set(V,P.defaultAgentName),s.set(P.defaultAgentVersion,P.packageVersion));let o=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),o=3),e.rateLimit&&(o=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=de(this.throttledRequest.bind(this),o,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||we.DRAFT,this.inlineAssets=e.inlineAssets||!1,this.client=new ke({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return pe(e)?this.parseParams(t):t}makeRequest(e,t,r,s,o){const c=this.factoryParamOptions(e,fe(t,r,s));return this.cacheResponse(e,c,void 0,o)}get(e,t={},r){t||(t={});const s=`/${e}`;t.version=t.version||this.version;const o=this.factoryParamOptions(s,t);return this.cacheResponse(s,o,void 0,r)}async getAll(e,t={},r,s){const o=(t==null?void 0:t.per_page)||25,c=`/${e}`.replace(/\/$/,""),l=r??c.substring(c.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,h=await this.makeRequest(c,t,o,i,s),f=h.total?Math.ceil(h.total/o):1,y=await be(me(i,f),$=>this.makeRequest(c,t,o,$+1,s));return ve([h,...y],$=>Object.values($.data[l]))}post(e,t={},r){const s=`/${e}`;return this.throttle("post",s,t,r)}put(e,t={},r){const s=`/${e}`;return this.throttle("put",s,t,r)}delete(e,t={},r){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(o=>this.getStoryReference(r,o)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(c=>c.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const o=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(o):r===o)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(o,c="")=>{if(!(!o||o._stopResolving)){if(Array.isArray(o))o.forEach((l,i)=>s(l,`${c}[${i}]`));else if(typeof o=="object")for(const l in o){const i=c?`${c}.${l}`:l;(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,l,t,r),this._insertLinks(o,l,r)),s(o[l],i)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const o=e.link_uuids.length,c=[],l=50;for(let i=0;i<o;i+=l){const h=Math.min(o,i+l);c.push(e.link_uuids.slice(i,h))}for(let i=0;i<c.length;i++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:c[i].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(o=>{this.links[r][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const o=e.rel_uuids.length,c=[],l=50;for(let i=0;i<o;i+=l){const h=Math.min(o,i+l);c.push(e.rel_uuids.slice(i,h))}for(let i=0;i<c.length;i++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:c[i].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(o=>{this.relations[r][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,r){var s,o;let c=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(c=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],c,r);e.story?this.iterateTree(e.story,c,r):e.stories.forEach(l=>{this.iterateTree(l,c,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const o=H({url:e,params:t}),c=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await c.get(o);if(l)return Promise.resolve(l)}return new Promise(async(l,i)=>{var h;try{const f=await this.throttle("get",e,t,s);if(f.status!==200)return i(f);let y={data:f.data,headers:f.headers};if((h=f.headers)!=null&&h["per-page"]&&(y=Object.assign({},y,{perPage:f.headers["per-page"]?Number.parseInt(f.headers["per-page"]):0,total:f.headers["per-page"]?Number.parseInt(f.headers.total):0})),y.data.story||y.data.stories){const T=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${T}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await c.set(o,y);const $=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&($&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(f){if(f.response&&f.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ye(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(i);i(f)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(o=>t(o));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(o=>o.id===s.id)});for(const o in s)typeof s[o]=="object"&&(s[o]=t(s[o]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}}const Re=(n={})=>{const{apiOptions:e}=n;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new Te(e)}},_e=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};try{const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let x="https://app.storyblok.com/f/storyblok-v2-latest.js";const Y=(n,e,t={})=>{var r;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),c=o!==null&&+o===n;if(!(!s||!c)){if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var i;l&&(l.action==="input"&&((i=l.story)==null?void 0:i.id)===n?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===n&&window.location.reload())})})}},$e=(n={})=>{var e,t;const{bridge:r,accessToken:s,use:o=[],apiOptions:c={},bridgeUrl:l}=n;c.accessToken=c.accessToken||s;const i={bridge:r,apiOptions:c};let h={};o.forEach(y=>{h={...h,...y(i)}}),l&&(x=l);const f=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&f&&J(x),h};function Ee(n,e){return q(e).render(n)}const Ae=()=>J(x);exports.BlockTypes=b;exports.MarkTypes=_;exports.TextTypes=N;exports.apiPlugin=Re;exports.loadStoryblokBridge=Ae;exports.registerStoryblokBridge=Y;exports.renderRichText=Ee;exports.richTextResolver=q;exports.storyblokEditable=_e;exports.storyblokInit=$e;exports.useStoryblokBridge=Y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function oe(n,e){if(!e)return{src:n,attrs:{}};let t=0,r=0;const s={},o=[];function c(i,h,f,y,$){typeof i!="number"||i<=h||i>=f?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${h} and ${f} (inclusive)`):$.push(`${y}(${i})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(s.height=e.height,r=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:i}=e||{},{blur:h,brightness:f,fill:y,format:$,grayscale:T,quality:A,rotate:I}=i||{};h&&c(h,0,100,"blur",o),A&&c(A,0,100,"quality",o),f&&c(f,0,100,"brightness",o),y&&o.push(`fill(${y})`),T&&o.push("grayscale()"),I&&[0,90,180,270].includes(e.filters.rotate||0)&&o.push(`rotate(${I})`),$&&["webp","png","jpeg"].includes($)&&o.push(`format(${$})`)}e.srcset&&(s.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${n}/m/${i}x0/${o.length>0?`filters:${o.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[h,f]=i;return`${n}/m/${h}x${f}/${o.length>0?`filters:${o.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let l=`${n}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),o.length>0&&(l=`${l}filters:${o.join(":")}`),{src:l,attrs:s}}var b=(n=>(n.DOCUMENT="doc",n.HEADING="heading",n.PARAGRAPH="paragraph",n.QUOTE="blockquote",n.OL_LIST="ordered_list",n.UL_LIST="bullet_list",n.LIST_ITEM="list_item",n.CODE_BLOCK="code_block",n.HR="horizontal_rule",n.BR="hard_break",n.IMAGE="image",n.EMOJI="emoji",n.COMPONENT="blok",n.TABLE="table",n.TABLE_ROW="tableRow",n.TABLE_CELL="tableCell",n.TABLE_HEADER="tableHeader",n))(b||{}),_=(n=>(n.BOLD="bold",n.STRONG="strong",n.STRIKE="strike",n.UNDERLINE="underline",n.ITALIC="italic",n.CODE="code",n.LINK="link",n.ANCHOR="anchor",n.STYLED="styled",n.SUPERSCRIPT="superscript",n.SUBSCRIPT="subscript",n.TEXT_STYLE="textStyle",n.HIGHLIGHT="highlight",n))(_||{}),N=(n=>(n.TEXT="text",n))(N||{}),S=(n=>(n.URL="url",n.STORY="story",n.ASSET="asset",n.EMAIL="email",n))(S||{});const ie=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ae=(n={})=>Object.keys(n).map(e=>`${e}="${n[e]}"`).join(" "),le=(n={})=>Object.keys(n).map(e=>`${e}: ${n[e]}`).join("; ");function ce(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const O=n=>Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0));function M(n,e={},t){const r=ae(e),s=r?`${n} ${r}`:n,o=Array.isArray(t)?t.join(""):t||"";if(n){if(ie.includes(n))return`<${s}>`}else return o;return`<${s}>${o}</${n}>`}function F(n={}){const e=new Map,{renderFn:t=M,textFn:r=ce,resolvers:s={},optimizeImages:o=!1,keyedResolvers:c=!1}=n,l=t!==M,i=a=>(u,d)=>{const p=u.attrs||{};return d.render(a,p,u.children||null)},h=(a,u)=>{const{src:d,alt:p,title:m,srcset:w,sizes:v}=a.attrs||{};let k=d,R={};if(o){const{src:re,attrs:ne}=oe(d,o);k=re,R=ne}const se={src:k,alt:p,title:m,srcset:w,sizes:v,...R};return u.render("img",O(se))},f=(a,u)=>{const{level:d,...p}=a.attrs||{};return u.render(`h${d}`,p,a.children)},y=(a,u)=>{var d,p,m,w;const v=u.render("img",{src:(d=a.attrs)==null?void 0:d.fallbackImage,alt:(p=a.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return u.render("span",{"data-type":"emoji","data-name":(m=a.attrs)==null?void 0:m.name,"data-emoji":(w=a.attrs)==null?void 0:w.emoji},v)},$=(a,u)=>u.render("pre",a.attrs||{},u.render("code",{},a.children||"")),T=(a,u=!1)=>({text:d,attrs:p},m)=>{const{class:w,id:v,...k}=p||{},R=u?{class:w,id:v,style:le(k)||void 0}:p||{};return m.render(a,O(R),d)},A=a=>C(a),I=a=>{const{marks:u,...d}=a;if("text"in a){if(u)return u.reduce((m,w)=>A({...w,text:m}),A({...d,children:d.children}));const p=a.attrs||{};if(c){const m=e.get("txt")||0;e.set("txt",m+1),p.key=`txt-${m}`}return r(d.text,p)}return""},U=(a,u)=>{const{linktype:d,href:p,anchor:m,...w}=a.attrs||{};let v="";switch(d){case S.ASSET:case S.URL:v=p;break;case S.EMAIL:v=`mailto:${p}`;break;case S.STORY:v=p,m&&(v=`${v}#${m}`);break;default:v=p;break}const k={...w};return v&&(k.href=v),u.render("a",k,a.text)},W=(a,u)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.render("span",{blok:(d=a==null?void 0:a.attrs)==null?void 0:d.body[0],id:(p=a.attrs)==null?void 0:p.id,style:"display: none"})},X=(a,u)=>{const d={},p=u.render("tbody",{},a.children);return u.render("table",d,p)},Q=(a,u)=>{const d={};return u.render("tr",d,a.children)},Z=(a,u)=>{const{colspan:d,rowspan:p,colwidth:m,backgroundColor:w,...v}=a.attrs||{},k={...v};d>1&&(k.colspan=d),p>1&&(k.rowspan=p);const R=[];return m&&R.push(`width: ${m}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(k.style=R.join(" ")),u.render("td",O(k),a.children)},ee=(a,u)=>{const{colspan:d,rowspan:p,colwidth:m,backgroundColor:w,...v}=a.attrs||{},k={...v};d>1&&(k.colspan=d),p>1&&(k.rowspan=p);const R=[];return m&&R.push(`width: ${m}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(k.style=R.join(" ")),u.render("th",O(k),a.children)},B=new Map([[b.DOCUMENT,i("")],[b.HEADING,f],[b.PARAGRAPH,i("p")],[b.UL_LIST,i("ul")],[b.OL_LIST,i("ol")],[b.LIST_ITEM,i("li")],[b.IMAGE,h],[b.EMOJI,y],[b.CODE_BLOCK,$],[b.HR,i("hr")],[b.BR,i("br")],[b.QUOTE,i("blockquote")],[b.COMPONENT,W],[N.TEXT,I],[_.LINK,U],[_.ANCHOR,U],[_.STYLED,T("span",!0)],[_.BOLD,T("strong")],[_.TEXT_STYLE,T("span",!0)],[_.ITALIC,T("em")],[_.UNDERLINE,T("u")],[_.STRIKE,T("s")],[_.CODE,T("code")],[_.SUPERSCRIPT,T("sup")],[_.SUBSCRIPT,T("sub")],[_.HIGHLIGHT,T("mark")],[b.TABLE,X],[b.TABLE_ROW,Q],[b.TABLE_CELL,Z],[b.TABLE_HEADER,ee]]),D=new Map([...B,...Object.entries(s).map(([a,u])=>[a,u])]),te=()=>({render:(a,u={},d)=>{if(c&&a){const p=e.get(a)||0;e.set(a,p+1),u.key=`${a}-${p}`}return t(a,u,d)},originalResolvers:B,mergedResolvers:D});function L(a){const u=D.get(a.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${a.type}`),"";const d=te();if(a.type==="text")return u(a,d);const p=a.content?a.content.map(C):void 0;return u({...a,children:p},d)}function C(a){return a.type==="doc"?l?a.content.map(L):a.content.map(L).join(""):Array.isArray(a)?a.map(L):L(a)}return{render:C}}let z=!1;const G=[],Y=n=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?s():G.push(s)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{G.forEach(o=>o()),z=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var he=Object.defineProperty,ue=(n,e,t)=>e in n?he(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e,t)=>ue(n,typeof e!="symbol"?e+"":e,t);class de extends Error{constructor(e){super(e),this.name="AbortError"}}function pe(n,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let s=[],o=0,c=!1;const l=async()=>{o++;const h=r.shift();if(h)try{const y=await n(...h.args);h.resolve(y)}catch(y){h.reject(y)}const f=setTimeout(()=>{o--,r.length>0&&l(),s=s.filter(y=>y!==f)},t);s.includes(f)||s.push(f)},i=(...h)=>c?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((f,y)=>{r.push({resolve:f,reject:y,args:h}),o<e&&l()});return i.abort=()=>{c=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new de("Throttle function aborted"))),r.length=0},i}const V=(n="")=>n.includes("/cdn/"),fe=(n,e=25,t=1)=>({...n,per_page:e,page:t}),ye=n=>new Promise(e=>setTimeout(e,n)),ge=(n=0,e)=>Array.from({length:n},e),me=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return ge(t,(s,o)=>o*r+n)},be=async(n,e)=>Promise.all(n.map(e)),ve=(n=[],e)=>n.map(e).reduce((t,r)=>[...t,...r],[]),H=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s];if(o==null)continue;const c=t?"":encodeURIComponent(s);let l;typeof o=="object"?l=H(o,e?e+encodeURIComponent(`[${c}]`):c,Array.isArray(o)):l=`${e?e+encodeURIComponent(`[${c}]`):c}=${encodeURIComponent(o)}`,r.push(l)}return r.join("&")},q=n=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[n]??e.eu};class ke{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${H(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),o=new AbortController,{signal:c}=o;let l;this.timeout&&(l=setTimeout(()=>o.abort(),this.timeout));try{const i=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:c,...this.fetchOptions});this.timeout&&clearTimeout(l);const h=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(i){return{message:i}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const o={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(o)})}}const J="SB-Agent",P={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},we={PUBLISHED:"published"};let j={};const E={};class Te{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"version"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache"),g(this,"inlineAssets");let r=e.endpoint||t;if(!r){const c=e.https===!1?"http":"https";e.oauthToken?r=`${c}://${q(e.region)}/v1`:r=`${c}://${q(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([c,l])=>{s.set(c,l)}),s.has(J)||(s.set(J,P.defaultAgentName),s.set(P.defaultAgentVersion,P.packageVersion));let o=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),o=3),e.rateLimit&&(o=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=pe(this.throttledRequest.bind(this),o,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||we.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new ke({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return V(e)?this.parseParams(t):t}makeRequest(e,t,r,s,o){const c=this.factoryParamOptions(e,fe(t,r,s));return this.cacheResponse(e,c,void 0,o)}get(e,t={},r){t||(t={});const s=`/${e}`;V(s)&&(t.version=t.version||this.version);const o=this.factoryParamOptions(s,t);return this.cacheResponse(s,o,void 0,r)}async getAll(e,t={},r,s){const o=(t==null?void 0:t.per_page)||25,c=`/${e}`.replace(/\/$/,""),l=r??c.substring(c.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,h=await this.makeRequest(c,t,o,i,s),f=h.total?Math.ceil(h.total/o):1,y=await be(me(i,f),$=>this.makeRequest(c,t,o,$+1,s));return ve([h,...y],$=>Object.values($.data[l]))}post(e,t={},r){const s=`/${e}`;return this.throttle("post",s,t,r)}put(e,t={},r){const s=`/${e}`;return this.throttle("put",s,t,r)}delete(e,t={},r){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(o=>this.getStoryReference(r,o)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(c=>c.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const o=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(o):r===o)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(o,c="")=>{if(!(!o||o._stopResolving)){if(Array.isArray(o))o.forEach((l,i)=>s(l,`${c}[${i}]`));else if(typeof o=="object")for(const l in o){const i=c?`${c}.${l}`:l;(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,l,t,r),this._insertLinks(o,l,r)),s(o[l],i)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const o=e.link_uuids.length,c=[],l=50;for(let i=0;i<o;i+=l){const h=Math.min(o,i+l);c.push(e.link_uuids.slice(i,h))}for(let i=0;i<c.length;i++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:c[i].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(o=>{this.links[r][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const o=e.rel_uuids.length,c=[],l=50;for(let i=0;i<o;i+=l){const h=Math.min(o,i+l);c.push(e.rel_uuids.slice(i,h))}for(let i=0;i<c.length;i++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:c[i].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(o=>{this.relations[r][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,r){var s,o;let c=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(c=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],c,r);e.story?this.iterateTree(e.story,c,r):e.stories.forEach(l=>{this.iterateTree(l,c,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const o=H({url:e,params:t}),c=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await c.get(o);if(l)return Promise.resolve(l)}return new Promise(async(l,i)=>{var h;try{const f=await this.throttle("get",e,t,s);if(f.status!==200)return i(f);let y={data:f.data,headers:f.headers};if((h=f.headers)!=null&&h["per-page"]&&(y=Object.assign({},y,{perPage:f.headers["per-page"]?Number.parseInt(f.headers["per-page"]):0,total:f.headers["per-page"]?Number.parseInt(f.headers.total):0})),y.data.story||y.data.stories){const T=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${T}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await c.set(o,y);const $=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&($&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(f){if(f.response&&f.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ye(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(i);i(f)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(o=>t(o));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(o=>o.id===s.id)});for(const o in s)typeof s[o]=="object"&&(s[o]=t(s[o]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}}const Re=(n={})=>{const{apiOptions:e}=n;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new Te(e)}},_e=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};try{const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let x="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(n,e,t={})=>{var r;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),c=o!==null&&+o===n;if(!(!s||!c)){if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var i;l&&(l.action==="input"&&((i=l.story)==null?void 0:i.id)===n?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===n&&window.location.reload())})})}},$e=(n={})=>{var e,t;const{bridge:r,accessToken:s,use:o=[],apiOptions:c={},bridgeUrl:l}=n;c.accessToken=c.accessToken||s;const i={bridge:r,apiOptions:c};let h={};o.forEach(y=>{h={...h,...y(i)}}),l&&(x=l);const f=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&f&&Y(x),h};function Ee(n,e){return F(e).render(n)}const Ae=()=>Y(x);exports.BlockTypes=b;exports.MarkTypes=_;exports.TextTypes=N;exports.apiPlugin=Re;exports.loadStoryblokBridge=Ae;exports.registerStoryblokBridge=K;exports.renderRichText=Ee;exports.richTextResolver=F;exports.storyblokEditable=_e;exports.storyblokInit=$e;exports.useStoryblokBridge=K;
@@ -1,4 +1,4 @@
1
- function se(n, e) {
1
+ function re(n, e) {
2
2
  if (!e)
3
3
  return { src: n, attrs: {} };
4
4
  let t = 0, r = 0;
@@ -29,8 +29,8 @@ function se(n, e) {
29
29
  attrs: s
30
30
  };
31
31
  }
32
- var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n.TABLE = "table", n.TABLE_ROW = "tableRow", n.TABLE_CELL = "tableCell", n.TABLE_HEADER = "tableHeader", n))(v || {}), $ = /* @__PURE__ */ ((n) => (n.BOLD = "bold", n.STRONG = "strong", n.STRIKE = "strike", n.UNDERLINE = "underline", n.ITALIC = "italic", n.CODE = "code", n.LINK = "link", n.ANCHOR = "anchor", n.STYLED = "styled", n.SUPERSCRIPT = "superscript", n.SUBSCRIPT = "subscript", n.TEXT_STYLE = "textStyle", n.HIGHLIGHT = "highlight", n))($ || {}), V = /* @__PURE__ */ ((n) => (n.TEXT = "text", n))(V || {}), I = /* @__PURE__ */ ((n) => (n.URL = "url", n.STORY = "story", n.ASSET = "asset", n.EMAIL = "email", n))(I || {});
33
- const re = [
32
+ var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n.TABLE = "table", n.TABLE_ROW = "tableRow", n.TABLE_CELL = "tableCell", n.TABLE_HEADER = "tableHeader", n))(v || {}), $ = /* @__PURE__ */ ((n) => (n.BOLD = "bold", n.STRONG = "strong", n.STRIKE = "strike", n.UNDERLINE = "underline", n.ITALIC = "italic", n.CODE = "code", n.LINK = "link", n.ANCHOR = "anchor", n.STYLED = "styled", n.SUPERSCRIPT = "superscript", n.SUBSCRIPT = "subscript", n.TEXT_STYLE = "textStyle", n.HIGHLIGHT = "highlight", n))($ || {}), J = /* @__PURE__ */ ((n) => (n.TEXT = "text", n))(J || {}), I = /* @__PURE__ */ ((n) => (n.URL = "url", n.STORY = "story", n.ASSET = "asset", n.EMAIL = "email", n))(I || {});
33
+ const ne = [
34
34
  "area",
35
35
  "base",
36
36
  "br",
@@ -45,23 +45,23 @@ const re = [
45
45
  "source",
46
46
  "track",
47
47
  "wbr"
48
- ], ne = (n = {}) => Object.keys(n).map((e) => `${e}="${n[e]}"`).join(" "), oe = (n = {}) => Object.keys(n).map((e) => `${e}: ${n[e]}`).join("; ");
49
- function ie(n) {
48
+ ], oe = (n = {}) => Object.keys(n).map((e) => `${e}="${n[e]}"`).join(" "), ie = (n = {}) => Object.keys(n).map((e) => `${e}: ${n[e]}`).join("; ");
49
+ function ae(n) {
50
50
  return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
51
51
  }
52
52
  const O = (n) => Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0));
53
53
  function D(n, e = {}, t) {
54
- const r = ne(e), s = r ? `${n} ${r}` : n, o = Array.isArray(t) ? t.join("") : t || "";
54
+ const r = oe(e), s = r ? `${n} ${r}` : n, o = Array.isArray(t) ? t.join("") : t || "";
55
55
  if (n) {
56
- if (re.includes(n))
56
+ if (ne.includes(n))
57
57
  return `<${s}>`;
58
58
  } else return o;
59
59
  return `<${s}>${o}</${n}>`;
60
60
  }
61
- function ae(n = {}) {
61
+ function le(n = {}) {
62
62
  const e = /* @__PURE__ */ new Map(), {
63
63
  renderFn: t = D,
64
- textFn: r = ie,
64
+ textFn: r = ae,
65
65
  resolvers: s = {},
66
66
  optimizeImages: o = !1,
67
67
  keyedResolvers: c = !1
@@ -72,10 +72,10 @@ function ae(n = {}) {
72
72
  const { src: d, alt: p, title: m, srcset: w, sizes: b } = a.attrs || {};
73
73
  let k = d, R = {};
74
74
  if (o) {
75
- const { src: ee, attrs: te } = se(d, o);
76
- k = ee, R = te;
75
+ const { src: te, attrs: se } = re(d, o);
76
+ k = te, R = se;
77
77
  }
78
- const Z = {
78
+ const ee = {
79
79
  src: k,
80
80
  alt: p,
81
81
  title: m,
@@ -83,7 +83,7 @@ function ae(n = {}) {
83
83
  sizes: b,
84
84
  ...R
85
85
  };
86
- return u.render("img", O(Z));
86
+ return u.render("img", O(ee));
87
87
  }, f = (a, u) => {
88
88
  const { level: d, ...p } = a.attrs || {};
89
89
  return u.render(`h${d}`, p, a.children);
@@ -109,7 +109,7 @@ function ae(n = {}) {
109
109
  const { class: w, id: b, ...k } = p || {}, R = u ? {
110
110
  class: w,
111
111
  id: b,
112
- style: oe(k) || void 0
112
+ style: ie(k) || void 0
113
113
  } : p || {};
114
114
  return m.render(a, O(R), d);
115
115
  }, A = (a) => C(a), S = (a) => {
@@ -148,27 +148,27 @@ function ae(n = {}) {
148
148
  }
149
149
  const k = { ...w };
150
150
  return b && (k.href = b), u.render("a", k, a.text);
151
- }, J = (a, u) => {
151
+ }, Y = (a, u) => {
152
152
  var d, p;
153
153
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), u.render("span", {
154
154
  blok: (d = a == null ? void 0 : a.attrs) == null ? void 0 : d.body[0],
155
155
  id: (p = a.attrs) == null ? void 0 : p.id,
156
156
  style: "display: none"
157
157
  });
158
- }, Y = (a, u) => {
158
+ }, K = (a, u) => {
159
159
  const d = {}, p = u.render("tbody", {}, a.children);
160
160
  return u.render("table", d, p);
161
- }, K = (a, u) => {
161
+ }, W = (a, u) => {
162
162
  const d = {};
163
163
  return u.render("tr", d, a.children);
164
- }, W = (a, u) => {
164
+ }, X = (a, u) => {
165
165
  const { colspan: d, rowspan: p, colwidth: m, backgroundColor: w, ...b } = a.attrs || {}, k = {
166
166
  ...b
167
167
  };
168
168
  d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
169
169
  const R = [];
170
170
  return m && R.push(`width: ${m}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (k.style = R.join(" ")), u.render("td", O(k), a.children);
171
- }, X = (a, u) => {
171
+ }, Q = (a, u) => {
172
172
  const { colspan: d, rowspan: p, colwidth: m, backgroundColor: w, ...b } = a.attrs || {}, k = {
173
173
  ...b
174
174
  };
@@ -188,8 +188,8 @@ function ae(n = {}) {
188
188
  [v.HR, i("hr")],
189
189
  [v.BR, i("br")],
190
190
  [v.QUOTE, i("blockquote")],
191
- [v.COMPONENT, J],
192
- [V.TEXT, S],
191
+ [v.COMPONENT, Y],
192
+ [J.TEXT, S],
193
193
  [$.LINK, H],
194
194
  [$.ANCHOR, H],
195
195
  [$.STYLED, T("span", !0)],
@@ -202,14 +202,14 @@ function ae(n = {}) {
202
202
  [$.SUPERSCRIPT, T("sup")],
203
203
  [$.SUBSCRIPT, T("sub")],
204
204
  [$.HIGHLIGHT, T("mark")],
205
- [v.TABLE, Y],
206
- [v.TABLE_ROW, K],
207
- [v.TABLE_CELL, W],
208
- [v.TABLE_HEADER, X]
205
+ [v.TABLE, K],
206
+ [v.TABLE_ROW, W],
207
+ [v.TABLE_CELL, X],
208
+ [v.TABLE_HEADER, Q]
209
209
  ]), B = new Map([
210
210
  ...U,
211
211
  ...Object.entries(s).map(([a, u]) => [a, u])
212
- ]), Q = () => ({
212
+ ]), Z = () => ({
213
213
  render: (a, u = {}, d) => {
214
214
  if (c && a) {
215
215
  const p = e.get(a) || 0;
@@ -224,7 +224,7 @@ function ae(n = {}) {
224
224
  const u = B.get(a.type);
225
225
  if (!u)
226
226
  return console.error("<Storyblok>", `No resolver found for node type ${a.type}`), "";
227
- const d = Q();
227
+ const d = Z();
228
228
  if (a.type === "text")
229
229
  return u(a, d);
230
230
  const p = a.content ? a.content.map(C) : void 0;
@@ -241,7 +241,7 @@ function ae(n = {}) {
241
241
  };
242
242
  }
243
243
  let M = !1;
244
- const z = [], q = (n) => new Promise((e, t) => {
244
+ const z = [], F = (n) => new Promise((e, t) => {
245
245
  if (typeof window > "u") {
246
246
  t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
247
247
  return;
@@ -261,13 +261,13 @@ const z = [], q = (n) => new Promise((e, t) => {
261
261
  z.forEach((o) => o()), M = !0, e(s);
262
262
  }, document.getElementsByTagName("head")[0].appendChild(r);
263
263
  });
264
- var le = Object.defineProperty, ce = (n, e, t) => e in n ? le(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t) => ce(n, typeof e != "symbol" ? e + "" : e, t);
265
- class he extends Error {
264
+ var ce = Object.defineProperty, he = (n, e, t) => e in n ? ce(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t) => he(n, typeof e != "symbol" ? e + "" : e, t);
265
+ class ue extends Error {
266
266
  constructor(e) {
267
267
  super(e), this.name = "AbortError";
268
268
  }
269
269
  }
270
- function ue(n, e, t) {
270
+ function de(n, e, t) {
271
271
  if (!Number.isFinite(e))
272
272
  throw new TypeError("Expected `limit` to be a finite number");
273
273
  if (!Number.isFinite(t))
@@ -301,11 +301,11 @@ function ue(n, e, t) {
301
301
  });
302
302
  return i.abort = () => {
303
303
  c = !0, s.forEach(clearTimeout), s = [], r.forEach(
304
- (h) => h.reject(() => new he("Throttle function aborted"))
304
+ (h) => h.reject(() => new ue("Throttle function aborted"))
305
305
  ), r.length = 0;
306
306
  }, i;
307
307
  }
308
- const de = (n = "") => n.includes("/cdn/"), pe = (n, e = 25, t = 1) => ({
308
+ const G = (n = "") => n.includes("/cdn/"), pe = (n, e = 25, t = 1) => ({
309
309
  ...n,
310
310
  per_page: e,
311
311
  page: t
@@ -329,7 +329,7 @@ const de = (n = "") => n.includes("/cdn/"), pe = (n, e = 25, t = 1) => ({
329
329
  ) : l = `${e ? e + encodeURIComponent(`[${c}]`) : c}=${encodeURIComponent(o)}`, r.push(l);
330
330
  }
331
331
  return r.join("&");
332
- }, F = (n) => {
332
+ }, V = (n) => {
333
333
  const e = {
334
334
  eu: "api.storyblok.com",
335
335
  us: "api-us.storyblok.com",
@@ -442,12 +442,12 @@ class ve {
442
442
  });
443
443
  }
444
444
  }
445
- const G = "SB-Agent", P = {
445
+ const q = "SB-Agent", P = {
446
446
  defaultAgentName: "SB-JS-CLIENT",
447
447
  defaultAgentVersion: "SB-Agent-Version",
448
- packageVersion: "6.0.0"
448
+ packageVersion: "7.0.0"
449
449
  }, ke = {
450
- DRAFT: "draft"
450
+ PUBLISHED: "published"
451
451
  };
452
452
  let j = {};
453
453
  const E = {};
@@ -462,21 +462,21 @@ class we {
462
462
  let r = e.endpoint || t;
463
463
  if (!r) {
464
464
  const c = e.https === !1 ? "http" : "https";
465
- e.oauthToken ? r = `${c}://${F(e.region)}/v1` : r = `${c}://${F(e.region)}/v2`;
465
+ e.oauthToken ? r = `${c}://${V(e.region)}/v1` : r = `${c}://${V(e.region)}/v2`;
466
466
  }
467
467
  const s = new Headers();
468
468
  s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([c, l]) => {
469
469
  s.set(c, l);
470
- }), s.has(G) || (s.set(G, P.defaultAgentName), s.set(
470
+ }), s.has(q) || (s.set(q, P.defaultAgentName), s.set(
471
471
  P.defaultAgentVersion,
472
472
  P.packageVersion
473
473
  ));
474
474
  let o = 5;
475
- e.oauthToken && (s.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ue(
475
+ e.oauthToken && (s.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = de(
476
476
  this.throttledRequest.bind(this),
477
477
  o,
478
478
  1e3
479
- ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ke.DRAFT, this.inlineAssets = e.inlineAssets || !1, this.client = new ve({
479
+ ), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || ke.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new ve({
480
480
  baseURL: r,
481
481
  timeout: e.timeout || 0,
482
482
  headers: s,
@@ -488,7 +488,7 @@ class we {
488
488
  return e.token || (e.token = this.getToken()), e.cv || (e.cv = E[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
489
489
  }
490
490
  factoryParamOptions(e, t) {
491
- return de(e) ? this.parseParams(t) : t;
491
+ return G(e) ? this.parseParams(t) : t;
492
492
  }
493
493
  makeRequest(e, t, r, s, o) {
494
494
  const c = this.factoryParamOptions(
@@ -500,7 +500,7 @@ class we {
500
500
  get(e, t = {}, r) {
501
501
  t || (t = {});
502
502
  const s = `/${e}`;
503
- t.version = t.version || this.version;
503
+ G(s) && (t.version = t.version || this.version);
504
504
  const o = this.factoryParamOptions(s, t);
505
505
  return this.cacheResponse(s, o, void 0, r);
506
506
  }
@@ -877,21 +877,21 @@ const _e = (n, e, t = {}) => {
877
877
  h = { ...h, ...y(i) };
878
878
  }), l && (x = l);
879
879
  const f = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
880
- return r !== !1 && f && q(x), h;
880
+ return r !== !1 && f && F(x), h;
881
881
  };
882
882
  function Ee(n, e) {
883
- return ae(e).render(n);
883
+ return le(e).render(n);
884
884
  }
885
- const Ae = () => q(x);
885
+ const Ae = () => F(x);
886
886
  export {
887
887
  v as BlockTypes,
888
888
  $ as MarkTypes,
889
- V as TextTypes,
889
+ J as TextTypes,
890
890
  Te as apiPlugin,
891
891
  Ae as loadStoryblokBridge,
892
892
  _e as registerStoryblokBridge,
893
893
  Ee as renderRichText,
894
- ae as richTextResolver,
894
+ le as richTextResolver,
895
895
  Re as storyblokEditable,
896
896
  $e as storyblokInit,
897
897
  _e as useStoryblokBridge
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@storyblok/react",
3
3
  "type": "module",
4
- "version": "5.0.2-rc.0",
4
+ "version": "5.1.1",
5
5
  "private": false,
6
6
  "description": "SDK to integrate Storyblok into your project using React.",
7
7
  "author": "Storyblok",
8
8
  "license": "MIT",
9
+ "homepage": "https://github.com/storyblok/monoblok/tree/main/packages/react#readme",
9
10
  "repository": {
10
11
  "type": "git",
11
- "url": "https://github.com/storyblok/storyblok-react"
12
+ "url": "https://github.com/storyblok/monoblok.git",
13
+ "directory": "packages/react"
12
14
  },
13
15
  "bugs": {
14
- "url": "https://github.com/storyblok/storyblok-react/issues"
16
+ "url": "https://github.com/storyblok/monoblok/issues"
15
17
  },
16
18
  "exports": {
17
19
  ".": {
@@ -42,7 +44,7 @@
42
44
  }
43
45
  },
44
46
  "dependencies": {
45
- "@storyblok/js": "4.0.4-rc.0"
47
+ "@storyblok/js": "4.1.1"
46
48
  },
47
49
  "devDependencies": {
48
50
  "@babel/core": "^7.27.1",
@@ -51,7 +53,7 @@
51
53
  "@cypress/vite-dev-server": "^6.0.3",
52
54
  "@storyblok/eslint-config": "^0.3.0",
53
55
  "@tsconfig/recommended": "^1.0.8",
54
- "@types/node": "^22.15.1",
56
+ "@types/node": "^22.15.18",
55
57
  "@types/react": "19.1.4",
56
58
  "@vitejs/plugin-react": "^4.4.1",
57
59
  "babel-jest": "^29.7.0",