@storyblok/vue 9.2.8 → 9.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,7 +1,22 @@
1
1
  import { SbComponentProps } from '../types';
2
- declare const _default: import('vue').DefineComponent<SbComponentProps, {
2
+ declare function __VLS_template(): {
3
+ attrs: Partial<{}>;
4
+ slots: any;
5
+ refs: {
6
+ blokRef: unknown;
7
+ };
8
+ rootEl: any;
9
+ };
10
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
11
+ declare const __VLS_component: import('vue').DefineComponent<SbComponentProps, {
3
12
  value: import('vue').Ref<any, any>;
4
13
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SbComponentProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
5
14
  blokRef: unknown;
6
15
  }, any>;
16
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
7
17
  export default _default;
18
+ type __VLS_WithTemplateSlots<T, S> = T & {
19
+ new (): {
20
+ $slots: S;
21
+ };
22
+ };
@@ -4,5 +4,5 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- (function(k,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(k=typeof globalThis<"u"?globalThis:k||self,f(k.storyblokVue={},k.Vue))})(this,function(k,f){"use strict";var re=Object.defineProperty,se=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,b=(e,t,r)=>se(e,typeof t!="symbol"?t+"":t,r);let v=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),$=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),M=function(e){return e.TEXT="text",e}({}),L=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const ne=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],oe=(e={})=>Object.keys(e).map(t=>`${t}="${e[t]}"`).join(" "),ie=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function ae(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const O=e=>Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0));function le(e,t){if(!t)return{src:e,attrs:{}};let r=0,s=0;const n={},o=[];function l(c,u,y,m,S){typeof c!="number"||c<=u||c>=y?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${u} and ${y} (inclusive)`):S.push(`${m}(${c})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(n.width=t.width,r=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),t.height&&typeof t.height=="number"&&t.height>0?(n.height=t.height,s=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),t.loading&&["lazy","eager"].includes(t.loading)&&(n.loading=t.loading),t.class&&(n.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:y,fill:m,format:S,grayscale:E,quality:I,rotate:P}=c||{};u&&l(u,0,100,"blur",o),I&&l(I,0,100,"quality",o),y&&l(y,0,100,"brightness",o),m&&o.push(`fill(${m})`),E&&o.push("grayscale()"),P&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${P})`),S&&["webp","png","jpeg"].includes(S)&&o.push(`format(${S})`)}t.srcset&&(n.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,y]=c;return`${e}/m/${u}x${y}/${o.length>0?`filters:${o.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(n.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return r>0&&s>0&&(a=`${a}${r}x${s}/`),o.length>0&&(a=`${a}filters:${o.join(":")}`),{src:a,attrs:n}}function V(e,t={},r){const s=oe(t),n=s?`${e} ${s}`:e,o=Array.isArray(r)?r.join(""):r||"";if(e){if(ne.includes(e))return`<${n}>`}else return o;return`<${n}>${o}</${e}>`}function x(e={}){const t=new Map,{renderFn:r=V,textFn:s=ae,resolvers:n={},optimizeImages:o=!1,keyedResolvers:l=!1}=e,a=r!==V,c=i=>(h,d)=>{const p=h.attrs||{};return d.render(i,p,h.children||null)},u=(i,h)=>{const{src:d,alt:p,title:g,srcset:w,sizes:_}=i.attrs||{};let T=d,R={};if(o){const{src:Fe,attrs:ze}=le(d,o);T=Fe,R=ze}const Ve={src:T,alt:p,title:g,srcset:w,sizes:_,...R};return h.render("img",O(Ve))},y=(i,h)=>{const{level:d,...p}=i.attrs||{};return h.render(`h${d}`,p,i.children)},m=(i,h)=>{var d,p,g,w;const _=h.render("img",{src:(d=i.attrs)==null?void 0:d.fallbackImage,alt:(p=i.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(g=i.attrs)==null?void 0:g.name,"data-emoji":(w=i.attrs)==null?void 0:w.emoji},_)},S=(i,h)=>h.render("pre",i.attrs||{},h.render("code",{},i.children||"")),E=(i,h=!1)=>({text:d,attrs:p},g)=>{const{class:w,id:_,...T}=p||{},R=h?{class:w,id:_,style:ie(T)||void 0}:p||{};return g.render(i,O(R),d)},I=i=>U(i),P=i=>{const{marks:h,...d}=i;if("text"in i){if(h)return h.reduce((g,w)=>I({...w,text:g}),I({...d,children:d.children}));const p=i.attrs||{};if(l){const g=t.get("txt")||0;t.set("txt",g+1),p.key=`txt-${g}`}return s(d.text,p)}return""},Z=(i,h)=>{const{linktype:d,href:p,anchor:g,...w}=i.attrs||{};let _="";switch(d){case L.ASSET:case L.URL:_=p;break;case L.EMAIL:_=`mailto:${p}`;break;case L.STORY:_=p,g&&(_=`${_}#${g}`);break;default:_=p;break}const T={...w};return _&&(T.href=_),h.render("a",T,i.text)},xe=(i,h)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=i==null?void 0:i.attrs)==null?void 0:d.body[0],id:(p=i.attrs)==null?void 0:p.id,style:"display: none"})},Be=(i,h)=>{const d={},p=h.render("tbody",{},i.children);return h.render("table",d,p)},De=(i,h)=>{const d={};return h.render("tr",d,i.children)},He=(i,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:w,..._}=i.attrs||{},T={..._};d>1&&(T.colspan=d),p>1&&(T.rowspan=p);const R=[];return g&&R.push(`width: ${g}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(T.style=R.join(" ")),h.render("td",O(T),i.children)},Ue=(i,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:w,..._}=i.attrs||{},T={..._};d>1&&(T.colspan=d),p>1&&(T.rowspan=p);const R=[];return g&&R.push(`width: ${g}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(T.style=R.join(" ")),h.render("th",O(T),i.children)},ee=new Map([[v.DOCUMENT,c("")],[v.HEADING,y],[v.PARAGRAPH,c("p")],[v.UL_LIST,c("ul")],[v.OL_LIST,c("ol")],[v.LIST_ITEM,c("li")],[v.IMAGE,u],[v.EMOJI,m],[v.CODE_BLOCK,S],[v.HR,c("hr")],[v.BR,c("br")],[v.QUOTE,c("blockquote")],[v.COMPONENT,xe],[M.TEXT,P],[$.LINK,Z],[$.ANCHOR,Z],[$.STYLED,E("span",!0)],[$.BOLD,E("strong")],[$.TEXT_STYLE,E("span",!0)],[$.ITALIC,E("em")],[$.UNDERLINE,E("u")],[$.STRIKE,E("s")],[$.CODE,E("code")],[$.SUPERSCRIPT,E("sup")],[$.SUBSCRIPT,E("sub")],[$.HIGHLIGHT,E("mark")],[v.TABLE,Be],[v.TABLE_ROW,De],[v.TABLE_CELL,He],[v.TABLE_HEADER,Ue]]),te=new Map([...ee,...Object.entries(n).map(([i,h])=>[i,h])]),Me=()=>({render:(i,h={},d)=>{if(l&&i){const p=t.get(i)||0;t.set(i,p+1),h.key=`${i}-${p}`}return r(i,h,d)},originalResolvers:ee,mergedResolvers:te});function N(i){const h=te.get(i.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const d=Me();if(i.type==="text")return h(i,d);const p=i.content?i.content.map(U):void 0;return h({...i,children:p},d)}function U(i){return i.type==="doc"?a?i.content.map(N):i.content.map(N).join(""):Array.isArray(i)?i.map(N):N(i)}return{render:U}}let F=!1;const z=[],ce=e=>new Promise((t,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}F?n():z.push(n)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const s=document.createElement("script");s.async=!0,s.src=e,s.id="storyblok-javascript-bridge",s.onerror=n=>r(n),s.onload=n=>{z.forEach(o=>o()),F=!0,t(n)},document.getElementsByTagName("head")[0].appendChild(s)});var ue=class extends Error{constructor(e){super(e),this.name="AbortError"}};function he(e,t,r){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");const s=[];let n=[],o=0,l=!1;const a=async()=>{o++;const u=s.shift();if(u)try{const m=await e(...u.args);u.resolve(m)}catch(m){u.reject(m)}const y=setTimeout(()=>{o--,s.length>0&&a(),n=n.filter(m=>m!==y)},r);n.includes(y)||n.push(y)},c=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((y,m)=>{s.push({resolve:y,reject:m,args:u}),o<t&&a()});return c.abort=()=>{l=!0,n.forEach(clearTimeout),n=[],s.forEach(u=>u.reject(()=>new ue("Throttle function aborted"))),s.length=0},c}var de=he;const q=(e="")=>e.includes("/cdn/"),pe=(e,t=25,r=1)=>({...e,per_page:t,page:r}),fe=e=>new Promise(t=>setTimeout(t,e)),ye=(e=0,t)=>Array.from({length:e},t),me=(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return ye(r,(n,o)=>o*s+e)},be=async(e,t)=>Promise.all(e.map(t)),ge=(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[]),B=(e,t,r)=>{const s=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const l=r?"":encodeURIComponent(n);let a;typeof o=="object"?a=B(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,s.push(a)}return s.join("&")},G=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var ke=class{constructor(e){b(this,"baseURL"),b(this,"timeout"),b(this,"headers"),b(this,"responseInterceptor"),b(this,"fetch"),b(this,"ejectInterceptor"),b(this,"url"),b(this,"parameters"),b(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}?${B(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:o}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:o,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}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 n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(n)})}},ve=ke;const J="SB-Agent",D={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},_e={PUBLISHED:"published"};let j={};const A={};var Te=class{constructor(e,t){b(this,"client"),b(this,"maxRetries"),b(this,"retriesDelay"),b(this,"throttle"),b(this,"accessToken"),b(this,"cache"),b(this,"resolveCounter"),b(this,"relations"),b(this,"links"),b(this,"version"),b(this,"richTextResolver"),b(this,"resolveNestedRelations"),b(this,"stringifiedStoriesCache"),b(this,"inlineAssets");let r=e.endpoint||t;if(!r){const o=e.https===!1?"http":"https";e.oauthToken?r=`${o}://${G(e.region)}/v1`:r=`${o}://${G(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([o,l])=>{s.set(o,l)}),s.has(J)||(s.set(J,D.defaultAgentName),s.set(D.defaultAgentVersion,D.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=de(this.throttledRequest.bind(this),n,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||_e.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new ve({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=A[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 q(e)?this.parseParams(t):t}makeRequest(e,t,r,s,n){const o=this.factoryParamOptions(e,pe(t,r,s));return this.cacheResponse(e,o,void 0,n)}get(e,t={},r){t||(t={});const s=`/${e}`;q(s)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,r)}async getAll(e,t={},r,s){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),l=r??o.substring(o.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,c=await this.makeRequest(o,t,n,a,s),u=c.total?Math.ceil(c.total/(c.perPage||n)):1,y=await be(me(a,u),m=>this.makeRequest(o,t,n,m+1,s));return ge([c,...y],m=>Object.values(m.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(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(o=>o.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>s(l,`${o}[${a}]`));else if(typeof n=="object")for(const l in n){const a=o?`${o}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,r),this._insertLinks(n,l,r)),s(n[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.links;s.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{s.push(c)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var s,n;let o=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],o,r);e.story?this.iterateTree(e.story,o,r):e.stories.forEach(l=>{this.iterateTree(l,o,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const n=B({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await o.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var c;try{const u=await this.throttle("get",e,t,s);if(u.status!==200)return a(u);let y={data:u.data,headers:u.headers};if((c=u.headers)!=null&&c["per-page"]&&(y=Object.assign({},y,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),y.data.story||y.data.stories){const S=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${S}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,y);const m=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(m&&A[t.token]&&A[t.token]!==y.data.cv&&await this.flushCache(),A[t.token]=y.data.cv),l(y)}catch(u){if(u.response&&u.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 fe(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(a);a(u)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return A}cacheVersion(){return A[this.accessToken]}setCacheVersion(e){this.accessToken&&(A[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(A[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(n=>t(n));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(n=>n.id===s.id)});for(const n in s)typeof s[n]=="object"&&(s[n]=t(s[n]));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}},we=Te;const Re=(e={})=>{const{apiOptions:t}=e;if(!t||!t.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 we(t)}},$e=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let K="https://app.storyblok.com/f/storyblok-v2-latest.js";const Y=(e,t,r={})=>{var s;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok"),l=o!==null&&+o===e;if(!(!n||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],a=>{var c;a&&(a.action==="input"&&((c=a.story)==null?void 0:c.id)===e?t(a.story):(a.action==="change"||a.action==="published")&&a.storyId===e&&window.location.reload())})})}},Ee=(e={})=>{var t,r;const{bridge:s,accessToken:n,use:o=[],apiOptions:l={},bridgeUrl:a}=e;l.accessToken=l.accessToken||n;const c={bridge:s,apiOptions:l};let u={};o.forEach(m=>{u={...u,...m(c)}}),a&&(K=a);const y=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return s!==!1&&y&&ce(K),u};function Se(e,t){return x(t).render(e)}const H=f.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var a;const r=e,s=f.ref();t({value:s});const n=typeof f.resolveDynamicComponent(r.blok.component)!="string",o=f.inject("VueSDKOptions"),l=f.ref((a=r.blok.component)==null?void 0:a.replace(/_/g,"-"));return!n&&o&&(o.enableFallbackComponent?(l.value=o.customFallbackComponent??"FallbackComponent",typeof f.resolveDynamicComponent(l.value)=="string"&&console.error(`Is the Fallback component "${l.value}" registered properly?`)):console.error(`Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`)),(c,u)=>(f.openBlock(),f.createBlock(f.resolveDynamicComponent(l.value),f.mergeProps({ref_key:"blokRef",ref:s},{...c.$props,...c.$attrs}),null,16))}}),Ae=e=>{var r;const t=(r=e==null?void 0:e.attrs)==null?void 0:r.body;return!Array.isArray(t)||t.length===0?[]:t.map(s=>{var n;return f.h(H,{blok:s,id:(n=e==null?void 0:e.attrs)==null?void 0:n.id},e.children)})};function W(e){const t={renderFn:f.h,textFn:f.createTextVNode,keyedResolvers:!0,resolvers:{[v.COMPONENT]:Ae,...e.resolvers}};return x(t)}const X=f.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(e){const t=e,r=f.ref(),s=()=>r.value;return f.watch([()=>t.doc,()=>t.resolvers],([n,o])=>{const{render:l}=W({resolvers:o??{}});r.value=l(n)},{immediate:!0,deep:!0}),(n,o)=>(f.openBlock(),f.createBlock(s))}}),Ce={beforeMount(e,t){if(t.value){const r=$e(t.value);Object.keys(r).length>0&&(e.setAttribute("data-blok-c",r["data-blok-c"]),e.setAttribute("data-blok-uid",r["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},Q=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
- `)};let C=null;const Ie=()=>(C||Q("useStoryblokApi"),C),Le=async(e,t={},r={})=>{const s=f.ref(null);if(r.resolveRelations=r.resolveRelations??t.resolve_relations,r.resolveLinks=r.resolveLinks??t.resolve_links,f.onMounted(()=>{s.value&&s.value.id&&Y(s.value.id,n=>s.value=n,r)}),C){const{data:n}=await C.get(`cdn/stories/${e}`,t);s.value=n.story}else Q("useStoryblok");return s},Oe={install(e,t={}){e.directive("editable",Ce),e.component("StoryblokComponent",H),e.component("StoryblokRichText",X),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",f.defineAsyncComponent(()=>Promise.resolve().then(()=>Ne)));const{storyblokApi:r}=Ee(t);C=r||null,e.provide("VueSDKOptions",t)}},je={class:"fallback-component"},Pe={class:"component"},Ne=Object.freeze(Object.defineProperty({__proto__:null,default:((e,t)=>{const r=e.__vccOpts||e;for(const[s,n]of t)r[s]=n;return r})(f.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(e){return(t,r)=>(f.openBlock(),f.createElementBlock("div",je,[f.createElementVNode("p",null,[r[0]||(r[0]=f.createTextVNode(" Component could not be found for blok ",-1)),f.createElementVNode("span",Pe,f.toDisplayString(t.blok.component),1),r[1]||(r[1]=f.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));k.BlockTypes=v,k.MarkTypes=$,k.StoryblokComponent=H,k.StoryblokRichText=X,k.StoryblokVue=Oe,k.TextTypes=M,k.apiPlugin=Re,k.renderRichText=Se,k.richTextResolver=x,k.useStoryblok=Le,k.useStoryblokApi=Ie,k.useStoryblokBridge=Y,k.useStoryblokRichText=W,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
7
+ (function(v,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(v=typeof globalThis<"u"?globalThis:v||self,d(v.storyblokVue={},v.Vue))})(this,function(v,d){"use strict";var se=Object.defineProperty,ne=(e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,k=(e,t,r)=>ne(e,typeof t!="symbol"?t+"":t,r);let _=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),$=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),V=function(e){return e.TEXT="text",e}({}),j=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const oe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ie=(e={})=>Object.keys(e).map(t=>`${t}="${e[t]}"`).join(" "),ae=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function le(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const C=e=>Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0));function ce(e,t){if(!t)return{src:e,attrs:{}};let r=0,s=0;const n={},o=[];function l(c,u,y,m,A){typeof c!="number"||c<=u||c>=y?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${u} and ${y} (inclusive)`):A.push(`${m}(${c})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(n.width=t.width,r=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),t.height&&typeof t.height=="number"&&t.height>0?(n.height=t.height,s=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),t.loading&&["lazy","eager"].includes(t.loading)&&(n.loading=t.loading),t.class&&(n.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:y,fill:m,format:A,grayscale:U,quality:R,rotate:L}=c||{};u&&l(u,0,100,"blur",o),R&&l(R,0,100,"quality",o),y&&l(y,0,100,"brightness",o),m&&o.push(`fill(${m})`),U&&o.push("grayscale()"),L&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${L})`),A&&["webp","png","jpeg"].includes(A)&&o.push(`format(${A})`)}t.srcset&&(n.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,y]=c;return`${e}/m/${u}x${y}/${o.length>0?`filters:${o.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(n.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return r>0&&s>0&&(a=`${a}${r}x${s}/`),o.length>0&&(a=`${a}filters:${o.join(":")}`),{src:a,attrs:n}}function F(e,t={},r){const s=ie(t),n=s?`${e} ${s}`:e,o=Array.isArray(r)?r.join(""):r||"";if(e){if(oe.includes(e))return`<${n}>`}else return o;return`<${n}>${o}</${e}>`}function N(e={}){const t=new Map,{renderFn:r=F,textFn:s=le,resolvers:n={},optimizeImages:o=!1,keyedResolvers:l=!1}=e,a=r!==F,c=(i={})=>{const{textAlign:h,class:p,id:f,style:b,...w}=i,g=[];return b&&g.push(b.endsWith(";")?b:`${b};`),h&&g.push(`text-align: ${h};`),C({...w,class:p,id:f,...g.length>0?{style:g.join(" ")}:{}})},u=i=>(h,p)=>{const f=c(h.attrs);return p.render(i,f,h.children||null)},y=(i,h)=>{const{src:p,alt:f,title:b,srcset:w,sizes:g}=i.attrs||{};let S=p,T={};if(o){const{src:ze,attrs:qe}=ce(p,o);S=ze,T=qe}const O={src:S,alt:f,title:b,srcset:w,sizes:g,...T};return h.render("img",C(O))},m=(i,h)=>{const{level:p,...f}=i.attrs||{},b=c(f);return h.render(`h${p}`,b,i.children)},A=(i,h)=>{var p,f,b,w;const g=h.render("img",{src:(p=i.attrs)==null?void 0:p.fallbackImage,alt:(f=i.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(b=i.attrs)==null?void 0:b.name,"data-emoji":(w=i.attrs)==null?void 0:w.emoji},g)},U=(i,h)=>h.render("pre",i.attrs||{},h.render("code",{},i.children||"")),R=(i,h=!1)=>({text:p,attrs:f},b)=>{const{class:w,id:g,...S}=f||{},T=h?{class:w,id:g,style:ae(S)||void 0}:f||{};return b.render(i,C(T),p)},L=i=>M(i),Be=i=>{const{marks:h,...p}=i;if("text"in i){if(h)return h.reduce((b,w)=>L({...w,text:b}),L({...p,children:p.children}));const f=i.attrs||{};if(l){const b=t.get("txt")||0;t.set("txt",b+1),f.key=`txt-${b}`}return s(p.text,f)}return""},ee=(i,h)=>{const{linktype:p,href:f,anchor:b,...w}=i.attrs||{};let g="";switch(p){case j.ASSET:case j.URL:g=f;break;case j.EMAIL:g=`mailto:${f}`;break;case j.STORY:g=f,b&&(g=`${g}#${b}`);break;default:g=f;break}const S={...w};return g&&(S.href=g),h.render("a",S,i.text)},De=(i,h)=>{var p,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(p=i==null?void 0:i.attrs)==null?void 0:p.body[0],id:(f=i.attrs)==null?void 0:f.id,style:"display: none"})},He=(i,h)=>{const p=c(i.attrs),f=i.children||null;return h.render("table",p,h.render("tbody",{},f))},Ue=(i,h)=>{const p=c(i.attrs);return h.render("tr",p,i.children)},Me=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...S}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...S,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("td",C(O),i.children)},Ve=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...S}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...S,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("th",C(O),i.children)},te=new Map([[_.DOCUMENT,u("")],[_.HEADING,m],[_.PARAGRAPH,u("p")],[_.UL_LIST,u("ul")],[_.OL_LIST,u("ol")],[_.LIST_ITEM,u("li")],[_.IMAGE,y],[_.EMOJI,A],[_.CODE_BLOCK,U],[_.HR,u("hr")],[_.BR,u("br")],[_.QUOTE,u("blockquote")],[_.COMPONENT,De],[V.TEXT,Be],[$.LINK,ee],[$.ANCHOR,ee],[$.STYLED,R("span",!0)],[$.BOLD,R("strong")],[$.TEXT_STYLE,R("span",!0)],[$.ITALIC,R("em")],[$.UNDERLINE,R("u")],[$.STRIKE,R("s")],[$.CODE,R("code")],[$.SUPERSCRIPT,R("sup")],[$.SUBSCRIPT,R("sub")],[$.HIGHLIGHT,R("mark")],[_.TABLE,He],[_.TABLE_ROW,Ue],[_.TABLE_CELL,Me],[_.TABLE_HEADER,Ve]]),re=new Map([...te,...Object.entries(n).map(([i,h])=>[i,h])]),Fe=()=>({render:(i,h={},p)=>{if(l&&i){const f=t.get(i)||0;t.set(i,f+1),h.key=`${i}-${f}`}return r(i,h,p)},originalResolvers:te,mergedResolvers:re});function x(i){const h=re.get(i.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const p=Fe();if(i.type==="text")return h(i,p);const f=i.content?i.content.map(M):void 0;return h({...i,children:f},p)}function M(i){return i.type==="doc"?a?i.content.map(x):i.content.map(x).join(""):Array.isArray(i)?i.map(x):x(i)}return{render:M}}let z=!1;const q=[],ue=e=>new Promise((t,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?n():q.push(n)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const s=document.createElement("script");s.async=!0,s.src=e,s.id="storyblok-javascript-bridge",s.onerror=n=>r(n),s.onload=n=>{q.forEach(o=>o()),z=!0,t(n)},document.getElementsByTagName("head")[0].appendChild(s)});var he=class extends Error{constructor(e){super(e),this.name="AbortError"}};function de(e,t,r){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");const s=[];let n=[],o=0,l=!1;const a=async()=>{o++;const u=s.shift();if(u)try{const m=await e(...u.args);u.resolve(m)}catch(m){u.reject(m)}const y=setTimeout(()=>{o--,s.length>0&&a(),n=n.filter(m=>m!==y)},r);n.includes(y)||n.push(y)},c=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((y,m)=>{s.push({resolve:y,reject:m,args:u}),o<t&&a()});return c.abort=()=>{l=!0,n.forEach(clearTimeout),n=[],s.forEach(u=>u.reject(()=>new he("Throttle function aborted"))),s.length=0},c}var pe=de;const G=(e="")=>e.includes("/cdn/"),fe=(e,t=25,r=1)=>({...e,per_page:t,page:r}),ye=e=>new Promise(t=>setTimeout(t,e)),me=(e=0,t)=>Array.from({length:e},t),be=(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return me(r,(n,o)=>o*s+e)},ge=async(e,t)=>Promise.all(e.map(t)),ke=(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[]),B=(e,t,r)=>{const s=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const l=r?"":encodeURIComponent(n);let a;typeof o=="object"?a=B(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,s.push(a)}return s.join("&")},J=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var ve=class{constructor(e){k(this,"baseURL"),k(this,"timeout"),k(this,"headers"),k(this,"responseInterceptor"),k(this,"fetch"),k(this,"ejectInterceptor"),k(this,"url"),k(this,"parameters"),k(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}?${B(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:o}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:o,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}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 n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(n)})}},_e=ve;const K="SB-Agent",D={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},we={PUBLISHED:"published"};let P={};const E={};var Te=class{constructor(e,t){k(this,"client"),k(this,"maxRetries"),k(this,"retriesDelay"),k(this,"throttle"),k(this,"accessToken"),k(this,"cache"),k(this,"resolveCounter"),k(this,"relations"),k(this,"links"),k(this,"version"),k(this,"richTextResolver"),k(this,"resolveNestedRelations"),k(this,"stringifiedStoriesCache"),k(this,"inlineAssets");let r=e.endpoint||t;if(!r){const o=e.https===!1?"http":"https";e.oauthToken?r=`${o}://${J(e.region)}/v1`:r=`${o}://${J(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(([o,l])=>{s.set(o,l)}),s.has(K)||(s.set(K,D.defaultAgentName),s.set(D.defaultAgentVersion,D.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=pe(this.throttledRequest.bind(this),n,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 _e({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 G(e)?this.parseParams(t):t}makeRequest(e,t,r,s,n){const o=this.factoryParamOptions(e,fe(t,r,s));return this.cacheResponse(e,o,void 0,n)}get(e,t={},r){t||(t={});const s=`/${e}`;G(s)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,r)}async getAll(e,t={},r,s){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),l=r??o.substring(o.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,c=await this.makeRequest(o,t,n,a,s),u=c.total?Math.ceil(c.total/(c.perPage||n)):1,y=await ge(be(a,u),m=>this.makeRequest(o,t,n,m+1,s));return ke([c,...y],m=>Object.values(m.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(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(o=>o.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>s(l,`${o}[${a}]`));else if(typeof n=="object")for(const l in n){const a=o?`${o}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,r),this._insertLinks(n,l,r)),s(n[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.links;s.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{s.push(c)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var s,n;let o=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],o,r);e.story?this.iterateTree(e.story,o,r):e.stories.forEach(l=>{this.iterateTree(l,o,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const n=B({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await o.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var c;try{const u=await this.throttle("get",e,t,s);if(u.status!==200)return a(u);let y={data:u.data,headers:u.headers};if((c=u.headers)!=null&&c["per-page"]&&(y=Object.assign({},y,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),y.data.story||y.data.stories){const A=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${A}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,y);const m=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(m&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(u){if(u.response&&u.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(a);a(u)}})}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(P[e])},getAll(){return Promise.resolve(P)},set(e,t){return P[e]=t,Promise.resolve(void 0)},flush(){return P={},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(n=>t(n));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(n=>n.id===s.id)});for(const n in s)typeof s[n]=="object"&&(s[n]=t(s[n]));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}},$e=Te;const Re=(e={})=>{const{apiOptions:t}=e;if(!t||!t.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 $e(t)}},Ae=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let Y="https://app.storyblok.com/f/storyblok-v2-latest.js";const W=(e,t,r={})=>{var s;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok"),l=o!==null&&+o===e;if(!(!n||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],a=>{var c;a&&(a.action==="input"&&((c=a.story)==null?void 0:c.id)===e?t(a.story):(a.action==="change"||a.action==="published")&&a.storyId===e&&window.location.reload())})})}},Se=(e={})=>{var t,r;const{bridge:s,accessToken:n,use:o=[],apiOptions:l={},bridgeUrl:a}=e;l.accessToken=l.accessToken||n;const c={bridge:s,apiOptions:l};let u={};o.forEach(m=>{u={...u,...m(c)}}),a&&(Y=a);const y=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return s!==!1&&y&&ue(Y),u};function Ee(e,t){return N(t).render(e)}const H=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var a;const r=e,s=d.ref();t({value:s});const n=typeof d.resolveDynamicComponent(r.blok.component)!="string",o=d.inject("VueSDKOptions"),l=d.ref((a=r.blok.component)==null?void 0:a.replace(/_/g,"-"));return!n&&o&&(o.enableFallbackComponent?(l.value=o.customFallbackComponent??"FallbackComponent",typeof d.resolveDynamicComponent(l.value)=="string"&&console.error(`Is the Fallback component "${l.value}" registered properly?`)):console.error(`Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`)),(c,u)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(l.value),d.mergeProps({ref_key:"blokRef",ref:s},{...c.$props,...c.$attrs}),d.createSlots({_:2},[d.renderList(c.$slots,(y,m)=>({name:m,fn:d.withCtx(A=>[d.renderSlot(c.$slots,m,d.normalizeProps(d.guardReactiveProps(A)))])}))]),1040))}}),Ce=e=>{var r;const t=(r=e==null?void 0:e.attrs)==null?void 0:r.body;return!Array.isArray(t)||t.length===0?[]:t.map(s=>{var n;return d.h(H,{blok:s,id:(n=e==null?void 0:e.attrs)==null?void 0:n.id},e.children)})};function X(e){const t={renderFn:d.h,textFn:d.createTextVNode,keyedResolvers:!0,resolvers:{[_.COMPONENT]:Ce,...e.resolvers}};return N(t)}const Q=d.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(e){const t=e,r=d.ref(),s=()=>r.value;return d.watch([()=>t.doc,()=>t.resolvers],([n,o])=>{const{render:l}=X({resolvers:o??{}});r.value=l(n)},{immediate:!0,deep:!0}),(n,o)=>(d.openBlock(),d.createBlock(s))}}),Ie={beforeMount(e,t){if(t.value){const r=Ae(t.value);Object.keys(r).length>0&&(e.setAttribute("data-blok-c",r["data-blok-c"]),e.setAttribute("data-blok-uid",r["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},Z=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
+ `)};let I=null;const Le=()=>(I||Z("useStoryblokApi"),I),Oe=async(e,t={},r={})=>{const s=d.ref(null);if(r.resolveRelations=r.resolveRelations??t.resolve_relations,r.resolveLinks=r.resolveLinks??t.resolve_links,d.onMounted(()=>{s.value&&s.value.id&&W(s.value.id,n=>s.value=n,r)}),I){const{data:n}=await I.get(`cdn/stories/${e}`,t);s.value=n.story}else Z("useStoryblok");return s},je={install(e,t={}){e.directive("editable",Ie),e.component("StoryblokComponent",H),e.component("StoryblokRichText",Q),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",d.defineAsyncComponent(()=>Promise.resolve().then(()=>Ne)));const{storyblokApi:r}=Se(t);I=r||null,e.provide("VueSDKOptions",t)}},Pe={class:"fallback-component"},xe={class:"component"},Ne=Object.freeze(Object.defineProperty({__proto__:null,default:((e,t)=>{const r=e.__vccOpts||e;for(const[s,n]of t)r[s]=n;return r})(d.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(e){return(t,r)=>(d.openBlock(),d.createElementBlock("div",Pe,[d.createElementVNode("p",null,[r[0]||(r[0]=d.createTextVNode(" Component could not be found for blok ",-1)),d.createElementVNode("span",xe,d.toDisplayString(t.blok.component),1),r[1]||(r[1]=d.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));v.BlockTypes=_,v.MarkTypes=$,v.StoryblokComponent=H,v.StoryblokRichText=Q,v.StoryblokVue=je,v.TextTypes=V,v.apiPlugin=Re,v.renderRichText=Ee,v.richTextResolver=N,v.useStoryblok=Oe,v.useStoryblokApi=Le,v.useStoryblokBridge=W,v.useStoryblokRichText=X,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
@@ -4,18 +4,18 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- import { defineComponent as Y, ref as P, resolveDynamicComponent as N, inject as he, createBlock as W, openBlock as X, mergeProps as de, h as Q, createTextVNode as pe, watch as fe, onMounted as ye, defineAsyncComponent as me } from "vue";
8
- var be = Object.defineProperty, ve = (e, t, r) => t in e ? be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, m = (e, t, r) => ve(e, typeof t != "symbol" ? t + "" : t, r);
9
- let g = /* @__PURE__ */ function(e) {
7
+ import { defineComponent as W, ref as x, resolveDynamicComponent as H, inject as de, createBlock as X, openBlock as Q, mergeProps as pe, createSlots as fe, renderList as ye, withCtx as me, renderSlot as ge, normalizeProps as be, guardReactiveProps as ve, h as Z, createTextVNode as ke, watch as we, onMounted as _e, defineAsyncComponent as Te } from "vue";
8
+ var $e = Object.defineProperty, Re = (e, t, r) => t in e ? $e(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, b = (e, t, r) => Re(e, typeof t != "symbol" ? t + "" : t, r);
9
+ let k = /* @__PURE__ */ function(e) {
10
10
  return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
11
- }({}), R = /* @__PURE__ */ function(e) {
11
+ }({}), T = /* @__PURE__ */ function(e) {
12
12
  return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
13
- }({}), ge = /* @__PURE__ */ function(e) {
13
+ }({}), Ae = /* @__PURE__ */ function(e) {
14
14
  return e.TEXT = "text", e;
15
- }({}), C = /* @__PURE__ */ function(e) {
15
+ }({}), O = /* @__PURE__ */ function(e) {
16
16
  return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
17
17
  }({});
18
- const ke = [
18
+ const Ee = [
19
19
  "area",
20
20
  "base",
21
21
  "br",
@@ -30,12 +30,12 @@ const ke = [
30
30
  "source",
31
31
  "track",
32
32
  "wbr"
33
- ], we = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), _e = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
34
- function Te(e) {
33
+ ], Se = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), Le = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
34
+ function Ie(e) {
35
35
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
36
36
  }
37
- const O = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
38
- function Re(e, t) {
37
+ const L = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
38
+ function Ce(e, t) {
39
39
  if (!t) return {
40
40
  src: e,
41
41
  attrs: {}
@@ -47,13 +47,13 @@ function Re(e, t) {
47
47
  }
48
48
  if (typeof t == "object") {
49
49
  if (typeof t.width == "number" && t.width > 0 ? (n.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (n.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (n.loading = t.loading), t.class && (n.class = t.class), t.filters) {
50
- const { filters: c } = t || {}, { blur: u, brightness: f, fill: y, format: $, grayscale: T, quality: A, rotate: I } = c || {};
51
- u && l(u, 0, 100, "blur", o), A && l(A, 0, 100, "quality", o), f && l(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), T && o.push("grayscale()"), I && [
50
+ const { filters: c } = t || {}, { blur: u, brightness: f, fill: y, format: $, grayscale: P, quality: _, rotate: E } = c || {};
51
+ u && l(u, 0, 100, "blur", o), _ && l(_, 0, 100, "quality", o), f && l(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), P && o.push("grayscale()"), E && [
52
52
  0,
53
53
  90,
54
54
  180,
55
55
  270
56
- ].includes(t.filters.rotate || 0) && o.push(`rotate(${I})`), $ && [
56
+ ].includes(t.filters.rotate || 0) && o.push(`rotate(${E})`), $ && [
57
57
  "webp",
58
58
  "png",
59
59
  "jpeg"
@@ -76,39 +76,47 @@ function Re(e, t) {
76
76
  attrs: n
77
77
  };
78
78
  }
79
- function F(e, t = {}, r) {
80
- const s = we(t), n = s ? `${e} ${s}` : e, o = Array.isArray(r) ? r.join("") : r || "";
79
+ function V(e, t = {}, r) {
80
+ const s = Se(t), n = s ? `${e} ${s}` : e, o = Array.isArray(r) ? r.join("") : r || "";
81
81
  if (e) {
82
- if (ke.includes(e)) return `<${n}>`;
82
+ if (Ee.includes(e)) return `<${n}>`;
83
83
  } else return o;
84
84
  return `<${n}>${o}</${e}>`;
85
85
  }
86
- function Z(e = {}) {
87
- const t = /* @__PURE__ */ new Map(), { renderFn: r = F, textFn: s = Te, resolvers: n = {}, optimizeImages: o = !1, keyedResolvers: l = !1 } = e, a = r !== F, c = (i) => (h, d) => {
88
- const p = h.attrs || {};
86
+ function ee(e = {}) {
87
+ const t = /* @__PURE__ */ new Map(), { renderFn: r = V, textFn: s = Ie, resolvers: n = {}, optimizeImages: o = !1, keyedResolvers: l = !1 } = e, a = r !== V, c = (i = {}) => {
88
+ const { textAlign: h, class: d, id: p, style: m, ...v } = i, g = [];
89
+ return m && g.push(m.endsWith(";") ? m : `${m};`), h && g.push(`text-align: ${h};`), L({
90
+ ...v,
91
+ class: d,
92
+ id: p,
93
+ ...g.length > 0 ? { style: g.join(" ") } : {}
94
+ });
95
+ }, u = (i) => (h, d) => {
96
+ const p = c(h.attrs);
89
97
  return d.render(i, p, h.children || null);
90
- }, u = (i, h) => {
91
- const { src: d, alt: p, title: b, srcset: w, sizes: v } = i.attrs || {};
92
- let k = d, _ = {};
98
+ }, f = (i, h) => {
99
+ const { src: d, alt: p, title: m, srcset: v, sizes: g } = i.attrs || {};
100
+ let R = d, w = {};
93
101
  if (o) {
94
- const { src: ce, attrs: ue } = Re(d, o);
95
- k = ce, _ = ue;
102
+ const { src: ue, attrs: he } = Ce(d, o);
103
+ R = ue, w = he;
96
104
  }
97
- const le = {
98
- src: k,
105
+ const S = {
106
+ src: R,
99
107
  alt: p,
100
- title: b,
101
- srcset: w,
102
- sizes: v,
103
- ..._
108
+ title: m,
109
+ srcset: v,
110
+ sizes: g,
111
+ ...w
104
112
  };
105
- return h.render("img", O(le));
106
- }, f = (i, h) => {
107
- const { level: d, ...p } = i.attrs || {};
108
- return h.render(`h${d}`, p, i.children);
113
+ return h.render("img", L(S));
109
114
  }, y = (i, h) => {
110
- var d, p, b, w;
111
- const v = h.render("img", {
115
+ const { level: d, ...p } = i.attrs || {}, m = c(p);
116
+ return h.render(`h${d}`, m, i.children);
117
+ }, $ = (i, h) => {
118
+ var d, p, m, v;
119
+ const g = h.render("img", {
112
120
  src: (d = i.attrs) == null ? void 0 : d.fallbackImage,
113
121
  alt: (p = i.attrs) == null ? void 0 : p.alt,
114
122
  style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
@@ -117,109 +125,119 @@ function Z(e = {}) {
117
125
  });
118
126
  return h.render("span", {
119
127
  "data-type": "emoji",
120
- "data-name": (b = i.attrs) == null ? void 0 : b.name,
121
- "data-emoji": (w = i.attrs) == null ? void 0 : w.emoji
122
- }, v);
123
- }, $ = (i, h) => h.render("pre", i.attrs || {}, h.render("code", {}, i.children || "")), T = (i, h = !1) => ({ text: d, attrs: p }, b) => {
124
- const { class: w, id: v, ...k } = p || {}, _ = h ? {
125
- class: w,
126
- id: v,
127
- style: _e(k) || void 0
128
+ "data-name": (m = i.attrs) == null ? void 0 : m.name,
129
+ "data-emoji": (v = i.attrs) == null ? void 0 : v.emoji
130
+ }, g);
131
+ }, P = (i, h) => h.render("pre", i.attrs || {}, h.render("code", {}, i.children || "")), _ = (i, h = !1) => ({ text: d, attrs: p }, m) => {
132
+ const { class: v, id: g, ...R } = p || {}, w = h ? {
133
+ class: v,
134
+ id: g,
135
+ style: Le(R) || void 0
128
136
  } : p || {};
129
- return b.render(i, O(_), d);
130
- }, A = (i) => x(i), I = (i) => {
137
+ return m.render(i, L(w), d);
138
+ }, E = (i) => N(i), se = (i) => {
131
139
  const { marks: h, ...d } = i;
132
140
  if ("text" in i) {
133
- if (h) return h.reduce((b, w) => A({
134
- ...w,
135
- text: b
136
- }), A({
141
+ if (h) return h.reduce((m, v) => E({
142
+ ...v,
143
+ text: m
144
+ }), E({
137
145
  ...d,
138
146
  children: d.children
139
147
  }));
140
148
  const p = i.attrs || {};
141
149
  if (l) {
142
- const b = t.get("txt") || 0;
143
- t.set("txt", b + 1), p.key = `txt-${b}`;
150
+ const m = t.get("txt") || 0;
151
+ t.set("txt", m + 1), p.key = `txt-${m}`;
144
152
  }
145
153
  return s(d.text, p);
146
154
  }
147
155
  return "";
148
- }, D = (i, h) => {
149
- const { linktype: d, href: p, anchor: b, ...w } = i.attrs || {};
150
- let v = "";
156
+ }, B = (i, h) => {
157
+ const { linktype: d, href: p, anchor: m, ...v } = i.attrs || {};
158
+ let g = "";
151
159
  switch (d) {
152
- case C.ASSET:
153
- case C.URL:
154
- v = p;
160
+ case O.ASSET:
161
+ case O.URL:
162
+ g = p;
155
163
  break;
156
- case C.EMAIL:
157
- v = `mailto:${p}`;
164
+ case O.EMAIL:
165
+ g = `mailto:${p}`;
158
166
  break;
159
- case C.STORY:
160
- v = p, b && (v = `${v}#${b}`);
167
+ case O.STORY:
168
+ g = p, m && (g = `${g}#${m}`);
161
169
  break;
162
170
  default:
163
- v = p;
171
+ g = p;
164
172
  break;
165
173
  }
166
- const k = { ...w };
167
- return v && (k.href = v), h.render("a", k, i.text);
168
- }, re = (i, h) => {
174
+ const R = { ...v };
175
+ return g && (R.href = g), h.render("a", R, i.text);
176
+ }, ne = (i, h) => {
169
177
  var d, p;
170
178
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
171
179
  blok: (d = i == null ? void 0 : i.attrs) == null ? void 0 : d.body[0],
172
180
  id: (p = i.attrs) == null ? void 0 : p.id,
173
181
  style: "display: none"
174
182
  });
175
- }, se = (i, h) => {
176
- const d = {}, p = h.render("tbody", {}, i.children);
177
- return h.render("table", d, p);
178
- }, ne = (i, h) => {
179
- const d = {};
180
- return h.render("tr", d, i.children);
181
183
  }, oe = (i, h) => {
182
- const { colspan: d, rowspan: p, colwidth: b, backgroundColor: w, ...v } = i.attrs || {}, k = { ...v };
183
- d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
184
- const _ = [];
185
- return b && _.push(`width: ${b}px;`), w && _.push(`background-color: ${w};`), _.length > 0 && (k.style = _.join(" ")), h.render("td", O(k), i.children);
184
+ const d = c(i.attrs), p = i.children || null;
185
+ return h.render("table", d, h.render("tbody", {}, p));
186
186
  }, ie = (i, h) => {
187
- const { colspan: d, rowspan: p, colwidth: b, backgroundColor: w, ...v } = i.attrs || {}, k = { ...v };
188
- d > 1 && (k.colspan = d), p > 1 && (k.rowspan = p);
189
- const _ = [];
190
- return b && _.push(`width: ${b}px;`), w && _.push(`background-color: ${w};`), _.length > 0 && (k.style = _.join(" ")), h.render("th", O(k), i.children);
191
- }, B = /* @__PURE__ */ new Map([
192
- [g.DOCUMENT, c("")],
193
- [g.HEADING, f],
194
- [g.PARAGRAPH, c("p")],
195
- [g.UL_LIST, c("ul")],
196
- [g.OL_LIST, c("ol")],
197
- [g.LIST_ITEM, c("li")],
198
- [g.IMAGE, u],
199
- [g.EMOJI, y],
200
- [g.CODE_BLOCK, $],
201
- [g.HR, c("hr")],
202
- [g.BR, c("br")],
203
- [g.QUOTE, c("blockquote")],
204
- [g.COMPONENT, re],
205
- [ge.TEXT, I],
206
- [R.LINK, D],
207
- [R.ANCHOR, D],
208
- [R.STYLED, T("span", !0)],
209
- [R.BOLD, T("strong")],
210
- [R.TEXT_STYLE, T("span", !0)],
211
- [R.ITALIC, T("em")],
212
- [R.UNDERLINE, T("u")],
213
- [R.STRIKE, T("s")],
214
- [R.CODE, T("code")],
215
- [R.SUPERSCRIPT, T("sup")],
216
- [R.SUBSCRIPT, T("sub")],
217
- [R.HIGHLIGHT, T("mark")],
218
- [g.TABLE, se],
219
- [g.TABLE_ROW, ne],
220
- [g.TABLE_CELL, oe],
221
- [g.TABLE_HEADER, ie]
222
- ]), M = new Map([...B, ...Object.entries(n).map(([i, h]) => [i, h])]), ae = () => ({
187
+ const d = c(i.attrs);
188
+ return h.render("tr", d, i.children);
189
+ }, ae = (i, h) => {
190
+ const { colspan: d, rowspan: p, colwidth: m, backgroundColor: v, textAlign: g, ...R } = i.attrs || {}, w = [];
191
+ m && w.push(`width: ${m}px;`), v && w.push(`background-color: ${v};`), g && w.push(`text-align: ${g};`);
192
+ const S = {
193
+ ...R,
194
+ ...d > 1 ? { colspan: d } : {},
195
+ ...p > 1 ? { rowspan: p } : {},
196
+ ...w.length > 0 ? { style: w.join(" ") } : {}
197
+ };
198
+ return h.render("td", L(S), i.children);
199
+ }, le = (i, h) => {
200
+ const { colspan: d, rowspan: p, colwidth: m, backgroundColor: v, textAlign: g, ...R } = i.attrs || {}, w = [];
201
+ m && w.push(`width: ${m}px;`), v && w.push(`background-color: ${v};`), g && w.push(`text-align: ${g};`);
202
+ const S = {
203
+ ...R,
204
+ ...d > 1 ? { colspan: d } : {},
205
+ ...p > 1 ? { rowspan: p } : {},
206
+ ...w.length > 0 ? { style: w.join(" ") } : {}
207
+ };
208
+ return h.render("th", L(S), i.children);
209
+ }, M = /* @__PURE__ */ new Map([
210
+ [k.DOCUMENT, u("")],
211
+ [k.HEADING, y],
212
+ [k.PARAGRAPH, u("p")],
213
+ [k.UL_LIST, u("ul")],
214
+ [k.OL_LIST, u("ol")],
215
+ [k.LIST_ITEM, u("li")],
216
+ [k.IMAGE, f],
217
+ [k.EMOJI, $],
218
+ [k.CODE_BLOCK, P],
219
+ [k.HR, u("hr")],
220
+ [k.BR, u("br")],
221
+ [k.QUOTE, u("blockquote")],
222
+ [k.COMPONENT, ne],
223
+ [Ae.TEXT, se],
224
+ [T.LINK, B],
225
+ [T.ANCHOR, B],
226
+ [T.STYLED, _("span", !0)],
227
+ [T.BOLD, _("strong")],
228
+ [T.TEXT_STYLE, _("span", !0)],
229
+ [T.ITALIC, _("em")],
230
+ [T.UNDERLINE, _("u")],
231
+ [T.STRIKE, _("s")],
232
+ [T.CODE, _("code")],
233
+ [T.SUPERSCRIPT, _("sup")],
234
+ [T.SUBSCRIPT, _("sub")],
235
+ [T.HIGHLIGHT, _("mark")],
236
+ [k.TABLE, oe],
237
+ [k.TABLE_ROW, ie],
238
+ [k.TABLE_CELL, ae],
239
+ [k.TABLE_HEADER, le]
240
+ ]), F = new Map([...M, ...Object.entries(n).map(([i, h]) => [i, h])]), ce = () => ({
223
241
  render: (i, h = {}, d) => {
224
242
  if (l && i) {
225
243
  const p = t.get(i) || 0;
@@ -227,28 +245,28 @@ function Z(e = {}) {
227
245
  }
228
246
  return r(i, h, d);
229
247
  },
230
- originalResolvers: B,
231
- mergedResolvers: M
248
+ originalResolvers: M,
249
+ mergedResolvers: F
232
250
  });
233
- function L(i) {
234
- const h = M.get(i.type);
251
+ function C(i) {
252
+ const h = F.get(i.type);
235
253
  if (!h)
236
254
  return console.error("<Storyblok>", `No resolver found for node type ${i.type}`), "";
237
- const d = ae();
255
+ const d = ce();
238
256
  if (i.type === "text") return h(i, d);
239
- const p = i.content ? i.content.map(x) : void 0;
257
+ const p = i.content ? i.content.map(N) : void 0;
240
258
  return h({
241
259
  ...i,
242
260
  children: p
243
261
  }, d);
244
262
  }
245
- function x(i) {
246
- return i.type === "doc" ? a ? i.content.map(L) : i.content.map(L).join("") : Array.isArray(i) ? i.map(L) : L(i);
263
+ function N(i) {
264
+ return i.type === "doc" ? a ? i.content.map(C) : i.content.map(C).join("") : Array.isArray(i) ? i.map(C) : C(i);
247
265
  }
248
- return { render: x };
266
+ return { render: N };
249
267
  }
250
- let V = !1;
251
- const z = [], $e = (e) => new Promise((t, r) => {
268
+ let z = !1;
269
+ const G = [], Oe = (e) => new Promise((t, r) => {
252
270
  if (typeof window > "u") {
253
271
  r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
254
272
  return;
@@ -258,22 +276,22 @@ const z = [], $e = (e) => new Promise((t, r) => {
258
276
  console.warn("You are not in Draft Mode or in the Visual Editor.");
259
277
  return;
260
278
  }
261
- V ? n() : z.push(n);
279
+ z ? n() : G.push(n);
262
280
  }, document.getElementById("storyblok-javascript-bridge")) {
263
281
  t(void 0);
264
282
  return;
265
283
  }
266
284
  const s = document.createElement("script");
267
285
  s.async = !0, s.src = e, s.id = "storyblok-javascript-bridge", s.onerror = (n) => r(n), s.onload = (n) => {
268
- z.forEach((o) => o()), V = !0, t(n);
286
+ G.forEach((o) => o()), z = !0, t(n);
269
287
  }, document.getElementsByTagName("head")[0].appendChild(s);
270
288
  });
271
- var Ee = class extends Error {
289
+ var je = class extends Error {
272
290
  constructor(e) {
273
291
  super(e), this.name = "AbortError";
274
292
  }
275
293
  };
276
- function Ae(e, t, r) {
294
+ function xe(e, t, r) {
277
295
  if (!Number.isFinite(t)) throw new TypeError("Expected `limit` to be a finite number");
278
296
  if (!Number.isFinite(r)) throw new TypeError("Expected `interval` to be a finite number");
279
297
  const s = [];
@@ -299,18 +317,18 @@ function Ae(e, t, r) {
299
317
  }), o < t && a();
300
318
  });
301
319
  return c.abort = () => {
302
- l = !0, n.forEach(clearTimeout), n = [], s.forEach((u) => u.reject(() => new Ee("Throttle function aborted"))), s.length = 0;
320
+ l = !0, n.forEach(clearTimeout), n = [], s.forEach((u) => u.reject(() => new je("Throttle function aborted"))), s.length = 0;
303
321
  }, c;
304
322
  }
305
- var Se = Ae;
306
- const G = (e = "") => e.includes("/cdn/"), Ie = (e, t = 25, r = 1) => ({
323
+ var Pe = xe;
324
+ const q = (e = "") => e.includes("/cdn/"), Ne = (e, t = 25, r = 1) => ({
307
325
  ...e,
308
326
  per_page: t,
309
327
  page: r
310
- }), Le = (e) => new Promise((t) => setTimeout(t, e)), Ce = (e = 0, t) => Array.from({ length: e }, t), Oe = (e = 0, t = e) => {
328
+ }), He = (e) => new Promise((t) => setTimeout(t, e)), Ue = (e = 0, t) => Array.from({ length: e }, t), De = (e = 0, t = e) => {
311
329
  const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
312
- return Ce(r, (n, o) => o * s + e);
313
- }, je = async (e, t) => Promise.all(e.map(t)), Pe = (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], []), U = (e, t, r) => {
330
+ return Ue(r, (n, o) => o * s + e);
331
+ }, Be = async (e, t) => Promise.all(e.map(t)), Me = (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], []), D = (e, t, r) => {
314
332
  const s = [];
315
333
  for (const n in e) {
316
334
  if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
@@ -318,10 +336,10 @@ const G = (e = "") => e.includes("/cdn/"), Ie = (e, t = 25, r = 1) => ({
318
336
  if (o == null) continue;
319
337
  const l = r ? "" : encodeURIComponent(n);
320
338
  let a;
321
- typeof o == "object" ? a = U(o, t ? t + encodeURIComponent(`[${l}]`) : l, Array.isArray(o)) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(o)}`, s.push(a);
339
+ typeof o == "object" ? a = D(o, t ? t + encodeURIComponent(`[${l}]`) : l, Array.isArray(o)) : a = `${t ? t + encodeURIComponent(`[${l}]`) : l}=${encodeURIComponent(o)}`, s.push(a);
322
340
  }
323
341
  return s.join("&");
324
- }, q = (e) => {
342
+ }, J = (e) => {
325
343
  const t = {
326
344
  eu: "api.storyblok.com",
327
345
  us: "api-us.storyblok.com",
@@ -331,9 +349,9 @@ const G = (e = "") => e.includes("/cdn/"), Ie = (e, t = 25, r = 1) => ({
331
349
  };
332
350
  return t[e] ?? t.eu;
333
351
  };
334
- var xe = class {
352
+ var Fe = class {
335
353
  constructor(e) {
336
- m(this, "baseURL"), m(this, "timeout"), m(this, "headers"), m(this, "responseInterceptor"), m(this, "fetch"), m(this, "ejectInterceptor"), m(this, "url"), m(this, "parameters"), m(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 = {};
354
+ b(this, "baseURL"), b(this, "timeout"), b(this, "headers"), b(this, "responseInterceptor"), b(this, "fetch"), b(this, "ejectInterceptor"), b(this, "url"), b(this, "parameters"), b(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 = {};
337
355
  }
338
356
  /**
339
357
  *
@@ -368,7 +386,7 @@ var xe = class {
368
386
  }
369
387
  async _methodHandler(e) {
370
388
  let t = `${this.baseURL}${this.url}`, r = null;
371
- e === "get" ? t = `${this.baseURL}${this.url}?${U(this.parameters)}` : r = JSON.stringify(this.parameters);
389
+ e === "get" ? t = `${this.baseURL}${this.url}?${D(this.parameters)}` : r = JSON.stringify(this.parameters);
372
390
  const s = new URL(t), n = new AbortController(), { signal: o } = n;
373
391
  let l;
374
392
  this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
@@ -422,35 +440,35 @@ var xe = class {
422
440
  s(n);
423
441
  });
424
442
  }
425
- }, Ne = xe;
426
- const J = "SB-Agent", H = {
443
+ }, Ve = Fe;
444
+ const K = "SB-Agent", U = {
427
445
  defaultAgentName: "SB-JS-CLIENT",
428
446
  defaultAgentVersion: "SB-Agent-Version",
429
447
  packageVersion: "7.0.0"
430
- }, He = {
448
+ }, ze = {
431
449
  PUBLISHED: "published"
432
450
  };
433
451
  let j = {};
434
- const E = {};
435
- var Ue = class {
452
+ const A = {};
453
+ var Ge = class {
436
454
  /**
437
455
  *
438
456
  * @param config ISbConfig interface
439
457
  * @param pEndpoint string, optional
440
458
  */
441
459
  constructor(e, t) {
442
- m(this, "client"), m(this, "maxRetries"), m(this, "retriesDelay"), m(this, "throttle"), m(this, "accessToken"), m(this, "cache"), m(this, "resolveCounter"), m(this, "relations"), m(this, "links"), m(this, "version"), m(this, "richTextResolver"), m(this, "resolveNestedRelations"), m(this, "stringifiedStoriesCache"), m(this, "inlineAssets");
460
+ b(this, "client"), b(this, "maxRetries"), b(this, "retriesDelay"), b(this, "throttle"), b(this, "accessToken"), b(this, "cache"), b(this, "resolveCounter"), b(this, "relations"), b(this, "links"), b(this, "version"), b(this, "richTextResolver"), b(this, "resolveNestedRelations"), b(this, "stringifiedStoriesCache"), b(this, "inlineAssets");
443
461
  let r = e.endpoint || t;
444
462
  if (!r) {
445
463
  const o = e.https === !1 ? "http" : "https";
446
- e.oauthToken ? r = `${o}://${q(e.region)}/v1` : r = `${o}://${q(e.region)}/v2`;
464
+ e.oauthToken ? r = `${o}://${J(e.region)}/v1` : r = `${o}://${J(e.region)}/v2`;
447
465
  }
448
466
  const s = new Headers();
449
467
  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(([o, l]) => {
450
468
  s.set(o, l);
451
- }), s.has(J) || (s.set(J, H.defaultAgentName), s.set(H.defaultAgentVersion, H.packageVersion));
469
+ }), s.has(K) || (s.set(K, U.defaultAgentName), s.set(U.defaultAgentVersion, U.packageVersion));
452
470
  let n = 5;
453
- e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Se(this.throttledRequest.bind(this), n, 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 || He.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Ne({
471
+ e.oauthToken && (s.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Pe(this.throttledRequest.bind(this), n, 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 || ze.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Ve({
454
472
  baseURL: r,
455
473
  timeout: e.timeout || 0,
456
474
  headers: s,
@@ -459,27 +477,27 @@ var Ue = class {
459
477
  });
460
478
  }
461
479
  parseParams(e) {
462
- 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;
480
+ return e.token || (e.token = this.getToken()), e.cv || (e.cv = A[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
463
481
  }
464
482
  factoryParamOptions(e, t) {
465
- return G(e) ? this.parseParams(t) : t;
483
+ return q(e) ? this.parseParams(t) : t;
466
484
  }
467
485
  makeRequest(e, t, r, s, n) {
468
- const o = this.factoryParamOptions(e, Ie(t, r, s));
486
+ const o = this.factoryParamOptions(e, Ne(t, r, s));
469
487
  return this.cacheResponse(e, o, void 0, n);
470
488
  }
471
489
  get(e, t = {}, r) {
472
490
  t || (t = {});
473
491
  const s = `/${e}`;
474
- G(s) && (t.version = t.version || this.version);
492
+ q(s) && (t.version = t.version || this.version);
475
493
  const n = this.factoryParamOptions(s, t);
476
494
  return this.cacheResponse(s, n, void 0, r);
477
495
  }
478
496
  async getAll(e, t = {}, r, s) {
479
497
  const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`.replace(/\/$/, ""), l = r ?? o.substring(o.lastIndexOf("/") + 1);
480
498
  t.version = t.version || this.version;
481
- const a = 1, c = await this.makeRequest(o, t, n, a, s), u = c.total ? Math.ceil(c.total / (c.perPage || n)) : 1, f = await je(Oe(a, u), (y) => this.makeRequest(o, t, n, y + 1, s));
482
- return Pe([c, ...f], (y) => Object.values(y.data[l]));
499
+ const a = 1, c = await this.makeRequest(o, t, n, a, s), u = c.total ? Math.ceil(c.total / (c.perPage || n)) : 1, f = await Be(De(a, u), (y) => this.makeRequest(o, t, n, y + 1, s));
500
+ return Me([c, ...f], (y) => Object.values(y.data[l]));
483
501
  }
484
502
  post(e, t = {}, r) {
485
503
  const s = `/${e}`;
@@ -659,7 +677,7 @@ var Ue = class {
659
677
  }), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
660
678
  }
661
679
  async cacheResponse(e, t, r, s) {
662
- const n = U({
680
+ const n = D({
663
681
  url: e,
664
682
  params: t
665
683
  }), o = this.cacheProvider();
@@ -685,10 +703,10 @@ var Ue = class {
685
703
  }
686
704
  t.version === "published" && e !== "/cdn/spaces/me" && await o.set(n, f);
687
705
  const y = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
688
- return t.token && f.data.cv && (y && E[t.token] && E[t.token] !== f.data.cv && await this.flushCache(), E[t.token] = f.data.cv), l(f);
706
+ return t.token && f.data.cv && (y && A[t.token] && A[t.token] !== f.data.cv && await this.flushCache(), A[t.token] = f.data.cv), l(f);
689
707
  } catch (u) {
690
708
  if (u.response && u.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
691
- return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await Le(this.retriesDelay), this.cacheResponse(e, t, r).then(l).catch(a);
709
+ return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await He(this.retriesDelay), this.cacheResponse(e, t, r).then(l).catch(a);
692
710
  a(u);
693
711
  }
694
712
  });
@@ -697,16 +715,16 @@ var Ue = class {
697
715
  return this.client.setFetchOptions(s), this.client[e](t, r);
698
716
  }
699
717
  cacheVersions() {
700
- return E;
718
+ return A;
701
719
  }
702
720
  cacheVersion() {
703
- return E[this.accessToken];
721
+ return A[this.accessToken];
704
722
  }
705
723
  setCacheVersion(e) {
706
- this.accessToken && (E[this.accessToken] = e);
724
+ this.accessToken && (A[this.accessToken] = e);
707
725
  }
708
726
  clearCacheVersion() {
709
- this.accessToken && (E[this.accessToken] = 0);
727
+ this.accessToken && (A[this.accessToken] = 0);
710
728
  }
711
729
  cacheProvider() {
712
730
  switch (this.cache.type) {
@@ -762,8 +780,8 @@ var Ue = class {
762
780
  };
763
781
  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;
764
782
  }
765
- }, De = Ue;
766
- const Ke = (e = {}) => {
783
+ }, qe = Ge;
784
+ const tt = (e = {}) => {
767
785
  const { apiOptions: t } = e;
768
786
  if (!t || !t.accessToken) {
769
787
  console.error(
@@ -771,8 +789,8 @@ const Ke = (e = {}) => {
771
789
  );
772
790
  return;
773
791
  }
774
- return { storyblokApi: new De(t) };
775
- }, Be = (e) => {
792
+ return { storyblokApi: new qe(t) };
793
+ }, Je = (e) => {
776
794
  if (typeof e != "object" || typeof e._editable > "u")
777
795
  return {};
778
796
  try {
@@ -787,8 +805,8 @@ const Ke = (e = {}) => {
787
805
  return {};
788
806
  }
789
807
  };
790
- let K = "https://app.storyblok.com/f/storyblok-v2-latest.js";
791
- const Me = (e, t, r = {}) => {
808
+ let Y = "https://app.storyblok.com/f/storyblok-v2-latest.js";
809
+ const Ke = (e, t, r = {}) => {
792
810
  var s;
793
811
  const n = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
794
812
  "_storyblok"
@@ -805,7 +823,7 @@ const Me = (e, t, r = {}) => {
805
823
  });
806
824
  });
807
825
  }
808
- }, Fe = (e = {}) => {
826
+ }, Ye = (e = {}) => {
809
827
  var t, r;
810
828
  const {
811
829
  bridge: s,
@@ -819,130 +837,137 @@ const Me = (e, t, r = {}) => {
819
837
  let u = {};
820
838
  o.forEach((y) => {
821
839
  u = { ...u, ...y(c) };
822
- }), a && (K = a);
840
+ }), a && (Y = a);
823
841
  const f = !(typeof window > "u") && ((r = (t = window.location) == null ? void 0 : t.search) == null ? void 0 : r.includes("_storyblok_tk"));
824
- return s !== !1 && f && $e(K), u;
842
+ return s !== !1 && f && Oe(Y), u;
825
843
  };
826
- function Ye(e, t) {
827
- return Z(t).render(e);
844
+ function rt(e, t) {
845
+ return ee(t).render(e);
828
846
  }
829
- const ee = /* @__PURE__ */ Y({
847
+ const te = /* @__PURE__ */ W({
830
848
  __name: "StoryblokComponent",
831
849
  props: {
832
850
  blok: {}
833
851
  },
834
852
  setup(e, { expose: t }) {
835
853
  var a;
836
- const r = e, s = P();
854
+ const r = e, s = x();
837
855
  t({
838
856
  value: s
839
857
  });
840
- const n = typeof N(r.blok.component) != "string", o = he("VueSDKOptions"), l = P((a = r.blok.component) == null ? void 0 : a.replace(/_/g, "-"));
841
- return !n && o && (o.enableFallbackComponent ? (l.value = o.customFallbackComponent ?? "FallbackComponent", typeof N(l.value) == "string" && console.error(
858
+ const n = typeof H(r.blok.component) != "string", o = de("VueSDKOptions"), l = x((a = r.blok.component) == null ? void 0 : a.replace(/_/g, "-"));
859
+ return !n && o && (o.enableFallbackComponent ? (l.value = o.customFallbackComponent ?? "FallbackComponent", typeof H(l.value) == "string" && console.error(
842
860
  `Is the Fallback component "${l.value}" registered properly?`
843
861
  )) : console.error(
844
862
  `Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`
845
- )), (c, u) => (X(), W(N(l.value), de({
863
+ )), (c, u) => (Q(), X(H(l.value), pe({
846
864
  ref_key: "blokRef",
847
865
  ref: s
848
- }, { ...c.$props, ...c.$attrs }), null, 16));
849
- }
850
- }), Ve = (e) => {
866
+ }, { ...c.$props, ...c.$attrs }), fe({ _: 2 }, [
867
+ ye(c.$slots, (f, y) => ({
868
+ name: y,
869
+ fn: me(($) => [
870
+ ge(c.$slots, y, be(ve($)))
871
+ ])
872
+ }))
873
+ ]), 1040));
874
+ }
875
+ }), We = (e) => {
851
876
  var r;
852
877
  const t = (r = e == null ? void 0 : e.attrs) == null ? void 0 : r.body;
853
878
  return !Array.isArray(t) || t.length === 0 ? [] : t.map(
854
879
  (s) => {
855
880
  var n;
856
- return Q(ee, {
881
+ return Z(te, {
857
882
  blok: s,
858
883
  id: (n = e == null ? void 0 : e.attrs) == null ? void 0 : n.id
859
884
  }, e.children);
860
885
  }
861
886
  );
862
887
  };
863
- function ze(e) {
888
+ function Xe(e) {
864
889
  const t = {
865
- renderFn: Q,
890
+ renderFn: Z,
866
891
  // TODO: Check why this changed.
867
892
  // @ts-expect-error - createTextVNode types has been recently changed.
868
- textFn: pe,
893
+ textFn: ke,
869
894
  keyedResolvers: !0,
870
895
  resolvers: {
871
- [g.COMPONENT]: Ve,
896
+ [k.COMPONENT]: We,
872
897
  ...e.resolvers
873
898
  }
874
899
  };
875
- return Z(t);
900
+ return ee(t);
876
901
  }
877
- const Ge = /* @__PURE__ */ Y({
902
+ const Qe = /* @__PURE__ */ W({
878
903
  __name: "StoryblokRichText",
879
904
  props: {
880
905
  doc: {},
881
906
  resolvers: {}
882
907
  },
883
908
  setup(e) {
884
- const t = e, r = P(), s = () => r.value;
885
- return fe([() => t.doc, () => t.resolvers], ([n, o]) => {
886
- const { render: l } = ze({
909
+ const t = e, r = x(), s = () => r.value;
910
+ return we([() => t.doc, () => t.resolvers], ([n, o]) => {
911
+ const { render: l } = Xe({
887
912
  resolvers: o ?? {}
888
913
  });
889
914
  r.value = l(n);
890
915
  }, {
891
916
  immediate: !0,
892
917
  deep: !0
893
- }), (n, o) => (X(), W(s));
918
+ }), (n, o) => (Q(), X(s));
894
919
  }
895
- }), qe = {
920
+ }), Ze = {
896
921
  beforeMount(e, t) {
897
922
  if (t.value) {
898
- const r = Be(t.value);
923
+ const r = Je(t.value);
899
924
  Object.keys(r).length > 0 && (e.setAttribute("data-blok-c", r["data-blok-c"]), e.setAttribute("data-blok-uid", r["data-blok-uid"]), e.classList.add("storyblok__outline"));
900
925
  }
901
926
  }
902
- }, te = (e) => {
927
+ }, re = (e) => {
903
928
  console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
904
929
  `);
905
930
  };
906
- let S = null;
907
- const We = () => (S || te("useStoryblokApi"), S), Xe = async (e, t = {}, r = {}) => {
908
- const s = P(null);
909
- if (r.resolveRelations = r.resolveRelations ?? t.resolve_relations, r.resolveLinks = r.resolveLinks ?? t.resolve_links, ye(() => {
910
- s.value && s.value.id && Me(
931
+ let I = null;
932
+ const st = () => (I || re("useStoryblokApi"), I), nt = async (e, t = {}, r = {}) => {
933
+ const s = x(null);
934
+ if (r.resolveRelations = r.resolveRelations ?? t.resolve_relations, r.resolveLinks = r.resolveLinks ?? t.resolve_links, _e(() => {
935
+ s.value && s.value.id && Ke(
911
936
  s.value.id,
912
937
  (n) => s.value = n,
913
938
  r
914
939
  );
915
- }), S) {
916
- const { data: n } = await S.get(
940
+ }), I) {
941
+ const { data: n } = await I.get(
917
942
  `cdn/stories/${e}`,
918
943
  t
919
944
  );
920
945
  s.value = n.story;
921
946
  } else
922
- te("useStoryblok");
947
+ re("useStoryblok");
923
948
  return s;
924
- }, Qe = {
949
+ }, ot = {
925
950
  install(e, t = {}) {
926
- e.directive("editable", qe), e.component("StoryblokComponent", ee), e.component("StoryblokRichText", Ge), t.enableFallbackComponent && !t.customFallbackComponent && e.component(
951
+ e.directive("editable", Ze), e.component("StoryblokComponent", te), e.component("StoryblokRichText", Qe), t.enableFallbackComponent && !t.customFallbackComponent && e.component(
927
952
  "FallbackComponent",
928
- me(() => import("./FallbackComponent-vpkAikkq.js"))
953
+ Te(() => import("./FallbackComponent-vpkAikkq.js"))
929
954
  );
930
- const { storyblokApi: r } = Fe(t);
931
- S = r || null, e.provide("VueSDKOptions", t);
955
+ const { storyblokApi: r } = Ye(t);
956
+ I = r || null, e.provide("VueSDKOptions", t);
932
957
  }
933
958
  };
934
959
  export {
935
- g as BlockTypes,
936
- R as MarkTypes,
937
- ee as StoryblokComponent,
938
- Ge as StoryblokRichText,
939
- Qe as StoryblokVue,
940
- ge as TextTypes,
941
- Ke as apiPlugin,
942
- Ye as renderRichText,
943
- Z as richTextResolver,
944
- Xe as useStoryblok,
945
- We as useStoryblokApi,
946
- Me as useStoryblokBridge,
947
- ze as useStoryblokRichText
960
+ k as BlockTypes,
961
+ T as MarkTypes,
962
+ te as StoryblokComponent,
963
+ Qe as StoryblokRichText,
964
+ ot as StoryblokVue,
965
+ Ae as TextTypes,
966
+ tt as apiPlugin,
967
+ rt as renderRichText,
968
+ ee as richTextResolver,
969
+ nt as useStoryblok,
970
+ st as useStoryblokApi,
971
+ Ke as useStoryblokBridge,
972
+ Xe as useStoryblokRichText
948
973
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
3
  "type": "module",
4
- "version": "9.2.8",
4
+ "version": "9.3.1",
5
5
  "description": "SDK to integrate Storyblok into your project using Vue.",
6
6
  "author": "Storyblok",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "vue": ">=3.4"
32
32
  },
33
33
  "dependencies": {
34
- "@storyblok/js": "4.2.7"
34
+ "@storyblok/js": "4.3.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rollup/plugin-typescript": "^12.1.2",