@storyblok/react 2.1.3 → 2.1.5

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.
@@ -1,19 +1,16 @@
1
- import { useState, useEffect } from "react";
2
- import { h as he } from "./storyblok-js-612aedc3.mjs";
1
+ import { useState } from "react";
2
+ import { u as ue } from "./storyblok-js-834d6ca5.mjs";
3
3
  const useStoryblokState = (initialStory = null, bridgeOptions = {}) => {
4
4
  let [story, setStory] = useState(initialStory);
5
5
  const isBridgeEnable = typeof window !== "undefined" && typeof window.storyblokRegisterEvent !== "undefined";
6
6
  if (!isBridgeEnable || !initialStory) {
7
7
  return initialStory;
8
8
  }
9
- useEffect(() => {
10
- setStory(initialStory);
11
- he(
12
- story.id,
13
- (newStory) => setStory(newStory),
14
- bridgeOptions
15
- );
16
- }, [initialStory]);
9
+ ue(
10
+ story.id,
11
+ (newStory) => setStory(newStory),
12
+ bridgeOptions
13
+ );
17
14
  return story;
18
15
  };
19
16
  export {
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react"),t=require("./storyblok-js-1cafaa66.js");exports.useStoryblokState=(r=null,o={})=>{let[s,i]=e.useState(r);return"undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent&&r?(t.ue(s.id,(e=>i(e)),o),s):r};
@@ -1,4 +1,4 @@
1
- import { u as ue } from "./storyblok-js-612aedc3.mjs";
1
+ import { p as pe } from "./storyblok-js-834d6ca5.mjs";
2
2
  import React, { forwardRef } from "react";
3
3
  const StoryblokComponent = forwardRef(
4
4
  ({ blok, ...restProps }, ref) => {
@@ -34,7 +34,7 @@ const getComponent = (componentKey) => {
34
34
  return componentsMap[componentKey];
35
35
  };
36
36
  const storyblokInit = (pluginOptions = {}) => {
37
- const { storyblokApi } = ue(pluginOptions);
37
+ const { storyblokApi } = pe(pluginOptions);
38
38
  storyblokApiInstance = storyblokApi;
39
39
  componentsMap = pluginOptions.components;
40
40
  };
@@ -1 +1 @@
1
- "use strict";const o=require("./storyblok-js-a8758ae9.js"),e=require("react"),t=e.forwardRef((({blok:o,...t},r)=>{if(!o)return console.error("Please provide a 'blok' property to the StoryblokComponent"),e.createElement("div",null,"Please provide a blok property to the StoryblokComponent");const n=l(o.component);return n?e.createElement(n,{ref:r,blok:o,...t}):e.createElement("div",null)}));t.displayName="StoryblokComponent";let r=null,n={};const l=o=>n[o]?n[o]:(console.error(`Component ${o} doesn't exist.`),!1);exports.StoryblokComponent=t,exports.getComponent=l,exports.storyblokInit=(e={})=>{const{storyblokApi:t}=o.ue(e);r=t,n=e.components},exports.useStoryblokApi=()=>(r||console.error("You can't use getStoryblokApi if you're not loading apiPlugin."),r);
1
+ "use strict";const o=require("./storyblok-js-1cafaa66.js"),e=require("react"),t=e.forwardRef((({blok:o,...t},r)=>{if(!o)return console.error("Please provide a 'blok' property to the StoryblokComponent"),e.createElement("div",null,"Please provide a blok property to the StoryblokComponent");const n=l(o.component);return n?e.createElement(n,{ref:r,blok:o,...t}):e.createElement("div",null)}));t.displayName="StoryblokComponent";let r=null,n={};const l=o=>n[o]?n[o]:(console.error(`Component ${o} doesn't exist.`),!1);exports.StoryblokComponent=t,exports.getComponent=l,exports.storyblokInit=(e={})=>{const{storyblokApi:t}=o.pe(e);r=t,n=e.components},exports.useStoryblokApi=()=>(r||console.error("You can't use getStoryblokApi if you're not loading apiPlugin."),r);
@@ -0,0 +1 @@
1
+ "use strict";let t=!1;const e=[],s=s=>new Promise(((r,o)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{window.location!==window.parent.location?t?s():e.push(s):console.warn("You are not in Draft Mode or in the Visual Editor.")},document.getElementById("storyblok-javascript-bridge")))return;const i=document.createElement("script");i.async=!0,i.src=s,i.id="storyblok-javascript-bridge",i.onerror=t=>o(t),i.onload=s=>{e.forEach((t=>t())),t=!0,r(s)},document.getElementsByTagName("head")[0].appendChild(i)}));var r=Object.defineProperty,o=(t,e,s)=>(((t,e,s)=>{e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(t,"symbol"!=typeof e?e+"":e,s),s);function i(t){return!(t!=t||t===1/0||t===-1/0)}const n=function(t,e){const s={};for(const r in t){const o=t[r];e.indexOf(r)>-1&&null!==o&&(s[r]=o)}return s},a={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:t=>({tag:`h${t.attrs.level}`}),image:t=>({singleTag:[{tag:"img",attrs:n(t.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"}),emoji:t=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":t.attrs.name,emoji:t.attrs.emoji}}]})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link:t=>{const e={...t.attrs},{linktype:s="url"}=t.attrs;if((t=>"email"===t)(s)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const t in e.custom)e[t]=e.custom[t];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},styled:t=>({tag:[{tag:"span",attrs:t.attrs}]}),subscript:()=>({tag:"sub"}),superscript:()=>({tag:"sup"}),anchor:t=>({tag:[{tag:"span",attrs:t.attrs}]}),highlight:t=>{var e;return null!=(e=t.attrs)&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${t.attrs.color};`}}]}:{tag:""}},textStyle:t=>{var e;return null!=(e=t.attrs)&&e.color?{tag:[{tag:"span",attrs:{style:`color:${t.attrs.color}`}}]}:{tag:""}}}};class l{constructor(t){o(this,"marks"),o(this,"nodes"),t||(t=a),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}){if(t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach((t=>{s+=this.renderNode(t)})),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn("The render method must receive an Object with a \"content\" field.\n\t\t\tThe \"content\" field must be an array of nodes as the type ISbRichtext.\n\t\t\tISbRichtext:\n\t\t\t\tcontent?: ISbRichtext[]\n\t\t\t\tmarks?: ISbRichtext[]\n\t\t\t\tattrs?: any\n\t\t\t\ttext?: string\n\t\t\t\ttype: string\n\t\t\t\t\n\t\t\t\tExample:\n\t\t\t\t{\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttext: 'Hello World',\n\t\t\t\t\t\t\t\t\ttype: 'text'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\ttype: 'paragraph'\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\ttype: 'doc'\n\t\t\t\t}"),""}optimizeImages(t,e){let s=0,r=0,o="",i="";"boolean"!=typeof e&&("number"==typeof e.width&&e.width>0&&(o+=`width="${e.width}" `,s=e.width),"number"==typeof e.height&&e.height>0&&(o+=`height="${e.height}" `,r=e.height),("lazy"===e.loading||"eager"===e.loading)&&(o+=`loading="${e.loading}" `),"string"==typeof e.class&&e.class.length>0&&(o+=`class="${e.class}" `),e.filters&&("number"==typeof e.filters.blur&&e.filters.blur>=0&&e.filters.blur<=100&&(i+=`:blur(${e.filters.blur})`),"number"==typeof e.filters.brightness&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(i+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||"transparent"===e.filters.fill)&&(i+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(i+=`:format(${e.filters.format})`),"boolean"==typeof e.filters.grayscale&&e.filters.grayscale&&(i+=":grayscale()"),"number"==typeof e.filters.quality&&e.filters.quality>=0&&e.filters.quality<=100&&(i+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(i+=`:rotate(${e.filters.rotate})`),i.length>0&&(i="/filters"+i))),o.length>0&&(t=t.replace(/<img/g,`<img ${o.trim()}`));const n=s>0||r>0||i.length>0?`${s}x${r}${i}`:"";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/${n}`),"boolean"!=typeof e&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,(t=>{var s,r;const o=t.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(o&&o.length>0){const n={srcset:null==(s=e.srcset)?void 0:s.map((t=>{if("number"==typeof t)return`//${o}/m/${t}x0${i} ${t}w`;if("object"==typeof t&&2===t.length){let e=0,s=0;return"number"==typeof t[0]&&(e=t[0]),"number"==typeof t[1]&&(s=t[1]),`//${o}/m/${e}x${s}${i} ${e}w`}})).join(", "),sizes:null==(r=e.sizes)?void 0:r.map((t=>t)).join(", ")};let a="";return n.srcset&&(a+=`srcset="${n.srcset}" `),n.sizes&&(a+=`sizes="${n.sizes}" `),t.replace(/<img/g,`<img ${a.trim()}`)}return t}))),t}renderNode(t){const e=[];t.marks&&t.marks.forEach((t=>{const s=this.getMatchingMark(t);s&&""!==s.tag&&e.push(this.renderOpeningTag(s.tag))}));const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach((t=>{e.push(this.renderNode(t))})):t.text?e.push(function(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=RegExp(s.source);return t&&r.test(t)?t.replace(s,(t=>e[t])):t}(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):"emoji"===t.type&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach((t=>{const s=this.getMatchingMark(t);s&&""!==s.tag&&e.push(this.renderClosingTag(s.tag))})),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map((t=>{if(t.constructor===String)return`<${t}${e}>`;{let s=`<${t.tag}`;if(t.attrs)for(const e in t.attrs){const r=t.attrs[e];null!==r&&(s+=` ${e}="${r}"`)}return`${s}${e}>`}})).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map((t=>t.constructor===String?`</${t}>`:`</${t.tag}>`)).join("")}getMatchingNode(t){const e=this.nodes[t.type];if("function"==typeof e)return e(t)}getMatchingMark(t){const e=this.marks[t.type];if("function"==typeof e)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," /")}}class c{constructor(){o(this,"isCDNUrl",((t="")=>t.indexOf("/cdn/")>-1)),o(this,"getOptionsPage",((t,e=25,s=1)=>({...t,per_page:e,page:s}))),o(this,"delay",(t=>new Promise((e=>setTimeout(e,t))))),o(this,"arrayFrom",((t=0,e)=>[...Array(t)].map(e))),o(this,"range",((t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,((e,s)=>s*r+t))})),o(this,"asyncMap",(async(t,e)=>Promise.all(t.map(e)))),o(this,"flatMap",((t=[],e)=>t.map(e).reduce(((t,e)=>[...t,...e]),[])))}stringify(t,e,s){const r=[];for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const i=t[o],n=s?"":encodeURIComponent(o);let a;a="object"==typeof i?this.stringify(i,e?e+encodeURIComponent("["+n+"]"):n,Array.isArray(i)):(e?e+encodeURIComponent("["+n+"]"):n)+"="+encodeURIComponent(i),r.push(a)}return r.join("&")}getRegionURL(t){switch(t){case"us":return"api-us.storyblok.com";case"cn":return"app.storyblokchina.cn";default:return"api.storyblok.com"}}}class h{constructor(t){o(this,"baseURL"),o(this,"timeout"),o(this,"headers"),o(this,"responseInterceptor"),o(this,"fetch"),o(this,"ejectInterceptor"),o(this,"url"),o(this,"parameters"),this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=null!=t&&t.timeout?1e3*t.timeout:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}delete(t,e){return this.url=t,this.parameters=e,this._methodHandler("delete")}async _responseHandler(t){const e=[],s={data:{},headers:{},status:0,statusText:""};204!==t.status&&await t.json().then((t=>{s.data=t}));for(const r of t.headers.entries())e[r[0]]=r[1];return s.headers={...e},s.status=t.status,s.statusText=t.statusText,s}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,s=null;if("get"===t){const t=new c;e=`${this.baseURL}${this.url}?${t.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),o=new AbortController,{signal:i}=o;let n;this.timeout&&(n=setTimeout((()=>o.abort()),this.timeout));try{const e=await this.fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:i});this.timeout&&clearTimeout(n);const o=await this._responseHandler(e);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(o)):this._statusHandler(o)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(t){const e=/20[0-6]/g;return new Promise(((s,r)=>{if(e.test(`${t.status}`))return s(t);r({message:new Error(t.statusText),status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug})}))}}let u={};const p={};class d{constructor(t,e){if(o(this,"client"),o(this,"maxRetries"),o(this,"throttle"),o(this,"accessToken"),o(this,"cache"),o(this,"helpers"),o(this,"resolveCounter"),o(this,"relations"),o(this,"links"),o(this,"richTextResolver"),o(this,"resolveNestedRelations"),!e){const s=(new c).getRegionURL,r=!1===t.https?"http":"https";e=t.oauthToken?`${r}://${s(t.region)}/v1`:`${r}://${s(t.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),s.forEach(((e,r)=>{t.headers&&t.headers[r]&&s.set(r,t.headers[r])}));let r=5;t.oauthToken&&(s.set("Authorization",t.oauthToken),r=3),t.rateLimit&&(r=t.rateLimit),t.richTextSchema?this.richTextResolver=new l(t.richTextSchema):this.richTextResolver=new l,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=function(t,e,s){if(!i(e))throw new TypeError("Expected `limit` to be a finite number");if(!i(s))throw new TypeError("Expected `interval` to be a finite number");const r=[];let o=[],n=0;const a=function(){n++;const e=setTimeout((function(){n--,r.length>0&&a(),o=o.filter((function(t){return t!==e}))}),s);o.indexOf(e)<0&&o.push(e);const i=r.shift();i.resolve(t.apply(i.self,i.args))},l=function(...t){const s=this;return new Promise((function(o,i){r.push({resolve:o,reject:i,args:t,self:s}),n<e&&a()}))};return l.abort=function(){o.forEach(clearTimeout),o=[],r.forEach((function(t){t.reject((function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"}))})),r.length=0},l}(this.throttledRequest,r,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new c,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.client=new h({baseURL:e,timeout:t.timeout||0,headers:s,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",(e=>{let s="";return e.attrs.body&&e.attrs.body.forEach((e=>{s+=t(e.component,e)})),{html:s}}))}parseParams(t){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=p[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e){return this.helpers.isCDNUrl(t)?this.parseParams(e):e}makeRequest(t,e,s,r){const o=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,o)}get(t,e){e||(e={});const s=`/${t}`,r=this.factoryParamOptions(s,e);return this.cacheResponse(s,r)}async getAll(t,e,s){const r=(null==e?void 0:e.per_page)||25,o=`/${t}`,i=o.split("/"),n=s||i[i.length-1],a=await this.makeRequest(o,e,r,1),l=a.total?Math.ceil(a.total/r):1,c=await this.helpers.asyncMap(this.helpers.range(1,l),(t=>this.makeRequest(o,e,r,t+1)));return this.helpers.flatMap([a,...c],(t=>Object.values(t.data[n])))}post(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("post",s,e))}put(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("put",s,e))}delete(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("delete",s,e))}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,s){const r=t[e];r&&"multilink"==r.fieldtype&&"story"==r.linktype&&"string"==typeof r.id&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&"story"===r.linktype&&"string"==typeof r.uuid&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}_insertRelations(t,e,s,r){if(s.indexOf(`${t.component}.${e}`)>-1)if("string"==typeof t[e])this.relations[r][t[e]]&&(t[e]=this._cleanCopy(this.relations[r][t[e]]));else if(t[e]&&t[e].constructor===Array){const s=[];t[e].forEach((t=>{this.relations[r][t]&&s.push(this._cleanCopy(this.relations[r][t]))})),t[e]=s}}iterateTree(t,e,s){const r=t=>{if(null!=t)if(t.constructor===Array)for(let e=0;e<t.length;e++)r(t[e]);else if(t.constructor===Object){if(t._stopResolving)return;for(const o in t)(t.component&&t._uid||"link"===t.type)&&(this._insertRelations(t,o,e,s),this._insertLinks(t,o,s)),r(t[o])}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const s=t.link_uuids.length,o=[],i=50;for(let e=0;e<s;e+=i){const r=Math.min(s,e+i);o.push(t.link_uuids.slice(e,r))}for(let t=0;t<o.length;t++)(await this.getStories({per_page:i,language:e.language,version:e.version,by_uuids:o[t].join(",")})).data.stories.forEach((t=>{r.push(t)}))}else r=t.links;r.forEach((t=>{this.links[s][t.uuid]={...t,_stopResolving:!0}}))}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const s=t.rel_uuids.length,o=[],i=50;for(let e=0;e<s;e+=i){const r=Math.min(s,e+i);o.push(t.rel_uuids.slice(e,r))}for(let t=0;t<o.length;t++)(await this.getStories({per_page:i,language:e.language,version:e.version,by_uuids:o[t].join(",")})).data.stories.forEach((t=>{r.push(t)}))}else r=t.rels;r&&r.length>0&&r.forEach((t=>{this.relations[s][t.uuid]={...t,_stopResolving:!0}}))}async resolveStories(t,e,s){var r,o;let i=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&("string"==typeof e.resolve_relations&&(i=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url"].indexOf(e.resolve_links)>-1&&(null!=(r=t.links)&&r.length||null!=(o=t.link_uuids)&&o.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const n in this.relations[s])this.iterateTree(this.relations[s][n],i,s);t.story?this.iterateTree(t.story,i,s):t.stories.forEach((t=>{this.iterateTree(t,i,s)})),delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){const r=this.helpers.stringify({url:t,params:e}),o=this.cacheProvider();if("auto"===this.cache.clear&&"draft"===e.version&&await this.flushCache(),"published"===e.version&&"/cdn/spaces/me"!=t){const t=await o.get(r);if(t)return Promise.resolve(t)}return new Promise(((s,i)=>{try{(async()=>{var n;try{const a=await this.throttle("get",t,e);let l={data:a.data,headers:a.headers};if(null!=(n=a.headers)&&n["per-page"]&&(l=Object.assign({},l,{perPage:a.headers["per-page"]?parseInt(a.headers["per-page"]):0,total:a.headers["per-page"]?parseInt(a.headers.total):0})),200!=a.status)return i(a);if(l.data.story||l.data.stories){const t=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(l.data,e,`${t}`)}return"published"===e.version&&"/cdn/spaces/me"!=t&&await o.set(r,l),l.data.cv&&e.token&&("draft"==e.version&&p[e.token]!=l.data.cv&&await this.flushCache(),p[e.token]=l.data.cv),s(l)}catch(a){return i(a)}})()}catch{}}))}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return p}cacheVersion(){return p[this.accessToken]}setCacheVersion(t){this.accessToken&&(p[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get:t=>Promise.resolve(u[t]),getAll:()=>Promise.resolve(u),set:(t,e)=>(u[t]=e,Promise.resolve(void 0)),flush:()=>(u={},Promise.resolve(void 0))};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get:()=>Promise.resolve(void 0),getAll:()=>Promise.resolve(void 0),set:()=>Promise.resolve(void 0),flush:()=>Promise.resolve(void 0)}}}async flushCache(){return await this.cacheProvider().flush(),this}}let g;const f="https://app.storyblok.com/f/storyblok-v2-latest.js",m=(t,e)=>{t.addNode("blok",(t=>{let s="";return t.attrs.body.forEach((t=>{s+=e(t.component,t)})),{html:s}}))};exports.ce=(t={})=>{const{apiOptions:e}=t;if(e.accessToken)return{storyblokApi:new d(e)};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")},exports.de=(t,e,s)=>{let r=s||g;if(r)return(t=>{var e,s;return!t||"blok"!==(null==(e=null==t?void 0:t.content)?void 0:e[0].type)&&!(null!=(s=null==t?void 0:t.content)&&s[0].content)})(t)?"":(e&&(r=new l(e.schema),e.resolver&&m(r,e.resolver)),r.render(t));console.error("Please initialize the Storyblok SDK before calling the renderRichText function")},exports.ge=()=>s(f),exports.he=t=>{if("object"!=typeof t||typeof t._editable>"u")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}},exports.ie=a,exports.pe=(t={})=>{var e,r;const{bridge:o,accessToken:i,use:n=[],apiOptions:a={},richText:c={}}=t;a.accessToken=a.accessToken||i;const h={bridge:o,apiOptions:a};let u={};n.forEach((t=>{u={...u,...t(h)}}));const p=!(typeof window>"u")&&(null==(r=null==(e=window.location)?void 0:e.search)?void 0:r.includes("_storyblok_tk"));return!1!==o&&p&&s(f),g=new l(c.schema),c.resolver&&m(g,c.resolver),u},exports.ue=(t,e,s={})=>{var r;const o=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL(null==(r=window.location)?void 0:r.href).searchParams.get("_storyblok")===t;if(o&&i){if(!t)return void console.warn("Story ID is not defined. Please provide a valid ID.");window.storyblokRegisterEvent((()=>{new window.StoryblokBridge(s).on(["input","published","change"],(s=>{"input"===s.action&&s.story.id===t?e(s.story):("change"===s.action||"published"===s.action)&&s.storyId===t&&window.location.reload()}))}))}},exports.y=l;
@@ -1,5 +1,5 @@
1
1
  let R = false;
2
- const T = [], j = (n) => new Promise((e, t) => {
2
+ const T = [], j = (o) => new Promise((e, t) => {
3
3
  if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
4
4
  if (window.location === window.parent.location) {
5
5
  console.warn("You are not in Draft Mode or in the Visual Editor.");
@@ -9,40 +9,40 @@ const T = [], j = (n) => new Promise((e, t) => {
9
9
  }, document.getElementById("storyblok-javascript-bridge")))
10
10
  return;
11
11
  const s = document.createElement("script");
12
- s.async = true, s.src = n, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
12
+ s.async = true, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
13
13
  T.forEach((i) => i()), R = true, e(r);
14
14
  }, document.getElementsByTagName("head")[0].appendChild(s);
15
15
  });
16
- var I = Object.defineProperty, P = (n, e, t) => e in n ? I(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t, h = (n, e, t) => (P(n, typeof e != "symbol" ? e + "" : e, t), t);
17
- function _(n) {
18
- return !(n !== n || n === 1 / 0 || n === -1 / 0);
16
+ var I = Object.defineProperty, P = (o, e, t) => e in o ? I(o, e, { enumerable: true, configurable: true, writable: true, value: t }) : o[e] = t, h = (o, e, t) => (P(o, typeof e != "symbol" ? e + "" : e, t), t);
17
+ function _(o) {
18
+ return !(o !== o || o === 1 / 0 || o === -1 / 0);
19
19
  }
20
- function S(n, e, t) {
20
+ function S(o, e, t) {
21
21
  if (!_(e))
22
22
  throw new TypeError("Expected `limit` to be a finite number");
23
23
  if (!_(t))
24
24
  throw new TypeError("Expected `interval` to be a finite number");
25
25
  const s = [];
26
26
  let r = [], i = 0;
27
- const o = function() {
27
+ const n = function() {
28
28
  i++;
29
29
  const a = setTimeout(function() {
30
- i--, s.length > 0 && o(), r = r.filter(function(u) {
30
+ i--, s.length > 0 && n(), r = r.filter(function(u) {
31
31
  return u !== a;
32
32
  });
33
33
  }, t);
34
34
  r.indexOf(a) < 0 && r.push(a);
35
35
  const l = s.shift();
36
- l.resolve(n.apply(l.self, l.args));
36
+ l.resolve(o.apply(l.self, l.args));
37
37
  }, c = function(...a) {
38
38
  const l = this;
39
- return new Promise(function(u, d) {
39
+ return new Promise(function(u, p) {
40
40
  s.push({
41
41
  resolve: u,
42
- reject: d,
42
+ reject: p,
43
43
  args: a,
44
44
  self: l
45
- }), i < e && o();
45
+ }), i < e && n();
46
46
  });
47
47
  };
48
48
  return c.abort = function() {
@@ -53,36 +53,36 @@ function S(n, e, t) {
53
53
  }), s.length = 0;
54
54
  }, c;
55
55
  }
56
- const C = function(n, e) {
56
+ const C = function(o, e) {
57
57
  const t = {};
58
- for (const s in n) {
59
- const r = n[s];
58
+ for (const s in o) {
59
+ const r = o[s];
60
60
  e.indexOf(s) > -1 && r !== null && (t[s] = r);
61
61
  }
62
62
  return t;
63
- }, O = (n) => n === "email", A = () => ({
63
+ }, O = (o) => o === "email", A = () => ({
64
64
  singleTag: "hr"
65
65
  }), N = () => ({
66
66
  tag: "blockquote"
67
67
  }), L = () => ({
68
68
  tag: "ul"
69
- }), M = (n) => ({
69
+ }), M = (o) => ({
70
70
  tag: [
71
71
  "pre",
72
72
  {
73
73
  tag: "code",
74
- attrs: n.attrs
74
+ attrs: o.attrs
75
75
  }
76
76
  ]
77
77
  }), z = () => ({
78
78
  singleTag: "br"
79
- }), U = (n) => ({
80
- tag: `h${n.attrs.level}`
81
- }), q = (n) => ({
79
+ }), U = (o) => ({
80
+ tag: `h${o.attrs.level}`
81
+ }), q = (o) => ({
82
82
  singleTag: [
83
83
  {
84
84
  tag: "img",
85
- attrs: C(n.attrs, ["src", "alt", "title"])
85
+ attrs: C(o.attrs, ["src", "alt", "title"])
86
86
  }
87
87
  ]
88
88
  }), H = () => ({
@@ -91,18 +91,18 @@ const C = function(n, e) {
91
91
  tag: "ol"
92
92
  }), D = () => ({
93
93
  tag: "p"
94
- }), F = (n) => ({
94
+ }), J = (o) => ({
95
95
  tag: [
96
96
  {
97
97
  tag: "span",
98
98
  attrs: {
99
99
  ["data-type"]: "emoji",
100
- ["data-name"]: n.attrs.name,
101
- emoji: n.attrs.emoji
100
+ ["data-name"]: o.attrs.name,
101
+ emoji: o.attrs.emoji
102
102
  }
103
103
  }
104
104
  ]
105
- }), J = () => ({
105
+ }), F = () => ({
106
106
  tag: "b"
107
107
  }), V = () => ({
108
108
  tag: "strike"
@@ -114,8 +114,8 @@ const C = function(n, e) {
114
114
  tag: "code"
115
115
  }), G = () => ({
116
116
  tag: "i"
117
- }), Q = (n) => {
118
- const e = { ...n.attrs }, { linktype: t = "url" } = n.attrs;
117
+ }), Q = (o) => {
118
+ const e = { ...o.attrs }, { linktype: t = "url" } = o.attrs;
119
119
  if (O(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
120
120
  for (const s in e.custom)
121
121
  e[s] = e.custom[s];
@@ -129,43 +129,53 @@ const C = function(n, e) {
129
129
  }
130
130
  ]
131
131
  };
132
- }, X = (n) => ({
132
+ }, X = (o) => ({
133
133
  tag: [
134
134
  {
135
135
  tag: "span",
136
- attrs: n.attrs
136
+ attrs: o.attrs
137
137
  }
138
138
  ]
139
139
  }), Z = () => ({
140
140
  tag: "sub"
141
141
  }), ee = () => ({
142
142
  tag: "sup"
143
- }), te = (n) => ({
143
+ }), te = (o) => ({
144
144
  tag: [
145
145
  {
146
146
  tag: "span",
147
- attrs: n.attrs
147
+ attrs: o.attrs
148
148
  }
149
149
  ]
150
- }), se = (n) => ({
151
- tag: [
152
- {
153
- tag: "span",
154
- attrs: {
155
- style: `background-color:${n.attrs.color};`
150
+ }), se = (o) => {
151
+ var e;
152
+ return (e = o.attrs) != null && e.color ? {
153
+ tag: [
154
+ {
155
+ tag: "span",
156
+ attrs: {
157
+ style: `background-color:${o.attrs.color};`
158
+ }
156
159
  }
157
- }
158
- ]
159
- }), re = (n) => ({
160
- tag: [
161
- {
162
- tag: "span",
163
- attrs: {
164
- style: `color:${n.attrs.color}`
160
+ ]
161
+ } : {
162
+ tag: ""
163
+ };
164
+ }, re = (o) => {
165
+ var e;
166
+ return (e = o.attrs) != null && e.color ? {
167
+ tag: [
168
+ {
169
+ tag: "span",
170
+ attrs: {
171
+ style: `color:${o.attrs.color}`
172
+ }
165
173
  }
166
- }
167
- ]
168
- }), ie = {
174
+ ]
175
+ } : {
176
+ tag: ""
177
+ };
178
+ }, ie = {
169
179
  nodes: {
170
180
  horizontal_rule: A,
171
181
  blockquote: N,
@@ -177,10 +187,10 @@ const C = function(n, e) {
177
187
  list_item: H,
178
188
  ordered_list: B,
179
189
  paragraph: D,
180
- emoji: F
190
+ emoji: J
181
191
  },
182
192
  marks: {
183
- bold: J,
193
+ bold: F,
184
194
  strike: V,
185
195
  underline: Y,
186
196
  strong: K,
@@ -194,7 +204,7 @@ const C = function(n, e) {
194
204
  highlight: se,
195
205
  textStyle: re
196
206
  }
197
- }, oe = function(n) {
207
+ }, oe = function(o) {
198
208
  const e = {
199
209
  "&": "&amp;",
200
210
  "<": "&lt;",
@@ -202,7 +212,7 @@ const C = function(n, e) {
202
212
  '"': "&quot;",
203
213
  "'": "&#39;"
204
214
  }, t = /[&<>"']/g, s = RegExp(t.source);
205
- return n && s.test(n) ? n.replace(t, (r) => e[r]) : n;
215
+ return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
206
216
  };
207
217
  class y {
208
218
  constructor(e) {
@@ -249,28 +259,28 @@ class y {
249
259
  ), "";
250
260
  }
251
261
  optimizeImages(e, t) {
252
- let s = 0, r = 0, i = "", o = "";
253
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (i += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (i += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (i += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (i += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (o += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (o += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (o += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (o += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (o += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (o += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (o += `:rotate(${t.filters.rotate})`), o.length > 0 && (o = "/filters" + o))), i.length > 0 && (e = e.replace(/<img/g, `<img ${i.trim()}`));
254
- const c = s > 0 || r > 0 || o.length > 0 ? `${s}x${r}${o}` : "";
262
+ let s = 0, r = 0, i = "", n = "";
263
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (i += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (i += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (i += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (i += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (n += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (n += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (n += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (n += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (n += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (n += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (n += `:rotate(${t.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), i.length > 0 && (e = e.replace(/<img/g, `<img ${i.trim()}`));
264
+ const c = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
255
265
  return e = e.replace(
256
266
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
257
267
  `a.storyblok.com/f/$1/$2.$3/m/${c}`
258
268
  ), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
259
269
  var l, u;
260
- const d = a.match(
270
+ const p = a.match(
261
271
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
262
272
  );
263
- if (d && d.length > 0) {
273
+ if (p && p.length > 0) {
264
274
  const g = {
265
- srcset: (l = t.srcset) == null ? void 0 : l.map((p) => {
266
- if (typeof p == "number")
267
- return `//${d}/m/${p}x0${o} ${p}w`;
268
- if (typeof p == "object" && p.length === 2) {
269
- let k = 0, $ = 0;
270
- return typeof p[0] == "number" && (k = p[0]), typeof p[1] == "number" && ($ = p[1]), `//${d}/m/${k}x${$}${o} ${k}w`;
275
+ srcset: (l = t.srcset) == null ? void 0 : l.map((d) => {
276
+ if (typeof d == "number")
277
+ return `//${p}/m/${d}x0${n} ${d}w`;
278
+ if (typeof d == "object" && d.length === 2) {
279
+ let v = 0, $ = 0;
280
+ return typeof d[0] == "number" && (v = d[0]), typeof d[1] == "number" && ($ = d[1]), `//${p}/m/${v}x${$}${n} ${v}w`;
271
281
  }
272
282
  }).join(", "),
273
- sizes: (u = t.sizes) == null ? void 0 : u.map((p) => p).join(", ")
283
+ sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
274
284
  };
275
285
  let b = "";
276
286
  return g.srcset && (b += `srcset="${g.srcset}" `), g.sizes && (b += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${b.trim()}`);
@@ -282,14 +292,14 @@ class y {
282
292
  const t = [];
283
293
  e.marks && e.marks.forEach((r) => {
284
294
  const i = this.getMatchingMark(r);
285
- i && t.push(this.renderOpeningTag(i.tag));
295
+ i && i.tag !== "" && t.push(this.renderOpeningTag(i.tag));
286
296
  });
287
297
  const s = this.getMatchingNode(e);
288
298
  return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
289
299
  t.push(this.renderNode(r));
290
300
  }) : e.text ? t.push(oe(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
291
301
  const i = this.getMatchingMark(r);
292
- i && t.push(this.renderClosingTag(i.tag));
302
+ i && i.tag !== "" && t.push(this.renderClosingTag(i.tag));
293
303
  }), t.join("");
294
304
  }
295
305
  renderTag(e, t) {
@@ -300,8 +310,8 @@ class y {
300
310
  let r = `<${s.tag}`;
301
311
  if (s.attrs)
302
312
  for (const i in s.attrs) {
303
- const o = s.attrs[i];
304
- o !== null && (r += ` ${i}="${o}"`);
313
+ const n = s.attrs[i];
314
+ n !== null && (r += ` ${i}="${n}"`);
305
315
  }
306
316
  return `${r}${t}>`;
307
317
  }
@@ -340,7 +350,7 @@ class y {
340
350
  return this.renderTag(t, " /");
341
351
  }
342
352
  }
343
- class v {
353
+ class k {
344
354
  constructor() {
345
355
  h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, s = 1) => ({
346
356
  ...e,
@@ -348,7 +358,7 @@ class v {
348
358
  page: s
349
359
  })), h(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), h(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), h(this, "range", (e = 0, t = e) => {
350
360
  const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
351
- return this.arrayFrom(s, (i, o) => o * r + e);
361
+ return this.arrayFrom(s, (i, n) => n * r + e);
352
362
  }), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []));
353
363
  }
354
364
  /**
@@ -363,13 +373,13 @@ class v {
363
373
  for (const i in e) {
364
374
  if (!Object.prototype.hasOwnProperty.call(e, i))
365
375
  continue;
366
- const o = e[i], c = s ? "" : encodeURIComponent(i);
376
+ const n = e[i], c = s ? "" : encodeURIComponent(i);
367
377
  let a;
368
- typeof o == "object" ? a = this.stringify(
369
- o,
378
+ typeof n == "object" ? a = this.stringify(
379
+ n,
370
380
  t ? t + encodeURIComponent("[" + c + "]") : c,
371
- Array.isArray(o)
372
- ) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(o), r.push(a);
381
+ Array.isArray(n)
382
+ ) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(n), r.push(a);
373
383
  }
374
384
  return r.join("&");
375
385
  }
@@ -429,13 +439,13 @@ class ne {
429
439
  async _methodHandler(e) {
430
440
  let t = `${this.baseURL}${this.url}`, s = null;
431
441
  if (e === "get") {
432
- const a = new v();
442
+ const a = new k();
433
443
  t = `${this.baseURL}${this.url}?${a.stringify(
434
444
  this.parameters
435
445
  )}`;
436
446
  } else
437
447
  s = JSON.stringify(this.parameters);
438
- const r = new URL(t), i = new AbortController(), { signal: o } = i;
448
+ const r = new URL(t), i = new AbortController(), { signal: n } = i;
439
449
  let c;
440
450
  this.timeout && (c = setTimeout(() => i.abort(), this.timeout));
441
451
  try {
@@ -443,7 +453,7 @@ class ne {
443
453
  method: e,
444
454
  headers: this.headers,
445
455
  body: s,
446
- signal: o
456
+ signal: n
447
457
  });
448
458
  this.timeout && clearTimeout(c);
449
459
  const l = await this._responseHandler(a);
@@ -481,15 +491,15 @@ class ae {
481
491
  */
482
492
  constructor(e, t) {
483
493
  if (h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations"), !t) {
484
- const i = new v().getRegionURL, o = e.https === false ? "http" : "https";
485
- e.oauthToken ? t = `${o}://${i(e.region)}/v1` : t = `${o}://${i(e.region)}/v2`;
494
+ const i = new k().getRegionURL, n = e.https === false ? "http" : "https";
495
+ e.oauthToken ? t = `${n}://${i(e.region)}/v1` : t = `${n}://${i(e.region)}/v2`;
486
496
  }
487
497
  const s = new Headers();
488
- s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), s.forEach((i, o) => {
489
- e.headers && e.headers[o] && s.set(o, e.headers[o]);
498
+ s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), s.forEach((i, n) => {
499
+ e.headers && e.headers[n] && s.set(n, e.headers[n]);
490
500
  });
491
501
  let r = 5;
492
- e.oauthToken && (s.set("Authorization", e.oauthToken), r = 3), e.rateLimit && (r = e.rateLimit), e.richTextSchema ? this.richTextResolver = new y(e.richTextSchema) : this.richTextResolver = new y(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = S(this.throttledRequest, r, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new v(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || true, this.client = new ne({
502
+ e.oauthToken && (s.set("Authorization", e.oauthToken), r = 3), e.rateLimit && (r = e.rateLimit), e.richTextSchema ? this.richTextResolver = new y(e.richTextSchema) : this.richTextResolver = new y(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = S(this.throttledRequest, r, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new k(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || true, this.client = new ne({
493
503
  baseURL: t,
494
504
  timeout: e.timeout || 0,
495
505
  headers: s,
@@ -500,7 +510,7 @@ class ae {
500
510
  setComponentResolver(e) {
501
511
  this.richTextResolver.addNode("blok", (t) => {
502
512
  let s = "";
503
- return t.attrs.body.forEach((r) => {
513
+ return t.attrs.body && t.attrs.body.forEach((r) => {
504
514
  s += e(r.component, r);
505
515
  }), {
506
516
  html: s
@@ -526,12 +536,12 @@ class ae {
526
536
  return this.cacheResponse(s, r);
527
537
  }
528
538
  async getAll(e, t, s) {
529
- const r = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, o = i.split("/"), c = s || o[o.length - 1], a = 1, l = await this.makeRequest(i, t, r, a), u = l.total ? Math.ceil(l.total / r) : 1, d = await this.helpers.asyncMap(
539
+ const r = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, n = i.split("/"), c = s || n[n.length - 1], a = 1, l = await this.makeRequest(i, t, r, a), u = l.total ? Math.ceil(l.total / r) : 1, p = await this.helpers.asyncMap(
530
540
  this.helpers.range(a, u),
531
541
  (g) => this.makeRequest(i, t, r, g + 1)
532
542
  );
533
543
  return this.helpers.flatMap(
534
- [l, ...d],
544
+ [l, ...p],
535
545
  (g) => Object.values(g.data[c])
536
546
  );
537
547
  }
@@ -574,8 +584,8 @@ class ae {
574
584
  ));
575
585
  else if (e[t] && e[t].constructor === Array) {
576
586
  const i = [];
577
- e[t].forEach((o) => {
578
- this.relations[r][o] && i.push(this._cleanCopy(this.relations[r][o]));
587
+ e[t].forEach((n) => {
588
+ this.relations[r][n] && i.push(this._cleanCopy(this.relations[r][n]));
579
589
  }), e[t] = i;
580
590
  }
581
591
  }
@@ -584,22 +594,22 @@ class ae {
584
594
  const r = (i) => {
585
595
  if (i != null) {
586
596
  if (i.constructor === Array)
587
- for (let o = 0; o < i.length; o++)
588
- r(i[o]);
597
+ for (let n = 0; n < i.length; n++)
598
+ r(i[n]);
589
599
  else if (i.constructor === Object) {
590
600
  if (i._stopResolving)
591
601
  return;
592
- for (const o in i)
602
+ for (const n in i)
593
603
  (i.component && i._uid || i.type === "link") && (this._insertRelations(
594
604
  i,
595
- o,
605
+ n,
596
606
  t,
597
607
  s
598
608
  ), this._insertLinks(
599
609
  i,
600
- o,
610
+ n,
601
611
  s
602
- )), r(i[o]);
612
+ )), r(i[n]);
603
613
  }
604
614
  }
605
615
  };
@@ -608,17 +618,17 @@ class ae {
608
618
  async resolveLinks(e, t, s) {
609
619
  let r = [];
610
620
  if (e.link_uuids) {
611
- const i = e.link_uuids.length, o = [], c = 50;
621
+ const i = e.link_uuids.length, n = [], c = 50;
612
622
  for (let a = 0; a < i; a += c) {
613
623
  const l = Math.min(i, a + c);
614
- o.push(e.link_uuids.slice(a, l));
624
+ n.push(e.link_uuids.slice(a, l));
615
625
  }
616
- for (let a = 0; a < o.length; a++)
626
+ for (let a = 0; a < n.length; a++)
617
627
  (await this.getStories({
618
628
  per_page: c,
619
629
  language: t.language,
620
630
  version: t.version,
621
- by_uuids: o[a].join(",")
631
+ by_uuids: n[a].join(",")
622
632
  })).data.stories.forEach(
623
633
  (l) => {
624
634
  r.push(l);
@@ -636,17 +646,17 @@ class ae {
636
646
  async resolveRelations(e, t, s) {
637
647
  let r = [];
638
648
  if (e.rel_uuids) {
639
- const i = e.rel_uuids.length, o = [], c = 50;
649
+ const i = e.rel_uuids.length, n = [], c = 50;
640
650
  for (let a = 0; a < i; a += c) {
641
651
  const l = Math.min(i, a + c);
642
- o.push(e.rel_uuids.slice(a, l));
652
+ n.push(e.rel_uuids.slice(a, l));
643
653
  }
644
- for (let a = 0; a < o.length; a++)
654
+ for (let a = 0; a < n.length; a++)
645
655
  (await this.getStories({
646
656
  per_page: c,
647
657
  language: t.language,
648
658
  version: t.version,
649
- by_uuids: o[a].join(",")
659
+ by_uuids: n[a].join(",")
650
660
  })).data.stories.forEach((l) => {
651
661
  r.push(l);
652
662
  });
@@ -661,26 +671,26 @@ class ae {
661
671
  }
662
672
  async resolveStories(e, t, s) {
663
673
  var r, i;
664
- let o = [];
665
- if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (o = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (i = e.link_uuids) != null && i.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
674
+ let n = [];
675
+ if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (i = e.link_uuids) != null && i.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
666
676
  for (const c in this.relations[s])
667
677
  this.iterateTree(
668
678
  this.relations[s][c],
669
- o,
679
+ n,
670
680
  s
671
681
  );
672
- e.story ? this.iterateTree(e.story, o, s) : e.stories.forEach((c) => {
673
- this.iterateTree(c, o, s);
682
+ e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((c) => {
683
+ this.iterateTree(c, n, s);
674
684
  }), delete this.links[s], delete this.relations[s];
675
685
  }
676
686
  async cacheResponse(e, t, s) {
677
687
  const r = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
678
688
  if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
679
- const o = await i.get(r);
680
- if (o)
681
- return Promise.resolve(o);
689
+ const n = await i.get(r);
690
+ if (n)
691
+ return Promise.resolve(n);
682
692
  }
683
- return new Promise((o, c) => {
693
+ return new Promise((n, c) => {
684
694
  try {
685
695
  (async () => {
686
696
  var a;
@@ -693,10 +703,10 @@ class ae {
693
703
  })), l.status != 200)
694
704
  return c(l);
695
705
  if (u.data.story || u.data.stories) {
696
- const d = this.resolveCounter = ++this.resolveCounter % 1e3;
697
- await this.resolveStories(u.data, t, `${d}`);
706
+ const p = this.resolveCounter = ++this.resolveCounter % 1e3;
707
+ await this.resolveStories(u.data, t, `${p}`);
698
708
  }
699
- return t.version === "published" && e != "/cdn/spaces/me" && await i.set(r, u), u.data.cv && t.token && (t.version == "draft" && f[t.token] != u.data.cv && await this.flushCache(), f[t.token] = u.data.cv), o(u);
709
+ return t.version === "published" && e != "/cdn/spaces/me" && await i.set(r, u), u.data.cv && t.token && (t.version == "draft" && f[t.token] != u.data.cv && await this.flushCache(), f[t.token] = u.data.cv), n(u);
700
710
  } catch (l) {
701
711
  return c(l);
702
712
  }
@@ -758,8 +768,8 @@ class ae {
758
768
  return await this.cacheProvider().flush(), this;
759
769
  }
760
770
  }
761
- const le = (n = {}) => {
762
- const { apiOptions: e } = n;
771
+ const ce = (o = {}) => {
772
+ const { apiOptions: e } = o;
763
773
  if (!e.accessToken) {
764
774
  console.error(
765
775
  "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
@@ -767,11 +777,11 @@ const le = (n = {}) => {
767
777
  return;
768
778
  }
769
779
  return { storyblokApi: new ae(e) };
770
- }, ce = (n) => {
771
- if (typeof n != "object" || typeof n._editable > "u")
780
+ }, he = (o) => {
781
+ if (typeof o != "object" || typeof o._editable > "u")
772
782
  return {};
773
783
  const e = JSON.parse(
774
- n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
784
+ o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
775
785
  );
776
786
  return {
777
787
  "data-blok-c": JSON.stringify(e),
@@ -779,41 +789,41 @@ const le = (n = {}) => {
779
789
  };
780
790
  };
781
791
  let w;
782
- const x = "https://app.storyblok.com/f/storyblok-v2-latest.js", he = (n, e, t = {}) => {
792
+ const x = "https://app.storyblok.com/f/storyblok-v2-latest.js", ue = (o, e, t = {}) => {
783
793
  var c;
784
- const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = +new URL((c = window.location) == null ? void 0 : c.href).searchParams.get(
794
+ const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((c = window.location) == null ? void 0 : c.href).searchParams.get(
785
795
  "_storyblok"
786
- ) === n;
787
- if (!(!r || !o)) {
788
- if (!n) {
796
+ ) === o;
797
+ if (!(!r || !n)) {
798
+ if (!o) {
789
799
  console.warn("Story ID is not defined. Please provide a valid ID.");
790
800
  return;
791
801
  }
792
802
  window.storyblokRegisterEvent(() => {
793
803
  new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
794
- l.action === "input" && l.story.id === n ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === n && window.location.reload();
804
+ l.action === "input" && l.story.id === o ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === o && window.location.reload();
795
805
  });
796
806
  });
797
807
  }
798
- }, ue = (n = {}) => {
799
- var u, d;
808
+ }, pe = (o = {}) => {
809
+ var u, p;
800
810
  const {
801
811
  bridge: e,
802
812
  accessToken: t,
803
813
  use: s = [],
804
814
  apiOptions: r = {},
805
815
  richText: i = {}
806
- } = n;
816
+ } = o;
807
817
  r.accessToken = r.accessToken || t;
808
- const o = { bridge: e, apiOptions: r };
818
+ const n = { bridge: e, apiOptions: r };
809
819
  let c = {};
810
820
  s.forEach((g) => {
811
- c = { ...c, ...g(o) };
821
+ c = { ...c, ...g(n) };
812
822
  });
813
- const l = !(typeof window > "u") && ((d = (u = window.location) == null ? void 0 : u.search) == null ? void 0 : d.includes("_storyblok_tk"));
823
+ const l = !(typeof window > "u") && ((p = (u = window.location) == null ? void 0 : u.search) == null ? void 0 : p.includes("_storyblok_tk"));
814
824
  return e !== false && l && j(x), w = new y(i.schema), i.resolver && E(w, i.resolver), c;
815
- }, E = (n, e) => {
816
- n.addNode("blok", (t) => {
825
+ }, E = (o, e) => {
826
+ o.addNode("blok", (t) => {
817
827
  let s = "";
818
828
  return t.attrs.body.forEach((r) => {
819
829
  s += e(r.component, r);
@@ -821,7 +831,10 @@ const x = "https://app.storyblok.com/f/storyblok-v2-latest.js", he = (n, e, t =
821
831
  html: s
822
832
  };
823
833
  });
824
- }, de = (n, e, t) => {
834
+ }, le = (o) => {
835
+ var e, t;
836
+ return !o || ((e = o == null ? void 0 : o.content) == null ? void 0 : e[0].type) !== "blok" && !((t = o == null ? void 0 : o.content) != null && t[0].content);
837
+ }, de = (o, e, t) => {
825
838
  let s = t || w;
826
839
  if (!s) {
827
840
  console.error(
@@ -829,16 +842,14 @@ const x = "https://app.storyblok.com/f/storyblok-v2-latest.js", he = (n, e, t =
829
842
  );
830
843
  return;
831
844
  }
832
- return n === "" ? "" : n ? (e && (s = new y(e.schema), e.resolver && E(s, e.resolver)), s.render(n)) : (console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
833
-
834
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
835
- }, pe = () => j(x);
845
+ return le(o) ? "" : (e && (s = new y(e.schema), e.resolver && E(s, e.resolver)), s.render(o));
846
+ }, ge = () => j(x);
836
847
  export {
837
848
  ce as c,
838
849
  de as d,
850
+ ge as g,
839
851
  he as h,
840
852
  ie as i,
841
- le as l,
842
853
  pe as p,
843
854
  ue as u,
844
855
  y
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),o=require("./storyblok-js-a8758ae9.js"),t=require("./index-65ac33dd.js"),r=require("./client-6eb29fd9.js");exports.RichTextResolver=o.y,exports.RichTextSchema=o.ie,exports.apiPlugin=o.le,exports.loadStoryblokBridge=o.pe,exports.registerStoryblokBridge=o.he,exports.renderRichText=o.de,exports.storyblokEditable=o.ce,exports.useStoryblokBridge=o.he,exports.StoryblokComponent=t.StoryblokComponent,exports.getComponent=t.getComponent,exports.getStoryblokApi=t.useStoryblokApi,exports.storyblokInit=t.storyblokInit,exports.useStoryblokApi=t.useStoryblokApi,exports.useStoryblokState=r.useStoryblokState,exports.useStoryblok=(r,s={},i={})=>{const n=t.useStoryblokApi();if(!n)return console.error("You can't use useStoryblok if you're not loading apiPlugin."),null;let[l,p]=e.useState({});const y="undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent;return e.useEffect((()=>{!async function(){const{data:e}=await n.get(`cdn/stories/${r}`,s);p(e.story),y&&e.story.id&&o.he(e.story.id,(e=>p(e)),i)}()}),[r,JSON.stringify(s)]),l};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),o=require("./storyblok-js-1cafaa66.js"),t=require("./index-c2e3dd49.js"),r=require("./client-85627252.js");exports.RichTextResolver=o.y,exports.RichTextSchema=o.ie,exports.apiPlugin=o.ce,exports.loadStoryblokBridge=o.ge,exports.registerStoryblokBridge=o.ue,exports.renderRichText=o.de,exports.storyblokEditable=o.he,exports.useStoryblokBridge=o.ue,exports.StoryblokComponent=t.StoryblokComponent,exports.getComponent=t.getComponent,exports.getStoryblokApi=t.useStoryblokApi,exports.storyblokInit=t.storyblokInit,exports.useStoryblokApi=t.useStoryblokApi,exports.useStoryblokState=r.useStoryblokState,exports.useStoryblok=(r,s={},i={})=>{const n=t.useStoryblokApi();if(!n)return console.error("You can't use useStoryblok if you're not loading apiPlugin."),null;let[l,u]=e.useState({});const p="undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent;return e.useEffect((()=>{(async()=>{const{data:e}=await n.get(`cdn/stories/${r}`,s);u(e.story)})()}),[r,s]),e.useEffect((()=>{p&&l.id&&o.ue(l.id,(e=>u(e)),i)}),[l]),l};
@@ -1,9 +1,9 @@
1
1
  import { useState, useEffect } from "react";
2
- import { h as he } from "./storyblok-js-612aedc3.mjs";
3
- import { y, i, l, p, d, c } from "./storyblok-js-612aedc3.mjs";
4
- import { u as useStoryblokApi } from "./index-f1318b50.mjs";
5
- import { S, g, s } from "./index-f1318b50.mjs";
6
- import { u } from "./client-16ee9ae1.mjs";
2
+ import { u as ue } from "./storyblok-js-834d6ca5.mjs";
3
+ import { y, i, c, g, d, h } from "./storyblok-js-834d6ca5.mjs";
4
+ import { u as useStoryblokApi } from "./index-a23f03ba.mjs";
5
+ import { S, g as g2, s } from "./index-a23f03ba.mjs";
6
+ import { u } from "./client-7b1fd9f5.mjs";
7
7
  const useStoryblok = (slug, apiOptions = {}, bridgeOptions = {}) => {
8
8
  const storyblokApiInstance = useStoryblokApi();
9
9
  if (!storyblokApiInstance) {
@@ -14,39 +14,41 @@ const useStoryblok = (slug, apiOptions = {}, bridgeOptions = {}) => {
14
14
  }
15
15
  let [story, setStory] = useState({});
16
16
  const isBridgeEnable = typeof window !== "undefined" && typeof window.storyblokRegisterEvent !== "undefined";
17
+ const initStory = async () => {
18
+ const { data } = await storyblokApiInstance.get(
19
+ `cdn/stories/${slug}`,
20
+ apiOptions
21
+ );
22
+ setStory(data.story);
23
+ };
24
+ useEffect(() => {
25
+ initStory();
26
+ }, [slug, apiOptions]);
17
27
  useEffect(() => {
18
- async function initStory() {
19
- const { data } = await storyblokApiInstance.get(
20
- `cdn/stories/${slug}`,
21
- apiOptions
28
+ if (isBridgeEnable && story.id) {
29
+ ue(
30
+ story.id,
31
+ (story2) => setStory(story2),
32
+ bridgeOptions
22
33
  );
23
- setStory(data.story);
24
- if (isBridgeEnable && data.story.id) {
25
- he(
26
- data.story.id,
27
- (story2) => setStory(story2),
28
- bridgeOptions
29
- );
30
- }
31
34
  }
32
- initStory();
33
- }, [slug, JSON.stringify(apiOptions)]);
35
+ }, [story]);
34
36
  return story;
35
37
  };
36
38
  export {
37
39
  y as RichTextResolver,
38
40
  i as RichTextSchema,
39
41
  S as StoryblokComponent,
40
- l as apiPlugin,
41
- g as getComponent,
42
+ c as apiPlugin,
43
+ g2 as getComponent,
42
44
  useStoryblokApi as getStoryblokApi,
43
- p as loadStoryblokBridge,
44
- he as registerStoryblokBridge,
45
+ g as loadStoryblokBridge,
46
+ ue as registerStoryblokBridge,
45
47
  d as renderRichText,
46
- c as storyblokEditable,
48
+ h as storyblokEditable,
47
49
  s as storyblokInit,
48
50
  useStoryblok,
49
51
  useStoryblokApi,
50
- he as useStoryblokBridge,
52
+ ue as useStoryblokBridge,
51
53
  u as useStoryblokState
52
54
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-65ac33dd.js"),o=require("./storyblok-js-a8758ae9.js");require("react"),exports.StoryblokComponent=e.StoryblokComponent,exports.getComponent=e.getComponent,exports.getStoryblokApi=e.useStoryblokApi,exports.storyblokInit=e.storyblokInit,exports.useStoryblokApi=e.useStoryblokApi,exports.RichTextResolver=o.y,exports.RichTextSchema=o.ie,exports.apiPlugin=o.le,exports.loadStoryblokBridge=o.pe,exports.registerStoryblokBridge=o.he,exports.renderRichText=o.de,exports.storyblokEditable=o.ce,exports.useStoryblokBridge=o.he;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-c2e3dd49.js"),o=require("./storyblok-js-1cafaa66.js");require("react"),exports.StoryblokComponent=e.StoryblokComponent,exports.getComponent=e.getComponent,exports.getStoryblokApi=e.useStoryblokApi,exports.storyblokInit=e.storyblokInit,exports.useStoryblokApi=e.useStoryblokApi,exports.RichTextResolver=o.y,exports.RichTextSchema=o.ie,exports.apiPlugin=o.ce,exports.loadStoryblokBridge=o.ge,exports.registerStoryblokBridge=o.ue,exports.renderRichText=o.de,exports.storyblokEditable=o.he,exports.useStoryblokBridge=o.ue;
@@ -1,18 +1,18 @@
1
- import { S, g, u, s, u as u2 } from "./index-f1318b50.mjs";
2
- import { y, i, l, p, h, d, c, h as h2 } from "./storyblok-js-612aedc3.mjs";
1
+ import { S, g, u, s, u as u2 } from "./index-a23f03ba.mjs";
2
+ import { y, i, c, g as g2, u as u3, d, h, u as u4 } from "./storyblok-js-834d6ca5.mjs";
3
3
  import "react";
4
4
  export {
5
5
  y as RichTextResolver,
6
6
  i as RichTextSchema,
7
7
  S as StoryblokComponent,
8
- l as apiPlugin,
8
+ c as apiPlugin,
9
9
  g as getComponent,
10
10
  u as getStoryblokApi,
11
- p as loadStoryblokBridge,
12
- h as registerStoryblokBridge,
11
+ g2 as loadStoryblokBridge,
12
+ u3 as registerStoryblokBridge,
13
13
  d as renderRichText,
14
- c as storyblokEditable,
14
+ h as storyblokEditable,
15
15
  s as storyblokInit,
16
16
  u2 as useStoryblokApi,
17
- h2 as useStoryblokBridge
17
+ u4 as useStoryblokBridge
18
18
  };
@@ -1 +1 @@
1
- "use strict";"use client";const e=require("react"),o=require("./storyblok-js-a8758ae9.js");module.exports=({options:t})=>((async e=>{await o.pe(),new window.StoryblokBridge(e).on(["published","change"],(()=>{window.location.reload()}))})(t),e.createElement(e.Fragment,null));
1
+ "use strict";"use client";const e=require("react"),o=require("./storyblok-js-1cafaa66.js");module.exports=({options:t})=>((async e=>{await o.ge(),new window.StoryblokBridge(e).on(["published","change"],(()=>{window.location.reload()}))})(t),e.createElement(e.Fragment,null));
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import React from "react";
3
- import { p as pe } from "./storyblok-js-612aedc3.mjs";
3
+ import { g as ge } from "./storyblok-js-834d6ca5.mjs";
4
4
  const setBridge = async (options) => {
5
- await pe();
5
+ await ge();
6
6
  const sbBridge = new window.StoryblokBridge(options);
7
7
  sbBridge.on(["published", "change"], () => {
8
8
  window.location.reload();
@@ -1 +1 @@
1
- "use strict";"use client";const e=require("react"),t=require("./client-6eb29fd9.js"),r=require("./index-65ac33dd.js");require("./storyblok-js-a8758ae9.js");module.exports=({story:o})=>(o=t.useStoryblokState(o),e.createElement(r.StoryblokComponent,{blok:o.content}));
1
+ "use strict";"use client";const e=require("react"),t=require("./client-85627252.js"),r=require("./index-c2e3dd49.js");require("./storyblok-js-1cafaa66.js");module.exports=({story:o})=>(o=t.useStoryblokState(o),e.createElement(r.StoryblokComponent,{blok:o.content}));
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import React from "react";
3
- import { u as useStoryblokState } from "./client-16ee9ae1.mjs";
4
- import { S as StoryblokComponent } from "./index-f1318b50.mjs";
5
- import "./storyblok-js-612aedc3.mjs";
3
+ import { u as useStoryblokState } from "./client-7b1fd9f5.mjs";
4
+ import { S as StoryblokComponent } from "./index-a23f03ba.mjs";
5
+ import "./storyblok-js-834d6ca5.mjs";
6
6
  const StoryblokStory = ({ story }) => {
7
7
  story = useStoryblokState(story);
8
8
  return /* @__PURE__ */ React.createElement(StoryblokComponent, { blok: story.content });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/react",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "SDK to integrate Storyblok into your project using React.",
5
5
  "main": "./dist/storyblok-react.js",
6
6
  "module": "./dist/storyblok-react.mjs",
@@ -44,15 +44,15 @@
44
44
  "prepublishOnly": "npm run build && cp ../README.md ./"
45
45
  },
46
46
  "dependencies": {
47
- "@storyblok/js": "^2.1.4"
47
+ "@storyblok/js": "^2.2.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@babel/core": "^7.21.8",
51
- "@babel/preset-env": "^7.21.5",
50
+ "@babel/core": "^7.22.5",
51
+ "@babel/preset-env": "^7.22.5",
52
52
  "@cypress/react": "^5.12.5",
53
53
  "@cypress/vite-dev-server": "^2.2.3",
54
54
  "@tsconfig/recommended": "^1.0.2",
55
- "@types/react": "18.2.7",
55
+ "@types/react": "18.2.12",
56
56
  "@vitejs/plugin-react": "^4.0.0",
57
57
  "babel-jest": "^29.5.0",
58
58
  "cypress": "^9.7.0",
@@ -62,7 +62,7 @@
62
62
  "react": "^18.2.0",
63
63
  "react-dom": "^18.2.0",
64
64
  "start-server-and-test": "^2.0.0",
65
- "terser": "^5.17.6",
65
+ "terser": "^5.18.0",
66
66
  "vite": "^4.1.4"
67
67
  },
68
68
  "peerDependencies": {
@@ -1 +0,0 @@
1
- "use strict";const e=require("react"),t=require("./storyblok-js-a8758ae9.js");exports.useStoryblokState=(r=null,o={})=>{let[s,i]=e.useState(r);return"undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent&&r?(e.useEffect((()=>{i(r),t.he(s.id,(e=>i(e)),o)}),[r]),s):r};
@@ -1 +0,0 @@
1
- "use strict";let t=!1;const e=[],s=s=>new Promise(((r,i)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{window.location!==window.parent.location?t?s():e.push(s):console.warn("You are not in Draft Mode or in the Visual Editor.")},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=s,o.id="storyblok-javascript-bridge",o.onerror=t=>i(t),o.onload=s=>{e.forEach((t=>t())),t=!0,r(s)},document.getElementsByTagName("head")[0].appendChild(o)}));var r=Object.defineProperty,i=(t,e,s)=>(((t,e,s)=>{e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(t,"symbol"!=typeof e?e+"":e,s),s);function o(t){return!(t!=t||t===1/0||t===-1/0)}const n=function(t,e){const s={};for(const r in t){const i=t[r];e.indexOf(r)>-1&&null!==i&&(s[r]=i)}return s},a={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:t=>({tag:`h${t.attrs.level}`}),image:t=>({singleTag:[{tag:"img",attrs:n(t.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"}),emoji:t=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":t.attrs.name,emoji:t.attrs.emoji}}]})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link:t=>{const e={...t.attrs},{linktype:s="url"}=t.attrs;if((t=>"email"===t)(s)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const t in e.custom)e[t]=e.custom[t];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},styled:t=>({tag:[{tag:"span",attrs:t.attrs}]}),subscript:()=>({tag:"sub"}),superscript:()=>({tag:"sup"}),anchor:t=>({tag:[{tag:"span",attrs:t.attrs}]}),highlight:t=>({tag:[{tag:"span",attrs:{style:`background-color:${t.attrs.color};`}}]}),textStyle:t=>({tag:[{tag:"span",attrs:{style:`color:${t.attrs.color}`}}]})}};class l{constructor(t){i(this,"marks"),i(this,"nodes"),t||(t=a),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}){if(t&&t.content&&Array.isArray(t.content)){let s="";return t.content.forEach((t=>{s+=this.renderNode(t)})),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn("The render method must receive an Object with a \"content\" field.\n\t\t\tThe \"content\" field must be an array of nodes as the type ISbRichtext.\n\t\t\tISbRichtext:\n\t\t\t\tcontent?: ISbRichtext[]\n\t\t\t\tmarks?: ISbRichtext[]\n\t\t\t\tattrs?: any\n\t\t\t\ttext?: string\n\t\t\t\ttype: string\n\t\t\t\t\n\t\t\t\tExample:\n\t\t\t\t{\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttext: 'Hello World',\n\t\t\t\t\t\t\t\t\ttype: 'text'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\ttype: 'paragraph'\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\ttype: 'doc'\n\t\t\t\t}"),""}optimizeImages(t,e){let s=0,r=0,i="",o="";"boolean"!=typeof e&&("number"==typeof e.width&&e.width>0&&(i+=`width="${e.width}" `,s=e.width),"number"==typeof e.height&&e.height>0&&(i+=`height="${e.height}" `,r=e.height),("lazy"===e.loading||"eager"===e.loading)&&(i+=`loading="${e.loading}" `),"string"==typeof e.class&&e.class.length>0&&(i+=`class="${e.class}" `),e.filters&&("number"==typeof e.filters.blur&&e.filters.blur>=0&&e.filters.blur<=100&&(o+=`:blur(${e.filters.blur})`),"number"==typeof e.filters.brightness&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(o+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||"transparent"===e.filters.fill)&&(o+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(o+=`:format(${e.filters.format})`),"boolean"==typeof e.filters.grayscale&&e.filters.grayscale&&(o+=":grayscale()"),"number"==typeof e.filters.quality&&e.filters.quality>=0&&e.filters.quality<=100&&(o+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(o+=`:rotate(${e.filters.rotate})`),o.length>0&&(o="/filters"+o))),i.length>0&&(t=t.replace(/<img/g,`<img ${i.trim()}`));const n=s>0||r>0||o.length>0?`${s}x${r}${o}`:"";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/${n}`),"boolean"!=typeof e&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,(t=>{var s,r;const i=t.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(i&&i.length>0){const n={srcset:null==(s=e.srcset)?void 0:s.map((t=>{if("number"==typeof t)return`//${i}/m/${t}x0${o} ${t}w`;if("object"==typeof t&&2===t.length){let e=0,s=0;return"number"==typeof t[0]&&(e=t[0]),"number"==typeof t[1]&&(s=t[1]),`//${i}/m/${e}x${s}${o} ${e}w`}})).join(", "),sizes:null==(r=e.sizes)?void 0:r.map((t=>t)).join(", ")};let a="";return n.srcset&&(a+=`srcset="${n.srcset}" `),n.sizes&&(a+=`sizes="${n.sizes}" `),t.replace(/<img/g,`<img ${a.trim()}`)}return t}))),t}renderNode(t){const e=[];t.marks&&t.marks.forEach((t=>{const s=this.getMatchingMark(t);s&&e.push(this.renderOpeningTag(s.tag))}));const s=this.getMatchingNode(t);return s&&s.tag&&e.push(this.renderOpeningTag(s.tag)),t.content?t.content.forEach((t=>{e.push(this.renderNode(t))})):t.text?e.push(function(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=RegExp(s.source);return t&&r.test(t)?t.replace(s,(t=>e[t])):t}(t.text)):s&&s.singleTag?e.push(this.renderTag(s.singleTag," /")):s&&s.html?e.push(s.html):"emoji"===t.type&&e.push(this.renderEmoji(t)),s&&s.tag&&e.push(this.renderClosingTag(s.tag)),t.marks&&t.marks.slice(0).reverse().forEach((t=>{const s=this.getMatchingMark(t);s&&e.push(this.renderClosingTag(s.tag))})),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map((t=>{if(t.constructor===String)return`<${t}${e}>`;{let s=`<${t.tag}`;if(t.attrs)for(const e in t.attrs){const r=t.attrs[e];null!==r&&(s+=` ${e}="${r}"`)}return`${s}${e}>`}})).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map((t=>t.constructor===String?`</${t}>`:`</${t.tag}>`)).join("")}getMatchingNode(t){const e=this.nodes[t.type];if("function"==typeof e)return e(t)}getMatchingMark(t){const e=this.marks[t.type];if("function"==typeof e)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," /")}}class c{constructor(){i(this,"isCDNUrl",((t="")=>t.indexOf("/cdn/")>-1)),i(this,"getOptionsPage",((t,e=25,s=1)=>({...t,per_page:e,page:s}))),i(this,"delay",(t=>new Promise((e=>setTimeout(e,t))))),i(this,"arrayFrom",((t=0,e)=>[...Array(t)].map(e))),i(this,"range",((t=0,e=t)=>{const s=Math.abs(e-t)||0,r=t<e?1:-1;return this.arrayFrom(s,((e,s)=>s*r+t))})),i(this,"asyncMap",(async(t,e)=>Promise.all(t.map(e)))),i(this,"flatMap",((t=[],e)=>t.map(e).reduce(((t,e)=>[...t,...e]),[])))}stringify(t,e,s){const r=[];for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const o=t[i],n=s?"":encodeURIComponent(i);let a;a="object"==typeof o?this.stringify(o,e?e+encodeURIComponent("["+n+"]"):n,Array.isArray(o)):(e?e+encodeURIComponent("["+n+"]"):n)+"="+encodeURIComponent(o),r.push(a)}return r.join("&")}getRegionURL(t){switch(t){case"us":return"api-us.storyblok.com";case"cn":return"app.storyblokchina.cn";default:return"api.storyblok.com"}}}class h{constructor(t){i(this,"baseURL"),i(this,"timeout"),i(this,"headers"),i(this,"responseInterceptor"),i(this,"fetch"),i(this,"ejectInterceptor"),i(this,"url"),i(this,"parameters"),this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=null!=t&&t.timeout?1e3*t.timeout:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}delete(t,e){return this.url=t,this.parameters=e,this._methodHandler("delete")}async _responseHandler(t){const e=[],s={data:{},headers:{},status:0,statusText:""};204!==t.status&&await t.json().then((t=>{s.data=t}));for(const r of t.headers.entries())e[r[0]]=r[1];return s.headers={...e},s.status=t.status,s.statusText=t.statusText,s}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,s=null;if("get"===t){const t=new c;e=`${this.baseURL}${this.url}?${t.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(e),i=new AbortController,{signal:o}=i;let n;this.timeout&&(n=setTimeout((()=>i.abort()),this.timeout));try{const e=await this.fetch(`${r}`,{method:t,headers:this.headers,body:s,signal:o});this.timeout&&clearTimeout(n);const i=await this._responseHandler(e);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(i)):this._statusHandler(i)}catch(a){return{message:a}}}eject(){this.ejectInterceptor=!0}_statusHandler(t){const e=/20[0-6]/g;return new Promise(((s,r)=>{if(e.test(`${t.status}`))return s(t);r({message:new Error(t.statusText),status:t.status,response:Array.isArray(t.data)?t.data[0]:t.data.error||t.data.slug})}))}}let u={};const p={};class d{constructor(t,e){if(i(this,"client"),i(this,"maxRetries"),i(this,"throttle"),i(this,"accessToken"),i(this,"cache"),i(this,"helpers"),i(this,"resolveCounter"),i(this,"relations"),i(this,"links"),i(this,"richTextResolver"),i(this,"resolveNestedRelations"),!e){const s=(new c).getRegionURL,r=!1===t.https?"http":"https";e=t.oauthToken?`${r}://${s(t.region)}/v1`:`${r}://${s(t.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),s.forEach(((e,r)=>{t.headers&&t.headers[r]&&s.set(r,t.headers[r])}));let r=5;t.oauthToken&&(s.set("Authorization",t.oauthToken),r=3),t.rateLimit&&(r=t.rateLimit),t.richTextSchema?this.richTextResolver=new l(t.richTextSchema):this.richTextResolver=new l,t.componentResolver&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=function(t,e,s){if(!o(e))throw new TypeError("Expected `limit` to be a finite number");if(!o(s))throw new TypeError("Expected `interval` to be a finite number");const r=[];let i=[],n=0;const a=function(){n++;const e=setTimeout((function(){n--,r.length>0&&a(),i=i.filter((function(t){return t!==e}))}),s);i.indexOf(e)<0&&i.push(e);const o=r.shift();o.resolve(t.apply(o.self,o.args))},l=function(...t){const s=this;return new Promise((function(i,o){r.push({resolve:i,reject:o,args:t,self:s}),n<e&&a()}))};return l.abort=function(){i.forEach(clearTimeout),i=[],r.forEach((function(t){t.reject((function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"}))})),r.length=0},l}(this.throttledRequest,r,1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.helpers=new c,this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.client=new h({baseURL:e,timeout:t.timeout||0,headers:s,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}setComponentResolver(t){this.richTextResolver.addNode("blok",(e=>{let s="";return e.attrs.body.forEach((e=>{s+=t(e.component,e)})),{html:s}}))}parseParams(t){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=p[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e){return this.helpers.isCDNUrl(t)?this.parseParams(e):e}makeRequest(t,e,s,r){const i=this.factoryParamOptions(t,this.helpers.getOptionsPage(e,s,r));return this.cacheResponse(t,i)}get(t,e){e||(e={});const s=`/${t}`,r=this.factoryParamOptions(s,e);return this.cacheResponse(s,r)}async getAll(t,e,s){const r=(null==e?void 0:e.per_page)||25,i=`/${t}`,o=i.split("/"),n=s||o[o.length-1],a=await this.makeRequest(i,e,r,1),l=a.total?Math.ceil(a.total/r):1,c=await this.helpers.asyncMap(this.helpers.range(1,l),(t=>this.makeRequest(i,e,r,t+1)));return this.helpers.flatMap([a,...c],(t=>Object.values(t.data[n])))}post(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("post",s,e))}put(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("put",s,e))}delete(t,e){const s=`/${t}`;return Promise.resolve(this.throttle("delete",s,e))}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,s){const r=t[e];r&&"multilink"==r.fieldtype&&"story"==r.linktype&&"string"==typeof r.id&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&"story"===r.linktype&&"string"==typeof r.uuid&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}_insertRelations(t,e,s,r){if(s.indexOf(`${t.component}.${e}`)>-1)if("string"==typeof t[e])this.relations[r][t[e]]&&(t[e]=this._cleanCopy(this.relations[r][t[e]]));else if(t[e]&&t[e].constructor===Array){const s=[];t[e].forEach((t=>{this.relations[r][t]&&s.push(this._cleanCopy(this.relations[r][t]))})),t[e]=s}}iterateTree(t,e,s){const r=t=>{if(null!=t)if(t.constructor===Array)for(let e=0;e<t.length;e++)r(t[e]);else if(t.constructor===Object){if(t._stopResolving)return;for(const i in t)(t.component&&t._uid||"link"===t.type)&&(this._insertRelations(t,i,e,s),this._insertLinks(t,i,s)),r(t[i])}};r(t.content)}async resolveLinks(t,e,s){let r=[];if(t.link_uuids){const s=t.link_uuids.length,i=[],o=50;for(let e=0;e<s;e+=o){const r=Math.min(s,e+o);i.push(t.link_uuids.slice(e,r))}for(let t=0;t<i.length;t++)(await this.getStories({per_page:o,language:e.language,version:e.version,by_uuids:i[t].join(",")})).data.stories.forEach((t=>{r.push(t)}))}else r=t.links;r.forEach((t=>{this.links[s][t.uuid]={...t,_stopResolving:!0}}))}async resolveRelations(t,e,s){let r=[];if(t.rel_uuids){const s=t.rel_uuids.length,i=[],o=50;for(let e=0;e<s;e+=o){const r=Math.min(s,e+o);i.push(t.rel_uuids.slice(e,r))}for(let t=0;t<i.length;t++)(await this.getStories({per_page:o,language:e.language,version:e.version,by_uuids:i[t].join(",")})).data.stories.forEach((t=>{r.push(t)}))}else r=t.rels;r&&r.length>0&&r.forEach((t=>{this.relations[s][t.uuid]={...t,_stopResolving:!0}}))}async resolveStories(t,e,s){var r,i;let o=[];if(this.links[s]={},this.relations[s]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&("string"==typeof e.resolve_relations&&(o=e.resolve_relations.split(",")),await this.resolveRelations(t,e,s)),e.resolve_links&&["1","story","url"].indexOf(e.resolve_links)>-1&&(null!=(r=t.links)&&r.length||null!=(i=t.link_uuids)&&i.length)&&await this.resolveLinks(t,e,s),this.resolveNestedRelations)for(const n in this.relations[s])this.iterateTree(this.relations[s][n],o,s);t.story?this.iterateTree(t.story,o,s):t.stories.forEach((t=>{this.iterateTree(t,o,s)})),delete this.links[s],delete this.relations[s]}async cacheResponse(t,e,s){const r=this.helpers.stringify({url:t,params:e}),i=this.cacheProvider();if("auto"===this.cache.clear&&"draft"===e.version&&await this.flushCache(),"published"===e.version&&"/cdn/spaces/me"!=t){const t=await i.get(r);if(t)return Promise.resolve(t)}return new Promise(((s,o)=>{try{(async()=>{var n;try{const a=await this.throttle("get",t,e);let l={data:a.data,headers:a.headers};if(null!=(n=a.headers)&&n["per-page"]&&(l=Object.assign({},l,{perPage:a.headers["per-page"]?parseInt(a.headers["per-page"]):0,total:a.headers["per-page"]?parseInt(a.headers.total):0})),200!=a.status)return o(a);if(l.data.story||l.data.stories){const t=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(l.data,e,`${t}`)}return"published"===e.version&&"/cdn/spaces/me"!=t&&await i.set(r,l),l.data.cv&&e.token&&("draft"==e.version&&p[e.token]!=l.data.cv&&await this.flushCache(),p[e.token]=l.data.cv),s(l)}catch(a){return o(a)}})()}catch{}}))}throttledRequest(t,e,s){return this.client[t](e,s)}cacheVersions(){return p}cacheVersion(){return p[this.accessToken]}setCacheVersion(t){this.accessToken&&(p[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get:t=>Promise.resolve(u[t]),getAll:()=>Promise.resolve(u),set:(t,e)=>(u[t]=e,Promise.resolve(void 0)),flush:()=>(u={},Promise.resolve(void 0))};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get:()=>Promise.resolve(void 0),getAll:()=>Promise.resolve(void 0),set:()=>Promise.resolve(void 0),flush:()=>Promise.resolve(void 0)}}}async flushCache(){return await this.cacheProvider().flush(),this}}let g;const f="https://app.storyblok.com/f/storyblok-v2-latest.js",m=(t,e)=>{t.addNode("blok",(t=>{let s="";return t.attrs.body.forEach((t=>{s+=e(t.component,t)})),{html:s}}))};exports.ce=t=>{if("object"!=typeof t||typeof t._editable>"u")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}},exports.de=(t,e,s)=>{let r=s||g;if(r)return""===t?"":t?(e&&(r=new l(e.schema),e.resolver&&m(r,e.resolver)),r.render(t)):(console.warn(`${t} is not a valid Richtext object. This might be because the value of the richtext field is empty.\n \n For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"");console.error("Please initialize the Storyblok SDK before calling the renderRichText function")},exports.he=(t,e,s={})=>{var r;const i=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=+new URL(null==(r=window.location)?void 0:r.href).searchParams.get("_storyblok")===t;if(i&&o){if(!t)return void console.warn("Story ID is not defined. Please provide a valid ID.");window.storyblokRegisterEvent((()=>{new window.StoryblokBridge(s).on(["input","published","change"],(s=>{"input"===s.action&&s.story.id===t?e(s.story):("change"===s.action||"published"===s.action)&&s.storyId===t&&window.location.reload()}))}))}},exports.ie=a,exports.le=(t={})=>{const{apiOptions:e}=t;if(e.accessToken)return{storyblokApi:new d(e)};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")},exports.pe=()=>s(f),exports.ue=(t={})=>{var e,r;const{bridge:i,accessToken:o,use:n=[],apiOptions:a={},richText:c={}}=t;a.accessToken=a.accessToken||o;const h={bridge:i,apiOptions:a};let u={};n.forEach((t=>{u={...u,...t(h)}}));const p=!(typeof window>"u")&&(null==(r=null==(e=window.location)?void 0:e.search)?void 0:r.includes("_storyblok_tk"));return!1!==i&&p&&s(f),g=new l(c.schema),c.resolver&&m(g,c.resolver),u},exports.y=l;