@storyblok/vue 9.3.1 → 9.3.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.
@@ -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,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(v=typeof globalThis<"u"?globalThis:v||self,d(v.storyblokVue={},v.Vue))})(this,function(v,d){"use strict";var se=Object.defineProperty,ne=(e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,k=(e,t,r)=>ne(e,typeof t!="symbol"?t+"":t,r);let _=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),$=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),V=function(e){return e.TEXT="text",e}({}),j=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const oe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ie=(e={})=>Object.keys(e).map(t=>`${t}="${e[t]}"`).join(" "),ae=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function le(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const C=e=>Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0));function ce(e,t){if(!t)return{src:e,attrs:{}};let r=0,s=0;const n={},o=[];function l(c,u,y,m,A){typeof c!="number"||c<=u||c>=y?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${u} and ${y} (inclusive)`):A.push(`${m}(${c})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(n.width=t.width,r=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),t.height&&typeof t.height=="number"&&t.height>0?(n.height=t.height,s=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),t.loading&&["lazy","eager"].includes(t.loading)&&(n.loading=t.loading),t.class&&(n.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:y,fill:m,format:A,grayscale:U,quality:R,rotate:L}=c||{};u&&l(u,0,100,"blur",o),R&&l(R,0,100,"quality",o),y&&l(y,0,100,"brightness",o),m&&o.push(`fill(${m})`),U&&o.push("grayscale()"),L&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${L})`),A&&["webp","png","jpeg"].includes(A)&&o.push(`format(${A})`)}t.srcset&&(n.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,y]=c;return`${e}/m/${u}x${y}/${o.length>0?`filters:${o.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(n.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return r>0&&s>0&&(a=`${a}${r}x${s}/`),o.length>0&&(a=`${a}filters:${o.join(":")}`),{src:a,attrs:n}}function F(e,t={},r){const s=ie(t),n=s?`${e} ${s}`:e,o=Array.isArray(r)?r.join(""):r||"";if(e){if(oe.includes(e))return`<${n}>`}else return o;return`<${n}>${o}</${e}>`}function N(e={}){const t=new Map,{renderFn:r=F,textFn:s=le,resolvers:n={},optimizeImages:o=!1,keyedResolvers:l=!1}=e,a=r!==F,c=(i={})=>{const{textAlign:h,class:p,id:f,style:b,...w}=i,g=[];return b&&g.push(b.endsWith(";")?b:`${b};`),h&&g.push(`text-align: ${h};`),C({...w,class:p,id:f,...g.length>0?{style:g.join(" ")}:{}})},u=i=>(h,p)=>{const f=c(h.attrs);return p.render(i,f,h.children||null)},y=(i,h)=>{const{src:p,alt:f,title:b,srcset:w,sizes:g}=i.attrs||{};let S=p,T={};if(o){const{src:ze,attrs:qe}=ce(p,o);S=ze,T=qe}const O={src:S,alt:f,title:b,srcset:w,sizes:g,...T};return h.render("img",C(O))},m=(i,h)=>{const{level:p,...f}=i.attrs||{},b=c(f);return h.render(`h${p}`,b,i.children)},A=(i,h)=>{var p,f,b,w;const g=h.render("img",{src:(p=i.attrs)==null?void 0:p.fallbackImage,alt:(f=i.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(b=i.attrs)==null?void 0:b.name,"data-emoji":(w=i.attrs)==null?void 0:w.emoji},g)},U=(i,h)=>h.render("pre",i.attrs||{},h.render("code",{},i.children||"")),R=(i,h=!1)=>({text:p,attrs:f},b)=>{const{class:w,id:g,...S}=f||{},T=h?{class:w,id:g,style:ae(S)||void 0}:f||{};return b.render(i,C(T),p)},L=i=>M(i),Be=i=>{const{marks:h,...p}=i;if("text"in i){if(h)return h.reduce((b,w)=>L({...w,text:b}),L({...p,children:p.children}));const f=i.attrs||{};if(l){const b=t.get("txt")||0;t.set("txt",b+1),f.key=`txt-${b}`}return s(p.text,f)}return""},ee=(i,h)=>{const{linktype:p,href:f,anchor:b,...w}=i.attrs||{};let g="";switch(p){case j.ASSET:case j.URL:g=f;break;case j.EMAIL:g=`mailto:${f}`;break;case j.STORY:g=f,b&&(g=`${g}#${b}`);break;default:g=f;break}const S={...w};return g&&(S.href=g),h.render("a",S,i.text)},De=(i,h)=>{var p,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(p=i==null?void 0:i.attrs)==null?void 0:p.body[0],id:(f=i.attrs)==null?void 0:f.id,style:"display: none"})},He=(i,h)=>{const p=c(i.attrs),f=i.children||null;return h.render("table",p,h.render("tbody",{},f))},Ue=(i,h)=>{const p=c(i.attrs);return h.render("tr",p,i.children)},Me=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...S}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...S,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("td",C(O),i.children)},Ve=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...S}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...S,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("th",C(O),i.children)},te=new Map([[_.DOCUMENT,u("")],[_.HEADING,m],[_.PARAGRAPH,u("p")],[_.UL_LIST,u("ul")],[_.OL_LIST,u("ol")],[_.LIST_ITEM,u("li")],[_.IMAGE,y],[_.EMOJI,A],[_.CODE_BLOCK,U],[_.HR,u("hr")],[_.BR,u("br")],[_.QUOTE,u("blockquote")],[_.COMPONENT,De],[V.TEXT,Be],[$.LINK,ee],[$.ANCHOR,ee],[$.STYLED,R("span",!0)],[$.BOLD,R("strong")],[$.TEXT_STYLE,R("span",!0)],[$.ITALIC,R("em")],[$.UNDERLINE,R("u")],[$.STRIKE,R("s")],[$.CODE,R("code")],[$.SUPERSCRIPT,R("sup")],[$.SUBSCRIPT,R("sub")],[$.HIGHLIGHT,R("mark")],[_.TABLE,He],[_.TABLE_ROW,Ue],[_.TABLE_CELL,Me],[_.TABLE_HEADER,Ve]]),re=new Map([...te,...Object.entries(n).map(([i,h])=>[i,h])]),Fe=()=>({render:(i,h={},p)=>{if(l&&i){const f=t.get(i)||0;t.set(i,f+1),h.key=`${i}-${f}`}return r(i,h,p)},originalResolvers:te,mergedResolvers:re});function x(i){const h=re.get(i.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const p=Fe();if(i.type==="text")return h(i,p);const f=i.content?i.content.map(M):void 0;return h({...i,children:f},p)}function M(i){return i.type==="doc"?a?i.content.map(x):i.content.map(x).join(""):Array.isArray(i)?i.map(x):x(i)}return{render:M}}let z=!1;const q=[],ue=e=>new Promise((t,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?n():q.push(n)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const s=document.createElement("script");s.async=!0,s.src=e,s.id="storyblok-javascript-bridge",s.onerror=n=>r(n),s.onload=n=>{q.forEach(o=>o()),z=!0,t(n)},document.getElementsByTagName("head")[0].appendChild(s)});var he=class extends Error{constructor(e){super(e),this.name="AbortError"}};function de(e,t,r){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");const s=[];let n=[],o=0,l=!1;const a=async()=>{o++;const u=s.shift();if(u)try{const m=await e(...u.args);u.resolve(m)}catch(m){u.reject(m)}const y=setTimeout(()=>{o--,s.length>0&&a(),n=n.filter(m=>m!==y)},r);n.includes(y)||n.push(y)},c=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((y,m)=>{s.push({resolve:y,reject:m,args:u}),o<t&&a()});return c.abort=()=>{l=!0,n.forEach(clearTimeout),n=[],s.forEach(u=>u.reject(()=>new he("Throttle function aborted"))),s.length=0},c}var pe=de;const G=(e="")=>e.includes("/cdn/"),fe=(e,t=25,r=1)=>({...e,per_page:t,page:r}),ye=e=>new Promise(t=>setTimeout(t,e)),me=(e=0,t)=>Array.from({length:e},t),be=(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return me(r,(n,o)=>o*s+e)},ge=async(e,t)=>Promise.all(e.map(t)),ke=(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[]),B=(e,t,r)=>{const s=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const l=r?"":encodeURIComponent(n);let a;typeof o=="object"?a=B(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,s.push(a)}return s.join("&")},J=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var ve=class{constructor(e){k(this,"baseURL"),k(this,"timeout"),k(this,"headers"),k(this,"responseInterceptor"),k(this,"fetch"),k(this,"ejectInterceptor"),k(this,"url"),k(this,"parameters"),k(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:o}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:o,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(n)})}},_e=ve;const K="SB-Agent",D={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},we={PUBLISHED:"published"};let P={};const E={};var Te=class{constructor(e,t){k(this,"client"),k(this,"maxRetries"),k(this,"retriesDelay"),k(this,"throttle"),k(this,"accessToken"),k(this,"cache"),k(this,"resolveCounter"),k(this,"relations"),k(this,"links"),k(this,"version"),k(this,"richTextResolver"),k(this,"resolveNestedRelations"),k(this,"stringifiedStoriesCache"),k(this,"inlineAssets");let r=e.endpoint||t;if(!r){const o=e.https===!1?"http":"https";e.oauthToken?r=`${o}://${J(e.region)}/v1`:r=`${o}://${J(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([o,l])=>{s.set(o,l)}),s.has(K)||(s.set(K,D.defaultAgentName),s.set(D.defaultAgentVersion,D.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=pe(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||we.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new _e({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return G(e)?this.parseParams(t):t}makeRequest(e,t,r,s,n){const o=this.factoryParamOptions(e,fe(t,r,s));return this.cacheResponse(e,o,void 0,n)}get(e,t={},r){t||(t={});const s=`/${e}`;G(s)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,r)}async getAll(e,t={},r,s){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),l=r??o.substring(o.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,c=await this.makeRequest(o,t,n,a,s),u=c.total?Math.ceil(c.total/(c.perPage||n)):1,y=await ge(be(a,u),m=>this.makeRequest(o,t,n,m+1,s));return ke([c,...y],m=>Object.values(m.data[l]))}post(e,t={},r){const s=`/${e}`;return this.throttle("post",s,t,r)}put(e,t={},r){const s=`/${e}`;return this.throttle("put",s,t,r)}delete(e,t={},r){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(o=>o.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>s(l,`${o}[${a}]`));else if(typeof n=="object")for(const l in n){const a=o?`${o}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,r),this._insertLinks(n,l,r)),s(n[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.links;s.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{s.push(c)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var s,n;let o=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],o,r);e.story?this.iterateTree(e.story,o,r):e.stories.forEach(l=>{this.iterateTree(l,o,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const n=B({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await o.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var c;try{const u=await this.throttle("get",e,t,s);if(u.status!==200)return a(u);let y={data:u.data,headers:u.headers};if((c=u.headers)!=null&&c["per-page"]&&(y=Object.assign({},y,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),y.data.story||y.data.stories){const A=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${A}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,y);const m=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(m&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(u){if(u.response&&u.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ye(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(a);a(u)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(P[e])},getAll(){return Promise.resolve(P)},set(e,t){return P[e]=t,Promise.resolve(void 0)},flush(){return P={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(n=>t(n));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...s,...e.data.assets.find(n=>n.id===s.id)});for(const n in s)typeof s[n]=="object"&&(s[n]=t(s[n]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}},$e=Te;const Re=(e={})=>{const{apiOptions:t}=e;if(!t||!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new $e(t)}},Ae=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let Y="https://app.storyblok.com/f/storyblok-v2-latest.js";const W=(e,t,r={})=>{var s;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok"),l=o!==null&&+o===e;if(!(!n||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],a=>{var c;a&&(a.action==="input"&&((c=a.story)==null?void 0:c.id)===e?t(a.story):(a.action==="change"||a.action==="published")&&a.storyId===e&&window.location.reload())})})}},Se=(e={})=>{var t,r;const{bridge:s,accessToken:n,use:o=[],apiOptions:l={},bridgeUrl:a}=e;l.accessToken=l.accessToken||n;const c={bridge:s,apiOptions:l};let u={};o.forEach(m=>{u={...u,...m(c)}}),a&&(Y=a);const y=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return s!==!1&&y&&ue(Y),u};function Ee(e,t){return N(t).render(e)}const H=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var a;const r=e,s=d.ref();t({value:s});const n=typeof d.resolveDynamicComponent(r.blok.component)!="string",o=d.inject("VueSDKOptions"),l=d.ref((a=r.blok.component)==null?void 0:a.replace(/_/g,"-"));return!n&&o&&(o.enableFallbackComponent?(l.value=o.customFallbackComponent??"FallbackComponent",typeof d.resolveDynamicComponent(l.value)=="string"&&console.error(`Is the Fallback component "${l.value}" registered properly?`)):console.error(`Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`)),(c,u)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(l.value),d.mergeProps({ref_key:"blokRef",ref:s},{...c.$props,...c.$attrs}),d.createSlots({_:2},[d.renderList(c.$slots,(y,m)=>({name:m,fn:d.withCtx(A=>[d.renderSlot(c.$slots,m,d.normalizeProps(d.guardReactiveProps(A)))])}))]),1040))}}),Ce=e=>{var r;const t=(r=e==null?void 0:e.attrs)==null?void 0:r.body;return!Array.isArray(t)||t.length===0?[]:t.map(s=>{var n;return d.h(H,{blok:s,id:(n=e==null?void 0:e.attrs)==null?void 0:n.id},e.children)})};function X(e){const t={renderFn:d.h,textFn:d.createTextVNode,keyedResolvers:!0,resolvers:{[_.COMPONENT]:Ce,...e.resolvers}};return N(t)}const Q=d.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(e){const t=e,r=d.ref(),s=()=>r.value;return d.watch([()=>t.doc,()=>t.resolvers],([n,o])=>{const{render:l}=X({resolvers:o??{}});r.value=l(n)},{immediate:!0,deep:!0}),(n,o)=>(d.openBlock(),d.createBlock(s))}}),Ie={beforeMount(e,t){if(t.value){const r=Ae(t.value);Object.keys(r).length>0&&(e.setAttribute("data-blok-c",r["data-blok-c"]),e.setAttribute("data-blok-uid",r["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},Z=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
7
+ (function(v,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(v=typeof globalThis<"u"?globalThis:v||self,d(v.storyblokVue={},v.Vue))})(this,function(v,d){"use strict";var se=Object.defineProperty,ne=(e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,k=(e,t,r)=>ne(e,typeof t!="symbol"?t+"":t,r);let _=function(e){return e.DOCUMENT="doc",e.HEADING="heading",e.PARAGRAPH="paragraph",e.QUOTE="blockquote",e.OL_LIST="ordered_list",e.UL_LIST="bullet_list",e.LIST_ITEM="list_item",e.CODE_BLOCK="code_block",e.HR="horizontal_rule",e.BR="hard_break",e.IMAGE="image",e.EMOJI="emoji",e.COMPONENT="blok",e.TABLE="table",e.TABLE_ROW="tableRow",e.TABLE_CELL="tableCell",e.TABLE_HEADER="tableHeader",e}({}),$=function(e){return e.BOLD="bold",e.STRONG="strong",e.STRIKE="strike",e.UNDERLINE="underline",e.ITALIC="italic",e.CODE="code",e.LINK="link",e.ANCHOR="anchor",e.STYLED="styled",e.SUPERSCRIPT="superscript",e.SUBSCRIPT="subscript",e.TEXT_STYLE="textStyle",e.HIGHLIGHT="highlight",e}({}),V=function(e){return e.TEXT="text",e}({}),j=function(e){return e.URL="url",e.STORY="story",e.ASSET="asset",e.EMAIL="email",e}({});const oe=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ie=(e={})=>{const{custom:t,...r}=e,s={...r,...t};return Object.keys(s).map(n=>`${n}="${s[n]}"`).join(" ")},ae=(e={})=>Object.keys(e).map(t=>`${t}: ${e[t]}`).join("; ");function le(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const C=e=>Object.fromEntries(Object.entries(e).filter(([t,r])=>r!==void 0));function ce(e,t){if(!t)return{src:e,attrs:{}};let r=0,s=0;const n={},o=[];function l(c,u,y,m,A){typeof c!="number"||c<=u||c>=y?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${u} and ${y} (inclusive)`):A.push(`${m}(${c})`)}if(typeof t=="object"){if(t.width!==void 0&&(typeof t.width=="number"&&t.width>=0?(n.width=t.width,r=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),t.height!==void 0&&(typeof t.height=="number"&&t.height>=0?(n.height=t.height,s=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),t.height===0&&t.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),t.loading&&["lazy","eager"].includes(t.loading)&&(n.loading=t.loading),t.class&&(n.class=t.class),t.filters){const{filters:c}=t||{},{blur:u,brightness:y,fill:m,format:A,grayscale:U,quality:R,rotate:L}=c||{};u&&l(u,0,100,"blur",o),R&&l(R,0,100,"quality",o),y&&l(y,0,100,"brightness",o),m&&o.push(`fill(${m})`),U&&o.push("grayscale()"),L&&[0,90,180,270].includes(t.filters.rotate||0)&&o.push(`rotate(${L})`),A&&["webp","png","jpeg"].includes(A)&&o.push(`format(${A})`)}t.srcset&&(n.srcset=t.srcset.map(c=>{if(typeof c=="number")return`${e}/m/${c}x0/${o.length>0?`filters:${o.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,y]=c;return`${e}/m/${u}x${y}/${o.length>0?`filters:${o.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(n.sizes=t.sizes.join(", "))}let a=`${e}/m/`;return(r>0||s>0)&&(a=`${a}${r}x${s}/`),o.length>0&&(a=`${a}filters:${o.join(":")}`),{src:a,attrs:n}}function F(e,t={},r){const s=ie(t),n=s?`${e} ${s}`:e,o=Array.isArray(r)?r.join(""):r||"";if(e){if(oe.includes(e))return`<${n}>`}else return o;return`<${n}>${o}</${e}>`}function N(e={}){const t=new Map,{renderFn:r=F,textFn:s=le,resolvers:n={},optimizeImages:o=!1,keyedResolvers:l=!1}=e,a=r!==F,c=(i={})=>{const{textAlign:h,class:p,id:f,style:b,...w}=i,g=[];return b&&g.push(b.endsWith(";")?b:`${b};`),h&&g.push(`text-align: ${h};`),C({...w,class:p,id:f,...g.length>0?{style:g.join(" ")}:{}})},u=i=>(h,p)=>{const f=c(h.attrs);return p.render(i,f,h.children||null)},y=(i,h)=>{const{src:p,alt:f,title:b,srcset:w,sizes:g}=i.attrs||{};let S=p,T={};if(o){const{src:ze,attrs:qe}=ce(p,o);S=ze,T=qe}const O={src:S,alt:f,title:b,srcset:w,sizes:g,...T};return h.render("img",C(O))},m=(i,h)=>{const{level:p,...f}=i.attrs||{},b=c(f);return h.render(`h${p}`,b,i.children)},A=(i,h)=>{var p,f,b,w;const g=h.render("img",{src:(p=i.attrs)==null?void 0:p.fallbackImage,alt:(f=i.attrs)==null?void 0:f.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(b=i.attrs)==null?void 0:b.name,"data-emoji":(w=i.attrs)==null?void 0:w.emoji},g)},U=(i,h)=>h.render("pre",i.attrs||{},h.render("code",{},i.children||"")),R=(i,h=!1)=>({text:p,attrs:f},b)=>{const{class:w,id:g,...S}=f||{},T=h?{class:w,id:g,style:ae(S)||void 0}:f||{};return b.render(i,C(T),p)},L=i=>M(i),Be=i=>{const{marks:h,...p}=i;if("text"in i){if(h)return h.reduce((b,w)=>L({...w,text:b}),L({...p,children:p.children}));const f=i.attrs||{};if(l){const b=t.get("txt")||0;t.set("txt",b+1),f.key=`txt-${b}`}return s(p.text,f)}return""},ee=(i,h)=>{const{linktype:p,href:f,anchor:b,...w}=i.attrs||{};let g="";switch(p){case j.ASSET:case j.URL:g=f;break;case j.EMAIL:g=`mailto:${f}`;break;case j.STORY:g=f,b&&(g=`${g}#${b}`);break;default:g=f;break}const S={...w};return g&&(S.href=g),h.render("a",S,i.text)},De=(i,h)=>{var p,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(p=i==null?void 0:i.attrs)==null?void 0:p.body[0],id:(f=i.attrs)==null?void 0:f.id,style:"display: none"})},He=(i,h)=>{const p=c(i.attrs),f=i.children||null;return h.render("table",p,h.render("tbody",{},f))},Ue=(i,h)=>{const p=c(i.attrs);return h.render("tr",p,i.children)},Me=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...S}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...S,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("td",C(O),i.children)},Ve=(i,h)=>{const{colspan:p,rowspan:f,colwidth:b,backgroundColor:w,textAlign:g,...S}=i.attrs||{},T=[];b&&T.push(`width: ${b}px;`),w&&T.push(`background-color: ${w};`),g&&T.push(`text-align: ${g};`);const O={...S,...p>1?{colspan:p}:{},...f>1?{rowspan:f}:{},...T.length>0?{style:T.join(" ")}:{}};return h.render("th",C(O),i.children)},te=new Map([[_.DOCUMENT,u("")],[_.HEADING,m],[_.PARAGRAPH,u("p")],[_.UL_LIST,u("ul")],[_.OL_LIST,u("ol")],[_.LIST_ITEM,u("li")],[_.IMAGE,y],[_.EMOJI,A],[_.CODE_BLOCK,U],[_.HR,u("hr")],[_.BR,u("br")],[_.QUOTE,u("blockquote")],[_.COMPONENT,De],[V.TEXT,Be],[$.LINK,ee],[$.ANCHOR,ee],[$.STYLED,R("span",!0)],[$.BOLD,R("strong")],[$.TEXT_STYLE,R("span",!0)],[$.ITALIC,R("em")],[$.UNDERLINE,R("u")],[$.STRIKE,R("s")],[$.CODE,R("code")],[$.SUPERSCRIPT,R("sup")],[$.SUBSCRIPT,R("sub")],[$.HIGHLIGHT,R("mark")],[_.TABLE,He],[_.TABLE_ROW,Ue],[_.TABLE_CELL,Me],[_.TABLE_HEADER,Ve]]),re=new Map([...te,...Object.entries(n).map(([i,h])=>[i,h])]),Fe=()=>({render:(i,h={},p)=>{if(l&&i){const f=t.get(i)||0;t.set(i,f+1),h.key=`${i}-${f}`}return r(i,h,p)},originalResolvers:te,mergedResolvers:re});function x(i){const h=re.get(i.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${i.type}`),"";const p=Fe();if(i.type==="text")return h(i,p);const f=i.content?i.content.map(M):void 0;return h({...i,children:f},p)}function M(i){return i.type==="doc"?a?i.content.map(x):i.content.map(x).join(""):Array.isArray(i)?i.map(x):x(i)}return{render:M}}let z=!1;const q=[],ue=e=>new Promise((t,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?n():q.push(n)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const s=document.createElement("script");s.async=!0,s.src=e,s.id="storyblok-javascript-bridge",s.onerror=n=>r(n),s.onload=n=>{q.forEach(o=>o()),z=!0,t(n)},document.getElementsByTagName("head")[0].appendChild(s)});var he=class extends Error{constructor(e){super(e),this.name="AbortError"}};function de(e,t,r){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");const s=[];let n=[],o=0,l=!1;const a=async()=>{o++;const u=s.shift();if(u)try{const m=await e(...u.args);u.resolve(m)}catch(m){u.reject(m)}const y=setTimeout(()=>{o--,s.length>0&&a(),n=n.filter(m=>m!==y)},r);n.includes(y)||n.push(y)},c=(...u)=>l?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((y,m)=>{s.push({resolve:y,reject:m,args:u}),o<t&&a()});return c.abort=()=>{l=!0,n.forEach(clearTimeout),n=[],s.forEach(u=>u.reject(()=>new he("Throttle function aborted"))),s.length=0},c}var pe=de;const G=(e="")=>e.includes("/cdn/"),fe=(e,t=25,r=1)=>({...e,per_page:t,page:r}),ye=e=>new Promise(t=>setTimeout(t,e)),me=(e=0,t)=>Array.from({length:e},t),be=(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return me(r,(n,o)=>o*s+e)},ge=async(e,t)=>Promise.all(e.map(t)),ke=(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[]),B=(e,t,r)=>{const s=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const l=r?"":encodeURIComponent(n);let a;typeof o=="object"?a=B(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,s.push(a)}return s.join("&")},J=e=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[e]??t.eu};var ve=class{constructor(e){k(this,"baseURL"),k(this,"timeout"),k(this,"headers"),k(this,"responseInterceptor"),k(this,"fetch"),k(this,"ejectInterceptor"),k(this,"url"),k(this,"parameters"),k(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(s=>{r.data=s});for(const s of e.headers.entries())t[s[0]]=s[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(t),n=new AbortController,{signal:o}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await this.fetch(`${s}`,{method:e,headers:this.headers,body:r,signal:o,...this.fetchOptions});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,s)=>{if(t.test(`${e.status}`))return r(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};s(n)})}},_e=ve;const K="SB-Agent",D={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},we={PUBLISHED:"published"};let P={};const E={};var Te=class{constructor(e,t){k(this,"client"),k(this,"maxRetries"),k(this,"retriesDelay"),k(this,"throttle"),k(this,"accessToken"),k(this,"cache"),k(this,"resolveCounter"),k(this,"relations"),k(this,"links"),k(this,"version"),k(this,"richTextResolver"),k(this,"resolveNestedRelations"),k(this,"stringifiedStoriesCache"),k(this,"inlineAssets");let r=e.endpoint||t;if(!r){const o=e.https===!1?"http":"https";e.oauthToken?r=`${o}://${J(e.region)}/v1`:r=`${o}://${J(e.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([o,l])=>{s.set(o,l)}),s.has(K)||(s.set(K,D.defaultAgentName),s.set(D.defaultAgentVersion,D.packageVersion));let n=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=pe(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||we.PUBLISHED,this.inlineAssets=e.inlineAssets||!1,this.client=new _e({baseURL:r,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return G(e)?this.parseParams(t):t}makeRequest(e,t,r,s,n){const o=this.factoryParamOptions(e,fe(t,r,s));return this.cacheResponse(e,o,void 0,n)}get(e,t={},r){t||(t={});const s=`/${e}`;G(s)&&(t.version=t.version||this.version);const n=this.factoryParamOptions(s,t);return this.cacheResponse(s,n,void 0,r)}async getAll(e,t={},r,s){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`.replace(/\/$/,""),l=r??o.substring(o.lastIndexOf("/")+1);t.version=t.version||this.version;const a=1,c=await this.makeRequest(o,t,n,a,s),u=c.total?Math.ceil(c.total/(c.perPage||n)):1,y=await ge(be(a,u),m=>this.makeRequest(o,t,n,m+1,s));return ke([c,...y],m=>Object.values(m.data[l]))}post(e,t={},r){const s=`/${e}`;return this.throttle("post",s,t,r)}put(e,t={},r){const s=`/${e}`;return this.throttle("put",s,t,r)}delete(e,t={},r){t||(t={});const s=`/${e}`;return this.throttle("delete",s,t,r)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},r){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,r)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,r){const s=e[t];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,r){const s=e[t];typeof s=="string"?e[t]=this.getStoryReference(r,s):Array.isArray(s)&&(e[t]=s.map(n=>this.getStoryReference(r,n)).filter(Boolean))}_insertRelations(e,t,r,s){if(Array.isArray(r)?r.find(o=>o.endsWith(`.${t}`)):r.endsWith(`.${t}`)){this._resolveField(e,t,s);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(r)?r.includes(n):r===n)&&this._resolveField(e,t,s)}iterateTree(e,t,r){const s=(n,o="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,a)=>s(l,`${o}[${a}]`));else if(typeof n=="object")for(const l in n){const a=o?`${o}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,r),this._insertLinks(n,l,r)),s(n[l],a)}}};s(e.content)}async resolveLinks(e,t,r){let s=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=e.links;s.forEach(n=>{this.links[r][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,r){let s=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);o.push(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:o[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{s.push(c)});s.length>0&&(e.rels=s,delete e.rel_uuids)}else s=e.rels;s&&s.length>0&&s.forEach(n=>{this.relations[r][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,r){var s,n;let o=[];if(this.links[r]={},this.relations[r]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t,r)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((s=e.links)!=null&&s.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,r),this.resolveNestedRelations)for(const l in this.relations[r])this.iterateTree(this.relations[r][l],o,r);e.story?this.iterateTree(e.story,o,r):e.stories.forEach(l=>{this.iterateTree(l,o,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(e,t,r,s){const n=B({url:e,params:t}),o=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await o.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,a)=>{var c;try{const u=await this.throttle("get",e,t,s);if(u.status!==200)return a(u);let y={data:u.data,headers:u.headers};if((c=u.headers)!=null&&c["per-page"]&&(y=Object.assign({},y,{perPage:u.headers["per-page"]?Number.parseInt(u.headers["per-page"]):0,total:u.headers["per-page"]?Number.parseInt(u.headers.total):0})),y.data.story||y.data.stories){const A=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${A}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await o.set(n,y);const m=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(m&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(u){if(u.response&&u.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await ye(this.retriesDelay),this.cacheResponse(e,t,r).then(l).catch(a);a(u)}})}throttledRequest(e,t,r,s){return this.client.setFetchOptions(s),this.client[e](t,r)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(P[e])},getAll(){return Promise.resolve(P)},set(e,t){return P[e]=t,Promise.resolve(void 0)},flush(){return P={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(n=>t(n));let s={...r};s.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(s={...e.data.assets.find(n=>n.id===s.id),...s});for(const n in s)typeof s[n]=="object"&&(s[n]=t(s[n]));return s};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(r=>(r.content=t(r.content),r))),e}},$e=Te;const Re=(e={})=>{const{apiOptions:t}=e;if(!t||!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new $e(t)}},Ae=e=>{if(typeof e!="object"||typeof e._editable>"u")return{};try{const t=JSON.parse(e._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let Y="https://app.storyblok.com/f/storyblok-v2-latest.js";const W=(e,t,r={})=>{var s;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok"),l=o!==null&&+o===e;if(!(!n||!l)){if(!e){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],a=>{var c;a&&(a.action==="input"&&((c=a.story)==null?void 0:c.id)===e?t(a.story):(a.action==="change"||a.action==="published")&&a.storyId===e&&window.location.reload())})})}},Se=(e={})=>{var t,r;const{bridge:s,accessToken:n,use:o=[],apiOptions:l={},bridgeUrl:a}=e;l.accessToken=l.accessToken||n;const c={bridge:s,apiOptions:l};let u={};o.forEach(m=>{u={...u,...m(c)}}),a&&(Y=a);const y=!(typeof window>"u")&&((r=(t=window.location)==null?void 0:t.search)==null?void 0:r.includes("_storyblok_tk"));return s!==!1&&y&&ue(Y),u};function Ee(e,t){return N(t).render(e)}const H=d.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(e,{expose:t}){var a;const r=e,s=d.ref();t({value:s});const n=typeof d.resolveDynamicComponent(r.blok.component)!="string",o=d.inject("VueSDKOptions"),l=d.ref((a=r.blok.component)==null?void 0:a.replace(/_/g,"-"));return!n&&o&&(o.enableFallbackComponent?(l.value=o.customFallbackComponent??"FallbackComponent",typeof d.resolveDynamicComponent(l.value)=="string"&&console.error(`Is the Fallback component "${l.value}" registered properly?`)):console.error(`Component could not be found for blok "${r.blok.component}"! Is it defined in main.ts as "app.component("${r.blok.component}", ${r.blok.component});"?`)),(c,u)=>(d.openBlock(),d.createBlock(d.resolveDynamicComponent(l.value),d.mergeProps({ref_key:"blokRef",ref:s},{...c.$props,...c.$attrs}),d.createSlots({_:2},[d.renderList(c.$slots,(y,m)=>({name:m,fn:d.withCtx(A=>[d.renderSlot(c.$slots,m,d.normalizeProps(d.guardReactiveProps(A)))])}))]),1040))}}),Ce=e=>{var r;const t=(r=e==null?void 0:e.attrs)==null?void 0:r.body;return!Array.isArray(t)||t.length===0?[]:t.map(s=>{var n;return d.h(H,{blok:s,id:(n=e==null?void 0:e.attrs)==null?void 0:n.id},e.children)})};function X(e){const t={renderFn:d.h,textFn:d.createTextVNode,keyedResolvers:!0,resolvers:{[_.COMPONENT]:Ce,...e.resolvers}};return N(t)}const Q=d.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(e){const t=e,r=d.ref(),s=()=>r.value;return d.watch([()=>t.doc,()=>t.resolvers],([n,o])=>{const{render:l}=X({resolvers:o??{}});r.value=l(n)},{immediate:!0,deep:!0}),(n,o)=>(d.openBlock(),d.createBlock(s))}}),Ie={beforeMount(e,t){if(t.value){const r=Ae(t.value);Object.keys(r).length>0&&(e.setAttribute("data-blok-c",r["data-blok-c"]),e.setAttribute("data-blok-uid",r["data-blok-uid"]),e.classList.add("storyblok__outline"))}}},Z=e=>{console.error(`You can't use ${e} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
8
  `)};let I=null;const Le=()=>(I||Z("useStoryblokApi"),I),Oe=async(e,t={},r={})=>{const s=d.ref(null);if(r.resolveRelations=r.resolveRelations??t.resolve_relations,r.resolveLinks=r.resolveLinks??t.resolve_links,d.onMounted(()=>{s.value&&s.value.id&&W(s.value.id,n=>s.value=n,r)}),I){const{data:n}=await I.get(`cdn/stories/${e}`,t);s.value=n.story}else Z("useStoryblok");return s},je={install(e,t={}){e.directive("editable",Ie),e.component("StoryblokComponent",H),e.component("StoryblokRichText",Q),t.enableFallbackComponent&&!t.customFallbackComponent&&e.component("FallbackComponent",d.defineAsyncComponent(()=>Promise.resolve().then(()=>Ne)));const{storyblokApi:r}=Se(t);I=r||null,e.provide("VueSDKOptions",t)}},Pe={class:"fallback-component"},xe={class:"component"},Ne=Object.freeze(Object.defineProperty({__proto__:null,default:((e,t)=>{const r=e.__vccOpts||e;for(const[s,n]of t)r[s]=n;return r})(d.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(e){return(t,r)=>(d.openBlock(),d.createElementBlock("div",Pe,[d.createElementVNode("p",null,[r[0]||(r[0]=d.createTextVNode(" Component could not be found for blok ",-1)),d.createElementVNode("span",xe,d.toDisplayString(t.blok.component),1),r[1]||(r[1]=d.createTextVNode("! Is it configured correctly? ",-1))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));v.BlockTypes=_,v.MarkTypes=$,v.StoryblokComponent=H,v.StoryblokRichText=Q,v.StoryblokVue=je,v.TextTypes=V,v.apiPlugin=Re,v.renderRichText=Ee,v.richTextResolver=N,v.useStoryblok=Oe,v.useStoryblokApi=Le,v.useStoryblokBridge=W,v.useStoryblokRichText=X,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
@@ -4,11 +4,11 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- import { defineComponent as W, ref as x, resolveDynamicComponent as H, inject as de, createBlock as X, openBlock as Q, mergeProps as pe, createSlots as fe, renderList as ye, withCtx as me, renderSlot as ge, normalizeProps as be, guardReactiveProps as ve, h as Z, createTextVNode as ke, watch as we, onMounted as _e, defineAsyncComponent as Te } from "vue";
8
- var $e = Object.defineProperty, Re = (e, t, r) => t in e ? $e(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, b = (e, t, r) => Re(e, typeof t != "symbol" ? t + "" : t, r);
7
+ import { defineComponent as W, ref as x, resolveDynamicComponent as H, inject as de, createBlock as X, openBlock as Q, mergeProps as pe, createSlots as fe, renderList as ye, withCtx as me, renderSlot as ge, normalizeProps as be, guardReactiveProps as ve, h as Z, createTextVNode as ke, watch as we, onMounted as Te, defineAsyncComponent as _e } from "vue";
8
+ var Re = Object.defineProperty, $e = (e, t, r) => t in e ? Re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, b = (e, t, r) => $e(e, typeof t != "symbol" ? t + "" : t, r);
9
9
  let k = /* @__PURE__ */ function(e) {
10
10
  return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
11
- }({}), T = /* @__PURE__ */ function(e) {
11
+ }({}), _ = /* @__PURE__ */ function(e) {
12
12
  return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
13
13
  }({}), Ae = /* @__PURE__ */ function(e) {
14
14
  return e.TEXT = "text", e;
@@ -30,7 +30,13 @@ const Ee = [
30
30
  "source",
31
31
  "track",
32
32
  "wbr"
33
- ], Se = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), Le = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
33
+ ], Se = (e = {}) => {
34
+ const { custom: t, ...r } = e, s = {
35
+ ...r,
36
+ ...t
37
+ };
38
+ return Object.keys(s).map((n) => `${n}="${s[n]}"`).join(" ");
39
+ }, Le = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
34
40
  function Ie(e) {
35
41
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
36
42
  }
@@ -42,22 +48,22 @@ function Ce(e, t) {
42
48
  };
43
49
  let r = 0, s = 0;
44
50
  const n = {}, o = [];
45
- function l(c, u, f, y, $) {
46
- typeof c != "number" || c <= u || c >= f ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : $.push(`${y}(${c})`);
51
+ function l(c, u, f, y, R) {
52
+ typeof c != "number" || c <= u || c >= f ? console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase() + y.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : R.push(`${y}(${c})`);
47
53
  }
48
54
  if (typeof t == "object") {
49
- if (typeof t.width == "number" && t.width > 0 ? (n.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (n.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (n.loading = t.loading), t.class && (n.class = t.class), t.filters) {
50
- const { filters: c } = t || {}, { blur: u, brightness: f, fill: y, format: $, grayscale: P, quality: _, rotate: E } = c || {};
51
- u && l(u, 0, 100, "blur", o), _ && l(_, 0, 100, "quality", o), f && l(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), P && o.push("grayscale()"), E && [
55
+ if (t.width !== void 0 && (typeof t.width == "number" && t.width >= 0 ? (n.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")), t.height !== void 0 && (typeof t.height == "number" && t.height >= 0 ? (n.height = t.height, s = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")), t.height === 0 && t.width === 0 && (delete n.width, delete n.height, console.warn("[StoryblokRichText] - Width and height values cannot both be 0")), t.loading && ["lazy", "eager"].includes(t.loading) && (n.loading = t.loading), t.class && (n.class = t.class), t.filters) {
56
+ const { filters: c } = t || {}, { blur: u, brightness: f, fill: y, format: R, grayscale: P, quality: T, rotate: E } = c || {};
57
+ u && l(u, 0, 100, "blur", o), T && l(T, 0, 100, "quality", o), f && l(f, 0, 100, "brightness", o), y && o.push(`fill(${y})`), P && o.push("grayscale()"), E && [
52
58
  0,
53
59
  90,
54
60
  180,
55
61
  270
56
- ].includes(t.filters.rotate || 0) && o.push(`rotate(${E})`), $ && [
62
+ ].includes(t.filters.rotate || 0) && o.push(`rotate(${E})`), R && [
57
63
  "webp",
58
64
  "png",
59
65
  "jpeg"
60
- ].includes($) && o.push(`format(${$})`);
66
+ ].includes(R) && o.push(`format(${R})`);
61
67
  }
62
68
  t.srcset && (n.srcset = t.srcset.map((c) => {
63
69
  if (typeof c == "number") return `${e}/m/${c}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${c}w`;
@@ -71,7 +77,7 @@ function Ce(e, t) {
71
77
  }).join(", ")), t.sizes && (n.sizes = t.sizes.join(", "));
72
78
  }
73
79
  let a = `${e}/m/`;
74
- return r > 0 && s > 0 && (a = `${a}${r}x${s}/`), o.length > 0 && (a = `${a}filters:${o.join(":")}`), {
80
+ return (r > 0 || s > 0) && (a = `${a}${r}x${s}/`), o.length > 0 && (a = `${a}filters:${o.join(":")}`), {
75
81
  src: a,
76
82
  attrs: n
77
83
  };
@@ -97,13 +103,13 @@ function ee(e = {}) {
97
103
  return d.render(i, p, h.children || null);
98
104
  }, f = (i, h) => {
99
105
  const { src: d, alt: p, title: m, srcset: v, sizes: g } = i.attrs || {};
100
- let R = d, w = {};
106
+ let $ = d, w = {};
101
107
  if (o) {
102
108
  const { src: ue, attrs: he } = Ce(d, o);
103
- R = ue, w = he;
109
+ $ = ue, w = he;
104
110
  }
105
111
  const S = {
106
- src: R,
112
+ src: $,
107
113
  alt: p,
108
114
  title: m,
109
115
  srcset: v,
@@ -114,7 +120,7 @@ function ee(e = {}) {
114
120
  }, y = (i, h) => {
115
121
  const { level: d, ...p } = i.attrs || {}, m = c(p);
116
122
  return h.render(`h${d}`, m, i.children);
117
- }, $ = (i, h) => {
123
+ }, R = (i, h) => {
118
124
  var d, p, m, v;
119
125
  const g = h.render("img", {
120
126
  src: (d = i.attrs) == null ? void 0 : d.fallbackImage,
@@ -128,11 +134,11 @@ function ee(e = {}) {
128
134
  "data-name": (m = i.attrs) == null ? void 0 : m.name,
129
135
  "data-emoji": (v = i.attrs) == null ? void 0 : v.emoji
130
136
  }, g);
131
- }, P = (i, h) => h.render("pre", i.attrs || {}, h.render("code", {}, i.children || "")), _ = (i, h = !1) => ({ text: d, attrs: p }, m) => {
132
- const { class: v, id: g, ...R } = p || {}, w = h ? {
137
+ }, P = (i, h) => h.render("pre", i.attrs || {}, h.render("code", {}, i.children || "")), T = (i, h = !1) => ({ text: d, attrs: p }, m) => {
138
+ const { class: v, id: g, ...$ } = p || {}, w = h ? {
133
139
  class: v,
134
140
  id: g,
135
- style: Le(R) || void 0
141
+ style: Le($) || void 0
136
142
  } : p || {};
137
143
  return m.render(i, L(w), d);
138
144
  }, E = (i) => N(i), se = (i) => {
@@ -171,8 +177,8 @@ function ee(e = {}) {
171
177
  g = p;
172
178
  break;
173
179
  }
174
- const R = { ...v };
175
- return g && (R.href = g), h.render("a", R, i.text);
180
+ const $ = { ...v };
181
+ return g && ($.href = g), h.render("a", $, i.text);
176
182
  }, ne = (i, h) => {
177
183
  var d, p;
178
184
  return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), h.render("span", {
@@ -187,20 +193,20 @@ function ee(e = {}) {
187
193
  const d = c(i.attrs);
188
194
  return h.render("tr", d, i.children);
189
195
  }, ae = (i, h) => {
190
- const { colspan: d, rowspan: p, colwidth: m, backgroundColor: v, textAlign: g, ...R } = i.attrs || {}, w = [];
196
+ const { colspan: d, rowspan: p, colwidth: m, backgroundColor: v, textAlign: g, ...$ } = i.attrs || {}, w = [];
191
197
  m && w.push(`width: ${m}px;`), v && w.push(`background-color: ${v};`), g && w.push(`text-align: ${g};`);
192
198
  const S = {
193
- ...R,
199
+ ...$,
194
200
  ...d > 1 ? { colspan: d } : {},
195
201
  ...p > 1 ? { rowspan: p } : {},
196
202
  ...w.length > 0 ? { style: w.join(" ") } : {}
197
203
  };
198
204
  return h.render("td", L(S), i.children);
199
205
  }, le = (i, h) => {
200
- const { colspan: d, rowspan: p, colwidth: m, backgroundColor: v, textAlign: g, ...R } = i.attrs || {}, w = [];
206
+ const { colspan: d, rowspan: p, colwidth: m, backgroundColor: v, textAlign: g, ...$ } = i.attrs || {}, w = [];
201
207
  m && w.push(`width: ${m}px;`), v && w.push(`background-color: ${v};`), g && w.push(`text-align: ${g};`);
202
208
  const S = {
203
- ...R,
209
+ ...$,
204
210
  ...d > 1 ? { colspan: d } : {},
205
211
  ...p > 1 ? { rowspan: p } : {},
206
212
  ...w.length > 0 ? { style: w.join(" ") } : {}
@@ -214,25 +220,25 @@ function ee(e = {}) {
214
220
  [k.OL_LIST, u("ol")],
215
221
  [k.LIST_ITEM, u("li")],
216
222
  [k.IMAGE, f],
217
- [k.EMOJI, $],
223
+ [k.EMOJI, R],
218
224
  [k.CODE_BLOCK, P],
219
225
  [k.HR, u("hr")],
220
226
  [k.BR, u("br")],
221
227
  [k.QUOTE, u("blockquote")],
222
228
  [k.COMPONENT, ne],
223
229
  [Ae.TEXT, se],
224
- [T.LINK, B],
225
- [T.ANCHOR, B],
226
- [T.STYLED, _("span", !0)],
227
- [T.BOLD, _("strong")],
228
- [T.TEXT_STYLE, _("span", !0)],
229
- [T.ITALIC, _("em")],
230
- [T.UNDERLINE, _("u")],
231
- [T.STRIKE, _("s")],
232
- [T.CODE, _("code")],
233
- [T.SUPERSCRIPT, _("sup")],
234
- [T.SUBSCRIPT, _("sub")],
235
- [T.HIGHLIGHT, _("mark")],
230
+ [_.LINK, B],
231
+ [_.ANCHOR, B],
232
+ [_.STYLED, T("span", !0)],
233
+ [_.BOLD, T("strong")],
234
+ [_.TEXT_STYLE, T("span", !0)],
235
+ [_.ITALIC, T("em")],
236
+ [_.UNDERLINE, T("u")],
237
+ [_.STRIKE, T("s")],
238
+ [_.CODE, T("code")],
239
+ [_.SUPERSCRIPT, T("sup")],
240
+ [_.SUBSCRIPT, T("sub")],
241
+ [_.HIGHLIGHT, T("mark")],
236
242
  [k.TABLE, oe],
237
243
  [k.TABLE_ROW, ie],
238
244
  [k.TABLE_CELL, ae],
@@ -266,7 +272,7 @@ function ee(e = {}) {
266
272
  return { render: N };
267
273
  }
268
274
  let z = !1;
269
- const G = [], Oe = (e) => new Promise((t, r) => {
275
+ const q = [], Oe = (e) => new Promise((t, r) => {
270
276
  if (typeof window > "u") {
271
277
  r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
272
278
  return;
@@ -276,14 +282,14 @@ const G = [], Oe = (e) => new Promise((t, r) => {
276
282
  console.warn("You are not in Draft Mode or in the Visual Editor.");
277
283
  return;
278
284
  }
279
- z ? n() : G.push(n);
285
+ z ? n() : q.push(n);
280
286
  }, document.getElementById("storyblok-javascript-bridge")) {
281
287
  t(void 0);
282
288
  return;
283
289
  }
284
290
  const s = document.createElement("script");
285
291
  s.async = !0, s.src = e, s.id = "storyblok-javascript-bridge", s.onerror = (n) => r(n), s.onload = (n) => {
286
- G.forEach((o) => o()), z = !0, t(n);
292
+ q.forEach((o) => o()), z = !0, t(n);
287
293
  }, document.getElementsByTagName("head")[0].appendChild(s);
288
294
  });
289
295
  var je = class extends Error {
@@ -321,7 +327,7 @@ function xe(e, t, r) {
321
327
  }, c;
322
328
  }
323
329
  var Pe = xe;
324
- const q = (e = "") => e.includes("/cdn/"), Ne = (e, t = 25, r = 1) => ({
330
+ const G = (e = "") => e.includes("/cdn/"), Ne = (e, t = 25, r = 1) => ({
325
331
  ...e,
326
332
  per_page: t,
327
333
  page: r
@@ -450,7 +456,7 @@ const K = "SB-Agent", U = {
450
456
  };
451
457
  let j = {};
452
458
  const A = {};
453
- var Ge = class {
459
+ var qe = class {
454
460
  /**
455
461
  *
456
462
  * @param config ISbConfig interface
@@ -480,7 +486,7 @@ var Ge = class {
480
486
  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;
481
487
  }
482
488
  factoryParamOptions(e, t) {
483
- return q(e) ? this.parseParams(t) : t;
489
+ return G(e) ? this.parseParams(t) : t;
484
490
  }
485
491
  makeRequest(e, t, r, s, n) {
486
492
  const o = this.factoryParamOptions(e, Ne(t, r, s));
@@ -489,7 +495,7 @@ var Ge = class {
489
495
  get(e, t = {}, r) {
490
496
  t || (t = {});
491
497
  const s = `/${e}`;
492
- q(s) && (t.version = t.version || this.version);
498
+ G(s) && (t.version = t.version || this.version);
493
499
  const n = this.factoryParamOptions(s, t);
494
500
  return this.cacheResponse(s, n, void 0, r);
495
501
  }
@@ -698,8 +704,8 @@ var Ge = class {
698
704
  perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
699
705
  total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
700
706
  })), f.data.story || f.data.stories) {
701
- const $ = this.resolveCounter = ++this.resolveCounter % 1e3;
702
- await this.resolveStories(f.data, t, `${$}`), f = await this.processInlineAssets(f);
707
+ const R = this.resolveCounter = ++this.resolveCounter % 1e3;
708
+ await this.resolveStories(f.data, t, `${R}`), f = await this.processInlineAssets(f);
703
709
  }
704
710
  t.version === "published" && e !== "/cdn/spaces/me" && await o.set(n, f);
705
711
  const y = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
@@ -772,15 +778,15 @@ var Ge = class {
772
778
  if (Array.isArray(r)) return r.map((n) => t(n));
773
779
  let s = { ...r };
774
780
  s.fieldtype === "asset" && Array.isArray(e.data.assets) && (s = {
775
- ...s,
776
- ...e.data.assets.find((n) => n.id === s.id)
781
+ ...e.data.assets.find((n) => n.id === s.id),
782
+ ...s
777
783
  });
778
784
  for (const n in s) typeof s[n] == "object" && (s[n] = t(s[n]));
779
785
  return s;
780
786
  };
781
787
  return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((r) => (r.content = t(r.content), r))), e;
782
788
  }
783
- }, qe = Ge;
789
+ }, Ge = qe;
784
790
  const tt = (e = {}) => {
785
791
  const { apiOptions: t } = e;
786
792
  if (!t || !t.accessToken) {
@@ -789,7 +795,7 @@ const tt = (e = {}) => {
789
795
  );
790
796
  return;
791
797
  }
792
- return { storyblokApi: new qe(t) };
798
+ return { storyblokApi: new Ge(t) };
793
799
  }, Je = (e) => {
794
800
  if (typeof e != "object" || typeof e._editable > "u")
795
801
  return {};
@@ -866,8 +872,8 @@ const te = /* @__PURE__ */ W({
866
872
  }, { ...c.$props, ...c.$attrs }), fe({ _: 2 }, [
867
873
  ye(c.$slots, (f, y) => ({
868
874
  name: y,
869
- fn: me(($) => [
870
- ge(c.$slots, y, be(ve($)))
875
+ fn: me((R) => [
876
+ ge(c.$slots, y, be(ve(R)))
871
877
  ])
872
878
  }))
873
879
  ]), 1040));
@@ -931,7 +937,7 @@ const Qe = /* @__PURE__ */ W({
931
937
  let I = null;
932
938
  const st = () => (I || re("useStoryblokApi"), I), nt = async (e, t = {}, r = {}) => {
933
939
  const s = x(null);
934
- if (r.resolveRelations = r.resolveRelations ?? t.resolve_relations, r.resolveLinks = r.resolveLinks ?? t.resolve_links, _e(() => {
940
+ if (r.resolveRelations = r.resolveRelations ?? t.resolve_relations, r.resolveLinks = r.resolveLinks ?? t.resolve_links, Te(() => {
935
941
  s.value && s.value.id && Ke(
936
942
  s.value.id,
937
943
  (n) => s.value = n,
@@ -950,7 +956,7 @@ const st = () => (I || re("useStoryblokApi"), I), nt = async (e, t = {}, r = {})
950
956
  install(e, t = {}) {
951
957
  e.directive("editable", Ze), e.component("StoryblokComponent", te), e.component("StoryblokRichText", Qe), t.enableFallbackComponent && !t.customFallbackComponent && e.component(
952
958
  "FallbackComponent",
953
- Te(() => import("./FallbackComponent-vpkAikkq.js"))
959
+ _e(() => import("./FallbackComponent-vpkAikkq.js"))
954
960
  );
955
961
  const { storyblokApi: r } = Ye(t);
956
962
  I = r || null, e.provide("VueSDKOptions", t);
@@ -958,7 +964,7 @@ const st = () => (I || re("useStoryblokApi"), I), nt = async (e, t = {}, r = {})
958
964
  };
959
965
  export {
960
966
  k as BlockTypes,
961
- T as MarkTypes,
967
+ _ as MarkTypes,
962
968
  te as StoryblokComponent,
963
969
  Qe as StoryblokRichText,
964
970
  ot as StoryblokVue,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
3
  "type": "module",
4
- "version": "9.3.1",
4
+ "version": "9.3.3",
5
5
  "description": "SDK to integrate Storyblok into your project using Vue.",
6
6
  "author": "Storyblok",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "vue": ">=3.4"
32
32
  },
33
33
  "dependencies": {
34
- "@storyblok/js": "4.3.0"
34
+ "@storyblok/js": "4.3.2"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rollup/plugin-typescript": "^12.1.2",