@storyblok/vue 8.2.2 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -66
- package/dist/index.d.ts +1 -1
- package/dist/storyblok-vue.js +2 -25
- package/dist/storyblok-vue.mjs +619 -950
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -445,72 +445,6 @@ If you want to use the `useStoryblokRichText` composable, you can pass the `reso
|
|
|
445
445
|
</template>
|
|
446
446
|
```
|
|
447
447
|
|
|
448
|
-
### Legacy Rich Text Resolver
|
|
449
|
-
|
|
450
|
-
> [!WARNING]
|
|
451
|
-
> The legacy `richTextResolver` is soon to be deprecated. We recommend migrating to the new approach described above instead.
|
|
452
|
-
|
|
453
|
-
You can easily render rich text by using the `renderRichText` function that comes with `@storyblok/vue` and a Vue computed property:
|
|
454
|
-
|
|
455
|
-
```html
|
|
456
|
-
<template>
|
|
457
|
-
<div v-html="articleContent"></div>
|
|
458
|
-
</template>
|
|
459
|
-
|
|
460
|
-
<script setup>
|
|
461
|
-
import { computed } from "vue";
|
|
462
|
-
import { renderRichText } from "@storyblok/vue";
|
|
463
|
-
|
|
464
|
-
const articleContent = computed(() => renderRichText(blok.articleContent));
|
|
465
|
-
</script>
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
You can set a **custom Schema and component resolver globally** at init time by using the `richText` init option:
|
|
469
|
-
|
|
470
|
-
```js
|
|
471
|
-
import { RichTextSchema, StoryblokVue } from "@storyblok/vue";
|
|
472
|
-
import cloneDeep from "clone-deep";
|
|
473
|
-
|
|
474
|
-
const mySchema = cloneDeep(RichTextSchema); // you can make a copy of the default RichTextSchema
|
|
475
|
-
// ... and edit the nodes and marks, or add your own.
|
|
476
|
-
// Check the base RichTextSchema source here https://github.com/storyblok/storyblok-js-client/blob/master/source/schema.js
|
|
477
|
-
|
|
478
|
-
app.use(StoryblokVue, {
|
|
479
|
-
accessToken: "YOUR_ACCESS_TOKEN",
|
|
480
|
-
use: [apiPlugin],
|
|
481
|
-
richText: {
|
|
482
|
-
schema: mySchema,
|
|
483
|
-
resolver: (component, blok) => {
|
|
484
|
-
switch (component) {
|
|
485
|
-
case "my-custom-component":
|
|
486
|
-
return `<div class="my-component-class">${blok.text}</div>`;
|
|
487
|
-
default:
|
|
488
|
-
return "Resolver not defined";
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
},
|
|
492
|
-
});
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
You can also set a **custom Schema and component resolver only once** by passing the options as the second parameter to `renderRichText` function:
|
|
496
|
-
|
|
497
|
-
```js
|
|
498
|
-
import { renderRichText } from "@storyblok/vue";
|
|
499
|
-
|
|
500
|
-
renderRichText(blok.richTextField, {
|
|
501
|
-
schema: mySchema,
|
|
502
|
-
resolver: (component, blok) => {
|
|
503
|
-
switch (component) {
|
|
504
|
-
case "my-custom-component":
|
|
505
|
-
return `<div class="my-component-class">${blok.text}</div>`;
|
|
506
|
-
break;
|
|
507
|
-
default:
|
|
508
|
-
return `Component ${component} not found`;
|
|
509
|
-
}
|
|
510
|
-
},
|
|
511
|
-
});
|
|
512
|
-
```
|
|
513
|
-
|
|
514
448
|
## Compatibility
|
|
515
449
|
|
|
516
450
|
This plugin is for Vue 3. Thus, it supports the [same browsers as Vue 3](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0038-vue3-ie11-support.md). In short: all modern browsers, dropping IE support.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { default as StoryblokComponent } from './components/StoryblokComponent.v
|
|
|
4
4
|
export { default as StoryblokRichText } from './components/StoryblokRichText.vue';
|
|
5
5
|
export * from './composables/useStoryblokRichText';
|
|
6
6
|
export * from './types';
|
|
7
|
-
export { apiPlugin, BlockTypes, MarkTypes, renderRichText,
|
|
7
|
+
export { apiPlugin, BlockTypes, MarkTypes, renderRichText, richTextResolver, type StoryblokRichTextDocumentNode, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeResolver, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, type StoryblokRichTextResolvers, TextTypes, useStoryblokBridge, } from '@storyblok/js';
|
|
8
8
|
export declare const useStoryblokApi: () => StoryblokClient;
|
|
9
9
|
export declare const useStoryblok: (url: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => Promise<Ref<ISbStoryData<import('@storyblok/js').StoryblokComponentType<string> & {
|
|
10
10
|
[index: string]: any;
|
package/dist/storyblok-vue.js
CHANGED
|
@@ -4,28 +4,5 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using Vue.
|
|
5
5
|
* author: Storyblok
|
|
6
6
|
*/
|
|
7
|
-
(function(b,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],m):(b=typeof globalThis<"u"?globalThis:b||self,m(b.storyblokVue={},b.Vue))})(this,function(b,m){"use strict";let F=!1;const V=[],se=r=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}F?o():V.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=r,s.id="storyblok-javascript-bridge",s.onerror=o=>t(o),s.onload=o=>{V.forEach(n=>n()),F=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(s)});var oe=Object.defineProperty,ne=(r,e,t)=>e in r?oe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,y=(r,e,t)=>ne(r,typeof e!="symbol"?e+"":e,t);class ae extends Error{constructor(e){super(e),this.name="AbortError"}}function ie(r,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 s=[];let o=[],n=0,a=!1;const i=async()=>{n++;const h=s.shift();if(h)try{const p=await r(...h.args);h.resolve(p)}catch(p){h.reject(p)}const u=setTimeout(()=>{n--,s.length>0&&i(),o=o.filter(p=>p!==u)},t);o.includes(u)||o.push(u)},l=(...h)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((u,p)=>{s.push({resolve:u,reject:p,args:h}),n<e&&i()});return l.abort=()=>{a=!0,o.forEach(clearTimeout),o=[],s.forEach(h=>h.reject(()=>new ae("Throttle function aborted"))),s.length=0},l}class L{constructor(){y(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),y(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),y(this,"delay",e=>new Promise(t=>setTimeout(t,e))),y(this,"arrayFrom",(e=0,t)=>Array.from({length:e},t)),y(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,o=e<t?1:-1;return this.arrayFrom(s,(n,a)=>a*o+e)}),y(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),y(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,o)=>[...s,...o],[])),y(this,"escapeHTML",function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},s=/[&<>"']/g,o=new RegExp(s.source);return e&&o.test(e)?e.replace(s,n=>t[n]):e})}stringify(e,t,s){const o=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const a=e[n];if(a==null)continue;const i=s?"":encodeURIComponent(n);let l;typeof a=="object"?l=this.stringify(a,t?t+encodeURIComponent(`[${i}]`):i,Array.isArray(a)):l=`${t?t+encodeURIComponent(`[${i}]`):i}=${encodeURIComponent(a)}`,o.push(l)}return o.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",o="app.storyblokchina.cn",n="api-ap.storyblok.com",a="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return o;case"ap":return n;case"ca":return a;default:return t}}}const le=function(r,e){const t={};for(const s in r){const o=r[s];e.includes(s)&&o!==null&&(t[s]=o)}return t},ce=r=>r==="email",he=()=>({singleTag:"hr"}),ue=()=>({tag:"blockquote"}),de=()=>({tag:"ul"}),pe=r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),ge=()=>({singleTag:"br"}),fe=r=>({tag:`h${r.attrs.level}`}),me=r=>({singleTag:[{tag:"img",attrs:le(r.attrs,["src","alt","title"])}]}),ye=()=>({tag:"li"}),be=()=>({tag:"ol"}),ke=()=>({tag:"p"}),ve=r=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":r.attrs.name,emoji:r.attrs.emoji}}]}),Te=()=>({tag:"b"}),$e=()=>({tag:"s"}),we=()=>({tag:"u"}),_e=()=>({tag:"strong"}),Re=()=>({tag:"code"}),Se=()=>({tag:"i"}),Ee=r=>{if(!r.attrs)return{tag:""};const e=new L().escapeHTML,t={...r.attrs},{linktype:s="url"}=r.attrs;if(delete t.linktype,t.href&&(t.href=e(r.attrs.href||"")),ce(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const o in t.custom)t[o]=t.custom[o];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},je=r=>({tag:[{tag:"span",attrs:r.attrs}]}),Ce=()=>({tag:"sub"}),Ae=()=>({tag:"sup"}),Ie=r=>({tag:[{tag:"span",attrs:r.attrs}]}),xe=r=>{var e;return(e=r.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${r.attrs.color};`}}]}:{tag:""}},Oe=r=>{var e;return(e=r.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${r.attrs.color}`}}]}:{tag:""}},q={nodes:{horizontal_rule:he,blockquote:ue,bullet_list:de,code_block:pe,hard_break:ge,heading:fe,image:me,list_item:ye,ordered_list:be,paragraph:ke,emoji:ve},marks:{bold:Te,strike:$e,underline:we,strong:_e,code:Re,italic:Se,link:Ee,styled:je,subscript:Ce,superscript:Ae,anchor:Ie,highlight:xe,textStyle:Oe}},Le=function(r){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,s=new RegExp(t.source);return r&&s.test(r)?r.replace(t,o=>e[o]):r};let G=!1,I=class{constructor(r){y(this,"marks"),y(this,"nodes"),r||(r=q),this.marks=r.marks||[],this.nodes=r.nodes||[]}addNode(r,e){this.nodes[r]=e}addMark(r,e){this.marks[r]=e}render(r,e={optimizeImages:!1},t=!0){if(!G&&t&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),G=!0),r&&r.content&&Array.isArray(r.content)){let s="";return r.content.forEach(o=>{s+=this.renderNode(o)}),e.optimizeImages?this.optimizeImages(s,e.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
|
|
8
|
-
|
|
9
|
-
ISbRichtext:
|
|
10
|
-
content?: ISbRichtext[]
|
|
11
|
-
marks?: ISbRichtext[]
|
|
12
|
-
attrs?: any
|
|
13
|
-
text?: string
|
|
14
|
-
type: string
|
|
15
|
-
|
|
16
|
-
Example:
|
|
17
|
-
{
|
|
18
|
-
content: [
|
|
19
|
-
{
|
|
20
|
-
content: [
|
|
21
|
-
{
|
|
22
|
-
text: 'Hello World',
|
|
23
|
-
type: 'text'
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
type: 'paragraph'
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
type: 'doc'
|
|
30
|
-
}`),""}optimizeImages(r,e){let t=0,s=0,o="",n="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(o+=`width="${e.width}" `,t=e.width),typeof e.height=="number"&&e.height>0&&(o+=`height="${e.height}" `,s=e.height),(e.loading==="lazy"||e.loading==="eager")&&(o+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(o+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(n+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(n+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-F]{6}/gi)||e.filters.fill==="transparent")&&(n+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(n+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(n+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(n+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(n+=`:rotate(${e.filters.rotate})`),n.length>0&&(n=`/filters${n}`))),o.length>0&&(r=r.replace(/<img/g,`<img ${o.trim()}`));const a=t>0||s>0||n.length>0?`${t}x${s}${n}`:"";return r=r.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${a}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(r=r.replace(/<img.*?src=["|'](.*?)["|']/g,i=>{var l,h;const u=i.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(u&&u.length>0){const p={srcset:(l=e.srcset)==null?void 0:l.map(w=>{if(typeof w=="number")return`//${u}/m/${w}x0${n} ${w}w`;if(typeof w=="object"&&w.length===2){let _=0,A=0;return typeof w[0]=="number"&&(_=w[0]),typeof w[1]=="number"&&(A=w[1]),`//${u}/m/${_}x${A}${n} ${_}w`}return""}).join(", "),sizes:(h=e.sizes)==null?void 0:h.map(w=>w).join(", ")};let T="";return p.srcset&&(T+=`srcset="${p.srcset}" `),p.sizes&&(T+=`sizes="${p.sizes}" `),i.replace(/<img/g,`<img ${T.trim()}`)}return i})),r}renderNode(r){const e=[];r.marks&&r.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&o.tag!==""&&e.push(this.renderOpeningTag(o.tag))});const t=this.getMatchingNode(r);return t&&t.tag&&e.push(this.renderOpeningTag(t.tag)),r.content?r.content.forEach(s=>{e.push(this.renderNode(s))}):r.text?e.push(Le(r.text)):t&&t.singleTag?e.push(this.renderTag(t.singleTag," /")):t&&t.html?e.push(t.html):r.type==="emoji"&&e.push(this.renderEmoji(r)),t&&t.tag&&e.push(this.renderClosingTag(t.tag)),r.marks&&r.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&o.tag!==""&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(r,e){return r.constructor===String?`<${r}${e}>`:r.map(t=>{if(t.constructor===String)return`<${t}${e}>`;{let s=`<${t.tag}`;if(t.attrs){for(const o in t.attrs)if(Object.prototype.hasOwnProperty.call(t.attrs,o)){const n=t.attrs[o];n!==null&&(s+=` ${o}="${n}"`)}}return`${s}${e}>`}}).join("")}renderOpeningTag(r){return this.renderTag(r,"")}renderClosingTag(r){return r.constructor===String?`</${r}>`:r.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(r){const e=this.nodes[r.type];if(typeof e=="function")return e(r)}getMatchingMark(r){const e=this.marks[r.type];if(typeof e=="function")return e(r)}renderEmoji(r){if(r.attrs.emoji)return r.attrs.emoji;const e=[{tag:"img",attrs:{src:r.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}};class Pe{constructor(e){y(this,"baseURL"),y(this,"timeout"),y(this,"headers"),y(this,"responseInterceptor"),y(this,"fetch"),y(this,"ejectInterceptor"),y(this,"url"),y(this,"parameters"),y(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=[],s={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(o=>{s.data=o});for(const o of e.headers.entries())t[o[0]]=o[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const l=new L;t=`${this.baseURL}${this.url}?${l.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const o=new URL(t),n=new AbortController,{signal:a}=n;let i;this.timeout&&(i=setTimeout(()=>n.abort(),this.timeout));try{const l=await this.fetch(`${o}`,{method:e,headers:this.headers,body:s,signal:a,...this.fetchOptions});this.timeout&&clearTimeout(i);const h=await this._responseHandler(l);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(h)):this._statusHandler(h)}catch(l){return{message:l}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,o)=>{if(t.test(`${e.status}`))return s(e);const n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};o(n)})}}const K="SB-Agent",D={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let P={};const C={};class Ne{constructor(e,t){y(this,"client"),y(this,"maxRetries"),y(this,"retriesDelay"),y(this,"throttle"),y(this,"accessToken"),y(this,"cache"),y(this,"helpers"),y(this,"resolveCounter"),y(this,"relations"),y(this,"links"),y(this,"richTextResolver"),y(this,"resolveNestedRelations"),y(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const a=new L().getRegionURL,i=e.https===!1?"http":"https";e.oauthToken?s=`${i}://${a(e.region)}/v1`:s=`${i}://${a(e.region)}/v2`}const o=new Headers;o.set("Content-Type","application/json"),o.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([a,i])=>{o.set(a,i)}),o.has(K)||(o.set(K,D.defaultAgentName),o.set(D.defaultAgentVersion,D.packageVersion));let n=5;e.oauthToken&&(o.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new I(e.richTextSchema):this.richTextResolver=new I,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=ie(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new L,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new Pe({baseURL:s,timeout:e.timeout||0,headers:o,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(o=>{s+=e(o.component,o)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=C[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 this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,o,n){const a=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,o));return this.cacheResponse(e,a,void 0,n)}get(e,t,s){t||(t={});const o=`/${e}`,n=this.factoryParamOptions(o,t);return this.cacheResponse(o,n,void 0,s)}async getAll(e,t,s,o){const n=(t==null?void 0:t.per_page)||25,a=`/${e}`.replace(/\/$/,""),i=s??a.substring(a.lastIndexOf("/")+1),l=1,h=await this.makeRequest(a,t,n,l,o),u=h.total?Math.ceil(h.total/n):1,p=await this.helpers.asyncMap(this.helpers.range(l,u),T=>this.makeRequest(a,t,n,T+1,o));return this.helpers.flatMap([h,...p],T=>Object.values(T.data[i]))}post(e,t,s){const o=`/${e}`;return Promise.resolve(this.throttle("post",o,t,s))}put(e,t,s){const o=`/${e}`;return Promise.resolve(this.throttle("put",o,t,s))}delete(e,t,s){t||(t={});const o=`/${e}`;return Promise.resolve(this.throttle("delete",o,t,s))}getStories(e,t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t,s){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,s)}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,s){const o=e[t];o&&o.fieldtype==="multilink"&&o.linktype==="story"&&typeof o.id=="string"&&this.links[s][o.id]?o.story=this._cleanCopy(this.links[s][o.id]):o&&o.linktype==="story"&&typeof o.uuid=="string"&&this.links[s][o.uuid]&&(o.story=this._cleanCopy(this.links[s][o.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,s){const o=e[t];typeof o=="string"?e[t]=this.getStoryReference(s,o):Array.isArray(o)&&(e[t]=o.map(n=>this.getStoryReference(s,n)).filter(Boolean))}_insertRelations(e,t,s,o){if(Array.isArray(s)?s.find(a=>a.endsWith(`.${t}`)):s.endsWith(`.${t}`)){this._resolveField(e,t,o);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(s)?s.includes(n):s===n)&&this._resolveField(e,t,o)}iterateTree(e,t,s){const o=(n,a="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((i,l)=>o(i,`${a}[${l}]`));else if(typeof n=="object")for(const i in n){const l=a?`${a}.${i}`:i;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,t,s),this._insertLinks(n,i,s)),o(n[i],l)}}};o(e.content)}async resolveLinks(e,t,s){let o=[];if(e.link_uuids){const n=e.link_uuids.length,a=[],i=50;for(let l=0;l<n;l+=i){const h=Math.min(n,l+i);a.push(e.link_uuids.slice(l,h))}for(let l=0;l<a.length;l++)(await this.getStories({per_page:i,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[l].join(",")})).data.stories.forEach(h=>{o.push(h)})}else o=e.links;o.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let o=[];if(e.rel_uuids){const n=e.rel_uuids.length,a=[],i=50;for(let l=0;l<n;l+=i){const h=Math.min(n,l+i);a.push(e.rel_uuids.slice(l,h))}for(let l=0;l<a.length;l++)(await this.getStories({per_page:i,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[l].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(h=>{o.push(h)})}else o=e.rels;o&&o.length>0&&o.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var o,n;let a=[];if(this.links[s]={},this.relations[s]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(a=t.resolve_relations.split(",")),await this.resolveRelations(e,t,s)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((o=e.links)!=null&&o.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const i in this.relations[s])this.iterateTree(this.relations[s][i],a,s);e.story?this.iterateTree(e.story,a,s):e.stories.forEach(i=>{this.iterateTree(i,a,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,o){const n=this.helpers.stringify({url:e,params:t}),a=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const i=await a.get(n);if(i)return Promise.resolve(i)}return new Promise(async(i,l)=>{var h;try{const u=await this.throttle("get",e,t,o);if(u.status!==200)return l(u);let p={data:u.data,headers:u.headers};if((h=u.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),p.data.story||p.data.stories){const w=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${w}`)}t.version==="published"&&e!=="/cdn/spaces/me"&&await a.set(n,p);const T=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&p.data.cv&&(T&&C[t.token]&&C[t.token]!==p.data.cv&&await this.flushCache(),C[t.token]=p.data.cv),i(p)}catch(u){if(u.response&&u.status===429&&(s=typeof s>"u"?0:s+1,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,s).then(i).catch(l);l(u)}})}throttledRequest(e,t,s,o){return this.client.setFetchOptions(o),this.client[e](t,s)}cacheVersions(){return C}cacheVersion(){return C[this.accessToken]}setCacheVersion(e){this.accessToken&&(C[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(C[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}}const Me=(r={})=>{const{apiOptions:e}=r;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 Ne(e)}},De=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};try{const e=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};function He(r,e){if(!e)return{src:r,attrs:{}};let t=0,s=0;const o={},n=[];function a(l,h,u,p,T){typeof l!="number"||l<=h||l>=u?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`):T.push(`${p}(${l})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(o.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?(o.height=e.height,s=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(o.loading=e.loading),e.class&&(o.class=e.class),e.filters){const{filters:l}=e||{},{blur:h,brightness:u,fill:p,format:T,grayscale:w,quality:_,rotate:A}=l||{};h&&a(h,0,100,"blur",n),_&&a(_,0,100,"quality",n),u&&a(u,0,100,"brightness",n),p&&n.push(`fill(${p})`),w&&n.push("grayscale()"),A&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${A})`),T&&["webp","png","jpeg"].includes(T)&&n.push(`format(${T})`)}e.srcset&&(o.srcset=e.srcset.map(l=>{if(typeof l=="number")return`${r}/m/${l}x0/${n.length>0?`filters:${n.join(":")}`:""} ${l}w`;if(Array.isArray(l)&&l.length===2){const[h,u]=l;return`${r}/m/${h}x${u}/${n.length>0?`filters:${n.join(":")}`:""} ${h}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(o.sizes=e.sizes.join(", "))}let i=`${r}/m/`;return t>0&&s>0&&(i=`${i}${t}x${s}/`),n.length>0&&(i=`${i}filters:${n.join(":")}`),{src:i,attrs:o}}var k=(r=>(r.DOCUMENT="doc",r.HEADING="heading",r.PARAGRAPH="paragraph",r.QUOTE="blockquote",r.OL_LIST="ordered_list",r.UL_LIST="bullet_list",r.LIST_ITEM="list_item",r.CODE_BLOCK="code_block",r.HR="horizontal_rule",r.BR="hard_break",r.IMAGE="image",r.EMOJI="emoji",r.COMPONENT="blok",r.TABLE="table",r.TABLE_ROW="tableRow",r.TABLE_CELL="tableCell",r.TABLE_HEADER="tableHeader",r))(k||{}),E=(r=>(r.BOLD="bold",r.STRONG="strong",r.STRIKE="strike",r.UNDERLINE="underline",r.ITALIC="italic",r.CODE="code",r.LINK="link",r.ANCHOR="anchor",r.STYLED="styled",r.SUPERSCRIPT="superscript",r.SUBSCRIPT="subscript",r.TEXT_STYLE="textStyle",r.HIGHLIGHT="highlight",r))(E||{}),H=(r=>(r.TEXT="text",r))(H||{}),x=(r=>(r.URL="url",r.STORY="story",r.ASSET="asset",r.EMAIL="email",r))(x||{});const Be=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Ue=(r={})=>Object.keys(r).map(e=>`${e}="${r[e]}"`).join(" "),ze=(r={})=>Object.keys(r).map(e=>`${e}: ${r[e]}`).join("; ");function Fe(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const N=r=>Object.fromEntries(Object.entries(r).filter(([e,t])=>t!==void 0));function J(r,e={},t){const s=Ue(e),o=s?`${r} ${s}`:r,n=Array.isArray(t)?t.join(""):t||"";if(r){if(Be.includes(r))return`<${o}>`}else return n;return`<${o}>${n}</${r}>`}function Y(r={}){const e=new Map,{renderFn:t=J,textFn:s=Fe,resolvers:o={},optimizeImages:n=!1,keyedResolvers:a=!1}=r,i=t!==J,l=()=>({render:(c,d={},g)=>{if(a&&c){const f=e.get(c)||0;e.set(c,f+1),d.key=`${c}-${f}`}return t(c,d,g)}}),h=c=>(d,g)=>{const f=d.attrs||{};return g.render(c,f,d.children||null)},u=(c,d)=>{const{src:g,alt:f,title:v,srcset:S,sizes:$}=c.attrs||{};let R=g,j={};if(n){const{src:ct,attrs:ht}=He(g,n);R=ct,j=ht}const lt={src:R,alt:f,title:v,srcset:S,sizes:$,...j};return d.render("img",N(lt))},p=(c,d)=>{const{level:g,...f}=c.attrs||{};return d.render(`h${g}`,f,c.children)},T=(c,d)=>{var g,f,v,S;const $=d.render("img",{src:(g=c.attrs)==null?void 0:g.fallbackImage,alt:(f=c.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return d.render("span",{"data-type":"emoji","data-name":(v=c.attrs)==null?void 0:v.name,"data-emoji":(S=c.attrs)==null?void 0:S.emoji},$)},w=(c,d)=>d.render("pre",c.attrs||{},d.render("code",{},c.children||"")),_=(c,d=!1)=>({text:g,attrs:f},v)=>{const{class:S,id:$,...R}=f||{},j=d?{class:S,id:$,style:ze(R)||void 0}:f||{};return v.render(c,N(j),g)},A=c=>z(c),tt=c=>{const{marks:d,...g}=c;if("text"in c){if(d)return d.reduce((v,S)=>A({...S,text:v}),A({...g,children:g.children}));const f=c.attrs||{};if(a){const v=e.get("txt")||0;e.set("txt",v+1),f.key=`txt-${v}`}return s(g.text,f)}return""},re=(c,d)=>{const{linktype:g,href:f,anchor:v,...S}=c.attrs||{};let $="";switch(g){case x.ASSET:case x.URL:$=f;break;case x.EMAIL:$=`mailto:${f}`;break;case x.STORY:$=f,v&&($=`${$}#${v}`);break;default:$=f;break}const R={...S};return $&&(R.href=$),d.render("a",R,c.text)},rt=(c,d)=>{var g,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),d.render("span",{blok:(g=c==null?void 0:c.attrs)==null?void 0:g.body[0],id:(f=c.attrs)==null?void 0:f.id,style:"display: none"})},st=(c,d)=>{const g={},f=d.render("tbody",{},c.children);return d.render("table",g,f)},ot=(c,d)=>{const g={};return d.render("tr",g,c.children)},nt=(c,d)=>{const{colspan:g,rowspan:f,colwidth:v,backgroundColor:S,...$}=c.attrs||{},R={...$};g>1&&(R.colspan=g),f>1&&(R.rowspan=f);const j=[];return v&&j.push(`width: ${v}px;`),S&&j.push(`background-color: ${S};`),j.length>0&&(R.style=j.join(" ")),d.render("td",N(R),c.children)},at=(c,d)=>{const{colspan:g,rowspan:f,colwidth:v,backgroundColor:S,...$}=c.attrs||{},R={...$};g>1&&(R.colspan=g),f>1&&(R.rowspan=f);const j=[];return v&&j.push(`width: ${v}px;`),S&&j.push(`background-color: ${S};`),j.length>0&&(R.style=j.join(" ")),d.render("th",N(R),c.children)},it=new Map([[k.DOCUMENT,h("")],[k.HEADING,p],[k.PARAGRAPH,h("p")],[k.UL_LIST,h("ul")],[k.OL_LIST,h("ol")],[k.LIST_ITEM,h("li")],[k.IMAGE,u],[k.EMOJI,T],[k.CODE_BLOCK,w],[k.HR,h("hr")],[k.BR,h("br")],[k.QUOTE,h("blockquote")],[k.COMPONENT,rt],[H.TEXT,tt],[E.LINK,re],[E.ANCHOR,re],[E.STYLED,_("span",!0)],[E.BOLD,_("strong")],[E.TEXT_STYLE,_("span",!0)],[E.ITALIC,_("em")],[E.UNDERLINE,_("u")],[E.STRIKE,_("s")],[E.CODE,_("code")],[E.SUPERSCRIPT,_("sup")],[E.SUBSCRIPT,_("sub")],[E.HIGHLIGHT,_("mark")],[k.TABLE,st],[k.TABLE_ROW,ot],[k.TABLE_CELL,nt],[k.TABLE_HEADER,at],...Object.entries(o).map(([c,d])=>[c,d])]);function M(c){const d=it.get(c.type);if(!d)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";const g=l();if(c.type==="text")return d(c,g);const f=c.content?c.content.map(z):void 0;return d({...c,children:f},g)}function z(c){return c.type==="doc"?i?c.content.map(M):c.content.map(M).join(""):Array.isArray(c)?c.map(M):M(c)}return{render:z}}let B,W="https://app.storyblok.com/f/storyblok-v2-latest.js";const X=(r,e,t={})=>{var s;const o=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok"),a=n!==null&&+n===r;if(!(!o||!a)){if(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],i=>{var l;i&&(i.action==="input"&&((l=i.story)==null?void 0:l.id)===r?e(i.story):(i.action==="change"||i.action==="published")&&i.storyId===r&&window.location.reload())})})}},Q=(r,e)=>{r.addNode("blok",t=>{let s="";return t.attrs.body.forEach(o=>{s+=e(o.component,o)}),{html:s}})},Ve=(r={})=>{var e,t;const{bridge:s,accessToken:o,use:n=[],apiOptions:a={},richText:i={},bridgeUrl:l}=r;a.accessToken=a.accessToken||o;const h={bridge:s,apiOptions:a};let u={};n.forEach(T=>{u={...u,...T(h)}}),l&&(W=l);const p=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return s!==!1&&p&&se(W),B=new I(i.schema),i.resolver&&Q(B,i.resolver),u},qe=r=>{var e;return!r||!((e=r==null?void 0:r.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},Ge=(r,e,t)=>{let s=t||B;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return qe(r)?"":(e&&(s=new I(e.schema),e.resolver&&Q(s,e.resolver)),s.render(r,{},!1))},U=m.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(r,{expose:e}){const t=r,s=m.ref();e({value:s});const o=typeof m.resolveDynamicComponent(t.blok.component)!="string",n=m.inject("VueSDKOptions"),a=m.ref(t.blok.component);return!o&&n&&(n.enableFallbackComponent?(a.value=n.customFallbackComponent??"FallbackComponent",typeof m.resolveDynamicComponent(a.value)=="string"&&console.error(`Is the Fallback component "${a.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(i,l)=>(m.openBlock(),m.createBlock(m.resolveDynamicComponent(a.value),m.mergeProps({ref_key:"blokRef",ref:s},{...i.$props,...i.$attrs}),null,16))}}),Ke=r=>{var e,t;return m.h(U,{blok:(e=r==null?void 0:r.attrs)==null?void 0:e.body[0],id:(t=r.attrs)==null?void 0:t.id},r.children)};function Z(r){const e={renderFn:m.h,textFn:m.createTextVNode,keyedResolvers:!0,resolvers:{[k.COMPONENT]:Ke,...r.resolvers}};return Y(e)}const ee=m.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(r){const e=r,t=m.ref(),s=()=>t.value;return m.watch([()=>e.doc,()=>e.resolvers],([o,n])=>{const{render:a}=Z({resolvers:n??{}});t.value=a(o)},{immediate:!0,deep:!0}),(o,n)=>(m.openBlock(),m.createBlock(s))}}),Je={beforeMount(r,e){if(e.value){const t=De(e.value);Object.keys(t).length>0&&(r.setAttribute("data-blok-c",t["data-blok-c"]),r.setAttribute("data-blok-uid",t["data-blok-uid"]),r.classList.add("storyblok__outline"))}}},te=r=>{console.error(`You can't use ${r} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
31
|
-
`)};let O=null;const Ye=()=>(O||te("useStoryblokApi"),O),We=async(r,e={},t={})=>{const s=m.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,m.onMounted(()=>{s.value&&s.value.id&&X(s.value.id,o=>s.value=o,t)}),O){const{data:o}=await O.get(`cdn/stories/${r}`,e);s.value=o.story}else te("useStoryblok");return s},Xe={install(r,e={}){r.directive("editable",Je),r.component("StoryblokComponent",U),r.component("StoryblokRichText",ee),e.enableFallbackComponent&&!e.customFallbackComponent&&r.component("FallbackComponent",m.defineAsyncComponent(()=>Promise.resolve().then(()=>et)));const{storyblokApi:t}=Ve(e);O=t||null,r.provide("VueSDKOptions",e)}},Qe={class:"fallback-component"},Ze={class:"component"},et=Object.freeze(Object.defineProperty({__proto__:null,default:((r,e)=>{const t=r.__vccOpts||r;for(const[s,o]of e)t[s]=o;return t})(m.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(r){return(e,t)=>(m.openBlock(),m.createElementBlock("div",Qe,[m.createElementVNode("p",null,[t[0]||(t[0]=m.createTextVNode(" Component could not be found for blok ")),m.createElementVNode("span",Ze,m.toDisplayString(e.blok.component),1),t[1]||(t[1]=m.createTextVNode("! Is it configured correctly? "))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));b.BlockTypes=k,b.MarkTypes=E,b.RichTextResolver=I,b.RichTextSchema=q,b.StoryblokComponent=U,b.StoryblokRichText=ee,b.StoryblokVue=Xe,b.TextTypes=H,b.apiPlugin=Me,b.renderRichText=Ge,b.richTextResolver=Y,b.useStoryblok=We,b.useStoryblokApi=Ye,b.useStoryblokBridge=X,b.useStoryblokRichText=Z,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
7
|
+
(function(v,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(v=typeof globalThis<"u"?globalThis:v||self,f(v.storyblokVue={},v.Vue))})(this,function(v,f){"use strict";function Z(s,e){if(!e)return{src:s,attrs:{}};let t=0,o=0;const r={},n=[];function i(c,u,m,y,A){typeof c!="number"||c<=u||c>=m?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${u} and ${m} (inclusive)`):A.push(`${y}(${c})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(r.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?(r.height=e.height,o=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(r.loading=e.loading),e.class&&(r.class=e.class),e.filters){const{filters:c}=e||{},{blur:u,brightness:m,fill:y,format:A,grayscale:L,quality:S,rotate:O}=c||{};u&&i(u,0,100,"blur",n),S&&i(S,0,100,"quality",n),m&&i(m,0,100,"brightness",n),y&&n.push(`fill(${y})`),L&&n.push("grayscale()"),O&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${O})`),A&&["webp","png","jpeg"].includes(A)&&n.push(`format(${A})`)}e.srcset&&(r.srcset=e.srcset.map(c=>{if(typeof c=="number")return`${s}/m/${c}x0/${n.length>0?`filters:${n.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,m]=c;return`${s}/m/${u}x${m}/${n.length>0?`filters:${n.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(r.sizes=e.sizes.join(", "))}let l=`${s}/m/`;return t>0&&o>0&&(l=`${l}${t}x${o}/`),n.length>0&&(l=`${l}filters:${n.join(":")}`),{src:l,attrs:r}}var k=(s=>(s.DOCUMENT="doc",s.HEADING="heading",s.PARAGRAPH="paragraph",s.QUOTE="blockquote",s.OL_LIST="ordered_list",s.UL_LIST="bullet_list",s.LIST_ITEM="list_item",s.CODE_BLOCK="code_block",s.HR="horizontal_rule",s.BR="hard_break",s.IMAGE="image",s.EMOJI="emoji",s.COMPONENT="blok",s.TABLE="table",s.TABLE_ROW="tableRow",s.TABLE_CELL="tableCell",s.TABLE_HEADER="tableHeader",s))(k||{}),$=(s=>(s.BOLD="bold",s.STRONG="strong",s.STRIKE="strike",s.UNDERLINE="underline",s.ITALIC="italic",s.CODE="code",s.LINK="link",s.ANCHOR="anchor",s.STYLED="styled",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.TEXT_STYLE="textStyle",s.HIGHLIGHT="highlight",s))($||{}),x=(s=>(s.TEXT="text",s))(x||{}),C=(s=>(s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s))(C||{});const ee=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],te=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),se=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function re(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const j=s=>Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));function F(s,e={},t){const o=te(e),r=o?`${s} ${o}`:s,n=Array.isArray(t)?t.join(""):t||"";if(s){if(ee.includes(s))return`<${r}>`}else return n;return`<${r}>${n}</${s}>`}function D(s={}){const e=new Map,{renderFn:t=F,textFn:o=re,resolvers:r={},optimizeImages:n=!1,keyedResolvers:i=!1}=s,l=t!==F,c=()=>({render:(a,h={},d)=>{if(i&&a){const p=e.get(a)||0;e.set(a,p+1),h.key=`${a}-${p}`}return t(a,h,d)}}),u=a=>(h,d)=>{const p=h.attrs||{};return d.render(a,p,h.children||null)},m=(a,h)=>{const{src:d,alt:p,title:g,srcset:w,sizes:_}=a.attrs||{};let T=d,R={};if(n){const{src:He,attrs:Ue}=Z(d,n);T=He,R=Ue}const Be={src:T,alt:p,title:g,srcset:w,sizes:_,...R};return h.render("img",j(Be))},y=(a,h)=>{const{level:d,...p}=a.attrs||{};return h.render(`h${d}`,p,a.children)},A=(a,h)=>{var d,p,g,w;const _=h.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 h.render("span",{"data-type":"emoji","data-name":(g=a.attrs)==null?void 0:g.name,"data-emoji":(w=a.attrs)==null?void 0:w.emoji},_)},L=(a,h)=>h.render("pre",a.attrs||{},h.render("code",{},a.children||"")),S=(a,h=!1)=>({text:d,attrs:p},g)=>{const{class:w,id:_,...T}=p||{},R=h?{class:w,id:_,style:se(T)||void 0}:p||{};return g.render(a,j(R),d)},O=a=>M(a),Le=a=>{const{marks:h,...d}=a;if("text"in a){if(h)return h.reduce((g,w)=>O({...w,text:g}),O({...d,children:d.children}));const p=a.attrs||{};if(i){const g=e.get("txt")||0;e.set("txt",g+1),p.key=`txt-${g}`}return o(d.text,p)}return""},Q=(a,h)=>{const{linktype:d,href:p,anchor:g,...w}=a.attrs||{};let _="";switch(d){case C.ASSET:case C.URL:_=p;break;case C.EMAIL:_=`mailto:${p}`;break;case C.STORY:_=p,g&&(_=`${_}#${g}`);break;default:_=p;break}const T={...w};return _&&(T.href=_),h.render("a",T,a.text)},Oe=(a,h)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.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"})},je=(a,h)=>{const d={},p=h.render("tbody",{},a.children);return h.render("table",d,p)},Pe=(a,h)=>{const d={};return h.render("tr",d,a.children)},Ne=(a,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:w,..._}=a.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",j(T),a.children)},xe=(a,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:w,..._}=a.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",j(T),a.children)},De=new Map([[k.DOCUMENT,u("")],[k.HEADING,y],[k.PARAGRAPH,u("p")],[k.UL_LIST,u("ul")],[k.OL_LIST,u("ol")],[k.LIST_ITEM,u("li")],[k.IMAGE,m],[k.EMOJI,A],[k.CODE_BLOCK,L],[k.HR,u("hr")],[k.BR,u("br")],[k.QUOTE,u("blockquote")],[k.COMPONENT,Oe],[x.TEXT,Le],[$.LINK,Q],[$.ANCHOR,Q],[$.STYLED,S("span",!0)],[$.BOLD,S("strong")],[$.TEXT_STYLE,S("span",!0)],[$.ITALIC,S("em")],[$.UNDERLINE,S("u")],[$.STRIKE,S("s")],[$.CODE,S("code")],[$.SUPERSCRIPT,S("sup")],[$.SUBSCRIPT,S("sub")],[$.HIGHLIGHT,S("mark")],[k.TABLE,je],[k.TABLE_ROW,Pe],[k.TABLE_CELL,Ne],[k.TABLE_HEADER,xe],...Object.entries(r).map(([a,h])=>[a,h])]);function N(a){const h=De.get(a.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${a.type}`),"";const d=c();if(a.type==="text")return h(a,d);const p=a.content?a.content.map(M):void 0;return h({...a,children:p},d)}function M(a){return a.type==="doc"?l?a.content.map(N):a.content.map(N).join(""):Array.isArray(a)?a.map(N):N(a)}return{render:M}}let V=!1;const z=[],oe=s=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}V?r():z.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=s,o.id="storyblok-javascript-bridge",o.onerror=r=>t(r),o.onload=r=>{z.forEach(n=>n()),V=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(o)});var ne=Object.defineProperty,ie=(s,e,t)=>e in s?ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,b=(s,e,t)=>ie(s,typeof e!="symbol"?e+"":e,t);class ae extends Error{constructor(e){super(e),this.name="AbortError"}}function le(s,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 o=[];let r=[],n=0,i=!1;const l=async()=>{n++;const u=o.shift();if(u)try{const y=await s(...u.args);u.resolve(y)}catch(y){u.reject(y)}const m=setTimeout(()=>{n--,o.length>0&&l(),r=r.filter(y=>y!==m)},t);r.includes(m)||r.push(m)},c=(...u)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((m,y)=>{o.push({resolve:m,reject:y,args:u}),n<e&&l()});return c.abort=()=>{i=!0,r.forEach(clearTimeout),r=[],o.forEach(u=>u.reject(()=>new ae("Throttle function aborted"))),o.length=0},c}const ce=(s="")=>s.includes("/cdn/"),ue=(s,e=25,t=1)=>({...s,per_page:e,page:t}),he=s=>new Promise(e=>setTimeout(e,s)),de=(s=0,e)=>Array.from({length:s},e),pe=(s=0,e=s)=>{const t=Math.abs(e-s)||0,o=s<e?1:-1;return de(t,(r,n)=>n*o+s)},fe=async(s,e)=>Promise.all(s.map(e)),me=(s=[],e)=>s.map(e).reduce((t,o)=>[...t,...o],[]),B=(s,e,t)=>{const o=[];for(const r in s){if(!Object.prototype.hasOwnProperty.call(s,r))continue;const n=s[r];if(n==null)continue;const i=t?"":encodeURIComponent(r);let l;typeof n=="object"?l=B(n,e?e+encodeURIComponent(`[${i}]`):i,Array.isArray(n)):l=`${e?e+encodeURIComponent(`[${i}]`):i}=${encodeURIComponent(n)}`,o.push(l)}return o.join("&")},q=s=>{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[s]??e.eu};class ye{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=[],o={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{o.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return o.headers={...t},o.status=e.status,o.statusText=e.statusText,o}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,o=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:o=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:i}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const c=await this.fetch(`${r}`,{method:e,headers:this.headers,body:o,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(l);const u=await this._responseHandler(c);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}catch(c){return{message:c}}}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((o,r)=>{if(t.test(`${e.status}`))return o(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(n)})}}const G="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"},be={DRAFT:"draft"};let P={};const E={};class ke{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 o=e.endpoint||t;if(!o){const i=e.https===!1?"http":"https";e.oauthToken?o=`${i}://${q(e.region)}/v1`:o=`${i}://${q(e.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([i,l])=>{r.set(i,l)}),r.has(G)||(r.set(G,H.defaultAgentName),r.set(H.defaultAgentVersion,H.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=le(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||be.DRAFT,this.inlineAssets=e.inlineAssets||!1,this.client=new ye({baseURL:o,timeout:e.timeout||0,headers:r,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 ce(e)?this.parseParams(t):t}makeRequest(e,t,o,r,n){const i=this.factoryParamOptions(e,ue(t,o,r));return this.cacheResponse(e,i,void 0,n)}get(e,t={},o){t||(t={});const r=`/${e}`;t.version=t.version||this.version;const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,o)}async getAll(e,t={},o,r){const n=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=o??i.substring(i.lastIndexOf("/")+1);t.version=t.version||this.version;const c=1,u=await this.makeRequest(i,t,n,c,r),m=u.total?Math.ceil(u.total/n):1,y=await fe(pe(c,m),A=>this.makeRequest(i,t,n,A+1,r));return me([u,...y],A=>Object.values(A.data[l]))}post(e,t={},o){const r=`/${e}`;return this.throttle("post",r,t,o)}put(e,t={},o){const r=`/${e}`;return this.throttle("put",r,t,o)}delete(e,t={},o){t||(t={});const r=`/${e}`;return this.throttle("delete",r,t,o)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},o){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,o)}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,o){const r=e[t];r&&r.fieldtype==="multilink"&&r.linktype==="story"&&typeof r.id=="string"&&this.links[o][r.id]?r.story=this._cleanCopy(this.links[o][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[o][r.uuid]&&(r.story=this._cleanCopy(this.links[o][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,o){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(o,r):Array.isArray(r)&&(e[t]=r.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(e,t,o,r){if(Array.isArray(o)?o.find(i=>i.endsWith(`.${t}`)):o.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(e,t,r)}iterateTree(e,t,o){const r=(n,i="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,c)=>r(l,`${i}[${c}]`));else if(typeof n=="object")for(const l in n){const c=i?`${i}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,o),this._insertLinks(n,l,o)),r(n[l],c)}}};r(e.content)}async resolveLinks(e,t,o){let r=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let c=0;c<n;c+=l){const u=Math.min(n,c+l);i.push(e.link_uuids.slice(c,u))}for(let c=0;c<i.length;c++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[c].join(",")})).data.stories.forEach(u=>{r.push(u)})}else r=e.links;r.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,o){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let c=0;c<n;c+=l){const u=Math.min(n,c+l);i.push(e.rel_uuids.slice(c,u))}for(let c=0;c<i.length;c++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[c].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{r.push(u)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,o){var r,n;let i=[];if(this.links[o]={},this.relations[o]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(i=t.resolve_relations.split(",")),await this.resolveRelations(e,t,o)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,o),this.resolveNestedRelations)for(const l in this.relations[o])this.iterateTree(this.relations[o][l],i,o);e.story?this.iterateTree(e.story,i,o):e.stories.forEach(l=>{this.iterateTree(l,i,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(e,t,o,r){const n=B({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await i.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,c)=>{var u;try{const m=await this.throttle("get",e,t,r);if(m.status!==200)return c(m);let y={data:m.data,headers:m.headers};if((u=m.headers)!=null&&u["per-page"]&&(y=Object.assign({},y,{perPage:m.headers["per-page"]?Number.parseInt(m.headers["per-page"]):0,total:m.headers["per-page"]?Number.parseInt(m.headers.total):0})),y.data.story||y.data.stories){const L=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${L}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(n,y);const A=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(A&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(m){if(m.response&&m.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await he(this.retriesDelay),this.cacheResponse(e,t,o).then(l).catch(c);c(m)}})}throttledRequest(e,t,o,r){return this.client.setFetchOptions(r),this.client[e](t,o)}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=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>t(n));let r={...o};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...r,...e.data.assets.find(n=>n.id===r.id)});for(const n in r)typeof r[n]=="object"&&(r[n]=t(r[n]));return r};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(o=>(o.content=t(o.content),o))),e}}const ge=(s={})=>{const{apiOptions:e}=s;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 ke(e)}},ve=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};try{const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let J="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(s,e,t={})=>{var o;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((o=window.location)==null?void 0:o.href).searchParams.get("_storyblok"),i=n!==null&&+n===s;if(!(!r||!i)){if(!s){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 c;l&&(l.action==="input"&&((c=l.story)==null?void 0:c.id)===s?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===s&&window.location.reload())})})}},_e=(s={})=>{var e,t;const{bridge:o,accessToken:r,use:n=[],apiOptions:i={},bridgeUrl:l}=s;i.accessToken=i.accessToken||r;const c={bridge:o,apiOptions:i};let u={};n.forEach(y=>{u={...u,...y(c)}}),l&&(J=l);const m=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return o!==!1&&m&&oe(J),u};function Te(s,e){return D(e).render(s)}const U=f.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){const t=s,o=f.ref();e({value:o});const r=typeof f.resolveDynamicComponent(t.blok.component)!="string",n=f.inject("VueSDKOptions"),i=f.ref(t.blok.component);return!r&&n&&(n.enableFallbackComponent?(i.value=n.customFallbackComponent??"FallbackComponent",typeof f.resolveDynamicComponent(i.value)=="string"&&console.error(`Is the Fallback component "${i.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(l,c)=>(f.openBlock(),f.createBlock(f.resolveDynamicComponent(i.value),f.mergeProps({ref_key:"blokRef",ref:o},{...l.$props,...l.$attrs}),null,16))}}),we=s=>{var e,t;return f.h(U,{blok:(e=s==null?void 0:s.attrs)==null?void 0:e.body[0],id:(t=s.attrs)==null?void 0:t.id},s.children)};function Y(s){const e={renderFn:f.h,textFn:f.createTextVNode,keyedResolvers:!0,resolvers:{[k.COMPONENT]:we,...s.resolvers}};return D(e)}const W=f.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(s){const e=s,t=f.ref(),o=()=>t.value;return f.watch([()=>e.doc,()=>e.resolvers],([r,n])=>{const{render:i}=Y({resolvers:n??{}});t.value=i(r)},{immediate:!0,deep:!0}),(r,n)=>(f.openBlock(),f.createBlock(o))}}),$e={beforeMount(s,e){if(e.value){const t=ve(e.value);Object.keys(t).length>0&&(s.setAttribute("data-blok-c",t["data-blok-c"]),s.setAttribute("data-blok-uid",t["data-blok-uid"]),s.classList.add("storyblok__outline"))}}},X=s=>{console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
8
|
+
`)};let I=null;const Re=()=>(I||X("useStoryblokApi"),I),Ae=async(s,e={},t={})=>{const o=f.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,f.onMounted(()=>{o.value&&o.value.id&&K(o.value.id,r=>o.value=r,t)}),I){const{data:r}=await I.get(`cdn/stories/${s}`,e);o.value=r.story}else X("useStoryblok");return o},Se={install(s,e={}){s.directive("editable",$e),s.component("StoryblokComponent",U),s.component("StoryblokRichText",W),e.enableFallbackComponent&&!e.customFallbackComponent&&s.component("FallbackComponent",f.defineAsyncComponent(()=>Promise.resolve().then(()=>Ie)));const{storyblokApi:t}=_e(e);I=t||null,s.provide("VueSDKOptions",e)}},Ee={class:"fallback-component"},Ce={class:"component"},Ie=Object.freeze(Object.defineProperty({__proto__:null,default:((s,e)=>{const t=s.__vccOpts||s;for(const[o,r]of e)t[o]=r;return t})(f.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(s){return(e,t)=>(f.openBlock(),f.createElementBlock("div",Ee,[f.createElementVNode("p",null,[t[0]||(t[0]=f.createTextVNode(" Component could not be found for blok ")),f.createElementVNode("span",Ce,f.toDisplayString(e.blok.component),1),t[1]||(t[1]=f.createTextVNode("! Is it configured correctly? "))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));v.BlockTypes=k,v.MarkTypes=$,v.StoryblokComponent=U,v.StoryblokRichText=W,v.StoryblokVue=Se,v.TextTypes=x,v.apiPlugin=ge,v.renderRichText=Te,v.richTextResolver=D,v.useStoryblok=Ae,v.useStoryblokApi=Re,v.useStoryblokBridge=K,v.useStoryblokRichText=Y,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|