@storyblok/astro 9.0.5 → 9.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37836,10 +37836,7 @@ const Eb = c1.configure({ types: ["heading", "paragraph"] }), Ab = Ch.extend({ r
|
|
|
37836
37836
|
}), Bb = kp.extend({
|
|
37837
37837
|
name: "ordered_list",
|
|
37838
37838
|
addAttributes() {
|
|
37839
|
-
return {
|
|
37840
|
-
...this.parent?.(),
|
|
37841
|
-
order: { default: 1 }
|
|
37842
|
-
};
|
|
37839
|
+
return { order: { default: 1 } };
|
|
37843
37840
|
},
|
|
37844
37841
|
addOptions() {
|
|
37845
37842
|
return {
|
|
@@ -37946,21 +37943,15 @@ const Eb = c1.configure({ types: ["heading", "paragraph"] }), Ab = Ch.extend({ r
|
|
|
37946
37943
|
})];
|
|
37947
37944
|
}
|
|
37948
37945
|
}), Hb = Gh.extend({ renderHTML({ HTMLAttributes: t }) {
|
|
37949
|
-
return [
|
|
37950
|
-
"
|
|
37951
|
-
|
|
37952
|
-
|
|
37953
|
-
|
|
37954
|
-
|
|
37955
|
-
|
|
37956
|
-
|
|
37957
|
-
|
|
37958
|
-
alt: t.alt,
|
|
37959
|
-
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
37960
|
-
draggable: "false",
|
|
37961
|
-
loading: "lazy"
|
|
37962
|
-
}]
|
|
37963
|
-
];
|
|
37946
|
+
return ["img", {
|
|
37947
|
+
"data-emoji": t.emoji,
|
|
37948
|
+
"data-name": t.name,
|
|
37949
|
+
src: t.fallbackImage,
|
|
37950
|
+
alt: t.alt,
|
|
37951
|
+
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
37952
|
+
draggable: "false",
|
|
37953
|
+
loading: "lazy"
|
|
37954
|
+
}];
|
|
37964
37955
|
} }), Yp = J.create({
|
|
37965
37956
|
name: "blok",
|
|
37966
37957
|
group: "block",
|
|
@@ -38579,6 +38570,7 @@ var dj = class {
|
|
|
38579
38570
|
links;
|
|
38580
38571
|
version;
|
|
38581
38572
|
rateLimitConfig;
|
|
38573
|
+
cvMode;
|
|
38582
38574
|
/**
|
|
38583
38575
|
* @deprecated This property is deprecated. Use the standalone `richTextResolver` from `@storyblok/richtext` instead.
|
|
38584
38576
|
* @see https://github.com/storyblok/richtext
|
|
@@ -38601,7 +38593,7 @@ var dj = class {
|
|
|
38601
38593
|
const a = new Headers();
|
|
38602
38594
|
a.set("Content-Type", "application/json"), a.set("Accept", "application/json"), t.headers && (t.headers.constructor.name === "Headers" ? t.headers.entries().toArray() : Object.entries(t.headers)).forEach(([n, s]) => {
|
|
38603
38595
|
a.set(n, s);
|
|
38604
|
-
}), a.has(Dr) || (a.set(Dr, Dn.defaultAgentName), a.set(Dn.defaultAgentVersion, Dn.packageVersion)), t.oauthToken && a.set("Authorization", t.oauthToken), this.rateLimitConfig = pj(t.rateLimit, !!t.oauthToken), this.maxRetries = t.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new uj(this.throttledRequest.bind(this), 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = t.version || nj.PUBLISHED, this.inlineAssets = t.inlineAssets || !1, this.client = new aj({
|
|
38596
|
+
}), a.has(Dr) || (a.set(Dr, Dn.defaultAgentName), a.set(Dn.defaultAgentVersion, Dn.packageVersion)), t.oauthToken && a.set("Authorization", t.oauthToken), this.rateLimitConfig = pj(t.rateLimit, !!t.oauthToken), this.maxRetries = t.maxRetries || 10, this.retriesDelay = 300, this.throttleManager = new uj(this.throttledRequest.bind(this), 1e3), this.accessToken = t.accessToken || "", this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.cvMode = t.cache?.cv ?? "auto", this.resolveCounter = 0, this.resolveNestedRelations = t.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = t.version || nj.PUBLISHED, this.inlineAssets = t.inlineAssets || !1, this.client = new aj({
|
|
38605
38597
|
baseURL: o,
|
|
38606
38598
|
timeout: t.timeout || 0,
|
|
38607
38599
|
headers: a,
|
|
@@ -38610,7 +38602,7 @@ var dj = class {
|
|
|
38610
38602
|
});
|
|
38611
38603
|
}
|
|
38612
38604
|
parseParams(t) {
|
|
38613
|
-
return t.token || (t.token = this.getToken()), t.cv
|
|
38605
|
+
return t.token || (t.token = this.getToken()), !t.cv && this.cvMode === "auto" && (t.cv = Ge[t.token]), Array.isArray(t.resolve_relations) ? t.resolve_relations = t.resolve_relations.map(Fr).join(",") : typeof t.resolve_relations == "string" && (t.resolve_relations = Fr(t.resolve_relations)), typeof t.resolve_relations < "u" && (t.resolve_level = 2), t;
|
|
38614
38606
|
}
|
|
38615
38607
|
factoryParamOptions(t, e) {
|
|
38616
38608
|
return _n(t) ? this.parseParams(e) : e;
|
|
@@ -145,4 +145,4 @@ ${o}
|
|
|
145
145
|
`,U1="️",V1="",zs="";let $a=null,Pa=null;function K1(t=[]){const e={};je.groups=e;const o=new je;$a==null&&($a=Ep(O1)),Pa==null&&(Pa=Ep($1)),y(o,"'",Ea),y(o,"{",co),y(o,"}",mo),y(o,"[",da),y(o,"]",ga),y(o,"(",fa),y(o,")",ha),y(o,"<",ba),y(o,">",ja),y(o,"(",va),y(o,")",ka),y(o,"「",ya),y(o,"」",Fa),y(o,"『",_a),y(o,"』",Da),y(o,"<",wa),y(o,">",Ia),y(o,"&",Ca),y(o,"*",Aa),y(o,"@",it),y(o,"`",Sa),y(o,"^",Ta),y(o,":",rt),y(o,",",Ss),y(o,"$",Ma),y(o,".",Be),y(o,"=",Ba),y(o,"!",Ts),y(o,"-",we),y(o,"%",uo),y(o,"|",Ra),y(o,"+",La),y(o,"#",Na),y(o,"?",go),y(o,'"',Ms),y(o,"/",Re),y(o,";",Bs),y(o,"~",fo),y(o,"_",za),y(o,"\\",xa),y(o,"・",_p);const a=X(o,qe,Es,{[ks]:!0});X(a,qe,a);const n=X(a,He,yp,{[ro]:!0}),s=X(a,ho,Fp,{[lo]:!0}),i=X(o,He,Pe,{[ys]:!0});X(i,qe,n),X(i,He,i),X(n,qe,n),X(n,He,n);const r=X(o,ho,ws,{[Fs]:!0});X(r,He),X(r,qe,s),X(r,ho,r),X(s,qe,s),X(s,He),X(s,ho,s);const l=y(o,Ns,xs,{[Ds]:!0}),p=y(o,Ip,As,{[Ds]:!0}),c=X(o,Ls,As,{[Ds]:!0});y(o,zs,c),y(p,Ns,l),y(p,zs,c),X(p,Ls,c),y(c,Ip),y(c,Ns),X(c,Ls,c),y(c,zs,c);const m=X(o,Rs,Dp,{[vp]:!0});y(m,"#"),X(m,Rs,m),y(m,U1,m);const u=y(m,V1);y(u,"#"),X(u,Rs,m);const d=[[He,i],[qe,n]],g=[[He,null],[ho,r],[qe,s]];for(let f=0;f<$a.length;f++)lt(o,$a[f],Is,Pe,d);for(let f=0;f<Pa.length;f++)lt(o,Pa[f],Cs,ws,g);wt(Is,{tld:!0,ascii:!0},e),wt(Cs,{utld:!0,alpha:!0},e),lt(o,"file",ua,Pe,d),lt(o,"mailto",ua,Pe,d),lt(o,"http",Ot,Pe,d),lt(o,"https",Ot,Pe,d),lt(o,"ftp",Ot,Pe,d),lt(o,"ftps",Ot,Pe,d),wt(ua,{scheme:!0,ascii:!0},e),wt(Ot,{slashscheme:!0,ascii:!0},e),t=t.sort((f,h)=>f[0]>h[0]?1:-1);for(let f=0;f<t.length;f++){const h=t[f][0],k=t[f][1]?{[P1]:!0}:{[H1]:!0};h.indexOf("-")>=0?k[_s]=!0:He.test(h)?qe.test(h)?k[ro]=!0:k[ys]=!0:k[ks]=!0,kp(o,h,h,k)}return kp(o,"localhost",po,{ascii:!0}),o.jd=new je(Oa),{start:o,tokens:Object.assign({groups:e},wp)}}function Cp(t,e){const o=J1(e.replace(/[A-Z]/g,r=>r.toLowerCase())),a=o.length,n=[];let s=0,i=0;for(;i<a;){let r=t,l=null,p=0,c=null,m=-1,u=-1;for(;i<a&&(l=r.go(o[i]));)r=l,r.accepts()?(m=0,u=0,c=r):m>=0&&(m+=o[i].length,u++),p+=o[i].length,s+=o[i].length,i++;s-=m,i-=u,p-=m,n.push({t:c.t,v:e.slice(s-p,s),s:s-p,e:s})}return n}function J1(t){const e=[],o=t.length;let a=0;for(;a<o;){let n=t.charCodeAt(a),s,i=n<55296||n>56319||a+1===o||(s=t.charCodeAt(a+1))<56320||s>57343?t[a]:t.slice(a,a+2);e.push(i),a+=i.length}return e}function lt(t,e,o,a,n){let s;const i=e.length;for(let r=0;r<i-1;r++){const l=e[r];t.j[l]?s=t.j[l]:(s=new je(a),s.jr=n.slice(),t.j[l]=s),t=s}return s=new je(o),s.jr=n.slice(),t.j[e[i-1]]=s,s}function Ep(t){const e=[],o=[];let a=0,n="0123456789";for(;a<t.length;){let s=0;for(;n.indexOf(t[a+s])>=0;)s++;if(s>0){e.push(o.join(""));for(let i=parseInt(t.substring(a,a+s),10);i>0;i--)o.pop();a+=s}else o.push(t[a]),a++}return e}const bo={defaultProtocol:"http",events:null,format:Ap,formatHref:Ap,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Os(t,e=null){let o=Object.assign({},bo);t&&(o=Object.assign(o,t instanceof Os?t.o:t));const a=o.ignoreTags,n=[];for(let s=0;s<a.length;s++)n.push(a[s].toUpperCase());this.o=o,e&&(this.defaultRender=e),this.ignoreTags=n}Os.prototype={o:bo,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,o){const a=e!=null;let n=this.o[t];return n&&(typeof n=="object"?(n=o.t in n?n[o.t]:bo[t],typeof n=="function"&&a&&(n=n(e,o))):typeof n=="function"&&a&&(n=n(e,o.t,o)),n)},getObj(t,e,o){let a=this.o[t];return typeof a=="function"&&e!=null&&(a=a(e,o.t,o)),a},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Ap(t){return t}function xp(t,e){this.t="token",this.v=t,this.tk=e}xp.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),o=t.get("truncate",e,this),a=t.get("format",e,this);return o&&a.length>o?a.substring(0,o)+"…":a},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=bo.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,o=this.toHref(t.get("defaultProtocol")),a=t.get("formatHref",o,this),n=t.get("tagName",o,e),s=this.toFormattedString(t),i={},r=t.get("className",o,e),l=t.get("target",o,e),p=t.get("rel",o,e),c=t.getObj("attributes",o,e),m=t.getObj("events",o,e);return i.href=a,r&&(i.class=r),l&&(i.target=l),p&&(i.rel=p),c&&Object.assign(i,c),{tagName:n,attributes:i,content:s,eventListeners:m}}};function Ha(t,e){class o extends xp{constructor(n,s){super(n,s),this.t=t}}for(const a in e)o.prototype[a]=e[a];return o.t=t,o}const Sp=Ha("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Tp=Ha("text"),G1=Ha("nl"),qa=Ha("url",{isLink:!0,toHref(t=bo.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==po&&t[1].t===rt}}),Ie=t=>new je(t);function X1({groups:t}){const e=t.domain.concat([Ca,Aa,it,xa,Sa,Ta,Ma,Ba,we,Es,uo,Ra,La,Na,Re,Oa,fo,za]),o=[Ea,rt,Ss,Be,Ts,uo,go,Ms,Bs,ba,ja,co,mo,ga,da,fa,ha,va,ka,ya,Fa,_a,Da,wa,Ia],a=[Ca,Ea,Aa,xa,Sa,Ta,Ma,Ba,we,co,mo,uo,Ra,La,Na,go,Re,Oa,fo,za],n=Ie(),s=y(n,fo);N(s,a,s),N(s,t.domain,s);const i=Ie(),r=Ie(),l=Ie();N(n,t.domain,i),N(n,t.scheme,r),N(n,t.slashscheme,l),N(i,a,s),N(i,t.domain,i);const p=y(i,it);y(s,it,p),y(r,it,p),y(l,it,p);const c=y(s,Be);N(c,a,s),N(c,t.domain,s);const m=Ie();N(p,t.domain,m),N(m,t.domain,m);const u=y(m,Be);N(u,t.domain,m);const d=Ie(Sp);N(u,t.tld,d),N(u,t.utld,d),y(p,po,d);const g=y(m,we);y(g,we,g),N(g,t.domain,m),N(d,t.domain,m),y(d,Be,u),y(d,we,g);const f=y(d,rt);N(f,t.numeric,Sp);const h=y(i,we),b=y(i,Be);y(h,we,h),N(h,t.domain,i),N(b,a,s),N(b,t.domain,i);const k=Ie(qa);N(b,t.tld,k),N(b,t.utld,k),N(k,t.domain,i),N(k,a,s),y(k,Be,b),y(k,we,h),y(k,it,p);const j=y(k,rt),F=Ie(qa);N(j,t.numeric,F);const _=Ie(qa),I=Ie();N(_,e,_),N(_,o,I),N(I,e,_),N(I,o,I),y(k,Re,_),y(F,Re,_);const E=y(r,rt),L=y(l,rt),z=y(L,Re),C=y(z,Re);N(r,t.domain,i),y(r,Be,b),y(r,we,h),N(l,t.domain,i),y(l,Be,b),y(l,we,h),N(E,t.domain,_),y(E,Re,_),y(E,go,_),N(C,t.domain,_),N(C,e,_),y(C,Re,_);const R=[[co,mo],[da,ga],[fa,ha],[ba,ja],[va,ka],[ya,Fa],[_a,Da],[wa,Ia]];for(let q=0;q<R.length;q++){const[T,M]=R[q],O=y(_,T);y(I,T,O),y(O,M,_);const Y=Ie(qa);N(O,e,Y);const ue=Ie();N(O,o),N(Y,e,Y),N(Y,o,ue),N(ue,e,Y),N(ue,o,ue),y(Y,M,_),y(ue,M,_)}return y(n,po,k),y(n,xs,G1),{start:n,tokens:wp}}function Y1(t,e,o){let a=o.length,n=0,s=[],i=[];for(;n<a;){let r=t,l=null,p=null,c=0,m=null,u=-1;for(;n<a&&!(l=r.go(o[n].t));)i.push(o[n++]);for(;n<a&&(p=l||r.go(o[n].t));)l=null,r=p,r.accepts()?(u=0,m=r):u>=0&&u++,n++,c++;if(u<0)n-=c,n<a&&(i.push(o[n]),n++);else{i.length>0&&(s.push($s(Tp,e,i)),i=[]),n-=u,c-=u;const d=m.t,g=o.slice(n-c,n);s.push($s(d,e,g))}}return i.length>0&&s.push($s(Tp,e,i)),s}function $s(t,e,o){const a=o[0].s,n=o[o.length-1].e,s=e.slice(a,n);return new t(s,o)}const Z1=typeof console<"u"&&console&&console.warn||(()=>{}),Q1="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",V={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function eb(){return je.groups={},V.scanner=null,V.parser=null,V.tokenQueue=[],V.pluginQueue=[],V.customSchemes=[],V.initialized=!1,V}function Mp(t,e=!1){if(V.initialized&&Z1(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Q1}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
146
146
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
147
147
|
2. Cannot start or end with "-"
|
|
148
|
-
3. "-" cannot repeat`);V.customSchemes.push([t,e])}function tb(){V.scanner=K1(V.customSchemes);for(let t=0;t<V.tokenQueue.length;t++)V.tokenQueue[t][1]({scanner:V.scanner});V.parser=X1(V.scanner.tokens);for(let t=0;t<V.pluginQueue.length;t++)V.pluginQueue[t][1]({scanner:V.scanner,parser:V.parser});return V.initialized=!0,V}function Ps(t){return V.initialized||tb(),Y1(V.parser.start,t,Cp(V.scanner.start,t))}Ps.scan=Cp;function Bp(t,e=null,o=null){if(e&&typeof e=="object"){if(o)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);o=e,e=null}const a=new Os(o),n=Ps(t),s=[];for(let i=0;i<n.length;i++){const r=n[i];r.isLink&&(!e||r.t===e)&&a.check(r)&&s.push(r.toFormattedObject(a))}return s}var Hs="[\0- -\u2029 ]",ob=new RegExp(Hs),ab=new RegExp(`${Hs}$`),nb=new RegExp(Hs,"g");function sb(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function ib(t){return new le({key:new oe("autolink"),appendTransaction:(e,o,a)=>{const n=e.some(p=>p.docChanged)&&!o.doc.eq(a.doc),s=e.some(p=>p.getMeta("preventAutolink"));if(!n||s)return;const{tr:i}=a,r=qn(o.doc,[...e]);if(Un(r).forEach(({newRange:p})=>{const c=vl(a.doc,p,d=>d.isTextblock);let m,u;if(c.length>1)m=c[0],u=a.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(c.length){const d=a.doc.textBetween(p.from,p.to," "," ");if(!ab.test(d))return;m=c[0],u=a.doc.textBetween(m.pos,p.to,void 0," ")}if(m&&u){const d=u.split(ob).filter(Boolean);if(d.length<=0)return!1;const g=d[d.length-1],f=m.pos+u.lastIndexOf(g);if(!g)return!1;const h=Ps(g).map(b=>b.toObject(t.defaultProtocol));if(!sb(h))return!1;h.filter(b=>b.isLink).map(b=>({...b,from:f+b.start+1,to:f+b.end+1})).filter(b=>a.schema.marks.code?!a.doc.rangeHasMark(b.from,b.to,a.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Vn(b.from,b.to,a.doc).some(k=>k.mark.type===t.type)||i.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!i.steps.length)return i}})}function rb(t){return new le({key:new oe("handleClickLink"),props:{handleClick:(e,o,a)=>{var n,s;if(a.button!==0||!e.editable)return!1;let i=null;if(a.target instanceof HTMLAnchorElement)i=a.target;else{const l=a.target;if(!l)return!1;const p=t.editor.view.dom;i=l.closest("a"),i&&!p.contains(i)&&(i=null)}if(!i)return!1;let r=!1;if(t.enableClickSelection&&(r=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const l=pg(e.state,t.type.name),p=(n=i.href)!=null?n:l.href,c=(s=i.target)!=null?s:l.target;p&&(window.open(p,c),r=!0)}return r}}})}function lb(t){return new le({key:new oe("handlePasteLink"),props:{handlePaste:(e,o,a)=>{const{shouldAutoLink:n}=t,{state:s}=e,{selection:i}=s,{empty:r}=i;if(r)return!1;let l="";a.content.forEach(c=>{l+=c.textContent});const p=Bp(l,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!p||n!==void 0&&!n(p.value)?!1:t.editor.commands.setMark(t.type,{href:p.href})}}})}function It(t,e){const o=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(a=>{const n=typeof a=="string"?a:a.scheme;n&&o.push(n)}),!t||t.replace(nb,"").match(new RegExp(`^(?:(?:${o.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var pb=be.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Mp(t);return}Mp(t.scheme,t.optionalSlashes)})},onDestroy(){eb()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!It(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),o=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||o&&!t.includes("@"))return!0;const n=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(n)||!/\./.test(n))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:o=>!!It(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!It(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",H(this.options.HTMLAttributes,t),0]:["a",H(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var o,a,n,s;const i=(a=(o=t.attrs)==null?void 0:o.href)!=null?a:"",r=(s=(n=t.attrs)==null?void 0:n.title)!=null?s:"",l=e.renderChildren(t);return r?`[${l}](${i} "${r}")`:`[${l}](${i})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:o}=t;return this.options.isAllowedUri(o,{defaultValidate:a=>!!It(a,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:o}=t||{};return o&&!this.options.isAllowedUri(o,{defaultValidate:a=>!!It(a,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[nt({find:t=>{const e=[];if(t){const{protocols:o,defaultProtocol:a}=this.options,n=Bp(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!It(i,o),protocols:o,defaultProtocol:a}));n.length&&n.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:o}=this.options;return this.options.autolink&&t.push(ib({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:a=>this.options.isAllowedUri(a,{defaultValidate:n=>!!It(n,e),protocols:e,defaultProtocol:o}),shouldAutoLink:this.options.shouldAutoLink})),t.push(rb({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(lb({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),cb=pb,mb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,ub=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,db=be.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ft({find:mb,type:this.type})]},addPasteRules(){return[nt({find:ub,type:this.type})]}}),gb=db,fb=be.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hb=fb,bb=be.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),jb=bb,vb=20,Rp=(t,e=0)=>{const o=[];return!t.children.length||e>vb||Array.from(t.children).forEach(a=>{a.tagName==="SPAN"?o.push(a):a.children.length&&o.push(...Rp(a,e+1))}),o},kb=t=>{if(!t.children.length)return;const e=Rp(t);e&&e.forEach(o=>{var a,n;const s=o.getAttribute("style"),i=(n=(a=o.parentElement)==null?void 0:a.closest("span"))==null?void 0:n.getAttribute("style");o.setAttribute("style",`${i};${s}`)})},yb=be.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&kb(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",H(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(o,a)=>{if(o.isTextblock)return!0;o.marks.filter(n=>n.type===this.type).some(n=>Object.values(n.attrs).some(s=>!!s))||t.removeMark(a,a+o.nodeSize,this.type)}),!0}}}}),Fb=te.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const o=t.getAttribute("style");if(o){const a=o.split(";").map(n=>n.trim()).filter(Boolean);for(let n=a.length-1;n>=0;n-=1){const s=a[n].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),r=s.slice(1).join(":").trim();if(i==="background-color")return r.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),_b=te.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const o=t.getAttribute("style");if(o){const a=o.split(";").map(n=>n.trim()).filter(Boolean);for(let n=a.length-1;n>=0;n-=1){const s=a[n].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),r=s.slice(1).join(":").trim();if(i==="color")return r.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Db=te.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),wb=te.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Ib=te.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});te.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(Fb.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(_b.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(Db.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(wb.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(Ib.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(yb.configure(this.options.textStyle)),t}});var Cb=be.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",H(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,o){const n=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!n)return;const s=n[2].trim();return{type:"underline",raw:n[0],text:s,tokens:o.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Eb=Cb;function Ab(t,e){if(!e)return{src:t,attrs:{}};let o=0,a=0;const n={},s=[];function i(l,p,c,m,u){typeof l!="number"||l<=p||l>=c?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${p} and ${c} (inclusive)`):u.push(`${m}(${l})`)}if(typeof e=="object"){if(e.width!==void 0&&(typeof e.width=="number"&&e.width>=0?(n.width=e.width,o=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),e.height!==void 0&&(typeof e.height=="number"&&e.height>=0?(n.height=e.height,a=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),e.height===0&&e.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),e.loading&&["lazy","eager"].includes(e.loading)&&(n.loading=e.loading),e.class&&(n.class=e.class),e.filters){const{filters:l}=e||{},{blur:p,brightness:c,fill:m,format:u,grayscale:d,quality:g,rotate:f}=l||{};p&&i(p,0,100,"blur",s),g&&i(g,0,100,"quality",s),c&&i(c,0,100,"brightness",s),m&&s.push(`fill(${m})`),d&&s.push("grayscale()"),f&&[0,90,180,270].includes(e.filters.rotate||0)&&s.push(`rotate(${f})`),u&&["webp","png","jpeg"].includes(u)&&s.push(`format(${u})`)}e.srcset&&(n.srcset=e.srcset.map(l=>{if(typeof l=="number")return`${t}/m/${l}x0/${s.length>0?`filters:${s.join(":")}`:""} ${l}w`;if(Array.isArray(l)&&l.length===2){const[p,c]=l;return`${t}/m/${p}x${c}/${s.length>0?`filters:${s.join(":")}`:""} ${p}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(n.sizes=e.sizes.join(", "))}let r=`${t}/m/`;return(o>0||a>0)&&(r=`${r}${o}x${a}/`),s.length>0&&(r=`${r}filters:${s.join(":")}`),{src:r,attrs:n}}function qs(t,e){if(t===e)return!0;if(t==null||e===null||e===void 0)return t===e;if(typeof t!=typeof e||typeof t!="object"||Array.isArray(t)!==Array.isArray(e))return!1;if(Array.isArray(t))return t.length!==e.length?!1:t.every((n,s)=>qs(n,e[s]));const o=Object.keys(t),a=Object.keys(e);return o.length!==a.length?!1:o.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&qs(t[n],e[n]))}function Lp(t,e){return t.type===e.type&&qs(t.attrs,e.attrs)}function Np(t){return t.type==="text"&&!!t.marks?.length}function xb(t,e){const o=t.filter(a=>!e.some(n=>Lp(n,a)));return o.length?o:void 0}function Sb(t,e){const o=t[e];if(!Np(o))return null;const a=[o];let n=o.marks,s=e+1;for(;s<t.length;){const i=t[s];if(!Np(i))break;const r=n.filter(l=>i.marks.some(p=>Lp(l,p)));if(r.length===0)break;n=r,a.push(i),s++}return{group:a,shared:n,endIndex:s}}const Tb=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Mb=(t={})=>{const{custom:e,...o}=t,a={...o,...e};return Object.keys(a).filter(n=>a[n]!=null).map(n=>`${n}="${String(a[n]).replace(/&/g,"&").replace(/"/g,""")}"`).join(" ")},zp=(t={})=>Object.keys(t).map(e=>`${e}: ${t[e]}`).join("; ");function Bb(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ct=t=>Object.fromEntries(Object.entries(t).filter(([e,o])=>o!=null));let Wa=(function(t){return t.URL="url",t.STORY="story",t.ASSET="asset",t.EMAIL="email",t})({});function We(t={}){const{textAlign:e,class:o,id:a,style:n,...s}=t,i=[];return n&&i.push(n.endsWith(";")?n:`${n};`),e&&i.push(`text-align: ${e};`),Ct({...s,class:o,id:a,...i.length>0?{style:i.join(" ")}:{}})}function Rb(t={}){const{linktype:e,href:o,anchor:a,uuid:n,custom:s,...i}=t;let r=o??"";switch(e){case Wa.ASSET:case Wa.URL:break;case Wa.EMAIL:r&&!r.startsWith("mailto:")&&(r=`mailto:${r}`);break;case Wa.STORY:a&&(r=`${r}#${a}`);break}return{href:r,rest:{...i,...s||{}}}}function Op(t={}){const{colspan:e,rowspan:o,colwidth:a,backgroundColor:n,textAlign:s,...i}=t,r=[];return a&&r.push(`width: ${a}px;`),n&&r.push(`background-color: ${n};`),s&&r.push(`text-align: ${s};`),Ct({...i,...e>1?{colspan:e}:{},...o>1?{rowspan:o}:{},...r.length>0?{style:r.join(" ")}:{}})}const Ws={a:["href","target","data-uuid","data-anchor","data-linktype"],img:["alt","src","title"],span:["class"]};function $p(t,{allowedStyles:e}){const o=(t.getAttribute("class")||"").split(" ").filter(Boolean);if(!o.length)return[];const a=o.filter(n=>!e.includes(n));for(const n of a)console.warn(`[StoryblokRichText] - \`class\` "${n}" on \`<${t.tagName.toLowerCase()}>\` can not be transformed to rich text.`);return e.filter(n=>o.includes(n))}const Lb=j1.configure({types:["heading","paragraph"]}),Nb=Rh.extend({renderHTML({HTMLAttributes:t}){return["blockquote",We(t),0]}}),zb=g1.extend({renderHTML({HTMLAttributes:t}){return["p",We(t),0]}}),Ob=r1.extend({renderHTML({node:t,HTMLAttributes:e}){const{level:o,...a}=e;return[`h${t.attrs.level}`,We(a),0]}}),$b=gp.extend({renderHTML({HTMLAttributes:t}){return["tr",We(t),0]}}),Pb=Sl.extend({name:"bullet_list",addOptions(){return{...this.parent(),itemTypeName:"list_item"}},renderHTML({HTMLAttributes:t}){return["ul",We(t),0]}}),Hb=Hl.extend({name:"ordered_list",addAttributes(){return{...this.parent?.(),order:{default:1}}},addOptions(){return{...this.parent(),itemTypeName:"list_item"}},renderHTML({HTMLAttributes:t}){return["ol",We(t),0]}}),qb=Tl.extend({name:"list_item",addOptions(){return{...this.parent(),bulletListTypeName:"bullet_list",orderedListTypeName:"ordered_list"}},renderHTML({HTMLAttributes:t}){return["li",We(t),0]}}),Wb=Oh.extend({name:"code_block",addAttributes(){return{class:{default:null}}},renderHTML({node:t,HTMLAttributes:e}){const{language:o,...a}=e,n=We(a),s=t.attrs.language;return["pre",n,["code",s?{class:`language-${s}`}:{},0]]}}),Ub=s1.extend({name:"hard_break"}),Vb=p1.extend({name:"horizontal_rule"}),Kb=bp.extend({renderHTML({HTMLAttributes:t}){return["table",We(t),0]}}),Jb=up.extend({addAttributes(){return{...this.parent?.(),colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(Number):null}},backgroundColor:{default:null}}},renderHTML({HTMLAttributes:t}){return["td",Op(t),0]}}),Gb=dp.extend({renderHTML({HTMLAttributes:t}){return["th",Op(t),0]}}),Pp=u1.extend({addOptions(){return{...this.parent?.(),optimizeImages:!1}},renderHTML({HTMLAttributes:t}){const{src:e,alt:o,title:a,srcset:n,sizes:s}=t;let i=e,r={};if(this.options.optimizeImages){const l=Ab(e,this.options.optimizeImages);i=l.src,r=l.attrs}return["img",Ct({src:i,alt:o,title:a,srcset:n,sizes:s,...r})]}}),Xb=a1.extend({renderHTML({HTMLAttributes:t}){return["span",{"data-type":"emoji","data-name":t.name,"data-emoji":t.emoji},["img",{src:t.fallbackImage,alt:t.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"}]]}}),Hp=J.create({name:"blok",group:"block",atom:!0,addOptions(){return{renderComponent:null}},addAttributes(){return{id:{default:null},body:{default:[]}}},parseHTML(){return[{tag:"div[data-blok]"}]},renderHTML({HTMLAttributes:t}){return console.warn("[StoryblokRichText] - BLOK resolver is not available for vanilla usage. Configure `renderComponent` option on the blok tiptapExtension."),["span",Ct({"data-blok":JSON.stringify(t?.body?.[0]??null),"data-blok-id":t?.id,style:"display: none"})]}}),Yb=T1.extend({addAttributes(){return{color:{default:null}}}}),Us=cb.extend({addAttributes(){return{href:{parseHTML:t=>t.getAttribute("href")},uuid:{default:null,parseHTML:t=>t.getAttribute("data-uuid")||null},anchor:{default:null,parseHTML:t=>t.getAttribute("data-anchor")||null},target:{parseHTML:t=>t.getAttribute("target")||null},linktype:{default:"url",parseHTML:t=>t.getAttribute("data-linktype")||"url"}}},renderHTML({HTMLAttributes:t}){const{href:e,rest:o}=Rb(t);return["a",Ct({...e?{href:e}:{},...o}),0]}}),Zb=Us.extend({addAttributes(){return{...this.parent?.(),custom:{default:null,parseHTML:t=>{const e=Ws.a,o=t.getAttributeNames().filter(n=>!e.includes(n)),a={};for(const n of o)a[n]=t.getAttribute(n);return Object.keys(a).length?a:null}}}}}),Qb=be.create({name:"anchor",addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:"span[id]"}]},renderHTML({HTMLAttributes:t}){return["span",{id:t.id},0]}}),qp=be.create({name:"styled",addAttributes(){return{class:{parseHTML:t=>{const e=$p(t,{allowedStyles:this.options.allowedStyles||[]});return e.length?e.join(" "):null}}}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>$p(t,{allowedStyles:this.options.allowedStyles||[]}).length?null:!1}]},renderHTML({HTMLAttributes:t}){const{class:e,...o}=t;return["span",Ct({class:e,style:zp(o)||void 0}),0]}}),ej=be.create({name:"textStyle",addAttributes(){return{class:{default:null},id:{default:null},color:{default:null}}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>{const e=t.getAttribute("style");return e&&/color/i.test(e)?null:!1}}]},renderHTML({HTMLAttributes:t}){const{class:e,id:o,...a}=t;return["span",Ct({class:e,id:o,style:zp(a)||void 0}),0]}}),Wp=be.create({name:"reporter",priority:0,addOptions(){return{allowCustomAttributes:!1}},parseHTML(){return[{tag:"*",consuming:!1,getAttrs:t=>{const e=t.tagName.toLowerCase();if(e==="a"&&this.options.allowCustomAttributes)return!1;const o=t.getAttributeNames().filter(a=>!(e in Ws?Ws[e]:[]).includes(a));for(const a of o)console.warn(`[StoryblokRichText] - \`${a}\` "${t.getAttribute(a)}" on \`<${e}>\` can not be transformed to rich text.`);return!1}}]}}),tj={document:Ph,text:h1,paragraph:zb,blockquote:Nb,heading:Ob,bulletList:Pb,orderedList:Hb,listItem:qb,codeBlock:Wb,hardBreak:Ub,horizontalRule:Vb,image:Pp,emoji:Xb,table:Kb,tableRow:$b,tableCell:Jb,tableHeader:Gb,blok:Hp,details:Ff,detailsContent:_f,detailsSummary:Df,bold:D1,italic:z1,strike:gb,underline:Eb,code:E1,superscript:jb,subscript:hb,highlight:Yb,textStyle:ej,link:Us,anchor:Qb,styled:qp,reporter:Wp,textAlign:Lb};function oj(t={}){const e=t.allowCustomAttributes?Zb:Us;return{...tj,image:Pp.configure({optimizeImages:t.optimizeImages||!1}),link:e,styled:qp.configure({allowedStyles:t.styleOptions?.map(o=>o.value)}),reporter:Wp.configure({allowCustomAttributes:t.allowCustomAttributes})}}function Up(t,e={},o){const a=Mb(e),n=a?`${t} ${a}`:t,s=Array.isArray(o)?o.join(""):o||"";if(t){if(Tb.includes(t))return`<${n}>`}else return s;return`<${n}>${s}</${t}>`}function jo(t,e,o){const[a,...n]=t;let s={},i=n;if(i.length>0&&i[0]!==null&&i[0]!==void 0&&typeof i[0]=="object"&&!Array.isArray(i[0])&&typeof i[0]!="number"&&(s=i[0],i=i.slice(1)),i=i.filter(l=>l!=null),i.length===0)return e(a,s);if(i.length===1&&i[0]===0)return e(a,s,o);const r=i.map(l=>l===0?o:Array.isArray(l)?jo(l,e,o):l);return e(a,s,r.length===1?r[0]:r)}function Ua(t,e,o){const a={options:t.options||{},name:t.name,type:t.type};return e==="node"?t.config.renderHTML.call(a,{node:{attrs:o},HTMLAttributes:o}):t.config.renderHTML.call(a,{mark:{attrs:o},HTMLAttributes:o})}function Vs(t={}){const e=new Map,{renderFn:o=Up,textFn:a=Bb,optimizeImages:n=!1,keyedResolvers:s=!1,tiptapExtensions:i}=t,r=o!==Up,l=oj({optimizeImages:n}),p=i?{...l,...i}:l,c=Object.values(p),m=new Map,u=new Map;for(const j of c)j.type==="node"?m.set(j.name,j):j.type==="mark"&&u.set(j.name,j);const d=(j,F={},_)=>{if(s&&j){const I=e.get(j)||0;e.set(j,I+1),F={...F,key:`${j}-${I}`}}return r&&typeof j!="string"&&_!==void 0?o(j,F,(()=>_)):o(j,F,_)};function g(j,F){const _=j.map(E=>b({...E,marks:xb(E.marks||[],F)}));let I=r?_:_.join("");for(const E of F){const L=u.get(E.type);L?.config?.renderHTML&&(I=jo(Ua(L,"mark",E.attrs||{}),d,I))}return I}function f(j){const F=[];let _=0;for(;_<j.length;){const I=Sb(j,_);if(!I){F.push(k(j[_])),_++;continue}I.group.length===1?F.push(b(I.group[0])):F.push(g(I.group,I.shared)),_=I.endIndex}return F}function h(j){if(j.type==="text")return b(j);if(j.type==="doc")return k(j);const F=m.get(j.type);if(!F?.config?.renderHTML)return console.error("<Storyblok>",`No extension found for node type ${j.type}`),"";if(F.options?.renderComponent){const I=j.attrs?.body,E=j.attrs?.id;if(!Array.isArray(I)||I.length===0)return r?[]:"";const L=I.map(z=>F.options.renderComponent(z,E));return r?L:L.filter(z=>z!=null).join("")}if(j.type==="table"&&j.content?.length){const I=[],E=[];for(const C of j.content)E.length===0&&C.content?.every(R=>R.type==="tableHeader")?I.push(C):E.push(C);const L=Ua(F,"node",j.attrs||{}),z=[];return I.length>0&&z.push(d("thead",{},I.map(k))),E.length>0&&z.push(d("tbody",{},E.map(k))),jo(L,d,z)}const _=j.content?f(j.content):void 0;return jo(Ua(F,"node",j.attrs||{}),d,_)}function b(j){const{marks:F,..._}=j;if(F?.length){const E=(()=>{const L={};if(s){const z=e.get("txt")||0;e.set("txt",z+1),L.key=`txt-${z}`}return a(_.text,L)})();return F.reduce((L,z)=>{const C=u.get(z.type);return C?.config?.renderHTML?jo(Ua(C,"mark",z.attrs||{}),d,L):(console.error("<Storyblok>",`No extension found for node type ${z.type}`),L)},E)}const I=j.attrs||{};if(s){const E=e.get("txt")||0;e.set("txt",E+1),I.key=`txt-${E}`}return a(_.text,I)}function k(j){const F=j;return F.type==="doc"?r?F.content.map(h):F.content.map(h).join(""):Array.isArray(F)?F.map(h):h(F)}return{render:k}}const aj="SB_BLOK_GROUP_",nj=/<!--SB_BLOK_GROUP_(\d+)-->/;function sj(t,e={}){const o=[],a=[],n=Vs({...e,tiptapExtensions:{blok:Hp.configure({renderComponent:s=>{const i=[s];return`<!--${aj}${a.push(i)-1}-->`}}),...e.tiptapExtensions}}).render(t).split(nj);for(let s=0;s<n.length;s++)if(s%2===0){const i=n[s];i&&i.trim()&&o.push({type:"html",content:i})}else{const i=a[Number(n[s])];if(i)for(const r of i)o.push({type:"blok",blok:r})}return o}const Ks=(t="")=>t.includes("/cdn/"),ij=(t,e=25,o=1)=>({...t,per_page:e,page:o}),rj=t=>new Promise(e=>setTimeout(e,t)),lj=(t=0,e)=>Array.from({length:t},e),pj=(t=0,e=t)=>{const o=Math.abs(e-t)||0,a=t<e?1:-1;return lj(o,(n,s)=>s*a+t)},cj=async(t,e)=>Promise.all(t.map(e)),mj=(t=[],e)=>t.map(e).reduce((o,a)=>[...o,...a],[]),Vp=t=>{if(/%[0-9A-F]{2}/i.test(t))try{return decodeURIComponent(t)}catch{return t}return t},Js=(t,e,o)=>{const a=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const s=t[n];if(s==null)continue;const i=o?"":encodeURIComponent(n);let r;typeof s=="object"?r=Js(s,e?e+encodeURIComponent(`[${i}]`):i,Array.isArray(s)):r=`${e?e+encodeURIComponent(`[${i}]`):i}=${encodeURIComponent(s)}`,a.push(r)}return a.join("&")},Kp=t=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[t]??e.eu};var uj=class{baseURL;timeout;headers;responseInterceptor;fetch;ejectInterceptor;url;parameters;fetchOptions;constructor(t){this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t?.timeout?t.timeout*1e3:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}delete(t,e){return this.url=t,this.parameters=e??{},this._methodHandler("delete")}async _responseHandler(t){const e=[],o={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(a=>{o.data=a});for(const a of t.headers.entries())e[a[0]]=a[1];return o.headers={...e},o.status=t.status,o.statusText=t.statusText,o}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,o=null;t==="get"?e=`${this.baseURL}${this.url}?${Js(this.parameters)}`:o=JSON.stringify(this.parameters);const a=new URL(e),n=new AbortController,{signal:s}=n;let i=null;this.timeout&&(i=setTimeout(()=>n.abort(),this.timeout));try{const r=await this.fetch(`${a}`,{method:t,headers:this.headers,body:o,signal:s,...this.fetchOptions});this.timeout&&i&&clearTimeout(i);const l=await this._responseHandler(r);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(r){return r.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:r.message||r.toString()||"An unknown error occurred"}}}setFetchOptions(t={}){Object.keys(t).length>0&&"method"in t&&delete t.method,this.fetchOptions={...t}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(t){if(Array.isArray(t))return t[0]||"Unknown error";if(t&&typeof t=="object"){if(t.error)return t.error;for(const e in t){if(Array.isArray(t[e]))return`${e}: ${t[e][0]}`;if(typeof t[e]=="string")return`${e}: ${t[e]}`}if(t.slug)return t.slug}return"Unknown error"}_statusHandler(t){const e=/20[0-6]/g;return new Promise((o,a)=>{if(e.test(`${t.status}`))return o(t);a({message:this._normalizeErrorMessage(t.data),status:t.status,response:t})})}};const Jp="SB-Agent",Gs={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},dj={PUBLISHED:"published"},gj=25,Xs={SMALL:25,MEDIUM:50,LARGE:75},$t={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},Gp=1e3,Va=3;function fj(t,e){const o=t.includes("/cdn/stories/"),a=t.split("/").length>3&&!t.endsWith("/cdn/stories"),n="find_by"in e;return o&&a||n}function hj(t){return t<=Xs.SMALL?$t.SINGLE_OR_SMALL:t<=Xs.MEDIUM?$t.MEDIUM:t<=Xs.LARGE?$t.LARGE:$t.VERY_LARGE}function Ka(t,e,o={},a){return o.userRateLimit!==void 0?Math.min(o.userRateLimit,Gp):o.serverHeadersRateLimit!==void 0?Math.min(o.serverHeadersRateLimit,Gp):a!==void 0?a:!t||!e||fj(t,e)?$t.SINGLE_OR_SMALL:hj(e.per_page||gj)}function bj(t){if(!t)return null;const e=t["x-ratelimit"]||t["X-RateLimit"],o=t["x-ratelimit-policy"]||t["X-RateLimit-Policy"];if(!e&&!o)return null;const a={};if(e){const n=e.match(/r=(\d+)/);n&&(a.remaining=Number.parseInt(n[1],10))}if(o){const n=o.match(/q=(\d+)/);n&&(a.max=Number.parseInt(n[1],10))}return Object.keys(a).length>0?a:null}function jj(t,e=!1){return{userRateLimit:t,serverHeadersRateLimit:void 0,isManagementApi:e}}var vj=class extends Error{constructor(t){super(t),this.name="AbortError"}};function kj(t,e,o){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(o))throw new TypeError("Expected `interval` to be a finite number");const a=[];let n=[],s=0,i=!1;const r=async()=>{s++;const p=a.shift();if(p)try{const m=await t(...p.args);p.resolve(m)}catch(m){p.reject(m)}const c=setTimeout(()=>{s--,a.length>0&&r(),n=n.filter(m=>m!==c)},o);n.includes(c)||n.push(c)},l=(...p)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((c,m)=>{a.push({resolve:c,reject:m,args:p}),s<e&&r()});return l.abort=()=>{i=!0,n.forEach(clearTimeout),n=[],a.forEach(p=>p.reject(()=>new vj("Throttle function aborted"))),a.length=0},l}var yj=class{queues;interval;throttledRequestFn;constructor(t,e=1e3){this.queues=new Map,this.interval=e,this.throttledRequestFn=t}getQueue(t){let e=this.queues.get(t);return e||(e=kj(this.throttledRequestFn,t,this.interval),this.queues.set(t,e)),e}execute(t,...e){return this.getQueue(t)(...e)}abortAll(){this.queues.forEach(t=>{t.abort?.()}),this.queues.clear()}getQueueCount(){return this.queues.size}};let Ja={};const pt={};var Fj=class{client;maxRetries;retriesDelay;throttleManager;accessToken;cache;resolveCounter;relations;links;version;rateLimitConfig;richTextResolver;resolveNestedRelations;stringifiedStoriesCache;inlineAssets;constructor(t,e){let o=t.endpoint||e;if(!o){const n=t.https===!1?"http":"https";t.oauthToken?o=`${n}://${Kp(t.region)}/v1`:o=`${n}://${Kp(t.region)}/v2`}const a=new Headers;a.set("Content-Type","application/json"),a.set("Accept","application/json"),t.headers&&(t.headers.constructor.name==="Headers"?t.headers.entries().toArray():Object.entries(t.headers)).forEach(([n,s])=>{a.set(n,s)}),a.has(Jp)||(a.set(Jp,Gs.defaultAgentName),a.set(Gs.defaultAgentVersion,Gs.packageVersion)),t.oauthToken&&a.set("Authorization",t.oauthToken),this.rateLimitConfig=jj(t.rateLimit,!!t.oauthToken),this.maxRetries=t.maxRetries||10,this.retriesDelay=300,this.throttleManager=new yj(this.throttledRequest.bind(this),1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=t.version||dj.PUBLISHED,this.inlineAssets=t.inlineAssets||!1,this.client=new uj({baseURL:o,timeout:t.timeout||0,headers:a,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}parseParams(t){return t.token||(t.token=this.getToken()),t.cv||(t.cv=pt[t.token]),Array.isArray(t.resolve_relations)?t.resolve_relations=t.resolve_relations.map(Vp).join(","):typeof t.resolve_relations=="string"&&(t.resolve_relations=Vp(t.resolve_relations)),typeof t.resolve_relations<"u"&&(t.resolve_level=2),t}factoryParamOptions(t,e){return Ks(t)?this.parseParams(e):e}makeRequest(t,e,o,a,n){const s=this.factoryParamOptions(t,ij(e,o,a));return this.cacheResponse(t,s,void 0,n)}get(t,e={},o){e||(e={});const a=`/${t}`;Ks(a)&&(e.version=e.version||this.version);const n=this.factoryParamOptions(a,e);return this.cacheResponse(a,n,void 0,o)}async getAll(t,e={},o,a){const n=e?.per_page||25,s=`/${t}`.replace(/\/$/,""),i=o??s.substring(s.lastIndexOf("/")+1);e.version=e.version||this.version;const r=1,l=await this.makeRequest(s,e,n,r,a);return mj([l,...await cj(pj(r,l.total?Math.ceil(l.total/(l.perPage||n)):1),p=>this.makeRequest(s,e,n,p+1,a))],p=>Object.values(p.data[i]))}post(t,e={},o){const a=`/${t}`,n=Ka(void 0,void 0,this.rateLimitConfig,Va);return this.throttleManager.execute(n,"post",a,e,o)}put(t,e={},o){const a=`/${t}`,n=Ka(void 0,void 0,this.rateLimitConfig,Va);return this.throttleManager.execute(n,"put",a,e,o)}delete(t,e={},o){e||(e={});const a=`/${t}`,n=Ka(void 0,void 0,this.rateLimitConfig,Va);return this.throttleManager.execute(n,"delete",a,e,o)}getStories(t={},e){return this._addResolveLevel(t),this.get("cdn/stories",t,e)}getStory(t,e={},o){return this._addResolveLevel(e),this.get(`cdn/stories/${t}`,e,o)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(t){typeof t.resolve_relations<"u"&&(t.resolve_level=2)}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,o){const a=t[e];a&&a.fieldtype==="multilink"&&a.linktype==="story"&&typeof a.id=="string"&&this.links[o][a.id]?a.story=this._cleanCopy(this.links[o][a.id]):a&&a.linktype==="story"&&typeof a.uuid=="string"&&this.links[o][a.uuid]&&(a.story=this._cleanCopy(this.links[o][a.uuid]))}getStoryReference(t,e){return this.relations[t][e]?JSON.parse(this.stringifiedStoriesCache[e]||JSON.stringify(this.relations[t][e])):e}_resolveField(t,e,o){const a=t[e];typeof a=="string"?t[e]=this.getStoryReference(o,a):Array.isArray(a)&&(t[e]=a.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(t,e,o,a){if(Array.isArray(o)?o.find(s=>s.endsWith(`.${e}`)):o.endsWith(`.${e}`)){this._resolveField(t,e,a);return}const n=t.component?`${t.component}.${e}`:e;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(t,e,a)}iterateTree(t,e,o){const a=(n,s="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((i,r)=>a(i,`${s}[${r}]`));else if(typeof n=="object")for(const i in n){const r=s?`${s}.${i}`:i;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,e,o),this._insertLinks(n,i,o)),a(n[i],r)}}};a(t.content)}async resolveLinks(t,e,o){let a=[];if(t.link_uuids){const n=t.link_uuids.length,s=[],i=50;for(let r=0;r<n;r+=i){const l=Math.min(n,r+i);s.push(t.link_uuids.slice(r,l))}for(let r=0;r<s.length;r++)(await this.getStories({per_page:i,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:s[r].join(",")})).data.stories.forEach(l=>{a.push(l)})}else a=t.links;a.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(t,e,o){let a=[];if(t.rel_uuids){const n=t.rel_uuids.length,s=[],i=50;for(let r=0;r<n;r+=i){const l=Math.min(n,r+i);s.push(t.rel_uuids.slice(r,l))}for(let r=0;r<s.length;r++)(await this.getStories({per_page:i,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:s[r].join(","),excluding_fields:e.excluding_fields})).data.stories.forEach(l=>{a.push(l)});a.length>0&&(t.rels=a,delete t.rel_uuids)}else a=t.rels;a&&a.length>0&&a.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(t,e,o){let a=[];if(this.links[o]={},this.relations[o]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(a=e.resolve_relations.split(",")),await this.resolveRelations(t,e,o)),e.resolve_links&&["1","story","url","link"].includes(e.resolve_links)&&(t.links?.length||t.link_uuids?.length)&&await this.resolveLinks(t,e,o),this.resolveNestedRelations)for(const n in this.relations[o])this.iterateTree(this.relations[o][n],a,o);t.story?this.iterateTree(t.story,a,o):t.stories.forEach(n=>{this.iterateTree(n,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(t,e,o,a){const n=Js({url:t,params:e}),s=this.cacheProvider();if(e.version==="published"&&t!=="/cdn/spaces/me"){const l=await s.get(n);if(l)return Promise.resolve(l)}const i=!Ks(t)&&this.rateLimitConfig.isManagementApi?Va:void 0,r=Ka(t,e,this.rateLimitConfig,i);return new Promise(async(l,p)=>{try{const c=await this.throttleManager.execute(r,"get",t,e,a);if(c.status!==200)return p(c);let m={data:c.data,headers:c.headers};const u=bj(c.headers);if(u?.max!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=u.max),c.headers?.["per-page"]&&(m=Object.assign({},m,{perPage:c.headers["per-page"]?Number.parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?Number.parseInt(c.headers.total):0})),m.data.story||m.data.stories){const g=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(m.data,e,`${g}`),m=await this.processInlineAssets(m)}e.version==="published"&&t!=="/cdn/spaces/me"&&await s.set(n,m);const d=this.cache.clear==="onpreview"&&e.version==="draft"||this.cache.clear==="auto";return e.token&&m.data.cv&&(d&&pt[e.token]&&pt[e.token]!==m.data.cv&&await this.flushCache(),pt[e.token]=m.data.cv),l(m)}catch(c){if(c.response&&c.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await rj(this.retriesDelay),this.cacheResponse(t,e,o).then(l).catch(p);p(c)}})}throttledRequest(t,e,o,a){return this.client.setFetchOptions(a),this.client[t](e,o)}cacheVersions(){return pt}cacheVersion(){return pt[this.accessToken]}setCacheVersion(t){this.accessToken&&(pt[this.accessToken]=t)}clearCacheVersion(){this.accessToken&&(pt[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(Ja[t])},getAll(){return Promise.resolve(Ja)},set(t,e){return Ja[t]=e,Promise.resolve(void 0)},flush(){return Ja={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(t){if(!this.inlineAssets)return t;const e=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>e(n));let a={...o};a.fieldtype==="asset"&&Array.isArray(t.data.assets)&&(a={...t.data.assets.find(n=>n.id===a.id),...a});for(const n in a)typeof a[n]=="object"&&(a[n]=e(a[n]));return a};return t.data.story&&(t.data.story.content=e(t.data.story.content)),t.data.stories&&(t.data.stories=t.data.stories.map(o=>(o.content=e(o.content),o))),t}};let Xp=!1;const Yp=[],Zp=t=>new Promise((e,o)=>{if(typeof window>"u"){o(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}Xp?n():Yp.push(n)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const a=document.createElement("script");a.async=!0,a.src=t,a.id="storyblok-javascript-bridge",a.onerror=n=>o(n),a.onload=n=>{Yp.forEach(s=>s()),Xp=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(a)}),_j=(t={})=>{const{apiOptions:e}=t;if(!e||!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 Fj(e)}},Dj=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};try{const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let Ys="https://app.storyblok.com/f/storyblok-v2-latest.js";const wj=(t={})=>{var e,o;const{bridge:a,accessToken:n,use:s=[],apiOptions:i={},bridgeUrl:r}=t;i.accessToken=i.accessToken||n;const l={bridge:a,apiOptions:i};let p={};s.forEach(m=>{p={...p,...m(l)}}),r&&(Ys=r);const c=!(typeof window>"u")&&((o=(e=window.location)==null?void 0:e.search)==null?void 0:o.includes("_storyblok_tk"));return a!==!1&&c&&Zp(Ys),p};function Ij(t,e){return Vs(e).render(t)}const Cj=()=>Zp(Ys);Q.apiPlugin=_j,Q.getLiveStory=lc,Q.getPayload=pc,Q.handleStoryblokMessage=Wc,Q.isEditorRequest=Qc,Q.loadStoryblokBridge=Cj,Q.renderRichText=Ij,Q.richTextResolver=Vs,Q.sanitizeJSON=Dc,Q.segmentStoryblokRichText=sj,Q.storyblok=_c,Q.storyblokEditable=Dj,Q.storyblokInit=wj,Q.toCamelCase=si,Q.useStoryblokApi=rc,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|
|
148
|
+
3. "-" cannot repeat`);V.customSchemes.push([t,e])}function tb(){V.scanner=K1(V.customSchemes);for(let t=0;t<V.tokenQueue.length;t++)V.tokenQueue[t][1]({scanner:V.scanner});V.parser=X1(V.scanner.tokens);for(let t=0;t<V.pluginQueue.length;t++)V.pluginQueue[t][1]({scanner:V.scanner,parser:V.parser});return V.initialized=!0,V}function Ps(t){return V.initialized||tb(),Y1(V.parser.start,t,Cp(V.scanner.start,t))}Ps.scan=Cp;function Bp(t,e=null,o=null){if(e&&typeof e=="object"){if(o)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);o=e,e=null}const a=new Os(o),n=Ps(t),s=[];for(let i=0;i<n.length;i++){const r=n[i];r.isLink&&(!e||r.t===e)&&a.check(r)&&s.push(r.toFormattedObject(a))}return s}var Hs="[\0- -\u2029 ]",ob=new RegExp(Hs),ab=new RegExp(`${Hs}$`),nb=new RegExp(Hs,"g");function sb(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function ib(t){return new le({key:new oe("autolink"),appendTransaction:(e,o,a)=>{const n=e.some(p=>p.docChanged)&&!o.doc.eq(a.doc),s=e.some(p=>p.getMeta("preventAutolink"));if(!n||s)return;const{tr:i}=a,r=qn(o.doc,[...e]);if(Un(r).forEach(({newRange:p})=>{const c=vl(a.doc,p,d=>d.isTextblock);let m,u;if(c.length>1)m=c[0],u=a.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(c.length){const d=a.doc.textBetween(p.from,p.to," "," ");if(!ab.test(d))return;m=c[0],u=a.doc.textBetween(m.pos,p.to,void 0," ")}if(m&&u){const d=u.split(ob).filter(Boolean);if(d.length<=0)return!1;const g=d[d.length-1],f=m.pos+u.lastIndexOf(g);if(!g)return!1;const h=Ps(g).map(b=>b.toObject(t.defaultProtocol));if(!sb(h))return!1;h.filter(b=>b.isLink).map(b=>({...b,from:f+b.start+1,to:f+b.end+1})).filter(b=>a.schema.marks.code?!a.doc.rangeHasMark(b.from,b.to,a.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Vn(b.from,b.to,a.doc).some(k=>k.mark.type===t.type)||i.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!i.steps.length)return i}})}function rb(t){return new le({key:new oe("handleClickLink"),props:{handleClick:(e,o,a)=>{var n,s;if(a.button!==0||!e.editable)return!1;let i=null;if(a.target instanceof HTMLAnchorElement)i=a.target;else{const l=a.target;if(!l)return!1;const p=t.editor.view.dom;i=l.closest("a"),i&&!p.contains(i)&&(i=null)}if(!i)return!1;let r=!1;if(t.enableClickSelection&&(r=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const l=pg(e.state,t.type.name),p=(n=i.href)!=null?n:l.href,c=(s=i.target)!=null?s:l.target;p&&(window.open(p,c),r=!0)}return r}}})}function lb(t){return new le({key:new oe("handlePasteLink"),props:{handlePaste:(e,o,a)=>{const{shouldAutoLink:n}=t,{state:s}=e,{selection:i}=s,{empty:r}=i;if(r)return!1;let l="";a.content.forEach(c=>{l+=c.textContent});const p=Bp(l,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!p||n!==void 0&&!n(p.value)?!1:t.editor.commands.setMark(t.type,{href:p.href})}}})}function It(t,e){const o=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(a=>{const n=typeof a=="string"?a:a.scheme;n&&o.push(n)}),!t||t.replace(nb,"").match(new RegExp(`^(?:(?:${o.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var pb=be.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Mp(t);return}Mp(t.scheme,t.optionalSlashes)})},onDestroy(){eb()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!It(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),o=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||o&&!t.includes("@"))return!0;const n=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(n)||!/\./.test(n))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:o=>!!It(o,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!It(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",H(this.options.HTMLAttributes,t),0]:["a",H(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var o,a,n,s;const i=(a=(o=t.attrs)==null?void 0:o.href)!=null?a:"",r=(s=(n=t.attrs)==null?void 0:n.title)!=null?s:"",l=e.renderChildren(t);return r?`[${l}](${i} "${r}")`:`[${l}](${i})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:o}=t;return this.options.isAllowedUri(o,{defaultValidate:a=>!!It(a,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:o}=t||{};return o&&!this.options.isAllowedUri(o,{defaultValidate:a=>!!It(a,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[nt({find:t=>{const e=[];if(t){const{protocols:o,defaultProtocol:a}=this.options,n=Bp(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!It(i,o),protocols:o,defaultProtocol:a}));n.length&&n.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:o}=this.options;return this.options.autolink&&t.push(ib({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:a=>this.options.isAllowedUri(a,{defaultValidate:n=>!!It(n,e),protocols:e,defaultProtocol:o}),shouldAutoLink:this.options.shouldAutoLink})),t.push(rb({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(lb({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),cb=pb,mb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,ub=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,db=be.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",H(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ft({find:mb,type:this.type})]},addPasteRules(){return[nt({find:ub,type:this.type})]}}),gb=db,fb=be.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hb=fb,bb=be.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",H(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),jb=bb,vb=20,Rp=(t,e=0)=>{const o=[];return!t.children.length||e>vb||Array.from(t.children).forEach(a=>{a.tagName==="SPAN"?o.push(a):a.children.length&&o.push(...Rp(a,e+1))}),o},kb=t=>{if(!t.children.length)return;const e=Rp(t);e&&e.forEach(o=>{var a,n;const s=o.getAttribute("style"),i=(n=(a=o.parentElement)==null?void 0:a.closest("span"))==null?void 0:n.getAttribute("style");o.setAttribute("style",`${i};${s}`)})},yb=be.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&kb(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",H(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(o,a)=>{if(o.isTextblock)return!0;o.marks.filter(n=>n.type===this.type).some(n=>Object.values(n.attrs).some(s=>!!s))||t.removeMark(a,a+o.nodeSize,this.type)}),!0}}}}),Fb=te.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const o=t.getAttribute("style");if(o){const a=o.split(";").map(n=>n.trim()).filter(Boolean);for(let n=a.length-1;n>=0;n-=1){const s=a[n].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),r=s.slice(1).join(":").trim();if(i==="background-color")return r.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),_b=te.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const o=t.getAttribute("style");if(o){const a=o.split(";").map(n=>n.trim()).filter(Boolean);for(let n=a.length-1;n>=0;n-=1){const s=a[n].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),r=s.slice(1).join(":").trim();if(i==="color")return r.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Db=te.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),wb=te.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Ib=te.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});te.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(Fb.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(_b.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(Db.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(wb.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(Ib.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(yb.configure(this.options.textStyle)),t}});var Cb=be.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",H(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,o){const n=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!n)return;const s=n[2].trim();return{type:"underline",raw:n[0],text:s,tokens:o.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Eb=Cb;function Ab(t,e){if(!e)return{src:t,attrs:{}};let o=0,a=0;const n={},s=[];function i(l,p,c,m,u){typeof l!="number"||l<=p||l>=c?console.warn(`[StoryblokRichText] - ${m.charAt(0).toUpperCase()+m.slice(1)} value must be a number between ${p} and ${c} (inclusive)`):u.push(`${m}(${l})`)}if(typeof e=="object"){if(e.width!==void 0&&(typeof e.width=="number"&&e.width>=0?(n.width=e.width,o=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than or equal to 0")),e.height!==void 0&&(typeof e.height=="number"&&e.height>=0?(n.height=e.height,a=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than or equal to 0")),e.height===0&&e.width===0&&(delete n.width,delete n.height,console.warn("[StoryblokRichText] - Width and height values cannot both be 0")),e.loading&&["lazy","eager"].includes(e.loading)&&(n.loading=e.loading),e.class&&(n.class=e.class),e.filters){const{filters:l}=e||{},{blur:p,brightness:c,fill:m,format:u,grayscale:d,quality:g,rotate:f}=l||{};p&&i(p,0,100,"blur",s),g&&i(g,0,100,"quality",s),c&&i(c,0,100,"brightness",s),m&&s.push(`fill(${m})`),d&&s.push("grayscale()"),f&&[0,90,180,270].includes(e.filters.rotate||0)&&s.push(`rotate(${f})`),u&&["webp","png","jpeg"].includes(u)&&s.push(`format(${u})`)}e.srcset&&(n.srcset=e.srcset.map(l=>{if(typeof l=="number")return`${t}/m/${l}x0/${s.length>0?`filters:${s.join(":")}`:""} ${l}w`;if(Array.isArray(l)&&l.length===2){const[p,c]=l;return`${t}/m/${p}x${c}/${s.length>0?`filters:${s.join(":")}`:""} ${p}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(n.sizes=e.sizes.join(", "))}let r=`${t}/m/`;return(o>0||a>0)&&(r=`${r}${o}x${a}/`),s.length>0&&(r=`${r}filters:${s.join(":")}`),{src:r,attrs:n}}function qs(t,e){if(t===e)return!0;if(t==null||e===null||e===void 0)return t===e;if(typeof t!=typeof e||typeof t!="object"||Array.isArray(t)!==Array.isArray(e))return!1;if(Array.isArray(t))return t.length!==e.length?!1:t.every((n,s)=>qs(n,e[s]));const o=Object.keys(t),a=Object.keys(e);return o.length!==a.length?!1:o.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&qs(t[n],e[n]))}function Lp(t,e){return t.type===e.type&&qs(t.attrs,e.attrs)}function Np(t){return t.type==="text"&&!!t.marks?.length}function xb(t,e){const o=t.filter(a=>!e.some(n=>Lp(n,a)));return o.length?o:void 0}function Sb(t,e){const o=t[e];if(!Np(o))return null;const a=[o];let n=o.marks,s=e+1;for(;s<t.length;){const i=t[s];if(!Np(i))break;const r=n.filter(l=>i.marks.some(p=>Lp(l,p)));if(r.length===0)break;n=r,a.push(i),s++}return{group:a,shared:n,endIndex:s}}const Tb=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Mb=(t={})=>{const{custom:e,...o}=t,a={...o,...e};return Object.keys(a).filter(n=>a[n]!=null).map(n=>`${n}="${String(a[n]).replace(/&/g,"&").replace(/"/g,""")}"`).join(" ")},zp=(t={})=>Object.keys(t).map(e=>`${e}: ${t[e]}`).join("; ");function Bb(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ct=t=>Object.fromEntries(Object.entries(t).filter(([e,o])=>o!=null));let Wa=(function(t){return t.URL="url",t.STORY="story",t.ASSET="asset",t.EMAIL="email",t})({});function We(t={}){const{textAlign:e,class:o,id:a,style:n,...s}=t,i=[];return n&&i.push(n.endsWith(";")?n:`${n};`),e&&i.push(`text-align: ${e};`),Ct({...s,class:o,id:a,...i.length>0?{style:i.join(" ")}:{}})}function Rb(t={}){const{linktype:e,href:o,anchor:a,uuid:n,custom:s,...i}=t;let r=o??"";switch(e){case Wa.ASSET:case Wa.URL:break;case Wa.EMAIL:r&&!r.startsWith("mailto:")&&(r=`mailto:${r}`);break;case Wa.STORY:a&&(r=`${r}#${a}`);break}return{href:r,rest:{...i,...s||{}}}}function Op(t={}){const{colspan:e,rowspan:o,colwidth:a,backgroundColor:n,textAlign:s,...i}=t,r=[];return a&&r.push(`width: ${a}px;`),n&&r.push(`background-color: ${n};`),s&&r.push(`text-align: ${s};`),Ct({...i,...e>1?{colspan:e}:{},...o>1?{rowspan:o}:{},...r.length>0?{style:r.join(" ")}:{}})}const Ws={a:["href","target","data-uuid","data-anchor","data-linktype"],img:["alt","src","title"],span:["class"]};function $p(t,{allowedStyles:e}){const o=(t.getAttribute("class")||"").split(" ").filter(Boolean);if(!o.length)return[];const a=o.filter(n=>!e.includes(n));for(const n of a)console.warn(`[StoryblokRichText] - \`class\` "${n}" on \`<${t.tagName.toLowerCase()}>\` can not be transformed to rich text.`);return e.filter(n=>o.includes(n))}const Lb=j1.configure({types:["heading","paragraph"]}),Nb=Rh.extend({renderHTML({HTMLAttributes:t}){return["blockquote",We(t),0]}}),zb=g1.extend({renderHTML({HTMLAttributes:t}){return["p",We(t),0]}}),Ob=r1.extend({renderHTML({node:t,HTMLAttributes:e}){const{level:o,...a}=e;return[`h${t.attrs.level}`,We(a),0]}}),$b=gp.extend({renderHTML({HTMLAttributes:t}){return["tr",We(t),0]}}),Pb=Sl.extend({name:"bullet_list",addOptions(){return{...this.parent(),itemTypeName:"list_item"}},renderHTML({HTMLAttributes:t}){return["ul",We(t),0]}}),Hb=Hl.extend({name:"ordered_list",addAttributes(){return{order:{default:1}}},addOptions(){return{...this.parent(),itemTypeName:"list_item"}},renderHTML({HTMLAttributes:t}){return["ol",We(t),0]}}),qb=Tl.extend({name:"list_item",addOptions(){return{...this.parent(),bulletListTypeName:"bullet_list",orderedListTypeName:"ordered_list"}},renderHTML({HTMLAttributes:t}){return["li",We(t),0]}}),Wb=Oh.extend({name:"code_block",addAttributes(){return{class:{default:null}}},renderHTML({node:t,HTMLAttributes:e}){const{language:o,...a}=e,n=We(a),s=t.attrs.language;return["pre",n,["code",s?{class:`language-${s}`}:{},0]]}}),Ub=s1.extend({name:"hard_break"}),Vb=p1.extend({name:"horizontal_rule"}),Kb=bp.extend({renderHTML({HTMLAttributes:t}){return["table",We(t),0]}}),Jb=up.extend({addAttributes(){return{...this.parent?.(),colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(Number):null}},backgroundColor:{default:null}}},renderHTML({HTMLAttributes:t}){return["td",Op(t),0]}}),Gb=dp.extend({renderHTML({HTMLAttributes:t}){return["th",Op(t),0]}}),Pp=u1.extend({addOptions(){return{...this.parent?.(),optimizeImages:!1}},renderHTML({HTMLAttributes:t}){const{src:e,alt:o,title:a,srcset:n,sizes:s}=t;let i=e,r={};if(this.options.optimizeImages){const l=Ab(e,this.options.optimizeImages);i=l.src,r=l.attrs}return["img",Ct({src:i,alt:o,title:a,srcset:n,sizes:s,...r})]}}),Xb=a1.extend({renderHTML({HTMLAttributes:t}){return["img",{"data-emoji":t.emoji,"data-name":t.name,src:t.fallbackImage,alt:t.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"}]}}),Hp=J.create({name:"blok",group:"block",atom:!0,addOptions(){return{renderComponent:null}},addAttributes(){return{id:{default:null},body:{default:[]}}},parseHTML(){return[{tag:"div[data-blok]"}]},renderHTML({HTMLAttributes:t}){return console.warn("[StoryblokRichText] - BLOK resolver is not available for vanilla usage. Configure `renderComponent` option on the blok tiptapExtension."),["span",Ct({"data-blok":JSON.stringify(t?.body?.[0]??null),"data-blok-id":t?.id,style:"display: none"})]}}),Yb=T1.extend({addAttributes(){return{color:{default:null}}}}),Us=cb.extend({addAttributes(){return{href:{parseHTML:t=>t.getAttribute("href")},uuid:{default:null,parseHTML:t=>t.getAttribute("data-uuid")||null},anchor:{default:null,parseHTML:t=>t.getAttribute("data-anchor")||null},target:{parseHTML:t=>t.getAttribute("target")||null},linktype:{default:"url",parseHTML:t=>t.getAttribute("data-linktype")||"url"}}},renderHTML({HTMLAttributes:t}){const{href:e,rest:o}=Rb(t);return["a",Ct({...e?{href:e}:{},...o}),0]}}),Zb=Us.extend({addAttributes(){return{...this.parent?.(),custom:{default:null,parseHTML:t=>{const e=Ws.a,o=t.getAttributeNames().filter(n=>!e.includes(n)),a={};for(const n of o)a[n]=t.getAttribute(n);return Object.keys(a).length?a:null}}}}}),Qb=be.create({name:"anchor",addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:"span[id]"}]},renderHTML({HTMLAttributes:t}){return["span",{id:t.id},0]}}),qp=be.create({name:"styled",addAttributes(){return{class:{parseHTML:t=>{const e=$p(t,{allowedStyles:this.options.allowedStyles||[]});return e.length?e.join(" "):null}}}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>$p(t,{allowedStyles:this.options.allowedStyles||[]}).length?null:!1}]},renderHTML({HTMLAttributes:t}){const{class:e,...o}=t;return["span",Ct({class:e,style:zp(o)||void 0}),0]}}),ej=be.create({name:"textStyle",addAttributes(){return{class:{default:null},id:{default:null},color:{default:null}}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>{const e=t.getAttribute("style");return e&&/color/i.test(e)?null:!1}}]},renderHTML({HTMLAttributes:t}){const{class:e,id:o,...a}=t;return["span",Ct({class:e,id:o,style:zp(a)||void 0}),0]}}),Wp=be.create({name:"reporter",priority:0,addOptions(){return{allowCustomAttributes:!1}},parseHTML(){return[{tag:"*",consuming:!1,getAttrs:t=>{const e=t.tagName.toLowerCase();if(e==="a"&&this.options.allowCustomAttributes)return!1;const o=t.getAttributeNames().filter(a=>!(e in Ws?Ws[e]:[]).includes(a));for(const a of o)console.warn(`[StoryblokRichText] - \`${a}\` "${t.getAttribute(a)}" on \`<${e}>\` can not be transformed to rich text.`);return!1}}]}}),tj={document:Ph,text:h1,paragraph:zb,blockquote:Nb,heading:Ob,bulletList:Pb,orderedList:Hb,listItem:qb,codeBlock:Wb,hardBreak:Ub,horizontalRule:Vb,image:Pp,emoji:Xb,table:Kb,tableRow:$b,tableCell:Jb,tableHeader:Gb,blok:Hp,details:Ff,detailsContent:_f,detailsSummary:Df,bold:D1,italic:z1,strike:gb,underline:Eb,code:E1,superscript:jb,subscript:hb,highlight:Yb,textStyle:ej,link:Us,anchor:Qb,styled:qp,reporter:Wp,textAlign:Lb};function oj(t={}){const e=t.allowCustomAttributes?Zb:Us;return{...tj,image:Pp.configure({optimizeImages:t.optimizeImages||!1}),link:e,styled:qp.configure({allowedStyles:t.styleOptions?.map(o=>o.value)}),reporter:Wp.configure({allowCustomAttributes:t.allowCustomAttributes})}}function Up(t,e={},o){const a=Mb(e),n=a?`${t} ${a}`:t,s=Array.isArray(o)?o.join(""):o||"";if(t){if(Tb.includes(t))return`<${n}>`}else return s;return`<${n}>${s}</${t}>`}function jo(t,e,o){const[a,...n]=t;let s={},i=n;if(i.length>0&&i[0]!==null&&i[0]!==void 0&&typeof i[0]=="object"&&!Array.isArray(i[0])&&typeof i[0]!="number"&&(s=i[0],i=i.slice(1)),i=i.filter(l=>l!=null),i.length===0)return e(a,s);if(i.length===1&&i[0]===0)return e(a,s,o);const r=i.map(l=>l===0?o:Array.isArray(l)?jo(l,e,o):l);return e(a,s,r.length===1?r[0]:r)}function Ua(t,e,o){const a={options:t.options||{},name:t.name,type:t.type};return e==="node"?t.config.renderHTML.call(a,{node:{attrs:o},HTMLAttributes:o}):t.config.renderHTML.call(a,{mark:{attrs:o},HTMLAttributes:o})}function Vs(t={}){const e=new Map,{renderFn:o=Up,textFn:a=Bb,optimizeImages:n=!1,keyedResolvers:s=!1,tiptapExtensions:i}=t,r=o!==Up,l=oj({optimizeImages:n}),p=i?{...l,...i}:l,c=Object.values(p),m=new Map,u=new Map;for(const j of c)j.type==="node"?m.set(j.name,j):j.type==="mark"&&u.set(j.name,j);const d=(j,F={},_)=>{if(s&&j){const I=e.get(j)||0;e.set(j,I+1),F={...F,key:`${j}-${I}`}}return r&&typeof j!="string"&&_!==void 0?o(j,F,(()=>_)):o(j,F,_)};function g(j,F){const _=j.map(E=>b({...E,marks:xb(E.marks||[],F)}));let I=r?_:_.join("");for(const E of F){const L=u.get(E.type);L?.config?.renderHTML&&(I=jo(Ua(L,"mark",E.attrs||{}),d,I))}return I}function f(j){const F=[];let _=0;for(;_<j.length;){const I=Sb(j,_);if(!I){F.push(k(j[_])),_++;continue}I.group.length===1?F.push(b(I.group[0])):F.push(g(I.group,I.shared)),_=I.endIndex}return F}function h(j){if(j.type==="text")return b(j);if(j.type==="doc")return k(j);const F=m.get(j.type);if(!F?.config?.renderHTML)return console.error("<Storyblok>",`No extension found for node type ${j.type}`),"";if(F.options?.renderComponent){const I=j.attrs?.body,E=j.attrs?.id;if(!Array.isArray(I)||I.length===0)return r?[]:"";const L=I.map(z=>F.options.renderComponent(z,E));return r?L:L.filter(z=>z!=null).join("")}if(j.type==="table"&&j.content?.length){const I=[],E=[];for(const C of j.content)E.length===0&&C.content?.every(R=>R.type==="tableHeader")?I.push(C):E.push(C);const L=Ua(F,"node",j.attrs||{}),z=[];return I.length>0&&z.push(d("thead",{},I.map(k))),E.length>0&&z.push(d("tbody",{},E.map(k))),jo(L,d,z)}const _=j.content?f(j.content):void 0;return jo(Ua(F,"node",j.attrs||{}),d,_)}function b(j){const{marks:F,..._}=j;if(F?.length){const E=(()=>{const L={};if(s){const z=e.get("txt")||0;e.set("txt",z+1),L.key=`txt-${z}`}return a(_.text,L)})();return F.reduce((L,z)=>{const C=u.get(z.type);return C?.config?.renderHTML?jo(Ua(C,"mark",z.attrs||{}),d,L):(console.error("<Storyblok>",`No extension found for node type ${z.type}`),L)},E)}const I=j.attrs||{};if(s){const E=e.get("txt")||0;e.set("txt",E+1),I.key=`txt-${E}`}return a(_.text,I)}function k(j){const F=j;return F.type==="doc"?r?F.content.map(h):F.content.map(h).join(""):Array.isArray(F)?F.map(h):h(F)}return{render:k}}const aj="SB_BLOK_GROUP_",nj=/<!--SB_BLOK_GROUP_(\d+)-->/;function sj(t,e={}){const o=[],a=[],n=Vs({...e,tiptapExtensions:{blok:Hp.configure({renderComponent:s=>{const i=[s];return`<!--${aj}${a.push(i)-1}-->`}}),...e.tiptapExtensions}}).render(t).split(nj);for(let s=0;s<n.length;s++)if(s%2===0){const i=n[s];i&&i.trim()&&o.push({type:"html",content:i})}else{const i=a[Number(n[s])];if(i)for(const r of i)o.push({type:"blok",blok:r})}return o}const Ks=(t="")=>t.includes("/cdn/"),ij=(t,e=25,o=1)=>({...t,per_page:e,page:o}),rj=t=>new Promise(e=>setTimeout(e,t)),lj=(t=0,e)=>Array.from({length:t},e),pj=(t=0,e=t)=>{const o=Math.abs(e-t)||0,a=t<e?1:-1;return lj(o,(n,s)=>s*a+t)},cj=async(t,e)=>Promise.all(t.map(e)),mj=(t=[],e)=>t.map(e).reduce((o,a)=>[...o,...a],[]),Vp=t=>{if(/%[0-9A-F]{2}/i.test(t))try{return decodeURIComponent(t)}catch{return t}return t},Js=(t,e,o)=>{const a=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const s=t[n];if(s==null)continue;const i=o?"":encodeURIComponent(n);let r;typeof s=="object"?r=Js(s,e?e+encodeURIComponent(`[${i}]`):i,Array.isArray(s)):r=`${e?e+encodeURIComponent(`[${i}]`):i}=${encodeURIComponent(s)}`,a.push(r)}return a.join("&")},Kp=t=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[t]??e.eu};var uj=class{baseURL;timeout;headers;responseInterceptor;fetch;ejectInterceptor;url;parameters;fetchOptions;constructor(t){this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t?.timeout?t.timeout*1e3:0,this.responseInterceptor=t.responseInterceptor,this.fetch=(...e)=>t.fetch?t.fetch(...e):fetch(...e),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(t,e){return this.url=t,this.parameters=e,this._methodHandler("get")}post(t,e){return this.url=t,this.parameters=e,this._methodHandler("post")}put(t,e){return this.url=t,this.parameters=e,this._methodHandler("put")}delete(t,e){return this.url=t,this.parameters=e??{},this._methodHandler("delete")}async _responseHandler(t){const e=[],o={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(a=>{o.data=a});for(const a of t.headers.entries())e[a[0]]=a[1];return o.headers={...e},o.status=t.status,o.statusText=t.statusText,o}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,o=null;t==="get"?e=`${this.baseURL}${this.url}?${Js(this.parameters)}`:o=JSON.stringify(this.parameters);const a=new URL(e),n=new AbortController,{signal:s}=n;let i=null;this.timeout&&(i=setTimeout(()=>n.abort(),this.timeout));try{const r=await this.fetch(`${a}`,{method:t,headers:this.headers,body:o,signal:s,...this.fetchOptions});this.timeout&&i&&clearTimeout(i);const l=await this._responseHandler(r);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(r){return r.name==="AbortError"?{message:"Request timeout: The request was aborted due to timeout"}:{message:r.message||r.toString()||"An unknown error occurred"}}}setFetchOptions(t={}){Object.keys(t).length>0&&"method"in t&&delete t.method,this.fetchOptions={...t}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(t){if(Array.isArray(t))return t[0]||"Unknown error";if(t&&typeof t=="object"){if(t.error)return t.error;for(const e in t){if(Array.isArray(t[e]))return`${e}: ${t[e][0]}`;if(typeof t[e]=="string")return`${e}: ${t[e]}`}if(t.slug)return t.slug}return"Unknown error"}_statusHandler(t){const e=/20[0-6]/g;return new Promise((o,a)=>{if(e.test(`${t.status}`))return o(t);a({message:this._normalizeErrorMessage(t.data),status:t.status,response:t})})}};const Jp="SB-Agent",Gs={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},dj={PUBLISHED:"published"},gj=25,Xs={SMALL:25,MEDIUM:50,LARGE:75},$t={SINGLE_OR_SMALL:50,MEDIUM:15,LARGE:10,VERY_LARGE:6},Gp=1e3,Va=3;function fj(t,e){const o=t.includes("/cdn/stories/"),a=t.split("/").length>3&&!t.endsWith("/cdn/stories"),n="find_by"in e;return o&&a||n}function hj(t){return t<=Xs.SMALL?$t.SINGLE_OR_SMALL:t<=Xs.MEDIUM?$t.MEDIUM:t<=Xs.LARGE?$t.LARGE:$t.VERY_LARGE}function Ka(t,e,o={},a){return o.userRateLimit!==void 0?Math.min(o.userRateLimit,Gp):o.serverHeadersRateLimit!==void 0?Math.min(o.serverHeadersRateLimit,Gp):a!==void 0?a:!t||!e||fj(t,e)?$t.SINGLE_OR_SMALL:hj(e.per_page||gj)}function bj(t){if(!t)return null;const e=t["x-ratelimit"]||t["X-RateLimit"],o=t["x-ratelimit-policy"]||t["X-RateLimit-Policy"];if(!e&&!o)return null;const a={};if(e){const n=e.match(/r=(\d+)/);n&&(a.remaining=Number.parseInt(n[1],10))}if(o){const n=o.match(/q=(\d+)/);n&&(a.max=Number.parseInt(n[1],10))}return Object.keys(a).length>0?a:null}function jj(t,e=!1){return{userRateLimit:t,serverHeadersRateLimit:void 0,isManagementApi:e}}var vj=class extends Error{constructor(t){super(t),this.name="AbortError"}};function kj(t,e,o){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(o))throw new TypeError("Expected `interval` to be a finite number");const a=[];let n=[],s=0,i=!1;const r=async()=>{s++;const p=a.shift();if(p)try{const m=await t(...p.args);p.resolve(m)}catch(m){p.reject(m)}const c=setTimeout(()=>{s--,a.length>0&&r(),n=n.filter(m=>m!==c)},o);n.includes(c)||n.push(c)},l=(...p)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((c,m)=>{a.push({resolve:c,reject:m,args:p}),s<e&&r()});return l.abort=()=>{i=!0,n.forEach(clearTimeout),n=[],a.forEach(p=>p.reject(()=>new vj("Throttle function aborted"))),a.length=0},l}var yj=class{queues;interval;throttledRequestFn;constructor(t,e=1e3){this.queues=new Map,this.interval=e,this.throttledRequestFn=t}getQueue(t){let e=this.queues.get(t);return e||(e=kj(this.throttledRequestFn,t,this.interval),this.queues.set(t,e)),e}execute(t,...e){return this.getQueue(t)(...e)}abortAll(){this.queues.forEach(t=>{t.abort?.()}),this.queues.clear()}getQueueCount(){return this.queues.size}};let Ja={};const pt={};var Fj=class{client;maxRetries;retriesDelay;throttleManager;accessToken;cache;resolveCounter;relations;links;version;rateLimitConfig;cvMode;richTextResolver;resolveNestedRelations;stringifiedStoriesCache;inlineAssets;constructor(t,e){let o=t.endpoint||e;if(!o){const n=t.https===!1?"http":"https";t.oauthToken?o=`${n}://${Kp(t.region)}/v1`:o=`${n}://${Kp(t.region)}/v2`}const a=new Headers;a.set("Content-Type","application/json"),a.set("Accept","application/json"),t.headers&&(t.headers.constructor.name==="Headers"?t.headers.entries().toArray():Object.entries(t.headers)).forEach(([n,s])=>{a.set(n,s)}),a.has(Jp)||(a.set(Jp,Gs.defaultAgentName),a.set(Gs.defaultAgentVersion,Gs.packageVersion)),t.oauthToken&&a.set("Authorization",t.oauthToken),this.rateLimitConfig=jj(t.rateLimit,!!t.oauthToken),this.maxRetries=t.maxRetries||10,this.retriesDelay=300,this.throttleManager=new yj(this.throttledRequest.bind(this),1e3),this.accessToken=t.accessToken||"",this.relations={},this.links={},this.cache=t.cache||{clear:"manual"},this.cvMode=t.cache?.cv??"auto",this.resolveCounter=0,this.resolveNestedRelations=t.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=t.version||dj.PUBLISHED,this.inlineAssets=t.inlineAssets||!1,this.client=new uj({baseURL:o,timeout:t.timeout||0,headers:a,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}parseParams(t){return t.token||(t.token=this.getToken()),!t.cv&&this.cvMode==="auto"&&(t.cv=pt[t.token]),Array.isArray(t.resolve_relations)?t.resolve_relations=t.resolve_relations.map(Vp).join(","):typeof t.resolve_relations=="string"&&(t.resolve_relations=Vp(t.resolve_relations)),typeof t.resolve_relations<"u"&&(t.resolve_level=2),t}factoryParamOptions(t,e){return Ks(t)?this.parseParams(e):e}makeRequest(t,e,o,a,n){const s=this.factoryParamOptions(t,ij(e,o,a));return this.cacheResponse(t,s,void 0,n)}get(t,e={},o){e||(e={});const a=`/${t}`;Ks(a)&&(e.version=e.version||this.version);const n=this.factoryParamOptions(a,e);return this.cacheResponse(a,n,void 0,o)}async getAll(t,e={},o,a){const n=e?.per_page||25,s=`/${t}`.replace(/\/$/,""),i=o??s.substring(s.lastIndexOf("/")+1);e.version=e.version||this.version;const r=1,l=await this.makeRequest(s,e,n,r,a);return mj([l,...await cj(pj(r,l.total?Math.ceil(l.total/(l.perPage||n)):1),p=>this.makeRequest(s,e,n,p+1,a))],p=>Object.values(p.data[i]))}post(t,e={},o){const a=`/${t}`,n=Ka(void 0,void 0,this.rateLimitConfig,Va);return this.throttleManager.execute(n,"post",a,e,o)}put(t,e={},o){const a=`/${t}`,n=Ka(void 0,void 0,this.rateLimitConfig,Va);return this.throttleManager.execute(n,"put",a,e,o)}delete(t,e={},o){e||(e={});const a=`/${t}`,n=Ka(void 0,void 0,this.rateLimitConfig,Va);return this.throttleManager.execute(n,"delete",a,e,o)}getStories(t={},e){return this._addResolveLevel(t),this.get("cdn/stories",t,e)}getStory(t,e={},o){return this._addResolveLevel(e),this.get(`cdn/stories/${t}`,e,o)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(t){typeof t.resolve_relations<"u"&&(t.resolve_level=2)}_cleanCopy(t){return JSON.parse(JSON.stringify(t))}_insertLinks(t,e,o){const a=t[e];a&&a.fieldtype==="multilink"&&a.linktype==="story"&&typeof a.id=="string"&&this.links[o][a.id]?a.story=this._cleanCopy(this.links[o][a.id]):a&&a.linktype==="story"&&typeof a.uuid=="string"&&this.links[o][a.uuid]&&(a.story=this._cleanCopy(this.links[o][a.uuid]))}getStoryReference(t,e){return this.relations[t][e]?JSON.parse(this.stringifiedStoriesCache[e]||JSON.stringify(this.relations[t][e])):e}_resolveField(t,e,o){const a=t[e];typeof a=="string"?t[e]=this.getStoryReference(o,a):Array.isArray(a)&&(t[e]=a.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(t,e,o,a){if(Array.isArray(o)?o.find(s=>s.endsWith(`.${e}`)):o.endsWith(`.${e}`)){this._resolveField(t,e,a);return}const n=t.component?`${t.component}.${e}`:e;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(t,e,a)}iterateTree(t,e,o){const a=(n,s="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((i,r)=>a(i,`${s}[${r}]`));else if(typeof n=="object")for(const i in n){const r=s?`${s}.${i}`:i;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,i,e,o),this._insertLinks(n,i,o)),a(n[i],r)}}};a(t.content)}async resolveLinks(t,e,o){let a=[];if(t.link_uuids){const n=t.link_uuids.length,s=[],i=50;for(let r=0;r<n;r+=i){const l=Math.min(n,r+i);s.push(t.link_uuids.slice(r,l))}for(let r=0;r<s.length;r++)(await this.getStories({per_page:i,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:s[r].join(",")})).data.stories.forEach(l=>{a.push(l)})}else a=t.links;a.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(t,e,o){let a=[];if(t.rel_uuids){const n=t.rel_uuids.length,s=[],i=50;for(let r=0;r<n;r+=i){const l=Math.min(n,r+i);s.push(t.rel_uuids.slice(r,l))}for(let r=0;r<s.length;r++)(await this.getStories({per_page:i,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:s[r].join(","),excluding_fields:e.excluding_fields})).data.stories.forEach(l=>{a.push(l)});a.length>0&&(t.rels=a,delete t.rel_uuids)}else a=t.rels;a&&a.length>0&&a.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(t,e,o){let a=[];if(this.links[o]={},this.relations[o]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(a=e.resolve_relations.split(",")),await this.resolveRelations(t,e,o)),e.resolve_links&&["1","story","url","link"].includes(e.resolve_links)&&(t.links?.length||t.link_uuids?.length)&&await this.resolveLinks(t,e,o),this.resolveNestedRelations)for(const n in this.relations[o])this.iterateTree(this.relations[o][n],a,o);t.story?this.iterateTree(t.story,a,o):t.stories.forEach(n=>{this.iterateTree(n,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(t,e,o,a){const n=Js({url:t,params:e}),s=this.cacheProvider();if(e.version==="published"&&t!=="/cdn/spaces/me"){const l=await s.get(n);if(l)return Promise.resolve(l)}const i=!Ks(t)&&this.rateLimitConfig.isManagementApi?Va:void 0,r=Ka(t,e,this.rateLimitConfig,i);return new Promise(async(l,p)=>{try{const c=await this.throttleManager.execute(r,"get",t,e,a);if(c.status!==200)return p(c);let m={data:c.data,headers:c.headers};const u=bj(c.headers);if(u?.max!==void 0&&(this.rateLimitConfig.serverHeadersRateLimit=u.max),c.headers?.["per-page"]&&(m=Object.assign({},m,{perPage:c.headers["per-page"]?Number.parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?Number.parseInt(c.headers.total):0})),m.data.story||m.data.stories){const g=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(m.data,e,`${g}`),m=await this.processInlineAssets(m)}e.version==="published"&&t!=="/cdn/spaces/me"&&await s.set(n,m);const d=this.cache.clear==="onpreview"&&e.version==="draft"||this.cache.clear==="auto";return e.token&&m.data.cv&&(d&&pt[e.token]&&pt[e.token]!==m.data.cv&&await this.flushCache(),pt[e.token]=m.data.cv),l(m)}catch(c){if(c.response&&c.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await rj(this.retriesDelay),this.cacheResponse(t,e,o).then(l).catch(p);p(c)}})}throttledRequest(t,e,o,a){return this.client.setFetchOptions(a),this.client[t](e,o)}cacheVersions(){return pt}cacheVersion(){return pt[this.accessToken]}setCacheVersion(t){this.accessToken&&(pt[this.accessToken]=t)}clearCacheVersion(){this.accessToken&&(pt[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(Ja[t])},getAll(){return Promise.resolve(Ja)},set(t,e){return Ja[t]=e,Promise.resolve(void 0)},flush(){return Ja={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(t){if(!this.inlineAssets)return t;const e=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>e(n));let a={...o};a.fieldtype==="asset"&&Array.isArray(t.data.assets)&&(a={...t.data.assets.find(n=>n.id===a.id),...a});for(const n in a)typeof a[n]=="object"&&(a[n]=e(a[n]));return a};return t.data.story&&(t.data.story.content=e(t.data.story.content)),t.data.stories&&(t.data.stories=t.data.stories.map(o=>(o.content=e(o.content),o))),t}};let Xp=!1;const Yp=[],Zp=t=>new Promise((e,o)=>{if(typeof window>"u"){o(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=n=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}Xp?n():Yp.push(n)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const a=document.createElement("script");a.async=!0,a.src=t,a.id="storyblok-javascript-bridge",a.onerror=n=>o(n),a.onload=n=>{Yp.forEach(s=>s()),Xp=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(a)}),_j=(t={})=>{const{apiOptions:e}=t;if(!e||!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 Fj(e)}},Dj=t=>{if(typeof t!="object"||typeof t._editable>"u")return{};try{const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let Ys="https://app.storyblok.com/f/storyblok-v2-latest.js";const wj=(t={})=>{var e,o;const{bridge:a,accessToken:n,use:s=[],apiOptions:i={},bridgeUrl:r}=t;i.accessToken=i.accessToken||n;const l={bridge:a,apiOptions:i};let p={};s.forEach(m=>{p={...p,...m(l)}}),r&&(Ys=r);const c=!(typeof window>"u")&&((o=(e=window.location)==null?void 0:e.search)==null?void 0:o.includes("_storyblok_tk"));return a!==!1&&c&&Zp(Ys),p};function Ij(t,e){return Vs(e).render(t)}const Cj=()=>Zp(Ys);Q.apiPlugin=_j,Q.getLiveStory=lc,Q.getPayload=pc,Q.handleStoryblokMessage=Wc,Q.isEditorRequest=Qc,Q.loadStoryblokBridge=Cj,Q.renderRichText=Ij,Q.richTextResolver=Vs,Q.sanitizeJSON=Dc,Q.segmentStoryblokRichText=sj,Q.storyblok=_c,Q.storyblokEditable=Dj,Q.storyblokInit=wj,Q.toCamelCase=si,Q.useStoryblokApi=rc,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/astro",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.7",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Official Astro integration for the Storyblok Headless CMS",
|
|
7
7
|
"author": "Storyblok",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"camelcase": "^8.0.0",
|
|
57
57
|
"morphdom": "^2.7.8",
|
|
58
|
-
"@storyblok/js": "5.1.
|
|
58
|
+
"@storyblok/js": "5.1.6"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@cypress/vite-dev-server": "^6.0.3",
|