@storyblok/vue 8.0.0 → 8.0.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.
@@ -21,5 +21,5 @@
21
21
  }
22
22
  ],
23
23
  type: 'doc'
24
- }`),""}optimizeImages(e,t){let s=0,r=0,n="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i="/filters"+i))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=s>0||r>0||i.length>0?`${s}x${r}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var c,p;const m=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(m&&m.length>0){const f={srcset:(c=t.srcset)==null?void 0:c.map(g=>{if(typeof g=="number")return`//${m}/m/${g}x0${i} ${g}w`;if(typeof g=="object"&&g.length===2){let w=0,P=0;return typeof g[0]=="number"&&(w=g[0]),typeof g[1]=="number"&&(P=g[1]),`//${m}/m/${w}x${P}${i} ${w}w`}}).join(", "),sizes:(p=t.sizes)==null?void 0:p.map(g=>g).join(", ")};let T="";return f.srcset&&(T+=`srcset="${f.srcset}" `),f.sizes&&(T+=`sizes="${f.sizes}" `),a.replace(/<img/g,`<img ${T.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&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(de(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&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 i=s.attrs[n];i!==null&&(r+=` ${n}="${i}"`)}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)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class me{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||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={}}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 a=new v;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:i}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:i});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}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 n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(n)})}}var ge={NVM_INC:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/include/node",TERM_PROGRAM:"iTerm.app",NODE:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",NVM_CD_FLAGS:"-q",INIT_CWD:"/Users/lisilinhart/Code/storyblok-js-client",SHELL:"/bin/zsh",TERM:"xterm-256color",TMPDIR:"/var/folders/9v/t3hq3s9n2rj6_x9jlsjjq95w0000gn/T/",npm_config_metrics_registry:"https://registry.npmjs.org/",npm_config_global_prefix:"/Users/lisilinhart/.nvm/versions/node/v18.16.0",TERM_PROGRAM_VERSION:"3.4.20",TERM_SESSION_ID:"w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF",COLOR:"0",npm_config_noproxy:"",ZSH:"/Users/lisilinhart/.oh-my-zsh",npm_config_local_prefix:"/Users/lisilinhart/Code/storyblok-js-client",USER:"lisilinhart",NVM_DIR:"/Users/lisilinhart/.nvm",COMMAND_MODE:"unix2003",npm_config_globalconfig:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/etc/npmrc",SSH_AUTH_SOCK:"/private/tmp/com.apple.launchd.oUounWp9qr/Listeners",__CF_USER_TEXT_ENCODING:"0x1F5:0x0:0x5C",npm_execpath:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/bin/npm-cli.js",PAGER:"less",npm_package_integrity:"null",LSCOLORS:"Gxfxcxdxbxegedabagacad",PATH:"/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/usr/local/sbin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.yarn/bin:/Users/lisilinhart/.config/yarn/global/node_modules/.bin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin:/Users/lisilinhart/bin:/usr/local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/lisilinhart/.cargo/bin",RUBY_CONFIGURE_OPTS:"--with-openssl-dir=/usr/local/opt/openssl@1.1",LaunchInstanceID:"9D2A03D3-35CC-4CDD-810D-0D5C25991BBB",_:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",npm_package_json:"/Users/lisilinhart/Code/storyblok-js-client/package.json",__CFBundleIdentifier:"com.googlecode.iterm2",npm_config_init_module:"/Users/lisilinhart/.npm-init.js",npm_config_userconfig:"/Users/lisilinhart/.npmrc",PWD:"/Users/lisilinhart/Code/storyblok-js-client",npm_command:"run-script",P9K_SSH:"0",EDITOR:"vi",npm_lifecycle_event:"build",LANG:"de_AT.UTF-8",P9K_TTY:"old",npm_package_name:"storyblok-js-client",ITERM_PROFILE:"Default",XPC_FLAGS:"0x0",RBENV_SHELL:"zsh",npm_config_node_gyp:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",XPC_SERVICE_NAME:"0",npm_package_version:"6.4.1",COLORFGBG:"7;0",HOME:"/Users/lisilinhart",SHLVL:"3",npm_package_resolved:"/Users/lisilinhart/Code/storyblok-js-client",LC_TERMINAL_VERSION:"3.4.20",ITERM_SESSION_ID:"w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF",LOGNAME:"lisilinhart",LESS:"-R",npm_config_cache:"/Users/lisilinhart/.npm",npm_lifecycle_script:"node vite.build.mjs && tsc",NVM_BIN:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin",npm_config_user_agent:"npm/9.5.1 node/v18.16.0 darwin x64 workspaces/false",LC_TERMINAL:"iTerm2",SECURITYSESSIONID:"186a1",COLORTERM:"truecolor",npm_config_prefix:"/Users/lisilinhart/.nvm/versions/node/v18.16.0",npm_node_execpath:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",NODE_ENV:"production"};const x="SB-Agent",R={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:ge.npm_package_version};let k={};const b={};class fe{constructor(e,t){h(this,"client"),h(this,"maxRetries"),h(this,"throttle"),h(this,"accessToken"),h(this,"cache"),h(this,"helpers"),h(this,"resolveCounter"),h(this,"relations"),h(this,"links"),h(this,"richTextResolver"),h(this,"resolveNestedRelations"),h(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const i=new v().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?s=`${l}://${i(e.region)}/v1`:s=`${l}://${i(e.region)}/v2`}const r=new Headers;if(r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers)for(const i in e.headers)r.set(i,e.headers[i]);r.has(x)||(r.set(x,R.defaultAgentName),r.set(R.defaultAgentVersion,R.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new y(e.richTextSchema):this.richTextResolver=new y,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=F(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new v,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new me({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=b[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}`,i=n.split("/"),l=s||i[i.length-1],a=1,c=await this.makeRequest(n,t,r,a),p=c.total?Math.ceil(c.total/r):1,m=await this.helpers.asyncMap(this.helpers.range(a,p),f=>this.makeRequest(n,t,r,f+1));return this.helpers.flatMap([c,...m],f=>Object.values(f.data[l]))}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,s){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,s,r){s.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(r,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(n=>this.getStoryReference(r,n)).filter(Boolean)))}iterateTree(e,t,s){const r=n=>{if(n!=null){if(n.constructor===Array)for(let i=0;i<n.length;i++)r(n[i]);else if(n.constructor===Object){if(n._stopResolving)return;for(const i in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,t,s),this._insertLinks(n,i,s)),r(n[i])}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);i.push(e.link_uuids.slice(a,c))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);i.push(e.rel_uuids.slice(a,c))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var r,n;let i=[];if(this.links[s]={},this.relations[s]={},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,s)),t.resolve_links&&["1","story","url","link"].indexOf(t.resolve_links)>-1&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],i,s);e.story?this.iterateTree(e.story,i,s):e.stories.forEach(l=>{this.iterateTree(l,i,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s){(typeof s>"u"||!s)&&(s=0);const r=this.helpers.stringify({url:e,params:t}),n=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const i=await n.get(r);if(i)return Promise.resolve(i)}return new Promise(async(i,l)=>{var a;try{const c=await this.throttle("get",e,t);if(c.status!==200)return l(c);let p={data:c.data,headers:c.headers};if((a=c.headers)!=null&&a["per-page"]&&(p=Object.assign({},p,{perPage:c.headers["per-page"]?parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?parseInt(c.headers.total):0})),p.data.story||p.data.stories){const m=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${m}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await n.set(r,p),p.data.cv&&t.token&&(t.version==="draft"&&b[t.token]!=p.data.cv&&await this.flushCache(),b[t.token]=t.cv?t.cv:p.data.cv),i(p)}catch(c){if(c.response&&c.response.status===429&&(s=s?s+1:0,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${s} seconds.`),await this.helpers.delay(1e3*s),this.cacheResponse(e,t,s).then(i).catch(l);l(c)}})}throttledRequest(e,t,s){return this.client[e](t,s)}cacheVersions(){return b}cacheVersion(){return b[this.accessToken]}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()},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 ye=(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 fe(e)}},be=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}};let S,I="https://app.storyblok.com/f/storyblok-v2-latest.js";const U=(o,e,t={})=>{var s;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===o;if(!(!r||!n)){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"],i=>{i.action==="input"&&i.story.id===o?e(i.story):(i.action==="change"||i.action==="published")&&i.storyId===o&&window.location.reload()})})}},_e=(o={})=>{var e,t;const{bridge:s,accessToken:r,use:n=[],apiOptions:i={},richText:l={},bridgeUrl:a}=o;i.accessToken=i.accessToken||r;const c={bridge:s,apiOptions:i};let p={};n.forEach(f=>{p={...p,...f(c)}}),a&&(I=a);const m=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return s!==!1&&m&&L(I),S=new y(l.schema),l.resolver&&O(S,l.resolver),p},O=(o,e)=>{o.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},ve=o=>!o||!(o!=null&&o.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),ke=(o,e,t)=>{let s=t||S;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return ve(o)?"":(e&&(s=new y(e.schema),e.resolver&&O(s,e.resolver)),s.render(o))},A=u.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(o,{expose:e}){const t=o,s=u.ref();e({value:s});const r=typeof u.resolveDynamicComponent(t.blok.component)!="string",n=u.inject("VueSDKOptions"),i=u.ref(t.blok.component);return r||(n.enableFallbackComponent?(i.value=n.customFallbackComponent??"FallbackComponent",typeof u.resolveDynamicComponent(i.value)=="string"&&console.error(`Is the Fallback component "${i.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(l,a)=>(u.openBlock(),u.createBlock(u.resolveDynamicComponent(i.value),u.mergeProps({ref_key:"blokRef",ref:s},{...l.$props,...l.$attrs}),null,16))}}),Re={beforeMount(o,e){if(e.value){const t=be(e.value);Object.keys(t).length>0&&(o.setAttribute("data-blok-c",t["data-blok-c"]),o.setAttribute("data-blok-uid",t["data-blok-uid"]),o.classList.add("storyblok__outline"))}}},N=o=>{console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
24
+ }`),""}optimizeImages(e,t){let s=0,r=0,n="",i="";typeof t!="boolean"&&(typeof t.width=="number"&&t.width>0&&(n+=`width="${t.width}" `,s=t.width),typeof t.height=="number"&&t.height>0&&(n+=`height="${t.height}" `,r=t.height),(t.loading==="lazy"||t.loading==="eager")&&(n+=`loading="${t.loading}" `),typeof t.class=="string"&&t.class.length>0&&(n+=`class="${t.class}" `),t.filters&&(typeof t.filters.blur=="number"&&t.filters.blur>=0&&t.filters.blur<=100&&(i+=`:blur(${t.filters.blur})`),typeof t.filters.brightness=="number"&&t.filters.brightness>=-100&&t.filters.brightness<=100&&(i+=`:brightness(${t.filters.brightness})`),t.filters.fill&&(t.filters.fill.match(/[0-9A-Fa-f]{6}/g)||t.filters.fill==="transparent")&&(i+=`:fill(${t.filters.fill})`),t.filters.format&&["webp","png","jpeg"].includes(t.filters.format)&&(i+=`:format(${t.filters.format})`),typeof t.filters.grayscale=="boolean"&&t.filters.grayscale&&(i+=":grayscale()"),typeof t.filters.quality=="number"&&t.filters.quality>=0&&t.filters.quality<=100&&(i+=`:quality(${t.filters.quality})`),t.filters.rotate&&[90,180,270].includes(t.filters.rotate)&&(i+=`:rotate(${t.filters.rotate})`),i.length>0&&(i="/filters"+i))),n.length>0&&(e=e.replace(/<img/g,`<img ${n.trim()}`));const l=s>0||r>0||i.length>0?`${s}x${r}${i}`:"";return e=e.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${l}`),typeof t!="boolean"&&(t.sizes||t.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,a=>{var c,p;const m=a.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(m&&m.length>0){const f={srcset:(c=t.srcset)==null?void 0:c.map(g=>{if(typeof g=="number")return`//${m}/m/${g}x0${i} ${g}w`;if(typeof g=="object"&&g.length===2){let w=0,P=0;return typeof g[0]=="number"&&(w=g[0]),typeof g[1]=="number"&&(P=g[1]),`//${m}/m/${w}x${P}${i} ${w}w`}}).join(", "),sizes:(p=t.sizes)==null?void 0:p.map(g=>g).join(", ")};let T="";return f.srcset&&(T+=`srcset="${f.srcset}" `),f.sizes&&(T+=`sizes="${f.sizes}" `),a.replace(/<img/g,`<img ${T.trim()}`)}return a})),e}renderNode(e){const t=[];e.marks&&e.marks.forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&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(de(e.text)):s&&s.singleTag?t.push(this.renderTag(s.singleTag," /")):s&&s.html?t.push(s.html):e.type==="emoji"&&t.push(this.renderEmoji(e)),s&&s.tag&&t.push(this.renderClosingTag(s.tag)),e.marks&&e.marks.slice(0).reverse().forEach(r=>{const n=this.getMatchingMark(r);n&&n.tag!==""&&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 i=s.attrs[n];i!==null&&(r+=` ${n}="${i}"`)}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)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const t=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(t," /")}}class me{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||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={}}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 a=new v;t=`${this.baseURL}${this.url}?${a.stringify(this.parameters)}`}else s=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:i}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const a=await fetch(`${r}`,{method:e,headers:this.headers,body:s,signal:i});this.timeout&&clearTimeout(l);const c=await this._responseHandler(a);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(c)):this._statusHandler(c)}catch(a){return{message:a}}}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 n={message:e.statusText,status:e.status,response:Array.isArray(e.data)?e.data[0]:e.data.error||e.data.slug};r(n)})}}var ge={NVM_INC:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/include/node",TERM_PROGRAM:"iTerm.app",NODE:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",NVM_CD_FLAGS:"-q",INIT_CWD:"/Users/lisilinhart/Code/storyblok-js-client",SHELL:"/bin/zsh",TERM:"xterm-256color",TMPDIR:"/var/folders/9v/t3hq3s9n2rj6_x9jlsjjq95w0000gn/T/",npm_config_metrics_registry:"https://registry.npmjs.org/",npm_config_global_prefix:"/Users/lisilinhart/.nvm/versions/node/v18.16.0",TERM_PROGRAM_VERSION:"3.4.20",TERM_SESSION_ID:"w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF",COLOR:"0",npm_config_noproxy:"",ZSH:"/Users/lisilinhart/.oh-my-zsh",npm_config_local_prefix:"/Users/lisilinhart/Code/storyblok-js-client",USER:"lisilinhart",NVM_DIR:"/Users/lisilinhart/.nvm",COMMAND_MODE:"unix2003",npm_config_globalconfig:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/etc/npmrc",SSH_AUTH_SOCK:"/private/tmp/com.apple.launchd.oUounWp9qr/Listeners",__CF_USER_TEXT_ENCODING:"0x1F5:0x0:0x5C",npm_execpath:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/bin/npm-cli.js",PAGER:"less",npm_package_integrity:"null",LSCOLORS:"Gxfxcxdxbxegedabagacad",PATH:"/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/lisilinhart/Code/storyblok-js-client/node_modules/.bin:/Users/lisilinhart/Code/node_modules/.bin:/Users/lisilinhart/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/usr/local/sbin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.yarn/bin:/Users/lisilinhart/.config/yarn/global/node_modules/.bin:/Users/lisilinhart/.rbenv/shims:/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin:/Users/lisilinhart/bin:/usr/local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/lisilinhart/.cargo/bin",RUBY_CONFIGURE_OPTS:"--with-openssl-dir=/usr/local/opt/openssl@1.1",LaunchInstanceID:"9D2A03D3-35CC-4CDD-810D-0D5C25991BBB",_:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",npm_package_json:"/Users/lisilinhart/Code/storyblok-js-client/package.json",__CFBundleIdentifier:"com.googlecode.iterm2",npm_config_init_module:"/Users/lisilinhart/.npm-init.js",npm_config_userconfig:"/Users/lisilinhart/.npmrc",PWD:"/Users/lisilinhart/Code/storyblok-js-client",npm_command:"run-script",P9K_SSH:"0",EDITOR:"vi",npm_lifecycle_event:"build",LANG:"de_AT.UTF-8",P9K_TTY:"old",npm_package_name:"storyblok-js-client",ITERM_PROFILE:"Default",XPC_FLAGS:"0x0",RBENV_SHELL:"zsh",npm_config_node_gyp:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",XPC_SERVICE_NAME:"0",npm_package_version:"6.4.1",COLORFGBG:"7;0",HOME:"/Users/lisilinhart",SHLVL:"3",npm_package_resolved:"/Users/lisilinhart/Code/storyblok-js-client",LC_TERMINAL_VERSION:"3.4.20",ITERM_SESSION_ID:"w0t0p1:12B7CE01-010D-40B5-B6DA-DFE3CF20B8FF",LOGNAME:"lisilinhart",LESS:"-R",npm_config_cache:"/Users/lisilinhart/.npm",npm_lifecycle_script:"node vite.build.mjs && tsc",NVM_BIN:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin",npm_config_user_agent:"npm/9.5.1 node/v18.16.0 darwin x64 workspaces/false",LC_TERMINAL:"iTerm2",SECURITYSESSIONID:"186a1",COLORTERM:"truecolor",npm_config_prefix:"/Users/lisilinhart/.nvm/versions/node/v18.16.0",npm_node_execpath:"/Users/lisilinhart/.nvm/versions/node/v18.16.0/bin/node",NODE_ENV:"production"};const x="SB-Agent",R={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:ge.npm_package_version};let k={};const b={};class fe{constructor(e,t){h(this,"client"),h(this,"maxRetries"),h(this,"throttle"),h(this,"accessToken"),h(this,"cache"),h(this,"helpers"),h(this,"resolveCounter"),h(this,"relations"),h(this,"links"),h(this,"richTextResolver"),h(this,"resolveNestedRelations"),h(this,"stringifiedStoriesCache");let s=e.endpoint||t;if(!s){const i=new v().getRegionURL,l=e.https===!1?"http":"https";e.oauthToken?s=`${l}://${i(e.region)}/v1`:s=`${l}://${i(e.region)}/v2`}const r=new Headers;if(r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers)for(const i in e.headers)r.set(i,e.headers[i]);r.has(x)||(r.set(x,R.defaultAgentName),r.set(R.defaultAgentVersion,R.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new y(e.richTextSchema):this.richTextResolver=new y,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=F(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new v,this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.client=new me({baseURL:s,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let s="";return t.attrs.body&&t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=b[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}`,i=n.split("/"),l=s||i[i.length-1],a=1,c=await this.makeRequest(n,t,r,a),p=c.total?Math.ceil(c.total/r):1,m=await this.helpers.asyncMap(this.helpers.range(a,p),f=>this.makeRequest(n,t,r,f+1));return this.helpers.flatMap([c,...m],f=>Object.values(f.data[l]))}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,s){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[s][r.id]?r.story=this._cleanCopy(this.links[s][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[s][r.uuid]&&(r.story=this._cleanCopy(this.links[s][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?(this.stringifiedStoriesCache[t]||(this.stringifiedStoriesCache[t]=JSON.stringify(this.relations[e][t])),JSON.parse(this.stringifiedStoriesCache[t])):t}_insertRelations(e,t,s,r){s.indexOf(`${e.component}.${t}`)>-1&&(typeof e[t]=="string"?e[t]=this.getStoryReference(r,e[t]):Array.isArray(e[t])&&(e[t]=e[t].map(n=>this.getStoryReference(r,n)).filter(Boolean)))}iterateTree(e,t,s){const r=n=>{if(n!=null){if(n.constructor===Array)for(let i=0;i<n.length;i++)r(n[i]);else if(n.constructor===Object){if(n._stopResolving)return;for(const i in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,t,s),this._insertLinks(n,i,s)),r(n[i])}}};r(e.content)}async resolveLinks(e,t,s){let r=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);i.push(e.link_uuids.slice(a,c))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(n=>{this.links[s][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,s){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let a=0;a<n;a+=l){const c=Math.min(n,a+l);i.push(e.rel_uuids.slice(a,c))}for(let a=0;a<i.length;a++)(await this.getStories({per_page:l,language:t.language,version:t.version,by_uuids:i[a].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[s][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,s){var r,n;let i=[];if(this.links[s]={},this.relations[s]={},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,s)),t.resolve_links&&["1","story","url","link"].indexOf(t.resolve_links)>-1&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,s),this.resolveNestedRelations)for(const l in this.relations[s])this.iterateTree(this.relations[s][l],i,s);e.story?this.iterateTree(e.story,i,s):e.stories.forEach(l=>{this.iterateTree(l,i,s)}),this.stringifiedStoriesCache={},delete this.links[s],delete this.relations[s]}async cacheResponse(e,t,s){(typeof s>"u"||!s)&&(s=0);const r=this.helpers.stringify({url:e,params:t}),n=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const i=await n.get(r);if(i)return Promise.resolve(i)}return new Promise(async(i,l)=>{var a;try{const c=await this.throttle("get",e,t);if(c.status!==200)return l(c);let p={data:c.data,headers:c.headers};if((a=c.headers)!=null&&a["per-page"]&&(p=Object.assign({},p,{perPage:c.headers["per-page"]?parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?parseInt(c.headers.total):0})),p.data.story||p.data.stories){const m=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(p.data,t,`${m}`)}return t.version==="published"&&e!="/cdn/spaces/me"&&await n.set(r,p),p.data.cv&&t.token&&(t.version==="draft"&&b[t.token]!=p.data.cv&&await this.flushCache(),b[t.token]=t.cv?t.cv:p.data.cv),i(p)}catch(c){if(c.response&&c.response.status===429&&(s=s?s+1:0,s<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${s} seconds.`),await this.helpers.delay(1e3*s),this.cacheResponse(e,t,s).then(i).catch(l);l(c)}})}throttledRequest(e,t,s){return this.client[e](t,s)}cacheVersions(){return b}cacheVersion(){return b[this.accessToken]}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()},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 ye=(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 fe(e)}},be=o=>{if(typeof o!="object"||typeof o._editable>"u")return{};try{const e=JSON.parse(o._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}:{}}catch{return{}}};let S,I="https://app.storyblok.com/f/storyblok-v2-latest.js";const U=(o,e,t={})=>{var s;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=+new URL((s=window.location)==null?void 0:s.href).searchParams.get("_storyblok")===o;if(!(!r||!n)){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"],i=>{i.action==="input"&&i.story.id===o?e(i.story):(i.action==="change"||i.action==="published")&&i.storyId===o&&window.location.reload()})})}},_e=(o={})=>{var e,t;const{bridge:s,accessToken:r,use:n=[],apiOptions:i={},richText:l={},bridgeUrl:a}=o;i.accessToken=i.accessToken||r;const c={bridge:s,apiOptions:i};let p={};n.forEach(f=>{p={...p,...f(c)}}),a&&(I=a);const m=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return s!==!1&&m&&L(I),S=new y(l.schema),l.resolver&&O(S,l.resolver),p},O=(o,e)=>{o.addNode("blok",t=>{let s="";return t.attrs.body.forEach(r=>{s+=e(r.component,r)}),{html:s}})},ve=o=>!o||!(o!=null&&o.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),ke=(o,e,t)=>{let s=t||S;if(!s){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return ve(o)?"":(e&&(s=new y(e.schema),e.resolver&&O(s,e.resolver)),s.render(o))},A=u.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(o,{expose:e}){const t=o,s=u.ref();e({value:s});const r=typeof u.resolveDynamicComponent(t.blok.component)!="string",n=u.inject("VueSDKOptions"),i=u.ref(t.blok.component);return r||(n.enableFallbackComponent?(i.value=n.customFallbackComponent??"FallbackComponent",typeof u.resolveDynamicComponent(i.value)=="string"&&console.error(`Is the Fallback component "${i.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(l,a)=>(u.openBlock(),u.createBlock(u.resolveDynamicComponent(i.value),u.mergeProps({ref_key:"blokRef",ref:s},{...l.$props,...l.$attrs}),null,16))}}),Re={beforeMount(o,e){if(e.value){const t=be(e.value);Object.keys(t).length>0&&(o.setAttribute("data-blok-c",t["data-blok-c"]),o.setAttribute("data-blok-uid",t["data-blok-uid"]),o.classList.add("storyblok__outline"))}}},N=o=>{console.error(`You can't use ${o} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
25
25
  `)};let _=null;const Se=()=>(_||N("useStoryblokApi"),_),Te=async(o,e={},t={})=>{const s=u.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,u.onMounted(()=>{s.value&&s.value.id&&U(s.value.id,r=>s.value=r,t)}),_){const{data:r}=await _.get(`cdn/stories/${o}`,e);s.value=r.story}else N("useStoryblok");return s},we={install(o,e={}){o.directive("editable",Re),o.component("StoryblokComponent",A),e.enableFallbackComponent&&!e.customFallbackComponent&&o.component("FallbackComponent",u.defineAsyncComponent(()=>Promise.resolve().then(()=>Ee)));const{storyblokApi:t}=_e(e);_=t,o.provide("VueSDKOptions",e)}},Ce={class:"fallback-component"},$e={class:"component"},Ee=Object.freeze(Object.defineProperty({__proto__:null,default:((o,e)=>{const t=o.__vccOpts||o;for(const[s,r]of e)t[s]=r;return t})(u.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(o){return(e,t)=>(u.openBlock(),u.createElementBlock("div",Ce,[u.createElementVNode("p",null,[u.createTextVNode(" Component could not be found for blok "),u.createElementVNode("span",$e,u.toDisplayString(e.blok.component),1),u.createTextVNode("! Is it configured correctly? ")])]))}}),[["__scopeId","data-v-93c770c0"]])},Symbol.toStringTag,{value:"Module"}));d.RichTextResolver=y,d.RichTextSchema=j,d.StoryblokComponent=A,d.StoryblokVue=we,d.apiPlugin=ye,d.renderRichText=ke,d.useStoryblok=Te,d.useStoryblokApi=Se,d.useStoryblokBridge=U,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
@@ -11,7 +11,7 @@ const E = [], B = (o) => new Promise((e, t) => {
11
11
  return;
12
12
  const s = document.createElement("script");
13
13
  s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
14
- E.forEach((i) => i()), $ = !0, e(r);
14
+ E.forEach((n) => n()), $ = !0, e(r);
15
15
  }, document.getElementsByTagName("head")[0].appendChild(s);
16
16
  });
17
17
  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, h = (o, e, t) => (V(o, typeof e != "symbol" ? e + "" : e, t), t);
@@ -24,11 +24,11 @@ function z(o, e, t) {
24
24
  if (!x(t))
25
25
  throw new TypeError("Expected `interval` to be a finite number");
26
26
  const s = [];
27
- let r = [], i = 0;
28
- const n = function() {
29
- i++;
27
+ let r = [], n = 0;
28
+ const i = function() {
29
+ n++;
30
30
  const a = setTimeout(function() {
31
- i--, s.length > 0 && n(), r = r.filter(function(u) {
31
+ n--, s.length > 0 && i(), r = r.filter(function(u) {
32
32
  return u !== a;
33
33
  });
34
34
  }, t);
@@ -43,7 +43,7 @@ function z(o, e, t) {
43
43
  reject: p,
44
44
  args: a,
45
45
  self: c
46
- }), i < e && n();
46
+ }), n < e && i();
47
47
  });
48
48
  };
49
49
  return l.abort = function() {
@@ -62,7 +62,7 @@ class b {
62
62
  page: s
63
63
  })), 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) => {
64
64
  const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
65
- return this.arrayFrom(s, (i, n) => n * r + e);
65
+ return this.arrayFrom(s, (n, i) => i * r + e);
66
66
  }), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), h(this, "escapeHTML", function(e) {
67
67
  const t = {
68
68
  "&": "&amp;",
@@ -71,7 +71,7 @@ class b {
71
71
  '"': "&quot;",
72
72
  "'": "&#39;"
73
73
  }, s = /[&<>"']/g, r = RegExp(s.source);
74
- return e && r.test(e) ? e.replace(s, (i) => t[i]) : e;
74
+ return e && r.test(e) ? e.replace(s, (n) => t[n]) : e;
75
75
  });
76
76
  }
77
77
  /**
@@ -83,16 +83,16 @@ class b {
83
83
  */
84
84
  stringify(e, t, s) {
85
85
  const r = [];
86
- for (const i in e) {
87
- if (!Object.prototype.hasOwnProperty.call(e, i))
86
+ for (const n in e) {
87
+ if (!Object.prototype.hasOwnProperty.call(e, n))
88
88
  continue;
89
- const n = e[i], l = s ? "" : encodeURIComponent(i);
89
+ const i = e[n], l = s ? "" : encodeURIComponent(n);
90
90
  let a;
91
- typeof n == "object" ? a = this.stringify(
92
- n,
91
+ typeof i == "object" ? a = this.stringify(
92
+ i,
93
93
  t ? t + encodeURIComponent("[" + l + "]") : l,
94
- Array.isArray(n)
95
- ) : a = (t ? t + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(n), r.push(a);
94
+ Array.isArray(i)
95
+ ) : a = (t ? t + encodeURIComponent("[" + l + "]") : l) + "=" + encodeURIComponent(i), r.push(a);
96
96
  }
97
97
  return r.join("&");
98
98
  }
@@ -102,16 +102,16 @@ class b {
102
102
  * @return {String} The base URL of the region
103
103
  */
104
104
  getRegionURL(e) {
105
- const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", i = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
105
+ const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", n = "api-ap.storyblok.com", i = "api-ca.storyblok.com";
106
106
  switch (e) {
107
107
  case "us":
108
108
  return s;
109
109
  case "cn":
110
110
  return r;
111
111
  case "ap":
112
- return i;
113
- case "ca":
114
112
  return n;
113
+ case "ca":
114
+ return i;
115
115
  default:
116
116
  return t;
117
117
  }
@@ -168,9 +168,9 @@ const q = function(o, e) {
168
168
  ]
169
169
  }), oe = () => ({
170
170
  tag: "b"
171
- }), ie = () => ({
172
- tag: "s"
173
171
  }), ne = () => ({
172
+ tag: "s"
173
+ }), ie = () => ({
174
174
  tag: "u"
175
175
  }), ae = () => ({
176
176
  tag: "strong"
@@ -259,8 +259,8 @@ const q = function(o, e) {
259
259
  },
260
260
  marks: {
261
261
  bold: oe,
262
- strike: ie,
263
- underline: ne,
262
+ strike: ne,
263
+ underline: ie,
264
264
  strong: ae,
265
265
  code: le,
266
266
  italic: ce,
@@ -327,9 +327,9 @@ class v {
327
327
  ), "";
328
328
  }
329
329
  optimizeImages(e, t) {
330
- let s = 0, r = 0, i = "", n = "";
331
- typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (i += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (i += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (i += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (i += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (n += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (n += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (n += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (n += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (n += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (n += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (n += `:rotate(${t.filters.rotate})`), n.length > 0 && (n = "/filters" + n))), i.length > 0 && (e = e.replace(/<img/g, `<img ${i.trim()}`));
332
- const l = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
330
+ let s = 0, r = 0, n = "", i = "";
331
+ typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = "/filters" + i))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
332
+ const l = s > 0 || r > 0 || i.length > 0 ? `${s}x${r}${i}` : "";
333
333
  return e = e.replace(
334
334
  /a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
335
335
  `a.storyblok.com/f/$1/$2.$3/m/${l}`
@@ -342,10 +342,10 @@ class v {
342
342
  const m = {
343
343
  srcset: (c = t.srcset) == null ? void 0 : c.map((d) => {
344
344
  if (typeof d == "number")
345
- return `//${p}/m/${d}x0${n} ${d}w`;
345
+ return `//${p}/m/${d}x0${i} ${d}w`;
346
346
  if (typeof d == "object" && d.length === 2) {
347
347
  let k = 0, C = 0;
348
- return typeof d[0] == "number" && (k = d[0]), typeof d[1] == "number" && (C = d[1]), `//${p}/m/${k}x${C}${n} ${k}w`;
348
+ return typeof d[0] == "number" && (k = d[0]), typeof d[1] == "number" && (C = d[1]), `//${p}/m/${k}x${C}${i} ${k}w`;
349
349
  }
350
350
  }).join(", "),
351
351
  sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
@@ -359,15 +359,15 @@ class v {
359
359
  renderNode(e) {
360
360
  const t = [];
361
361
  e.marks && e.marks.forEach((r) => {
362
- const i = this.getMatchingMark(r);
363
- i && i.tag !== "" && t.push(this.renderOpeningTag(i.tag));
362
+ const n = this.getMatchingMark(r);
363
+ n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
364
364
  });
365
365
  const s = this.getMatchingNode(e);
366
366
  return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
367
367
  t.push(this.renderNode(r));
368
368
  }) : e.text ? t.push(be(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
369
- const i = this.getMatchingMark(r);
370
- i && i.tag !== "" && t.push(this.renderClosingTag(i.tag));
369
+ const n = this.getMatchingMark(r);
370
+ n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
371
371
  }), t.join("");
372
372
  }
373
373
  renderTag(e, t) {
@@ -377,9 +377,9 @@ class v {
377
377
  {
378
378
  let r = `<${s.tag}`;
379
379
  if (s.attrs)
380
- for (const i in s.attrs) {
381
- const n = s.attrs[i];
382
- n !== null && (r += ` ${i}="${n}"`);
380
+ for (const n in s.attrs) {
381
+ const i = s.attrs[n];
382
+ i !== null && (r += ` ${n}="${i}"`);
383
383
  }
384
384
  return `${r}${t}>`;
385
385
  }
@@ -463,15 +463,15 @@ class ve {
463
463
  )}`;
464
464
  } else
465
465
  s = JSON.stringify(this.parameters);
466
- const r = new URL(t), i = new AbortController(), { signal: n } = i;
466
+ const r = new URL(t), n = new AbortController(), { signal: i } = n;
467
467
  let l;
468
- this.timeout && (l = setTimeout(() => i.abort(), this.timeout));
468
+ this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
469
469
  try {
470
470
  const a = await fetch(`${r}`, {
471
471
  method: e,
472
472
  headers: this.headers,
473
473
  body: s,
474
- signal: n
474
+ signal: i
475
475
  });
476
476
  this.timeout && clearTimeout(l);
477
477
  const c = await this._responseHandler(a);
@@ -490,12 +490,12 @@ class ve {
490
490
  return new Promise((s, r) => {
491
491
  if (t.test(`${e.status}`))
492
492
  return s(e);
493
- const i = {
493
+ const n = {
494
494
  message: e.statusText,
495
495
  status: e.status,
496
496
  response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
497
497
  };
498
- r(i);
498
+ r(n);
499
499
  });
500
500
  }
501
501
  }
@@ -517,19 +517,19 @@ class ke {
517
517
  h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations"), h(this, "stringifiedStoriesCache");
518
518
  let s = e.endpoint || t;
519
519
  if (!s) {
520
- const n = new b().getRegionURL, l = e.https === !1 ? "http" : "https";
521
- e.oauthToken ? s = `${l}://${n(e.region)}/v1` : s = `${l}://${n(e.region)}/v2`;
520
+ const i = new b().getRegionURL, l = e.https === !1 ? "http" : "https";
521
+ e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
522
522
  }
523
523
  const r = new Headers();
524
524
  if (r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers)
525
- for (const n in e.headers)
526
- r.set(n, e.headers[n]);
525
+ for (const i in e.headers)
526
+ r.set(i, e.headers[i]);
527
527
  r.has(j) || (r.set(j, w.defaultAgentName), r.set(
528
528
  w.defaultAgentVersion,
529
529
  w.packageVersion
530
530
  ));
531
- let i = 5;
532
- e.oauthToken && (r.set("Authorization", e.oauthToken), i = 3), e.rateLimit && (i = e.rateLimit), e.richTextSchema ? this.richTextResolver = new v(e.richTextSchema) : this.richTextResolver = new v(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = z(this.throttledRequest, i, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new ve({
531
+ let n = 5;
532
+ e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new v(e.richTextSchema) : this.richTextResolver = new v(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = z(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new ve({
533
533
  baseURL: s,
534
534
  timeout: e.timeout || 0,
535
535
  headers: r,
@@ -554,11 +554,11 @@ class ke {
554
554
  return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
555
555
  }
556
556
  makeRequest(e, t, s, r) {
557
- const i = this.factoryParamOptions(
557
+ const n = this.factoryParamOptions(
558
558
  e,
559
559
  this.helpers.getOptionsPage(t, s, r)
560
560
  );
561
- return this.cacheResponse(e, i);
561
+ return this.cacheResponse(e, n);
562
562
  }
563
563
  get(e, t) {
564
564
  t || (t = {});
@@ -566,9 +566,9 @@ class ke {
566
566
  return this.cacheResponse(s, r);
567
567
  }
568
568
  async getAll(e, t, s) {
569
- const r = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, n = i.split("/"), l = s || n[n.length - 1], a = 1, c = await this.makeRequest(i, t, r, a), u = c.total ? Math.ceil(c.total / r) : 1, p = await this.helpers.asyncMap(
569
+ const r = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, i = n.split("/"), l = s || i[i.length - 1], a = 1, c = await this.makeRequest(n, t, r, a), u = c.total ? Math.ceil(c.total / r) : 1, p = await this.helpers.asyncMap(
570
570
  this.helpers.range(a, u),
571
- (m) => this.makeRequest(i, t, r, m + 1)
571
+ (m) => this.makeRequest(n, t, r, m + 1)
572
572
  );
573
573
  return this.helpers.flatMap(
574
574
  [c, ...p],
@@ -618,28 +618,28 @@ class ke {
618
618
  )), JSON.parse(this.stringifiedStoriesCache[t])) : t;
619
619
  }
620
620
  _insertRelations(e, t, s, r) {
621
- s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(r, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((i) => this.getStoryReference(r, i)).filter(Boolean)));
621
+ s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(r, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(r, n)).filter(Boolean)));
622
622
  }
623
623
  iterateTree(e, t, s) {
624
- const r = (i) => {
625
- if (i != null) {
626
- if (i.constructor === Array)
627
- for (let n = 0; n < i.length; n++)
628
- r(i[n]);
629
- else if (i.constructor === Object) {
630
- if (i._stopResolving)
624
+ const r = (n) => {
625
+ if (n != null) {
626
+ if (n.constructor === Array)
627
+ for (let i = 0; i < n.length; i++)
628
+ r(n[i]);
629
+ else if (n.constructor === Object) {
630
+ if (n._stopResolving)
631
631
  return;
632
- for (const n in i)
633
- (i.component && i._uid || i.type === "link") && (this._insertRelations(
634
- i,
632
+ for (const i in n)
633
+ (n.component && n._uid || n.type === "link") && (this._insertRelations(
635
634
  n,
635
+ i,
636
636
  t,
637
637
  s
638
638
  ), this._insertLinks(
639
- i,
640
639
  n,
640
+ i,
641
641
  s
642
- )), r(i[n]);
642
+ )), r(n[i]);
643
643
  }
644
644
  }
645
645
  };
@@ -648,17 +648,17 @@ class ke {
648
648
  async resolveLinks(e, t, s) {
649
649
  let r = [];
650
650
  if (e.link_uuids) {
651
- const i = e.link_uuids.length, n = [], l = 50;
652
- for (let a = 0; a < i; a += l) {
653
- const c = Math.min(i, a + l);
654
- n.push(e.link_uuids.slice(a, c));
651
+ const n = e.link_uuids.length, i = [], l = 50;
652
+ for (let a = 0; a < n; a += l) {
653
+ const c = Math.min(n, a + l);
654
+ i.push(e.link_uuids.slice(a, c));
655
655
  }
656
- for (let a = 0; a < n.length; a++)
656
+ for (let a = 0; a < i.length; a++)
657
657
  (await this.getStories({
658
658
  per_page: l,
659
659
  language: t.language,
660
660
  version: t.version,
661
- by_uuids: n[a].join(",")
661
+ by_uuids: i[a].join(",")
662
662
  })).data.stories.forEach(
663
663
  (c) => {
664
664
  r.push(c);
@@ -666,9 +666,9 @@ class ke {
666
666
  );
667
667
  } else
668
668
  r = e.links;
669
- r.forEach((i) => {
670
- this.links[s][i.uuid] = {
671
- ...i,
669
+ r.forEach((n) => {
670
+ this.links[s][n.uuid] = {
671
+ ...n,
672
672
  _stopResolving: !0
673
673
  };
674
674
  });
@@ -676,53 +676,53 @@ class ke {
676
676
  async resolveRelations(e, t, s) {
677
677
  let r = [];
678
678
  if (e.rel_uuids) {
679
- const i = e.rel_uuids.length, n = [], l = 50;
680
- for (let a = 0; a < i; a += l) {
681
- const c = Math.min(i, a + l);
682
- n.push(e.rel_uuids.slice(a, c));
679
+ const n = e.rel_uuids.length, i = [], l = 50;
680
+ for (let a = 0; a < n; a += l) {
681
+ const c = Math.min(n, a + l);
682
+ i.push(e.rel_uuids.slice(a, c));
683
683
  }
684
- for (let a = 0; a < n.length; a++)
684
+ for (let a = 0; a < i.length; a++)
685
685
  (await this.getStories({
686
686
  per_page: l,
687
687
  language: t.language,
688
688
  version: t.version,
689
- by_uuids: n[a].join(","),
689
+ by_uuids: i[a].join(","),
690
690
  excluding_fields: t.excluding_fields
691
691
  })).data.stories.forEach((c) => {
692
692
  r.push(c);
693
693
  });
694
694
  } else
695
695
  r = e.rels;
696
- r && r.length > 0 && r.forEach((i) => {
697
- this.relations[s][i.uuid] = {
698
- ...i,
696
+ r && r.length > 0 && r.forEach((n) => {
697
+ this.relations[s][n.uuid] = {
698
+ ...n,
699
699
  _stopResolving: !0
700
700
  };
701
701
  });
702
702
  }
703
703
  async resolveStories(e, t, s) {
704
- var r, i;
705
- let n = [];
706
- if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (i = e.link_uuids) != null && i.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
704
+ var r, n;
705
+ let i = [];
706
+ if (this.links[s] = {}, this.relations[s] = {}, 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, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
707
707
  for (const l in this.relations[s])
708
708
  this.iterateTree(
709
709
  this.relations[s][l],
710
- n,
710
+ i,
711
711
  s
712
712
  );
713
- e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((l) => {
714
- this.iterateTree(l, n, s);
713
+ e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
714
+ this.iterateTree(l, i, s);
715
715
  }), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
716
716
  }
717
717
  async cacheResponse(e, t, s) {
718
718
  (typeof s > "u" || !s) && (s = 0);
719
- const r = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
719
+ const r = this.helpers.stringify({ url: e, params: t }), n = this.cacheProvider();
720
720
  if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
721
- const n = await i.get(r);
722
- if (n)
723
- return Promise.resolve(n);
721
+ const i = await n.get(r);
722
+ if (i)
723
+ return Promise.resolve(i);
724
724
  }
725
- return new Promise(async (n, l) => {
725
+ return new Promise(async (i, l) => {
726
726
  var a;
727
727
  try {
728
728
  const c = await this.throttle("get", e, t);
@@ -736,10 +736,10 @@ class ke {
736
736
  const p = this.resolveCounter = ++this.resolveCounter % 1e3;
737
737
  await this.resolveStories(u.data, t, `${p}`);
738
738
  }
739
- return 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] = t.cv ? t.cv : u.data.cv), n(u);
739
+ return t.version === "published" && e != "/cdn/spaces/me" && await n.set(r, u), u.data.cv && t.token && (t.version === "draft" && g[t.token] != u.data.cv && await this.flushCache(), g[t.token] = t.cv ? t.cv : u.data.cv), i(u);
740
740
  } catch (c) {
741
741
  if (c.response && c.response.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
742
- return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(n).catch(l);
742
+ return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(i).catch(l);
743
743
  l(c);
744
744
  }
745
745
  });
@@ -806,28 +806,32 @@ const xe = (o = {}) => {
806
806
  }, Re = (o) => {
807
807
  if (typeof o != "object" || typeof o._editable > "u")
808
808
  return {};
809
- const e = JSON.parse(
810
- o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
811
- );
812
- return e ? {
813
- "data-blok-c": JSON.stringify(e),
814
- "data-blok-uid": e.id + "-" + e.uid
815
- } : {};
809
+ try {
810
+ const e = JSON.parse(
811
+ o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
812
+ );
813
+ return e ? {
814
+ "data-blok-c": JSON.stringify(e),
815
+ "data-blok-uid": e.id + "-" + e.uid
816
+ } : {};
817
+ } catch {
818
+ return {};
819
+ }
816
820
  };
817
821
  let T, I = "https://app.storyblok.com/f/storyblok-v2-latest.js";
818
822
  const we = (o, e, t = {}) => {
819
823
  var s;
820
- const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", i = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
824
+ const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
821
825
  "_storyblok"
822
826
  ) === o;
823
- if (!(!r || !i)) {
827
+ if (!(!r || !n)) {
824
828
  if (!o) {
825
829
  console.warn("Story ID is not defined. Please provide a valid ID.");
826
830
  return;
827
831
  }
828
832
  window.storyblokRegisterEvent(() => {
829
- new window.StoryblokBridge(t).on(["input", "published", "change"], (n) => {
830
- n.action === "input" && n.story.id === o ? e(n.story) : (n.action === "change" || n.action === "published") && n.storyId === o && window.location.reload();
833
+ new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
834
+ i.action === "input" && i.story.id === o ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === o && window.location.reload();
831
835
  });
832
836
  });
833
837
  }
@@ -836,15 +840,15 @@ const we = (o, e, t = {}) => {
836
840
  const {
837
841
  bridge: s,
838
842
  accessToken: r,
839
- use: i = [],
840
- apiOptions: n = {},
843
+ use: n = [],
844
+ apiOptions: i = {},
841
845
  richText: l = {},
842
846
  bridgeUrl: a
843
847
  } = o;
844
- n.accessToken = n.accessToken || r;
845
- const c = { bridge: s, apiOptions: n };
848
+ i.accessToken = i.accessToken || r;
849
+ const c = { bridge: s, apiOptions: i };
846
850
  let u = {};
847
- i.forEach((m) => {
851
+ n.forEach((m) => {
848
852
  u = { ...u, ...m(c) };
849
853
  }), a && (I = a);
850
854
  const p = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
@@ -877,12 +881,12 @@ const we = (o, e, t = {}) => {
877
881
  e({
878
882
  value: s
879
883
  });
880
- const r = typeof R(t.blok.component) != "string", i = N("VueSDKOptions"), n = S(t.blok.component);
881
- return r || (i.enableFallbackComponent ? (n.value = i.customFallbackComponent ?? "FallbackComponent", typeof R(n.value) == "string" && console.error(
882
- `Is the Fallback component "${n.value}" registered properly?`
884
+ const r = typeof R(t.blok.component) != "string", n = N("VueSDKOptions"), i = S(t.blok.component);
885
+ return r || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof R(i.value) == "string" && console.error(
886
+ `Is the Fallback component "${i.value}" registered properly?`
883
887
  )) : console.error(
884
888
  `Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`
885
- )), (l, a) => (P(), L(R(n.value), M({
889
+ )), (l, a) => (P(), L(R(i.value), M({
886
890
  ref_key: "blokRef",
887
891
  ref: s
888
892
  }, { ...l.$props, ...l.$attrs }), null, 16));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Storyblok directive for get editable elements.",
5
5
  "main": "./dist/storyblok-vue.js",
6
6
  "module": "./dist/storyblok-vue.mjs",
@@ -25,13 +25,13 @@
25
25
  "prepublishOnly": "npm run build && cp ../README.md ./"
26
26
  },
27
27
  "dependencies": {
28
- "@storyblok/js": "^3.0.0"
28
+ "@storyblok/js": "^3.0.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@babel/core": "^7.23.6",
32
- "@cypress/vite-dev-server": "^5.0.6",
32
+ "@cypress/vite-dev-server": "^5.0.7",
33
33
  "@cypress/vue": "^6.0.0",
34
- "@vitejs/plugin-vue": "^4.5.2",
34
+ "@vitejs/plugin-vue": "^5.0.2",
35
35
  "@vue/babel-preset-app": "^5.0.8",
36
36
  "@vue/test-utils": "2.4.3",
37
37
  "@vue/tsconfig": "^0.1.3",
@@ -39,12 +39,12 @@
39
39
  "babel-jest": "^29.4.3",
40
40
  "cypress": "^13.5.1",
41
41
  "eslint-plugin-cypress": "^2.15.1",
42
- "eslint-plugin-jest": "^27.6.0",
42
+ "eslint-plugin-jest": "^27.6.1",
43
43
  "jest": "^29.6.4",
44
44
  "typescript": "^4.9.5",
45
- "vite": "^5.0.8",
45
+ "vite": "^5.0.10",
46
46
  "vue": "^3.3.4",
47
- "vue-tsc": "^1.8.25"
47
+ "vue-tsc": "^1.8.27"
48
48
  },
49
49
  "babel": {
50
50
  "presets": [