@storyblok/vue 8.2.3 → 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 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, RichTextResolver, richTextResolver, RichTextSchema, type StoryblokRichTextDocumentNode, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeResolver, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, type StoryblokRichTextResolvers, TextTypes, useStoryblokBridge, } from '@storyblok/js';
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;
@@ -4,28 +4,5 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- (function(k,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],m):(k=typeof globalThis<"u"?globalThis:k||self,m(k.storyblokVue={},k.Vue))})(this,function(k,m){"use strict";let V=!1;const q=[],oe=s=>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}V?o():q.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=s,r.id="storyblok-javascript-bridge",r.onerror=o=>t(o),r.onload=o=>{q.forEach(n=>n()),V=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(r)});var ne=Object.defineProperty,ae=(s,e,t)=>e in s?ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,y=(s,e,t)=>ae(s,typeof e!="symbol"?e+"":e,t);class ie 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 r=[];let o=[],n=0,a=!1;const i=async()=>{n++;const h=r.shift();if(h)try{const p=await s(...h.args);h.resolve(p)}catch(p){h.reject(p)}const d=setTimeout(()=>{n--,r.length>0&&i(),o=o.filter(p=>p!==d)},t);o.includes(d)||o.push(d)},l=(...h)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,p)=>{r.push({resolve:d,reject:p,args:h}),n<e&&i()});return l.abort=()=>{a=!0,o.forEach(clearTimeout),o=[],r.forEach(h=>h.reject(()=>new ie("Throttle function aborted"))),r.length=0},l}class L{constructor(){y(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),y(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),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 r=Math.abs(t-e)||0,o=e<t?1:-1;return this.arrayFrom(r,(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((r,o)=>[...r,...o],[])),y(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r=/[&<>"']/g,o=new RegExp(r.source);return e&&o.test(e)?e.replace(r,n=>t[n]):e})}stringify(e,t,r){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=r?"":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",r="api-us.storyblok.com",o="app.storyblokchina.cn",n="api-ap.storyblok.com",a="api-ca.storyblok.com";switch(e){case"us":return r;case"cn":return o;case"ap":return n;case"ca":return a;default:return t}}}const ce=function(s,e){const t={};for(const r in s){const o=s[r];e.includes(r)&&o!==null&&(t[r]=o)}return t},he=s=>s==="email",ue=()=>({singleTag:"hr"}),de=()=>({tag:"blockquote"}),pe=()=>({tag:"ul"}),ge=s=>({tag:["pre",{tag:"code",attrs:s.attrs}]}),fe=()=>({singleTag:"br"}),me=s=>({tag:`h${s.attrs.level}`}),ye=s=>({singleTag:[{tag:"img",attrs:ce(s.attrs,["src","alt","title"])}]}),be=()=>({tag:"li"}),ke=()=>({tag:"ol"}),ve=()=>({tag:"p"}),Te=s=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":s.attrs.name,emoji:s.attrs.emoji}}]}),$e=()=>({tag:"b"}),we=()=>({tag:"s"}),_e=()=>({tag:"u"}),Re=()=>({tag:"strong"}),Se=()=>({tag:"code"}),Ee=()=>({tag:"i"}),je=s=>{if(!s.attrs)return{tag:""};const e=new L().escapeHTML,t={...s.attrs},{linktype:r="url"}=s.attrs;if(delete t.linktype,t.href&&(t.href=e(s.attrs.href||"")),he(r)&&(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}]}},Ce=s=>({tag:[{tag:"span",attrs:s.attrs}]}),Ae=()=>({tag:"sub"}),Ie=()=>({tag:"sup"}),xe=s=>({tag:[{tag:"span",attrs:s.attrs}]}),Oe=s=>{var e;return(e=s.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${s.attrs.color};`}}]}:{tag:""}},Le=s=>{var e;return(e=s.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${s.attrs.color}`}}]}:{tag:""}},G={nodes:{horizontal_rule:ue,blockquote:de,bullet_list:pe,code_block:ge,hard_break:fe,heading:me,image:ye,list_item:be,ordered_list:ke,paragraph:ve,emoji:Te},marks:{bold:$e,strike:we,underline:_e,strong:Re,code:Se,italic:Ee,link:je,styled:Ce,subscript:Ae,superscript:Ie,anchor:xe,highlight:Oe,textStyle:Le}},Pe=function(s){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,r=new RegExp(t.source);return s&&r.test(s)?s.replace(t,o=>e[o]):s};let K=!1;class I{constructor(e){y(this,"marks"),y(this,"nodes"),e||(e=G),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},r=!0){if(!K&&r&&(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/"),K=!0),e&&e.content&&Array.isArray(e.content)){let o="";return e.content.forEach(n=>{o+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(o,t.optimizeImages):o}return console.warn(`The render method must receive an Object with a "content" field.
8
- The "content" field must be an array of nodes as the type ISbRichtext.
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(e,t){let r=0,o=0,n="",a="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,r=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,o=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(a+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(a+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-F]{6}/gi)||t.filters.fill==="transparent")&&(a+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(a+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(a+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(a+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(a+=`:rotate(${t.filters.rotate})`),a.length>0&&(a=`/filters${a}`))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const i=r>0||o>0||a.length>0?`${r}x${o}${a}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${i}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,l=>{var h,d;const p=l.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g);if(p&&p.length>0){const T={srcset:(h=t.srcset)==null?void 0:h.map(b=>{if(typeof b=="number")return`//${p}/m/${b}x0${a} ${b}w`;if(typeof b=="object"&&b.length===2){let C=0,M=0;return typeof b[0]=="number"&&(C=b[0]),typeof b[1]=="number"&&(M=b[1]),`//${p}/m/${C}x${M}${a} ${C}w`}return""}).join(", "),sizes:(d=t.sizes)==null?void 0:d.map(b=>b).join(", ")};let j="";return T.srcset&&(j+=`srcset="${T.srcset}" `),T.sizes&&(j+=`sizes="${T.sizes}" `),l.replace(/<img/g,`<img ${j.trim()}`)}return l})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(o=>{const n=this.getMatchingMark(o);n&&n.tag!==""&&t.push(this.renderOpeningTag(n.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(o=>{t.push(this.renderNode(o))}):e.text?t.push(Pe(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html?t.push(r.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(o=>{const n=this.getMatchingMark(o);n&&n.tag!==""&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let o=`<${r.tag}`;if(r.attrs){for(const n in r.attrs)if(Object.prototype.hasOwnProperty.call(r.attrs,n)){const a=r.attrs[n];a!==null&&(o+=` ${n}="${a}"`)}}return`${o}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class Ne{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=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(o=>{r.data=o});for(const o of e.headers.entries())t[o[0]]=o[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;if(e==="get"){const l=new L;t=`${this.baseURL}${this.url}?${l.stringify(this.parameters)}`}else r=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:r,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((r,o)=>{if(t.test(`${e.status}`))return r(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 J="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"};let P={};const A={};class Me{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 r=e.endpoint||t;if(!r){const a=new L().getRegionURL,i=e.https===!1?"http":"https";e.oauthToken?r=`${i}://${a(e.region)}/v1`:r=`${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(J)||(o.set(J,H.defaultAgentName),o.set(H.defaultAgentVersion,H.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=le(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 Ne({baseURL:r,timeout:e.timeout||0,headers:o,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body&&t.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})}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 this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,r,o,n){const a=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,o));return this.cacheResponse(e,a,void 0,n)}get(e,t,r){t||(t={});const o=`/${e}`,n=this.factoryParamOptions(o,t);return this.cacheResponse(o,n,void 0,r)}async getAll(e,t,r,o){const n=(t==null?void 0:t.per_page)||25,a=`/${e}`.replace(/\/$/,""),i=r??a.substring(a.lastIndexOf("/")+1),l=1,h=await this.makeRequest(a,t,n,l,o),d=h.total?Math.ceil(h.total/n):1,p=await this.helpers.asyncMap(this.helpers.range(l,d),T=>this.makeRequest(a,t,n,T+1,o));return this.helpers.flatMap([h,...p],T=>Object.values(T.data[i]))}post(e,t,r){const o=`/${e}`;return Promise.resolve(this.throttle("post",o,t,r))}put(e,t,r){const o=`/${e}`;return Promise.resolve(this.throttle("put",o,t,r))}delete(e,t,r){t||(t={});const o=`/${e}`;return Promise.resolve(this.throttle("delete",o,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 o=e[t];o&&o.fieldtype==="multilink"&&o.linktype==="story"&&typeof o.id=="string"&&this.links[r][o.id]?o.story=this._cleanCopy(this.links[r][o.id]):o&&o.linktype==="story"&&typeof o.uuid=="string"&&this.links[r][o.uuid]&&(o.story=this._cleanCopy(this.links[r][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,r){const o=e[t];typeof o=="string"?e[t]=this.getStoryReference(r,o):Array.isArray(o)&&(e[t]=o.map(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,o){if(Array.isArray(r)?r.find(a=>a.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,o);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,o)}iterateTree(e,t,r){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,r),this._insertLinks(n,i,r)),o(n[i],l)}}};o(e.content)}async resolveLinks(e,t,r){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[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){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)});o.length>0&&(e.rels=o,delete e.rel_uuids)}else o=e.rels;o&&o.length>0&&o.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var o,n;let a=[];if(this.links[r]={},this.relations[r]={},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,r)),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,r),this.resolveNestedRelations)for(const i in this.relations[r])this.iterateTree(this.relations[r][i],a,r);e.story?this.iterateTree(e.story,a,r):e.stories.forEach(i=>{this.iterateTree(i,a,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,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 d=await this.throttle("get",e,t,o);if(d.status!==200)return l(d);let p={data:d.data,headers:d.headers};if((h=d.headers)!=null&&h["per-page"]&&(p=Object.assign({},p,{perPage:d.headers["per-page"]?Number.parseInt(d.headers["per-page"]):0,total:d.headers["per-page"]?Number.parseInt(d.headers.total):0})),p.data.story||p.data.stories){const j=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${j}`)}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&&A[t.token]&&A[t.token]!==p.data.cv&&await this.flushCache(),A[t.token]=p.data.cv),i(p)}catch(d){if(d.response&&d.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 this.helpers.delay(this.retriesDelay),this.cacheResponse(e,t,r).then(i).catch(l);l(d)}})}throttledRequest(e,t,r,o){return this.client.setFetchOptions(o),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(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 De=(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 Me(e)}},He=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{}}};function Be(s,e){if(!e)return{src:s,attrs:{}};let t=0,r=0;const o={},n=[];function a(l,h,d,p,T){typeof l!="number"||l<=h||l>=d?console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase()+p.slice(1)} value must be a number between ${h} and ${d} (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,r=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:d,fill:p,format:T,grayscale:j,quality:b,rotate:C}=l||{};h&&a(h,0,100,"blur",n),b&&a(b,0,100,"quality",n),d&&a(d,0,100,"brightness",n),p&&n.push(`fill(${p})`),j&&n.push("grayscale()"),C&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${C})`),T&&["webp","png","jpeg"].includes(T)&&n.push(`format(${T})`)}e.srcset&&(o.srcset=e.srcset.map(l=>{if(typeof l=="number")return`${s}/m/${l}x0/${n.length>0?`filters:${n.join(":")}`:""} ${l}w`;if(Array.isArray(l)&&l.length===2){const[h,d]=l;return`${s}/m/${h}x${d}/${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=`${s}/m/`;return t>0&&r>0&&(i=`${i}${t}x${r}/`),n.length>0&&(i=`${i}filters:${n.join(":")}`),{src:i,attrs:o}}var v=(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))(v||{}),S=(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))(S||{}),B=(s=>(s.TEXT="text",s))(B||{}),x=(s=>(s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s))(x||{});const Ue=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ze=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),Fe=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function Ve(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const N=s=>Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));function Y(s,e={},t){const r=ze(e),o=r?`${s} ${r}`:s,n=Array.isArray(t)?t.join(""):t||"";if(s){if(Ue.includes(s))return`<${o}>`}else return n;return`<${o}>${n}</${s}>`}function W(s={}){const e=new Map,{renderFn:t=Y,textFn:r=Ve,resolvers:o={},optimizeImages:n=!1,keyedResolvers:a=!1}=s,i=t!==Y,l=()=>({render:(c,u={},g)=>{if(a&&c){const f=e.get(c)||0;e.set(c,f+1),u.key=`${c}-${f}`}return t(c,u,g)}}),h=c=>(u,g)=>{const f=u.attrs||{};return g.render(c,f,u.children||null)},d=(c,u)=>{const{src:g,alt:f,title:$,srcset:R,sizes:w}=c.attrs||{};let _=g,E={};if(n){const{src:ct,attrs:ht}=Be(g,n);_=ct,E=ht}const lt={src:_,alt:f,title:$,srcset:R,sizes:w,...E};return u.render("img",N(lt))},p=(c,u)=>{const{level:g,...f}=c.attrs||{};return u.render(`h${g}`,f,c.children)},T=(c,u)=>{var g,f,$,R;const w=u.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 u.render("span",{"data-type":"emoji","data-name":($=c.attrs)==null?void 0:$.name,"data-emoji":(R=c.attrs)==null?void 0:R.emoji},w)},j=(c,u)=>u.render("pre",c.attrs||{},u.render("code",{},c.children||"")),b=(c,u=!1)=>({text:g,attrs:f},$)=>{const{class:R,id:w,..._}=f||{},E=u?{class:R,id:w,style:Fe(_)||void 0}:f||{};return $.render(c,N(E),g)},C=c=>F(c),M=c=>{const{marks:u,...g}=c;if("text"in c){if(u)return u.reduce(($,R)=>C({...R,text:$}),C({...g,children:g.children}));const f=c.attrs||{};if(a){const $=e.get("txt")||0;e.set("txt",$+1),f.key=`txt-${$}`}return r(g.text,f)}return""},se=(c,u)=>{const{linktype:g,href:f,anchor:$,...R}=c.attrs||{};let w="";switch(g){case x.ASSET:case x.URL:w=f;break;case x.EMAIL:w=`mailto:${f}`;break;case x.STORY:w=f,$&&(w=`${w}#${$}`);break;default:w=f;break}const _={...R};return w&&(_.href=w),u.render("a",_,c.text)},rt=(c,u)=>{var g,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),u.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,u)=>{const g={},f=u.render("tbody",{},c.children);return u.render("table",g,f)},ot=(c,u)=>{const g={};return u.render("tr",g,c.children)},nt=(c,u)=>{const{colspan:g,rowspan:f,colwidth:$,backgroundColor:R,...w}=c.attrs||{},_={...w};g>1&&(_.colspan=g),f>1&&(_.rowspan=f);const E=[];return $&&E.push(`width: ${$}px;`),R&&E.push(`background-color: ${R};`),E.length>0&&(_.style=E.join(" ")),u.render("td",N(_),c.children)},at=(c,u)=>{const{colspan:g,rowspan:f,colwidth:$,backgroundColor:R,...w}=c.attrs||{},_={...w};g>1&&(_.colspan=g),f>1&&(_.rowspan=f);const E=[];return $&&E.push(`width: ${$}px;`),R&&E.push(`background-color: ${R};`),E.length>0&&(_.style=E.join(" ")),u.render("th",N(_),c.children)},it=new Map([[v.DOCUMENT,h("")],[v.HEADING,p],[v.PARAGRAPH,h("p")],[v.UL_LIST,h("ul")],[v.OL_LIST,h("ol")],[v.LIST_ITEM,h("li")],[v.IMAGE,d],[v.EMOJI,T],[v.CODE_BLOCK,j],[v.HR,h("hr")],[v.BR,h("br")],[v.QUOTE,h("blockquote")],[v.COMPONENT,rt],[B.TEXT,M],[S.LINK,se],[S.ANCHOR,se],[S.STYLED,b("span",!0)],[S.BOLD,b("strong")],[S.TEXT_STYLE,b("span",!0)],[S.ITALIC,b("em")],[S.UNDERLINE,b("u")],[S.STRIKE,b("s")],[S.CODE,b("code")],[S.SUPERSCRIPT,b("sup")],[S.SUBSCRIPT,b("sub")],[S.HIGHLIGHT,b("mark")],[v.TABLE,st],[v.TABLE_ROW,ot],[v.TABLE_CELL,nt],[v.TABLE_HEADER,at],...Object.entries(o).map(([c,u])=>[c,u])]);function D(c){const u=it.get(c.type);if(!u)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";const g=l();if(c.type==="text")return u(c,g);const f=c.content?c.content.map(F):void 0;return u({...c,children:f},g)}function F(c){return c.type==="doc"?i?c.content.map(D):c.content.map(D).join(""):Array.isArray(c)?c.map(D):D(c)}return{render:F}}let U,X="https://app.storyblok.com/f/storyblok-v2-latest.js";const Q=(s,e,t={})=>{var r;const o=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok"),a=n!==null&&+n===s;if(!(!o||!a)){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"],i=>{var l;i&&(i.action==="input"&&((l=i.story)==null?void 0:l.id)===s?e(i.story):(i.action==="change"||i.action==="published")&&i.storyId===s&&window.location.reload())})})}},Z=(s,e)=>{s.addNode("blok",t=>{let r="";return t.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})},qe=(s={})=>{var e,t;const{bridge:r,accessToken:o,use:n=[],apiOptions:a={},richText:i={},bridgeUrl:l}=s;a.accessToken=a.accessToken||o;const h={bridge:r,apiOptions:a};let d={};n.forEach(T=>{d={...d,...T(h)}}),l&&(X=l);const p=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&p&&oe(X),U=new I(i.schema),i.resolver&&Z(U,i.resolver),d},Ge=s=>{var e;return!s||!((e=s==null?void 0:s.content)!=null&&e.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule"))},Ke=(s,e,t)=>{let r=t||U;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ge(s)?"":(e&&(r=new I(e.schema),e.resolver&&Z(r,e.resolver)),r.render(s,{},!1))},z=m.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){const t=s,r=m.ref();e({value:r});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:r},{...i.$props,...i.$attrs}),null,16))}}),Je=s=>{var e,t;return m.h(z,{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 ee(s){const e={renderFn:m.h,textFn:m.createTextVNode,keyedResolvers:!0,resolvers:{[v.COMPONENT]:Je,...s.resolvers}};return W(e)}const te=m.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(s){const e=s,t=m.ref(),r=()=>t.value;return m.watch([()=>e.doc,()=>e.resolvers],([o,n])=>{const{render:a}=ee({resolvers:n??{}});t.value=a(o)},{immediate:!0,deep:!0}),(o,n)=>(m.openBlock(),m.createBlock(r))}}),Ye={beforeMount(s,e){if(e.value){const t=He(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"))}}},re=s=>{console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
31
- `)};let O=null;const We=()=>(O||re("useStoryblokApi"),O),Xe=async(s,e={},t={})=>{const r=m.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,m.onMounted(()=>{r.value&&r.value.id&&Q(r.value.id,o=>r.value=o,t)}),O){const{data:o}=await O.get(`cdn/stories/${s}`,e);r.value=o.story}else re("useStoryblok");return r},Qe={install(s,e={}){s.directive("editable",Ye),s.component("StoryblokComponent",z),s.component("StoryblokRichText",te),e.enableFallbackComponent&&!e.customFallbackComponent&&s.component("FallbackComponent",m.defineAsyncComponent(()=>Promise.resolve().then(()=>tt)));const{storyblokApi:t}=qe(e);O=t||null,s.provide("VueSDKOptions",e)}},Ze={class:"fallback-component"},et={class:"component"},tt=Object.freeze(Object.defineProperty({__proto__:null,default:((s,e)=>{const t=s.__vccOpts||s;for(const[r,o]of e)t[r]=o;return t})(m.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(s){return(e,t)=>(m.openBlock(),m.createElementBlock("div",Ze,[m.createElementVNode("p",null,[t[0]||(t[0]=m.createTextVNode(" Component could not be found for blok ")),m.createElementVNode("span",et,m.toDisplayString(e.blok.component),1),t[1]||(t[1]=m.createTextVNode("! Is it configured correctly? "))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));k.BlockTypes=v,k.MarkTypes=S,k.RichTextResolver=I,k.RichTextSchema=G,k.StoryblokComponent=z,k.StoryblokRichText=te,k.StoryblokVue=Qe,k.TextTypes=B,k.apiPlugin=De,k.renderRichText=Ke,k.richTextResolver=W,k.useStoryblok=Xe,k.useStoryblokApi=We,k.useStoryblokBridge=Q,k.useStoryblokRichText=ee,Object.defineProperty(k,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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}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"})});