@storyblok/vue 7.0.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ import { mount } from "cypress/vue";
2
+ declare global {
3
+ namespace Cypress {
4
+ interface Chainable {
5
+ mount: typeof mount;
6
+ }
7
+ }
8
+ }
@@ -0,0 +1 @@
1
+ import "./commands";
@@ -0,0 +1,3 @@
1
+ /// <reference types="cypress" />
2
+ declare const _default: Cypress.ConfigOptions<any>;
3
+ export default _default;
@@ -1,4 +1,4 @@
1
- (function(d,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],p):(d=typeof globalThis<"u"?globalThis:d||self,p(d.storyblokVue={},d.Vue))})(this,function(d,p){"use strict";var M=Object.defineProperty,N=Object.defineProperties,L=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,P=(o,e,t)=>e in o?M(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,f=(o,e)=>{for(var t in e||(e={}))U.call(e,t)&&P(o,t,e[t]);if(R)for(var t of R(e))D.call(e,t)&&P(o,t,e[t]);return o},v=(o,e)=>N(o,L(e));let S=!1;const E=[],B=o=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}S?r():E.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=o,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{E.forEach(n=>n()),S=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var H=Object.defineProperty,V=(o,e,t)=>e in o?H(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,c=(o,e,t)=>(V(o,typeof e!="symbol"?e+"":e,t),t);function O(o){return!(o!==o||o===1/0||o===-1/0)}function q(o,e,t){if(!O(e))throw new TypeError("Expected `limit` to be a finite number");if(!O(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],n=0;const a=function(){n++;const l=setTimeout(function(){n--,s.length>0&&a(),r=r.filter(function(u){return u!==l})},t);r.indexOf(l)<0&&r.push(l);const h=s.shift();h.resolve(o.apply(h.self,h.args))},i=function(...l){const h=this;return new Promise(function(u,T){s.push({resolve:u,reject:T,args:l,self:h}),n<e&&a()})};return i.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(l){l.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},i}const z=function(o,e){const t={};for(const s in o){const r=o[s];e.indexOf(s)>-1&&r!==null&&(t[s]=r)}return t},J=o=>o==="email",F=()=>({singleTag:"hr"}),G=()=>({tag:"blockquote"}),Y=()=>({tag:"ul"}),K=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),Q=()=>({singleTag:"br"}),W=o=>({tag:`h${o.attrs.level}`}),X=o=>({singleTag:[{tag:"img",attrs:z(o.attrs,["src","alt","title"])}]}),Z=()=>({tag:"li"}),ee=()=>({tag:"ol"}),te=()=>({tag:"p"}),se=()=>({tag:"b"}),re=()=>({tag:"strike"}),oe=()=>({tag:"u"}),ne=()=>({tag:"strong"}),ie=()=>({tag:"code"}),ae=()=>({tag:"i"}),le=o=>{const e=f({},o.attrs),{linktype:t="url"}=o.attrs;return J(t)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},ce=o=>({tag:[{tag:"span",attrs:o.attrs}]}),$={nodes:{horizontal_rule:F,blockquote:G,bullet_list:Y,code_block:K,hard_break:Q,heading:W,image:X,list_item:Z,ordered_list:ee,paragraph:te},marks:{bold:se,strike:re,underline:oe,strong:ne,code:ie,italic:ae,link:le,styled:ce}},he=function(o){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=RegExp(t.source);return o&&s.test(o)?o.replace(t,r=>e[r]):o};class y{constructor(e){c(this,"marks"),c(this,"nodes"),e||(e=$),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e){if(e&&e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(s=>{t+=this.renderNode(s)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const n=this.getMatchingMark(r);n&&t.push(this.renderOpeningTag(n.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(he(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html&&t.push(s.html),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const n=this.getMatchingMark(r);n&&t.push(this.renderClosingTag(n.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs)for(const n in s.attrs){const a=s.attrs[n];a!==null&&(r+=` ${n}="${a}"`)}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}}class j{constructor(){c(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),c(this,"getOptionsPage",(e,t=25,s=1)=>v(f({},e),{per_page:t,page:s})),c(this,"delay",e=>new Promise(t=>setTimeout(t,e))),c(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t)),c(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(n,a)=>a*r+e)}),c(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),c(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[]))}stringify(e,t,s){const r=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const a=e[n],i=s?"":encodeURIComponent(n);let l;typeof a=="object"?l=this.stringify(a,t?t+encodeURIComponent("["+i+"]"):i,Array.isArray(a)):l=(t?t+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(a),r.push(l)}return r.join("&")}}var m=(o=>(o.GET="get",o.DELETE="delete",o.POST="post",o.PUT="put",o))(m||{});class ue{constructor(e){c(this,"baseURL"),c(this,"timeout"),c(this,"headers"),c(this,"responseInterceptor"),c(this,"ejectInterceptor"),c(this,"url"),c(this,"parameters"),this.baseURL=e.baseURL,this.timeout=e.timeout?e.timeout*1e3:1e3,this.headers=e.headers||[],this.responseInterceptor=e.responseInterceptor,this.ejectInterceptor=!1,this.url="",this.parameters={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler(m.GET)}post(e,t){return this.url=e,this.parameters=t,this._methodHandler(m.POST)}put(e,t){return this.url=e,this.parameters=t,this._methodHandler(m.PUT)}delete(e,t){return this.url=e,this.parameters=t,this._methodHandler(m.DELETE)}async _responseHandler(e){const t=[],s={data:{},headers:{},status:0,statusText:""};await e.json().then(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers=f({},t),s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){const t=new URL(`${this.baseURL}${this.url}`);let s=null;if(e==="get"){const i=new j;t.search=i.stringify(this.parameters)}else s=JSON.stringify(this.parameters);const r=new AbortController,{signal:n}=r,a=setTimeout(()=>r.abort(),this.timeout);try{const i=await fetch(`${t}`,{method:e,headers:this.headers,body:s,signal:n});clearTimeout(a);const l=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(i){return i}}eject(){this.ejectInterceptor=!0}_statusHandler(e){if(/20[01]/g.test(`${e.status}`))return e;throw{message:new Error(e.statusText||`status: ${e.status}`),response:e}}}let k={};const g={};class de{constructor(e,t){if(c(this,"client"),c(this,"maxRetries"),c(this,"throttle"),c(this,"accessToken"),c(this,"cache"),c(this,"helpers"),c(this,"relations"),c(this,"links"),c(this,"richTextResolver"),c(this,"resolveNestedRelations"),!t){const n=e.region?`-${e.region}`:"",a=e.https===!1?"http":"https";e.oauthToken?t=`${a}://api${n}.storyblok.com/v1`:t=`${a}://api${n}.storyblok.com/v2`}const s=Object.assign({},e.headers);let r=5;e.oauthToken&&(s.Authorization=e.oauthToken,r=3),e.rateLimit&&(r=e.rateLimit),e.richTextSchema?this.richTextResolver=new y(e.richTextSchema):this.richTextResolver=new y,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries,this.throttle=q(this.throttledRequest,r,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new j,this.resolveNestedRelations=!1,this.client=new ue({baseURL:t,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=g[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r){const n=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,n)}get(e,t){t||(t={});const s=`/${e}`,r=this.factoryParamOptions(s,t);return this.cacheResponse(s,r)}async getAll(e,t,s){const r=(t==null?void 0:t.per_page)||25,n=`/${e}`,a=n.split("/"),i=s||a[a.length-1],l=1,h=await this.makeRequest(n,t,r,l),u=h.total?Math.ceil(h.total/r):1,T=await this.helpers.asyncMap(this.helpers.range(l,u),w=>this.makeRequest(n,t,r,w+1));return this.helpers.flatMap([h,...T],w=>Object.values(w.data[i]))}post(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t))}put(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t))}delete(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t))}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const s=e[t];s&&s.fieldtype=="multilink"&&s.linktype=="story"&&typeof s.id=="string"&&this.links[s.id]?s.story=this._cleanCopy(this.links[s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[s.uuid]&&(s.story=this._cleanCopy(this.links[s.uuid]))}_insertRelations(e,t,s){if(s.indexOf(`${e.component}.${t}`)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t]&&e[t].constructor===Array){const r=[];e[t].forEach(n=>{this.relations[n]&&r.push(this._cleanCopy(this.relations[n]))}),e[t]=r}}}iterateTree(e,t){const s=r=>{if(r!=null){if(r.constructor===Array)for(let n=0;n<r.length;n++)s(r[n]);else if(r.constructor===Object){if(r._stopResolving)return;for(const n in r)(r.component&&r._uid||r.type==="link")&&(this._insertRelations(r,n,t),this._insertLinks(r,n)),s(r[n])}}};s(e.content)}async resolveLinks(e,t){let s=[];if(e.link_uuids){const r=e.link_uuids.length,n=[],a=50;for(let i=0;i<r;i+=a){const l=Math.min(r,i+a);n.push(e.link_uuids.slice(i,l))}for(let i=0;i<n.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:n[i].join(",")})).data.stories.forEach(l=>{s.push(l)})}else s=e.links;s.forEach(r=>{this.links[r.uuid]=v(f({},r),{_stopResolving:!0})})}async resolveRelations(e,t){let s=[];if(e.rel_uuids){const r=e.rel_uuids.length,n=[],a=50;for(let i=0;i<r;i+=a){const l=Math.min(r,i+a);n.push(e.rel_uuids.slice(i,l))}for(let i=0;i<n.length;i++)(await this.getStories({per_page:a,language:t.language,version:t.version,by_uuids:n[i].join(",")})).data.stories.forEach(l=>{s.push(l)})}else s=e.rels;s&&s.length>0&&s.forEach(r=>{this.relations[r.uuid]=v(f({},r),{_stopResolving:!0})})}async resolveStories(e,t){var s,r;let n=[];if(typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(n=t.resolve_relations.split(","),await this.resolveRelations(e,t)),t.resolve_links&&["1","story","url"].indexOf(t.resolve_links)>-1&&(((s=e.links)==null?void 0:s.length)||((r=e.link_uuids)==null?void 0:r.length))&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const a in this.relations)this.iterateTree(this.relations[a],n);e.story?this.iterateTree(e.story,n):e.stories.forEach(a=>{this.iterateTree(a,n)})}cacheResponse(e,t,s){return new Promise((r,n)=>{const a=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const l=i.get(a);if(l)return r(l)}try{(async()=>{var l;const h=await this.throttle("get",e,t);let u={data:h.data,headers:h.headers};if((l=h.headers)!=null&&l["per-page"]&&(u=Object.assign({},u,{perPage:h.headers["per-page"]?parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?parseInt(h.headers.total):0})),h.status!=200)return n(h);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&t.token&&(t.version=="draft"&&g[t.token]!=u.data.cv&&this.flushCache(),g[t.token]=u.data.cv),r(u)})()}catch{}})}throttledRequest(e,t,s){return this.client[e](t,s)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(e){this.accessToken&&(g[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return k[e]},getAll(){return k},set(e,t){k[e]=t},flush(){k={}}};default:return{get(){},getAll(){},set(){},flush(){}}}}flushCache(){return this.cacheProvider().flush(),this}}const pe=(o={})=>{const{apiOptions:e}=o;if(!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 de(e)}};var fe=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let _;const ge="https://app.storyblok.com/f/storyblok-v2-latest.js",C=(o,e,t={})=>{if(!(typeof window>"u")){if(typeof window.storyblokRegisterEvent>"u"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],r=>{r.action==="input"&&r.story.id===o?e(r.story):(r.action==="change"||r.action==="published")&&r.storyId===o&&window.location.reload()})})}},ye=(o={})=>{const{bridge:e,accessToken:t,use:s=[],apiOptions:r={},richText:n={}}=o;r.accessToken=r.accessToken||t;const a={bridge:e,apiOptions:r};let i={};return s.forEach(l=>{i=f(f({},i),l(a))}),e!==!1&&B(ge),_=new y(n.schema),n.resolver&&x(_,n.resolver),i},x=(o,e)=>{o.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},me=(o,e,t)=>{let s=t||_;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return o===""?"":o?(e&&(s=new y(e.schema),e.resolver&&x(s,e.resolver)),s.render(o)):(console.warn(`${o} is not a valid Richtext object. This might be because the value of the richtext field is empty.
1
+ (function(d,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],p):(d=typeof globalThis<"u"?globalThis:d||self,p(d.storyblokVue={},d.Vue))})(this,function(d,p){"use strict";let w=!1;const T=[],C=o=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}w?r():T.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=o,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{T.forEach(i=>i()),w=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var O=Object.defineProperty,x=(o,e,t)=>e in o?O(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,h=(o,e,t)=>(x(o,typeof e!="symbol"?e+"":e,t),t);function _(o){return!(o!==o||o===1/0||o===-1/0)}function A(o,e,t){if(!_(e))throw new TypeError("Expected `limit` to be a finite number");if(!_(t))throw new TypeError("Expected `interval` to be a finite number");const s=[];let r=[],i=0;const n=function(){i++;const l=setTimeout(function(){i--,s.length>0&&n(),r=r.filter(function(u){return u!==l})},t);r.indexOf(l)<0&&r.push(l);const c=s.shift();c.resolve(o.apply(c.self,c.args))},a=function(...l){const c=this;return new Promise(function(u,y){s.push({resolve:u,reject:y,args:l,self:c}),i<e&&n()})};return a.abort=function(){r.forEach(clearTimeout),r=[],s.forEach(function(l){l.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),s.length=0},a}const I=function(o,e){const t={};for(const s in o){const r=o[s];e.indexOf(s)>-1&&r!==null&&(t[s]=r)}return t},M=o=>o==="email",N=()=>({singleTag:"hr"}),L=()=>({tag:"blockquote"}),U=()=>({tag:"ul"}),H=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),q=()=>({singleTag:"br"}),V=o=>({tag:`h${o.attrs.level}`}),D=o=>({singleTag:[{tag:"img",attrs:I(o.attrs,["src","alt","title"])}]}),B=()=>({tag:"li"}),z=()=>({tag:"ol"}),J=()=>({tag:"p"}),F=()=>({tag:"b"}),Y=()=>({tag:"strike"}),K=()=>({tag:"u"}),G=()=>({tag:"strong"}),Q=()=>({tag:"code"}),W=()=>({tag:"i"}),X=o=>{const e={...o.attrs},{linktype:t="url"}=o.attrs;return M(t)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},Z=o=>({tag:[{tag:"span",attrs:o.attrs}]}),R={nodes:{horizontal_rule:N,blockquote:L,bullet_list:U,code_block:H,hard_break:q,heading:V,image:D,list_item:B,ordered_list:z,paragraph:J},marks:{bold:F,strike:Y,underline:K,strong:G,code:Q,italic:W,link:X,styled:Z}},ee=function(o){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=RegExp(t.source);return o&&s.test(o)?o.replace(t,r=>e[r]):o};class f{constructor(e){h(this,"marks"),h(this,"nodes"),e||(e=R),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e){if(e&&e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(s=>{t+=this.renderNode(s)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const i=this.getMatchingMark(r);i&&t.push(this.renderOpeningTag(i.tag))});const s=this.getMatchingNode(e);return s&&s.tag&&t.push(this.renderOpeningTag(s.tag)),e.content?e.content.forEach(r=>{t.push(this.renderNode(r))}):e.text?t.push(ee(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html&&t.push(s.html),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const i=this.getMatchingMark(r);i&&t.push(this.renderClosingTag(i.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(s=>{if(s.constructor===String)return`<${s}${t}>`;{let r=`<${s.tag}`;if(s.attrs)for(const i in s.attrs){const n=s.attrs[i];n!==null&&(r+=` ${i}="${n}"`)}return`${r}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}}class ${constructor(){h(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),h(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),h(this,"delay",e=>new Promise(t=>setTimeout(t,e))),h(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t)),h(this,"range",(e=0,t=e)=>{const s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(i,n)=>n*r+e)}),h(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),h(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[]))}stringify(e,t,s){const r=[];for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const n=e[i],a=s?"":encodeURIComponent(i);let l;typeof n=="object"?l=this.stringify(n,t?t+encodeURIComponent("["+a+"]"):a,Array.isArray(n)):l=(t?t+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(n),r.push(l)}return r.join("&")}}class te{constructor(e){h(this,"baseURL"),h(this,"timeout"),h(this,"headers"),h(this,"responseInterceptor"),h(this,"fetch"),h(this,"ejectInterceptor"),h(this,"url"),h(this,"parameters"),this.baseURL=e.baseURL,this.headers=e.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={}}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(r=>{s.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return s.headers={...t},s.status=e.status,s.statusText=e.statusText,s}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,s=null;if(e==="get"){const l=new $;t=`${this.baseURL}${this.url}?${l.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),i=new AbortController,{signal:n}=i;let a;this.timeout&&(a=setTimeout(()=>i.abort(),this.timeout));try{const l=await this.fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:n});this.timeout&&clearTimeout(a);const c=await this._responseHandler(l);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(l){return{message:l}}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((s,r)=>{if(t.test(`${e.status}`))return s(e);const i={message:new Error(e.statusText),status:e.status,response:e.data.error||e.data.slug};r(i)})}}let k={};const g={};class se{constructor(e,t){if(h(this,"client"),h(this,"maxRetries"),h(this,"throttle"),h(this,"accessToken"),h(this,"cache"),h(this,"helpers"),h(this,"relations"),h(this,"links"),h(this,"richTextResolver"),h(this,"resolveNestedRelations"),!t){const i=e.region?`-${e.region}`:"",n=e.https===!1?"http":"https";e.oauthToken?t=`${n}://api${i}.storyblok.com/v1`:t=`${n}://api${i}.storyblok.com/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),s.forEach((i,n)=>{e.headers&&e.headers[n]&&s.set(n,e.headers[n])});let r=5;e.oauthToken&&(s.set("Authorization",e.oauthToken),r=3),e.rateLimit&&(r=e.rateLimit),e.richTextSchema?this.richTextResolver=new f(e.richTextSchema):this.richTextResolver=new f,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries,this.throttle=A(this.throttledRequest,r,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new $,this.resolveNestedRelations=!1,this.client=new te({baseURL:t,timeout:e.timeout||0,headers:s,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=g[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,s,r){const i=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,s,r));return this.cacheResponse(e,i)}get(e,t){t||(t={});const s=`/${e}`,r=this.factoryParamOptions(s,t);return this.cacheResponse(s,r)}async getAll(e,t,s){const r=(t==null?void 0:t.per_page)||25,i=`/${e}`,n=i.split("/"),a=s||n[n.length-1],l=1,c=await this.makeRequest(i,t,r,l),u=c.total?Math.ceil(c.total/r):1,y=await this.helpers.asyncMap(this.helpers.range(l,u),v=>this.makeRequest(i,t,r,v+1));return this.helpers.flatMap([c,...y],v=>Object.values(v.data[a]))}post(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("post",s,t))}put(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("put",s,t))}delete(e,t){const s=`/${e}`;return Promise.resolve(this.throttle("delete",s,t))}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const s=e[t];s&&s.fieldtype=="multilink"&&s.linktype=="story"&&typeof s.id=="string"&&this.links[s.id]?s.story=this._cleanCopy(this.links[s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[s.uuid]&&(s.story=this._cleanCopy(this.links[s.uuid]))}_insertRelations(e,t,s){if(s.indexOf(`${e.component}.${t}`)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t]&&e[t].constructor===Array){const r=[];e[t].forEach(i=>{this.relations[i]&&r.push(this._cleanCopy(this.relations[i]))}),e[t]=r}}}iterateTree(e,t){const s=r=>{if(r!=null){if(r.constructor===Array)for(let i=0;i<r.length;i++)s(r[i]);else if(r.constructor===Object){if(r._stopResolving)return;for(const i in r)(r.component&&r._uid||r.type==="link")&&(this._insertRelations(r,i,t),this._insertLinks(r,i)),s(r[i])}}};s(e.content)}async resolveLinks(e,t){let s=[];if(e.link_uuids){const r=e.link_uuids.length,i=[],n=50;for(let a=0;a<r;a+=n){const l=Math.min(r,a+n);i.push(e.link_uuids.slice(a,l))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:n,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(l=>{s.push(l)})}else s=e.links;s.forEach(r=>{this.links[r.uuid]={...r,_stopResolving:!0}})}async resolveRelations(e,t){let s=[];if(e.rel_uuids){const r=e.rel_uuids.length,i=[],n=50;for(let a=0;a<r;a+=n){const l=Math.min(r,a+n);i.push(e.rel_uuids.slice(a,l))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:n,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(l=>{s.push(l)})}else s=e.rels;s&&s.length>0&&s.forEach(r=>{this.relations[r.uuid]={...r,_stopResolving:!0}})}async resolveStories(e,t){var s,r;let i=[];if(typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(i=t.resolve_relations.split(",")),await this.resolveRelations(e,t)),t.resolve_links&&["1","story","url"].indexOf(t.resolve_links)>-1&&((s=e.links)!=null&&s.length||(r=e.link_uuids)!=null&&r.length)&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const n in this.relations)this.iterateTree(this.relations[n],i);e.story?this.iterateTree(e.story,i):e.stories.forEach(n=>{this.iterateTree(n,i)})}async cacheResponse(e,t,s){const r=this.helpers.stringify({url:e,params:t}),i=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const n=await i.get(r);if(n)return Promise.resolve(n)}return new Promise((n,a)=>{try{(async()=>{var l;try{const c=await this.throttle("get",e,t);let u={data:c.data,headers:c.headers};return(l=c.headers)!=null&&l["per-page"]&&(u=Object.assign({},u,{perPage:c.headers["per-page"]?parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?parseInt(c.headers.total):0})),c.status!=200?a(c):((u.data.story||u.data.stories)&&await this.resolveStories(u.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&await i.set(r,u),u.data.cv&&t.token&&(t.version=="draft"&&g[t.token]!=u.data.cv&&await this.flushCache(),g[t.token]=u.data.cv),n(u))}catch(c){return a(c)}})()}catch{}})}throttledRequest(e,t,s){return this.client[e](t,s)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(e){this.accessToken&&(g[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(k[e])},getAll(){return Promise.resolve(k)},set(e,t){return k[e]=t,Promise.resolve(void 0)},flush(){return k={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve(void 0)},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}}const re=(o={})=>{const{apiOptions:e}=o;if(!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 se(e)}},oe=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let b;const ie="https://app.storyblok.com/f/storyblok-v2-latest.js",P=(o,e,t={})=>{var s;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===o;if(!(!r||!i)){if(!o){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],n=>{n.action==="input"&&n.story.id===o?e(n.story):(n.action==="change"||n.action==="published")&&n.storyId===o&&window.location.reload()})})}},ne=(o={})=>{var e,t;const{bridge:s,accessToken:r,use:i=[],apiOptions:n={},richText:a={}}=o;n.accessToken=n.accessToken||r;const l={bridge:s,apiOptions:n};let c={};i.forEach(y=>{c={...c,...y(l)}});const u=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return s!==!1&&u&&C(ie),b=new f(a.schema),a.resolver&&S(b,a.resolver),c},S=(o,e)=>{o.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},ae=(o,e,t)=>{let s=t||b;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return o===""?"":o?(e&&(s=new f(e.schema),e.resolver&&S(s,e.resolver)),s.render(o)):(console.warn(`${o} is not a valid Richtext object. This might be because the value of the richtext field is empty.
2
2
 
3
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},I=p.defineComponent({__name:"StoryblokComponent",props:{blok:null},setup(o){return(e,t)=>(p.openBlock(),p.createBlock(p.resolveDynamicComponent(o.blok.component),p.normalizeProps(p.guardReactiveProps({...e.$props,...e.$attrs})),null,16))}}),be={beforeMount(o,e){if(e.value){const t=fe(e.value);o.setAttribute("data-blok-c",t["data-blok-c"]),o.setAttribute("data-blok-uid",t["data-blok-uid"]),o.classList.add("storyblok__outline")}}},A=o=>{console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
4
- `)};let b=null;const ke=()=>(b||A("useStoryblokApi"),b),ve=async(o,e={},t={})=>{const s=p.ref(null);if(p.onMounted(()=>{s.value&&s.value.id&&C(s.value.id,r=>s.value=r,t)}),b){const{data:r}=await b.get(`cdn/stories/${o}`,e);s.value=r.story}else A("useStoryblok");return s},_e={install(o,e={}){o.directive("editable",be),o.component("StoryblokComponent",I);const{storyblokApi:t}=ye(e);b=t}};d.RichTextResolver=y,d.RichTextSchema=$,d.StoryblokComponent=I,d.StoryblokVue=_e,d.apiPlugin=pe,d.renderRichText=me,d.useStoryblok=ve,d.useStoryblokApi=ke,d.useStoryblokBridge=C,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
3
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")},j=p.defineComponent({__name:"StoryblokComponent",props:{blok:null},setup(o){return(e,t)=>(p.openBlock(),p.createBlock(p.resolveDynamicComponent(o.blok.component),p.normalizeProps(p.guardReactiveProps({...e.$props,...e.$attrs})),null,16))}}),le={beforeMount(o,e){if(e.value){const t=oe(e.value);o.setAttribute("data-blok-c",t["data-blok-c"]),o.setAttribute("data-blok-uid",t["data-blok-uid"]),o.classList.add("storyblok__outline")}}},E=o=>{console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
4
+ `)};let m=null;const ce=()=>(m||E("useStoryblokApi"),m),he=async(o,e={},t={})=>{const s=p.ref(null);if(p.onMounted(()=>{s.value&&s.value.id&&P(s.value.id,r=>s.value=r,t)}),m){const{data:r}=await m.get(`cdn/stories/${o}`,e);s.value=r.story}else E("useStoryblok");return s},ue={install(o,e={}){o.directive("editable",le),o.component("StoryblokComponent",j);const{storyblokApi:t}=ne(e);m=t}};d.RichTextResolver=f,d.RichTextSchema=R,d.StoryblokComponent=j,d.StoryblokVue=ue,d.apiPlugin=re,d.renderRichText=ae,d.useStoryblok=he,d.useStoryblokApi=ce,d.useStoryblokBridge=P,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
@@ -1,81 +1,73 @@
1
- import { defineComponent as j, openBlock as x, createBlock as C, resolveDynamicComponent as I, normalizeProps as A, guardReactiveProps as M, ref as N, onMounted as L } from "vue";
2
- var U = Object.defineProperty, D = Object.defineProperties, H = Object.getOwnPropertyDescriptors, w = Object.getOwnPropertySymbols, B = Object.prototype.hasOwnProperty, q = Object.prototype.propertyIsEnumerable, T = (o, e, t) => e in o ? U(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, p = (o, e) => {
3
- for (var t in e || (e = {}))
4
- B.call(e, t) && T(o, t, e[t]);
5
- if (w)
6
- for (var t of w(e))
7
- q.call(e, t) && T(o, t, e[t]);
8
- return o;
9
- }, v = (o, e) => D(o, H(e));
10
- let R = !1;
11
- const P = [], V = (o) => new Promise((e, t) => {
1
+ import { defineComponent as $, openBlock as P, createBlock as E, resolveDynamicComponent as j, normalizeProps as S, guardReactiveProps as x, ref as C, onMounted as O } from "vue";
2
+ let v = !1;
3
+ const b = [], A = (o) => new Promise((e, t) => {
12
4
  if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
13
5
  if (window.location === window.parent.location) {
14
6
  console.warn("You are not in Draft Mode or in the Visual Editor.");
15
7
  return;
16
8
  }
17
- R ? r() : P.push(r);
9
+ v ? r() : b.push(r);
18
10
  }, document.getElementById("storyblok-javascript-bridge")))
19
11
  return;
20
12
  const s = document.createElement("script");
21
13
  s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
22
- P.forEach((n) => n()), R = !0, e(r);
14
+ b.forEach((i) => i()), v = !0, e(r);
23
15
  }, document.getElementsByTagName("head")[0].appendChild(s);
24
16
  });
25
- var z = Object.defineProperty, J = (o, e, t) => e in o ? z(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, c = (o, e, t) => (J(o, typeof e != "symbol" ? e + "" : e, t), t);
26
- function E(o) {
17
+ var I = Object.defineProperty, M = (o, e, t) => e in o ? I(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, h = (o, e, t) => (M(o, typeof e != "symbol" ? e + "" : e, t), t);
18
+ function w(o) {
27
19
  return !(o !== o || o === 1 / 0 || o === -1 / 0);
28
20
  }
29
- function F(o, e, t) {
30
- if (!E(e))
21
+ function N(o, e, t) {
22
+ if (!w(e))
31
23
  throw new TypeError("Expected `limit` to be a finite number");
32
- if (!E(t))
24
+ if (!w(t))
33
25
  throw new TypeError("Expected `interval` to be a finite number");
34
26
  const s = [];
35
- let r = [], n = 0;
36
- const a = function() {
37
- n++;
27
+ let r = [], i = 0;
28
+ const n = function() {
29
+ i++;
38
30
  const l = setTimeout(function() {
39
- n--, s.length > 0 && a(), r = r.filter(function(u) {
31
+ i--, s.length > 0 && n(), r = r.filter(function(u) {
40
32
  return u !== l;
41
33
  });
42
34
  }, t);
43
35
  r.indexOf(l) < 0 && r.push(l);
44
- const h = s.shift();
45
- h.resolve(o.apply(h.self, h.args));
46
- }, i = function(...l) {
47
- const h = this;
48
- return new Promise(function(u, b) {
36
+ const c = s.shift();
37
+ c.resolve(o.apply(c.self, c.args));
38
+ }, a = function(...l) {
39
+ const c = this;
40
+ return new Promise(function(u, p) {
49
41
  s.push({
50
42
  resolve: u,
51
- reject: b,
43
+ reject: p,
52
44
  args: l,
53
- self: h
54
- }), n < e && a();
45
+ self: c
46
+ }), i < e && n();
55
47
  });
56
48
  };
57
- return i.abort = function() {
49
+ return a.abort = function() {
58
50
  r.forEach(clearTimeout), r = [], s.forEach(function(l) {
59
51
  l.reject(function() {
60
52
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
61
53
  });
62
54
  }), s.length = 0;
63
- }, i;
55
+ }, a;
64
56
  }
65
- const G = function(o, e) {
57
+ const L = function(o, e) {
66
58
  const t = {};
67
59
  for (const s in o) {
68
60
  const r = o[s];
69
61
  e.indexOf(s) > -1 && r !== null && (t[s] = r);
70
62
  }
71
63
  return t;
72
- }, Y = (o) => o === "email", K = () => ({
64
+ }, U = (o) => o === "email", H = () => ({
73
65
  singleTag: "hr"
74
- }), Q = () => ({
66
+ }), q = () => ({
75
67
  tag: "blockquote"
76
- }), W = () => ({
68
+ }), D = () => ({
77
69
  tag: "ul"
78
- }), X = (o) => ({
70
+ }), B = (o) => ({
79
71
  tag: [
80
72
  "pre",
81
73
  {
@@ -83,38 +75,38 @@ const G = function(o, e) {
83
75
  attrs: o.attrs
84
76
  }
85
77
  ]
86
- }), Z = () => ({
78
+ }), V = () => ({
87
79
  singleTag: "br"
88
- }), ee = (o) => ({
80
+ }), z = (o) => ({
89
81
  tag: `h${o.attrs.level}`
90
- }), te = (o) => ({
82
+ }), J = (o) => ({
91
83
  singleTag: [
92
84
  {
93
85
  tag: "img",
94
- attrs: G(o.attrs, ["src", "alt", "title"])
86
+ attrs: L(o.attrs, ["src", "alt", "title"])
95
87
  }
96
88
  ]
97
- }), se = () => ({
89
+ }), F = () => ({
98
90
  tag: "li"
99
- }), re = () => ({
91
+ }), Y = () => ({
100
92
  tag: "ol"
101
- }), oe = () => ({
93
+ }), K = () => ({
102
94
  tag: "p"
103
- }), ne = () => ({
95
+ }), G = () => ({
104
96
  tag: "b"
105
- }), ie = () => ({
97
+ }), Q = () => ({
106
98
  tag: "strike"
107
- }), ae = () => ({
99
+ }), W = () => ({
108
100
  tag: "u"
109
- }), le = () => ({
101
+ }), X = () => ({
110
102
  tag: "strong"
111
- }), ce = () => ({
103
+ }), Z = () => ({
112
104
  tag: "code"
113
- }), he = () => ({
105
+ }), ee = () => ({
114
106
  tag: "i"
115
- }), ue = (o) => {
116
- const e = p({}, o.attrs), { linktype: t = "url" } = o.attrs;
117
- return Y(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
107
+ }), te = (o) => {
108
+ const e = { ...o.attrs }, { linktype: t = "url" } = o.attrs;
109
+ return U(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
118
110
  tag: [
119
111
  {
120
112
  tag: "a",
@@ -122,37 +114,37 @@ const G = function(o, e) {
122
114
  }
123
115
  ]
124
116
  };
125
- }, pe = (o) => ({
117
+ }, se = (o) => ({
126
118
  tag: [
127
119
  {
128
120
  tag: "span",
129
121
  attrs: o.attrs
130
122
  }
131
123
  ]
132
- }), de = {
124
+ }), re = {
133
125
  nodes: {
134
- horizontal_rule: K,
135
- blockquote: Q,
136
- bullet_list: W,
137
- code_block: X,
138
- hard_break: Z,
139
- heading: ee,
140
- image: te,
141
- list_item: se,
142
- ordered_list: re,
143
- paragraph: oe
126
+ horizontal_rule: H,
127
+ blockquote: q,
128
+ bullet_list: D,
129
+ code_block: B,
130
+ hard_break: V,
131
+ heading: z,
132
+ image: J,
133
+ list_item: F,
134
+ ordered_list: Y,
135
+ paragraph: K
144
136
  },
145
137
  marks: {
146
- bold: ne,
147
- strike: ie,
148
- underline: ae,
149
- strong: le,
150
- code: ce,
151
- italic: he,
152
- link: ue,
153
- styled: pe
154
- }
155
- }, ge = function(o) {
138
+ bold: G,
139
+ strike: Q,
140
+ underline: W,
141
+ strong: X,
142
+ code: Z,
143
+ italic: ee,
144
+ link: te,
145
+ styled: se
146
+ }
147
+ }, oe = function(o) {
156
148
  const e = {
157
149
  "&": "&amp;",
158
150
  "<": "&lt;",
@@ -162,9 +154,9 @@ const G = function(o, e) {
162
154
  }, t = /[&<>"']/g, s = RegExp(t.source);
163
155
  return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
164
156
  };
165
- class y {
157
+ class m {
166
158
  constructor(e) {
167
- c(this, "marks"), c(this, "nodes"), e || (e = de), this.marks = e.marks || [], this.nodes = e.nodes || [];
159
+ h(this, "marks"), h(this, "nodes"), e || (e = re), this.marks = e.marks || [], this.nodes = e.nodes || [];
168
160
  }
169
161
  addNode(e, t) {
170
162
  this.nodes[e] = t;
@@ -179,20 +171,22 @@ class y {
179
171
  t += this.renderNode(s);
180
172
  }), t;
181
173
  }
182
- return console.warn("The render method must receive an object with a content field, which is an array"), "";
174
+ return console.warn(
175
+ "The render method must receive an object with a content field, which is an array"
176
+ ), "";
183
177
  }
184
178
  renderNode(e) {
185
179
  const t = [];
186
180
  e.marks && e.marks.forEach((r) => {
187
- const n = this.getMatchingMark(r);
188
- n && t.push(this.renderOpeningTag(n.tag));
181
+ const i = this.getMatchingMark(r);
182
+ i && t.push(this.renderOpeningTag(i.tag));
189
183
  });
190
184
  const s = this.getMatchingNode(e);
191
185
  return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
192
186
  t.push(this.renderNode(r));
193
- }) : e.text ? t.push(ge(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html && t.push(s.html), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
194
- const n = this.getMatchingMark(r);
195
- n && t.push(this.renderClosingTag(n.tag));
187
+ }) : e.text ? t.push(oe(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html && t.push(s.html), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
188
+ const i = this.getMatchingMark(r);
189
+ i && t.push(this.renderClosingTag(i.tag));
196
190
  }), t.join("");
197
191
  }
198
192
  renderTag(e, t) {
@@ -202,9 +196,9 @@ class y {
202
196
  {
203
197
  let r = `<${s.tag}`;
204
198
  if (s.attrs)
205
- for (const n in s.attrs) {
206
- const a = s.attrs[n];
207
- a !== null && (r += ` ${n}="${a}"`);
199
+ for (const i in s.attrs) {
200
+ const n = s.attrs[i];
201
+ n !== null && (r += ` ${i}="${n}"`);
208
202
  }
209
203
  return `${r}${t}>`;
210
204
  }
@@ -227,44 +221,48 @@ class y {
227
221
  return t(e);
228
222
  }
229
223
  }
230
- class O {
224
+ class _ {
231
225
  constructor() {
232
- c(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), c(this, "getOptionsPage", (e, t = 25, s = 1) => v(p({}, e), {
226
+ h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, s = 1) => ({
227
+ ...e,
233
228
  per_page: t,
234
229
  page: s
235
- })), c(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), c(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), c(this, "range", (e = 0, t = e) => {
230
+ })), h(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), h(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), h(this, "range", (e = 0, t = e) => {
236
231
  const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
237
- return this.arrayFrom(s, (n, a) => a * r + e);
238
- }), c(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), c(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []));
232
+ return this.arrayFrom(s, (i, n) => n * r + e);
233
+ }), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], []));
239
234
  }
240
235
  stringify(e, t, s) {
241
236
  const r = [];
242
- for (const n in e) {
243
- if (!Object.prototype.hasOwnProperty.call(e, n))
237
+ for (const i in e) {
238
+ if (!Object.prototype.hasOwnProperty.call(e, i))
244
239
  continue;
245
- const a = e[n], i = s ? "" : encodeURIComponent(n);
240
+ const n = e[i], a = s ? "" : encodeURIComponent(i);
246
241
  let l;
247
- typeof a == "object" ? l = this.stringify(a, t ? t + encodeURIComponent("[" + i + "]") : i, Array.isArray(a)) : l = (t ? t + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(a), r.push(l);
242
+ typeof n == "object" ? l = this.stringify(
243
+ n,
244
+ t ? t + encodeURIComponent("[" + a + "]") : a,
245
+ Array.isArray(n)
246
+ ) : l = (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(n), r.push(l);
248
247
  }
249
248
  return r.join("&");
250
249
  }
251
250
  }
252
- var g = /* @__PURE__ */ ((o) => (o.GET = "get", o.DELETE = "delete", o.POST = "post", o.PUT = "put", o))(g || {});
253
- class fe {
251
+ class ie {
254
252
  constructor(e) {
255
- c(this, "baseURL"), c(this, "timeout"), c(this, "headers"), c(this, "responseInterceptor"), c(this, "ejectInterceptor"), c(this, "url"), c(this, "parameters"), this.baseURL = e.baseURL, this.timeout = e.timeout ? e.timeout * 1e3 : 1e3, this.headers = e.headers || [], this.responseInterceptor = e.responseInterceptor, this.ejectInterceptor = !1, this.url = "", this.parameters = {};
253
+ h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), this.baseURL = e.baseURL, this.headers = e.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 = {};
256
254
  }
257
255
  get(e, t) {
258
- return this.url = e, this.parameters = t, this._methodHandler(g.GET);
256
+ return this.url = e, this.parameters = t, this._methodHandler("get");
259
257
  }
260
258
  post(e, t) {
261
- return this.url = e, this.parameters = t, this._methodHandler(g.POST);
259
+ return this.url = e, this.parameters = t, this._methodHandler("post");
262
260
  }
263
261
  put(e, t) {
264
- return this.url = e, this.parameters = t, this._methodHandler(g.PUT);
262
+ return this.url = e, this.parameters = t, this._methodHandler("put");
265
263
  }
266
264
  delete(e, t) {
267
- return this.url = e, this.parameters = t, this._methodHandler(g.DELETE);
265
+ return this.url = e, this.parameters = t, this._methodHandler("delete");
268
266
  }
269
267
  async _responseHandler(e) {
270
268
  const t = [], s = {
@@ -273,63 +271,77 @@ class fe {
273
271
  status: 0,
274
272
  statusText: ""
275
273
  };
276
- await e.json().then((r) => {
274
+ e.status !== 204 && await e.json().then((r) => {
277
275
  s.data = r;
278
276
  });
279
277
  for (const r of e.headers.entries())
280
278
  t[r[0]] = r[1];
281
- return s.headers = p({}, t), s.status = e.status, s.statusText = e.statusText, s;
279
+ return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
282
280
  }
283
281
  async _methodHandler(e) {
284
- const t = new URL(`${this.baseURL}${this.url}`);
285
- let s = null;
282
+ let t = `${this.baseURL}${this.url}`, s = null;
286
283
  if (e === "get") {
287
- const i = new O();
288
- t.search = i.stringify(this.parameters);
284
+ const l = new _();
285
+ t = `${this.baseURL}${this.url}?${l.stringify(
286
+ this.parameters
287
+ )}`;
289
288
  } else
290
289
  s = JSON.stringify(this.parameters);
291
- const r = new AbortController(), { signal: n } = r, a = setTimeout(() => r.abort(), this.timeout);
290
+ const r = new URL(t), i = new AbortController(), { signal: n } = i;
291
+ let a;
292
+ this.timeout && (a = setTimeout(() => i.abort(), this.timeout));
292
293
  try {
293
- const i = await fetch(`${t}`, {
294
+ const l = await this.fetch(`${r}`, {
294
295
  method: e,
295
296
  headers: this.headers,
296
297
  body: s,
297
298
  signal: n
298
299
  });
299
- clearTimeout(a);
300
- const l = await this._responseHandler(i);
301
- return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(l)) : this._statusHandler(l);
302
- } catch (i) {
303
- return i;
300
+ this.timeout && clearTimeout(a);
301
+ const c = await this._responseHandler(l);
302
+ return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(c)) : this._statusHandler(c);
303
+ } catch (l) {
304
+ return {
305
+ message: l
306
+ };
304
307
  }
305
308
  }
306
309
  eject() {
307
310
  this.ejectInterceptor = !0;
308
311
  }
309
312
  _statusHandler(e) {
310
- if (/20[01]/g.test(`${e.status}`))
311
- return e;
312
- throw {
313
- message: new Error(e.statusText || `status: ${e.status}`),
314
- response: e
315
- };
313
+ const t = /20[0-6]/g;
314
+ return new Promise((s, r) => {
315
+ if (t.test(`${e.status}`))
316
+ return s(e);
317
+ const i = {
318
+ message: new Error(e.statusText),
319
+ status: e.status,
320
+ response: e.data.error || e.data.slug
321
+ };
322
+ r(i);
323
+ });
316
324
  }
317
325
  }
318
- let m = {};
326
+ let f = {};
319
327
  const d = {};
320
- class me {
328
+ class ne {
321
329
  constructor(e, t) {
322
- if (c(this, "client"), c(this, "maxRetries"), c(this, "throttle"), c(this, "accessToken"), c(this, "cache"), c(this, "helpers"), c(this, "relations"), c(this, "links"), c(this, "richTextResolver"), c(this, "resolveNestedRelations"), !t) {
323
- const n = e.region ? `-${e.region}` : "", a = e.https === !1 ? "http" : "https";
324
- e.oauthToken ? t = `${a}://api${n}.storyblok.com/v1` : t = `${a}://api${n}.storyblok.com/v2`;
330
+ if (h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations"), !t) {
331
+ const i = e.region ? `-${e.region}` : "", n = e.https === !1 ? "http" : "https";
332
+ e.oauthToken ? t = `${n}://api${i}.storyblok.com/v1` : t = `${n}://api${i}.storyblok.com/v2`;
325
333
  }
326
- const s = Object.assign({}, e.headers);
334
+ const s = new Headers();
335
+ s.set("Content-Type", "application/json"), s.set("Accept", "application/json"), s.forEach((i, n) => {
336
+ e.headers && e.headers[n] && s.set(n, e.headers[n]);
337
+ });
327
338
  let r = 5;
328
- e.oauthToken && (s.Authorization = e.oauthToken, r = 3), e.rateLimit && (r = e.rateLimit), e.richTextSchema ? this.richTextResolver = new y(e.richTextSchema) : this.richTextResolver = new y(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries, this.throttle = F(this.throttledRequest, r, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new O(), this.resolveNestedRelations = !1, this.client = new fe({
339
+ e.oauthToken && (s.set("Authorization", e.oauthToken), r = 3), e.rateLimit && (r = e.rateLimit), e.richTextSchema ? this.richTextResolver = new m(e.richTextSchema) : this.richTextResolver = new m(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries, this.throttle = N(this.throttledRequest, r, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new _(), this.resolveNestedRelations = !1, this.client = new ie({
329
340
  baseURL: t,
330
341
  timeout: e.timeout || 0,
331
342
  headers: s,
332
- responseInterceptor: e.responseInterceptor
343
+ responseInterceptor: e.responseInterceptor,
344
+ fetch: e.fetch
333
345
  });
334
346
  }
335
347
  setComponentResolver(e) {
@@ -349,8 +361,11 @@ class me {
349
361
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
350
362
  }
351
363
  makeRequest(e, t, s, r) {
352
- const n = this.factoryParamOptions(e, this.helpers.getOptionsPage(t, s, r));
353
- return this.cacheResponse(e, n);
364
+ const i = this.factoryParamOptions(
365
+ e,
366
+ this.helpers.getOptionsPage(t, s, r)
367
+ );
368
+ return this.cacheResponse(e, i);
354
369
  }
355
370
  get(e, t) {
356
371
  t || (t = {});
@@ -358,8 +373,14 @@ class me {
358
373
  return this.cacheResponse(s, r);
359
374
  }
360
375
  async getAll(e, t, s) {
361
- const r = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, a = n.split("/"), i = s || a[a.length - 1], l = 1, h = await this.makeRequest(n, t, r, l), u = h.total ? Math.ceil(h.total / r) : 1, b = await this.helpers.asyncMap(this.helpers.range(l, u), (k) => this.makeRequest(n, t, r, k + 1));
362
- return this.helpers.flatMap([h, ...b], (k) => Object.values(k.data[i]));
376
+ const r = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, n = i.split("/"), a = s || n[n.length - 1], l = 1, c = await this.makeRequest(i, t, r, l), u = c.total ? Math.ceil(c.total / r) : 1, p = await this.helpers.asyncMap(
377
+ this.helpers.range(l, u),
378
+ (y) => this.makeRequest(i, t, r, y + 1)
379
+ );
380
+ return this.helpers.flatMap(
381
+ [c, ...p],
382
+ (y) => Object.values(y.data[a])
383
+ );
363
384
  }
364
385
  post(e, t) {
365
386
  const s = `/${e}`;
@@ -398,8 +419,8 @@ class me {
398
419
  this.relations[e[t]] && (e[t] = this._cleanCopy(this.relations[e[t]]));
399
420
  else if (e[t] && e[t].constructor === Array) {
400
421
  const r = [];
401
- e[t].forEach((n) => {
402
- this.relations[n] && r.push(this._cleanCopy(this.relations[n]));
422
+ e[t].forEach((i) => {
423
+ this.relations[i] && r.push(this._cleanCopy(this.relations[i]));
403
424
  }), e[t] = r;
404
425
  }
405
426
  }
@@ -408,13 +429,17 @@ class me {
408
429
  const s = (r) => {
409
430
  if (r != null) {
410
431
  if (r.constructor === Array)
411
- for (let n = 0; n < r.length; n++)
412
- s(r[n]);
432
+ for (let i = 0; i < r.length; i++)
433
+ s(r[i]);
413
434
  else if (r.constructor === Object) {
414
435
  if (r._stopResolving)
415
436
  return;
416
- for (const n in r)
417
- (r.component && r._uid || r.type === "link") && (this._insertRelations(r, n, t), this._insertLinks(r, n)), s(r[n]);
437
+ for (const i in r)
438
+ (r.component && r._uid || r.type === "link") && (this._insertRelations(
439
+ r,
440
+ i,
441
+ t
442
+ ), this._insertLinks(r, i)), s(r[i]);
418
443
  }
419
444
  }
420
445
  };
@@ -423,78 +448,82 @@ class me {
423
448
  async resolveLinks(e, t) {
424
449
  let s = [];
425
450
  if (e.link_uuids) {
426
- const r = e.link_uuids.length, n = [], a = 50;
427
- for (let i = 0; i < r; i += a) {
428
- const l = Math.min(r, i + a);
429
- n.push(e.link_uuids.slice(i, l));
451
+ const r = e.link_uuids.length, i = [], n = 50;
452
+ for (let a = 0; a < r; a += n) {
453
+ const l = Math.min(r, a + n);
454
+ i.push(e.link_uuids.slice(a, l));
430
455
  }
431
- for (let i = 0; i < n.length; i++)
456
+ for (let a = 0; a < i.length; a++)
432
457
  (await this.getStories({
433
- per_page: a,
458
+ per_page: n,
434
459
  language: t.language,
435
460
  version: t.version,
436
- by_uuids: n[i].join(",")
437
- })).data.stories.forEach((l) => {
438
- s.push(l);
439
- });
461
+ by_uuids: i[a].join(",")
462
+ })).data.stories.forEach(
463
+ (l) => {
464
+ s.push(l);
465
+ }
466
+ );
440
467
  } else
441
468
  s = e.links;
442
469
  s.forEach((r) => {
443
- this.links[r.uuid] = v(p({}, r), { _stopResolving: !0 });
470
+ this.links[r.uuid] = { ...r, _stopResolving: !0 };
444
471
  });
445
472
  }
446
473
  async resolveRelations(e, t) {
447
474
  let s = [];
448
475
  if (e.rel_uuids) {
449
- const r = e.rel_uuids.length, n = [], a = 50;
450
- for (let i = 0; i < r; i += a) {
451
- const l = Math.min(r, i + a);
452
- n.push(e.rel_uuids.slice(i, l));
476
+ const r = e.rel_uuids.length, i = [], n = 50;
477
+ for (let a = 0; a < r; a += n) {
478
+ const l = Math.min(r, a + n);
479
+ i.push(e.rel_uuids.slice(a, l));
453
480
  }
454
- for (let i = 0; i < n.length; i++)
481
+ for (let a = 0; a < i.length; a++)
455
482
  (await this.getStories({
456
- per_page: a,
483
+ per_page: n,
457
484
  language: t.language,
458
485
  version: t.version,
459
- by_uuids: n[i].join(",")
486
+ by_uuids: i[a].join(",")
460
487
  })).data.stories.forEach((l) => {
461
488
  s.push(l);
462
489
  });
463
490
  } else
464
491
  s = e.rels;
465
492
  s && s.length > 0 && s.forEach((r) => {
466
- this.relations[r.uuid] = v(p({}, r), { _stopResolving: !0 });
493
+ this.relations[r.uuid] = { ...r, _stopResolving: !0 };
467
494
  });
468
495
  }
469
496
  async resolveStories(e, t) {
470
497
  var s, r;
471
- let n = [];
472
- if (typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (n = t.resolve_relations.split(","), await this.resolveRelations(e, t)), t.resolve_links && ["1", "story", "url"].indexOf(t.resolve_links) > -1 && (((s = e.links) == null ? void 0 : s.length) || ((r = e.link_uuids) == null ? void 0 : r.length)) && await this.resolveLinks(e, t), this.resolveNestedRelations)
473
- for (const a in this.relations)
474
- this.iterateTree(this.relations[a], n);
475
- e.story ? this.iterateTree(e.story, n) : e.stories.forEach((a) => {
476
- this.iterateTree(a, n);
498
+ let i = [];
499
+ if (typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t)), t.resolve_links && ["1", "story", "url"].indexOf(t.resolve_links) > -1 && ((s = e.links) != null && s.length || (r = e.link_uuids) != null && r.length) && await this.resolveLinks(e, t), this.resolveNestedRelations)
500
+ for (const n in this.relations)
501
+ this.iterateTree(this.relations[n], i);
502
+ e.story ? this.iterateTree(e.story, i) : e.stories.forEach((n) => {
503
+ this.iterateTree(n, i);
477
504
  });
478
505
  }
479
- cacheResponse(e, t, s) {
480
- return new Promise((r, n) => {
481
- const a = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
482
- if (this.cache.clear === "auto" && t.version === "draft" && this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
483
- const l = i.get(a);
484
- if (l)
485
- return r(l);
486
- }
506
+ async cacheResponse(e, t, s) {
507
+ const r = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
508
+ if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
509
+ const n = await i.get(r);
510
+ if (n)
511
+ return Promise.resolve(n);
512
+ }
513
+ return new Promise((n, a) => {
487
514
  try {
488
515
  (async () => {
489
516
  var l;
490
- const h = await this.throttle("get", e, t);
491
- let u = { data: h.data, headers: h.headers };
492
- if ((l = h.headers) != null && l["per-page"] && (u = Object.assign({}, u, {
493
- perPage: h.headers["per-page"] ? parseInt(h.headers["per-page"]) : 0,
494
- total: h.headers["per-page"] ? parseInt(h.headers.total) : 0
495
- })), h.status != 200)
496
- return n(h);
497
- (u.data.story || u.data.stories) && await this.resolveStories(u.data, t), t.version === "published" && e != "/cdn/spaces/me" && i.set(a, u), u.data.cv && t.token && (t.version == "draft" && d[t.token] != u.data.cv && this.flushCache(), d[t.token] = u.data.cv), r(u);
517
+ try {
518
+ const c = await this.throttle("get", e, t);
519
+ let u = { data: c.data, headers: c.headers };
520
+ return (l = c.headers) != null && l["per-page"] && (u = Object.assign({}, u, {
521
+ perPage: c.headers["per-page"] ? parseInt(c.headers["per-page"]) : 0,
522
+ total: c.headers["per-page"] ? parseInt(c.headers.total) : 0
523
+ })), c.status != 200 ? a(c) : ((u.data.story || u.data.stories) && await this.resolveStories(u.data, t), t.version === "published" && e != "/cdn/spaces/me" && await i.set(r, u), u.data.cv && t.token && (t.version == "draft" && d[t.token] != u.data.cv && await this.flushCache(), d[t.token] = u.data.cv), n(u));
524
+ } catch (c) {
525
+ return a(c);
526
+ }
498
527
  })();
499
528
  } catch {
500
529
  }
@@ -517,84 +546,97 @@ class me {
517
546
  case "memory":
518
547
  return {
519
548
  get(e) {
520
- return m[e];
549
+ return Promise.resolve(f[e]);
521
550
  },
522
551
  getAll() {
523
- return m;
552
+ return Promise.resolve(f);
524
553
  },
525
554
  set(e, t) {
526
- m[e] = t;
555
+ return f[e] = t, Promise.resolve(void 0);
527
556
  },
528
557
  flush() {
529
- m = {};
558
+ return f = {}, Promise.resolve(void 0);
530
559
  }
531
560
  };
561
+ case "custom":
562
+ if (this.cache.custom)
563
+ return this.cache.custom;
532
564
  default:
533
565
  return {
534
566
  get() {
567
+ return Promise.resolve(void 0);
535
568
  },
536
569
  getAll() {
570
+ return Promise.resolve(void 0);
537
571
  },
538
572
  set() {
573
+ return Promise.resolve(void 0);
539
574
  },
540
575
  flush() {
576
+ return Promise.resolve(void 0);
541
577
  }
542
578
  };
543
579
  }
544
580
  }
545
- flushCache() {
546
- return this.cacheProvider().flush(), this;
581
+ async flushCache() {
582
+ return await this.cacheProvider().flush(), this;
547
583
  }
548
584
  }
549
- const Re = (o = {}) => {
585
+ const ge = (o = {}) => {
550
586
  const { apiOptions: e } = o;
551
587
  if (!e.accessToken) {
552
- 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");
588
+ console.error(
589
+ "You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
590
+ );
553
591
  return;
554
592
  }
555
- return { storyblokApi: new me(e) };
556
- };
557
- var ye = (o) => {
593
+ return { storyblokApi: new ne(e) };
594
+ }, ae = (o) => {
558
595
  if (typeof o != "object" || typeof o._editable > "u")
559
596
  return {};
560
- const e = JSON.parse(o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
597
+ const e = JSON.parse(
598
+ o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
599
+ );
561
600
  return {
562
601
  "data-blok-c": JSON.stringify(e),
563
602
  "data-blok-uid": e.id + "-" + e.uid
564
603
  };
565
604
  };
566
- let _;
567
- const be = "https://app.storyblok.com/f/storyblok-v2-latest.js", ke = (o, e, t = {}) => {
568
- if (!(typeof window > "u")) {
569
- if (typeof window.storyblokRegisterEvent > "u") {
570
- console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
571
- return;
572
- }
605
+ let k;
606
+ const le = "https://app.storyblok.com/f/storyblok-v2-latest.js", ce = (o, e, t = {}) => {
607
+ var s;
608
+ const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
609
+ "_storyblok"
610
+ ) === o;
611
+ if (!(!r || !i)) {
573
612
  if (!o) {
574
613
  console.warn("Story ID is not defined. Please provide a valid ID.");
575
614
  return;
576
615
  }
577
616
  window.storyblokRegisterEvent(() => {
578
- new window.StoryblokBridge(t).on(["input", "published", "change"], (r) => {
579
- r.action === "input" && r.story.id === o ? e(r.story) : (r.action === "change" || r.action === "published") && r.storyId === o && window.location.reload();
617
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (n) => {
618
+ n.action === "input" && n.story.id === o ? e(n.story) : (n.action === "change" || n.action === "published") && n.storyId === o && window.location.reload();
580
619
  });
581
620
  });
582
621
  }
583
- }, ve = (o = {}) => {
622
+ }, he = (o = {}) => {
623
+ var e, t;
584
624
  const {
585
- bridge: e,
586
- accessToken: t,
587
- use: s = [],
588
- apiOptions: r = {},
589
- richText: n = {}
625
+ bridge: s,
626
+ accessToken: r,
627
+ use: i = [],
628
+ apiOptions: n = {},
629
+ richText: a = {}
590
630
  } = o;
591
- r.accessToken = r.accessToken || t;
592
- const a = { bridge: e, apiOptions: r };
593
- let i = {};
594
- return s.forEach((l) => {
595
- i = p(p({}, i), l(a));
596
- }), e !== !1 && V(be), _ = new y(n.schema), n.resolver && $(_, n.resolver), i;
597
- }, $ = (o, e) => {
631
+ n.accessToken = n.accessToken || r;
632
+ const l = { bridge: s, apiOptions: n };
633
+ let c = {};
634
+ i.forEach((p) => {
635
+ c = { ...c, ...p(l) };
636
+ });
637
+ const u = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
638
+ return s !== !1 && u && A(le), k = new m(a.schema), a.resolver && T(k, a.resolver), c;
639
+ }, T = (o, e) => {
598
640
  o.addNode("blok", (t) => {
599
641
  let s = "";
600
642
  return t.attrs.body.forEach((r) => {
@@ -603,67 +645,69 @@ const be = "https://app.storyblok.com/f/storyblok-v2-latest.js", ke = (o, e, t =
603
645
  html: s
604
646
  };
605
647
  });
606
- }, Pe = (o, e, t) => {
607
- let s = t || _;
648
+ }, fe = (o, e, t) => {
649
+ let s = t || k;
608
650
  if (!s) {
609
- console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
651
+ console.error(
652
+ "Please initialize the Storyblok SDK before calling the renderRichText function"
653
+ );
610
654
  return;
611
655
  }
612
- return o === "" ? "" : o ? (e && (s = new y(e.schema), e.resolver && $(s, e.resolver)), s.render(o)) : (console.warn(`${o} is not a valid Richtext object. This might be because the value of the richtext field is empty.
656
+ return o === "" ? "" : o ? (e && (s = new m(e.schema), e.resolver && T(s, e.resolver)), s.render(o)) : (console.warn(`${o} is not a valid Richtext object. This might be because the value of the richtext field is empty.
613
657
 
614
658
  For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
615
- }, _e = /* @__PURE__ */ j({
659
+ }, ue = /* @__PURE__ */ $({
616
660
  __name: "StoryblokComponent",
617
661
  props: {
618
662
  blok: null
619
663
  },
620
664
  setup(o) {
621
- return (e, t) => (x(), C(I(o.blok.component), A(M({ ...e.$props, ...e.$attrs })), null, 16));
665
+ return (e, t) => (P(), E(j(o.blok.component), S(x({ ...e.$props, ...e.$attrs })), null, 16));
622
666
  }
623
- }), we = {
667
+ }), de = {
624
668
  beforeMount(o, e) {
625
669
  if (e.value) {
626
- const t = ye(e.value);
670
+ const t = ae(e.value);
627
671
  o.setAttribute("data-blok-c", t["data-blok-c"]), o.setAttribute("data-blok-uid", t["data-blok-uid"]), o.classList.add("storyblok__outline");
628
672
  }
629
673
  }
630
- }, S = (o) => {
674
+ }, R = (o) => {
631
675
  console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
632
676
  `);
633
677
  };
634
- let f = null;
635
- const Ee = () => (f || S("useStoryblokApi"), f), Oe = async (o, e = {}, t = {}) => {
636
- const s = N(null);
637
- if (L(() => {
638
- s.value && s.value.id && ke(
678
+ let g = null;
679
+ const me = () => (g || R("useStoryblokApi"), g), ye = async (o, e = {}, t = {}) => {
680
+ const s = C(null);
681
+ if (O(() => {
682
+ s.value && s.value.id && ce(
639
683
  s.value.id,
640
684
  (r) => s.value = r,
641
685
  t
642
686
  );
643
- }), f) {
644
- const { data: r } = await f.get(
687
+ }), g) {
688
+ const { data: r } = await g.get(
645
689
  `cdn/stories/${o}`,
646
690
  e
647
691
  );
648
692
  s.value = r.story;
649
693
  } else
650
- S("useStoryblok");
694
+ R("useStoryblok");
651
695
  return s;
652
- }, $e = {
696
+ }, ke = {
653
697
  install(o, e = {}) {
654
- o.directive("editable", we), o.component("StoryblokComponent", _e);
655
- const { storyblokApi: t } = ve(e);
656
- f = t;
698
+ o.directive("editable", de), o.component("StoryblokComponent", ue);
699
+ const { storyblokApi: t } = he(e);
700
+ g = t;
657
701
  }
658
702
  };
659
703
  export {
660
- y as RichTextResolver,
661
- de as RichTextSchema,
662
- _e as StoryblokComponent,
663
- $e as StoryblokVue,
664
- Re as apiPlugin,
665
- Pe as renderRichText,
666
- Oe as useStoryblok,
667
- Ee as useStoryblokApi,
668
- ke as useStoryblokBridge
704
+ m as RichTextResolver,
705
+ re as RichTextSchema,
706
+ ue as StoryblokComponent,
707
+ ke as StoryblokVue,
708
+ ge as apiPlugin,
709
+ fe as renderRichText,
710
+ ye as useStoryblok,
711
+ me as useStoryblokApi,
712
+ ce as useStoryblokBridge
669
713
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
- "version": "7.0.0",
3
+ "version": "7.1.1",
4
4
  "description": "Storyblok directive for get editable elements.",
5
5
  "main": "./dist/storyblok-vue.js",
6
6
  "module": "./dist/storyblok-vue.mjs",
@@ -19,31 +19,31 @@
19
19
  "build": "vite build && vue-tsc --declaration --emitDeclarationOnly",
20
20
  "test": "npm run test:unit && npm run test:e2e",
21
21
  "test:unit": "jest __tests__",
22
- "test:e2e": "cypress run-ct",
23
- "test:e2e-watch": "cypress open-ct",
22
+ "test:e2e": "cypress run --component",
23
+ "test:e2e-watch": "cypress open --component",
24
24
  "prepublishOnly": "npm run build && cp ../README.md ./"
25
25
  },
26
26
  "dependencies": {
27
- "@storyblok/js": "^2.0.5"
27
+ "@storyblok/js": "^2.1.1"
28
28
  },
29
29
  "devDependencies": {
30
- "@babel/core": "^7.20.5",
31
- "@cypress/vite-dev-server": "^2.0.7",
32
- "@cypress/vue": "^3.1.2",
33
- "@vitejs/plugin-vue": "^2.3.4",
30
+ "@babel/core": "^7.21.3",
31
+ "@cypress/vite-dev-server": "^5.0.4",
32
+ "@cypress/vue": "^5.0.4",
33
+ "@vitejs/plugin-vue": "^4.0.0",
34
34
  "@vue/babel-preset-app": "^5.0.8",
35
- "@vue/test-utils": "next",
35
+ "@vue/test-utils": "2.3.1",
36
36
  "@vue/tsconfig": "^0.1.3",
37
- "babel-jest": "^26.0.0",
38
- "cypress": "^9.6.0",
37
+ "@vue/vue3-jest": "^29.2.3",
38
+ "babel-jest": "^29.4.3",
39
+ "cypress": "^12.8.1",
39
40
  "eslint-plugin-cypress": "^2.12.1",
40
- "eslint-plugin-jest": "^27.1.7",
41
- "jest": "^28.1.3",
42
- "typescript": "^4.9.4",
43
- "vite": "^3.1.0",
44
- "vue": "^3.2.39",
45
- "vue-jest": "next",
46
- "vue-tsc": "^0.40.13"
41
+ "eslint-plugin-jest": "^27.2.1",
42
+ "jest": "^29.4.3",
43
+ "typescript": "^4.9.5",
44
+ "vite": "^4.1.4",
45
+ "vue": "^3.2.47",
46
+ "vue-tsc": "^1.2.0"
47
47
  },
48
48
  "babel": {
49
49
  "presets": [
@@ -58,7 +58,7 @@
58
58
  ],
59
59
  "transform": {
60
60
  "^.+\\.js$": "babel-jest",
61
- "^.+\\.vue$": "vue-jest"
61
+ "^.+\\.vue$": "@vue/vue3-jest"
62
62
  }
63
63
  },
64
64
  "repository": {