@storyblok/react 5.1.1 → 5.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +5 -5
- package/dist/index2.mjs +2 -2
- package/dist/richtext2.js +1 -0
- package/dist/richtext2.mjs +32 -0
- package/dist/rsc/index.d.ts +2 -5
- package/dist/rsc/index.d.ts.map +1 -1
- package/dist/rsc/richtext.d.ts +11 -0
- package/dist/rsc/richtext.d.ts.map +1 -0
- package/dist/rsc/server-storyblok-richtext-component.d.ts +5 -0
- package/dist/rsc/server-storyblok-richtext-component.d.ts.map +1 -0
- package/dist/rsc.js +1 -1
- package/dist/rsc.mjs +25 -27
- package/dist/server-component.js +1 -1
- package/dist/server-component.mjs +1 -2
- package/dist/server-storyblok-richtext-component.js +1 -0
- package/dist/server-storyblok-richtext-component.mjs +17 -0
- package/dist/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +41 -41
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { useState as f, useEffect as k } from "react";
|
|
|
2
2
|
import { registerStoryblokBridge as u } from "./storyblok-js.mjs";
|
|
3
3
|
import { BlockTypes as T, MarkTypes as B, TextTypes as C, apiPlugin as E, loadStoryblokBridge as h, renderRichText as w, richTextResolver as A, storyblokEditable as I } from "./storyblok-js.mjs";
|
|
4
4
|
import { useStoryblokApi as c } from "./index2.mjs";
|
|
5
|
-
import { getComponent as L, getCustomFallbackComponent as P, getEnableFallbackComponent as _, setComponents as
|
|
5
|
+
import { getComponent as L, getCustomFallbackComponent as P, getEnableFallbackComponent as _, setComponents as $, storyblokInit as J } from "./index2.mjs";
|
|
6
6
|
import { useStoryblokRichText as m } from "./richtext.mjs";
|
|
7
|
-
import { useStoryblokState as
|
|
7
|
+
import { useStoryblokState as N } from "./client.mjs";
|
|
8
8
|
import { default as j } from "./storyblok-rich-text.mjs";
|
|
9
9
|
import { convertAttributesInElement as z } from "./utils.mjs";
|
|
10
10
|
import { default as G } from "./storyblok-component.mjs";
|
|
@@ -47,13 +47,13 @@ export {
|
|
|
47
47
|
u as registerStoryblokBridge,
|
|
48
48
|
w as renderRichText,
|
|
49
49
|
A as richTextResolver,
|
|
50
|
-
|
|
50
|
+
$ as setComponents,
|
|
51
51
|
I as storyblokEditable,
|
|
52
|
-
|
|
52
|
+
J as storyblokInit,
|
|
53
53
|
x as useStoryblok,
|
|
54
54
|
c as useStoryblokApi,
|
|
55
55
|
u as useStoryblokBridge,
|
|
56
56
|
m as useStoryblokRichText,
|
|
57
57
|
g as useStoryblokRichTextResolver,
|
|
58
|
-
|
|
58
|
+
N as useStoryblokState
|
|
59
59
|
};
|
package/dist/index2.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { storyblokInit as s } from "./storyblok-js.mjs";
|
|
2
2
|
import { BlockTypes as g, MarkTypes as C, TextTypes as d, apiPlugin as f, loadStoryblokBridge as S, registerStoryblokBridge as x, renderRichText as F, richTextResolver as T, storyblokEditable as A, registerStoryblokBridge as B } from "./storyblok-js.mjs";
|
|
3
|
-
import { default as
|
|
3
|
+
import { default as R } from "./storyblok-component.mjs";
|
|
4
4
|
let t = null, e = {}, r = !1, l = null;
|
|
5
5
|
const b = () => (t || console.error(
|
|
6
6
|
"You can't use getStoryblokApi if you're not loading apiPlugin."
|
|
@@ -11,7 +11,7 @@ const b = () => (t || console.error(
|
|
|
11
11
|
export {
|
|
12
12
|
g as BlockTypes,
|
|
13
13
|
C as MarkTypes,
|
|
14
|
-
|
|
14
|
+
R as StoryblokComponent,
|
|
15
15
|
d as TextTypes,
|
|
16
16
|
f as apiPlugin,
|
|
17
17
|
k as getComponent,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react");require("./common.js");const n=require("./storyblok-js.js"),l=require("./server-component.js");function c(e){var t,s;const r=(t=e==null?void 0:e.attrs)==null?void 0:t.body;return o.createElement(l,{blok:Array.isArray(r)&&r.length>0?r[0]:void 0,key:((s=e.attrs)==null?void 0:s.id)||`fallback-key-${JSON.stringify(e.attrs)}`})}function i(e){const r={...e,renderFn:o.createElement,textFn:t=>o.createElement(o.Fragment,{key:Math.random().toString(36).substring(2,15)},t),resolvers:{[n.BlockTypes.COMPONENT]:c,...e.resolvers},keyedResolvers:!0};return n.richTextResolver(r)}exports.componentResolver=c;exports.useStoryblokServerRichText=i;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import o from "react";
|
|
2
|
+
import "./common.mjs";
|
|
3
|
+
import { BlockTypes as n, richTextResolver as a } from "./storyblok-js.mjs";
|
|
4
|
+
import l from "./server-component.mjs";
|
|
5
|
+
function i(r) {
|
|
6
|
+
var t, s;
|
|
7
|
+
const e = (t = r == null ? void 0 : r.attrs) == null ? void 0 : t.body;
|
|
8
|
+
return o.createElement(l, {
|
|
9
|
+
blok: Array.isArray(e) && e.length > 0 ? e[0] : void 0,
|
|
10
|
+
key: ((s = r.attrs) == null ? void 0 : s.id) || `fallback-key-${JSON.stringify(r.attrs)}`
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function v(r) {
|
|
14
|
+
const e = {
|
|
15
|
+
...r,
|
|
16
|
+
renderFn: o.createElement,
|
|
17
|
+
textFn: (t) => o.createElement(o.Fragment, {
|
|
18
|
+
key: Math.random().toString(36).substring(2, 15)
|
|
19
|
+
}, t),
|
|
20
|
+
resolvers: {
|
|
21
|
+
[n.COMPONENT]: i,
|
|
22
|
+
// ✅ Uses RSC component resolver
|
|
23
|
+
...r.resolvers
|
|
24
|
+
},
|
|
25
|
+
keyedResolvers: !0
|
|
26
|
+
};
|
|
27
|
+
return a(e);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
i as componentResolver,
|
|
31
|
+
v as useStoryblokServerRichText
|
|
32
|
+
};
|
package/dist/rsc/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { useStoryblokRichText } from '../richtext';
|
|
2
|
-
export { useStoryblokRichText };
|
|
3
|
-
/** @deprecated Use useStoryblokRichText instead */
|
|
4
|
-
export declare const useStoryblokRichTextResolver: typeof useStoryblokRichText;
|
|
5
|
-
export { default as StoryblokRichText } from '../storyblok-rich-text';
|
|
6
1
|
export * from './common';
|
|
2
|
+
export { useStoryblokServerRichText } from './richtext';
|
|
3
|
+
export { default as StoryblokServerRichText } from './server-storyblok-richtext-component';
|
|
7
4
|
export { default as StoryblokStory } from './story';
|
|
8
5
|
export { BlockTypes, MarkTypes, richTextResolver, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeResolver, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, type StoryblokRichTextResolvers, TextTypes, } from '@storyblok/js';
|
|
9
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/rsc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rsc/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rsc/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,KAAK,yCAAyC,EAC9C,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,SAAS,GACV,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { StoryblokRichTextNode, StoryblokRichTextOptions } from '@storyblok/js';
|
|
3
|
+
/**
|
|
4
|
+
* RSC-specific component resolver that uses StoryblokServerComponent
|
|
5
|
+
* instead of the client-side StoryblokComponent
|
|
6
|
+
*/
|
|
7
|
+
export declare function componentResolver(node: StoryblokRichTextNode<React.ReactElement>): React.ReactElement;
|
|
8
|
+
export declare function useStoryblokServerRichText(options: StoryblokRichTextOptions<React.ReactElement>): {
|
|
9
|
+
render: (node: StoryblokRichTextNode<React.ReactNode>) => React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=richtext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"richtext.d.ts","sourceRoot":"","sources":["../../src/rsc/richtext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAGrF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,YAAY,CAMrG;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,wBAAwB,CAAC,KAAK,CAAC,YAAY,CAAC;;EAgBtD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { StoryblokRichTextProps } from '../types';
|
|
3
|
+
declare const StoryblokRichText: React.ForwardRefExoticComponent<StoryblokRichTextProps & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export default StoryblokRichText;
|
|
5
|
+
//# sourceMappingURL=server-storyblok-richtext-component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-storyblok-richtext-component.d.ts","sourceRoot":"","sources":["../../src/rsc/server-storyblok-richtext-component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGvD,QAAA,MAAM,iBAAiB,+FAkBtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/rsc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./common.js"),t=require("./richtext2.js"),r=require("./server-storyblok-richtext-component.js"),l=require("./story.js"),e=require("./storyblok-js.js"),s=require("./server-component.js");exports.getComponent=o.getComponent;exports.getCustomFallbackComponent=o.getCustomFallbackComponent;exports.getEnableFallbackComponent=o.getEnableFallbackComponent;exports.getStoryblokApi=o.useStoryblokApi;exports.setComponents=o.setComponents;exports.storyblokInit=o.storyblokInit;exports.useStoryblokApi=o.useStoryblokApi;exports.useStoryblokServerRichText=t.useStoryblokServerRichText;exports.StoryblokServerRichText=r;exports.StoryblokStory=l;exports.BlockTypes=e.BlockTypes;exports.MarkTypes=e.MarkTypes;exports.TextTypes=e.TextTypes;exports.apiPlugin=e.apiPlugin;exports.loadStoryblokBridge=e.loadStoryblokBridge;exports.registerStoryblokBridge=e.registerStoryblokBridge;exports.renderRichText=e.renderRichText;exports.richTextResolver=e.richTextResolver;exports.storyblokEditable=e.storyblokEditable;exports.useStoryblokBridge=e.registerStoryblokBridge;exports.StoryblokServerComponent=s;
|
package/dist/rsc.mjs
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { default as
|
|
5
|
-
import { BlockTypes as
|
|
6
|
-
import { default as
|
|
7
|
-
const t = o;
|
|
1
|
+
import { getComponent as r, getCustomFallbackComponent as t, getEnableFallbackComponent as l, useStoryblokApi as s, setComponents as p, storyblokInit as a, useStoryblokApi as b } from "./common.mjs";
|
|
2
|
+
import { useStoryblokServerRichText as k } from "./richtext2.mjs";
|
|
3
|
+
import { default as S } from "./server-storyblok-richtext-component.mjs";
|
|
4
|
+
import { default as m } from "./story.mjs";
|
|
5
|
+
import { BlockTypes as x, MarkTypes as d, TextTypes as f, apiPlugin as u, loadStoryblokBridge as T, registerStoryblokBridge as c, renderRichText as C, richTextResolver as B, storyblokEditable as h, registerStoryblokBridge as v } from "./storyblok-js.mjs";
|
|
6
|
+
import { default as A } from "./server-component.mjs";
|
|
8
7
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
x as BlockTypes,
|
|
9
|
+
d as MarkTypes,
|
|
10
|
+
A as StoryblokServerComponent,
|
|
11
|
+
S as StoryblokServerRichText,
|
|
12
|
+
m as StoryblokStory,
|
|
13
|
+
f as TextTypes,
|
|
14
|
+
u as apiPlugin,
|
|
15
|
+
r as getComponent,
|
|
16
|
+
t as getCustomFallbackComponent,
|
|
17
|
+
l as getEnableFallbackComponent,
|
|
18
|
+
s as getStoryblokApi,
|
|
20
19
|
T as loadStoryblokBridge,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
c as registerStoryblokBridge,
|
|
21
|
+
C as renderRichText,
|
|
22
|
+
B as richTextResolver,
|
|
23
|
+
p as setComponents,
|
|
24
|
+
h as storyblokEditable,
|
|
25
|
+
a as storyblokInit,
|
|
26
|
+
b as useStoryblokApi,
|
|
28
27
|
v as useStoryblokBridge,
|
|
29
|
-
|
|
30
|
-
t as useStoryblokRichTextResolver
|
|
28
|
+
k as useStoryblokServerRichText
|
|
31
29
|
};
|
package/dist/server-component.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),l=require("react")
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),l=require("react"),r=require("./common.js");require("./server-storyblok-richtext-component.js");require("./story.js");const c=l.forwardRef(({blok:o,...n},i)=>{if(!o)return console.error("Please provide a 'blok' property to the StoryblokComponent"),e.jsx("div",{children:"Please provide a blok property to the StoryblokServerComponent"});const t=r.getComponent(o.component);if(t)return e.jsx(t,{ref:i,blok:o,...n});if(r.getEnableFallbackComponent()){const s=r.getCustomFallbackComponent();return s?e.jsx(s,{blok:o,...n}):e.jsx(e.Fragment,{children:e.jsxs("p",{children:["Component could not be found for blok"," ",e.jsx("strong",{children:o.component}),"! Is it configured correctly?"]})})}return e.jsx("div",{})});c.displayName="StoryblokServerComponent";module.exports=c;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx as o, Fragment as m, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as i } from "react";
|
|
3
|
-
import "./storyblok-component.mjs";
|
|
4
|
-
import "./storyblok-rich-text.mjs";
|
|
5
3
|
import { getComponent as a, getEnableFallbackComponent as c, getCustomFallbackComponent as d } from "./common.mjs";
|
|
4
|
+
import "./server-storyblok-richtext-component.mjs";
|
|
6
5
|
import "./story.mjs";
|
|
7
6
|
const s = i(
|
|
8
7
|
({ blok: e, ...r }, p) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),i=require("react"),u=require("./utils.js"),l=require("./richtext2.js"),x=i.forwardRef(({doc:t,resolvers:e},r)=>{if(!t)return null;const{render:n}=l.useStoryblokServerRichText({resolvers:e}),s=n(t),o=u.convertAttributesInElement(s);return c.jsx("div",{ref:r,children:o})});module.exports=x;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as f } from "react";
|
|
3
|
+
import { convertAttributesInElement as l } from "./utils.mjs";
|
|
4
|
+
import { useStoryblokServerRichText as s } from "./richtext2.mjs";
|
|
5
|
+
const a = f(
|
|
6
|
+
({ doc: r, resolvers: t }, o) => {
|
|
7
|
+
if (!r)
|
|
8
|
+
return null;
|
|
9
|
+
const { render: e } = s({
|
|
10
|
+
resolvers: t
|
|
11
|
+
}), m = e(r), n = l(m);
|
|
12
|
+
return /* @__PURE__ */ i("div", { ref: o, children: n });
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
export {
|
|
16
|
+
a as default
|
|
17
|
+
};
|
package/dist/storyblok-js.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function oe(n,e){if(!e)return{src:n,attrs:{}};let t=0,r=0;const s={},o=[];function c(i,h,f,y,$){typeof i!="number"||i<=h||i>=f?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${h} and ${f} (inclusive)`):$.push(`${y}(${i})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(s.height=e.height,r=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:i}=e||{},{blur:h,brightness:f,fill:y,format:$,grayscale:T,quality:A,rotate:I}=i||{};h&&c(h,0,100,"blur",o),A&&c(A,0,100,"quality",o),f&&c(f,0,100,"brightness",o),y&&o.push(`fill(${y})`),T&&o.push("grayscale()"),I&&[0,90,180,270].includes(e.filters.rotate||0)&&o.push(`rotate(${I})`),$&&["webp","png","jpeg"].includes($)&&o.push(`format(${$})`)}e.srcset&&(s.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${n}/m/${i}x0/${o.length>0?`filters:${o.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[h,f]=i;return`${n}/m/${h}x${f}/${o.length>0?`filters:${o.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let l=`${n}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),o.length>0&&(l=`${l}filters:${o.join(":")}`),{src:l,attrs:s}}var b=(n=>(n.DOCUMENT="doc",n.HEADING="heading",n.PARAGRAPH="paragraph",n.QUOTE="blockquote",n.OL_LIST="ordered_list",n.UL_LIST="bullet_list",n.LIST_ITEM="list_item",n.CODE_BLOCK="code_block",n.HR="horizontal_rule",n.BR="hard_break",n.IMAGE="image",n.EMOJI="emoji",n.COMPONENT="blok",n.TABLE="table",n.TABLE_ROW="tableRow",n.TABLE_CELL="tableCell",n.TABLE_HEADER="tableHeader",n))(b||{}),_=(n=>(n.BOLD="bold",n.STRONG="strong",n.STRIKE="strike",n.UNDERLINE="underline",n.ITALIC="italic",n.CODE="code",n.LINK="link",n.ANCHOR="anchor",n.STYLED="styled",n.SUPERSCRIPT="superscript",n.SUBSCRIPT="subscript",n.TEXT_STYLE="textStyle",n.HIGHLIGHT="highlight",n))(_||{}),N=(n=>(n.TEXT="text",n))(N||{}),S=(n=>(n.URL="url",n.STORY="story",n.ASSET="asset",n.EMAIL="email",n))(S||{});const ie=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ae=(n={})=>Object.keys(n).map(e=>`${e}="${n[e]}"`).join(" "),le=(n={})=>Object.keys(n).map(e=>`${e}: ${n[e]}`).join("; ");function ce(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const O=n=>Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0));function M(n,e={},t){const r=ae(e),s=r?`${n} ${r}`:n,o=Array.isArray(t)?t.join(""):t||"";if(n){if(ie.includes(n))return`<${s}>`}else return o;return`<${s}>${o}</${n}>`}function F(n={}){const e=new Map,{renderFn:t=M,textFn:r=ce,resolvers:s={},optimizeImages:o=!1,keyedResolvers:c=!1}=n,l=t!==M,i=a=>(u,d)=>{const p=u.attrs||{};return d.render(a,p,u.children||null)},h=(a,u)=>{const{src:d,alt:p,title:m,srcset:w,sizes:v}=a.attrs||{};let k=d,R={};if(o){const{src:re,attrs:ne}=oe(d,o);k=re,R=ne}const se={src:k,alt:p,title:m,srcset:w,sizes:v,...R};return u.render("img",O(se))},f=(a,u)=>{const{level:d,...p}=a.attrs||{};return u.render(`h${d}`,p,a.children)},y=(a,u)=>{var d,p,m,w;const v=u.render("img",{src:(d=a.attrs)==null?void 0:d.fallbackImage,alt:(p=a.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return u.render("span",{"data-type":"emoji","data-name":(m=a.attrs)==null?void 0:m.name,"data-emoji":(w=a.attrs)==null?void 0:w.emoji},v)},$=(a,u)=>u.render("pre",a.attrs||{},u.render("code",{},a.children||"")),T=(a,u=!1)=>({text:d,attrs:p},m)=>{const{class:w,id:v,...k}=p||{},R=u?{class:w,id:v,style:le(k)||void 0}:p||{};return m.render(a,O(R),d)},A=a=>C(a),I=a=>{const{marks:u,...d}=a;if("text"in a){if(u)return u.reduce((m,w)=>A({...w,text:m}),A({...d,children:d.children}));const p=a.attrs||{};if(c){const m=e.get("txt")||0;e.set("txt",m+1),p.key=`txt-${m}`}return r(d.text,p)}return""},U=(a,u)=>{const{linktype:d,href:p,anchor:m,...w}=a.attrs||{};let v="";switch(d){case S.ASSET:case S.URL:v=p;break;case S.EMAIL:v=`mailto:${p}`;break;case S.STORY:v=p,m&&(v=`${v}#${m}`);break;default:v=p;break}const k={...w};return v&&(k.href=v),u.render("a",k,a.text)},W=(a,u)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.render("span",{blok:(d=a==null?void 0:a.attrs)==null?void 0:d.body[0],id:(p=a.attrs)==null?void 0:p.id,style:"display: none"})},X=(a,u)=>{const d={},p=u.render("tbody",{},a.children);return u.render("table",d,p)},Q=(a,u)=>{const d={};return u.render("tr",d,a.children)},Z=(a,u)=>{const{colspan:d,rowspan:p,colwidth:m,backgroundColor:w,...v}=a.attrs||{},k={...v};d>1&&(k.colspan=d),p>1&&(k.rowspan=p);const R=[];return m&&R.push(`width: ${m}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(k.style=R.join(" ")),u.render("td",O(k),a.children)},ee=(a,u)=>{const{colspan:d,rowspan:p,colwidth:m,backgroundColor:w,...v}=a.attrs||{},k={...v};d>1&&(k.colspan=d),p>1&&(k.rowspan=p);const R=[];return m&&R.push(`width: ${m}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(k.style=R.join(" ")),u.render("th",O(k),a.children)},B=new Map([[b.DOCUMENT,i("")],[b.HEADING,f],[b.PARAGRAPH,i("p")],[b.UL_LIST,i("ul")],[b.OL_LIST,i("ol")],[b.LIST_ITEM,i("li")],[b.IMAGE,h],[b.EMOJI,y],[b.CODE_BLOCK,$],[b.HR,i("hr")],[b.BR,i("br")],[b.QUOTE,i("blockquote")],[b.COMPONENT,W],[N.TEXT,I],[_.LINK,U],[_.ANCHOR,U],[_.STYLED,T("span",!0)],[_.BOLD,T("strong")],[_.TEXT_STYLE,T("span",!0)],[_.ITALIC,T("em")],[_.UNDERLINE,T("u")],[_.STRIKE,T("s")],[_.CODE,T("code")],[_.SUPERSCRIPT,T("sup")],[_.SUBSCRIPT,T("sub")],[_.HIGHLIGHT,T("mark")],[b.TABLE,X],[b.TABLE_ROW,Q],[b.TABLE_CELL,Z],[b.TABLE_HEADER,ee]]),D=new Map([...B,...Object.entries(s).map(([a,u])=>[a,u])]),te=()=>({render:(a,u={},d)=>{if(c&&a){const p=e.get(a)||0;e.set(a,p+1),u.key=`${a}-${p}`}return t(a,u,d)},originalResolvers:B,mergedResolvers:D});function L(a){const u=D.get(a.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${a.type}`),"";const d=te();if(a.type==="text")return u(a,d);const p=a.content?a.content.map(C):void 0;return u({...a,children:p},d)}function C(a){return a.type==="doc"?l?a.content.map(L):a.content.map(L).join(""):Array.isArray(a)?a.map(L):L(a)}return{render:C}}let z=!1;const G=[],Y=n=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?s():G.push(s)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{G.forEach(o=>o()),z=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var he=Object.defineProperty,ue=(n,e,t)=>e in n?he(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e,t)=>ue(n,typeof e!="symbol"?e+"":e,t);class de extends Error{constructor(e){super(e),this.name="AbortError"}}function pe(n,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let s=[],o=0,c=!1;const l=async()=>{o++;const h=r.shift();if(h)try{const y=await n(...h.args);h.resolve(y)}catch(y){h.reject(y)}const f=setTimeout(()=>{o--,r.length>0&&l(),s=s.filter(y=>y!==f)},t);s.includes(f)||s.push(f)},i=(...h)=>c?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((f,y)=>{r.push({resolve:f,reject:y,args:h}),o<e&&l()});return i.abort=()=>{c=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new de("Throttle function aborted"))),r.length=0},i}const V=(n="")=>n.includes("/cdn/"),fe=(n,e=25,t=1)=>({...n,per_page:e,page:t}),ye=n=>new Promise(e=>setTimeout(e,n)),ge=(n=0,e)=>Array.from({length:n},e),me=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return ge(t,(s,o)=>o*r+n)},be=async(n,e)=>Promise.all(n.map(e)),ve=(n=[],e)=>n.map(e).reduce((t,r)=>[...t,...r],[]),H=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s];if(o==null)continue;const c=t?"":encodeURIComponent(s);let l;typeof o=="object"?l=H(o,e?e+encodeURIComponent(`[${c}]`):c,Array.isArray(o)):l=`${e?e+encodeURIComponent(`[${c}]`):c}=${encodeURIComponent(o)}`,r.push(l)}return r.join("&")},q=n=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[n]??e.eu};class ke{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${H(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),o=new AbortController,{signal:c}=o;let l;this.timeout&&(l=setTimeout(()=>o.abort(),this.timeout));try{const i=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:c,...this.fetchOptions});this.timeout&&clearTimeout(l);const h=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(i){return{message:i}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const o={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(o)})}}const J="SB-Agent",P={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},we={PUBLISHED:"published"};let j={};const E={};class Te{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"version"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache"),g(this,"inlineAssets");let r=e.endpoint||t;if(!r){const c=e.https===!1?"http":"https";e.oauthToken?r=`${c}://${q(e.region)}/v1`:r=`${c}://${q(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([c,l])=>{s.set(c,l)}),s.has(J)||(s.set(J,P.defaultAgentName),s.set(P.defaultAgentVersion,P.packageVersion));let o=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),o=3),e.rateLimit&&(o=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=pe(this.throttledRequest.bind(this),o,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||we.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new ke({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return V(e)?this.parseParams(t):t}makeRequest(e,t,r,s,o){const c=this.factoryParamOptions(e,fe(t,r,s));return this.cacheResponse(e,c,void 0,o)}get(e,t={},r){t||(t={});const s=`/${e}`;V(s)&&(t.version=t.version||this.version);const o=this.factoryParamOptions(s,t);return this.cacheResponse(s,o,void 0,r)}async getAll(e,t={},r,s){const o=(t==null?void 0:t.per_page)||25,c=`/${e}`.replace(/\/$/,""),l=r??c.substring(c.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,h=await this.makeRequest(c,t,o,i,s),f=h.total?Math.ceil(h.total/o):1,y=await be(me(i,f),$=>this.makeRequest(c,t,o,$+1,s));return ve([h,...y],$=>Object.values($.data[l]))}post(e,t={},r){const s=`/${e}`;return this.throttle("post",s,t,r)}put(e,t={},r){const s=`/${e}`;return this.throttle("put",s,t,r)}delete(e,t={},r){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(o=>this.getStoryReference(r,o)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(c=>c.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const o=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(o):r===o)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(o,c="")=>{if(!(!o||o._stopResolving)){if(Array.isArray(o))o.forEach((l,i)=>s(l,`${c}[${i}]`));else if(typeof o=="object")for(const l in o){const i=c?`${c}.${l}`:l;(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,l,t,r),this._insertLinks(o,l,r)),s(o[l],i)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const o=e.link_uuids.length,c=[],l=50;for(let i=0;i<o;i+=l){const h=Math.min(o,i+l);c.push(e.link_uuids.slice(i,h))}for(let i=0;i<c.length;i++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:c[i].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(o=>{this.links[r][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const o=e.rel_uuids.length,c=[],l=50;for(let i=0;i<o;i+=l){const h=Math.min(o,i+l);c.push(e.rel_uuids.slice(i,h))}for(let i=0;i<c.length;i++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:c[i].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(o=>{this.relations[r][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,r){var s,o;let c=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(c=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],c,r);e.story?this.iterateTree(e.story,c,r):e.stories.forEach(l=>{this.iterateTree(l,c,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const o=H({url:e,params:t}),c=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await c.get(o);if(l)return Promise.resolve(l)}return new Promise(async(l,i)=>{var h;try{const f=await this.throttle("get",e,t,s);if(f.status!==200)return i(f);let y={data:f.data,headers:f.headers};if((h=f.headers)!=null&&h["per-page"]&&(y=Object.assign({},y,{perPage:f.headers["per-page"]?Number.parseInt(f.headers["per-page"]):0,total:f.headers["per-page"]?Number.parseInt(f.headers.total):0})),y.data.story||y.data.stories){const T=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${T}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await c.set(o,y);const $=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&($&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(f){if(f.response&&f.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ye(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(i);i(f)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(o=>t(o));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(o=>o.id===s.id)});for(const o in s)typeof s[o]=="object"&&(s[o]=t(s[o]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}}const Re=(n={})=>{const{apiOptions:e}=n;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new Te(e)}},_e=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};try{const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let x="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(n,e,t={})=>{var r;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),c=o!==null&&+o===n;if(!(!s||!c)){if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var i;l&&(l.action==="input"&&((i=l.story)==null?void 0:i.id)===n?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===n&&window.location.reload())})})}},$e=(n={})=>{var e,t;const{bridge:r,accessToken:s,use:o=[],apiOptions:c={},bridgeUrl:l}=n;c.accessToken=c.accessToken||s;const i={bridge:r,apiOptions:c};let h={};o.forEach(y=>{h={...h,...y(i)}}),l&&(x=l);const f=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&f&&Y(x),h};function Ee(n,e){return F(e).render(n)}const Ae=()=>Y(x);exports.BlockTypes=b;exports.MarkTypes=_;exports.TextTypes=N;exports.apiPlugin=Re;exports.loadStoryblokBridge=Ae;exports.registerStoryblokBridge=K;exports.renderRichText=Ee;exports.richTextResolver=F;exports.storyblokEditable=_e;exports.storyblokInit=$e;exports.useStoryblokBridge=K;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function oe(n,e){if(!e)return{src:n,attrs:{}};let t=0,r=0;const s={},o=[];function c(i,h,f,y,R){typeof i!="number"||i<=h||i>=f?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${h} and ${f} (inclusive)`):R.push(`${y}(${i})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(s.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(s.height=e.height,r=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(s.loading=e.loading),e.class&&(s.class=e.class),e.filters){const{filters:i}=e||{},{blur:h,brightness:f,fill:y,format:R,grayscale:T,quality:A,rotate:I}=i||{};h&&c(h,0,100,"blur",o),A&&c(A,0,100,"quality",o),f&&c(f,0,100,"brightness",o),y&&o.push(`fill(${y})`),T&&o.push("grayscale()"),I&&[0,90,180,270].includes(e.filters.rotate||0)&&o.push(`rotate(${I})`),R&&["webp","png","jpeg"].includes(R)&&o.push(`format(${R})`)}e.srcset&&(s.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${n}/m/${i}x0/${o.length>0?`filters:${o.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[h,f]=i;return`${n}/m/${h}x${f}/${o.length>0?`filters:${o.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(s.sizes=e.sizes.join(", "))}let l=`${n}/m/`;return t>0&&r>0&&(l=`${l}${t}x${r}/`),o.length>0&&(l=`${l}filters:${o.join(":")}`),{src:l,attrs:s}}var b=(n=>(n.DOCUMENT="doc",n.HEADING="heading",n.PARAGRAPH="paragraph",n.QUOTE="blockquote",n.OL_LIST="ordered_list",n.UL_LIST="bullet_list",n.LIST_ITEM="list_item",n.CODE_BLOCK="code_block",n.HR="horizontal_rule",n.BR="hard_break",n.IMAGE="image",n.EMOJI="emoji",n.COMPONENT="blok",n.TABLE="table",n.TABLE_ROW="tableRow",n.TABLE_CELL="tableCell",n.TABLE_HEADER="tableHeader",n))(b||{}),$=(n=>(n.BOLD="bold",n.STRONG="strong",n.STRIKE="strike",n.UNDERLINE="underline",n.ITALIC="italic",n.CODE="code",n.LINK="link",n.ANCHOR="anchor",n.STYLED="styled",n.SUPERSCRIPT="superscript",n.SUBSCRIPT="subscript",n.TEXT_STYLE="textStyle",n.HIGHLIGHT="highlight",n))($||{}),N=(n=>(n.TEXT="text",n))(N||{}),S=(n=>(n.URL="url",n.STORY="story",n.ASSET="asset",n.EMAIL="email",n))(S||{});const ie=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ae=(n={})=>Object.keys(n).map(e=>`${e}="${n[e]}"`).join(" "),le=(n={})=>Object.keys(n).map(e=>`${e}: ${n[e]}`).join("; ");function ce(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const O=n=>Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0));function M(n,e={},t){const r=ae(e),s=r?`${n} ${r}`:n,o=Array.isArray(t)?t.join(""):t||"";if(n){if(ie.includes(n))return`<${s}>`}else return o;return`<${s}>${o}</${n}>`}function F(n={}){const e=new Map,{renderFn:t=M,textFn:r=ce,resolvers:s={},optimizeImages:o=!1,keyedResolvers:c=!1}=n,l=t!==M,i=a=>(u,d)=>{const p=u.attrs||{};return d.render(a,p,u.children||null)},h=(a,u)=>{const{src:d,alt:p,title:m,srcset:w,sizes:v}=a.attrs||{};let k=d,_={};if(o){const{src:re,attrs:ne}=oe(d,o);k=re,_=ne}const se={src:k,alt:p,title:m,srcset:w,sizes:v,..._};return u.render("img",O(se))},f=(a,u)=>{const{level:d,...p}=a.attrs||{};return u.render(`h${d}`,p,a.children)},y=(a,u)=>{var d,p,m,w;const v=u.render("img",{src:(d=a.attrs)==null?void 0:d.fallbackImage,alt:(p=a.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return u.render("span",{"data-type":"emoji","data-name":(m=a.attrs)==null?void 0:m.name,"data-emoji":(w=a.attrs)==null?void 0:w.emoji},v)},R=(a,u)=>u.render("pre",a.attrs||{},u.render("code",{},a.children||"")),T=(a,u=!1)=>({text:d,attrs:p},m)=>{const{class:w,id:v,...k}=p||{},_=u?{class:w,id:v,style:le(k)||void 0}:p||{};return m.render(a,O(_),d)},A=a=>C(a),I=a=>{const{marks:u,...d}=a;if("text"in a){if(u)return u.reduce((m,w)=>A({...w,text:m}),A({...d,children:d.children}));const p=a.attrs||{};if(c){const m=e.get("txt")||0;e.set("txt",m+1),p.key=`txt-${m}`}return r(d.text,p)}return""},U=(a,u)=>{const{linktype:d,href:p,anchor:m,...w}=a.attrs||{};let v="";switch(d){case S.ASSET:case S.URL:v=p;break;case S.EMAIL:v=`mailto:${p}`;break;case S.STORY:v=p,m&&(v=`${v}#${m}`);break;default:v=p;break}const k={...w};return v&&(k.href=v),u.render("a",k,a.text)},W=(a,u)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.render("span",{blok:(d=a==null?void 0:a.attrs)==null?void 0:d.body[0],id:(p=a.attrs)==null?void 0:p.id,style:"display: none"})},X=(a,u)=>{const d={},p=u.render("tbody",{},a.children);return u.render("table",d,p)},Q=(a,u)=>{const d={};return u.render("tr",d,a.children)},Z=(a,u)=>{const{colspan:d,rowspan:p,colwidth:m,backgroundColor:w,...v}=a.attrs||{},k={...v};d>1&&(k.colspan=d),p>1&&(k.rowspan=p);const _=[];return m&&_.push(`width: ${m}px;`),w&&_.push(`background-color: ${w};`),_.length>0&&(k.style=_.join(" ")),u.render("td",O(k),a.children)},ee=(a,u)=>{const{colspan:d,rowspan:p,colwidth:m,backgroundColor:w,...v}=a.attrs||{},k={...v};d>1&&(k.colspan=d),p>1&&(k.rowspan=p);const _=[];return m&&_.push(`width: ${m}px;`),w&&_.push(`background-color: ${w};`),_.length>0&&(k.style=_.join(" ")),u.render("th",O(k),a.children)},B=new Map([[b.DOCUMENT,i("")],[b.HEADING,f],[b.PARAGRAPH,i("p")],[b.UL_LIST,i("ul")],[b.OL_LIST,i("ol")],[b.LIST_ITEM,i("li")],[b.IMAGE,h],[b.EMOJI,y],[b.CODE_BLOCK,R],[b.HR,i("hr")],[b.BR,i("br")],[b.QUOTE,i("blockquote")],[b.COMPONENT,W],[N.TEXT,I],[$.LINK,U],[$.ANCHOR,U],[$.STYLED,T("span",!0)],[$.BOLD,T("strong")],[$.TEXT_STYLE,T("span",!0)],[$.ITALIC,T("em")],[$.UNDERLINE,T("u")],[$.STRIKE,T("s")],[$.CODE,T("code")],[$.SUPERSCRIPT,T("sup")],[$.SUBSCRIPT,T("sub")],[$.HIGHLIGHT,T("mark")],[b.TABLE,X],[b.TABLE_ROW,Q],[b.TABLE_CELL,Z],[b.TABLE_HEADER,ee]]),D=new Map([...B,...Object.entries(s).map(([a,u])=>[a,u])]),te=()=>({render:(a,u={},d)=>{if(c&&a){const p=e.get(a)||0;e.set(a,p+1),u.key=`${a}-${p}`}return t(a,u,d)},originalResolvers:B,mergedResolvers:D});function L(a){const u=D.get(a.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${a.type}`),"";const d=te();if(a.type==="text")return u(a,d);const p=a.content?a.content.map(C):void 0;return u({...a,children:p},d)}function C(a){return a.type==="doc"?l?a.content.map(L):a.content.map(L).join(""):Array.isArray(a)?a.map(L):L(a)}return{render:C}}let z=!1;const G=[],Y=n=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=s=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?s():G.push(s)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{G.forEach(o=>o()),z=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var he=Object.defineProperty,ue=(n,e,t)=>e in n?he(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e,t)=>ue(n,typeof e!="symbol"?e+"":e,t);class de extends Error{constructor(e){super(e),this.name="AbortError"}}function pe(n,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let s=[],o=0,c=!1;const l=async()=>{o++;const h=r.shift();if(h)try{const y=await n(...h.args);h.resolve(y)}catch(y){h.reject(y)}const f=setTimeout(()=>{o--,r.length>0&&l(),s=s.filter(y=>y!==f)},t);s.includes(f)||s.push(f)},i=(...h)=>c?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((f,y)=>{r.push({resolve:f,reject:y,args:h}),o<e&&l()});return i.abort=()=>{c=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new de("Throttle function aborted"))),r.length=0},i}const V=(n="")=>n.includes("/cdn/"),fe=(n,e=25,t=1)=>({...n,per_page:e,page:t}),ye=n=>new Promise(e=>setTimeout(e,n)),ge=(n=0,e)=>Array.from({length:n},e),me=(n=0,e=n)=>{const t=Math.abs(e-n)||0,r=n<e?1:-1;return ge(t,(s,o)=>o*r+n)},be=async(n,e)=>Promise.all(n.map(e)),ve=(n=[],e)=>n.map(e).reduce((t,r)=>[...t,...r],[]),H=(n,e,t)=>{const r=[];for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const o=n[s];if(o==null)continue;const c=t?"":encodeURIComponent(s);let l;typeof o=="object"?l=H(o,e?e+encodeURIComponent(`[${c}]`):c,Array.isArray(o)):l=`${e?e+encodeURIComponent(`[${c}]`):c}=${encodeURIComponent(o)}`,r.push(l)}return r.join("&")},q=n=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[n]??e.eu};class ke{constructor(e){g(this,"baseURL"),g(this,"timeout"),g(this,"headers"),g(this,"responseInterceptor"),g(this,"fetch"),g(this,"ejectInterceptor"),g(this,"url"),g(this,"parameters"),g(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${H(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),o=new AbortController,{signal:c}=o;let l;this.timeout&&(l=setTimeout(()=>o.abort(),this.timeout));try{const i=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:c,...this.fetchOptions});this.timeout&&clearTimeout(l);const h=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(i){return{message:i}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const o={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(o)})}}const J="SB-Agent",P={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},we={PUBLISHED:"published"};let j={};const E={};class Te{constructor(e,t){g(this,"client"),g(this,"maxRetries"),g(this,"retriesDelay"),g(this,"throttle"),g(this,"accessToken"),g(this,"cache"),g(this,"resolveCounter"),g(this,"relations"),g(this,"links"),g(this,"version"),g(this,"richTextResolver"),g(this,"resolveNestedRelations"),g(this,"stringifiedStoriesCache"),g(this,"inlineAssets");let r=e.endpoint||t;if(!r){const c=e.https===!1?"http":"https";e.oauthToken?r=`${c}://${q(e.region)}/v1`:r=`${c}://${q(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([c,l])=>{s.set(c,l)}),s.has(J)||(s.set(J,P.defaultAgentName),s.set(P.defaultAgentVersion,P.packageVersion));let o=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),o=3),e.rateLimit&&(o=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=pe(this.throttledRequest.bind(this),o,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||we.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new ke({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return V(e)?this.parseParams(t):t}makeRequest(e,t,r,s,o){const c=this.factoryParamOptions(e,fe(t,r,s));return this.cacheResponse(e,c,void 0,o)}get(e,t={},r){t||(t={});const s=`/${e}`;V(s)&&(t.version=t.version||this.version);const o=this.factoryParamOptions(s,t);return this.cacheResponse(s,o,void 0,r)}async getAll(e,t={},r,s){const o=(t==null?void 0:t.per_page)||25,c=`/${e}`.replace(/\/$/,""),l=r??c.substring(c.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,h=await this.makeRequest(c,t,o,i,s),f=h.total?Math.ceil(h.total/o):1,y=await be(me(i,f),R=>this.makeRequest(c,t,o,R+1,s));return ve([h,...y],R=>Object.values(R.data[l]))}post(e,t={},r){const s=`/${e}`;return this.throttle("post",s,t,r)}put(e,t={},r){const s=`/${e}`;return this.throttle("put",s,t,r)}delete(e,t={},r){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(o=>this.getStoryReference(r,o)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(c=>c.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const o=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(o):r===o)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(o,c="")=>{if(!(!o||o._stopResolving)){if(Array.isArray(o))o.forEach((l,i)=>s(l,`${c}[${i}]`));else if(typeof o=="object")for(const l in o){const i=c?`${c}.${l}`:l;(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,l,t,r),this._insertLinks(o,l,r)),s(o[l],i)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const o=e.link_uuids.length,c=[],l=50;for(let i=0;i<o;i+=l){const h=Math.min(o,i+l);c.push(e.link_uuids.slice(i,h))}for(let i=0;i<c.length;i++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:c[i].join(",")})).data.stories.forEach(h=>{s.push(h)})}else s=e.links;s.forEach(o=>{this.links[r][o.uuid]={...o,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const o=e.rel_uuids.length,c=[],l=50;for(let i=0;i<o;i+=l){const h=Math.min(o,i+l);c.push(e.rel_uuids.slice(i,h))}for(let i=0;i<c.length;i++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:c[i].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{s.push(h)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(o=>{this.relations[r][o.uuid]={...o,_stopResolving:!0}})}async resolveStories(e,t,r){var s,o;let c=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(c=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(o=e.link_uuids)!=null&&o.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],c,r);e.story?this.iterateTree(e.story,c,r):e.stories.forEach(l=>{this.iterateTree(l,c,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const o=H({url:e,params:t}),c=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await c.get(o);if(l)return Promise.resolve(l)}return new Promise(async(l,i)=>{var h;try{const f=await this.throttle("get",e,t,s);if(f.status!==200)return i(f);let y={data:f.data,headers:f.headers};if((h=f.headers)!=null&&h["per-page"]&&(y=Object.assign({},y,{perPage:f.headers["per-page"]?Number.parseInt(f.headers["per-page"]):0,total:f.headers["per-page"]?Number.parseInt(f.headers.total):0})),y.data.story||y.data.stories){const T=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${T}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await c.set(o,y);const R=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(R&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(f){if(f.response&&f.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ye(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(i);i(f)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(o=>t(o));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(o=>o.id===s.id)});for(const o in s)typeof s[o]=="object"&&(s[o]=t(s[o]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}}const _e=(n={})=>{const{apiOptions:e}=n;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new Te(e)}},$e=n=>{if(typeof n!="object"||typeof n._editable>"u")return{};try{const e=JSON.parse(n._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let x="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(n,e,t={})=>{var r;const s=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),c=o!==null&&+o===n;if(!(!s||!c)){if(!n){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var i;l&&(l.action==="input"&&((i=l.story)==null?void 0:i.id)===n?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===n&&window.location.reload())})})}},Re=(n={})=>{var e,t;const{bridge:r,accessToken:s,use:o=[],apiOptions:c={},bridgeUrl:l}=n;c.accessToken=c.accessToken||s;const i={bridge:r,apiOptions:c};let h={};o.forEach(y=>{h={...h,...y(i)}}),l&&(x=l);const f=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&f&&Y(x),h};function Ee(n,e){return F(e).render(n)}const Ae=()=>Y(x);exports.BlockTypes=b;exports.MarkTypes=$;exports.TextTypes=N;exports.apiPlugin=_e;exports.loadStoryblokBridge=Ae;exports.registerStoryblokBridge=K;exports.renderRichText=Ee;exports.richTextResolver=F;exports.storyblokEditable=$e;exports.storyblokInit=Re;exports.useStoryblokBridge=K;
|
package/dist/storyblok-js.mjs
CHANGED
|
@@ -3,13 +3,13 @@ function re(n, e) {
|
|
|
3
3
|
return { src: n, attrs: {} };
|
|
4
4
|
let t = 0, r = 0;
|
|
5
5
|
const s = {}, o = [];
|
|
6
|
-
function c(i, h, f, y,
|
|
7
|
-
typeof i != "number" || i <= h || i >= f ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${h} and ${f} (inclusive)`) :
|
|
6
|
+
function c(i, h, f, y, $) {
|
|
7
|
+
typeof i != "number" || i <= h || i >= f ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${h} and ${f} (inclusive)`) : $.push(`${y}(${i})`);
|
|
8
8
|
}
|
|
9
9
|
if (typeof e == "object") {
|
|
10
10
|
if (typeof e.width == "number" && e.width > 0 ? (s.width = e.width, t = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (s.height = e.height, r = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (s.loading = e.loading), e.class && (s.class = e.class), e.filters) {
|
|
11
|
-
const { filters: i } = e || {}, { blur: h, brightness: f, fill: y, format:
|
|
12
|
-
h && c(h, 0, 100, "blur", o), A && c(A, 0, 100, "quality", o), f && c(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), T && o.push("grayscale()"), S && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${S})`),
|
|
11
|
+
const { filters: i } = e || {}, { blur: h, brightness: f, fill: y, format: $, grayscale: T, quality: A, rotate: S } = i || {};
|
|
12
|
+
h && c(h, 0, 100, "blur", o), A && c(A, 0, 100, "quality", o), f && c(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), T && o.push("grayscale()"), S && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${S})`), $ && ["webp", "png", "jpeg"].includes($) && o.push(`format(${$})`);
|
|
13
13
|
}
|
|
14
14
|
e.srcset && (s.srcset = e.srcset.map((i) => {
|
|
15
15
|
if (typeof i == "number")
|
|
@@ -29,7 +29,7 @@ function re(n, e) {
|
|
|
29
29
|
attrs: s
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n.TABLE = "table", n.TABLE_ROW = "tableRow", n.TABLE_CELL = "tableCell", n.TABLE_HEADER = "tableHeader", n))(v || {}),
|
|
32
|
+
var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n.TABLE = "table", n.TABLE_ROW = "tableRow", n.TABLE_CELL = "tableCell", n.TABLE_HEADER = "tableHeader", n))(v || {}), R = /* @__PURE__ */ ((n) => (n.BOLD = "bold", n.STRONG = "strong", n.STRIKE = "strike", n.UNDERLINE = "underline", n.ITALIC = "italic", n.CODE = "code", n.LINK = "link", n.ANCHOR = "anchor", n.STYLED = "styled", n.SUPERSCRIPT = "superscript", n.SUBSCRIPT = "subscript", n.TEXT_STYLE = "textStyle", n.HIGHLIGHT = "highlight", n))(R || {}), J = /* @__PURE__ */ ((n) => (n.TEXT = "text", n))(J || {}), I = /* @__PURE__ */ ((n) => (n.URL = "url", n.STORY = "story", n.ASSET = "asset", n.EMAIL = "email", n))(I || {});
|
|
33
33
|
const ne = [
|
|
34
34
|
"area",
|
|
35
35
|
"base",
|
|
@@ -70,10 +70,10 @@ function le(n = {}) {
|
|
|
70
70
|
return d.render(a, p, u.children || null);
|
|
71
71
|
}, h = (a, u) => {
|
|
72
72
|
const { src: d, alt: p, title: m, srcset: w, sizes: b } = a.attrs || {};
|
|
73
|
-
let k = d,
|
|
73
|
+
let k = d, _ = {};
|
|
74
74
|
if (o) {
|
|
75
75
|
const { src: te, attrs: se } = re(d, o);
|
|
76
|
-
k = te,
|
|
76
|
+
k = te, _ = se;
|
|
77
77
|
}
|
|
78
78
|
const ee = {
|
|
79
79
|
src: k,
|
|
@@ -81,7 +81,7 @@ function le(n = {}) {
|
|
|
81
81
|
title: m,
|
|
82
82
|
srcset: w,
|
|
83
83
|
sizes: b,
|
|
84
|
-
...
|
|
84
|
+
..._
|
|
85
85
|
};
|
|
86
86
|
return u.render("img", O(ee));
|
|
87
87
|
}, f = (a, u) => {
|
|
@@ -101,17 +101,17 @@ function le(n = {}) {
|
|
|
101
101
|
"data-name": (m = a.attrs) == null ? void 0 : m.name,
|
|
102
102
|
"data-emoji": (w = a.attrs) == null ? void 0 : w.emoji
|
|
103
103
|
}, b);
|
|
104
|
-
},
|
|
104
|
+
}, $ = (a, u) => u.render(
|
|
105
105
|
"pre",
|
|
106
106
|
a.attrs || {},
|
|
107
107
|
u.render("code", {}, a.children || "")
|
|
108
108
|
), T = (a, u = !1) => ({ text: d, attrs: p }, m) => {
|
|
109
|
-
const { class: w, id: b, ...k } = p || {},
|
|
109
|
+
const { class: w, id: b, ...k } = p || {}, _ = u ? {
|
|
110
110
|
class: w,
|
|
111
111
|
id: b,
|
|
112
112
|
style: ie(k) || void 0
|
|
113
113
|
} : p || {};
|
|
114
|
-
return m.render(a, O(
|
|
114
|
+
return m.render(a, O(_), d);
|
|
115
115
|
}, A = (a) => C(a), S = (a) => {
|
|
116
116
|
const { marks: u, ...d } = a;
|
|
117
117
|
if ("text" in a) {
|
|
@@ -166,15 +166,15 @@ function le(n = {}) {
|
|
|
166
166
|
...b
|
|
167
167
|
};
|
|
168
168
|
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
169
|
-
const
|
|
170
|
-
return m &&
|
|
169
|
+
const _ = [];
|
|
170
|
+
return m && _.push(`width: ${m}px;`), w && _.push(`background-color: ${w};`), _.length > 0 && (k.style = _.join(" ")), u.render("td", O(k), a.children);
|
|
171
171
|
}, Q = (a, u) => {
|
|
172
172
|
const { colspan: d, rowspan: p, colwidth: m, backgroundColor: w, ...b } = a.attrs || {}, k = {
|
|
173
173
|
...b
|
|
174
174
|
};
|
|
175
175
|
d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
|
|
176
|
-
const
|
|
177
|
-
return m &&
|
|
176
|
+
const _ = [];
|
|
177
|
+
return m && _.push(`width: ${m}px;`), w && _.push(`background-color: ${w};`), _.length > 0 && (k.style = _.join(" ")), u.render("th", O(k), a.children);
|
|
178
178
|
}, U = /* @__PURE__ */ new Map([
|
|
179
179
|
[v.DOCUMENT, i("")],
|
|
180
180
|
[v.HEADING, f],
|
|
@@ -184,24 +184,24 @@ function le(n = {}) {
|
|
|
184
184
|
[v.LIST_ITEM, i("li")],
|
|
185
185
|
[v.IMAGE, h],
|
|
186
186
|
[v.EMOJI, y],
|
|
187
|
-
[v.CODE_BLOCK,
|
|
187
|
+
[v.CODE_BLOCK, $],
|
|
188
188
|
[v.HR, i("hr")],
|
|
189
189
|
[v.BR, i("br")],
|
|
190
190
|
[v.QUOTE, i("blockquote")],
|
|
191
191
|
[v.COMPONENT, Y],
|
|
192
192
|
[J.TEXT, S],
|
|
193
|
-
[
|
|
194
|
-
[
|
|
195
|
-
[
|
|
196
|
-
[
|
|
197
|
-
[
|
|
198
|
-
[
|
|
199
|
-
[
|
|
200
|
-
[
|
|
201
|
-
[
|
|
202
|
-
[
|
|
203
|
-
[
|
|
204
|
-
[
|
|
193
|
+
[R.LINK, H],
|
|
194
|
+
[R.ANCHOR, H],
|
|
195
|
+
[R.STYLED, T("span", !0)],
|
|
196
|
+
[R.BOLD, T("strong")],
|
|
197
|
+
[R.TEXT_STYLE, T("span", !0)],
|
|
198
|
+
[R.ITALIC, T("em")],
|
|
199
|
+
[R.UNDERLINE, T("u")],
|
|
200
|
+
[R.STRIKE, T("s")],
|
|
201
|
+
[R.CODE, T("code")],
|
|
202
|
+
[R.SUPERSCRIPT, T("sup")],
|
|
203
|
+
[R.SUBSCRIPT, T("sub")],
|
|
204
|
+
[R.HIGHLIGHT, T("mark")],
|
|
205
205
|
[v.TABLE, K],
|
|
206
206
|
[v.TABLE_ROW, W],
|
|
207
207
|
[v.TABLE_CELL, X],
|
|
@@ -247,7 +247,7 @@ const z = [], F = (n) => new Promise((e, t) => {
|
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
249
|
if (window.storyblokRegisterEvent = (s) => {
|
|
250
|
-
if (window.location
|
|
250
|
+
if (!window.location.search.includes("_storyblok")) {
|
|
251
251
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
@@ -515,9 +515,9 @@ class we {
|
|
|
515
515
|
s
|
|
516
516
|
), f = h.total ? Math.ceil(h.total / o) : 1, y = await me(
|
|
517
517
|
ge(i, f),
|
|
518
|
-
(
|
|
518
|
+
($) => this.makeRequest(c, t, o, $ + 1, s)
|
|
519
519
|
);
|
|
520
|
-
return be([h, ...y], (
|
|
520
|
+
return be([h, ...y], ($) => Object.values($.data[l]));
|
|
521
521
|
}
|
|
522
522
|
post(e, t = {}, r) {
|
|
523
523
|
const s = `/${e}`;
|
|
@@ -732,8 +732,8 @@ class we {
|
|
|
732
732
|
await this.resolveStories(y.data, t, `${T}`), y = await this.processInlineAssets(y);
|
|
733
733
|
}
|
|
734
734
|
t.version === "published" && e !== "/cdn/spaces/me" && await c.set(o, y);
|
|
735
|
-
const
|
|
736
|
-
return t.token && y.data.cv && (
|
|
735
|
+
const $ = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
736
|
+
return t.token && y.data.cv && ($ && E[t.token] && E[t.token] !== y.data.cv && await this.flushCache(), E[t.token] = y.data.cv), l(y);
|
|
737
737
|
} catch (f) {
|
|
738
738
|
if (f.response && f.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
|
|
739
739
|
return console.log(
|
|
@@ -828,7 +828,7 @@ const Te = (n = {}) => {
|
|
|
828
828
|
return;
|
|
829
829
|
}
|
|
830
830
|
return { storyblokApi: new we(e) };
|
|
831
|
-
},
|
|
831
|
+
}, _e = (n) => {
|
|
832
832
|
if (typeof n != "object" || typeof n._editable > "u")
|
|
833
833
|
return {};
|
|
834
834
|
try {
|
|
@@ -844,7 +844,7 @@ const Te = (n = {}) => {
|
|
|
844
844
|
}
|
|
845
845
|
};
|
|
846
846
|
let x = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
847
|
-
const
|
|
847
|
+
const $e = (n, e, t = {}) => {
|
|
848
848
|
var r;
|
|
849
849
|
const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
|
|
850
850
|
"_storyblok"
|
|
@@ -861,7 +861,7 @@ const _e = (n, e, t = {}) => {
|
|
|
861
861
|
});
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
|
-
},
|
|
864
|
+
}, Re = (n = {}) => {
|
|
865
865
|
var e, t;
|
|
866
866
|
const {
|
|
867
867
|
bridge: r,
|
|
@@ -885,14 +885,14 @@ function Ee(n, e) {
|
|
|
885
885
|
const Ae = () => F(x);
|
|
886
886
|
export {
|
|
887
887
|
v as BlockTypes,
|
|
888
|
-
|
|
888
|
+
R as MarkTypes,
|
|
889
889
|
J as TextTypes,
|
|
890
890
|
Te as apiPlugin,
|
|
891
891
|
Ae as loadStoryblokBridge,
|
|
892
|
-
|
|
892
|
+
$e as registerStoryblokBridge,
|
|
893
893
|
Ee as renderRichText,
|
|
894
894
|
le as richTextResolver,
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
895
|
+
_e as storyblokEditable,
|
|
896
|
+
Re as storyblokInit,
|
|
897
|
+
$e as useStoryblokBridge
|
|
898
898
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "SDK to integrate Storyblok into your project using React.",
|
|
7
7
|
"author": "Storyblok",
|
|
@@ -44,14 +44,13 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@storyblok/js": "4.1.
|
|
47
|
+
"@storyblok/js": "4.1.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@babel/core": "^7.27.1",
|
|
51
51
|
"@babel/preset-env": "^7.27.2",
|
|
52
52
|
"@cypress/react": "^9.0.1",
|
|
53
53
|
"@cypress/vite-dev-server": "^6.0.3",
|
|
54
|
-
"@storyblok/eslint-config": "^0.3.0",
|
|
55
54
|
"@tsconfig/recommended": "^1.0.8",
|
|
56
55
|
"@types/node": "^22.15.18",
|
|
57
56
|
"@types/react": "19.1.4",
|
|
@@ -68,7 +67,8 @@
|
|
|
68
67
|
"typescript": "5.8.3",
|
|
69
68
|
"vite": "^6.3.5",
|
|
70
69
|
"vite-plugin-dts": "^4.5.3",
|
|
71
|
-
"vitest": "^3.1.3"
|
|
70
|
+
"vitest": "^3.1.3",
|
|
71
|
+
"@storyblok/eslint-config": "0.3.0"
|
|
72
72
|
},
|
|
73
73
|
"babel": {
|
|
74
74
|
"presets": [
|