@storyblok/js 4.2.3 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +595 -629
- package/package.json +5 -4
package/dist/storyblok-js.js
CHANGED
@@ -4,4 +4,4 @@
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using JavaScript.
|
5
5
|
* author: undefined
|
6
6
|
*/
|
7
|
-
(function(v,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(v=typeof globalThis<"u"?globalThis:v||self,S(v.storyblok={}))})(this,function(v){"use strict";const S=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,nt=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;function I(s){switch(s){case 9:case 32:return!0}return!1}function z(s){if(s>=8192&&s<=8202)return!0;switch(s){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function q(s){return S.test(s)||nt.test(s)}function G(s){switch(s){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function B(s,t,e){this.type=s,this.tag=t,this.attrs=null,this.map=null,this.nesting=e,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}B.prototype.attrIndex=function(t){if(!this.attrs)return-1;const e=this.attrs;for(let r=0,u=e.length;r<u;r++)if(e[r][0]===t)return r;return-1},B.prototype.attrPush=function(t){this.attrs?this.attrs.push(t):this.attrs=[t]},B.prototype.attrSet=function(t,e){const r=this.attrIndex(t),u=[t,e];r<0?this.attrPush(u):this.attrs[r]=u},B.prototype.attrGet=function(t){const e=this.attrIndex(t);let r=null;return e>=0&&(r=this.attrs[e][1]),r},B.prototype.attrJoin=function(t,e){const r=this.attrIndex(t);r<0?this.attrPush([t,e]):this.attrs[r][1]=this.attrs[r][1]+" "+e};function ot(s,t,e){this.src=s,this.env=e,this.tokens=[],this.inlineMode=!1,this.md=t}ot.prototype.Token=B;function w(s,t,e,r){this.src=s,this.md=t,this.env=e,this.tokens=r,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const u=this.src;for(let i=0,a=0,o=0,n=0,l=u.length,h=!1;a<l;a++){const D=u.charCodeAt(a);if(!h)if(I(D)){o++,D===9?n+=4-n%4:n++;continue}else h=!0;(D===10||a===l-1)&&(D!==10&&a++,this.bMarks.push(i),this.eMarks.push(a),this.tShift.push(o),this.sCount.push(n),this.bsCount.push(0),h=!1,o=0,n=0,i=a+1)}this.bMarks.push(u.length),this.eMarks.push(u.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}w.prototype.push=function(s,t,e){const r=new B(s,t,e);return r.block=!0,e<0&&this.level--,r.level=this.level,e>0&&this.level++,this.tokens.push(r),r},w.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},w.prototype.skipEmptyLines=function(t){for(let e=this.lineMax;t<e&&!(this.bMarks[t]+this.tShift[t]<this.eMarks[t]);t++);return t},w.prototype.skipSpaces=function(t){for(let e=this.src.length;t<e;t++){const r=this.src.charCodeAt(t);if(!I(r))break}return t},w.prototype.skipSpacesBack=function(t,e){if(t<=e)return t;for(;t>e;)if(!I(this.src.charCodeAt(--t)))return t+1;return t},w.prototype.skipChars=function(t,e){for(let r=this.src.length;t<r&&this.src.charCodeAt(t)===e;t++);return t},w.prototype.skipCharsBack=function(t,e,r){if(t<=r)return t;for(;t>r;)if(e!==this.src.charCodeAt(--t))return t+1;return t},w.prototype.getLines=function(t,e,r,u){if(t>=e)return"";const i=new Array(e-t);for(let a=0,o=t;o<e;o++,a++){let n=0;const l=this.bMarks[o];let h=l,D;for(o+1<e||u?D=this.eMarks[o]+1:D=this.eMarks[o];h<D&&n<r;){const A=this.src.charCodeAt(h);if(I(A))A===9?n+=4-(n+this.bsCount[o])%4:n++;else if(h-l<this.tShift[o])n++;else break;h++}n>r?i[a]=new Array(n-r+1).join(" ")+this.src.slice(h,D):i[a]=this.src.slice(h,D)}return i.join("")},w.prototype.Token=B;const at=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],lt="[a-zA-Z_:][a-zA-Z0-9:._-]*",ct="(?:"+"[^\"'=<>`\\x00-\\x20]+"+"|"+"'[^']*'"+"|"+'"[^"]*"'+")",ht="<[A-Za-z][A-Za-z0-9\\-]*"+("(?:\\s+"+lt+"(?:\\s*=\\s*"+ct+")?)")+"*\\s*\\/?>",Dt="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",dt=new RegExp("^(?:"+ht+"|"+Dt+")");new RegExp("^</?("+at.join("|")+")(?=(\\s|/?>|$))","i"),new RegExp(dt.source+"\\s*$");function L(s,t,e,r){this.src=s,this.env=e,this.md=t,this.tokens=r,this.tokens_meta=Array(r.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}L.prototype.pushPending=function(){const s=new B("text","",0);return s.content=this.pending,s.level=this.pendingLevel,this.tokens.push(s),this.pending="",s},L.prototype.push=function(s,t,e){this.pending&&this.pushPending();const r=new B(s,t,e);let u=null;return e<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),r.level=this.level,e>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],u={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(u),r},L.prototype.scanDelims=function(s,t){const e=this.posMax,r=this.src.charCodeAt(s),u=s>0?this.src.charCodeAt(s-1):32;let i=s;for(;i<e&&this.src.charCodeAt(i)===r;)i++;const a=i-s,o=i<e?this.src.charCodeAt(i):32,n=G(u)||q(String.fromCharCode(u)),l=G(o)||q(String.fromCharCode(o)),h=z(u),D=z(o),A=!D&&(!l||h||n),y=!h&&(!n||D||l);return{can_open:A&&(t||!y||n),can_close:y&&(t||!A||l),length:a}},L.prototype.Token=B;const J=[];for(let s=0;s<256;s++)J.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(s){J[s.charCodeAt(0)]=1});let m=function(s){return s.DOCUMENT="doc",s.HEADING="heading",s.PARAGRAPH="paragraph",s.QUOTE="blockquote",s.OL_LIST="ordered_list",s.UL_LIST="bullet_list",s.LIST_ITEM="list_item",s.CODE_BLOCK="code_block",s.HR="horizontal_rule",s.BR="hard_break",s.IMAGE="image",s.EMOJI="emoji",s.COMPONENT="blok",s.TABLE="table",s.TABLE_ROW="tableRow",s.TABLE_CELL="tableCell",s.TABLE_HEADER="tableHeader",s}({}),x=function(s){return s.BOLD="bold",s.STRONG="strong",s.STRIKE="strike",s.UNDERLINE="underline",s.ITALIC="italic",s.CODE="code",s.LINK="link",s.ANCHOR="anchor",s.STYLED="styled",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.TEXT_STYLE="textStyle",s.HIGHLIGHT="highlight",s}({}),V=function(s){return s.TEXT="text",s}({}),O=function(s){return s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s}({});function Ft(s,t){if(!t)return{src:s,attrs:{}};let e=0,r=0;const u={},i=[];function a(n,l,h,D,A){typeof n!="number"||n<=l||n>=h?console.warn(`[StoryblokRichText] - ${D.charAt(0).toUpperCase()+D.slice(1)} value must be a number between ${l} and ${h} (inclusive)`):A.push(`${D}(${n})`)}if(typeof t=="object"){if(typeof t.width=="number"&&t.width>0?(u.width=t.width,e=t.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),t.height&&typeof t.height=="number"&&t.height>0?(u.height=t.height,r=t.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),t.loading&&["lazy","eager"].includes(t.loading)&&(u.loading=t.loading),t.class&&(u.class=t.class),t.filters){const{filters:n}=t||{},{blur:l,brightness:h,fill:D,format:A,grayscale:y,quality:R,rotate:T}=n||{};l&&a(l,0,100,"blur",i),R&&a(R,0,100,"quality",i),h&&a(h,0,100,"brightness",i),D&&i.push(`fill(${D})`),y&&i.push("grayscale()"),T&&[0,90,180,270].includes(t.filters.rotate||0)&&i.push(`rotate(${T})`),A&&["webp","png","jpeg"].includes(A)&&i.push(`format(${A})`)}t.srcset&&(u.srcset=t.srcset.map(n=>{if(typeof n=="number")return`${s}/m/${n}x0/${i.length>0?`filters:${i.join(":")}`:""} ${n}w`;if(Array.isArray(n)&&n.length===2){const[l,h]=n;return`${s}/m/${l}x${h}/${i.length>0?`filters:${i.join(":")}`:""} ${l}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),t.sizes&&(u.sizes=t.sizes.join(", "))}let o=`${s}/m/`;return e>0&&r>0&&(o=`${o}${e}x${r}/`),i.length>0&&(o=`${o}filters:${i.join(":")}`),{src:o,attrs:u}}const ft=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],pt=(s={})=>Object.keys(s).map(t=>`${t}="${s[t]}"`).join(" "),Et=(s={})=>Object.keys(s).map(t=>`${t}: ${s[t]}`).join("; ");function At(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const P=s=>Object.fromEntries(Object.entries(s).filter(([t,e])=>e!==void 0));function W(s,t={},e){const r=pt(t),u=r?`${s} ${r}`:s,i=Array.isArray(e)?e.join(""):e||"";if(s){if(ft.includes(s))return`<${u}>`}else return i;return`<${u}>${i}</${s}>`}function Y(s={}){const t=new Map,{renderFn:e=W,textFn:r=At,resolvers:u={},optimizeImages:i=!1,keyedResolvers:a=!1}=s,o=e!==W,n=c=>(F,d)=>{const f=F.attrs||{};return d.render(c,f,F.children||null)},l=(c,F)=>{const{src:d,alt:f,title:E,srcset:C,sizes:g}=c.attrs||{};let b=d,k={};if(i){const{src:qt,attrs:Gt}=Ft(d,i);b=qt,k=Gt}const zt={src:b,alt:f,title:E,srcset:C,sizes:g,...k};return F.render("img",P(zt))},h=(c,F)=>{const{level:d,...f}=c.attrs||{};return F.render(`h${d}`,f,c.children)},D=(c,F)=>{var f,E,C,g;const d=F.render("img",{src:(f=c.attrs)==null?void 0:f.fallbackImage,alt:(E=c.attrs)==null?void 0:E.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return F.render("span",{"data-type":"emoji","data-name":(C=c.attrs)==null?void 0:C.name,"data-emoji":(g=c.attrs)==null?void 0:g.emoji},d)},A=(c,F)=>F.render("pre",c.attrs||{},F.render("code",{},c.children||"")),y=(c,F=!1)=>({text:d,attrs:f},E)=>{const{class:C,id:g,...b}=f||{},k=F?{class:C,id:g,style:Et(b)||void 0}:f||{};return E.render(c,P(k),d)},R=c=>U(c),T=c=>{const{marks:F,...d}=c;if("text"in c){if(F)return F.reduce((E,C)=>R({...C,text:E}),R({...d,children:d.children}));const f=c.attrs||{};if(a){const E=t.get("txt")||0;t.set("txt",E+1),f.key=`txt-${E}`}return r(d.text,f)}return""},rt=(c,F)=>{const{linktype:d,href:f,anchor:E,...C}=c.attrs||{};let g="";switch(d){case O.ASSET:case O.URL:g=f;break;case O.EMAIL:g=`mailto:${f}`;break;case O.STORY:g=f,E&&(g=`${g}#${E}`);break;default:g=f;break}const b={...C};return g&&(b.href=g),F.render("a",b,c.text)},jt=(c,F)=>{var d,f;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),F.render("span",{blok:(d=c==null?void 0:c.attrs)==null?void 0:d.body[0],id:(f=c.attrs)==null?void 0:f.id,style:"display: none"})},$t=(c,F)=>{const d={},f=F.render("tbody",{},c.children);return F.render("table",d,f)},Nt=(c,F)=>{const d={};return F.render("tr",d,c.children)},Ht=(c,F)=>{const{colspan:d,rowspan:f,colwidth:E,backgroundColor:C,...g}=c.attrs||{},b={...g};d>1&&(b.colspan=d),f>1&&(b.rowspan=f);const k=[];return E&&k.push(`width: ${E}px;`),C&&k.push(`background-color: ${C};`),k.length>0&&(b.style=k.join(" ")),F.render("td",P(b),c.children)},Mt=(c,F)=>{const{colspan:d,rowspan:f,colwidth:E,backgroundColor:C,...g}=c.attrs||{},b={...g};d>1&&(b.colspan=d),f>1&&(b.rowspan=f);const k=[];return E&&k.push(`width: ${E}px;`),C&&k.push(`background-color: ${C};`),k.length>0&&(b.style=k.join(" ")),F.render("th",P(b),c.children)},ut=new Map([[m.DOCUMENT,n("")],[m.HEADING,h],[m.PARAGRAPH,n("p")],[m.UL_LIST,n("ul")],[m.OL_LIST,n("ol")],[m.LIST_ITEM,n("li")],[m.IMAGE,l],[m.EMOJI,D],[m.CODE_BLOCK,A],[m.HR,n("hr")],[m.BR,n("br")],[m.QUOTE,n("blockquote")],[m.COMPONENT,jt],[V.TEXT,T],[x.LINK,rt],[x.ANCHOR,rt],[x.STYLED,y("span",!0)],[x.BOLD,y("strong")],[x.TEXT_STYLE,y("span",!0)],[x.ITALIC,y("em")],[x.UNDERLINE,y("u")],[x.STRIKE,y("s")],[x.CODE,y("code")],[x.SUPERSCRIPT,y("sup")],[x.SUBSCRIPT,y("sub")],[x.HIGHLIGHT,y("mark")],[m.TABLE,$t],[m.TABLE_ROW,Nt],[m.TABLE_CELL,Ht],[m.TABLE_HEADER,Mt]]),it=new Map([...ut,...Object.entries(u).map(([c,F])=>[c,F])]),Ut=()=>({render:(d,f={},E)=>{if(a&&d){const C=t.get(d)||0;t.set(d,C+1),f.key=`${d}-${C}`}return e(d,f,E)},originalResolvers:ut,mergedResolvers:it});function $(c){const F=it.get(c.type);if(!F)return console.error("<Storyblok>",`No resolver found for node type ${c.type}`),"";const d=Ut();if(c.type==="text")return F(c,d);const f=c.content?c.content.map(U):void 0;return F({...c,children:f},d)}function U(c){return c.type==="doc"?o?c.content.map($):c.content.map($).join(""):Array.isArray(c)?c.map($):$(c)}return{render:U}}let K=!1;const Z=[],X=s=>new Promise((t,e)=>{if(typeof window>"u"){e(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=u=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}K?u():Z.push(u)},document.getElementById("storyblok-javascript-bridge")){t(void 0);return}const r=document.createElement("script");r.async=!0,r.src=s,r.id="storyblok-javascript-bridge",r.onerror=u=>e(u),r.onload=u=>{Z.forEach(i=>i()),K=!0,t(u)},document.getElementsByTagName("head")[0].appendChild(r)});var Ct=Object.defineProperty,gt=(s,t,e)=>t in s?Ct(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,p=(s,t,e)=>gt(s,typeof t!="symbol"?t+"":t,e);class mt extends Error{constructor(t){super(t),this.name="AbortError"}}function yt(s,t,e){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");const r=[];let u=[],i=0,a=!1;const o=async()=>{i++;const l=r.shift();if(l)try{const D=await s(...l.args);l.resolve(D)}catch(D){l.reject(D)}const h=setTimeout(()=>{i--,r.length>0&&o(),u=u.filter(D=>D!==h)},e);u.includes(h)||u.push(h)},n=(...l)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((h,D)=>{r.push({resolve:h,reject:D,args:l}),i<t&&o()});return n.abort=()=>{a=!0,u.forEach(clearTimeout),u=[],r.forEach(l=>l.reject(()=>new mt("Throttle function aborted"))),r.length=0},n}const Q=(s="")=>s.includes("/cdn/"),bt=(s,t=25,e=1)=>({...s,per_page:t,page:e}),vt=s=>new Promise(t=>setTimeout(t,s)),kt=(s=0,t)=>Array.from({length:s},t),xt=(s=0,t=s)=>{const e=Math.abs(t-s)||0,r=s<t?1:-1;return kt(e,(u,i)=>i*r+s)},Bt=async(s,t)=>Promise.all(s.map(t)),wt=(s=[],t)=>s.map(t).reduce((e,r)=>[...e,...r],[]),N=(s,t,e)=>{const r=[];for(const u in s){if(!Object.prototype.hasOwnProperty.call(s,u))continue;const i=s[u];if(i==null)continue;const a=e?"":encodeURIComponent(u);let o;typeof i=="object"?o=N(i,t?t+encodeURIComponent(`[${a}]`):a,Array.isArray(i)):o=`${t?t+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(i)}`,r.push(o)}return r.join("&")},tt=s=>{const t={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return t[s]??t.eu};class _t{constructor(t){p(this,"baseURL"),p(this,"timeout"),p(this,"headers"),p(this,"responseInterceptor"),p(this,"fetch"),p(this,"ejectInterceptor"),p(this,"url"),p(this,"parameters"),p(this,"fetchOptions"),this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t!=null&&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=[],r={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(u=>{r.data=u});for(const u of t.headers.entries())e[u[0]]=u[1];return r.headers={...e},r.status=t.status,r.statusText=t.statusText,r}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,r=null;t==="get"?e=`${this.baseURL}${this.url}?${N(this.parameters)}`:r=JSON.stringify(this.parameters);const u=new URL(e),i=new AbortController,{signal:a}=i;let o;this.timeout&&(o=setTimeout(()=>i.abort(),this.timeout));try{const n=await this.fetch(`${u}`,{method:t,headers:this.headers,body:r,signal:a,...this.fetchOptions});this.timeout&&clearTimeout(o);const l=await this._responseHandler(n);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(n){return{message:n}}}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((r,u)=>{if(e.test(`${t.status}`))return r(t);const i={message:this._normalizeErrorMessage(t.data),status:t.status,response:t};u(i)})}}const et="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},Rt={PUBLISHED:"published"};let j={};const _={};class St{constructor(t,e){p(this,"client"),p(this,"maxRetries"),p(this,"retriesDelay"),p(this,"throttle"),p(this,"accessToken"),p(this,"cache"),p(this,"resolveCounter"),p(this,"relations"),p(this,"links"),p(this,"version"),p(this,"richTextResolver"),p(this,"resolveNestedRelations"),p(this,"stringifiedStoriesCache"),p(this,"inlineAssets");let r=t.endpoint||e;if(!r){const a=t.https===!1?"http":"https";t.oauthToken?r=`${a}://${tt(t.region)}/v1`:r=`${a}://${tt(t.region)}/v2`}const u=new Headers;u.set("Content-Type","application/json"),u.set("Accept","application/json"),t.headers&&(t.headers.constructor.name==="Headers"?t.headers.entries().toArray():Object.entries(t.headers)).forEach(([a,o])=>{u.set(a,o)}),u.has(et)||(u.set(et,H.defaultAgentName),u.set(H.defaultAgentVersion,H.packageVersion));let i=5;t.oauthToken&&(u.set("Authorization",t.oauthToken),i=3),t.rateLimit&&(i=t.rateLimit),this.maxRetries=t.maxRetries||10,this.retriesDelay=300,this.throttle=yt(this.throttledRequest.bind(this),i,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||Rt.PUBLISHED,this.inlineAssets=t.inlineAssets||!1,this.client=new _t({baseURL:r,timeout:t.timeout||0,headers:u,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}parseParams(t){return t.token||(t.token=this.getToken()),t.cv||(t.cv=_[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),typeof t.resolve_relations<"u"&&(t.resolve_level=2),t}factoryParamOptions(t,e){return Q(t)?this.parseParams(e):e}makeRequest(t,e,r,u,i){const a=this.factoryParamOptions(t,bt(e,r,u));return this.cacheResponse(t,a,void 0,i)}get(t,e={},r){e||(e={});const u=`/${t}`;Q(u)&&(e.version=e.version||this.version);const i=this.factoryParamOptions(u,e);return this.cacheResponse(u,i,void 0,r)}async getAll(t,e={},r,u){const i=(e==null?void 0:e.per_page)||25,a=`/${t}`.replace(/\/$/,""),o=r??a.substring(a.lastIndexOf("/")+1);e.version=e.version||this.version;const n=1,l=await this.makeRequest(a,e,i,n,u),h=l.total?Math.ceil(l.total/(l.perPage||i)):1,D=await Bt(xt(n,h),A=>this.makeRequest(a,e,i,A+1,u));return wt([l,...D],A=>Object.values(A.data[o]))}post(t,e={},r){const u=`/${t}`;return this.throttle("post",u,e,r)}put(t,e={},r){const u=`/${t}`;return this.throttle("put",u,e,r)}delete(t,e={},r){e||(e={});const u=`/${t}`;return this.throttle("delete",u,e,r)}getStories(t={},e){return this._addResolveLevel(t),this.get("cdn/stories",t,e)}getStory(t,e={},r){return this._addResolveLevel(e),this.get(`cdn/stories/${t}`,e,r)}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,r){const u=t[e];u&&u.fieldtype==="multilink"&&u.linktype==="story"&&typeof u.id=="string"&&this.links[r][u.id]?u.story=this._cleanCopy(this.links[r][u.id]):u&&u.linktype==="story"&&typeof u.uuid=="string"&&this.links[r][u.uuid]&&(u.story=this._cleanCopy(this.links[r][u.uuid]))}getStoryReference(t,e){return this.relations[t][e]?JSON.parse(this.stringifiedStoriesCache[e]||JSON.stringify(this.relations[t][e])):e}_resolveField(t,e,r){const u=t[e];typeof u=="string"?t[e]=this.getStoryReference(r,u):Array.isArray(u)&&(t[e]=u.map(i=>this.getStoryReference(r,i)).filter(Boolean))}_insertRelations(t,e,r,u){if(Array.isArray(r)?r.find(a=>a.endsWith(`.${e}`)):r.endsWith(`.${e}`)){this._resolveField(t,e,u);return}const i=t.component?`${t.component}.${e}`:e;(Array.isArray(r)?r.includes(i):r===i)&&this._resolveField(t,e,u)}iterateTree(t,e,r){const u=(i,a="")=>{if(!(!i||i._stopResolving)){if(Array.isArray(i))i.forEach((o,n)=>u(o,`${a}[${n}]`));else if(typeof i=="object")for(const o in i){const n=a?`${a}.${o}`:o;(i.component&&i._uid||i.type==="link")&&(this._insertRelations(i,o,e,r),this._insertLinks(i,o,r)),u(i[o],n)}}};u(t.content)}async resolveLinks(t,e,r){let u=[];if(t.link_uuids){const i=t.link_uuids.length,a=[],o=50;for(let n=0;n<i;n+=o){const l=Math.min(i,n+o);a.push(t.link_uuids.slice(n,l))}for(let n=0;n<a.length;n++)(await this.getStories({per_page:o,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:a[n].join(",")})).data.stories.forEach(l=>{u.push(l)})}else u=t.links;u.forEach(i=>{this.links[r][i.uuid]={...i,_stopResolving:!0}})}async resolveRelations(t,e,r){let u=[];if(t.rel_uuids){const i=t.rel_uuids.length,a=[],o=50;for(let n=0;n<i;n+=o){const l=Math.min(i,n+o);a.push(t.rel_uuids.slice(n,l))}for(let n=0;n<a.length;n++)(await this.getStories({per_page:o,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:a[n].join(","),excluding_fields:e.excluding_fields})).data.stories.forEach(l=>{u.push(l)});u.length>0&&(t.rels=u,delete t.rel_uuids)}else u=t.rels;u&&u.length>0&&u.forEach(i=>{this.relations[r][i.uuid]={...i,_stopResolving:!0}})}async resolveStories(t,e,r){var u,i;let a=[];if(this.links[r]={},this.relations[r]={},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,r)),e.resolve_links&&["1","story","url","link"].includes(e.resolve_links)&&((u=t.links)!=null&&u.length||(i=t.link_uuids)!=null&&i.length)&&await this.resolveLinks(t,e,r),this.resolveNestedRelations)for(const o in this.relations[r])this.iterateTree(this.relations[r][o],a,r);t.story?this.iterateTree(t.story,a,r):t.stories.forEach(o=>{this.iterateTree(o,a,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(t,e,r,u){const i=N({url:t,params:e}),a=this.cacheProvider();if(e.version==="published"&&t!=="/cdn/spaces/me"){const o=await a.get(i);if(o)return Promise.resolve(o)}return new Promise(async(o,n)=>{var l;try{const h=await this.throttle("get",t,e,u);if(h.status!==200)return n(h);let D={data:h.data,headers:h.headers};if((l=h.headers)!=null&&l["per-page"]&&(D=Object.assign({},D,{perPage:h.headers["per-page"]?Number.parseInt(h.headers["per-page"]):0,total:h.headers["per-page"]?Number.parseInt(h.headers.total):0})),D.data.story||D.data.stories){const y=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(D.data,e,`${y}`),D=await this.processInlineAssets(D)}e.version==="published"&&t!=="/cdn/spaces/me"&&await a.set(i,D);const A=this.cache.clear==="onpreview"&&e.version==="draft"||this.cache.clear==="auto";return e.token&&D.data.cv&&(A&&_[e.token]&&_[e.token]!==D.data.cv&&await this.flushCache(),_[e.token]=D.data.cv),o(D)}catch(h){if(h.response&&h.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await vt(this.retriesDelay),this.cacheResponse(t,e,r).then(o).catch(n);n(h)}})}throttledRequest(t,e,r,u){return this.client.setFetchOptions(u),this.client[t](e,r)}cacheVersions(){return _}cacheVersion(){return _[this.accessToken]}setCacheVersion(t){this.accessToken&&(_[this.accessToken]=t)}clearCacheVersion(){this.accessToken&&(_[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve(j[t])},getAll(){return Promise.resolve(j)},set(t,e){return j[t]=e,Promise.resolve(void 0)},flush(){return j={},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=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(i=>e(i));let u={...r};u.fieldtype==="asset"&&Array.isArray(t.data.assets)&&(u={...u,...t.data.assets.find(i=>i.id===u.id)});for(const i in u)typeof u[i]=="object"&&(u[i]=e(u[i]));return u};return t.data.story&&(t.data.story.content=e(t.data.story.content)),t.data.stories&&(t.data.stories=t.data.stories.map(r=>(r.content=e(r.content),r))),t}}const Tt=(s={})=>{const{apiOptions:t}=s;if(!t||!t.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new St(t)}},It=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};try{const t=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":`${t.id}-${t.uid}`}:{}}catch{return{}}};let M="https://app.storyblok.com/f/storyblok-v2-latest.js";const st=(s,t,e={})=>{var o;const u=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=new URL((o=window.location)==null?void 0:o.href).searchParams.get("_storyblok"),a=i!==null&&+i===s;if(!(!u||!a)){if(!s){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(e).on(["input","published","change"],l=>{var h;l&&(l.action==="input"&&((h=l.story)==null?void 0:h.id)===s?t(l.story):(l.action==="change"||l.action==="published")&&l.storyId===s&&window.location.reload())})})}},Lt=(s={})=>{var h,D;const{bridge:t,accessToken:e,use:r=[],apiOptions:u={},bridgeUrl:i}=s;u.accessToken=u.accessToken||e;const a={bridge:t,apiOptions:u};let o={};r.forEach(A=>{o={...o,...A(a)}}),i&&(M=i);const l=!(typeof window>"u")&&((D=(h=window.location)==null?void 0:h.search)==null?void 0:D.includes("_storyblok_tk"));return t!==!1&&l&&X(M),o};function Ot(s,t){return Y(t).render(s)}const Pt=()=>X(M);v.BlockTypes=m,v.MarkTypes=x,v.TextTypes=V,v.apiPlugin=Tt,v.loadStoryblokBridge=Pt,v.registerStoryblokBridge=st,v.renderRichText=Ot,v.richTextResolver=Y,v.storyblokEditable=It,v.storyblokInit=Lt,v.useStoryblokBridge=st,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
7
|
+
(function(p,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(p=typeof globalThis<"u"?globalThis:p||self,x(p.storyblok={}))})(this,function(p){"use strict";var Vt=Object.defineProperty;var Kt=(p,x,S)=>x in p?Vt(p,x,{enumerable:!0,configurable:!0,writable:!0,value:S}):p[x]=S;var E=(p,x,S)=>Kt(p,typeof x!="symbol"?x+"":x,S);const x=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,S=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;function P(t){switch(t){case 9:case 32:return!0}return!1}function q(t){if(t>=8192&&t<=8202)return!0;switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function G(t){return x.test(t)||S.test(t)}function J(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function B(t,e,r){this.type=t,this.tag=e,this.attrs=null,this.map=null,this.nesting=r,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}B.prototype.attrIndex=function(e){if(!this.attrs)return-1;const r=this.attrs;for(let s=0,u=r.length;s<u;s++)if(r[s][0]===e)return s;return-1},B.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]},B.prototype.attrSet=function(e,r){const s=this.attrIndex(e),u=[e,r];s<0?this.attrPush(u):this.attrs[s]=u},B.prototype.attrGet=function(e){const r=this.attrIndex(e);let s=null;return r>=0&&(s=this.attrs[r][1]),s},B.prototype.attrJoin=function(e,r){const s=this.attrIndex(e);s<0?this.attrPush([e,r]):this.attrs[s][1]=this.attrs[s][1]+" "+r};function ot(t,e,r){this.src=t,this.env=r,this.tokens=[],this.inlineMode=!1,this.md=e}ot.prototype.Token=B;function w(t,e,r,s){this.src=t,this.md=e,this.env=r,this.tokens=s,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const u=this.src;for(let i=0,o=0,n=0,a=0,c=u.length,h=!1;o<c;o++){const D=u.charCodeAt(o);if(!h)if(P(D)){n++,D===9?a+=4-a%4:a++;continue}else h=!0;(D===10||o===c-1)&&(D!==10&&o++,this.bMarks.push(i),this.eMarks.push(o),this.tShift.push(n),this.sCount.push(a),this.bsCount.push(0),h=!1,n=0,a=0,i=o+1)}this.bMarks.push(u.length),this.eMarks.push(u.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}w.prototype.push=function(t,e,r){const s=new B(t,e,r);return s.block=!0,r<0&&this.level--,s.level=this.level,r>0&&this.level++,this.tokens.push(s),s},w.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},w.prototype.skipEmptyLines=function(e){for(let r=this.lineMax;e<r&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e},w.prototype.skipSpaces=function(e){for(let r=this.src.length;e<r;e++){const s=this.src.charCodeAt(e);if(!P(s))break}return e},w.prototype.skipSpacesBack=function(e,r){if(e<=r)return e;for(;e>r;)if(!P(this.src.charCodeAt(--e)))return e+1;return e},w.prototype.skipChars=function(e,r){for(let s=this.src.length;e<s&&this.src.charCodeAt(e)===r;e++);return e},w.prototype.skipCharsBack=function(e,r,s){if(e<=s)return e;for(;e>s;)if(r!==this.src.charCodeAt(--e))return e+1;return e},w.prototype.getLines=function(e,r,s,u){if(e>=r)return"";const i=new Array(r-e);for(let o=0,n=e;n<r;n++,o++){let a=0;const c=this.bMarks[n];let h=c,D;for(n+1<r||u?D=this.eMarks[n]+1:D=this.eMarks[n];h<D&&a<s;){const b=this.src.charCodeAt(h);if(P(b))b===9?a+=4-(a+this.bsCount[n])%4:a++;else if(h-c<this.tShift[n])a++;else break;h++}a>s?i[o]=new Array(a-s+1).join(" ")+this.src.slice(h,D):i[o]=this.src.slice(h,D)}return i.join("")},w.prototype.Token=B;const at=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ct="[a-zA-Z_:][a-zA-Z0-9:._-]*",lt="(?:"+"[^\"'=<>`\\x00-\\x20]+"+"|"+"'[^']*'"+"|"+'"[^"]*"'+")",ht="<[A-Za-z][A-Za-z0-9\\-]*"+("(?:\\s+"+ct+"(?:\\s*=\\s*"+lt+")?)")+"*\\s*\\/?>",Dt="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",dt=new RegExp("^(?:"+ht+"|"+Dt+")");new RegExp("^</?("+at.join("|")+")(?=(\\s|/?>|$))","i"),new RegExp(dt.source+"\\s*$");function O(t,e,r,s){this.src=t,this.env=r,this.md=e,this.tokens=s,this.tokens_meta=Array(s.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}O.prototype.pushPending=function(){const t=new B("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t},O.prototype.push=function(t,e,r){this.pending&&this.pushPending();const s=new B(t,e,r);let u=null;return r<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),s.level=this.level,r>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],u={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(s),this.tokens_meta.push(u),s},O.prototype.scanDelims=function(t,e){const r=this.posMax,s=this.src.charCodeAt(t),u=t>0?this.src.charCodeAt(t-1):32;let i=t;for(;i<r&&this.src.charCodeAt(i)===s;)i++;const o=i-t,n=i<r?this.src.charCodeAt(i):32,a=J(u)||G(String.fromCharCode(u)),c=J(n)||G(String.fromCharCode(n)),h=q(u),D=q(n),b=!D&&(!c||h||a),m=!h&&(!a||D||c);return{can_open:b&&(e||!m||a),can_close:m&&(e||!b||c),length:o}},O.prototype.Token=B;const V=[];for(let t=0;t<256;t++)V.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t){V[t.charCodeAt(0)]=1});let g=function(t){return t.DOCUMENT="doc",t.HEADING="heading",t.PARAGRAPH="paragraph",t.QUOTE="blockquote",t.OL_LIST="ordered_list",t.UL_LIST="bullet_list",t.LIST_ITEM="list_item",t.CODE_BLOCK="code_block",t.HR="horizontal_rule",t.BR="hard_break",t.IMAGE="image",t.EMOJI="emoji",t.COMPONENT="blok",t.TABLE="table",t.TABLE_ROW="tableRow",t.TABLE_CELL="tableCell",t.TABLE_HEADER="tableHeader",t}({}),_=function(t){return t.BOLD="bold",t.STRONG="strong",t.STRIKE="strike",t.UNDERLINE="underline",t.ITALIC="italic",t.CODE="code",t.LINK="link",t.ANCHOR="anchor",t.STYLED="styled",t.SUPERSCRIPT="superscript",t.SUBSCRIPT="subscript",t.TEXT_STYLE="textStyle",t.HIGHLIGHT="highlight",t}({}),K=function(t){return t.TEXT="text",t}({}),I=function(t){return t.URL="url",t.STORY="story",t.ASSET="asset",t.EMAIL="email",t}({});function ft(t,e){if(!e)return{src:t,attrs:{}};let r=0,s=0;const u={},i=[];function o(a,c,h,D,b){typeof a!="number"||a<=c||a>=h?console.warn(`[StoryblokRichText] - ${D.charAt(0).toUpperCase()+D.slice(1)} value must be a number between ${c} and ${h} (inclusive)`):b.push(`${D}(${a})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(u.width=e.width,r=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(u.height=e.height,s=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(u.loading=e.loading),e.class&&(u.class=e.class),e.filters){const{filters:a}=e||{},{blur:c,brightness:h,fill:D,format:b,grayscale:m,quality:T,rotate:L}=a||{};c&&o(c,0,100,"blur",i),T&&o(T,0,100,"quality",i),h&&o(h,0,100,"brightness",i),D&&i.push(`fill(${D})`),m&&i.push("grayscale()"),L&&[0,90,180,270].includes(e.filters.rotate||0)&&i.push(`rotate(${L})`),b&&["webp","png","jpeg"].includes(b)&&i.push(`format(${b})`)}e.srcset&&(u.srcset=e.srcset.map(a=>{if(typeof a=="number")return`${t}/m/${a}x0/${i.length>0?`filters:${i.join(":")}`:""} ${a}w`;if(Array.isArray(a)&&a.length===2){const[c,h]=a;return`${t}/m/${c}x${h}/${i.length>0?`filters:${i.join(":")}`:""} ${c}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(u.sizes=e.sizes.join(", "))}let n=`${t}/m/`;return r>0&&s>0&&(n=`${n}${r}x${s}/`),i.length>0&&(n=`${n}filters:${i.join(":")}`),{src:n,attrs:u}}const Ft=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Et=(t={})=>Object.keys(t).map(e=>`${e}="${t[e]}"`).join(" "),pt=(t={})=>Object.keys(t).map(e=>`${e}: ${t[e]}`).join("; ");function Ct(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const N=t=>Object.fromEntries(Object.entries(t).filter(([e,r])=>r!==void 0));function Y(t,e={},r){const s=Et(e),u=s?`${t} ${s}`:t,i=Array.isArray(r)?r.join(""):r||"";if(t){if(Ft.includes(t))return`<${u}>`}else return i;return`<${u}>${i}</${t}>`}function W(t={}){const e=new Map,{renderFn:r=Y,textFn:s=Ct,resolvers:u={},optimizeImages:i=!1,keyedResolvers:o=!1}=t,n=r!==Y,a=l=>(f,d)=>{const F=f.attrs||{};return d.render(l,F,f.children||null)},c=(l,f)=>{const{src:d,alt:F,title:C,srcset:A,sizes:y}=l.attrs||{};let k=d,v={};if(i){const{src:Gt,attrs:Jt}=ft(d,i);k=Gt,v=Jt}const qt={src:k,alt:F,title:C,srcset:A,sizes:y,...v};return f.render("img",N(qt))},h=(l,f)=>{const{level:d,...F}=l.attrs||{};return f.render(`h${d}`,F,l.children)},D=(l,f)=>{var F,C,A,y;const d=f.render("img",{src:(F=l.attrs)==null?void 0:F.fallbackImage,alt:(C=l.attrs)==null?void 0:C.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return f.render("span",{"data-type":"emoji","data-name":(A=l.attrs)==null?void 0:A.name,"data-emoji":(y=l.attrs)==null?void 0:y.emoji},d)},b=(l,f)=>f.render("pre",l.attrs||{},f.render("code",{},l.children||"")),m=(l,f=!1)=>({text:d,attrs:F},C)=>{const{class:A,id:y,...k}=F||{},v=f?{class:A,id:y,style:pt(k)||void 0}:F||{};return C.render(l,N(v),d)},T=l=>z(l),L=l=>{const{marks:f,...d}=l;if("text"in l){if(f)return f.reduce((C,A)=>T({...A,text:C}),T({...d,children:d.children}));const F=l.attrs||{};if(o){const C=e.get("txt")||0;e.set("txt",C+1),F.key=`txt-${C}`}return s(d.text,F)}return""},ut=(l,f)=>{const{linktype:d,href:F,anchor:C,...A}=l.attrs||{};let y="";switch(d){case I.ASSET:case I.URL:y=F;break;case I.EMAIL:y=`mailto:${F}`;break;case I.STORY:y=F,C&&(y=`${y}#${C}`);break;default:y=F;break}const k={...A};return y&&(k.href=y),f.render("a",k,l.text)},$t=(l,f)=>{var d,F;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),f.render("span",{blok:(d=l==null?void 0:l.attrs)==null?void 0:d.body[0],id:(F=l.attrs)==null?void 0:F.id,style:"display: none"})},jt=(l,f)=>{const d={},F=f.render("tbody",{},l.children);return f.render("table",d,F)},Ht=(l,f)=>{const d={};return f.render("tr",d,l.children)},Mt=(l,f)=>{const{colspan:d,rowspan:F,colwidth:C,backgroundColor:A,...y}=l.attrs||{},k={...y};d>1&&(k.colspan=d),F>1&&(k.rowspan=F);const v=[];return C&&v.push(`width: ${C}px;`),A&&v.push(`background-color: ${A};`),v.length>0&&(k.style=v.join(" ")),f.render("td",N(k),l.children)},Ut=(l,f)=>{const{colspan:d,rowspan:F,colwidth:C,backgroundColor:A,...y}=l.attrs||{},k={...y};d>1&&(k.colspan=d),F>1&&(k.rowspan=F);const v=[];return C&&v.push(`width: ${C}px;`),A&&v.push(`background-color: ${A};`),v.length>0&&(k.style=v.join(" ")),f.render("th",N(k),l.children)},it=new Map([[g.DOCUMENT,a("")],[g.HEADING,h],[g.PARAGRAPH,a("p")],[g.UL_LIST,a("ul")],[g.OL_LIST,a("ol")],[g.LIST_ITEM,a("li")],[g.IMAGE,c],[g.EMOJI,D],[g.CODE_BLOCK,b],[g.HR,a("hr")],[g.BR,a("br")],[g.QUOTE,a("blockquote")],[g.COMPONENT,$t],[K.TEXT,L],[_.LINK,ut],[_.ANCHOR,ut],[_.STYLED,m("span",!0)],[_.BOLD,m("strong")],[_.TEXT_STYLE,m("span",!0)],[_.ITALIC,m("em")],[_.UNDERLINE,m("u")],[_.STRIKE,m("s")],[_.CODE,m("code")],[_.SUPERSCRIPT,m("sup")],[_.SUBSCRIPT,m("sub")],[_.HIGHLIGHT,m("mark")],[g.TABLE,jt],[g.TABLE_ROW,Ht],[g.TABLE_CELL,Mt],[g.TABLE_HEADER,Ut]]),nt=new Map([...it,...Object.entries(u).map(([l,f])=>[l,f])]),zt=()=>({render:(d,F={},C)=>{if(o&&d){const A=e.get(d)||0;e.set(d,A+1),F.key=`${d}-${A}`}return r(d,F,C)},originalResolvers:it,mergedResolvers:nt});function j(l){const f=nt.get(l.type);if(!f)return console.error("<Storyblok>",`No resolver found for node type ${l.type}`),"";const d=zt();if(l.type==="text")return f(l,d);const F=l.content?l.content.map(z):void 0;return f({...l,children:F},d)}function z(l){return l.type==="doc"?n?l.content.map(j):l.content.map(j).join(""):Array.isArray(l)?l.map(j):j(l)}return{render:z}}let Z=!1;const X=[],Q=t=>new Promise((e,r)=>{if(typeof window>"u"){r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=u=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}Z?u():X.push(u)},document.getElementById("storyblok-javascript-bridge")){e(void 0);return}const s=document.createElement("script");s.async=!0,s.src=t,s.id="storyblok-javascript-bridge",s.onerror=u=>r(u),s.onload=u=>{X.forEach(i=>i()),Z=!0,e(u)},document.getElementsByTagName("head")[0].appendChild(s)});var At=class extends Error{constructor(t){super(t),this.name="AbortError"}};function yt(t,e,r){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");const s=[];let u=[],i=0,o=!1;const n=async()=>{i++;const c=s.shift();if(c)try{const D=await t(...c.args);c.resolve(D)}catch(D){c.reject(D)}const h=setTimeout(()=>{i--,s.length>0&&n(),u=u.filter(D=>D!==h)},r);u.includes(h)||u.push(h)},a=(...c)=>o?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((h,D)=>{s.push({resolve:h,reject:D,args:c}),i<e&&n()});return a.abort=()=>{o=!0,u.forEach(clearTimeout),u=[],s.forEach(c=>c.reject(()=>new At("Throttle function aborted"))),s.length=0},a}var gt=yt;const tt=(t="")=>t.includes("/cdn/"),bt=(t,e=25,r=1)=>({...t,per_page:e,page:r}),kt=t=>new Promise(e=>setTimeout(e,t)),mt=(t=0,e)=>Array.from({length:t},e),vt=(t=0,e=t)=>{const r=Math.abs(e-t)||0,s=t<e?1:-1;return mt(r,(u,i)=>i*s+t)},xt=async(t,e)=>Promise.all(t.map(e)),_t=(t=[],e)=>t.map(e).reduce((r,s)=>[...r,...s],[]),H=(t,e,r)=>{const s=[];for(const u in t){if(!Object.prototype.hasOwnProperty.call(t,u))continue;const i=t[u];if(i==null)continue;const o=r?"":encodeURIComponent(u);let n;typeof i=="object"?n=H(i,e?e+encodeURIComponent(`[${o}]`):o,Array.isArray(i)):n=`${e?e+encodeURIComponent(`[${o}]`):o}=${encodeURIComponent(i)}`,s.push(n)}return s.join("&")},et=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 Bt=class{constructor(t){E(this,"baseURL");E(this,"timeout");E(this,"headers");E(this,"responseInterceptor");E(this,"fetch");E(this,"ejectInterceptor");E(this,"url");E(this,"parameters");E(this,"fetchOptions");this.baseURL=t.baseURL,this.headers=t.headers||new Headers,this.timeout=t!=null&&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=[],r={data:{},headers:{},status:0,statusText:""};t.status!==204&&await t.json().then(s=>{r.data=s});for(const s of t.headers.entries())e[s[0]]=s[1];return r.headers={...e},r.status=t.status,r.statusText=t.statusText,r}async _methodHandler(t){let e=`${this.baseURL}${this.url}`,r=null;t==="get"?e=`${this.baseURL}${this.url}?${H(this.parameters)}`:r=JSON.stringify(this.parameters);const s=new URL(e),u=new AbortController,{signal:i}=u;let o;this.timeout&&(o=setTimeout(()=>u.abort(),this.timeout));try{const n=await this.fetch(`${s}`,{method:t,headers:this.headers,body:r,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(o);const a=await this._responseHandler(n);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(a)):this._statusHandler(a)}catch(n){return{message:n}}}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((r,s)=>{if(e.test(`${t.status}`))return r(t);const u={message:this._normalizeErrorMessage(t.data),status:t.status,response:t};s(u)})}},wt=Bt;const st="SB-Agent",M={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"7.0.0"},Rt={PUBLISHED:"published"};let $={};const R={};var St=class{constructor(t,e){E(this,"client");E(this,"maxRetries");E(this,"retriesDelay");E(this,"throttle");E(this,"accessToken");E(this,"cache");E(this,"resolveCounter");E(this,"relations");E(this,"links");E(this,"version");E(this,"richTextResolver");E(this,"resolveNestedRelations");E(this,"stringifiedStoriesCache");E(this,"inlineAssets");let r=t.endpoint||e;if(!r){const i=t.https===!1?"http":"https";t.oauthToken?r=`${i}://${et(t.region)}/v1`:r=`${i}://${et(t.region)}/v2`}const s=new Headers;s.set("Content-Type","application/json"),s.set("Accept","application/json"),t.headers&&(t.headers.constructor.name==="Headers"?t.headers.entries().toArray():Object.entries(t.headers)).forEach(([o,n])=>{s.set(o,n)}),s.has(st)||(s.set(st,M.defaultAgentName),s.set(M.defaultAgentVersion,M.packageVersion));let u=5;t.oauthToken&&(s.set("Authorization",t.oauthToken),u=3),t.rateLimit&&(u=t.rateLimit),this.maxRetries=t.maxRetries||10,this.retriesDelay=300,this.throttle=gt(this.throttledRequest.bind(this),u,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||Rt.PUBLISHED,this.inlineAssets=t.inlineAssets||!1,this.client=new wt({baseURL:r,timeout:t.timeout||0,headers:s,responseInterceptor:t.responseInterceptor,fetch:t.fetch})}parseParams(t){return t.token||(t.token=this.getToken()),t.cv||(t.cv=R[t.token]),Array.isArray(t.resolve_relations)&&(t.resolve_relations=t.resolve_relations.join(",")),typeof t.resolve_relations<"u"&&(t.resolve_level=2),t}factoryParamOptions(t,e){return tt(t)?this.parseParams(e):e}makeRequest(t,e,r,s,u){const i=this.factoryParamOptions(t,bt(e,r,s));return this.cacheResponse(t,i,void 0,u)}get(t,e={},r){e||(e={});const s=`/${t}`;tt(s)&&(e.version=e.version||this.version);const u=this.factoryParamOptions(s,e);return this.cacheResponse(s,u,void 0,r)}async getAll(t,e={},r,s){const u=(e==null?void 0:e.per_page)||25,i=`/${t}`.replace(/\/$/,""),o=r??i.substring(i.lastIndexOf("/")+1);e.version=e.version||this.version;const n=1,a=await this.makeRequest(i,e,u,n,s),c=a.total?Math.ceil(a.total/(a.perPage||u)):1,h=await xt(vt(n,c),D=>this.makeRequest(i,e,u,D+1,s));return _t([a,...h],D=>Object.values(D.data[o]))}post(t,e={},r){const s=`/${t}`;return this.throttle("post",s,e,r)}put(t,e={},r){const s=`/${t}`;return this.throttle("put",s,e,r)}delete(t,e={},r){e||(e={});const s=`/${t}`;return this.throttle("delete",s,e,r)}getStories(t={},e){return this._addResolveLevel(t),this.get("cdn/stories",t,e)}getStory(t,e={},r){return this._addResolveLevel(e),this.get(`cdn/stories/${t}`,e,r)}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,r){const s=t[e];s&&s.fieldtype==="multilink"&&s.linktype==="story"&&typeof s.id=="string"&&this.links[r][s.id]?s.story=this._cleanCopy(this.links[r][s.id]):s&&s.linktype==="story"&&typeof s.uuid=="string"&&this.links[r][s.uuid]&&(s.story=this._cleanCopy(this.links[r][s.uuid]))}getStoryReference(t,e){return this.relations[t][e]?JSON.parse(this.stringifiedStoriesCache[e]||JSON.stringify(this.relations[t][e])):e}_resolveField(t,e,r){const s=t[e];typeof s=="string"?t[e]=this.getStoryReference(r,s):Array.isArray(s)&&(t[e]=s.map(u=>this.getStoryReference(r,u)).filter(Boolean))}_insertRelations(t,e,r,s){if(Array.isArray(r)?r.find(o=>o.endsWith(`.${e}`)):r.endsWith(`.${e}`)){this._resolveField(t,e,s);return}const i=t.component?`${t.component}.${e}`:e;(Array.isArray(r)?r.includes(i):r===i)&&this._resolveField(t,e,s)}iterateTree(t,e,r){const s=(u,i="")=>{if(!(!u||u._stopResolving)){if(Array.isArray(u))u.forEach((o,n)=>s(o,`${i}[${n}]`));else if(typeof u=="object")for(const o in u){const n=i?`${i}.${o}`:o;(u.component&&u._uid||u.type==="link")&&(this._insertRelations(u,o,e,r),this._insertLinks(u,o,r)),s(u[o],n)}}};s(t.content)}async resolveLinks(t,e,r){let s=[];if(t.link_uuids){const u=t.link_uuids.length,i=[],o=50;for(let n=0;n<u;n+=o){const a=Math.min(u,n+o);i.push(t.link_uuids.slice(n,a))}for(let n=0;n<i.length;n++)(await this.getStories({per_page:o,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:i[n].join(",")})).data.stories.forEach(c=>{s.push(c)})}else s=t.links;s.forEach(u=>{this.links[r][u.uuid]={...u,_stopResolving:!0}})}async resolveRelations(t,e,r){let s=[];if(t.rel_uuids){const u=t.rel_uuids.length,i=[],o=50;for(let n=0;n<u;n+=o){const a=Math.min(u,n+o);i.push(t.rel_uuids.slice(n,a))}for(let n=0;n<i.length;n++)(await this.getStories({per_page:o,language:e.language,version:e.version,starts_with:e.starts_with,by_uuids:i[n].join(","),excluding_fields:e.excluding_fields})).data.stories.forEach(c=>{s.push(c)});s.length>0&&(t.rels=s,delete t.rel_uuids)}else s=t.rels;s&&s.length>0&&s.forEach(u=>{this.relations[r][u.uuid]={...u,_stopResolving:!0}})}async resolveStories(t,e,r){var u,i;let s=[];if(this.links[r]={},this.relations[r]={},typeof e.resolve_relations<"u"&&e.resolve_relations.length>0&&(typeof e.resolve_relations=="string"&&(s=e.resolve_relations.split(",")),await this.resolveRelations(t,e,r)),e.resolve_links&&["1","story","url","link"].includes(e.resolve_links)&&((u=t.links)!=null&&u.length||(i=t.link_uuids)!=null&&i.length)&&await this.resolveLinks(t,e,r),this.resolveNestedRelations)for(const o in this.relations[r])this.iterateTree(this.relations[r][o],s,r);t.story?this.iterateTree(t.story,s,r):t.stories.forEach(o=>{this.iterateTree(o,s,r)}),this.stringifiedStoriesCache={},delete this.links[r],delete this.relations[r]}async cacheResponse(t,e,r,s){const u=H({url:t,params:e}),i=this.cacheProvider();if(e.version==="published"&&t!=="/cdn/spaces/me"){const o=await i.get(u);if(o)return Promise.resolve(o)}return new Promise(async(o,n)=>{var a;try{const c=await this.throttle("get",t,e,s);if(c.status!==200)return n(c);let h={data:c.data,headers:c.headers};if((a=c.headers)!=null&&a["per-page"]&&(h=Object.assign({},h,{perPage:c.headers["per-page"]?Number.parseInt(c.headers["per-page"]):0,total:c.headers["per-page"]?Number.parseInt(c.headers.total):0})),h.data.story||h.data.stories){const b=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(h.data,e,`${b}`),h=await this.processInlineAssets(h)}e.version==="published"&&t!=="/cdn/spaces/me"&&await i.set(u,h);const D=this.cache.clear==="onpreview"&&e.version==="draft"||this.cache.clear==="auto";return e.token&&h.data.cv&&(D&&R[e.token]&&R[e.token]!==h.data.cv&&await this.flushCache(),R[e.token]=h.data.cv),o(h)}catch(c){if(c.response&&c.status===429&&(r=typeof r>"u"?0:r+1,r<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await kt(this.retriesDelay),this.cacheResponse(t,e,r).then(o).catch(n);n(c)}})}throttledRequest(t,e,r,s){return this.client.setFetchOptions(s),this.client[t](e,r)}cacheVersions(){return R}cacheVersion(){return R[this.accessToken]}setCacheVersion(t){this.accessToken&&(R[this.accessToken]=t)}clearCacheVersion(){this.accessToken&&(R[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(t){return Promise.resolve($[t])},getAll(){return Promise.resolve($)},set(t,e){return $[t]=e,Promise.resolve(void 0)},flush(){return $={},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=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(u=>e(u));let s={...r};s.fieldtype==="asset"&&Array.isArray(t.data.assets)&&(s={...s,...t.data.assets.find(u=>u.id===s.id)});for(const u in s)typeof s[u]=="object"&&(s[u]=e(s[u]));return s};return t.data.story&&(t.data.story.content=e(t.data.story.content)),t.data.stories&&(t.data.stories=t.data.stories.map(r=>(r.content=e(r.content),r))),t}},Tt=St;const Lt=(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 Tt(e)}},Pt=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 U="https://app.storyblok.com/f/storyblok-v2-latest.js";const rt=(t,e,r={})=>{var n;const u=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",i=new URL((n=window.location)==null?void 0:n.href).searchParams.get("_storyblok"),o=i!==null&&+i===t;if(!(!u||!o)){if(!t){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(r).on(["input","published","change"],c=>{var h;c&&(c.action==="input"&&((h=c.story)==null?void 0:h.id)===t?e(c.story):(c.action==="change"||c.action==="published")&&c.storyId===t&&window.location.reload())})})}},Ot=(t={})=>{var h,D;const{bridge:e,accessToken:r,use:s=[],apiOptions:u={},bridgeUrl:i}=t;u.accessToken=u.accessToken||r;const o={bridge:e,apiOptions:u};let n={};s.forEach(b=>{n={...n,...b(o)}}),i&&(U=i);const c=!(typeof window>"u")&&((D=(h=window.location)==null?void 0:h.search)==null?void 0:D.includes("_storyblok_tk"));return e!==!1&&c&&Q(U),n};function It(t,e){return W(e).render(t)}const Nt=()=>Q(U);p.BlockTypes=g,p.MarkTypes=_,p.TextTypes=K,p.apiPlugin=Lt,p.loadStoryblokBridge=Nt,p.registerStoryblokBridge=rt,p.renderRichText=It,p.richTextResolver=W,p.storyblokEditable=Pt,p.storyblokInit=Ot,p.useStoryblokBridge=rt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|