@storyblok/svelte 2.3.5 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="svelte/types/runtime/ambient" />
2
1
  export { useStoryblokBridge, apiPlugin, renderRichText, RichTextSchema, } from "@storyblok/js";
3
2
  import type { SbSvelteSDKOptions, StoryblokClient, SbBlokData } from "./types";
4
3
  export declare const storyblokEditable: (node: HTMLElement, value: SbBlokData) => {
@@ -7,6 +6,6 @@ export declare const storyblokEditable: (node: HTMLElement, value: SbBlokData) =
7
6
  export declare const useStoryblokApi: () => StoryblokClient;
8
7
  export { useStoryblokApi as getStoryblokApi };
9
8
  export declare const storyblokInit: (options: SbSvelteSDKOptions) => void;
10
- export declare const getComponent: (componentName: string) => typeof import("*.svelte").default;
9
+ export declare const getComponent: (componentName: string) => any;
11
10
  export * from "./types";
12
11
  export { default as StoryblokComponent } from "./StoryblokComponent.svelte";
@@ -1,14 +1,14 @@
1
- (function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h.storyblokSvelte={},h.e))})(this,function(h,m){"use strict";const at=(r=>r&&typeof r=="object"&&"default"in r?r:{default:r})(m);var lt=Object.defineProperty,ct=Object.defineProperties,ut=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,q=(r,t,e)=>t in r?lt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d=(r,t)=>{for(var e in t||(t={}))ht.call(t,e)&&q(r,e,t[e]);if(L)for(var e of L(t))ft.call(t,e)&&q(r,e,t[e]);return r},R=(r,t)=>ct(r,ut(t));let B=!1;const D=[],dt=r=>new Promise((t,e)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}B?o():D.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const n=document.createElement("script");n.async=!0,n.src=r,n.id="storyblok-javascript-bridge",n.onerror=o=>e(o),n.onload=o=>{D.forEach(s=>s()),B=!0,t(o)},document.getElementsByTagName("head")[0].appendChild(n)}),pt=function(r,t){if(!r)return null;let e={};for(let n in r){let o=r[n];t.indexOf(n)>-1&&o!==null&&(e[n]=o)}return e},gt=r=>r==="email";var z={nodes:{horizontal_rule(){return{singleTag:"hr"}},blockquote(){return{tag:"blockquote"}},bullet_list(){return{tag:"ul"}},code_block(r){return{tag:["pre",{tag:"code",attrs:r.attrs}]}},hard_break(){return{singleTag:"br"}},heading(r){return{tag:`h${r.attrs.level}`}},image(r){return{singleTag:[{tag:"img",attrs:pt(r.attrs,["src","alt","title"])}]}},list_item(){return{tag:"li"}},ordered_list(){return{tag:"ol"}},paragraph(){return{tag:"p"}}},marks:{bold(){return{tag:"b"}},strike(){return{tag:"strike"}},underline(){return{tag:"u"}},strong(){return{tag:"strong"}},code(){return{tag:"code"}},italic(){return{tag:"i"}},link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return gt(e)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled(r){return{tag:[{tag:"span",attrs:r.attrs}]}}}};const mt=function(r){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},e=/[&<>"']/g,n=RegExp(e.source);return r&&n.test(r)?r.replace(e,o=>t[o]):r};class U{constructor(t){t||(t=z),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(o=>{const s=this.getMatchingMark(o);s&&e.push(this.renderOpeningTag(s.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(o=>{e.push(this.renderNode(o))}):t.text?e.push(mt(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(o=>{const s=this.getMatchingMark(o);s&&e.push(this.renderClosingTag(s.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(o=>{if(o.constructor===String)return`<${o}${e}>`;{let s=`<${o.tag}`;if(o.attrs)for(let a in o.attrs){let i=o.attrs[a];i!==null&&(s+=` ${a}="${i}"`)}return`${s}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(n=>n.constructor===String?`</${n}>`:`</${n.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}/*!
1
+ (function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h.storyblokSvelte={},h.e))})(this,function(h,m){"use strict";const ct=(r=>r&&typeof r=="object"&&"default"in r?r:{default:r})(m);var ut=Object.defineProperty,ht=Object.defineProperties,ft=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,D=(r,t,e)=>t in r?ut(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d=(r,t)=>{for(var e in t||(t={}))dt.call(t,e)&&D(r,e,t[e]);if(B)for(var e of B(t))pt.call(t,e)&&D(r,e,t[e]);return r},E=(r,t)=>ht(r,ft(t));let z=!1;const U=[],gt=r=>new Promise((t,e)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}z?s():U.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const n=document.createElement("script");n.async=!0,n.src=r,n.id="storyblok-javascript-bridge",n.onerror=s=>e(s),n.onload=s=>{U.forEach(o=>o()),z=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(n)}),mt=function(r,t){if(!r)return null;let e={};for(let n in r){let s=r[n];t.indexOf(n)>-1&&s!==null&&(e[n]=s)}return e},yt=r=>r==="email";var H={nodes:{horizontal_rule(){return{singleTag:"hr"}},blockquote(){return{tag:"blockquote"}},bullet_list(){return{tag:"ul"}},code_block(r){return{tag:["pre",{tag:"code",attrs:r.attrs}]}},hard_break(){return{singleTag:"br"}},heading(r){return{tag:`h${r.attrs.level}`}},image(r){return{singleTag:[{tag:"img",attrs:mt(r.attrs,["src","alt","title"])}]}},list_item(){return{tag:"li"}},ordered_list(){return{tag:"ol"}},paragraph(){return{tag:"p"}}},marks:{bold(){return{tag:"b"}},strike(){return{tag:"strike"}},underline(){return{tag:"u"}},strong(){return{tag:"strong"}},code(){return{tag:"code"}},italic(){return{tag:"i"}},link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return yt(e)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled(r){return{tag:[{tag:"span",attrs:r.attrs}]}}}};const kt=function(r){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},e=/[&<>"']/g,n=RegExp(e.source);return r&&n.test(r)?r.replace(e,s=>t[s]):r};class V{constructor(t){t||(t=H),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderOpeningTag(o.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(kt(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(s=>{if(s.constructor===String)return`<${s}${e}>`;{let o=`<${s.tag}`;if(s.attrs)for(let a in s.attrs){let i=s.attrs[a];i!==null&&(o+=` ${a}="${i}"`)}return`${o}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(n=>n.constructor===String?`</${n}>`:`</${n.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}/*!
2
2
  * storyblok-js-client v4.5.2
3
3
  * Universal JavaScript SDK for Storyblok's API
4
4
  * (c) 2020-2022 Stobylok Team
5
- */function H(r){return typeof r=="number"&&r==r&&r!==1/0&&r!==-1/0}function V(r,t,e){if(!H(t))throw new TypeError("Expected `limit` to be a finite number");if(!H(e))throw new TypeError("Expected `interval` to be a finite number");var n=[],o=[],s=0,a=function(){s++;var l=setTimeout(function(){s--,n.length>0&&a(),o=o.filter(function(u){return u!==l})},e);o.indexOf(l)<0&&o.push(l);var c=n.shift();c.resolve(r.apply(c.self,c.args))},i=function(){var l=arguments,c=this;return new Promise(function(u,f){n.push({resolve:u,reject:f,args:l,self:c}),s<t&&a()})};return i.abort=function(){o.forEach(clearTimeout),o=[],n.forEach(function(l){l.reject(new throttle.AbortError)}),n.length=0},i}V.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const yt=function(r,t){if(!r)return null;let e={};for(let n in r){let o=r[n];t.indexOf(n)>-1&&o!==null&&(e[n]=o)}return e};var kt={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:r=>({tag:`h${r.attrs.level}`}),image:r=>({singleTag:[{tag:"img",attrs:yt(r.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return e==="email"&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:r=>({tag:[{tag:"span",attrs:r.attrs}]})}};class _t{constructor(t){t||(t=kt),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(o=>{const s=this.getMatchingMark(o);s&&e.push(this.renderOpeningTag(s.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(o=>{e.push(this.renderNode(o))}):t.text?e.push(function(o){const s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return o&&i.test(o)?o.replace(a,l=>s[l]):o}(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(o=>{const s=this.getMatchingMark(o);s&&e.push(this.renderClosingTag(s.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(n=>{if(n.constructor===String)return`<${n}${e}>`;{let o=`<${n.tag}`;if(n.attrs)for(let s in n.attrs){let a=n.attrs[s];a!==null&&(o+=` ${s}="${a}"`)}return`${o}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}const bt=(r=0,t=r)=>{const e=Math.abs(t-r)||0,n=r<t?1:-1;return((o=0,s)=>[...Array(o)].map(s))(e,(o,s)=>s*n+r)},E=(r,t,e)=>{const n=[];for(const o in r){if(!Object.prototype.hasOwnProperty.call(r,o))continue;const s=r[o],a=e?"":encodeURIComponent(o);let i;i=typeof s=="object"?E(s,t?t+encodeURIComponent("["+a+"]"):a,Array.isArray(s)):(t?t+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(s),n.push(i)}return n.join("&")};let b={},g={};class vt{constructor(t,e){if(!e){let s=t.region?`-${t.region}`:"",a=t.https===!1?"http":"https";e=t.oauthToken===void 0?`${a}://api${s}.storyblok.com/v2`:`${a}://api${s}.storyblok.com/v1`}let n=Object.assign({},t.headers),o=5;t.oauthToken!==void 0&&(n.Authorization=t.oauthToken,o=3),t.rateLimit!==void 0&&(o=t.rateLimit),this.richTextResolver=new _t(t.richTextSchema),typeof t.componentResolver=="function"&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=V(this.throttledRequest,o,1e3),this.accessToken=t.accessToken,this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.client=at.default.create({baseURL:e,timeout:t.timeout||0,headers:n,proxy:t.proxy||!1}),t.responseInterceptor&&this.client.interceptors.response.use(s=>t.responseInterceptor(s)),this.resolveNestedRelations=t.resolveNestedRelations||!0}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let n="";return e.attrs.body.forEach(o=>{n+=t(o.component,o)}),{html:n}})}parseParams(t={}){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=g[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e={}){return((n="")=>n.indexOf("/cdn/")>-1)(t)?this.parseParams(e):e}makeRequest(t,e,n,o){const s=this.factoryParamOptions(t,((a={},i=25,l=1)=>R(d({},a),{per_page:i,page:l}))(e,n,o));return this.cacheResponse(t,s)}get(t,e){let n=`/${t}`;const o=this.factoryParamOptions(n,e);return this.cacheResponse(n,o)}async getAll(t,e={},n){const o=e.per_page||25,s=`/${t}`,a=s.split("/");n=n||a[a.length-1];const i=await this.makeRequest(s,e,o,1),l=i.total?Math.ceil(i.total/o):1;return((c=[],u)=>c.map(u).reduce((f,$)=>[...f,...$],[]))([i,...await(async(c=[],u)=>Promise.all(c.map(u)))(bt(1,l),async c=>this.makeRequest(s,e,o,c+1))],c=>Object.values(c.data[n]))}post(t,e){let n=`/${t}`;return this.throttle("post",n,e)}put(t,e){let n=`/${t}`;return this.throttle("put",n,e)}delete(t,e){let n=`/${t}`;return this.throttle("delete",n,e)}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}setToken(t){this.accessToken=t}getToken(){return this.accessToken}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e){const n=t[e];n&&n.fieldtype=="multilink"&&n.linktype=="story"&&typeof n.id=="string"&&this.links[n.id]?n.story=this._cleanCopy(this.links[n.id]):n&&n.linktype==="story"&&typeof n.uuid=="string"&&this.links[n.uuid]&&(n.story=this._cleanCopy(this.links[n.uuid]))}_insertRelations(t,e,n){if(n.indexOf(t.component+"."+e)>-1){if(typeof t[e]=="string")this.relations[t[e]]&&(t[e]=this._cleanCopy(this.relations[t[e]]));else if(t[e].constructor===Array){let o=[];t[e].forEach(s=>{this.relations[s]&&o.push(this._cleanCopy(this.relations[s]))}),t[e]=o}}}_insertAssetsRelations(t,e){e.forEach(n=>{t.id===n.id&&(t.original=n,t.original.filename=t.filename,t.original.filename=t.original.filename.includes("https://s3.amazonaws.com/")?t.original.filename:t.original.filename.replace("https://","https://s3.amazonaws.com/"),delete t.original.s3_filename)})}iterateTree(t,e){let n=o=>{if(o!=null){if(o.constructor===Array)for(let s=0;s<o.length;s++)n(o[s]);else if(o.constructor===Object){if(o._stopResolving)return;for(let s in o)o.component&&o._uid||o.type==="link"?(this._insertRelations(o,s,e),this._insertLinks(o,s)):"id"in o&&o.fieldtype==="asset"&&this._insertAssetsRelations(o,e),n(o[s])}}};n(t.content)}async resolveLinks(t,e){let n=[];if(t.link_uuids){const o=t.link_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(t.link_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.links;n.forEach(o=>{this.links[o.uuid]=R(d({},o),{_stopResolving:!0})})}async resolveRelations(t,e){let n=[];if(t.rel_uuids){const o=t.rel_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const l=Math.min(o,i+a);s.push(t.rel_uuids.slice(i,l))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:s[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.rels;n.forEach(o=>{this.relations[o.uuid]=R(d({},o),{_stopResolving:!0})})}async resolveStories(t,e){let n=[];if(e.resolve_relations!==void 0&&e.resolve_relations.length>0&&(t.rels||t.rel_uuids)&&(n=e.resolve_relations.split(","),await this.resolveRelations(t,e)),["1","story","url"].indexOf(e.resolve_links)>-1&&(t.links||t.link_uuids)&&await this.resolveLinks(t,e),this.resolveNestedRelations)for(const o in this.relations)this.iterateTree(this.relations[o],n);t.story?this.iterateTree(t.story,n):t.stories.forEach(o=>{this.iterateTree(o,n)})}resolveAssetsRelations(t){const{assets:e,stories:n,story:o}=t;if(n)for(const s of n)this.iterateTree(s,e);else{if(!o)return t;this.iterateTree(o,e)}}cacheResponse(t,e,n){return n===void 0&&(n=0),new Promise(async(o,s)=>{let a=E({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const c=await i.get(a);if(c)return o(c)}try{let c=await this.throttle("get",t,{params:e,paramsSerializer:f=>E(f)}),u={data:c.data,headers:c.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),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)return s(c);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,e),e.version==="published"&&t!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(e.version=="draft"&&g[e.token]!=u.data.cv&&this.flushCache(),g[e.token]=u.data.cv),o(u)}catch(c){if(c.response&&c.response.status===429&&(n+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${n} seconds.`),await(l=1e3*n,new Promise(u=>setTimeout(u,l))),this.cacheResponse(t,e,n).then(o).catch(s);s(c)}var l})}throttledRequest(t,e,n){return this.client[t](e,n)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(t){this.accessToken&&(g[this.accessToken]=t)}cacheProvider(){return this.cache.type==="memory"?{get:t=>b[t],getAll:()=>b,set(t,e){b[t]=e},flush(){b={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const wt=(r={})=>{const{apiOptions:t}=r;if(!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 vt(t)}};var Tt=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};const t=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let S;const $t="https://app.storyblok.com/f/storyblok-v2-latest.js",Rt=(r,t,e={})=>{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(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],o=>{o.action==="input"&&o.story.id===r?t(o.story):(o.action==="change"||o.action==="published")&&o.storyId===r&&window.location.reload()})})}},Et=(r={})=>{const{bridge:t,accessToken:e,use:n=[],apiOptions:o={},richText:s={}}=r;o.accessToken=o.accessToken||e;const a={bridge:t,apiOptions:o};let i={};return n.forEach(l=>{i=d(d({},i),l(a))}),t!==!1&&dt($t),S=new U(s.schema),s.resolver&&J(S,s.resolver),i},J=(r,t)=>{r.addNode("blok",e=>{let n="";return e.attrs.body.forEach(o=>{n+=t(o.component,o)}),{html:n}})},St=(r,t,e)=>{let n=e||S;if(!n){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return r===""?"":r?(t&&(n=new U(t.schema),t.resolver&&J(n,t.resolver)),n.render(r)):(console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
5
+ */function J(r){return typeof r=="number"&&r==r&&r!==1/0&&r!==-1/0}function Y(r,t,e){if(!J(t))throw new TypeError("Expected `limit` to be a finite number");if(!J(e))throw new TypeError("Expected `interval` to be a finite number");var n=[],s=[],o=0,a=function(){o++;var l=setTimeout(function(){o--,n.length>0&&a(),s=s.filter(function(u){return u!==l})},e);s.indexOf(l)<0&&s.push(l);var c=n.shift();c.resolve(r.apply(c.self,c.args))},i=function(){var l=arguments,c=this;return new Promise(function(u,f){n.push({resolve:u,reject:f,args:l,self:c}),o<t&&a()})};return i.abort=function(){s.forEach(clearTimeout),s=[],n.forEach(function(l){l.reject(new throttle.AbortError)}),n.length=0},i}Y.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const _t=function(r,t){if(!r)return null;let e={};for(let n in r){let s=r[n];t.indexOf(n)>-1&&s!==null&&(e[n]=s)}return e};var bt={nodes:{horizontal_rule:()=>({singleTag:"hr"}),blockquote:()=>({tag:"blockquote"}),bullet_list:()=>({tag:"ul"}),code_block:r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),hard_break:()=>({singleTag:"br"}),heading:r=>({tag:`h${r.attrs.level}`}),image:r=>({singleTag:[{tag:"img",attrs:_t(r.attrs,["src","alt","title"])}]}),list_item:()=>({tag:"li"}),ordered_list:()=>({tag:"ol"}),paragraph:()=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(r){const t=d({},r.attrs),{linktype:e="url"}=r.attrs;return e==="email"&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:r=>({tag:[{tag:"span",attrs:r.attrs}]})}};class vt{constructor(t){t||(t=bt),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t={}){if(t.content&&Array.isArray(t.content)){let e="";return t.content.forEach(n=>{e+=this.renderNode(n)}),e}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(t){let e=[];t.marks&&t.marks.forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderOpeningTag(o.tag))});const n=this.getMatchingNode(t);return n&&n.tag&&e.push(this.renderOpeningTag(n.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(function(s){const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return s&&i.test(s)?s.replace(a,l=>o[l]):s}(t.text)):n&&n.singleTag?e.push(this.renderTag(n.singleTag," /")):n&&n.html&&e.push(n.html),n&&n.tag&&e.push(this.renderClosingTag(n.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const o=this.getMatchingMark(s);o&&e.push(this.renderClosingTag(o.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(n=>{if(n.constructor===String)return`<${n}${e}>`;{let s=`<${n.tag}`;if(n.attrs)for(let o in n.attrs){let a=n.attrs[o];a!==null&&(s+=` ${o}="${a}"`)}return`${s}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){if(typeof this.nodes[t.type]=="function")return this.nodes[t.type](t)}getMatchingMark(t){if(typeof this.marks[t.type]=="function")return this.marks[t.type](t)}}const $t=(r=0,t=r)=>{const e=Math.abs(t-r)||0,n=r<t?1:-1;return((s=0,o)=>[...Array(s)].map(o))(e,(s,o)=>o*n+r)},S=(r,t,e)=>{const n=[];for(const s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;const o=r[s],a=e?"":encodeURIComponent(s);let i;i=typeof o=="object"?S(o,t?t+encodeURIComponent("["+a+"]"):a,Array.isArray(o)):(t?t+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(o),n.push(i)}return n.join("&")};let b={},g={};class wt{constructor(t,e){if(!e){let o=t.region?`-${t.region}`:"",a=t.https===!1?"http":"https";e=t.oauthToken===void 0?`${a}://api${o}.storyblok.com/v2`:`${a}://api${o}.storyblok.com/v1`}let n=Object.assign({},t.headers),s=5;t.oauthToken!==void 0&&(n.Authorization=t.oauthToken,s=3),t.rateLimit!==void 0&&(s=t.rateLimit),this.richTextResolver=new vt(t.richTextSchema),typeof t.componentResolver=="function"&&this.setComponentResolver(t.componentResolver),this.maxRetries=t.maxRetries||5,this.throttle=Y(this.throttledRequest,s,1e3),this.accessToken=t.accessToken,this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.client=ct.default.create({baseURL:e,timeout:t.timeout||0,headers:n,proxy:t.proxy||!1}),t.responseInterceptor&&this.client.interceptors.response.use(o=>t.responseInterceptor(o)),this.resolveNestedRelations=t.resolveNestedRelations||!0}setComponentResolver(t){this.richTextResolver.addNode("blok",e=>{let n="";return e.attrs.body.forEach(s=>{n+=t(s.component,s)}),{html:n}})}parseParams(t={}){return t.version||(t.version="published"),t.token||(t.token=this.getToken()),t.cv||(t.cv=g[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),t}factoryParamOptions(t,e={}){return((n="")=>n.indexOf("/cdn/")>-1)(t)?this.parseParams(e):e}makeRequest(t,e,n,s){const o=this.factoryParamOptions(t,((a={},i=25,l=1)=>E(d({},a),{per_page:i,page:l}))(e,n,s));return this.cacheResponse(t,o)}get(t,e){let n=`/${t}`;const s=this.factoryParamOptions(n,e);return this.cacheResponse(n,s)}async getAll(t,e={},n){const s=e.per_page||25,o=`/${t}`,a=o.split("/");n=n||a[a.length-1];const i=await this.makeRequest(o,e,s,1),l=i.total?Math.ceil(i.total/s):1;return((c=[],u)=>c.map(u).reduce((f,R)=>[...f,...R],[]))([i,...await(async(c=[],u)=>Promise.all(c.map(u)))($t(1,l),async c=>this.makeRequest(o,e,s,c+1))],c=>Object.values(c.data[n]))}post(t,e){let n=`/${t}`;return this.throttle("post",n,e)}put(t,e){let n=`/${t}`;return this.throttle("put",n,e)}delete(t,e){let n=`/${t}`;return this.throttle("delete",n,e)}getStories(t){return this.get("cdn/stories",t)}getStory(t,e){return this.get(`cdn/stories/${t}`,e)}setToken(t){this.accessToken=t}getToken(){return this.accessToken}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e){const n=t[e];n&&n.fieldtype=="multilink"&&n.linktype=="story"&&typeof n.id=="string"&&this.links[n.id]?n.story=this._cleanCopy(this.links[n.id]):n&&n.linktype==="story"&&typeof n.uuid=="string"&&this.links[n.uuid]&&(n.story=this._cleanCopy(this.links[n.uuid]))}_insertRelations(t,e,n){if(n.indexOf(t.component+"."+e)>-1){if(typeof t[e]=="string")this.relations[t[e]]&&(t[e]=this._cleanCopy(this.relations[t[e]]));else if(t[e].constructor===Array){let s=[];t[e].forEach(o=>{this.relations[o]&&s.push(this._cleanCopy(this.relations[o]))}),t[e]=s}}}_insertAssetsRelations(t,e){e.forEach(n=>{t.id===n.id&&(t.original=n,t.original.filename=t.filename,t.original.filename=t.original.filename.includes("https://s3.amazonaws.com/")?t.original.filename:t.original.filename.replace("https://","https://s3.amazonaws.com/"),delete t.original.s3_filename)})}iterateTree(t,e){let n=s=>{if(s!=null){if(s.constructor===Array)for(let o=0;o<s.length;o++)n(s[o]);else if(s.constructor===Object){if(s._stopResolving)return;for(let o in s)s.component&&s._uid||s.type==="link"?(this._insertRelations(s,o,e),this._insertLinks(s,o)):"id"in s&&s.fieldtype==="asset"&&this._insertAssetsRelations(s,e),n(s[o])}}};n(t.content)}async resolveLinks(t,e){let n=[];if(t.link_uuids){const s=t.link_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const l=Math.min(s,i+a);o.push(t.link_uuids.slice(i,l))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:o[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.links;n.forEach(s=>{this.links[s.uuid]=E(d({},s),{_stopResolving:!0})})}async resolveRelations(t,e){let n=[];if(t.rel_uuids){const s=t.rel_uuids.length;let o=[];const a=50;for(let i=0;i<s;i+=a){const l=Math.min(s,i+a);o.push(t.rel_uuids.slice(i,l))}for(let i=0;i<o.length;i++)(await this.getStories({per_page:a,language:e.language,version:e.version,by_uuids:o[i].join(",")})).data.stories.forEach(l=>{n.push(l)})}else n=t.rels;n.forEach(s=>{this.relations[s.uuid]=E(d({},s),{_stopResolving:!0})})}async resolveStories(t,e){let n=[];if(e.resolve_relations!==void 0&&e.resolve_relations.length>0&&(t.rels||t.rel_uuids)&&(n=e.resolve_relations.split(","),await this.resolveRelations(t,e)),["1","story","url"].indexOf(e.resolve_links)>-1&&(t.links||t.link_uuids)&&await this.resolveLinks(t,e),this.resolveNestedRelations)for(const s in this.relations)this.iterateTree(this.relations[s],n);t.story?this.iterateTree(t.story,n):t.stories.forEach(s=>{this.iterateTree(s,n)})}resolveAssetsRelations(t){const{assets:e,stories:n,story:s}=t;if(n)for(const o of n)this.iterateTree(o,e);else{if(!s)return t;this.iterateTree(s,e)}}cacheResponse(t,e,n){return n===void 0&&(n=0),new Promise(async(s,o)=>{let a=S({url:t,params:e}),i=this.cacheProvider();if(this.cache.clear==="auto"&&e.version==="draft"&&await this.flushCache(),e.version==="published"&&t!="/cdn/spaces/me"){const c=await i.get(a);if(c)return s(c)}try{let c=await this.throttle("get",t,{params:e,paramsSerializer:f=>S(f)}),u={data:c.data,headers:c.headers};if(u.data.assets&&u.data.assets.length&&this.resolveAssetsRelations(u.data),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)return o(c);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,e),e.version==="published"&&t!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(e.version=="draft"&&g[e.token]!=u.data.cv&&this.flushCache(),g[e.token]=u.data.cv),s(u)}catch(c){if(c.response&&c.response.status===429&&(n+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${n} seconds.`),await(l=1e3*n,new Promise(u=>setTimeout(u,l))),this.cacheResponse(t,e,n).then(s).catch(o);o(c)}var l})}throttledRequest(t,e,n){return this.client[t](e,n)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(t){this.accessToken&&(g[this.accessToken]=t)}cacheProvider(){return this.cache.type==="memory"?{get:t=>b[t],getAll:()=>b,set(t,e){b[t]=e},flush(){b={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}const Tt=(r={})=>{const{apiOptions:t}=r;if(!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 wt(t)}};var Rt=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};const t=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}};let x;const Et="https://app.storyblok.com/f/storyblok-v2-latest.js",St=(r,t,e={})=>{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(!r){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],s=>{s.action==="input"&&s.story.id===r?t(s.story):(s.action==="change"||s.action==="published")&&s.storyId===r&&window.location.reload()})})}},xt=(r={})=>{const{bridge:t,accessToken:e,use:n=[],apiOptions:s={},richText:o={}}=r;s.accessToken=s.accessToken||e;const a={bridge:t,apiOptions:s};let i={};return n.forEach(l=>{i=d(d({},i),l(a))}),t!==!1&&gt(Et),x=new V(o.schema),o.resolver&&F(x,o.resolver),i},F=(r,t)=>{r.addNode("blok",e=>{let n="";return e.attrs.body.forEach(s=>{n+=t(s.component,s)}),{html:n}})},Ot=(r,t,e)=>{let n=e||x;if(!n){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return r===""?"":r?(t&&(n=new V(t.schema),t.resolver&&F(n,t.resolver)),n.render(r)):(console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
6
6
 
7
- For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")};function Y(){}function x(r,t){for(const e in t)r[e]=t[e];return r}function F(r){return r()}function K(){return Object.create(null)}function y(r){r.forEach(F)}function xt(r){return typeof r=="function"}function Ot(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function jt(r){return Object.keys(r).length===0}function Pt(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function G(r,t){const e={};t=new Set(t);for(const n in r)!t.has(n)&&n[0]!=="$"&&(e[n]=r[n]);return e}function At(r,t,e){r.insertBefore(t,e||null)}function Q(r){r.parentNode.removeChild(r)}function Ct(r){return document.createTextNode(r)}function Mt(){return Ct("")}function Nt(r){return Array.from(r.childNodes)}let O;function k(r){O=r}const _=[],W=[],v=[],X=[],It=Promise.resolve();let j=!1;function Lt(){j||(j=!0,It.then(Z))}function P(r){v.push(r)}const A=new Set;let w=0;function Z(){const r=O;do{for(;w<_.length;){const t=_[w];w++,k(t),qt(t.$$)}for(k(null),_.length=0,w=0;W.length;)W.pop()();for(let t=0;t<v.length;t+=1){const e=v[t];A.has(e)||(A.add(e),e())}v.length=0}while(_.length);for(;X.length;)X.pop()();j=!1,A.clear(),k(r)}function qt(r){if(r.fragment!==null){r.update(),y(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(P)}}const T=new Set;let p;function Bt(){p={r:0,c:[],p}}function Dt(){p.r||y(p.c),p=p.p}function C(r,t){r&&r.i&&(T.delete(r),r.i(t))}function tt(r,t,e,n){if(r&&r.o){if(T.has(r))return;T.add(r),p.c.push(()=>{T.delete(r),n&&(e&&r.d(1),n())}),r.o(t)}else n&&n()}function zt(r,t){const e={},n={},o={$$scope:1};let s=r.length;for(;s--;){const a=r[s],i=t[s];if(i){for(const l in a)l in i||(n[l]=1);for(const l in i)o[l]||(e[l]=i[l],o[l]=1);r[s]=i}else for(const l in a)o[l]=1}for(const a in n)a in e||(e[a]=void 0);return e}function Ut(r){return typeof r=="object"&&r!==null?r:{}}function et(r){r&&r.c()}function M(r,t,e,n){const{fragment:o,on_mount:s,on_destroy:a,after_update:i}=r.$$;o&&o.m(t,e),n||P(()=>{const l=s.map(F).filter(xt);a?a.push(...l):y(l),r.$$.on_mount=[]}),i.forEach(P)}function N(r,t){const e=r.$$;e.fragment!==null&&(y(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Ht(r,t){r.$$.dirty[0]===-1&&(_.push(r),Lt(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function Vt(r,t,e,n,o,s,a,i=[-1]){const l=O;k(r);const c=r.$$={fragment:null,ctx:null,props:s,update:Y,not_equal:o,bound:K(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:K(),dirty:i,skip_bound:!1,root:t.target||l.$$.root};a&&a(c.root);let u=!1;if(c.ctx=e?e(r,t.props||{},(f,$,...st)=>{const it=st.length?st[0]:$;return c.ctx&&o(c.ctx[f],c.ctx[f]=it)&&(!c.skip_bound&&c.bound[f]&&c.bound[f](it),u&&Ht(r,f)),$}):[],c.update(),u=!0,y(c.before_update),c.fragment=n?n(c.ctx):!1,t.target){if(t.hydrate){const f=Nt(t.target);c.fragment&&c.fragment.l(f),f.forEach(Q)}else c.fragment&&c.fragment.c();t.intro&&C(r.$$.fragment),M(r,t.target,t.anchor,t.customElement),Z()}k(l)}class Jt{$destroy(){N(this,1),this.$destroy=Y}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const o=n.indexOf(e);o!==-1&&n.splice(o,1)}}$set(t){this.$$set&&!jt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Yt(r){let t,e,n;const o=[{blok:r[0]},r[2]];var s=r[1];function a(i){let l={};for(let c=0;c<o.length;c+=1)l=x(l,o[c]);return{props:l}}return s&&(t=new s(a())),{c(){t&&et(t.$$.fragment),e=Mt()},m(i,l){t&&M(t,i,l),At(i,e,l),n=!0},p(i,[l]){const c=l&5?zt(o,[l&1&&{blok:i[0]},l&4&&Ut(i[2])]):{};if(s!==(s=i[1])){if(t){Bt();const u=t;tt(u.$$.fragment,1,0,()=>{N(u,1)}),Dt()}s?(t=new s(a()),et(t.$$.fragment),C(t.$$.fragment,1),M(t,e.parentNode,e)):t=null}else s&&t.$set(c)},i(i){n||(t&&C(t.$$.fragment,i),n=!0)},o(i){t&&tt(t.$$.fragment,i),n=!1},d(i){i&&Q(e),t&&N(t,i)}}}function Ft(r,t,e){const n=["blok"];let o=G(t,n),s,{blok:a}=t;return a?s=ot(a.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),r.$$set=i=>{t=x(x({},t),Pt(i)),e(2,o=G(t,n)),"blok"in i&&e(0,a=i.blok)},[a,s,o]}class Kt extends Jt{constructor(t){super(),Vt(this,t,Ft,Yt,Ot,{blok:0})}}const Gt=(r,t)=>{const e=n=>{const o=Tt(n);o["data-blok-c"]&&(r.setAttribute("data-blok-c",o["data-blok-c"]),r.setAttribute("data-blok-uid",o["data-blok-uid"]),r.classList.add("storyblok__outline"))};return e(t),{update(n){e(n)}}};let I=null;const rt=()=>(I||console.log("You can't use getStoryblokApi if you're not loading apiPlugin."),I);let nt=null;const Qt=r=>{const{storyblokApi:t}=Et(r);I=t,nt=r.components||{}},ot=r=>{const t=nt[r];return t||console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
7
+ For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")};function O(){}function j(r,t){for(const e in t)r[e]=t[e];return r}function K(r){return r()}function G(){return Object.create(null)}function y(r){r.forEach(K)}function Q(r){return typeof r=="function"}function jt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Pt(r){return Object.keys(r).length===0}function At(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function W(r,t){const e={};t=new Set(t);for(const n in r)!t.has(n)&&n[0]!=="$"&&(e[n]=r[n]);return e}function Ct(r,t,e){r.insertBefore(t,e||null)}function X(r){r.parentNode.removeChild(r)}function Mt(r){return document.createTextNode(r)}function Nt(){return Mt("")}function It(r){return Array.from(r.childNodes)}function Z(r,t){return new r(t)}let P;function k(r){P=r}const _=[],tt=[],v=[],et=[],Lt=Promise.resolve();let A=!1;function qt(){A||(A=!0,Lt.then(rt))}function C(r){v.push(r)}const M=new Set;let $=0;function rt(){const r=P;do{for(;$<_.length;){const t=_[$];$++,k(t),Bt(t.$$)}for(k(null),_.length=0,$=0;tt.length;)tt.pop()();for(let t=0;t<v.length;t+=1){const e=v[t];M.has(e)||(M.add(e),e())}v.length=0}while(_.length);for(;et.length;)et.pop()();A=!1,M.clear(),k(r)}function Bt(r){if(r.fragment!==null){r.update(),y(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(C)}}const w=new Set;let p;function Dt(){p={r:0,c:[],p}}function zt(){p.r||y(p.c),p=p.p}function N(r,t){r&&r.i&&(w.delete(r),r.i(t))}function nt(r,t,e,n){if(r&&r.o){if(w.has(r))return;w.add(r),p.c.push(()=>{w.delete(r),n&&(e&&r.d(1),n())}),r.o(t)}else n&&n()}function Ut(r,t){const e={},n={},s={$$scope:1};let o=r.length;for(;o--;){const a=r[o],i=t[o];if(i){for(const l in a)l in i||(n[l]=1);for(const l in i)s[l]||(e[l]=i[l],s[l]=1);r[o]=i}else for(const l in a)s[l]=1}for(const a in n)a in e||(e[a]=void 0);return e}function Ht(r){return typeof r=="object"&&r!==null?r:{}}function st(r){r&&r.c()}function I(r,t,e,n){const{fragment:s,after_update:o}=r.$$;s&&s.m(t,e),n||C(()=>{const a=r.$$.on_mount.map(K).filter(Q);r.$$.on_destroy?r.$$.on_destroy.push(...a):y(a),r.$$.on_mount=[]}),o.forEach(C)}function L(r,t){const e=r.$$;e.fragment!==null&&(y(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Vt(r,t){r.$$.dirty[0]===-1&&(_.push(r),qt(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function Jt(r,t,e,n,s,o,a,i=[-1]){const l=P;k(r);const c=r.$$={fragment:null,ctx:[],props:o,update:O,not_equal:s,bound:G(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:G(),dirty:i,skip_bound:!1,root:t.target||l.$$.root};a&&a(c.root);let u=!1;if(c.ctx=e?e(r,t.props||{},(f,R,...at)=>{const lt=at.length?at[0]:R;return c.ctx&&s(c.ctx[f],c.ctx[f]=lt)&&(!c.skip_bound&&c.bound[f]&&c.bound[f](lt),u&&Vt(r,f)),R}):[],c.update(),u=!0,y(c.before_update),c.fragment=n?n(c.ctx):!1,t.target){if(t.hydrate){const f=It(t.target);c.fragment&&c.fragment.l(f),f.forEach(X)}else c.fragment&&c.fragment.c();t.intro&&N(r.$$.fragment),I(r,t.target,t.anchor,t.customElement),rt()}k(l)}class Yt{$destroy(){L(this,1),this.$destroy=O}$on(t,e){if(!Q(e))return O;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}$set(t){this.$$set&&!Pt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Ft(r){let t,e,n;const s=[{blok:r[0]},r[2]];var o=r[1];function a(i){let l={};for(let c=0;c<s.length;c+=1)l=j(l,s[c]);return{props:l}}return o&&(t=Z(o,a())),{c(){t&&st(t.$$.fragment),e=Nt()},m(i,l){t&&I(t,i,l),Ct(i,e,l),n=!0},p(i,[l]){const c=l&5?Ut(s,[l&1&&{blok:i[0]},l&4&&Ht(i[2])]):{};if(o!==(o=i[1])){if(t){Dt();const u=t;nt(u.$$.fragment,1,0,()=>{L(u,1)}),zt()}o?(t=Z(o,a()),st(t.$$.fragment),N(t.$$.fragment,1),I(t,e.parentNode,e)):t=null}else o&&t.$set(c)},i(i){n||(t&&N(t.$$.fragment,i),n=!0)},o(i){t&&nt(t.$$.fragment,i),n=!1},d(i){i&&X(e),t&&L(t,i)}}}function Kt(r,t,e){const n=["blok"];let s=W(t,n),o,{blok:a}=t;return a?o=it(a.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),r.$$set=i=>{t=j(j({},t),At(i)),e(2,s=W(t,n)),"blok"in i&&e(0,a=i.blok)},[a,o,s]}class Gt extends Yt{constructor(t){super(),Jt(this,t,Kt,Ft,jt,{blok:0})}}const Qt=(r,t)=>{const e=n=>{const s=Rt(n);s["data-blok-c"]&&(r.setAttribute("data-blok-c",s["data-blok-c"]),r.setAttribute("data-blok-uid",s["data-blok-uid"]),r.classList.add("storyblok__outline"))};return e(t),{update(n){e(n)}}};let q=null;const ot=()=>(q||console.log("You can't use getStoryblokApi if you're not loading apiPlugin."),q);let T=null;const Wt=r=>{const{storyblokApi:t}=xt(r);q=t,T=r.components||{}},it=r=>{let t=null;return t=typeof T=="function"?T()[r]:T[r],t||console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
8
8
  storyblokInit({
9
9
  accessToken: "<your-token>",
10
10
  components: {
11
11
  "teaser": Teaser
12
12
  }
13
13
  })
14
- `),t};h.RichTextSchema=z,h.StoryblokComponent=Kt,h.apiPlugin=wt,h.getComponent=ot,h.getStoryblokApi=rt,h.renderRichText=St,h.storyblokEditable=Gt,h.storyblokInit=Qt,h.useStoryblokApi=rt,h.useStoryblokBridge=Rt,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
14
+ `),t};h.RichTextSchema=H,h.StoryblokComponent=Gt,h.apiPlugin=Tt,h.getComponent=it,h.getStoryblokApi=ot,h.renderRichText=Ot,h.storyblokEditable=Qt,h.storyblokInit=Wt,h.useStoryblokApi=ot,h.useStoryblokBridge=St,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,27 +1,27 @@
1
- import rt from "axios";
2
- var nt = Object.defineProperty, st = Object.defineProperties, ot = Object.getOwnPropertyDescriptors, q = Object.getOwnPropertySymbols, it = Object.prototype.hasOwnProperty, at = Object.prototype.propertyIsEnumerable, L = (r, t, e) => t in r ? nt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, d = (r, t) => {
1
+ import st from "axios";
2
+ var ot = Object.defineProperty, it = Object.defineProperties, at = Object.getOwnPropertyDescriptors, B = Object.getOwnPropertySymbols, lt = Object.prototype.hasOwnProperty, ct = Object.prototype.propertyIsEnumerable, z = (r, t, e) => t in r ? ot(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, d = (r, t) => {
3
3
  for (var e in t || (t = {}))
4
- it.call(t, e) && L(r, e, t[e]);
5
- if (q)
6
- for (var e of q(t))
7
- at.call(t, e) && L(r, e, t[e]);
4
+ lt.call(t, e) && z(r, e, t[e]);
5
+ if (B)
6
+ for (var e of B(t))
7
+ ct.call(t, e) && z(r, e, t[e]);
8
8
  return r;
9
- }, $ = (r, t) => st(r, ot(t));
10
- let B = !1;
11
- const z = [], lt = (r) => new Promise((t, e) => {
9
+ }, T = (r, t) => it(r, at(t));
10
+ let D = !1;
11
+ const U = [], ut = (r) => new Promise((t, e) => {
12
12
  if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
13
13
  if (window.location === window.parent.location) {
14
14
  console.warn("You are not in Draft Mode or in the Visual Editor.");
15
15
  return;
16
16
  }
17
- B ? s() : z.push(s);
17
+ D ? s() : U.push(s);
18
18
  }, document.getElementById("storyblok-javascript-bridge")))
19
19
  return;
20
20
  const n = document.createElement("script");
21
21
  n.async = !0, n.src = r, n.id = "storyblok-javascript-bridge", n.onerror = (s) => e(s), n.onload = (s) => {
22
- z.forEach((o) => o()), B = !0, t(s);
22
+ U.forEach((o) => o()), D = !0, t(s);
23
23
  }, document.getElementsByTagName("head")[0].appendChild(n);
24
- }), ct = function(r, t) {
24
+ }), ht = function(r, t) {
25
25
  if (!r)
26
26
  return null;
27
27
  let e = {};
@@ -30,8 +30,8 @@ const z = [], lt = (r) => new Promise((t, e) => {
30
30
  t.indexOf(n) > -1 && s !== null && (e[n] = s);
31
31
  }
32
32
  return e;
33
- }, ut = (r) => r === "email";
34
- var ht = {
33
+ }, ft = (r) => r === "email";
34
+ var dt = {
35
35
  nodes: {
36
36
  horizontal_rule() {
37
37
  return {
@@ -74,7 +74,7 @@ var ht = {
74
74
  singleTag: [
75
75
  {
76
76
  tag: "img",
77
- attrs: ct(r.attrs, ["src", "alt", "title"])
77
+ attrs: ht(r.attrs, ["src", "alt", "title"])
78
78
  }
79
79
  ]
80
80
  };
@@ -128,7 +128,7 @@ var ht = {
128
128
  },
129
129
  link(r) {
130
130
  const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
131
- return ut(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
131
+ return ft(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
132
132
  tag: [
133
133
  {
134
134
  tag: "a",
@@ -149,7 +149,7 @@ var ht = {
149
149
  }
150
150
  }
151
151
  };
152
- const ft = function(r) {
152
+ const pt = function(r) {
153
153
  const t = {
154
154
  "&": "&amp;",
155
155
  "<": "&lt;",
@@ -159,9 +159,9 @@ const ft = function(r) {
159
159
  }, e = /[&<>"']/g, n = RegExp(e.source);
160
160
  return r && n.test(r) ? r.replace(e, (s) => t[s]) : r;
161
161
  };
162
- class K {
162
+ class W {
163
163
  constructor(t) {
164
- t || (t = ht), this.marks = t.marks || [], this.nodes = t.nodes || [];
164
+ t || (t = dt), this.marks = t.marks || [], this.nodes = t.nodes || [];
165
165
  }
166
166
  addNode(t, e) {
167
167
  this.nodes[t] = e;
@@ -187,7 +187,7 @@ class K {
187
187
  const n = this.getMatchingNode(t);
188
188
  return n && n.tag && e.push(this.renderOpeningTag(n.tag)), t.content ? t.content.forEach((s) => {
189
189
  e.push(this.renderNode(s));
190
- }) : t.text ? e.push(ft(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
190
+ }) : t.text ? e.push(pt(t.text)) : n && n.singleTag ? e.push(this.renderTag(n.singleTag, " /")) : n && n.html && e.push(n.html), n && n.tag && e.push(this.renderClosingTag(n.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
191
191
  const o = this.getMatchingMark(s);
192
192
  o && e.push(this.renderClosingTag(o.tag));
193
193
  }), e.join("");
@@ -227,13 +227,13 @@ class K {
227
227
  * Universal JavaScript SDK for Storyblok's API
228
228
  * (c) 2020-2022 Stobylok Team
229
229
  */
230
- function D(r) {
230
+ function H(r) {
231
231
  return typeof r == "number" && r == r && r !== 1 / 0 && r !== -1 / 0;
232
232
  }
233
- function G(r, t, e) {
234
- if (!D(t))
233
+ function X(r, t, e) {
234
+ if (!H(t))
235
235
  throw new TypeError("Expected `limit` to be a finite number");
236
- if (!D(e))
236
+ if (!H(e))
237
237
  throw new TypeError("Expected `interval` to be a finite number");
238
238
  var n = [], s = [], o = 0, a = function() {
239
239
  o++;
@@ -257,10 +257,10 @@ function G(r, t, e) {
257
257
  }), n.length = 0;
258
258
  }, i;
259
259
  }
260
- G.AbortError = function() {
260
+ X.AbortError = function() {
261
261
  Error.call(this, "Throttled function aborted"), this.name = "AbortError";
262
262
  };
263
- const dt = function(r, t) {
263
+ const gt = function(r, t) {
264
264
  if (!r)
265
265
  return null;
266
266
  let e = {};
@@ -270,13 +270,13 @@ const dt = function(r, t) {
270
270
  }
271
271
  return e;
272
272
  };
273
- var pt = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (r) => ({ tag: ["pre", { tag: "code", attrs: r.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (r) => ({ tag: `h${r.attrs.level}` }), image: (r) => ({ singleTag: [{ tag: "img", attrs: dt(r.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(r) {
273
+ var mt = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (r) => ({ tag: ["pre", { tag: "code", attrs: r.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (r) => ({ tag: `h${r.attrs.level}` }), image: (r) => ({ singleTag: [{ tag: "img", attrs: gt(r.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(r) {
274
274
  const t = d({}, r.attrs), { linktype: e = "url" } = r.attrs;
275
275
  return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
276
276
  }, styled: (r) => ({ tag: [{ tag: "span", attrs: r.attrs }] }) } };
277
- class gt {
277
+ class yt {
278
278
  constructor(t) {
279
- t || (t = pt), this.marks = t.marks || [], this.nodes = t.nodes || [];
279
+ t || (t = mt), this.marks = t.marks || [], this.nodes = t.nodes || [];
280
280
  }
281
281
  addNode(t, e) {
282
282
  this.nodes[t] = e;
@@ -340,29 +340,29 @@ class gt {
340
340
  return this.marks[t.type](t);
341
341
  }
342
342
  }
343
- const mt = (r = 0, t = r) => {
343
+ const kt = (r = 0, t = r) => {
344
344
  const e = Math.abs(t - r) || 0, n = r < t ? 1 : -1;
345
345
  return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * n + r);
346
- }, R = (r, t, e) => {
346
+ }, x = (r, t, e) => {
347
347
  const n = [];
348
348
  for (const s in r) {
349
349
  if (!Object.prototype.hasOwnProperty.call(r, s))
350
350
  continue;
351
351
  const o = r[s], a = e ? "" : encodeURIComponent(s);
352
352
  let i;
353
- i = typeof o == "object" ? R(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), n.push(i);
353
+ i = typeof o == "object" ? x(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), n.push(i);
354
354
  }
355
355
  return n.join("&");
356
356
  };
357
357
  let _ = {}, p = {};
358
- class yt {
358
+ class _t {
359
359
  constructor(t, e) {
360
360
  if (!e) {
361
361
  let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
362
362
  e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
363
363
  }
364
364
  let n = Object.assign({}, t.headers), s = 5;
365
- t.oauthToken !== void 0 && (n.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new gt(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = G(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = rt.create({ baseURL: e, timeout: t.timeout || 0, headers: n, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
365
+ t.oauthToken !== void 0 && (n.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new yt(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = X(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = st.create({ baseURL: e, timeout: t.timeout || 0, headers: n, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
366
366
  }
367
367
  setComponentResolver(t) {
368
368
  this.richTextResolver.addNode("blok", (e) => {
@@ -379,7 +379,7 @@ class yt {
379
379
  return ((n = "") => n.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
380
380
  }
381
381
  makeRequest(t, e, n, s) {
382
- const o = this.factoryParamOptions(t, ((a = {}, i = 25, l = 1) => $(d({}, a), { per_page: i, page: l }))(e, n, s));
382
+ const o = this.factoryParamOptions(t, ((a = {}, i = 25, l = 1) => T(d({}, a), { per_page: i, page: l }))(e, n, s));
383
383
  return this.cacheResponse(t, o);
384
384
  }
385
385
  get(t, e) {
@@ -391,7 +391,7 @@ class yt {
391
391
  const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
392
392
  n = n || a[a.length - 1];
393
393
  const i = await this.makeRequest(o, e, s, 1), l = i.total ? Math.ceil(i.total / s) : 1;
394
- return ((c = [], u) => c.map(u).reduce((h, k) => [...h, ...k], []))([i, ...await (async (c = [], u) => Promise.all(c.map(u)))(mt(1, l), async (c) => this.makeRequest(o, e, s, c + 1))], (c) => Object.values(c.data[n]));
394
+ return ((c = [], u) => c.map(u).reduce((h, k) => [...h, ...k], []))([i, ...await (async (c = [], u) => Promise.all(c.map(u)))(kt(1, l), async (c) => this.makeRequest(o, e, s, c + 1))], (c) => Object.values(c.data[n]));
395
395
  }
396
396
  post(t, e) {
397
397
  let n = `/${t}`;
@@ -474,7 +474,7 @@ class yt {
474
474
  } else
475
475
  n = t.links;
476
476
  n.forEach((s) => {
477
- this.links[s.uuid] = $(d({}, s), { _stopResolving: !0 });
477
+ this.links[s.uuid] = T(d({}, s), { _stopResolving: !0 });
478
478
  });
479
479
  }
480
480
  async resolveRelations(t, e) {
@@ -494,7 +494,7 @@ class yt {
494
494
  } else
495
495
  n = t.rels;
496
496
  n.forEach((s) => {
497
- this.relations[s.uuid] = $(d({}, s), { _stopResolving: !0 });
497
+ this.relations[s.uuid] = T(d({}, s), { _stopResolving: !0 });
498
498
  });
499
499
  }
500
500
  async resolveStories(t, e) {
@@ -519,14 +519,14 @@ class yt {
519
519
  }
520
520
  cacheResponse(t, e, n) {
521
521
  return n === void 0 && (n = 0), new Promise(async (s, o) => {
522
- let a = R({ url: t, params: e }), i = this.cacheProvider();
522
+ let a = x({ url: t, params: e }), i = this.cacheProvider();
523
523
  if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
524
524
  const c = await i.get(a);
525
525
  if (c)
526
526
  return s(c);
527
527
  }
528
528
  try {
529
- let c = await this.throttle("get", t, { params: e, paramsSerializer: (h) => R(h) }), u = { data: c.data, headers: c.headers };
529
+ let c = await this.throttle("get", t, { params: e, paramsSerializer: (h) => x(h) }), u = { data: c.data, headers: c.headers };
530
530
  if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), 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)
531
531
  return o(c);
532
532
  (u.data.story || u.data.stories) && await this.resolveStories(u.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, u), u.data.cv && (e.version == "draft" && p[e.token] != u.data.cv && this.flushCache(), p[e.token] = u.data.cv), s(u);
@@ -565,15 +565,15 @@ class yt {
565
565
  return await this.cacheProvider().flush(), this;
566
566
  }
567
567
  }
568
- const Ht = (r = {}) => {
568
+ const Vt = (r = {}) => {
569
569
  const { apiOptions: t } = r;
570
570
  if (!t.accessToken) {
571
571
  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");
572
572
  return;
573
573
  }
574
- return { storyblokApi: new yt(t) };
574
+ return { storyblokApi: new _t(t) };
575
575
  };
576
- var kt = (r) => {
576
+ var bt = (r) => {
577
577
  if (typeof r != "object" || typeof r._editable > "u")
578
578
  return {};
579
579
  const t = JSON.parse(r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
@@ -582,8 +582,8 @@ var kt = (r) => {
582
582
  "data-blok-uid": t.id + "-" + t.uid
583
583
  };
584
584
  };
585
- let x;
586
- const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e = {}) => {
585
+ let E;
586
+ const vt = "https://app.storyblok.com/f/storyblok-v2-latest.js", Jt = (r, t, e = {}) => {
587
587
  if (!(typeof window > "u")) {
588
588
  if (typeof window.storyblokRegisterEvent > "u") {
589
589
  console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
@@ -599,7 +599,7 @@ const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e =
599
599
  });
600
600
  });
601
601
  }
602
- }, bt = (r = {}) => {
602
+ }, $t = (r = {}) => {
603
603
  const {
604
604
  bridge: t,
605
605
  accessToken: e,
@@ -612,8 +612,8 @@ const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e =
612
612
  let i = {};
613
613
  return n.forEach((l) => {
614
614
  i = d(d({}, i), l(a));
615
- }), t !== !1 && lt(_t), x = new K(o.schema), o.resolver && Q(x, o.resolver), i;
616
- }, Q = (r, t) => {
615
+ }), t !== !1 && ut(vt), E = new W(o.schema), o.resolver && Z(E, o.resolver), i;
616
+ }, Z = (r, t) => {
617
617
  r.addNode("blok", (e) => {
618
618
  let n = "";
619
619
  return e.attrs.body.forEach((s) => {
@@ -622,135 +622,138 @@ const _t = "https://app.storyblok.com/f/storyblok-v2-latest.js", Vt = (r, t, e =
622
622
  html: n
623
623
  };
624
624
  });
625
- }, Jt = (r, t, e) => {
626
- let n = e || x;
625
+ }, Yt = (r, t, e) => {
626
+ let n = e || E;
627
627
  if (!n) {
628
628
  console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
629
629
  return;
630
630
  }
631
- return r === "" ? "" : r ? (t && (n = new K(t.schema), t.resolver && Q(n, t.resolver)), n.render(r)) : (console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
631
+ return r === "" ? "" : r ? (t && (n = new W(t.schema), t.resolver && Z(n, t.resolver)), n.render(r)) : (console.warn(`${r} is not a valid Richtext object. This might be because the value of the richtext field is empty.
632
632
 
633
633
  For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
634
634
  };
635
- function W() {
635
+ function O() {
636
636
  }
637
- function E(r, t) {
637
+ function S(r, t) {
638
638
  for (const e in t)
639
639
  r[e] = t[e];
640
640
  return r;
641
641
  }
642
- function X(r) {
642
+ function tt(r) {
643
643
  return r();
644
644
  }
645
- function U() {
645
+ function V() {
646
646
  return /* @__PURE__ */ Object.create(null);
647
647
  }
648
648
  function y(r) {
649
- r.forEach(X);
649
+ r.forEach(tt);
650
650
  }
651
- function vt(r) {
651
+ function et(r) {
652
652
  return typeof r == "function";
653
653
  }
654
654
  function wt(r, t) {
655
655
  return r != r ? t == t : r !== t || r && typeof r == "object" || typeof r == "function";
656
656
  }
657
- function $t(r) {
657
+ function Tt(r) {
658
658
  return Object.keys(r).length === 0;
659
659
  }
660
- function Tt(r) {
660
+ function Rt(r) {
661
661
  const t = {};
662
662
  for (const e in r)
663
663
  e[0] !== "$" && (t[e] = r[e]);
664
664
  return t;
665
665
  }
666
- function H(r, t) {
666
+ function J(r, t) {
667
667
  const e = {};
668
668
  t = new Set(t);
669
669
  for (const n in r)
670
670
  !t.has(n) && n[0] !== "$" && (e[n] = r[n]);
671
671
  return e;
672
672
  }
673
- function Rt(r, t, e) {
673
+ function xt(r, t, e) {
674
674
  r.insertBefore(t, e || null);
675
675
  }
676
- function Z(r) {
676
+ function rt(r) {
677
677
  r.parentNode.removeChild(r);
678
678
  }
679
- function xt(r) {
679
+ function Et(r) {
680
680
  return document.createTextNode(r);
681
681
  }
682
- function Et() {
683
- return xt("");
682
+ function Ot() {
683
+ return Et("");
684
684
  }
685
- function Ot(r) {
685
+ function St(r) {
686
686
  return Array.from(r.childNodes);
687
687
  }
688
- let M;
688
+ function Y(r, t) {
689
+ return new r(t);
690
+ }
691
+ let I;
689
692
  function m(r) {
690
- M = r;
693
+ I = r;
691
694
  }
692
- const g = [], V = [], v = [], J = [], St = Promise.resolve();
693
- let O = !1;
694
- function jt() {
695
- O || (O = !0, St.then(tt));
695
+ const g = [], F = [], v = [], K = [], jt = Promise.resolve();
696
+ let j = !1;
697
+ function Pt() {
698
+ j || (j = !0, jt.then(nt));
696
699
  }
697
- function S(r) {
700
+ function P(r) {
698
701
  v.push(r);
699
702
  }
700
- const T = /* @__PURE__ */ new Set();
703
+ const R = /* @__PURE__ */ new Set();
701
704
  let b = 0;
702
- function tt() {
703
- const r = M;
705
+ function nt() {
706
+ const r = I;
704
707
  do {
705
708
  for (; b < g.length; ) {
706
709
  const t = g[b];
707
- b++, m(t), Pt(t.$$);
710
+ b++, m(t), At(t.$$);
708
711
  }
709
- for (m(null), g.length = 0, b = 0; V.length; )
710
- V.pop()();
712
+ for (m(null), g.length = 0, b = 0; F.length; )
713
+ F.pop()();
711
714
  for (let t = 0; t < v.length; t += 1) {
712
715
  const e = v[t];
713
- T.has(e) || (T.add(e), e());
716
+ R.has(e) || (R.add(e), e());
714
717
  }
715
718
  v.length = 0;
716
719
  } while (g.length);
717
- for (; J.length; )
718
- J.pop()();
719
- O = !1, T.clear(), m(r);
720
+ for (; K.length; )
721
+ K.pop()();
722
+ j = !1, R.clear(), m(r);
720
723
  }
721
- function Pt(r) {
724
+ function At(r) {
722
725
  if (r.fragment !== null) {
723
726
  r.update(), y(r.before_update);
724
727
  const t = r.dirty;
725
- r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(S);
728
+ r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(P);
726
729
  }
727
730
  }
728
- const w = /* @__PURE__ */ new Set();
731
+ const $ = /* @__PURE__ */ new Set();
729
732
  let f;
730
- function At() {
733
+ function Ct() {
731
734
  f = {
732
735
  r: 0,
733
736
  c: [],
734
737
  p: f
735
738
  };
736
739
  }
737
- function Ct() {
740
+ function Mt() {
738
741
  f.r || y(f.c), f = f.p;
739
742
  }
740
- function j(r, t) {
741
- r && r.i && (w.delete(r), r.i(t));
743
+ function A(r, t) {
744
+ r && r.i && ($.delete(r), r.i(t));
742
745
  }
743
- function Y(r, t, e, n) {
746
+ function G(r, t, e, n) {
744
747
  if (r && r.o) {
745
- if (w.has(r))
748
+ if ($.has(r))
746
749
  return;
747
- w.add(r), f.c.push(() => {
748
- w.delete(r), n && (e && r.d(1), n());
750
+ $.add(r), f.c.push(() => {
751
+ $.delete(r), n && (e && r.d(1), n());
749
752
  }), r.o(t);
750
753
  } else
751
754
  n && n();
752
755
  }
753
- function Mt(r, t) {
756
+ function Nt(r, t) {
754
757
  const e = {}, n = {}, s = { $$scope: 1 };
755
758
  let o = r.length;
756
759
  for (; o--; ) {
@@ -769,67 +772,69 @@ function Mt(r, t) {
769
772
  a in e || (e[a] = void 0);
770
773
  return e;
771
774
  }
772
- function Nt(r) {
775
+ function It(r) {
773
776
  return typeof r == "object" && r !== null ? r : {};
774
777
  }
775
- function F(r) {
778
+ function Q(r) {
776
779
  r && r.c();
777
780
  }
778
- function P(r, t, e, n) {
779
- const { fragment: s, on_mount: o, on_destroy: a, after_update: i } = r.$$;
780
- s && s.m(t, e), n || S(() => {
781
- const l = o.map(X).filter(vt);
782
- a ? a.push(...l) : y(l), r.$$.on_mount = [];
783
- }), i.forEach(S);
781
+ function C(r, t, e, n) {
782
+ const { fragment: s, after_update: o } = r.$$;
783
+ s && s.m(t, e), n || P(() => {
784
+ const a = r.$$.on_mount.map(tt).filter(et);
785
+ r.$$.on_destroy ? r.$$.on_destroy.push(...a) : y(a), r.$$.on_mount = [];
786
+ }), o.forEach(P);
784
787
  }
785
- function A(r, t) {
788
+ function M(r, t) {
786
789
  const e = r.$$;
787
790
  e.fragment !== null && (y(e.on_destroy), e.fragment && e.fragment.d(t), e.on_destroy = e.fragment = null, e.ctx = []);
788
791
  }
789
- function It(r, t) {
790
- r.$$.dirty[0] === -1 && (g.push(r), jt(), r.$$.dirty.fill(0)), r.$$.dirty[t / 31 | 0] |= 1 << t % 31;
792
+ function qt(r, t) {
793
+ r.$$.dirty[0] === -1 && (g.push(r), Pt(), r.$$.dirty.fill(0)), r.$$.dirty[t / 31 | 0] |= 1 << t % 31;
791
794
  }
792
- function qt(r, t, e, n, s, o, a, i = [-1]) {
793
- const l = M;
795
+ function Lt(r, t, e, n, s, o, a, i = [-1]) {
796
+ const l = I;
794
797
  m(r);
795
798
  const c = r.$$ = {
796
799
  fragment: null,
797
- ctx: null,
800
+ ctx: [],
798
801
  props: o,
799
- update: W,
802
+ update: O,
800
803
  not_equal: s,
801
- bound: U(),
804
+ bound: V(),
802
805
  on_mount: [],
803
806
  on_destroy: [],
804
807
  on_disconnect: [],
805
808
  before_update: [],
806
809
  after_update: [],
807
810
  context: new Map(t.context || (l ? l.$$.context : [])),
808
- callbacks: U(),
811
+ callbacks: V(),
809
812
  dirty: i,
810
813
  skip_bound: !1,
811
814
  root: t.target || l.$$.root
812
815
  };
813
816
  a && a(c.root);
814
817
  let u = !1;
815
- if (c.ctx = e ? e(r, t.props || {}, (h, k, ...N) => {
816
- const I = N.length ? N[0] : k;
817
- return c.ctx && s(c.ctx[h], c.ctx[h] = I) && (!c.skip_bound && c.bound[h] && c.bound[h](I), u && It(r, h)), k;
818
+ if (c.ctx = e ? e(r, t.props || {}, (h, k, ...q) => {
819
+ const L = q.length ? q[0] : k;
820
+ return c.ctx && s(c.ctx[h], c.ctx[h] = L) && (!c.skip_bound && c.bound[h] && c.bound[h](L), u && qt(r, h)), k;
818
821
  }) : [], c.update(), u = !0, y(c.before_update), c.fragment = n ? n(c.ctx) : !1, t.target) {
819
822
  if (t.hydrate) {
820
- const h = Ot(t.target);
821
- c.fragment && c.fragment.l(h), h.forEach(Z);
823
+ const h = St(t.target);
824
+ c.fragment && c.fragment.l(h), h.forEach(rt);
822
825
  } else
823
826
  c.fragment && c.fragment.c();
824
- t.intro && j(r.$$.fragment), P(r, t.target, t.anchor, t.customElement), tt();
827
+ t.intro && A(r.$$.fragment), C(r, t.target, t.anchor, t.customElement), nt();
825
828
  }
826
829
  m(l);
827
830
  }
828
- class Lt {
831
+ class Bt {
829
832
  $destroy() {
830
- A(this, 1), this.$destroy = W;
833
+ M(this, 1), this.$destroy = O;
831
834
  }
832
835
  $on(t, e) {
836
+ if (!et(e))
837
+ return O;
833
838
  const n = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
834
839
  return n.push(e), () => {
835
840
  const s = n.indexOf(e);
@@ -837,69 +842,69 @@ class Lt {
837
842
  };
838
843
  }
839
844
  $set(t) {
840
- this.$$set && !$t(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
845
+ this.$$set && !Tt(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
841
846
  }
842
847
  }
843
- function Bt(r) {
848
+ function zt(r) {
844
849
  let t, e, n;
845
850
  const s = [{ blok: r[0] }, r[2]];
846
851
  var o = r[1];
847
852
  function a(i) {
848
853
  let l = {};
849
854
  for (let c = 0; c < s.length; c += 1)
850
- l = E(l, s[c]);
855
+ l = S(l, s[c]);
851
856
  return { props: l };
852
857
  }
853
- return o && (t = new o(a())), {
858
+ return o && (t = Y(o, a())), {
854
859
  c() {
855
- t && F(t.$$.fragment), e = Et();
860
+ t && Q(t.$$.fragment), e = Ot();
856
861
  },
857
862
  m(i, l) {
858
- t && P(t, i, l), Rt(i, e, l), n = !0;
863
+ t && C(t, i, l), xt(i, e, l), n = !0;
859
864
  },
860
865
  p(i, [l]) {
861
- const c = l & 5 ? Mt(s, [
866
+ const c = l & 5 ? Nt(s, [
862
867
  l & 1 && { blok: i[0] },
863
- l & 4 && Nt(i[2])
868
+ l & 4 && It(i[2])
864
869
  ]) : {};
865
870
  if (o !== (o = i[1])) {
866
871
  if (t) {
867
- At();
872
+ Ct();
868
873
  const u = t;
869
- Y(u.$$.fragment, 1, 0, () => {
870
- A(u, 1);
871
- }), Ct();
874
+ G(u.$$.fragment, 1, 0, () => {
875
+ M(u, 1);
876
+ }), Mt();
872
877
  }
873
- o ? (t = new o(a()), F(t.$$.fragment), j(t.$$.fragment, 1), P(t, e.parentNode, e)) : t = null;
878
+ o ? (t = Y(o, a()), Q(t.$$.fragment), A(t.$$.fragment, 1), C(t, e.parentNode, e)) : t = null;
874
879
  } else
875
880
  o && t.$set(c);
876
881
  },
877
882
  i(i) {
878
- n || (t && j(t.$$.fragment, i), n = !0);
883
+ n || (t && A(t.$$.fragment, i), n = !0);
879
884
  },
880
885
  o(i) {
881
- t && Y(t.$$.fragment, i), n = !1;
886
+ t && G(t.$$.fragment, i), n = !1;
882
887
  },
883
888
  d(i) {
884
- i && Z(e), t && A(t, i);
889
+ i && rt(e), t && M(t, i);
885
890
  }
886
891
  };
887
892
  }
888
- function zt(r, t, e) {
893
+ function Dt(r, t, e) {
889
894
  const n = ["blok"];
890
- let s = H(t, n), o, { blok: a } = t;
891
- return a ? o = Dt(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), r.$$set = (i) => {
892
- t = E(E({}, t), Tt(i)), e(2, s = H(t, n)), "blok" in i && e(0, a = i.blok);
895
+ let s = J(t, n), o, { blok: a } = t;
896
+ return a ? o = Ut(a.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), r.$$set = (i) => {
897
+ t = S(S({}, t), Rt(i)), e(2, s = J(t, n)), "blok" in i && e(0, a = i.blok);
893
898
  }, [a, o, s];
894
899
  }
895
- class Yt extends Lt {
900
+ class Ft extends Bt {
896
901
  constructor(t) {
897
- super(), qt(this, t, zt, Bt, wt, { blok: 0 });
902
+ super(), Lt(this, t, Dt, zt, wt, { blok: 0 });
898
903
  }
899
904
  }
900
- const Ft = (r, t) => {
905
+ const Kt = (r, t) => {
901
906
  const e = (n) => {
902
- const s = kt(n);
907
+ const s = bt(n);
903
908
  s["data-blok-c"] && (r.setAttribute("data-blok-c", s["data-blok-c"]), r.setAttribute("data-blok-uid", s["data-blok-uid"]), r.classList.add("storyblok__outline"));
904
909
  };
905
910
  return e(t), {
@@ -908,17 +913,17 @@ const Ft = (r, t) => {
908
913
  }
909
914
  };
910
915
  };
911
- let C = null;
912
- const Kt = () => (C || console.log(
916
+ let N = null;
917
+ const Gt = () => (N || console.log(
913
918
  "You can't use getStoryblokApi if you're not loading apiPlugin."
914
- ), C);
915
- let et = null;
916
- const Gt = (r) => {
917
- const { storyblokApi: t } = bt(r);
918
- C = t, et = r.components || {};
919
- }, Dt = (r) => {
920
- const t = et[r];
921
- return t || console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
919
+ ), N);
920
+ let w = null;
921
+ const Qt = (r) => {
922
+ const { storyblokApi: t } = $t(r);
923
+ N = t, w = r.components || {};
924
+ }, Ut = (r) => {
925
+ let t = null;
926
+ return t = typeof w == "function" ? w()[r] : w[r], t || console.error(`You didn't load the ${r} component. Please load it in storyblokInit. For example:
922
927
  storyblokInit({
923
928
  accessToken: "<your-token>",
924
929
  components: {
@@ -928,14 +933,14 @@ storyblokInit({
928
933
  `), t;
929
934
  };
930
935
  export {
931
- ht as RichTextSchema,
932
- Yt as StoryblokComponent,
933
- Ht as apiPlugin,
934
- Dt as getComponent,
935
- Kt as getStoryblokApi,
936
- Jt as renderRichText,
937
- Ft as storyblokEditable,
938
- Gt as storyblokInit,
939
- Kt as useStoryblokApi,
940
- Vt as useStoryblokBridge
936
+ dt as RichTextSchema,
937
+ Ft as StoryblokComponent,
938
+ Vt as apiPlugin,
939
+ Ut as getComponent,
940
+ Gt as getStoryblokApi,
941
+ Yt as renderRichText,
942
+ Kt as storyblokEditable,
943
+ Qt as storyblokInit,
944
+ Gt as useStoryblokApi,
945
+ Jt as useStoryblokBridge
941
946
  };
package/dist/types.d.ts CHANGED
@@ -4,6 +4,6 @@ export interface SbSvelteComponentsMap {
4
4
  [name: string]: typeof SvelteComponent;
5
5
  }
6
6
  export interface SbSvelteSDKOptions extends SbSDKOptions {
7
- components?: SbSvelteComponentsMap;
7
+ components?: SbSvelteComponentsMap | CallableFunction;
8
8
  }
9
9
  export type { AlternateObject, Richtext, RichtextInstance, SbBlokData, SbBlokKeyDataTypes, SbSDKOptions, Stories, StoriesParams, Story, StoryData, StoryParams, StoryblokBridgeConfigV2, StoryblokBridgeV2, StoryblokCache, StoryblokCacheProvider, StoryblokClient, StoryblokComponentType, StoryblokConfig, StoryblokManagmentApiResult, StoryblokResult, apiPlugin, useStoryblokBridge, } from "@storyblok/js";
package/index.ts CHANGED
@@ -48,7 +48,7 @@ export const useStoryblokApi = (): StoryblokClient => {
48
48
 
49
49
  export { useStoryblokApi as getStoryblokApi };
50
50
 
51
- let componentsMap: SbSvelteComponentsMap = null;
51
+ let componentsMap: SbSvelteComponentsMap | CallableFunction = null;
52
52
 
53
53
  export const storyblokInit = (options: SbSvelteSDKOptions) => {
54
54
  const { storyblokApi } = sbInit(options);
@@ -57,7 +57,11 @@ export const storyblokInit = (options: SbSvelteSDKOptions) => {
57
57
  };
58
58
 
59
59
  export const getComponent = (componentName: string) => {
60
- const component = componentsMap[componentName];
60
+ let component = null;
61
+ component =
62
+ typeof componentsMap === "function"
63
+ ? componentsMap()[componentName]
64
+ : componentsMap[componentName];
61
65
 
62
66
  if (!component) {
63
67
  console.error(`You didn't load the ${componentName} component. Please load it in storyblokInit. For example:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/svelte",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
4
4
  "description": "Storyblok SDK to connect Storyblok with Svelte",
5
5
  "main": "./dist/storyblok-svelte.js",
6
6
  "module": "./dist/storyblok-svelte.mjs",
@@ -39,10 +39,10 @@
39
39
  "cypress-svelte-unit-test": "^3.3.4",
40
40
  "eslint-plugin-cypress": "^2.12.1",
41
41
  "eslint-plugin-jest": "^27.0.4",
42
- "jest": "^29.0.3",
42
+ "jest": "^29.2.1",
43
43
  "svelte-preprocess": "^4.10.7",
44
- "typescript": "^4.8.3",
45
- "vite": "^3.1.3"
44
+ "typescript": "^4.8.4",
45
+ "vite": "^3.1.8"
46
46
  },
47
47
  "eslintConfig": {
48
48
  "env": {
package/types.ts CHANGED
@@ -6,7 +6,7 @@ export interface SbSvelteComponentsMap {
6
6
  }
7
7
 
8
8
  export interface SbSvelteSDKOptions extends SbSDKOptions {
9
- components?: SbSvelteComponentsMap;
9
+ components?: SbSvelteComponentsMap | CallableFunction;
10
10
  }
11
11
 
12
12
  export type {