@storyblok/react 2.2.1 → 2.3.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.
@@ -1 +1,3 @@
1
1
  export * from "../common";
2
+ export { default as StoryblokStory } from "../story";
3
+ export { default as BridgeLoader } from "../bridge-loader";
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@storyblok/react",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "description": "SDK to integrate Storyblok into your project using React.",
5
- "main": "./dist/storyblok-react.js",
6
- "module": "./dist/storyblok-react.mjs",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
7
  "types": "./dist/types/index.d.ts",
8
8
  "files": [
9
9
  "dist"
@@ -11,23 +11,23 @@
11
11
  "exports": {
12
12
  ".": {
13
13
  "types": "./dist/types/index.d.ts",
14
- "import": "./dist/storyblok-react.mjs",
15
- "require": "./dist/storyblok-react.js"
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.js"
16
16
  },
17
17
  "./rsc": {
18
18
  "types": "./dist/types/rsc/index.d.ts",
19
- "import": "./dist/storyblok-react2.mjs",
20
- "require": "./dist/storyblok-react2.js"
19
+ "import": "./dist/rsc.mjs",
20
+ "require": "./dist/rsc.js"
21
21
  },
22
22
  "./bridge-loader": {
23
23
  "types": "./dist/types/bridge-loader.d.ts",
24
- "import": "./dist/storyblok-react3.mjs",
25
- "require": "./dist/storyblok-react3.js"
24
+ "import": "./dist/bridge-loader.mjs",
25
+ "require": "./dist/bridge-loader.js"
26
26
  },
27
27
  "./story": {
28
28
  "types": "./dist/types/story.d.ts",
29
- "import": "./dist/storyblok-react4.mjs",
30
- "require": "./dist/storyblok-react4.js"
29
+ "import": "./dist/story.mjs",
30
+ "require": "./dist/story.js"
31
31
  }
32
32
  },
33
33
  "scripts": {
@@ -44,7 +44,7 @@
44
44
  "prepublishOnly": "npm run build && cp ../README.md ./"
45
45
  },
46
46
  "dependencies": {
47
- "@storyblok/js": "^2.2.3"
47
+ "@storyblok/js": "^2.2.4"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@babel/core": "^7.22.9",
@@ -52,18 +52,18 @@
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.16",
56
- "@vitejs/plugin-react": "^4.0.3",
57
- "babel-jest": "^29.6.1",
55
+ "@types/react": "18.2.18",
56
+ "@vitejs/plugin-react": "^4.0.4",
57
+ "babel-jest": "^29.6.2",
58
58
  "cypress": "^9.7.0",
59
59
  "eslint-plugin-cypress": "^2.13.3",
60
60
  "eslint-plugin-jest": "^27.2.3",
61
- "jest": "^29.6.1",
61
+ "jest": "^29.6.2",
62
62
  "react": "^18.2.0",
63
63
  "react-dom": "^18.2.0",
64
+ "rollup-plugin-preserve-directives": "^0.2.0",
64
65
  "start-server-and-test": "^2.0.0",
65
- "terser": "^5.19.2",
66
- "vite": "^4.1.4"
66
+ "vite": "^4.4.8"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "react": "^17.0.0 || ^18.0.0",
@@ -1 +0,0 @@
1
- "use strict";const e=require("react"),t=require("./storyblok-js-1fc8cce4.js");exports.useStoryblokState=(r=null,o={})=>{let[s,n]=e.useState(r);if(!("undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent)||!r)return r;const i=s.internalId||s.id;return e.useEffect((()=>{n(r),t.pe(i,(e=>n(e)),o)}),[r]),s};
@@ -1,22 +0,0 @@
1
- import { useState, useEffect } from "react";
2
- import { p as pe } from "./storyblok-js-82c403db.mjs";
3
- const useStoryblokState = (initialStory = null, bridgeOptions = {}) => {
4
- let [story, setStory] = useState(initialStory);
5
- const isBridgeEnable = typeof window !== "undefined" && typeof window.storyblokRegisterEvent !== "undefined";
6
- if (!isBridgeEnable || !initialStory) {
7
- return initialStory;
8
- }
9
- const id = story.internalId || story.id;
10
- useEffect(() => {
11
- setStory(initialStory);
12
- pe(
13
- id,
14
- (newStory) => setStory(newStory),
15
- bridgeOptions
16
- );
17
- }, [initialStory]);
18
- return story;
19
- };
20
- export {
21
- useStoryblokState as u
22
- };
@@ -1,51 +0,0 @@
1
- import { m as me } from "./storyblok-js-82c403db.mjs";
2
- import React, { forwardRef } from "react";
3
- const StoryblokComponent = forwardRef(
4
- ({ blok, ...restProps }, ref) => {
5
- if (!blok) {
6
- console.error(
7
- "Please provide a 'blok' property to the StoryblokComponent"
8
- );
9
- return /* @__PURE__ */ React.createElement("div", null, "Please provide a blok property to the StoryblokComponent");
10
- }
11
- const Component = getComponent(blok.component);
12
- if (Component) {
13
- return /* @__PURE__ */ React.createElement(Component, { ref, blok, ...restProps });
14
- }
15
- return /* @__PURE__ */ React.createElement("div", null);
16
- }
17
- );
18
- StoryblokComponent.displayName = "StoryblokComponent";
19
- let storyblokApiInstance = null;
20
- let componentsMap = {};
21
- const useStoryblokApi = () => {
22
- if (!storyblokApiInstance) {
23
- console.error(
24
- "You can't use getStoryblokApi if you're not loading apiPlugin."
25
- );
26
- }
27
- return storyblokApiInstance;
28
- };
29
- const setComponents = (newComponentsMap) => {
30
- componentsMap = newComponentsMap;
31
- return componentsMap;
32
- };
33
- const getComponent = (componentKey) => {
34
- if (!componentsMap[componentKey]) {
35
- console.error(`Component ${componentKey} doesn't exist.`);
36
- return false;
37
- }
38
- return componentsMap[componentKey];
39
- };
40
- const storyblokInit = (pluginOptions = {}) => {
41
- const { storyblokApi } = me(pluginOptions);
42
- storyblokApiInstance = storyblokApi;
43
- componentsMap = pluginOptions.components;
44
- };
45
- export {
46
- StoryblokComponent as S,
47
- storyblokInit as a,
48
- getComponent as g,
49
- setComponents as s,
50
- useStoryblokApi as u
51
- };
@@ -1 +0,0 @@
1
- "use strict";const o=require("./storyblok-js-1fc8cce4.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.setComponents=o=>(n=o,n),exports.storyblokInit=(e={})=>{const{storyblokApi:t}=o.me(e);r=t,n=e.components},exports.useStoryblokApi=()=>(r||console.error("You can't use getStoryblokApi if you're not loading apiPlugin."),r);
@@ -1 +0,0 @@
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})}))}}const u="SB-Agent",p="SB-JS-CLIENT",d="SB-Agent-Version",g="2.2.3";let f={};const m={};class y{constructor(t,e){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");let s=t.endpoint||e;if(!s){const e=(new c).getRegionURL,r=!1===t.https?"http":"https";s=t.oauthToken?`${r}://${e(t.region)}/v1`:`${r}://${e(t.region)}/v2`}const r=new Headers;if(r.set("Content-Type","application/json"),r.set("Accept","application/json"),t.headers)for(const o in t.headers)r.set(o,t.headers[o]);r.has(u)||(r.set(u,p),r.set(d,g));let n=5;t.oauthToken&&(r.set("Authorization",t.oauthToken),n=3),t.rateLimit&&(n=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,n,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:s,timeout:t.timeout||0,headers:r,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=m[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&&m[e.token]!=l.data.cv&&await this.flushCache(),m[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 m}cacheVersion(){return m[this.accessToken]}setCacheVersion(t){this.accessToken&&(m[this.accessToken]=t)}cacheProvider(){switch(this.cache.type){case"memory":return{get:t=>Promise.resolve(f[t]),getAll:()=>Promise.resolve(f),set:(t,e)=>(f[t]=e,Promise.resolve(void 0)),flush:()=>(f={},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 b;const v="https://app.storyblok.com/f/storyblok-v2-latest.js",k=(t,e)=>{t.addNode("blok",(t=>{let s="";return t.attrs.body.forEach((t=>{s+=e(t.component,t)})),{html:s}}))};exports._e=(t,e,s)=>{let r=s||b;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&&k(r,e.resolver)),r.render(t));console.error("Please initialize the Storyblok SDK before calling the renderRichText function")},exports.b=l,exports.de=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.ge=()=>s(v),exports.ie=a,exports.me=(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(v),b=new l(c.schema),c.resolver&&k(b,c.resolver),u},exports.pe=(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.ue=(t={})=>{const{apiOptions:e}=t;if(e.accessToken)return{storyblokApi:new y(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")};