@storyblok/astro 4.1.0-next.1 → 4.1.0-next.2
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/storyblok-astro.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(k,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(k=typeof globalThis<"u"?globalThis:k||self,N(k.storyblokAstro={}))})(this,function(k){"use strict";function N(o,e,r){const i="virtual:storyblok-init",s="\0"+i;return{name:"vite-plugin-storyblok-init",async resolveId(l){if(l===i)return s},async load(l){if(l===s)return`
|
|
2
2
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
3
3
|
const { storyblokApi } = storyblokInit({
|
|
4
4
|
accessToken: "${o}",
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
apiOptions: ${JSON.stringify(r)},
|
|
7
7
|
});
|
|
8
8
|
export const storyblokApiInstance = storyblokApi;
|
|
9
|
-
`}}}const
|
|
9
|
+
`}}}const Xt=/[\p{Lu}]/u,Zt=/[\p{Ll}]/u,gt=/^[\p{Lu}](?![\p{Lu}])/gu,ht=/([\p{Alpha}\p{N}_]|$)/u,et=/[_.\- ]+/,Qt=new RegExp("^"+et.source),yt=new RegExp(et.source+ht.source,"gu"),bt=new RegExp("\\d+"+ht.source,"gu"),Vt=(o,e,r,i)=>{let s=!1,l=!1,u=!1,h=!1;for(let d=0;d<o.length;d++){const g=o[d];h=d>2?o[d-3]==="-":!0,s&&Xt.test(g)?(o=o.slice(0,d)+"-"+o.slice(d),s=!1,u=l,l=!0,d++):l&&u&&Zt.test(g)&&(!h||i)?(o=o.slice(0,d-1)+"-"+o.slice(d-1),u=l,l=!1,s=!0):(s=e(g)===g&&r(g)!==g,u=l,l=r(g)===g&&e(g)!==g)}return o},te=(o,e)=>(gt.lastIndex=0,o.replaceAll(gt,r=>e(r))),ee=(o,e)=>(yt.lastIndex=0,bt.lastIndex=0,o.replaceAll(bt,(r,i,s)=>["_","-"].includes(o.charAt(s+r.length))?r:e(r)).replaceAll(yt,(r,i)=>e(i)));function mt(o,e){if(!(typeof o=="string"||Array.isArray(o)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(o)?o=o.map(l=>l.trim()).filter(l=>l.length).join("-"):o=o.trim(),o.length===0)return"";const r=e.locale===!1?l=>l.toLowerCase():l=>l.toLocaleLowerCase(e.locale),i=e.locale===!1?l=>l.toUpperCase():l=>l.toLocaleUpperCase(e.locale);return o.length===1?et.test(o)?"":e.pascalCase?i(o):r(o):(o!==r(o)&&(o=Vt(o,r,i,e.preserveConsecutiveUppercase)),o=o.replace(Qt,""),o=e.preserveConsecutiveUppercase?te(o,r):r(o),e.pascalCase&&(o=i(o.charAt(0))+o.slice(1)),ee(o,i))}function re(o,e,r,i){const s="virtual:storyblok-components",l="\0"+s;return{name:"vite-plugin-storyblok-components",async resolveId(u){if(u===s)return l},async load(u){if(u===l){const h=[],d=[];for await(const[v,T]of Object.entries(e)){const w=await this.resolve("/"+o+"/"+T+".astro");if(w)h.push(`import ${mt(v)} from "${w.id}"`);else if(r)d.push(v);else throw new Error(`Component could not be found for blok "${v}"! Does "${"/"+o+"/"+T}.astro" exist?`)}let g="";if(r)if(g=",FallbackComponent",i){const v=await this.resolve("/"+o+"/"+i+".astro");if(!v)throw new Error(`Custom fallback component could not be found. Does "${"/"+o+"/"+i}.astro" exist?`);h.push(`import FallbackComponent from "${v.id}"`)}else h.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(e).length)return`${h.join(";")};export default {${Object.keys(e).filter(v=>!d.includes(v)).map(v=>mt(v)).join(",")}${g}}`;if(r)return`${h[0]}; export default {${g.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
10
10
|
Please register your components or enable the fallback component.
|
|
11
|
-
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function re(o){const e="virtual:storyblok-options",r="\0"+e;return{name:"vite-plugin-storyblok-options",async resolveId(i){if(i===e)return r},async load(i){if(i===r)return`export default ${JSON.stringify(o)}`}}}var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ne(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var G={exports:{}};G.exports,function(o,e){var r=200,i="__lodash_hash_undefined__",s=800,l=16,u=9007199254740991,b="[object Arguments]",d="[object Array]",h="[object AsyncFunction]",v="[object Boolean]",w="[object Date]",T="[object Error]",R="[object Function]",k="[object GeneratorFunction]",L="[object Map]",J="[object Number]",er="[object Null]",kt="[object Object]",rr="[object Proxy]",nr="[object RegExp]",or="[object Set]",ar="[object String]",ir="[object Undefined]",sr="[object WeakMap]",lr="[object ArrayBuffer]",cr="[object DataView]",ur="[object Float32Array]",fr="[object Float64Array]",pr="[object Int8Array]",dr="[object Int16Array]",gr="[object Int32Array]",hr="[object Uint8Array]",yr="[object Uint8ClampedArray]",br="[object Uint16Array]",mr="[object Uint32Array]",_r=/[\\^$.*+?()[\]{}|]/g,vr=/^\[object .+?Constructor\]$/,Tr=/^(?:0|[1-9]\d*)$/,y={};y[ur]=y[fr]=y[pr]=y[dr]=y[gr]=y[hr]=y[yr]=y[br]=y[mr]=!0,y[b]=y[d]=y[lr]=y[v]=y[cr]=y[w]=y[T]=y[R]=y[L]=y[J]=y[kt]=y[nr]=y[or]=y[ar]=y[sr]=!1;var It=typeof q=="object"&&q&&q.Object===Object&&q,wr=typeof self=="object"&&self&&self.Object===Object&&self,U=It||wr||Function("return this")(),St=e&&!e.nodeType&&e,D=St&&!0&&o&&!o.nodeType&&o,Ot=D&&D.exports===St,rt=Ot&&It.process,Ct=function(){try{var t=D&&D.require&&D.require("util").types;return t||rt&&rt.binding&&rt.binding("util")}catch{}}(),jt=Ct&&Ct.isTypedArray;function Ar(t,n,a){switch(a.length){case 0:return t.call(n);case 1:return t.call(n,a[0]);case 2:return t.call(n,a[0],a[1]);case 3:return t.call(n,a[0],a[1],a[2])}return t.apply(n,a)}function kr(t,n){for(var a=-1,c=Array(t);++a<t;)c[a]=n(a);return c}function Ir(t){return function(n){return t(n)}}function Sr(t,n){return t==null?void 0:t[n]}function Or(t,n){return function(a){return t(n(a))}}var Cr=Array.prototype,jr=Function.prototype,K=Object.prototype,nt=U["__core-js_shared__"],W=jr.toString,C=K.hasOwnProperty,$t=function(){var t=/[^.]+$/.exec(nt&&nt.keys&&nt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),xt=K.toString,$r=W.call(Object),xr=RegExp("^"+W.call(C).replace(_r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Y=Ot?U.Buffer:void 0,Et=U.Symbol,Rt=U.Uint8Array,Mt=Y?Y.allocUnsafe:void 0,Pt=Or(Object.getPrototypeOf,Object),Nt=Object.create,Er=K.propertyIsEnumerable,Rr=Cr.splice,$=Et?Et.toStringTag:void 0,X=function(){try{var t=it(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Mr=Y?Y.isBuffer:void 0,zt=Math.max,Pr=Date.now,Lt=it(U,"Map"),F=it(Object,"create"),Nr=function(){function t(){}return function(n){if(!E(n))return{};if(Nt)return Nt(n);t.prototype=n;var a=new t;return t.prototype=void 0,a}}();function x(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var c=t[n];this.set(c[0],c[1])}}function zr(){this.__data__=F?F(null):{},this.size=0}function Lr(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function Ur(t){var n=this.__data__;if(F){var a=n[t];return a===i?void 0:a}return C.call(n,t)?n[t]:void 0}function Dr(t){var n=this.__data__;return F?n[t]!==void 0:C.call(n,t)}function Fr(t,n){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=F&&n===void 0?i:n,this}x.prototype.clear=zr,x.prototype.delete=Lr,x.prototype.get=Ur,x.prototype.has=Dr,x.prototype.set=Fr;function j(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var c=t[n];this.set(c[0],c[1])}}function Br(){this.__data__=[],this.size=0}function Hr(t){var n=this.__data__,a=Z(n,t);if(a<0)return!1;var c=n.length-1;return a==c?n.pop():Rr.call(n,a,1),--this.size,!0}function qr(t){var n=this.__data__,a=Z(n,t);return a<0?void 0:n[a][1]}function Gr(t){return Z(this.__data__,t)>-1}function Jr(t,n){var a=this.__data__,c=Z(a,t);return c<0?(++this.size,a.push([t,n])):a[c][1]=n,this}j.prototype.clear=Br,j.prototype.delete=Hr,j.prototype.get=qr,j.prototype.has=Gr,j.prototype.set=Jr;function M(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var c=t[n];this.set(c[0],c[1])}}function Kr(){this.size=0,this.__data__={hash:new x,map:new(Lt||j),string:new x}}function Wr(t){var n=V(this,t).delete(t);return this.size-=n?1:0,n}function Yr(t){return V(this,t).get(t)}function Xr(t){return V(this,t).has(t)}function Zr(t,n){var a=V(this,t),c=a.size;return a.set(t,n),this.size+=a.size==c?0:1,this}M.prototype.clear=Kr,M.prototype.delete=Wr,M.prototype.get=Yr,M.prototype.has=Xr,M.prototype.set=Zr;function P(t){var n=this.__data__=new j(t);this.size=n.size}function Qr(){this.__data__=new j,this.size=0}function Vr(t){var n=this.__data__,a=n.delete(t);return this.size=n.size,a}function tn(t){return this.__data__.get(t)}function en(t){return this.__data__.has(t)}function rn(t,n){var a=this.__data__;if(a instanceof j){var c=a.__data__;if(!Lt||c.length<r-1)return c.push([t,n]),this.size=++a.size,this;a=this.__data__=new M(c)}return a.set(t,n),this.size=a.size,this}P.prototype.clear=Qr,P.prototype.delete=Vr,P.prototype.get=tn,P.prototype.has=en,P.prototype.set=rn;function nn(t,n){var a=ct(t),c=!a&<(t),p=!a&&!c&&Ht(t),g=!a&&!c&&!p&&Gt(t),m=a||c||p||g,f=m?kr(t.length,String):[],_=f.length;for(var S in t)(n||C.call(t,S))&&!(m&&(S=="length"||p&&(S=="offset"||S=="parent")||g&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||Ft(S,_)))&&f.push(S);return f}function ot(t,n,a){(a!==void 0&&!tt(t[n],a)||a===void 0&&!(n in t))&&at(t,n,a)}function on(t,n,a){var c=t[n];(!(C.call(t,n)&&tt(c,a))||a===void 0&&!(n in t))&&at(t,n,a)}function Z(t,n){for(var a=t.length;a--;)if(tt(t[a][0],n))return a;return-1}function at(t,n,a){n=="__proto__"&&X?X(t,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):t[n]=a}var an=_n();function Q(t){return t==null?t===void 0?ir:er:$&&$ in Object(t)?vn(t):Sn(t)}function Ut(t){return B(t)&&Q(t)==b}function sn(t){if(!E(t)||kn(t))return!1;var n=ft(t)?xr:vr;return n.test($n(t))}function ln(t){return B(t)&&qt(t.length)&&!!y[Q(t)]}function cn(t){if(!E(t))return In(t);var n=Bt(t),a=[];for(var c in t)c=="constructor"&&(n||!C.call(t,c))||a.push(c);return a}function Dt(t,n,a,c,p){t!==n&&an(n,function(g,m){if(p||(p=new P),E(g))un(t,n,m,a,Dt,c,p);else{var f=c?c(st(t,m),g,m+"",t,n,p):void 0;f===void 0&&(f=g),ot(t,m,f)}},Jt)}function un(t,n,a,c,p,g,m){var f=st(t,a),_=st(n,a),S=m.get(_);if(S){ot(t,a,S);return}var I=g?g(f,_,a+"",t,n,m):void 0,H=I===void 0;if(H){var pt=ct(_),dt=!pt&&Ht(_),Wt=!pt&&!dt&&Gt(_);I=_,pt||dt||Wt?ct(f)?I=f:xn(f)?I=yn(f):dt?(H=!1,I=dn(_,!0)):Wt?(H=!1,I=hn(_,!0)):I=[]:En(_)||lt(_)?(I=f,lt(f)?I=Rn(f):(!E(f)||ft(f))&&(I=Tn(_))):H=!1}H&&(m.set(_,I),p(I,_,c,g,m),m.delete(_)),ot(t,a,I)}function fn(t,n){return Cn(On(t,n,Kt),t+"")}var pn=X?function(t,n){return X(t,"toString",{configurable:!0,enumerable:!1,value:Pn(n),writable:!0})}:Kt;function dn(t,n){if(n)return t.slice();var a=t.length,c=Mt?Mt(a):new t.constructor(a);return t.copy(c),c}function gn(t){var n=new t.constructor(t.byteLength);return new Rt(n).set(new Rt(t)),n}function hn(t,n){var a=n?gn(t.buffer):t.buffer;return new t.constructor(a,t.byteOffset,t.length)}function yn(t,n){var a=-1,c=t.length;for(n||(n=Array(c));++a<c;)n[a]=t[a];return n}function bn(t,n,a,c){var p=!a;a||(a={});for(var g=-1,m=n.length;++g<m;){var f=n[g],_=c?c(a[f],t[f],f,a,t):void 0;_===void 0&&(_=t[f]),p?at(a,f,_):on(a,f,_)}return a}function mn(t){return fn(function(n,a){var c=-1,p=a.length,g=p>1?a[p-1]:void 0,m=p>2?a[2]:void 0;for(g=t.length>3&&typeof g=="function"?(p--,g):void 0,m&&wn(a[0],a[1],m)&&(g=p<3?void 0:g,p=1),n=Object(n);++c<p;){var f=a[c];f&&t(n,f,c,g)}return n})}function _n(t){return function(n,a,c){for(var p=-1,g=Object(n),m=c(n),f=m.length;f--;){var _=m[t?f:++p];if(a(g[_],_,g)===!1)break}return n}}function V(t,n){var a=t.__data__;return An(n)?a[typeof n=="string"?"string":"hash"]:a.map}function it(t,n){var a=Sr(t,n);return sn(a)?a:void 0}function vn(t){var n=C.call(t,$),a=t[$];try{t[$]=void 0;var c=!0}catch{}var p=xt.call(t);return c&&(n?t[$]=a:delete t[$]),p}function Tn(t){return typeof t.constructor=="function"&&!Bt(t)?Nr(Pt(t)):{}}function Ft(t,n){var a=typeof t;return n=n??u,!!n&&(a=="number"||a!="symbol"&&Tr.test(t))&&t>-1&&t%1==0&&t<n}function wn(t,n,a){if(!E(a))return!1;var c=typeof n;return(c=="number"?ut(a)&&Ft(n,a.length):c=="string"&&n in a)?tt(a[n],t):!1}function An(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}function kn(t){return!!$t&&$t in t}function Bt(t){var n=t&&t.constructor,a=typeof n=="function"&&n.prototype||K;return t===a}function In(t){var n=[];if(t!=null)for(var a in Object(t))n.push(a);return n}function Sn(t){return xt.call(t)}function On(t,n,a){return n=zt(n===void 0?t.length-1:n,0),function(){for(var c=arguments,p=-1,g=zt(c.length-n,0),m=Array(g);++p<g;)m[p]=c[n+p];p=-1;for(var f=Array(n+1);++p<n;)f[p]=c[p];return f[n]=a(m),Ar(t,this,f)}}function st(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}var Cn=jn(pn);function jn(t){var n=0,a=0;return function(){var c=Pr(),p=l-(c-a);if(a=c,p>0){if(++n>=s)return arguments[0]}else n=0;return t.apply(void 0,arguments)}}function $n(t){if(t!=null){try{return W.call(t)}catch{}try{return t+""}catch{}}return""}function tt(t,n){return t===n||t!==t&&n!==n}var lt=Ut(function(){return arguments}())?Ut:function(t){return B(t)&&C.call(t,"callee")&&!Er.call(t,"callee")},ct=Array.isArray;function ut(t){return t!=null&&qt(t.length)&&!ft(t)}function xn(t){return B(t)&&ut(t)}var Ht=Mr||Nn;function ft(t){if(!E(t))return!1;var n=Q(t);return n==R||n==k||n==h||n==rr}function qt(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=u}function E(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}function B(t){return t!=null&&typeof t=="object"}function En(t){if(!B(t)||Q(t)!=kt)return!1;var n=Pt(t);if(n===null)return!0;var a=C.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&W.call(a)==$r}var Gt=jt?Ir(jt):ln;function Rn(t){return bn(t,Jt(t))}function Jt(t){return ut(t)?nn(t,!0):cn(t)}var Mn=mn(function(t,n,a,c){Dt(t,n,a,c)});function Pn(t){return function(){return t}}function Kt(t){return t}function Nn(){return!1}o.exports=Mn}(G,G.exports);var oe=G.exports;const ae=ne(oe);function ie(o){let e;function r(i,s){var l,u,b,d,h,v,w;if((s==null?void 0:s.type)==="AwaitExpression"&&((u=(l=s==null?void 0:s.argument)==null?void 0:l.callee)==null?void 0:u.name)==="useStoryblok"){const T=(b=s==null?void 0:s.argument)==null?void 0:b.arguments;((d=T[1])==null?void 0:d.type)==="ObjectExpression"&&(e={...e,apiOptions:_t((h=T[1])==null?void 0:h.properties)}),((v=T[2])==null?void 0:v.type)==="ObjectExpression"&&(e={...e,bridgeOptions:_t((w=T[2])==null?void 0:w.properties)})}}return ae({},o,r),e}function _t(o){return o.reduce((e,{key:r,value:i})=>{const{type:s}=i;return e[r.name]=s==="Literal"?i.value:s==="ArrayExpression"?i.elements.map(l=>l.value):i.value,e},{})}function se(o){let e={resolveRelations:[]};function r(i){i&&(Array.isArray(i)?e.resolveRelations.push(...i):e.resolveRelations.push(i))}for(const i of o)if(i.options){const{apiOptions:s,bridgeOptions:l}=i.options;if(r(s==null?void 0:s.resolve_relations),l){const{resolveRelations:u,...b}=l;r(u),Object.assign(e,b)}}return e.resolveRelations=[...new Set(e.resolveRelations)],e}let z=[];function le(){let o=[];const e="virtual:storyblok-bridge",r="\0"+e;let i=null,s=null;return{name:"vite-plugin-storyblok-bridge",async resolveId(l){if(l===e)return r},async transform(l,u){var w;if(u.includes("node_modules")&&!u.includes("/pages/")||!l.includes("useStoryblok")||!((w=this.getModuleInfo(u).meta)!=null&&w.astro))return;const[,...d]=u.split("src/pages/"),h=d.join("/").replace(".astro",""),v=ie(this.parse(l));z.length&&(o=z.filter(T=>T.url!==h)),o.push({url:h,options:v}),i&&(s&&clearTimeout(s),s=setTimeout(()=>{ce(z,o)||(z.length!==0&&(i.restart(),console.info("Updating bridge options...")),z=[...o])},1e3))},async load(l){if(l===r)return`export const bridgeOptions = ${JSON.stringify(se(o))}`},configureServer(l){i=l}}}function ce(o=[],e=[]){return e.every(({url:r,options:i})=>{const s=o.find(l=>(l==null?void 0:l.url)===r);return s&&JSON.stringify(i)===JSON.stringify(s.options)})}let vt=!1;const Tt=[],ue=o=>new Promise((e,r)=>{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}vt?s():Tt.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const i=document.createElement("script");i.async=!0,i.src=o,i.id="storyblok-javascript-bridge",i.onerror=s=>r(s),i.onload=s=>{Tt.forEach(l=>l()),vt=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(i)});var fe=Object.defineProperty,pe=(o,e,r)=>e in o?fe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,O=(o,e,r)=>(pe(o,typeof e!="symbol"?e+"":e,r),r);class de{constructor(){O(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),O(this,"getOptionsPage",(e,r=25,i=1)=>({...e,per_page:r,page:i})),O(this,"delay",e=>new Promise(r=>setTimeout(r,e))),O(this,"arrayFrom",(e=0,r)=>[...Array(e)].map(r)),O(this,"range",(e=0,r=e)=>{const i=Math.abs(r-e)||0,s=e<r?1:-1;return this.arrayFrom(i,(l,u)=>u*s+e)}),O(this,"asyncMap",async(e,r)=>Promise.all(e.map(r))),O(this,"flatMap",(e=[],r)=>e.map(r).reduce((i,s)=>[...i,...s],[])),O(this,"escapeHTML",function(e){const r={"&":"&","<":"<",">":">",'"':""","'":"'"},i=/[&<>"']/g,s=RegExp(i.source);return e&&s.test(e)?e.replace(i,l=>r[l]):e})}stringify(e,r,i){const s=[];for(const l in e){if(!Object.prototype.hasOwnProperty.call(e,l))continue;const u=e[l],b=i?"":encodeURIComponent(l);let d;typeof u=="object"?d=this.stringify(u,r?r+encodeURIComponent("["+b+"]"):b,Array.isArray(u)):d=(r?r+encodeURIComponent("["+b+"]"):b)+"="+encodeURIComponent(u),s.push(d)}return s.join("&")}getRegionURL(e){const r="api.storyblok.com",i="api-us.storyblok.com",s="app.storyblokchina.cn",l="api-ap.storyblok.com",u="api-ca.storyblok.com";switch(e){case"us":return i;case"cn":return s;case"ap":return l;case"ca":return u;default:return r}}}const ge=function(o,e){const r={};for(const i in o){const s=o[i];e.indexOf(i)>-1&&s!==null&&(r[i]=s)}return r},he=o=>o==="email",ye=()=>({singleTag:"hr"}),be=()=>({tag:"blockquote"}),me=()=>({tag:"ul"}),_e=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),ve=()=>({singleTag:"br"}),Te=o=>({tag:`h${o.attrs.level}`}),we=o=>({singleTag:[{tag:"img",attrs:ge(o.attrs,["src","alt","title"])}]}),Ae=()=>({tag:"li"}),ke=()=>({tag:"ol"}),Ie=()=>({tag:"p"}),Se=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),Oe=()=>({tag:"b"}),Ce=()=>({tag:"s"}),je=()=>({tag:"u"}),$e=()=>({tag:"strong"}),xe=()=>({tag:"code"}),Ee=()=>({tag:"i"}),Re=o=>{if(!o.attrs)return{tag:""};const e=new de().escapeHTML,r={...o.attrs},{linktype:i="url"}=o.attrs;if(delete r.linktype,r.href&&(r.href=e(o.attrs.href||"")),he(i)&&(r.href=`mailto:${r.href}`),r.anchor&&(r.href=`${r.href}#${r.anchor}`,delete r.anchor),r.custom){for(const s in r.custom)r[s]=r.custom[s];delete r.custom}return{tag:[{tag:"a",attrs:r}]}},Me=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Pe=()=>({tag:"sub"}),Ne=()=>({tag:"sup"}),ze=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Le=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Ue=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},wt={nodes:{horizontal_rule:ye,blockquote:be,bullet_list:me,code_block:_e,hard_break:ve,heading:Te,image:we,list_item:Ae,ordered_list:ke,paragraph:Ie,emoji:Se},marks:{bold:Oe,strike:Ce,underline:je,strong:$e,code:xe,italic:Ee,link:Re,styled:Me,subscript:Pe,superscript:Ne,anchor:ze,highlight:Le,textStyle:Ue}},De=function(o){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,i=RegExp(r.source);return o&&i.test(o)?o.replace(r,s=>e[s]):o};class At{constructor(e){O(this,"marks"),O(this,"nodes"),e||(e=wt),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,r){this.nodes[e]=r}addMark(e,r){this.marks[e]=r}render(e,r={optimizeImages:!1}){if(e&&e.content&&Array.isArray(e.content)){let i="";return e.content.forEach(s=>{i+=this.renderNode(s)}),r.optimizeImages?this.optimizeImages(i,r.optimizeImages):i}return console.warn(`The render method must receive an Object with a "content" field.
|
|
11
|
+
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function ne(o){const e="virtual:storyblok-options",r="\0"+e;return{name:"vite-plugin-storyblok-options",async resolveId(i){if(i===e)return r},async load(i){if(i===r)return`export default ${JSON.stringify(o)}`}}}var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function oe(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var G={exports:{}};G.exports,function(o,e){var r=200,i="__lodash_hash_undefined__",s=800,l=16,u=9007199254740991,h="[object Arguments]",d="[object Array]",g="[object AsyncFunction]",v="[object Boolean]",T="[object Date]",w="[object Error]",M="[object Function]",A="[object GeneratorFunction]",L="[object Map]",J="[object Number]",rr="[object Null]",It="[object Object]",nr="[object Proxy]",or="[object RegExp]",ar="[object Set]",ir="[object String]",sr="[object Undefined]",lr="[object WeakMap]",cr="[object ArrayBuffer]",ur="[object DataView]",fr="[object Float32Array]",pr="[object Float64Array]",dr="[object Int8Array]",gr="[object Int16Array]",hr="[object Int32Array]",yr="[object Uint8Array]",br="[object Uint8ClampedArray]",mr="[object Uint16Array]",_r="[object Uint32Array]",vr=/[\\^$.*+?()[\]{}|]/g,Tr=/^\[object .+?Constructor\]$/,wr=/^(?:0|[1-9]\d*)$/,b={};b[fr]=b[pr]=b[dr]=b[gr]=b[hr]=b[yr]=b[br]=b[mr]=b[_r]=!0,b[h]=b[d]=b[cr]=b[v]=b[ur]=b[T]=b[w]=b[M]=b[L]=b[J]=b[It]=b[or]=b[ar]=b[ir]=b[lr]=!1;var St=typeof q=="object"&&q&&q.Object===Object&&q,kr=typeof self=="object"&&self&&self.Object===Object&&self,D=St||kr||Function("return this")(),Ot=e&&!e.nodeType&&e,U=Ot&&!0&&o&&!o.nodeType&&o,Ct=U&&U.exports===Ot,rt=Ct&&St.process,jt=function(){try{var t=U&&U.require&&U.require("util").types;return t||rt&&rt.binding&&rt.binding("util")}catch{}}(),$t=jt&&jt.isTypedArray;function Ar(t,n,a){switch(a.length){case 0:return t.call(n);case 1:return t.call(n,a[0]);case 2:return t.call(n,a[0],a[1]);case 3:return t.call(n,a[0],a[1],a[2])}return t.apply(n,a)}function Ir(t,n){for(var a=-1,c=Array(t);++a<t;)c[a]=n(a);return c}function Sr(t){return function(n){return t(n)}}function Or(t,n){return t==null?void 0:t[n]}function Cr(t,n){return function(a){return t(n(a))}}var jr=Array.prototype,$r=Function.prototype,K=Object.prototype,nt=D["__core-js_shared__"],W=$r.toString,C=K.hasOwnProperty,xt=function(){var t=/[^.]+$/.exec(nt&&nt.keys&&nt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Et=K.toString,xr=W.call(Object),Er=RegExp("^"+W.call(C).replace(vr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Y=Ct?D.Buffer:void 0,Mt=D.Symbol,Rt=D.Uint8Array,Pt=Y?Y.allocUnsafe:void 0,Nt=Cr(Object.getPrototypeOf,Object),zt=Object.create,Mr=K.propertyIsEnumerable,Rr=jr.splice,$=Mt?Mt.toStringTag:void 0,X=function(){try{var t=it(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Pr=Y?Y.isBuffer:void 0,Lt=Math.max,Nr=Date.now,Dt=it(D,"Map"),F=it(Object,"create"),zr=function(){function t(){}return function(n){if(!E(n))return{};if(zt)return zt(n);t.prototype=n;var a=new t;return t.prototype=void 0,a}}();function x(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var c=t[n];this.set(c[0],c[1])}}function Lr(){this.__data__=F?F(null):{},this.size=0}function Dr(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function Ur(t){var n=this.__data__;if(F){var a=n[t];return a===i?void 0:a}return C.call(n,t)?n[t]:void 0}function Fr(t){var n=this.__data__;return F?n[t]!==void 0:C.call(n,t)}function Br(t,n){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=F&&n===void 0?i:n,this}x.prototype.clear=Lr,x.prototype.delete=Dr,x.prototype.get=Ur,x.prototype.has=Fr,x.prototype.set=Br;function j(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var c=t[n];this.set(c[0],c[1])}}function Hr(){this.__data__=[],this.size=0}function qr(t){var n=this.__data__,a=Z(n,t);if(a<0)return!1;var c=n.length-1;return a==c?n.pop():Rr.call(n,a,1),--this.size,!0}function Gr(t){var n=this.__data__,a=Z(n,t);return a<0?void 0:n[a][1]}function Jr(t){return Z(this.__data__,t)>-1}function Kr(t,n){var a=this.__data__,c=Z(a,t);return c<0?(++this.size,a.push([t,n])):a[c][1]=n,this}j.prototype.clear=Hr,j.prototype.delete=qr,j.prototype.get=Gr,j.prototype.has=Jr,j.prototype.set=Kr;function R(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var c=t[n];this.set(c[0],c[1])}}function Wr(){this.size=0,this.__data__={hash:new x,map:new(Dt||j),string:new x}}function Yr(t){var n=V(this,t).delete(t);return this.size-=n?1:0,n}function Xr(t){return V(this,t).get(t)}function Zr(t){return V(this,t).has(t)}function Qr(t,n){var a=V(this,t),c=a.size;return a.set(t,n),this.size+=a.size==c?0:1,this}R.prototype.clear=Wr,R.prototype.delete=Yr,R.prototype.get=Xr,R.prototype.has=Zr,R.prototype.set=Qr;function P(t){var n=this.__data__=new j(t);this.size=n.size}function Vr(){this.__data__=new j,this.size=0}function tn(t){var n=this.__data__,a=n.delete(t);return this.size=n.size,a}function en(t){return this.__data__.get(t)}function rn(t){return this.__data__.has(t)}function nn(t,n){var a=this.__data__;if(a instanceof j){var c=a.__data__;if(!Dt||c.length<r-1)return c.push([t,n]),this.size=++a.size,this;a=this.__data__=new R(c)}return a.set(t,n),this.size=a.size,this}P.prototype.clear=Vr,P.prototype.delete=tn,P.prototype.get=en,P.prototype.has=rn,P.prototype.set=nn;function on(t,n){var a=ct(t),c=!a&<(t),p=!a&&!c&&qt(t),y=!a&&!c&&!p&&Jt(t),m=a||c||p||y,f=m?Ir(t.length,String):[],_=f.length;for(var S in t)(n||C.call(t,S))&&!(m&&(S=="length"||p&&(S=="offset"||S=="parent")||y&&(S=="buffer"||S=="byteLength"||S=="byteOffset")||Bt(S,_)))&&f.push(S);return f}function ot(t,n,a){(a!==void 0&&!tt(t[n],a)||a===void 0&&!(n in t))&&at(t,n,a)}function an(t,n,a){var c=t[n];(!(C.call(t,n)&&tt(c,a))||a===void 0&&!(n in t))&&at(t,n,a)}function Z(t,n){for(var a=t.length;a--;)if(tt(t[a][0],n))return a;return-1}function at(t,n,a){n=="__proto__"&&X?X(t,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):t[n]=a}var sn=vn();function Q(t){return t==null?t===void 0?sr:rr:$&&$ in Object(t)?Tn(t):On(t)}function Ut(t){return B(t)&&Q(t)==h}function ln(t){if(!E(t)||In(t))return!1;var n=ft(t)?Er:Tr;return n.test(xn(t))}function cn(t){return B(t)&&Gt(t.length)&&!!b[Q(t)]}function un(t){if(!E(t))return Sn(t);var n=Ht(t),a=[];for(var c in t)c=="constructor"&&(n||!C.call(t,c))||a.push(c);return a}function Ft(t,n,a,c,p){t!==n&&sn(n,function(y,m){if(p||(p=new P),E(y))fn(t,n,m,a,Ft,c,p);else{var f=c?c(st(t,m),y,m+"",t,n,p):void 0;f===void 0&&(f=y),ot(t,m,f)}},Kt)}function fn(t,n,a,c,p,y,m){var f=st(t,a),_=st(n,a),S=m.get(_);if(S){ot(t,a,S);return}var I=y?y(f,_,a+"",t,n,m):void 0,H=I===void 0;if(H){var pt=ct(_),dt=!pt&&qt(_),Yt=!pt&&!dt&&Jt(_);I=_,pt||dt||Yt?ct(f)?I=f:En(f)?I=bn(f):dt?(H=!1,I=gn(_,!0)):Yt?(H=!1,I=yn(_,!0)):I=[]:Mn(_)||lt(_)?(I=f,lt(f)?I=Rn(f):(!E(f)||ft(f))&&(I=wn(_))):H=!1}H&&(m.set(_,I),p(I,_,c,y,m),m.delete(_)),ot(t,a,I)}function pn(t,n){return jn(Cn(t,n,Wt),t+"")}var dn=X?function(t,n){return X(t,"toString",{configurable:!0,enumerable:!1,value:Nn(n),writable:!0})}:Wt;function gn(t,n){if(n)return t.slice();var a=t.length,c=Pt?Pt(a):new t.constructor(a);return t.copy(c),c}function hn(t){var n=new t.constructor(t.byteLength);return new Rt(n).set(new Rt(t)),n}function yn(t,n){var a=n?hn(t.buffer):t.buffer;return new t.constructor(a,t.byteOffset,t.length)}function bn(t,n){var a=-1,c=t.length;for(n||(n=Array(c));++a<c;)n[a]=t[a];return n}function mn(t,n,a,c){var p=!a;a||(a={});for(var y=-1,m=n.length;++y<m;){var f=n[y],_=c?c(a[f],t[f],f,a,t):void 0;_===void 0&&(_=t[f]),p?at(a,f,_):an(a,f,_)}return a}function _n(t){return pn(function(n,a){var c=-1,p=a.length,y=p>1?a[p-1]:void 0,m=p>2?a[2]:void 0;for(y=t.length>3&&typeof y=="function"?(p--,y):void 0,m&&kn(a[0],a[1],m)&&(y=p<3?void 0:y,p=1),n=Object(n);++c<p;){var f=a[c];f&&t(n,f,c,y)}return n})}function vn(t){return function(n,a,c){for(var p=-1,y=Object(n),m=c(n),f=m.length;f--;){var _=m[t?f:++p];if(a(y[_],_,y)===!1)break}return n}}function V(t,n){var a=t.__data__;return An(n)?a[typeof n=="string"?"string":"hash"]:a.map}function it(t,n){var a=Or(t,n);return ln(a)?a:void 0}function Tn(t){var n=C.call(t,$),a=t[$];try{t[$]=void 0;var c=!0}catch{}var p=Et.call(t);return c&&(n?t[$]=a:delete t[$]),p}function wn(t){return typeof t.constructor=="function"&&!Ht(t)?zr(Nt(t)):{}}function Bt(t,n){var a=typeof t;return n=n??u,!!n&&(a=="number"||a!="symbol"&&wr.test(t))&&t>-1&&t%1==0&&t<n}function kn(t,n,a){if(!E(a))return!1;var c=typeof n;return(c=="number"?ut(a)&&Bt(n,a.length):c=="string"&&n in a)?tt(a[n],t):!1}function An(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}function In(t){return!!xt&&xt in t}function Ht(t){var n=t&&t.constructor,a=typeof n=="function"&&n.prototype||K;return t===a}function Sn(t){var n=[];if(t!=null)for(var a in Object(t))n.push(a);return n}function On(t){return Et.call(t)}function Cn(t,n,a){return n=Lt(n===void 0?t.length-1:n,0),function(){for(var c=arguments,p=-1,y=Lt(c.length-n,0),m=Array(y);++p<y;)m[p]=c[n+p];p=-1;for(var f=Array(n+1);++p<n;)f[p]=c[p];return f[n]=a(m),Ar(t,this,f)}}function st(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}var jn=$n(dn);function $n(t){var n=0,a=0;return function(){var c=Nr(),p=l-(c-a);if(a=c,p>0){if(++n>=s)return arguments[0]}else n=0;return t.apply(void 0,arguments)}}function xn(t){if(t!=null){try{return W.call(t)}catch{}try{return t+""}catch{}}return""}function tt(t,n){return t===n||t!==t&&n!==n}var lt=Ut(function(){return arguments}())?Ut:function(t){return B(t)&&C.call(t,"callee")&&!Mr.call(t,"callee")},ct=Array.isArray;function ut(t){return t!=null&&Gt(t.length)&&!ft(t)}function En(t){return B(t)&&ut(t)}var qt=Pr||zn;function ft(t){if(!E(t))return!1;var n=Q(t);return n==M||n==A||n==g||n==nr}function Gt(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=u}function E(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}function B(t){return t!=null&&typeof t=="object"}function Mn(t){if(!B(t)||Q(t)!=It)return!1;var n=Nt(t);if(n===null)return!0;var a=C.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&W.call(a)==xr}var Jt=$t?Sr($t):cn;function Rn(t){return mn(t,Kt(t))}function Kt(t){return ut(t)?on(t,!0):un(t)}var Pn=_n(function(t,n,a,c){Ft(t,n,a,c)});function Nn(t){return function(){return t}}function Wt(t){return t}function zn(){return!1}o.exports=Pn}(G,G.exports);var ae=G.exports;const ie=oe(ae);function se(o){let e;function r(i,s){var l,u,h,d,g,v,T;if((s==null?void 0:s.type)==="AwaitExpression"&&((u=(l=s==null?void 0:s.argument)==null?void 0:l.callee)==null?void 0:u.name)==="useStoryblok"){const w=(h=s==null?void 0:s.argument)==null?void 0:h.arguments;((d=w[1])==null?void 0:d.type)==="ObjectExpression"&&(e={...e,apiOptions:_t((g=w[1])==null?void 0:g.properties)}),((v=w[2])==null?void 0:v.type)==="ObjectExpression"&&(e={...e,bridgeOptions:_t((T=w[2])==null?void 0:T.properties)})}}return ie({},o,r),e}function _t(o){return o.reduce((e,{key:r,value:i})=>{const{type:s}=i;return e[r.name]=s==="Literal"?i.value:s==="ArrayExpression"?i.elements.map(l=>l.value):i.value,e},{})}function le(o){let e={resolveRelations:[]};function r(i){i&&(Array.isArray(i)?e.resolveRelations.push(...i):e.resolveRelations.push(i))}for(const i of o)if(i.options){const{apiOptions:s,bridgeOptions:l}=i.options;if(r(s==null?void 0:s.resolve_relations),l){const{resolveRelations:u,...h}=l;r(u),Object.assign(e,h)}}return e.resolveRelations=[...new Set(e.resolveRelations)],e}let z=[];function ce(){let o=[];const e="virtual:storyblok-bridge",r="\0"+e;let i=null,s=null;return{name:"vite-plugin-storyblok-bridge",async resolveId(l){if(l===e)return r},async transform(l,u){var T;if(u.includes("node_modules")&&!u.includes("/pages/")||!l.includes("useStoryblok")||!((T=this.getModuleInfo(u).meta)!=null&&T.astro))return;const[,...d]=u.split("src/pages/"),g=d.join("/").replace(".astro",""),v=se(this.parse(l));z.length&&(o=z.filter(w=>w.url!==g)),o.push({url:g,options:v}),i&&(s&&clearTimeout(s),s=setTimeout(()=>{ue(z,o)||(z.length!==0&&(i.restart(),console.info("Updating bridge options...")),z=[...o])},1e3))},async load(l){if(l===r)return`export const bridgeOptions = ${JSON.stringify(le(o))}`},configureServer(l){i=l}}}function ue(o=[],e=[]){return e.every(({url:r,options:i})=>{const s=o.find(l=>(l==null?void 0:l.url)===r);return s&&JSON.stringify(i)===JSON.stringify(s.options)})}let vt=!1;const Tt=[],fe=o=>new Promise((e,r)=>{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}vt?s():Tt.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const i=document.createElement("script");i.async=!0,i.src=o,i.id="storyblok-javascript-bridge",i.onerror=s=>r(s),i.onload=s=>{Tt.forEach(l=>l()),vt=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(i)});var pe=Object.defineProperty,de=(o,e,r)=>e in o?pe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,O=(o,e,r)=>(de(o,typeof e!="symbol"?e+"":e,r),r);class ge{constructor(){O(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),O(this,"getOptionsPage",(e,r=25,i=1)=>({...e,per_page:r,page:i})),O(this,"delay",e=>new Promise(r=>setTimeout(r,e))),O(this,"arrayFrom",(e=0,r)=>[...Array(e)].map(r)),O(this,"range",(e=0,r=e)=>{const i=Math.abs(r-e)||0,s=e<r?1:-1;return this.arrayFrom(i,(l,u)=>u*s+e)}),O(this,"asyncMap",async(e,r)=>Promise.all(e.map(r))),O(this,"flatMap",(e=[],r)=>e.map(r).reduce((i,s)=>[...i,...s],[])),O(this,"escapeHTML",function(e){const r={"&":"&","<":"<",">":">",'"':""","'":"'"},i=/[&<>"']/g,s=RegExp(i.source);return e&&s.test(e)?e.replace(i,l=>r[l]):e})}stringify(e,r,i){const s=[];for(const l in e){if(!Object.prototype.hasOwnProperty.call(e,l))continue;const u=e[l],h=i?"":encodeURIComponent(l);let d;typeof u=="object"?d=this.stringify(u,r?r+encodeURIComponent("["+h+"]"):h,Array.isArray(u)):d=(r?r+encodeURIComponent("["+h+"]"):h)+"="+encodeURIComponent(u),s.push(d)}return s.join("&")}getRegionURL(e){const r="api.storyblok.com",i="api-us.storyblok.com",s="app.storyblokchina.cn",l="api-ap.storyblok.com",u="api-ca.storyblok.com";switch(e){case"us":return i;case"cn":return s;case"ap":return l;case"ca":return u;default:return r}}}const he=function(o,e){const r={};for(const i in o){const s=o[i];e.indexOf(i)>-1&&s!==null&&(r[i]=s)}return r},ye=o=>o==="email",be=()=>({singleTag:"hr"}),me=()=>({tag:"blockquote"}),_e=()=>({tag:"ul"}),ve=o=>({tag:["pre",{tag:"code",attrs:o.attrs}]}),Te=()=>({singleTag:"br"}),we=o=>({tag:`h${o.attrs.level}`}),ke=o=>({singleTag:[{tag:"img",attrs:he(o.attrs,["src","alt","title"])}]}),Ae=()=>({tag:"li"}),Ie=()=>({tag:"ol"}),Se=()=>({tag:"p"}),Oe=o=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":o.attrs.name,emoji:o.attrs.emoji}}]}),Ce=()=>({tag:"b"}),je=()=>({tag:"s"}),$e=()=>({tag:"u"}),xe=()=>({tag:"strong"}),Ee=()=>({tag:"code"}),Me=()=>({tag:"i"}),Re=o=>{if(!o.attrs)return{tag:""};const e=new ge().escapeHTML,r={...o.attrs},{linktype:i="url"}=o.attrs;if(delete r.linktype,r.href&&(r.href=e(o.attrs.href||"")),ye(i)&&(r.href=`mailto:${r.href}`),r.anchor&&(r.href=`${r.href}#${r.anchor}`,delete r.anchor),r.custom){for(const s in r.custom)r[s]=r.custom[s];delete r.custom}return{tag:[{tag:"a",attrs:r}]}},Pe=o=>({tag:[{tag:"span",attrs:o.attrs}]}),Ne=()=>({tag:"sub"}),ze=()=>({tag:"sup"}),Le=o=>({tag:[{tag:"span",attrs:o.attrs}]}),De=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${o.attrs.color};`}}]}:{tag:""}},Ue=o=>{var e;return(e=o.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${o.attrs.color}`}}]}:{tag:""}},wt={nodes:{horizontal_rule:be,blockquote:me,bullet_list:_e,code_block:ve,hard_break:Te,heading:we,image:ke,list_item:Ae,ordered_list:Ie,paragraph:Se,emoji:Oe},marks:{bold:Ce,strike:je,underline:$e,strong:xe,code:Ee,italic:Me,link:Re,styled:Pe,subscript:Ne,superscript:ze,anchor:Le,highlight:De,textStyle:Ue}},Fe=function(o){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,i=RegExp(r.source);return o&&i.test(o)?o.replace(r,s=>e[s]):o};class kt{constructor(e){O(this,"marks"),O(this,"nodes"),e||(e=wt),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,r){this.nodes[e]=r}addMark(e,r){this.marks[e]=r}render(e,r={optimizeImages:!1}){if(e&&e.content&&Array.isArray(e.content)){let i="";return e.content.forEach(s=>{i+=this.renderNode(s)}),r.optimizeImages?this.optimizeImages(i,r.optimizeImages):i}return console.warn(`The render method must receive an Object with a "content" field.
|
|
12
12
|
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
13
13
|
ISbRichtext:
|
|
14
14
|
content?: ISbRichtext[]
|
|
@@ -31,7 +31,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
33
|
type: 'doc'
|
|
34
|
-
}`),""}optimizeImages(e,r){let i=0,s=0,l="",u="";typeof r!="boolean"&&(typeof r.width=="number"&&r.width>0&&(l+=`width="${r.width}" `,i=r.width),typeof r.height=="number"&&r.height>0&&(l+=`height="${r.height}" `,s=r.height),(r.loading==="lazy"||r.loading==="eager")&&(l+=`loading="${r.loading}" `),typeof r.class=="string"&&r.class.length>0&&(l+=`class="${r.class}" `),r.filters&&(typeof r.filters.blur=="number"&&r.filters.blur>=0&&r.filters.blur<=100&&(u+=`:blur(${r.filters.blur})`),typeof r.filters.brightness=="number"&&r.filters.brightness>=-100&&r.filters.brightness<=100&&(u+=`:brightness(${r.filters.brightness})`),r.filters.fill&&(r.filters.fill.match(/[0-9A-Fa-f]{6}/g)||r.filters.fill==="transparent")&&(u+=`:fill(${r.filters.fill})`),r.filters.format&&["webp","png","jpeg"].includes(r.filters.format)&&(u+=`:format(${r.filters.format})`),typeof r.filters.grayscale=="boolean"&&r.filters.grayscale&&(u+=":grayscale()"),typeof r.filters.quality=="number"&&r.filters.quality>=0&&r.filters.quality<=100&&(u+=`:quality(${r.filters.quality})`),r.filters.rotate&&[90,180,270].includes(r.filters.rotate)&&(u+=`:rotate(${r.filters.rotate})`),u.length>0&&(u="/filters"+u))),l.length>0&&(e=e.replace(/<img/g,`<img ${l.trim()}`));const
|
|
34
|
+
}`),""}optimizeImages(e,r){let i=0,s=0,l="",u="";typeof r!="boolean"&&(typeof r.width=="number"&&r.width>0&&(l+=`width="${r.width}" `,i=r.width),typeof r.height=="number"&&r.height>0&&(l+=`height="${r.height}" `,s=r.height),(r.loading==="lazy"||r.loading==="eager")&&(l+=`loading="${r.loading}" `),typeof r.class=="string"&&r.class.length>0&&(l+=`class="${r.class}" `),r.filters&&(typeof r.filters.blur=="number"&&r.filters.blur>=0&&r.filters.blur<=100&&(u+=`:blur(${r.filters.blur})`),typeof r.filters.brightness=="number"&&r.filters.brightness>=-100&&r.filters.brightness<=100&&(u+=`:brightness(${r.filters.brightness})`),r.filters.fill&&(r.filters.fill.match(/[0-9A-Fa-f]{6}/g)||r.filters.fill==="transparent")&&(u+=`:fill(${r.filters.fill})`),r.filters.format&&["webp","png","jpeg"].includes(r.filters.format)&&(u+=`:format(${r.filters.format})`),typeof r.filters.grayscale=="boolean"&&r.filters.grayscale&&(u+=":grayscale()"),typeof r.filters.quality=="number"&&r.filters.quality>=0&&r.filters.quality<=100&&(u+=`:quality(${r.filters.quality})`),r.filters.rotate&&[90,180,270].includes(r.filters.rotate)&&(u+=`:rotate(${r.filters.rotate})`),u.length>0&&(u="/filters"+u))),l.length>0&&(e=e.replace(/<img/g,`<img ${l.trim()}`));const h=i>0||s>0||u.length>0?`${i}x${s}${u}`:"";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/${h}`),typeof r!="boolean"&&(r.sizes||r.srcset)&&(e=e.replace(/<img.*?src=["|'](.*?)["|']/g,d=>{var g,v;const T=d.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(T&&T.length>0){const w={srcset:(g=r.srcset)==null?void 0:g.map(A=>{if(typeof A=="number")return`//${T}/m/${A}x0${u} ${A}w`;if(typeof A=="object"&&A.length===2){let L=0,J=0;return typeof A[0]=="number"&&(L=A[0]),typeof A[1]=="number"&&(J=A[1]),`//${T}/m/${L}x${J}${u} ${L}w`}}).join(", "),sizes:(v=r.sizes)==null?void 0:v.map(A=>A).join(", ")};let M="";return w.srcset&&(M+=`srcset="${w.srcset}" `),w.sizes&&(M+=`sizes="${w.sizes}" `),d.replace(/<img/g,`<img ${M.trim()}`)}return d})),e}renderNode(e){const r=[];e.marks&&e.marks.forEach(s=>{const l=this.getMatchingMark(s);l&&l.tag!==""&&r.push(this.renderOpeningTag(l.tag))});const i=this.getMatchingNode(e);return i&&i.tag&&r.push(this.renderOpeningTag(i.tag)),e.content?e.content.forEach(s=>{r.push(this.renderNode(s))}):e.text?r.push(Fe(e.text)):i&&i.singleTag?r.push(this.renderTag(i.singleTag," /")):i&&i.html?r.push(i.html):e.type==="emoji"&&r.push(this.renderEmoji(e)),i&&i.tag&&r.push(this.renderClosingTag(i.tag)),e.marks&&e.marks.slice(0).reverse().forEach(s=>{const l=this.getMatchingMark(s);l&&l.tag!==""&&r.push(this.renderClosingTag(l.tag))}),r.join("")}renderTag(e,r){return e.constructor===String?`<${e}${r}>`:e.map(i=>{if(i.constructor===String)return`<${i}${r}>`;{let s=`<${i.tag}`;if(i.attrs)for(const l in i.attrs){const u=i.attrs[l];u!==null&&(s+=` ${l}="${u}"`)}return`${s}${r}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(r=>r.constructor===String?`</${r}>`:`</${r.tag}>`).join("")}getMatchingNode(e){const r=this.nodes[e.type];if(typeof r=="function")return r(e)}getMatchingMark(e){const r=this.marks[e.type];if(typeof r=="function")return r(e)}renderEmoji(e){if(e.attrs.emoji)return e.attrs.emoji;const r=[{tag:"img",attrs:{src:e.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(r," /")}}const 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 He,qe="https://app.storyblok.com/f/storyblok-v2-latest.js";const Ge=(o,e)=>{o.addNode("blok",r=>{let i="";return r.attrs.body.forEach(s=>{i+=e(s.component,s)}),{html:i}})},Je=o=>!o||!(o!=null&&o.content.some(e=>e.content||e.type==="blok"||e.type==="horizontal_rule")),Ke=(o,e,r)=>{let i=r||He;if(!i){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Je(o)?"":(e&&(i=new kt(e.schema),e.resolver&&Ge(i,e.resolver)),i.render(o))},We=()=>fe(qe);let At;async function Ye(o){var i;const{action:e,story:r}=o||{};if(e==="input"&&r){const s=async()=>{const u=performance.now(),h=await Ze(r),d=performance.now();console.log(`getNewHTMLBody took ${d-u} milliseconds.`);const g=document.body;if(h.outerHTML===g.outerHTML)return;const v=document.querySelector('[data-blok-focused="true"]');Xe(g,h,v);const T=performance.now();console.log(`updateDOMWithNewBody took ${T-d} milliseconds.`),console.log(`total time took ${T-u} milliseconds.`)};clearTimeout(At),At=setTimeout(s,1500)}["published","change"].includes((i=o==null?void 0:o.data)==null?void 0:i.action)&&location.reload()}function Xe(o,e,r){if(r){const i=r.getAttribute("data-blok-uid"),s=e.querySelector(`[data-blok-uid="${i}"]`);s&&(s.setAttribute("data-blok-focused","true"),console.log("Doing partial replace"),r.replaceWith(s))}else console.log("Doing full replace"),o.replaceWith(e)}async function Ze(o){const r=await(await fetch(location.href,{method:"POST",body:JSON.stringify({...o,is_storyblok_preview:!0}),headers:{"Content-Type":"application/json"}})).text();return new DOMParser().parseFromString(r,"text/html").body}function Qe(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}async function Ve(o,e={},r={},i){globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly");let s=null;if(i&&i.locals._storyblok_preview_data)s=i.locals._storyblok_preview_data;else{const{data:l}=await globalThis.storyblokApiInstance.get(o,e,r);s=l.story}return s}function tr(o,e){const r=globalThis.storyblokApiInstance.richTextResolver;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return Ke(o,e,r)}function er(o){const e={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,...o};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:r,updateConfig:i,addDevToolbarApp:s,addMiddleware:l})=>{i({vite:{plugins:[N(e.accessToken,e.useCustomApi,e.apiOptions),re(e.componentsDir,e.components,e.enableFallbackComponent,e.customFallbackComponent),ne(e),ce()]}}),r("page-ssr",`
|
|
35
35
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
36
36
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
37
37
|
`),e.bridge&&(r("page",`
|
|
@@ -44,4 +44,4 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
44
44
|
storyblokInstance.on(["published", "change","input"], handleStoryblokMessage);
|
|
45
45
|
};
|
|
46
46
|
});
|
|
47
|
-
`),l({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),s("@storyblok/astro/toolbarApp.ts")}}}}
|
|
47
|
+
`),l({entrypoint:"@storyblok/astro/middleware.ts",order:"pre"})),s("@storyblok/astro/toolbarApp.ts")}}}}k.RichTextResolver=kt,k.RichTextSchema=wt,k.default=er,k.handleStoryblokMessage=Ye,k.loadStoryblokBridge=We,k.renderRichText=tr,k.storyblokEditable=Be,k.useStoryblok=Ve,k.useStoryblokApi=Qe,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|