@storyblok/vue 9.2.0 → 9.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -16
- package/dist/storyblok-vue.js +2 -2
- package/dist/storyblok-vue.mjs +401 -366
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
<h1 align="center">@storyblok/vue</h1>
|
|
6
|
+
<p>
|
|
7
|
+
The Vue SDK to interact with <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue" target="_blank">Storyblok API</a> and enable the <a href="https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue" target="_blank">Real-time Visual Editing Experience</a>.
|
|
8
8
|
</p>
|
|
9
9
|
<br />
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href="https://npmjs.com/package/@storyblok/vue">
|
|
14
|
-
<img src="https://img.shields.io/npm/v/@storyblok/vue/latest.svg?style=flat-square" alt="Storyblok Vue SDK" />
|
|
14
|
+
<img src="https://img.shields.io/npm/v/@storyblok/vue/latest.svg?style=flat-square&color=8d60ff" alt="Storyblok Vue SDK" />
|
|
15
15
|
</a>
|
|
16
16
|
<a href="https://npmjs.com/package/@storyblok/vue" rel="nofollow">
|
|
17
|
-
<img src="https://img.shields.io/npm/dt/@storyblok/vue.svg?style=
|
|
17
|
+
<img src="https://img.shields.io/npm/dt/@storyblok/vue.svg?style=appveyor&color=8d60ff" alt="npm">
|
|
18
18
|
</a>
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
|
-
<p align="center">
|
|
22
19
|
<a href="https://storyblok.com/join-discord">
|
|
23
20
|
<img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=8d60ff">
|
|
24
21
|
</a>
|
|
25
22
|
<a href="https://twitter.com/intent/follow?screen_name=storyblok">
|
|
26
23
|
<img src="https://img.shields.io/badge/Follow-%40storyblok-8d60ff?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
|
|
27
|
-
</a
|
|
28
|
-
<a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign
|
|
24
|
+
</a><br/>
|
|
25
|
+
<a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=@storyblok/vue">
|
|
29
26
|
<img src="https://img.shields.io/badge/Try%20Storyblok-Free-8d60ff?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
|
|
30
27
|
</a>
|
|
31
28
|
</p>
|
|
@@ -34,7 +31,11 @@
|
|
|
34
31
|
|
|
35
32
|
- Fetch content from the Content Delivery API
|
|
36
33
|
- Connect frontend components with the Visual Editor via StoryblokBridge
|
|
37
|
-
- Render rich text content
|
|
34
|
+
- Render rich text content with the Storyblok Rich Text Renderer based on `@storyblok/richtext`
|
|
35
|
+
- Vue-specific components: `StoryblokComponent` and `StoryblokRichText`
|
|
36
|
+
- Vue composables: `useStoryblok` and `useStoryblokRichText`
|
|
37
|
+
- Vue directive: `v-editable` for Visual Editor integration
|
|
38
|
+
- Vue plugin for easy integration with Vue applications
|
|
38
39
|
|
|
39
40
|
## Documentation
|
|
40
41
|
|
|
@@ -48,7 +49,7 @@ If you'd like to contribute, please refer to the [contributing guidelines](CONTR
|
|
|
48
49
|
|
|
49
50
|
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
50
51
|
|
|
51
|
-
- [Discuss Storyblok on Github Discussions](https://github.com/storyblok/
|
|
52
|
+
- [Discuss Storyblok on Github Discussions](https://github.com/storyblok/monoblok/discussions)
|
|
52
53
|
|
|
53
54
|
For community support, chatting with other users, please visit:
|
|
54
55
|
|
|
@@ -56,7 +57,7 @@ For community support, chatting with other users, please visit:
|
|
|
56
57
|
|
|
57
58
|
## Support
|
|
58
59
|
|
|
59
|
-
For bugs or feature requests, please [submit an issue](https://github.com/storyblok/
|
|
60
|
+
For bugs or feature requests, please [submit an issue](https://github.com/storyblok/monoblok/issues/new/choose).
|
|
60
61
|
|
|
61
62
|
> [!IMPORTANT]
|
|
62
63
|
> Please search existing issues before submitting a new one. Issues without a minimal reproducible example will be closed. [Why reproductions are Required](https://antfu.me/posts/why-reproductions-are-required).
|
package/dist/storyblok-vue.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using Vue.
|
|
5
5
|
* author: Storyblok
|
|
6
6
|
*/
|
|
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 se(s,e){if(!e)return{src:s,attrs:{}};let t=0,o=0;const r={},n=[];function a(i,u,m,y,S){typeof i!="number"||i<=u||i>=m?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${u} and ${m} (inclusive)`):S.push(`${y}(${i})`)}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:i}=e||{},{blur:u,brightness:m,fill:y,format:S,grayscale:R,quality:L,rotate:P}=i||{};u&&a(u,0,100,"blur",n),L&&a(L,0,100,"quality",n),m&&a(m,0,100,"brightness",n),y&&n.push(`fill(${y})`),R&&n.push("grayscale()"),P&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${P})`),S&&["webp","png","jpeg"].includes(S)&&n.push(`format(${S})`)}e.srcset&&(r.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${s}/m/${i}x0/${n.length>0?`filters:${n.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,m]=i;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 c=`${s}/m/`;return t>0&&o>0&&(c=`${c}${t}x${o}/`),n.length>0&&(c=`${c}filters:${n.join(":")}`),{src:c,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 re=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],oe=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),ne=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function ie(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const O=s=>Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));function V(s,e={},t){const o=oe(e),r=o?`${s} ${o}`:s,n=Array.isArray(t)?t.join(""):t||"";if(s){if(re.includes(s))return`<${r}>`}else return n;return`<${r}>${n}</${s}>`}function B(s={}){const e=new Map,{renderFn:t=V,textFn:o=ie,resolvers:r={},optimizeImages:n=!1,keyedResolvers:a=!1}=s,c=t!==V,i=l=>(h,d)=>{const p=h.attrs||{};return d.render(l,p,h.children||null)},u=(l,h)=>{const{src:d,alt:p,title:g,srcset:T,sizes:_}=l.attrs||{};let w=d,E={};if(n){const{src:Ue,attrs:Me}=se(d,n);w=Ue,E=Me}const He={src:w,alt:p,title:g,srcset:T,sizes:_,...E};return h.render("img",O(He))},m=(l,h)=>{const{level:d,...p}=l.attrs||{};return h.render(`h${d}`,p,l.children)},y=(l,h)=>{var d,p,g,T;const _=h.render("img",{src:(d=l.attrs)==null?void 0:d.fallbackImage,alt:(p=l.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=l.attrs)==null?void 0:g.name,"data-emoji":(T=l.attrs)==null?void 0:T.emoji},_)},S=(l,h)=>h.render("pre",l.attrs||{},h.render("code",{},l.children||"")),R=(l,h=!1)=>({text:d,attrs:p},g)=>{const{class:T,id:_,...w}=p||{},E=h?{class:T,id:_,style:ne(w)||void 0}:p||{};return g.render(l,O(E),d)},L=l=>M(l),P=l=>{const{marks:h,...d}=l;if("text"in l){if(h)return h.reduce((g,T)=>L({...T,text:g}),L({...d,children:d.children}));const p=l.attrs||{};if(a){const g=e.get("txt")||0;e.set("txt",g+1),p.key=`txt-${g}`}return o(d.text,p)}return""},Z=(l,h)=>{const{linktype:d,href:p,anchor:g,...T}=l.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 w={...T};return _&&(w.href=_),h.render("a",w,l.text)},je=(l,h)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=l==null?void 0:l.attrs)==null?void 0:d.body[0],id:(p=l.attrs)==null?void 0:p.id,style:"display: none"})},Pe=(l,h)=>{const d={},p=h.render("tbody",{},l.children);return h.render("table",d,p)},Ne=(l,h)=>{const d={};return h.render("tr",d,l.children)},xe=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const E=[];return g&&E.push(`width: ${g}px;`),T&&E.push(`background-color: ${T};`),E.length>0&&(w.style=E.join(" ")),h.render("td",O(w),l.children)},Be=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const E=[];return g&&E.push(`width: ${g}px;`),T&&E.push(`background-color: ${T};`),E.length>0&&(w.style=E.join(" ")),h.render("th",O(w),l.children)},ee=new Map([[k.DOCUMENT,i("")],[k.HEADING,m],[k.PARAGRAPH,i("p")],[k.UL_LIST,i("ul")],[k.OL_LIST,i("ol")],[k.LIST_ITEM,i("li")],[k.IMAGE,u],[k.EMOJI,y],[k.CODE_BLOCK,S],[k.HR,i("hr")],[k.BR,i("br")],[k.QUOTE,i("blockquote")],[k.COMPONENT,je],[x.TEXT,P],[$.LINK,Z],[$.ANCHOR,Z],[$.STYLED,R("span",!0)],[$.BOLD,R("strong")],[$.TEXT_STYLE,R("span",!0)],[$.ITALIC,R("em")],[$.UNDERLINE,R("u")],[$.STRIKE,R("s")],[$.CODE,R("code")],[$.SUPERSCRIPT,R("sup")],[$.SUBSCRIPT,R("sub")],[$.HIGHLIGHT,R("mark")],[k.TABLE,Pe],[k.TABLE_ROW,Ne],[k.TABLE_CELL,xe],[k.TABLE_HEADER,Be]]),te=new Map([...ee,...Object.entries(r).map(([l,h])=>[l,h])]),De=()=>({render:(l,h={},d)=>{if(a&&l){const p=e.get(l)||0;e.set(l,p+1),h.key=`${l}-${p}`}return t(l,h,d)},originalResolvers:ee,mergedResolvers:te});function N(l){const h=te.get(l.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${l.type}`),"";const d=De();if(l.type==="text")return h(l,d);const p=l.content?l.content.map(M):void 0;return h({...l,children:p},d)}function M(l){return l.type==="doc"?c?l.content.map(N):l.content.map(N).join(""):Array.isArray(l)?l.map(N):N(l)}return{render:M}}let F=!1;const z=[],ae=s=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=r=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}F?r():z.push(r)},document.getElementById("storyblok-javascript-bridge")){e(void 0);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()),F=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(o)});var le=Object.defineProperty,ce=(s,e,t)=>e in s?le(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,b=(s,e,t)=>ce(s,typeof e!="symbol"?e+"":e,t);class ue extends Error{constructor(e){super(e),this.name="AbortError"}}function he(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,a=!1;const c=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&&c(),r=r.filter(y=>y!==m)},t);r.includes(m)||r.push(m)},i=(...u)=>a?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&&c()});return i.abort=()=>{a=!0,r.forEach(clearTimeout),r=[],o.forEach(u=>u.reject(()=>new ue("Throttle function aborted"))),o.length=0},i}const q=(s="")=>s.includes("/cdn/"),de=(s,e=25,t=1)=>({...s,per_page:e,page:t}),pe=s=>new Promise(e=>setTimeout(e,s)),fe=(s=0,e)=>Array.from({length:s},e),me=(s=0,e=s)=>{const t=Math.abs(e-s)||0,o=s<e?1:-1;return fe(t,(r,n)=>n*o+s)},ye=async(s,e)=>Promise.all(s.map(e)),be=(s=[],e)=>s.map(e).reduce((t,o)=>[...t,...o],[]),D=(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 a=t?"":encodeURIComponent(r);let c;typeof n=="object"?c=D(n,e?e+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):c=`${e?e+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,o.push(c)}return o.join("&")},G=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 ke{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}?${D(this.parameters)}`:o=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:a}=n;let c;this.timeout&&(c=setTimeout(()=>n.abort(),this.timeout));try{const i=await this.fetch(`${r}`,{method:e,headers:this.headers,body:o,signal:a,...this.fetchOptions});this.timeout&&clearTimeout(c);const u=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}catch(i){return{message:i}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((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 J="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},ge={PUBLISHED:"published"};let j={};const A={};class ve{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 a=e.https===!1?"http":"https";e.oauthToken?o=`${a}://${G(e.region)}/v1`:o=`${a}://${G(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(([a,c])=>{r.set(a,c)}),r.has(J)||(r.set(J,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=he(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||ge.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new ke({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=A[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return q(e)?this.parseParams(t):t}makeRequest(e,t,o,r,n){const a=this.factoryParamOptions(e,de(t,o,r));return this.cacheResponse(e,a,void 0,n)}get(e,t={},o){t||(t={});const r=`/${e}`;q(r)&&(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,a=`/${e}`.replace(/\/$/,""),c=o??a.substring(a.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,u=await this.makeRequest(a,t,n,i,r),m=u.total?Math.ceil(u.total/n):1,y=await ye(me(i,m),S=>this.makeRequest(a,t,n,S+1,r));return be([u,...y],S=>Object.values(S.data[c]))}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(a=>a.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,a="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((c,i)=>r(c,`${a}[${i}]`));else if(typeof n=="object")for(const c in n){const i=a?`${a}.${c}`:c;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,c,t,o),this._insertLinks(n,c,o)),r(n[c],i)}}};r(e.content)}async resolveLinks(e,t,o){let r=[];if(e.link_uuids){const n=e.link_uuids.length,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.link_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].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,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.rel_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].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 a=[];if(this.links[o]={},this.relations[o]={},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,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 c in this.relations[o])this.iterateTree(this.relations[o][c],a,o);e.story?this.iterateTree(e.story,a,o):e.stories.forEach(c=>{this.iterateTree(c,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(e,t,o,r){const n=D({url:e,params:t}),a=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await a.get(n);if(c)return Promise.resolve(c)}return new Promise(async(c,i)=>{var u;try{const m=await this.throttle("get",e,t,r);if(m.status!==200)return i(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 R=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${R}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await a.set(n,y);const S=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(S&&A[t.token]&&A[t.token]!==y.data.cv&&await this.flushCache(),A[t.token]=y.data.cv),c(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 pe(this.retriesDelay),this.cacheResponse(e,t,o).then(c).catch(i);i(m)}})}throttledRequest(e,t,o,r){return this.client.setFetchOptions(r),this.client[e](t,o)}cacheVersions(){return A}cacheVersion(){return A[this.accessToken]}setCacheVersion(e){this.accessToken&&(A[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(A[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=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 _e=(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 ve(e)}},we=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 K="https://app.storyblok.com/f/storyblok-v2-latest.js";const Y=(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"),a=n!==null&&+n===s;if(!(!r||!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"],c=>{var i;c&&(c.action==="input"&&((i=c.story)==null?void 0:i.id)===s?e(c.story):(c.action==="change"||c.action==="published")&&c.storyId===s&&window.location.reload())})})}},Te=(s={})=>{var e,t;const{bridge:o,accessToken:r,use:n=[],apiOptions:a={},bridgeUrl:c}=s;a.accessToken=a.accessToken||r;const i={bridge:o,apiOptions:a};let u={};n.forEach(y=>{u={...u,...y(i)}}),c&&(K=c);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&&ae(K),u};function $e(s,e){return B(e).render(s)}const U=f.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){var c;const t=s,o=f.ref();e({value:o});const r=typeof f.resolveDynamicComponent(t.blok.component)!="string",n=f.inject("VueSDKOptions"),a=f.ref((c=t.blok.component)==null?void 0:c.replace(/_/g,"-"));return!r&&n&&(n.enableFallbackComponent?(a.value=n.customFallbackComponent??"FallbackComponent",typeof f.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,u)=>(f.openBlock(),f.createBlock(f.resolveDynamicComponent(a.value),f.mergeProps({ref_key:"blokRef",ref:o},{...i.$props,...i.$attrs}),null,16))}}),Re=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 W(s){const e={renderFn:f.h,textFn:f.createTextVNode,keyedResolvers:!0,resolvers:{[k.COMPONENT]:Re,...s.resolvers}};return B(e)}const X=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:a}=W({resolvers:n??{}});t.value=a(r)},{immediate:!0,deep:!0}),(r,n)=>(f.openBlock(),f.createBlock(o))}}),Ee={beforeMount(s,e){if(e.value){const t=we(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"))}}},Q=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
|
|
7
|
+
(function(k,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(k=typeof globalThis<"u"?globalThis:k||self,f(k.storyblokVue={},k.Vue))})(this,function(k,f){"use strict";function C(r,e,t){this.type=r,this.tag=e,this.attrs=null,this.map=null,this.nesting=t,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}C.prototype.attrIndex=function(r){if(!this.attrs)return-1;const e=this.attrs;for(let t=0,s=e.length;t<s;t++)if(e[t][0]===r)return t;return-1},C.prototype.attrPush=function(r){this.attrs?this.attrs.push(r):this.attrs=[r]},C.prototype.attrSet=function(r,e){const t=this.attrIndex(r),s=[r,e];t<0?this.attrPush(s):this.attrs[t]=s},C.prototype.attrGet=function(r){const e=this.attrIndex(r);let t=null;return e>=0&&(t=this.attrs[e][1]),t},C.prototype.attrJoin=function(r,e){const t=this.attrIndex(r);t<0?this.attrPush([r,e]):this.attrs[t][1]=this.attrs[t][1]+" "+e};const oe="[a-zA-Z_:][a-zA-Z0-9:._-]*",ne="[^\"'=<>`\\x00-\\x20]+",ie="'[^']*'",ae='"[^"]*"',le="(?:"+ne+"|"+ie+"|"+ae+")",ce="(?:\\s+"+oe+"(?:\\s*=\\s*"+le+")?)",ue="<[A-Za-z][A-Za-z0-9\\-]*"+ce+"*\\s*\\/?>",he="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",de=new RegExp("^(?:"+ue+"|"+he+")");new RegExp(de.source+"\\s*$");const V=[];for(let r=0;r<256;r++)V.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){V[r.charCodeAt(0)]=1});let v=function(r){return 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}({}),E=function(r){return 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}({}),z=function(r){return r.TEXT="text",r}({}),j=function(r){return r.URL="url",r.STORY="story",r.ASSET="asset",r.EMAIL="email",r}({});function pe(r,e){if(!e)return{src:r,attrs:{}};let t=0,s=0;const o={},n=[];function a(i,u,y,m,A){typeof i!="number"||i<=u||i>=y?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${u} and ${y} (inclusive)`):A.push(`${m}(${i})`)}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:i}=e||{},{blur:u,brightness:y,fill:m,format:A,grayscale:R,quality:L,rotate:x}=i||{};u&&a(u,0,100,"blur",n),L&&a(L,0,100,"quality",n),y&&a(y,0,100,"brightness",n),m&&n.push(`fill(${m})`),R&&n.push("grayscale()"),x&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${x})`),A&&["webp","png","jpeg"].includes(A)&&n.push(`format(${A})`)}e.srcset&&(o.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${r}/m/${i}x0/${n.length>0?`filters:${n.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,y]=i;return`${r}/m/${u}x${y}/${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&&(o.sizes=e.sizes.join(", "))}let c=`${r}/m/`;return t>0&&s>0&&(c=`${c}${t}x${s}/`),n.length>0&&(c=`${c}filters:${n.join(":")}`),{src:c,attrs:o}}const fe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ye=(r={})=>Object.keys(r).map(e=>`${e}="${r[e]}"`).join(" "),me=(r={})=>Object.keys(r).map(e=>`${e}: ${r[e]}`).join("; ");function be(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const O=r=>Object.fromEntries(Object.entries(r).filter(([e,t])=>t!==void 0));function F(r,e={},t){const s=ye(e),o=s?`${r} ${s}`:r,n=Array.isArray(t)?t.join(""):t||"";if(r){if(fe.includes(r))return`<${o}>`}else return n;return`<${o}>${n}</${r}>`}function D(r={}){const e=new Map,{renderFn:t=F,textFn:s=be,resolvers:o={},optimizeImages:n=!1,keyedResolvers:a=!1}=r,c=t!==F,i=l=>(h,d)=>{const p=h.attrs||{};return d.render(l,p,h.children||null)},u=(l,h)=>{const{src:d,alt:p,title:g,srcset:T,sizes:_}=l.attrs||{};let w=d,$={};if(n){const{src:We,attrs:Xe}=pe(d,n);w=We,$=Xe}const Ze={src:w,alt:p,title:g,srcset:T,sizes:_,...$};return h.render("img",O(Ze))},y=(l,h)=>{const{level:d,...p}=l.attrs||{};return h.render(`h${d}`,p,l.children)},m=(l,h)=>{var d,p,g,T;const _=h.render("img",{src:(d=l.attrs)==null?void 0:d.fallbackImage,alt:(p=l.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=l.attrs)==null?void 0:g.name,"data-emoji":(T=l.attrs)==null?void 0:T.emoji},_)},A=(l,h)=>h.render("pre",l.attrs||{},h.render("code",{},l.children||"")),R=(l,h=!1)=>({text:d,attrs:p},g)=>{const{class:T,id:_,...w}=p||{},$=h?{class:T,id:_,style:me(w)||void 0}:p||{};return g.render(l,O($),d)},L=l=>M(l),x=l=>{const{marks:h,...d}=l;if("text"in l){if(h)return h.reduce((g,T)=>L({...T,text:g}),L({...d,children:d.children}));const p=l.attrs||{};if(a){const g=e.get("txt")||0;e.set("txt",g+1),p.key=`txt-${g}`}return s(d.text,p)}return""},te=(l,h)=>{const{linktype:d,href:p,anchor:g,...T}=l.attrs||{};let _="";switch(d){case j.ASSET:case j.URL:_=p;break;case j.EMAIL:_=`mailto:${p}`;break;case j.STORY:_=p,g&&(_=`${_}#${g}`);break;default:_=p;break}const w={...T};return _&&(w.href=_),h.render("a",w,l.text)},Fe=(l,h)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=l==null?void 0:l.attrs)==null?void 0:d.body[0],id:(p=l.attrs)==null?void 0:p.id,style:"display: none"})},Ge=(l,h)=>{const d={},p=h.render("tbody",{},l.children);return h.render("table",d,p)},qe=(l,h)=>{const d={};return h.render("tr",d,l.children)},Je=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const $=[];return g&&$.push(`width: ${g}px;`),T&&$.push(`background-color: ${T};`),$.length>0&&(w.style=$.join(" ")),h.render("td",O(w),l.children)},Ke=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const $=[];return g&&$.push(`width: ${g}px;`),T&&$.push(`background-color: ${T};`),$.length>0&&(w.style=$.join(" ")),h.render("th",O(w),l.children)},re=new Map([[v.DOCUMENT,i("")],[v.HEADING,y],[v.PARAGRAPH,i("p")],[v.UL_LIST,i("ul")],[v.OL_LIST,i("ol")],[v.LIST_ITEM,i("li")],[v.IMAGE,u],[v.EMOJI,m],[v.CODE_BLOCK,A],[v.HR,i("hr")],[v.BR,i("br")],[v.QUOTE,i("blockquote")],[v.COMPONENT,Fe],[z.TEXT,x],[E.LINK,te],[E.ANCHOR,te],[E.STYLED,R("span",!0)],[E.BOLD,R("strong")],[E.TEXT_STYLE,R("span",!0)],[E.ITALIC,R("em")],[E.UNDERLINE,R("u")],[E.STRIKE,R("s")],[E.CODE,R("code")],[E.SUPERSCRIPT,R("sup")],[E.SUBSCRIPT,R("sub")],[E.HIGHLIGHT,R("mark")],[v.TABLE,Ge],[v.TABLE_ROW,qe],[v.TABLE_CELL,Je],[v.TABLE_HEADER,Ke]]),se=new Map([...re,...Object.entries(o).map(([l,h])=>[l,h])]),Ye=()=>({render:(l,h={},d)=>{if(a&&l){const p=e.get(l)||0;e.set(l,p+1),h.key=`${l}-${p}`}return t(l,h,d)},originalResolvers:re,mergedResolvers:se});function N(l){const h=se.get(l.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${l.type}`),"";const d=Ye();if(l.type==="text")return h(l,d);const p=l.content?l.content.map(M):void 0;return h({...l,children:p},d)}function M(l){return l.type==="doc"?c?l.content.map(N):l.content.map(N).join(""):Array.isArray(l)?l.map(N):N(l)}return{render:M}}let G=!1;const q=[],ge=r=>new Promise((e,t)=>{if(typeof window>"u"){t(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=o=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}G?o():q.push(o)},document.getElementById("storyblok-javascript-bridge")){e(void 0);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=>{q.forEach(n=>n()),G=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(s)});var ke=Object.defineProperty,ve=(r,e,t)=>e in r?ke(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,b=(r,e,t)=>ve(r,typeof e!="symbol"?e+"":e,t);class _e extends Error{constructor(e){super(e),this.name="AbortError"}}function we(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 c=async()=>{n++;const u=s.shift();if(u)try{const m=await r(...u.args);u.resolve(m)}catch(m){u.reject(m)}const y=setTimeout(()=>{n--,s.length>0&&c(),o=o.filter(m=>m!==y)},t);o.includes(y)||o.push(y)},i=(...u)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((y,m)=>{s.push({resolve:y,reject:m,args:u}),n<e&&c()});return i.abort=()=>{a=!0,o.forEach(clearTimeout),o=[],s.forEach(u=>u.reject(()=>new _e("Throttle function aborted"))),s.length=0},i}const J=(r="")=>r.includes("/cdn/"),Te=(r,e=25,t=1)=>({...r,per_page:e,page:t}),Re=r=>new Promise(e=>setTimeout(e,r)),$e=(r=0,e)=>Array.from({length:r},e),Ee=(r=0,e=r)=>{const t=Math.abs(e-r)||0,s=r<e?1:-1;return $e(t,(o,n)=>n*s+r)},Ae=async(r,e)=>Promise.all(r.map(e)),Se=(r=[],e)=>r.map(e).reduce((t,s)=>[...t,...s],[]),B=(r,e,t)=>{const s=[];for(const o in r){if(!Object.prototype.hasOwnProperty.call(r,o))continue;const n=r[o];if(n==null)continue;const a=t?"":encodeURIComponent(o);let c;typeof n=="object"?c=B(n,e?e+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):c=`${e?e+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,s.push(c)}return s.join("&")},K=r=>{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[r]??e.eu};class Ce{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=[],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;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:s=JSON.stringify(this.parameters);const o=new URL(t),n=new AbortController,{signal:a}=n;let c;this.timeout&&(c=setTimeout(()=>n.abort(),this.timeout));try{const i=await this.fetch(`${o}`,{method:e,headers:this.headers,body:s,signal:a,...this.fetchOptions});this.timeout&&clearTimeout(c);const u=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}catch(i){return{message:i}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,o)=>{if(t.test(`${e.status}`))return s(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};o(n)})}}const Y="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},Ie={PUBLISHED:"published"};let P={};const S={};class Le{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 s=e.endpoint||t;if(!s){const a=e.https===!1?"http":"https";e.oauthToken?s=`${a}://${K(e.region)}/v1`:s=`${a}://${K(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,c])=>{o.set(a,c)}),o.has(Y)||(o.set(Y,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),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=we(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||Ie.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new Ce({baseURL:s,timeout:e.timeout||0,headers:o,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=S[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 J(e)?this.parseParams(t):t}makeRequest(e,t,s,o,n){const a=this.factoryParamOptions(e,Te(t,s,o));return this.cacheResponse(e,a,void 0,n)}get(e,t={},s){t||(t={});const o=`/${e}`;J(o)&&(t.version=t.version||this.version);const 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(/\/$/,""),c=s??a.substring(a.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,u=await this.makeRequest(a,t,n,i,o),y=u.total?Math.ceil(u.total/(u.perPage||n)):1,m=await Ae(Ee(i,y),A=>this.makeRequest(a,t,n,A+1,o));return Se([u,...m],A=>Object.values(A.data[c]))}post(e,t={},s){const o=`/${e}`;return this.throttle("post",o,t,s)}put(e,t={},s){const o=`/${e}`;return this.throttle("put",o,t,s)}delete(e,t={},s){t||(t={});const o=`/${e}`;return 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((c,i)=>o(c,`${a}[${i}]`));else if(typeof n=="object")for(const c in n){const i=a?`${a}.${c}`:c;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,c,t,s),this._insertLinks(n,c,s)),o(n[c],i)}}};o(e.content)}async resolveLinks(e,t,s){let o=[];if(e.link_uuids){const n=e.link_uuids.length,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.link_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].join(",")})).data.stories.forEach(u=>{o.push(u)})}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=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.rel_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{o.push(u)});o.length>0&&(e.rels=o,delete e.rel_uuids)}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 c in this.relations[s])this.iterateTree(this.relations[s][c],a,s);e.story?this.iterateTree(e.story,a,s):e.stories.forEach(c=>{this.iterateTree(c,a,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s,o){const n=B({url:e,params:t}),a=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await a.get(n);if(c)return Promise.resolve(c)}return new Promise(async(c,i)=>{var u;try{const y=await this.throttle("get",e,t,o);if(y.status!==200)return i(y);let m={data:y.data,headers:y.headers};if((u=y.headers)!=null&&u["per-page"]&&(m=Object.assign({},m,{perPage:y.headers["per-page"]?Number.parseInt(y.headers["per-page"]):0,total:y.headers["per-page"]?Number.parseInt(y.headers.total):0})),m.data.story||m.data.stories){const R=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(m.data,t,`${R}`),m=await this.processInlineAssets(m)}t.version==="published"&&e!=="/cdn/spaces/me"&&await a.set(n,m);const A=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&m.data.cv&&(A&&S[t.token]&&S[t.token]!==m.data.cv&&await this.flushCache(),S[t.token]=m.data.cv),c(m)}catch(y){if(y.response&&y.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 Re(this.retriesDelay),this.cacheResponse(e,t,s).then(c).catch(i);i(y)}})}throttledRequest(e,t,s,o){return this.client.setFetchOptions(o),this.client[e](t,s)}cacheVersions(){return S}cacheVersion(){return S[this.accessToken]}setCacheVersion(e){this.accessToken&&(S[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(S[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=s=>{if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(n=>t(n));let o={...s};o.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(o={...o,...e.data.assets.find(n=>n.id===o.id)});for(const n in o)typeof o[n]=="object"&&(o[n]=t(o[n]));return o};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(s=>(s.content=t(s.content),s))),e}}const je=(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 Le(e)}},Oe=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{}}};let Z="https://app.storyblok.com/f/storyblok-v2-latest.js";const W=(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"],c=>{var i;c&&(c.action==="input"&&((i=c.story)==null?void 0:i.id)===r?e(c.story):(c.action==="change"||c.action==="published")&&c.storyId===r&&window.location.reload())})})}},Pe=(r={})=>{var e,t;const{bridge:s,accessToken:o,use:n=[],apiOptions:a={},bridgeUrl:c}=r;a.accessToken=a.accessToken||o;const i={bridge:s,apiOptions:a};let u={};n.forEach(m=>{u={...u,...m(i)}}),c&&(Z=c);const y=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return s!==!1&&y&&ge(Z),u};function xe(r,e){return D(e).render(r)}const U=f.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(r,{expose:e}){var c;const t=r,s=f.ref();e({value:s});const o=typeof f.resolveDynamicComponent(t.blok.component)!="string",n=f.inject("VueSDKOptions"),a=f.ref((c=t.blok.component)==null?void 0:c.replace(/_/g,"-"));return!o&&n&&(n.enableFallbackComponent?(a.value=n.customFallbackComponent??"FallbackComponent",typeof f.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,u)=>(f.openBlock(),f.createBlock(f.resolveDynamicComponent(a.value),f.mergeProps({ref_key:"blokRef",ref:s},{...i.$props,...i.$attrs}),null,16))}}),Ne=r=>{var e,t;return f.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 X(r){const e={renderFn:f.h,textFn:f.createTextVNode,keyedResolvers:!0,resolvers:{[v.COMPONENT]:Ne,...r.resolvers}};return D(e)}const Q=f.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(r){const e=r,t=f.ref(),s=()=>t.value;return f.watch([()=>e.doc,()=>e.resolvers],([o,n])=>{const{render:a}=X({resolvers:n??{}});t.value=a(o)},{immediate:!0,deep:!0}),(o,n)=>(f.openBlock(),f.createBlock(s))}}),De={beforeMount(r,e){if(e.value){const t=Oe(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"))}}},ee=r=>{console.error(`You can't use ${r} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
8
|
+
`)};let I=null;const Be=()=>(I||ee("useStoryblokApi"),I),He=async(r,e={},t={})=>{const s=f.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,f.onMounted(()=>{s.value&&s.value.id&&W(s.value.id,o=>s.value=o,t)}),I){const{data:o}=await I.get(`cdn/stories/${r}`,e);s.value=o.story}else ee("useStoryblok");return s},Ue={install(r,e={}){r.directive("editable",De),r.component("StoryblokComponent",U),r.component("StoryblokRichText",Q),e.enableFallbackComponent&&!e.customFallbackComponent&&r.component("FallbackComponent",f.defineAsyncComponent(()=>Promise.resolve().then(()=>ze)));const{storyblokApi:t}=Pe(e);I=t||null,r.provide("VueSDKOptions",e)}},Me={class:"fallback-component"},Ve={class:"component"},ze=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})(f.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(r){return(e,t)=>(f.openBlock(),f.createElementBlock("div",Me,[f.createElementVNode("p",null,[t[0]||(t[0]=f.createTextVNode(" Component could not be found for blok ")),f.createElementVNode("span",Ve,f.toDisplayString(e.blok.component),1),t[1]||(t[1]=f.createTextVNode("! Is it configured correctly? "))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));k.BlockTypes=v,k.MarkTypes=E,k.StoryblokComponent=U,k.StoryblokRichText=Q,k.StoryblokVue=Ue,k.TextTypes=z,k.apiPlugin=je,k.renderRichText=xe,k.richTextResolver=D,k.useStoryblok=He,k.useStoryblokApi=Be,k.useStoryblokBridge=W,k.useStoryblokRichText=X,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|